summaryrefslogtreecommitdiffstats
path: root/src/daemon/settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/settings.c')
-rw-r--r--src/daemon/settings.c33
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;
+}