X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Fconfigfile.c;h=654cc49b9b408108b174fe24020dc3fe3d4a6d32;hb=fb0cc621d4357bbe4a9dc36c7f055f46257ce57c;hp=d5f01e077937934b39b046a4829ec928da9e0c50;hpb=936c450a86c841eea89888c8550c9118fae90c25;p=collectd.git diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index d5f01e07..654cc49b 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -245,7 +245,7 @@ static int dispatch_value_plugindir(oconfig_item_t *ci) { static int dispatch_loadplugin(oconfig_item_t *ci) { const char *name; - unsigned int flags = 0; + _Bool global = 0; plugin_ctx_t ctx = {0}; plugin_ctx_t old_ctx; int ret_val; @@ -270,7 +270,7 @@ static int dispatch_loadplugin(oconfig_item_t *ci) { oconfig_item_t *child = ci->children + i; if (strcasecmp("Globals", child->key) == 0) - cf_util_get_flag(child, &flags, PLUGIN_FLAGS_GLOBAL); + cf_util_get_boolean(child, &global); else if (strcasecmp("Interval", child->key) == 0) cf_util_get_cdtime(child, &ctx.interval); else if (strcasecmp("FlushInterval", child->key) == 0) @@ -285,7 +285,7 @@ static int dispatch_loadplugin(oconfig_item_t *ci) { } old_ctx = plugin_set_ctx(ctx); - ret_val = plugin_load(name, (uint32_t)flags); + ret_val = plugin_load(name, global); /* reset to the "global" context */ plugin_set_ctx(old_ctx); @@ -1119,14 +1119,36 @@ int cf_util_get_boolean(const oconfig_item_t *ci, _Bool *ret_bool) /* {{{ */ if ((ci == NULL) || (ret_bool == NULL)) return (EINVAL); - if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) { + if ((ci->values_num != 1) || ((ci->values[0].type != OCONFIG_TYPE_BOOLEAN) && + (ci->values[0].type != OCONFIG_TYPE_STRING))) { ERROR("cf_util_get_boolean: The %s option requires " "exactly one boolean argument.", ci->key); return (-1); } - *ret_bool = ci->values[0].value.boolean ? 1 : 0; + switch (ci->values[0].type) { + case OCONFIG_TYPE_BOOLEAN: + *ret_bool = ci->values[0].value.boolean ? 1 : 0; + break; + case OCONFIG_TYPE_STRING: + WARNING("cf_util_get_boolean: Using string value `%s' for boolean option " + "`%s' is deprecated and will be removed in future releases. " + "Use unquoted true or false instead.", + ci->values[0].value.string, ci->key); + + if (IS_TRUE(ci->values[0].value.string)) + *ret_bool = 1; + else if (IS_FALSE(ci->values[0].value.string)) + *ret_bool = 0; + else { + ERROR("cf_util_get_boolean: Cannot parse string value `%s' of the `%s' " + "option as a boolean value.", + ci->values[0].value.string, ci->key); + return (-1); + } + break; + } return (0); } /* }}} int cf_util_get_boolean */