X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fdaemon%2Fconfigfile.c;h=654cc49b9b408108b174fe24020dc3fe3d4a6d32;hp=b57aadc8500084d5b23b1a92f1644076179ccc2e;hb=786a6be461cf58ef2b8c57974cad2a79ba2ee82c;hpb=7269bf71e30f0a70a9eb954f6b0a6fe1b10eb6e5 diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index b57aadc8..654cc49b 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -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 */