X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftail.c;h=5b9dc53988c46440c839878253385dd097f8d3ad;hb=d09ec85d1584a7a0649a240b78f1390ff1296814;hp=25cbcd4c1b5188df787e843c60aecb895aad5688;hpb=c15dbfc3739f7c3bbd8171797eaef55749008bfa;p=collectd.git diff --git a/src/tail.c b/src/tail.c index 25cbcd4c..5b9dc539 100644 --- a/src/tail.c +++ b/src/tail.c @@ -52,22 +52,6 @@ typedef struct ctail_config_match_s ctail_config_match_t; cu_tail_match_t **tail_match_list = NULL; size_t tail_match_list_num = 0; -static int ctail_config_add_string (const char *name, char **dest, oconfig_item_t *ci) -{ - if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) - { - WARNING ("tail plugin: `%s' needs exactly one string argument.", name); - return (-1); - } - - sfree (*dest); - *dest = strdup (ci->values[0].value.string); - if (*dest == NULL) - return (-1); - - return (0); -} /* int ctail_config_add_string */ - static int ctail_config_add_match_dstype (ctail_config_match_t *cm, oconfig_item_t *ci) { @@ -158,16 +142,15 @@ static int ctail_config_add_match (cu_tail_match_t *tm, oconfig_item_t *option = ci->children + i; if (strcasecmp ("Regex", option->key) == 0) - status = ctail_config_add_string ("Regex", &cm.regex, option); + status = cf_util_get_string (option, &cm.regex); else if (strcasecmp ("ExcludeRegex", option->key) == 0) - status = ctail_config_add_string ("ExcludeRegex", &cm.excluderegex, - option); + status = cf_util_get_string (option, &cm.excluderegex); else if (strcasecmp ("DSType", option->key) == 0) status = ctail_config_add_match_dstype (&cm, option); else if (strcasecmp ("Type", option->key) == 0) - status = ctail_config_add_string ("Type", &cm.type, option); + status = cf_util_get_string (option, &cm.type); else if (strcasecmp ("Instance", option->key) == 0) - status = ctail_config_add_string ("Instance", &cm.type_instance, option); + status = cf_util_get_string (option, &cm.type_instance); else { WARNING ("tail plugin: Option `%s' not allowed here.", option->key); @@ -228,7 +211,6 @@ static int ctail_config_add_file (oconfig_item_t *ci) cu_tail_match_t *tm; char *plugin_instance = NULL; int num_matches = 0; - int status; int i; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) @@ -245,10 +227,10 @@ static int ctail_config_add_file (oconfig_item_t *ci) return (-1); } - status = 0; for (i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; + int status; if (strcasecmp ("Match", option->key) == 0) { @@ -259,7 +241,7 @@ static int ctail_config_add_file (oconfig_item_t *ci) status = 0; } else if (strcasecmp ("Instance", option->key) == 0) - status = ctail_config_add_string ("Instance", &plugin_instance, option); + status = cf_util_get_string (option, &plugin_instance); else { WARNING ("tail plugin: Option `%s' not allowed here.", option->key);