From bd427117a36715cc602e85869cd7d6db6415a945 Mon Sep 17 00:00:00 2001 From: Gediminas Jakutis Date: Sun, 19 May 2019 16:15:11 +0300 Subject: daemon: handle the daemonize flag now. The flag is now successfully read from the config file and is honored. Logic does not handle leading or trailing whitespace yet. Signed-off-by: Gediminas Jakutis --- src/daemon/settings.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/daemon/settings.c') diff --git a/src/daemon/settings.c b/src/daemon/settings.c index acbf40d..355fe1d 100644 --- a/src/daemon/settings.c +++ b/src/daemon/settings.c @@ -129,8 +129,33 @@ static int setting_readconf(const char * const path) /* TODO: stub! */ static int setting_handle_config_entry(const char * const entry, const char * const value) { - printf( "key: %s\n" - "value: %s\n", entry, value); + size_t i; - return 0; + for (i = 0; i < sizeof(ent_table)/sizeof(*ent_table); ++i) { + if (!(strcmp(entry, ent_table[i].name))) { + ent_table[0].set(value); + return 0; + } + } + + return 1; +} + +static void set_daemonize(const void * const arg) +{ + const char * const a = arg; + + atoi(a) ? set_flag(flag_daemonize) : unset_flag(flag_daemonize); +} + +/* TODO: stub! */ +static void set_port(const void * const arg) +{ + (void) arg; +} + +/* TODO: stub! */ +static void set_verbosity(const void * const arg) +{ + (void) arg; } -- cgit v1.2.3