X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcommon.c;h=1c80e8f1b8cd6d2f85dfebd482e30caf88cdf6d0;hb=8eb9e6285f394569d7fe6ad43a0f4e5f9bca454f;hp=87d7bf0833e18fafde04d34555a86cbfd6c4afab;hpb=1f5513547a11512077e64769d3e08a2df35105a3;p=collectd.git diff --git a/src/common.c b/src/common.c index 87d7bf08..1c80e8f1 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,36 @@ 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, sizeof (plugin_instance)); + sstrncpy (vl->type, type, sizeof (type)); + sstrncpy (vl->type_instance, 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;