Added channel password to config file.
authorMartin Johansson <martin@fatbob.nu>
Thu, 6 Oct 2011 13:52:07 +0000 (09:52 -0400)
committerMartin Johansson <martin@fatbob.nu>
Thu, 6 Oct 2011 13:52:07 +0000 (09:52 -0400)
Added configuration test function.

src/conf.c
src/conf.h

index 38b32852775c1727ffbd4c045515294a42c4f611..2873a9e40e7d5bd6da75a2ee9137b6d1f34b5919 100644 (file)
@@ -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 */
index 32531f8653ed2874322a36802fc09f826aae0d9f..67d02c689808ad672eac5d37bcad6aca06ae116b 100644 (file)
@@ -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);