X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fconf.c;h=2873a9e40e7d5bd6da75a2ee9137b6d1f34b5919;hb=ddc0e8af6bbcb1f7635ea78297c5158611821aec;hp=35926473f9cbd81faffc24964a335e1801ca7b5d;hpb=454ad122eb158b4391e2690fe6a7e127d24c525b;p=umurmur.git diff --git a/src/conf.c b/src/conf.c index 3592647..2873a9e 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1,5 +1,5 @@ -/* Copyright (C) 2009-2010, Martin Johansson - Copyright (C) 2005-2010, Thorvald Natvig +/* Copyright (C) 2009-2011, Martin Johansson + Copyright (C) 2005-2011, Thorvald Natvig All rights reserved. @@ -40,7 +40,6 @@ static config_t configuration; -#define DEFAULT_CONFIG "/etc/umurmur.conf" #define DEFAULT_WELCOME "Welcome to uMurmur!" #define DEFAULT_MAX_CLIENTS 10 #define DEFAULT_MAX_BANDWIDTH 48000 @@ -59,6 +58,18 @@ void Conf_init(const char *conffile) } } +void Conf_test(const char *conffile) +{ + config_init(&configuration); + if (conffile == NULL) + conffile = defaultconfig; + if (config_read_file(&configuration, conffile) != CONFIG_TRUE) { + fprintf(stderr, "Error in config file %s line %d: %s", conffile, + config_error_line(&configuration), config_error_text(&configuration)); + exit(1); + } +} + void Conf_deinit() { config_destroy(&configuration); @@ -158,6 +169,17 @@ const char *getStrConf(param_t param) return ""; } break; + case LOGFILE: + setting = config_lookup(&configuration, "logfile"); + if (!setting) + return NULL; + else { + if ((strsetting = config_setting_get_string(setting)) != NULL) + return strsetting; + else + return NULL; + } + break; default: doAssert(false); break; @@ -224,6 +246,13 @@ int Conf_getNextChannel(conf_channel_t *chdesc, int index) else chdesc->description = config_setting_get_string(setting); + ret = snprintf(configstr, maxconfig, "channels.[%d].password", index); + setting = config_lookup(&configuration, configstr); + if (ret >= maxconfig || ret < 0 || setting == NULL) /* Optional */ + chdesc->password = NULL; + else + chdesc->password = config_setting_get_string(setting); + ret = snprintf(configstr, maxconfig, "channels.[%d].noenter", index); setting = config_lookup(&configuration, configstr); if (ret >= maxconfig || ret < 0 || setting == NULL) /* Optional */