From 8eb9e6285f394569d7fe6ad43a0f4e5f9bca454f Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 23 Nov 2010 12:57:25 +0100 Subject: [PATCH] src/common.[ch]: Implement "parse_identifier_vl". --- src/common.c | 34 ++++++++++++++++++++++++++++++++-- src/common.h | 5 +++-- 2 files changed, 35 insertions(+), 4 deletions(-) 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; diff --git a/src/common.h b/src/common.h index 63ecca39..425d6e2d 100644 --- a/src/common.h +++ b/src/common.h @@ -1,6 +1,6 @@ /** * collectd - src/common.h - * 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 **/ @@ -265,6 +265,7 @@ int format_values (char *ret, size_t ret_len, int parse_identifier (char *str, char **ret_host, char **ret_plugin, char **ret_plugin_instance, char **ret_type, char **ret_type_instance); +int parse_identifier_vl (const char *str, value_list_t *vl); int parse_value (const char *value, value_t *ret_value, int ds_type); int parse_values (char *buffer, value_list_t *vl, const data_set_t *ds); -- 2.11.0