From: Martin Johansson Date: Thu, 6 Oct 2011 13:52:07 +0000 (-0400) Subject: Added channel password to config file. X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;h=ddc0e8af6bbcb1f7635ea78297c5158611821aec;p=umurmur.git Added channel password to config file. Added configuration test function. --- diff --git a/src/conf.c b/src/conf.c index 38b3285..2873a9e 100644 --- a/src/conf.c +++ b/src/conf.c @@ -58,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); @@ -234,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 */ diff --git a/src/conf.h b/src/conf.h index 32531f8..67d02c6 100644 --- a/src/conf.h +++ b/src/conf.h @@ -54,6 +54,7 @@ typedef struct { const char *parent; const char *name; const char *description; + const char *password; bool_t noenter; } conf_channel_t; @@ -64,6 +65,7 @@ typedef struct { void Conf_init(const char *conffile); void Conf_deinit(); +void Conf_test(const char *conffile); const char *getStrConf(param_t param); int getIntConf(param_t param);