diff options
author | 2019-03-31 04:16:24 +0300 | |
---|---|---|
committer | 2019-04-01 16:04:11 +0300 | |
commit | bb736d606a28d4ab7d6d8d9f939c003fdf273274 (patch) | |
tree | ee7d224502e2c333b545de4a65d6117aaadfad98 /src/daemon/settings.c | |
parent | de18684a25cdc1e310636c5f74d4e901881b5710 (diff) | |
download | usurpation-bb736d606a28d4ab7d6d8d9f939c003fdf273274.tar.gz usurpation-bb736d606a28d4ab7d6d8d9f939c003fdf273274.tar.bz2 usurpation-bb736d606a28d4ab7d6d8d9f939c003fdf273274.zip |
daemon: employ a flags settings variable.
We now have a settings variable for holding various flags.
Turn the daemonize setting to a flag.
NOTE: the project should not have compiled since commit
de18684a25cdc1e310636c5f74d4e901881b5710
but due to some unexplained circumstances, no pre-commit
build testing failed.
This have been fixed.
This commit closes Ticket 25.
Signed-off-by: Gediminas Jakutis <gediminas@varciai.lt>
Diffstat (limited to 'src/daemon/settings.c')
-rw-r--r-- | src/daemon/settings.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/daemon/settings.c b/src/daemon/settings.c index 3777f23..9c4011f 100644 --- a/src/daemon/settings.c +++ b/src/daemon/settings.c @@ -19,11 +19,7 @@ */ #include "settings.h" - -static struct settings { - int daemonize; - unsigned short int port; -} settings; +#include "settings_private.h" /* TODO: should be, in this order: looking at options provided via command * line arguments, looking at at /etc/conf.d/usurpation.conf or @@ -31,16 +27,37 @@ static struct settings { */ void settings_init(void) { - settings.daemonize =0; - settings.port = 6996 + unset_flag(flag_daemonize); + settings.port = 6996; } int setting_detach(void) { - return settings.daemonize; + return test_flag(flag_daemonize); } unsigned short int setting_port(void) { return settings.port; } + +/* could be a one-liner, but let's make the logic more obvious */ +int test_flag(unsigned int flag) +{ + int ret; + + ret = settings.flags & flag; + ret = !!ret; + + return ret; +} + +void set_flag(unsigned int flag) +{ + settings.flags |= flag; +} + +void unset_flag(unsigned int flag) +{ + settings.flags &= ~flag; +} |