Merge branch 'st/python'
[collectd.git] / src / configfile.c
index 79ad9f6..b2997d6 100644 (file)
@@ -943,7 +943,7 @@ int cf_util_get_string (const oconfig_item_t *ci, char **ret_string) /* {{{ */
 
        if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
        {
-               ERROR ("cf_util_get_string: The %s plugin requires "
+               ERROR ("cf_util_get_string: The %s option requires "
                                "exactly one string argument.", ci->key);
                return (-1);
        }
@@ -959,6 +959,23 @@ int cf_util_get_string (const oconfig_item_t *ci, char **ret_string) /* {{{ */
        return (0);
 } /* }}} int cf_util_get_string */
 
+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))
+       {
+               ERROR ("cf_util_get_boolean: The %s option requires "
+                               "exactly one string argument.", ci->key);
+               return (-1);
+       }
+
+       *ret_bool = ci->values[0].value.boolean ? true : false;
+
+       return (0);
+} /* }}} int cf_util_get_boolean */
+
 /* Assures that the config option is a string. The string is then converted to
  * a port number using `service_name_to_port_number' and returned. Returns the
  * port number in the range [1-65535] or less than zero upon failure. */
@@ -966,7 +983,7 @@ int cf_util_get_port_number (const oconfig_item_t *ci) /* {{{ */
 {
        if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
        {
-               ERROR ("cf_util_get_port_number: The %s plugin requires "
+               ERROR ("cf_util_get_port_number: The %s option requires "
                                "exactly one string argument.", ci->key);
                return (-1);
        }