X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fconfigfile.c;h=4b6803ed68a398cbdff4881ad9e599b2ad9d3639;hb=34d1c751c009bed32c59d45ad1d71d73a787c6f5;hp=3cc0379ba7aa82e420d2b350647277576a250eba;hpb=838af4cdc6c8674ed3e14a95fea172118c707a85;p=collectd.git diff --git a/src/configfile.c b/src/configfile.c index 3cc0379b..4b6803ed 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -27,7 +27,6 @@ #include "common.h" #include "plugin.h" #include "configfile.h" -#include "network.h" #define ESCAPE_NULL(str) ((str) == NULL ? "(null)" : (str)) @@ -77,10 +76,11 @@ static int cf_value_map_num = STATIC_ARRAY_LEN (cf_value_map); static cf_global_option_t cf_global_options[] = { {"BaseDir", NULL, PKGLOCALSTATEDIR}, - {"LogFile", NULL, LOGFILE}, {"PIDFile", NULL, PIDFILE}, {"Hostname", NULL, NULL}, - {"Interval", NULL, "10"} + {"Interval", NULL, "10"}, + {"ReadThreads", NULL, "5"}, + {"TypesDB", NULL, PLUGINDIR"/types.db"} /* FIXME: Configure path */ }; static int cf_global_options_num = STATIC_ARRAY_LEN (cf_global_options); @@ -156,11 +156,18 @@ static int dispatch_global_option (const oconfig_item_t *ci) { if (ci->values_num != 1) return (-1); - if (ci->values[0].type != OCONFIG_TYPE_STRING) - return (-1); + if (ci->values[0].type == OCONFIG_TYPE_STRING) + return (global_option_set (ci->key, ci->values[0].value.string)); + else if (ci->values[0].type == OCONFIG_TYPE_NUMBER) + { + char tmp[128]; + snprintf (tmp, sizeof (tmp), "%lf", ci->values[0].value.number); + tmp[127] = '\0'; + return (global_option_set (ci->key, tmp)); + } - return (global_option_set (ci->key, ci->values[0].value.string)); -} + return (-1); +} /* int dispatch_global_option */ static int dispatch_value_plugindir (const oconfig_item_t *ci) { @@ -295,8 +302,7 @@ int global_option_set (const char *option, const char *value) if (i >= cf_global_options_num) return (-1); - if (cf_global_options[i].value != NULL) - free (cf_global_options[i].value); + sfree (cf_global_options[i].value); if (value != NULL) cf_global_options[i].value = strdup (value); @@ -339,7 +345,7 @@ void cf_unregister (const char *type) free (this); break; } -} +} /* void cf_unregister */ void cf_register (const char *type, int (*callback) (const char *, const char *),