Add option 'noenter' to channel configuration and implement support.
[umurmur.git] / src / conf.c
index 63e209c285e57c28046e87934073432af10dae75..a9d2c08e88d030429e637d5ae82c408260da2439 100644 (file)
@@ -1,5 +1,5 @@
-/* Copyright (C) 2009, Martin Johansson <martin@fatbob.nu>
-   Copyright (C) 2005-2009, Thorvald Natvig <thorvald@natvig.com>
+/* Copyright (C) 2009-2010, Martin Johansson <martin@fatbob.nu>
+   Copyright (C) 2005-2010, Thorvald Natvig <thorvald@natvig.com>
 
    All rights reserved.
 
@@ -47,7 +47,7 @@ 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 5000
+#define DEFAULT_MAX_BANDWIDTH 48000
 #define DEFAULT_BINDPORT 64738
 
 const char defaultconfig[] = DEFAULT_CONFIG;
@@ -195,20 +195,28 @@ int Conf_getNextChannel(conf_channel_t *chdesc, int index)
        sprintf(configstr, "channels.[%d].name", index);
        setting = config_lookup(&configuration, configstr);
        if (setting == NULL)
-               return -1;
+               return -1; /* Required */
        strncpy(chdesc->name, config_setting_get_string(setting), MAX_TEXT);
        
        sprintf(configstr, "channels.[%d].parent", index);
        setting = config_lookup(&configuration, configstr);
        if (setting == NULL)
-               return -1;
+               return -1; /* Required */
        strncpy(chdesc->parent, config_setting_get_string(setting), MAX_TEXT);
        
        sprintf(configstr, "channels.[%d].description", index);
        setting = config_lookup(&configuration, configstr);
-       if (setting == NULL)
-               return -1;
-       strncpy(chdesc->description, config_setting_get_string(setting), MAX_TEXT);
+       if (setting == NULL) /* Optional */
+               strncpy(chdesc->description, "", MAX_TEXT);
+       else
+               strncpy(chdesc->description, config_setting_get_string(setting), MAX_TEXT);
+       
+       sprintf(configstr, "channels.[%d].noenter", index);
+       setting = config_lookup(&configuration, configstr);
+       if (setting == NULL) /* Optional */
+               chdesc->noenter = false;
+       else
+               chdesc->noenter = config_setting_get_bool(setting);
 
        return 0;
 }