From: Florian Forster Date: Sun, 13 Jun 2010 13:33:39 +0000 (+0200) Subject: src/utils_threshold.[ch]: Use "cf_util_get_flag" for config handling. X-Git-Tag: collectd-5.0.0-beta0~109 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=72d9c1553333dc4d6102d2a2f55d81b2c1672a8d;p=collectd.git src/utils_threshold.[ch]: Use "cf_util_get_flag" for config handling. --- diff --git a/src/utils_threshold.c b/src/utils_threshold.c index e387cbf7..99309b93 100644 --- a/src/utils_threshold.c +++ b/src/utils_threshold.c @@ -218,78 +218,6 @@ static int ut_config_type_min (threshold_t *th, oconfig_item_t *ci) return (0); } /* int ut_config_type_min */ -static int ut_config_type_interesting (threshold_t *th, oconfig_item_t *ci) -{ - if ((ci->values_num != 1) - || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) - { - WARNING ("threshold values: The `Interesting' option needs exactly one " - "boolean argument."); - return (-1); - } - - if (ci->values[0].value.boolean) - th->flags |= UT_FLAG_INTERESTING; - else - th->flags &= ~UT_FLAG_INTERESTING; - - return (0); -} /* int ut_config_type_interesting */ - -static int ut_config_type_invert (threshold_t *th, oconfig_item_t *ci) -{ - if ((ci->values_num != 1) - || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) - { - WARNING ("threshold values: The `Invert' option needs exactly one " - "boolean argument."); - return (-1); - } - - if (ci->values[0].value.boolean) - th->flags |= UT_FLAG_INVERT; - else - th->flags &= ~UT_FLAG_INVERT; - - return (0); -} /* int ut_config_type_invert */ - -static int ut_config_type_persist (threshold_t *th, oconfig_item_t *ci) -{ - if ((ci->values_num != 1) - || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) - { - WARNING ("threshold values: The `Persist' option needs exactly one " - "boolean argument."); - return (-1); - } - - if (ci->values[0].value.boolean) - th->flags |= UT_FLAG_PERSIST; - else - th->flags &= ~UT_FLAG_PERSIST; - - return (0); -} /* int ut_config_type_persist */ - -static int ut_config_type_percentage(threshold_t *th, oconfig_item_t *ci) -{ - if ((ci->values_num != 1) - || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) - { - WARNING ("threshold values: The `Percentage' option needs exactly one " - "boolean argument."); - return (-1); - } - - if (ci->values[0].value.boolean) - th->flags |= UT_FLAG_PERCENTAGE; - else - th->flags &= ~UT_FLAG_PERCENTAGE; - - return (0); -} /* int ut_config_type_percentage */ - static int ut_config_type_hits (threshold_t *th, oconfig_item_t *ci) { if ((ci->values_num != 1) @@ -367,13 +295,13 @@ static int ut_config_type (const threshold_t *th_orig, oconfig_item_t *ci) || (strcasecmp ("FailureMin", option->key) == 0)) status = ut_config_type_min (&th, option); else if (strcasecmp ("Interesting", option->key) == 0) - status = ut_config_type_interesting (&th, option); + status = cf_util_get_flag (option, &th.flags, UT_FLAG_INTERESTING); else if (strcasecmp ("Invert", option->key) == 0) - status = ut_config_type_invert (&th, option); + status = cf_util_get_flag (option, &th.flags, UT_FLAG_INVERT); else if (strcasecmp ("Persist", option->key) == 0) - status = ut_config_type_persist (&th, option); + status = cf_util_get_flag (option, &th.flags, UT_FLAG_PERSIST); else if (strcasecmp ("Percentage", option->key) == 0) - status = ut_config_type_percentage (&th, option); + status = cf_util_get_flag (option, &th.flags, UT_FLAG_PERCENTAGE); else if (strcasecmp ("Hits", option->key) == 0) status = ut_config_type_hits (&th, option); else if (strcasecmp ("Hysteresis", option->key) == 0) diff --git a/src/utils_threshold.h b/src/utils_threshold.h index 8aaf34c6..5955ca6e 100644 --- a/src/utils_threshold.h +++ b/src/utils_threshold.h @@ -39,7 +39,7 @@ typedef struct threshold_s gauge_t failure_min; gauge_t failure_max; gauge_t hysteresis; - int flags; + unsigned int flags; int hits; struct threshold_s *next; } threshold_t;