X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcommon.c;h=142d7979adf1fc2c02e6a54d9a4bdc8483598c4e;hb=c9827c15fc557d7c9201f925f406023d660478eb;hp=87d7bf0833e18fafde04d34555a86cbfd6c4afab;hpb=edd0e2639a241167e213ec301bfc71c7d291ee61;p=collectd.git diff --git a/src/common.c b/src/common.c index 87d7bf08..142d7979 100644 --- a/src/common.c +++ b/src/common.c @@ -1,6 +1,6 @@ /** * collectd - src/common.c - * Copyright (C) 2005-2009 Florian octo Forster + * Copyright (C) 2005-2010 Florian octo Forster * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -16,7 +16,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: - * Florian octo Forster + * Florian octo Forster * Niki W. Waibel * Sebastian Harl * Michał Mirosław @@ -918,6 +918,40 @@ int parse_identifier (char *str, char **ret_host, return (0); } /* int parse_identifier */ +int parse_identifier_vl (const char *str, value_list_t *vl) /* {{{ */ +{ + char str_copy[6 * DATA_MAX_NAME_LEN]; + char *host = NULL; + char *plugin = NULL; + char *plugin_instance = NULL; + char *type = NULL; + char *type_instance = NULL; + int status; + + if ((str == NULL) || (vl == NULL)) + return (EINVAL); + + sstrncpy (str_copy, str, sizeof (str_copy)); + + status = parse_identifier (str_copy, &host, + &plugin, &plugin_instance, + &type, &type_instance); + if (status != 0) + return (status); + + sstrncpy (vl->host, host, sizeof (host)); + sstrncpy (vl->plugin, plugin, sizeof (plugin)); + sstrncpy (vl->plugin_instance, + (plugin_instance != NULL) ? plugin_instance : "", + sizeof (plugin_instance)); + sstrncpy (vl->type, type, sizeof (type)); + sstrncpy (vl->type_instance, + (type_instance != NULL) ? type_instance : "", + sizeof (type_instance)); + + return (0); +} /* }}} int parse_identifier_vl */ + int parse_value (const char *value, value_t *ret_value, int ds_type) { char *endptr = NULL; @@ -933,11 +967,11 @@ int parse_value (const char *value, value_t *ret_value, int ds_type) break; case DS_TYPE_DERIVE: - ret_value->counter = (derive_t) strtoll (value, &endptr, 0); + ret_value->derive = (derive_t) strtoll (value, &endptr, 0); break; case DS_TYPE_ABSOLUTE: - ret_value->counter = (absolute_t) strtoull (value, &endptr, 0); + ret_value->absolute = (absolute_t) strtoull (value, &endptr, 0); break; default: