Convert logical booleans in client_config_t to bool type.
This commit is contained in:
parent
571b22c4b2
commit
c38fd2be9b
14
src/cfg.rl
14
src/cfg.rl
@ -50,11 +50,11 @@ struct cfgparse {
|
||||
action background {
|
||||
switch (ccfg.ternary) {
|
||||
case 1:
|
||||
client_config.background_if_no_lease = 1;
|
||||
client_config.background_if_no_lease = true;
|
||||
gflags_detach = 1;
|
||||
break;
|
||||
case -1:
|
||||
client_config.background_if_no_lease = 0;
|
||||
client_config.background_if_no_lease = false;
|
||||
gflags_detach = 0;
|
||||
default:
|
||||
break;
|
||||
@ -74,14 +74,14 @@ struct cfgparse {
|
||||
}
|
||||
action now {
|
||||
switch (ccfg.ternary) {
|
||||
case 1: client_config.abort_if_no_lease = 1; break;
|
||||
case -1: client_config.abort_if_no_lease = 0; default: break;
|
||||
case 1: client_config.abort_if_no_lease = true; break;
|
||||
case -1: client_config.abort_if_no_lease = false; default: break;
|
||||
}
|
||||
}
|
||||
action quit {
|
||||
switch (ccfg.ternary) {
|
||||
case 1: client_config.quit_after_lease = 1; break;
|
||||
case -1: client_config.quit_after_lease = 0; default: break;
|
||||
case 1: client_config.quit_after_lease = true; break;
|
||||
case -1: client_config.quit_after_lease = false; default: break;
|
||||
}
|
||||
}
|
||||
action request { set_client_addr(ccfg.buf); }
|
||||
@ -171,7 +171,7 @@ struct cfgparse {
|
||||
action rfkill_idx {
|
||||
uint32_t t = atoi(ccfg.buf);
|
||||
client_config.rfkillIdx = t;
|
||||
client_config.enable_rfkill = 1;
|
||||
client_config.enable_rfkill = true;
|
||||
}
|
||||
action version { print_version(); exit(EXIT_SUCCESS); }
|
||||
action help { show_usage(); exit(EXIT_SUCCESS); }
|
||||
|
@ -92,7 +92,7 @@ struct client_config_t client_config = {
|
||||
.arp = "\0\0\0\0\0\0",
|
||||
.clientid_len = 0,
|
||||
.metric = 0,
|
||||
.foreground = 1,
|
||||
.foreground = true,
|
||||
};
|
||||
|
||||
void set_client_addr(const char v[static 1]) { cs.clientAddr = inet_addr(v); }
|
||||
|
10
src/ndhc.h
10
src/ndhc.h
@ -50,11 +50,11 @@ struct client_state_t {
|
||||
};
|
||||
|
||||
struct client_config_t {
|
||||
char foreground; // Do not fork
|
||||
char quit_after_lease; // Quit after obtaining lease
|
||||
char abort_if_no_lease; // Abort if no lease
|
||||
char background_if_no_lease; // Fork to background if no lease
|
||||
char enable_rfkill; // Listen for rfkill events
|
||||
bool foreground; // Do not fork
|
||||
bool quit_after_lease; // Quit after obtaining lease
|
||||
bool abort_if_no_lease; // Abort if no lease
|
||||
bool background_if_no_lease; // Fork to background if no lease
|
||||
bool enable_rfkill; // Listen for rfkill events
|
||||
char interface[IFNAMSIZ]; // The name of the interface to use
|
||||
char clientid[64]; // Optional client id to use
|
||||
uint8_t clientid_len; // Length of the clientid
|
||||
|
@ -37,13 +37,13 @@
|
||||
#include "ndhc.h"
|
||||
#include "rfkill.h"
|
||||
|
||||
int rfkill_open(char enable_rfkill[static 1])
|
||||
int rfkill_open(bool enable_rfkill[static 1])
|
||||
{
|
||||
if (!*enable_rfkill)
|
||||
return -1;
|
||||
int r = open("/dev/rfkill", O_RDONLY|O_CLOEXEC|O_NONBLOCK);
|
||||
if (r < 0) {
|
||||
*enable_rfkill = 0;
|
||||
*enable_rfkill = false;
|
||||
log_line("rfkill disabled: could not open /dev/rfkill: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ enum {
|
||||
RFK_DISABLED,
|
||||
};
|
||||
|
||||
int rfkill_open(char enable_rfkill[static 1]);
|
||||
int rfkill_open(bool enable_rfkill[static 1]);
|
||||
int rfkill_get(struct client_state_t cs[static 1],
|
||||
int check_idx, uint32_t rfkidx);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user