From: Florian Forster Date: Fri, 25 Dec 2009 10:13:19 +0000 (+0100) Subject: filecount plugin: Simplify config handling. X-Git-Tag: collectd-4.10.0~81 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=856a68d51bae3f76f54b7b056e83ca8801223d90;p=collectd.git filecount plugin: Simplify config handling. --- diff --git a/src/filecount.c b/src/filecount.c index dc242ada..9f6ea564 100644 --- a/src/filecount.c +++ b/src/filecount.c @@ -311,8 +311,8 @@ static int fc_config_add_dir_size (fc_directory_conf_t *dir, return (0); } /* int fc_config_add_dir_size */ -static int fc_config_add_dir_recursive (fc_directory_conf_t *dir, - oconfig_item_t *ci) +static int fc_config_add_dir_option (fc_directory_conf_t *dir, + oconfig_item_t *ci, int bit) { if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) @@ -323,31 +323,12 @@ static int fc_config_add_dir_recursive (fc_directory_conf_t *dir, } if (ci->values[0].value.boolean) - dir->options |= FC_RECURSIVE; - else - dir->options &= ~FC_RECURSIVE; - - return (0); -} /* int fc_config_add_dir_recursive */ - -static int fc_config_add_dir_hidden (fc_directory_conf_t *dir, - oconfig_item_t *ci) -{ - if ((ci->values_num != 1) - || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) - { - WARNING ("filecount plugin: The `Hidden' config options needs exactly " - "one boolean argument."); - return (-1); - } - - if (ci->values[0].value.boolean) - dir->options |= FC_HIDDEN; + dir->options |= bit; else - dir->options &= ~FC_HIDDEN; + dir->options &= ~bit; return (0); -} /* int fc_config_add_dir_hidden */ +} /* int fc_config_add_dir_option */ static int fc_config_add_dir (oconfig_item_t *ci) { @@ -400,9 +381,9 @@ static int fc_config_add_dir (oconfig_item_t *ci) else if (strcasecmp ("Size", option->key) == 0) status = fc_config_add_dir_size (dir, option); else if (strcasecmp ("Recursive", option->key) == 0) - status = fc_config_add_dir_recursive (dir, option); - else if (strcasecmp ("Hidden", option->key) == 0) - status = fc_config_add_dir_hidden (dir, option); + status = fc_config_add_dir_option (dir, option, FC_RECURSIVE); + else if (strcasecmp ("IncludeHidden", option->key) == 0) + status = fc_config_add_dir_option (dir, option, FC_HIDDEN); else { WARNING ("filecount plugin: fc_config_add_dir: "