From 5e630d84e5baa7b105ff83f81555c1e62f5a68ba Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 21 Jun 2010 12:30:28 +0200 Subject: [PATCH] src/graph.[ch]: Implement "graph_get_params". --- src/graph.c | 29 +++++++++++++++++++++++++++++ src/graph.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/src/graph.c b/src/graph.c index a503bfe..6b89859 100644 --- a/src/graph.c +++ b/src/graph.c @@ -204,6 +204,35 @@ int graph_get_title (graph_config_t *cfg, /* {{{ */ return (0); } /* }}} int graph_get_title */ +int graph_get_params (graph_config_t *cfg, /* {{{ */ + char *buffer, size_t buffer_size) +{ + buffer[0] = 0; + +#define COPY_FIELD(field) do { \ + const char *str = ident_get_##field (cfg->select); \ + char uri_str[1024]; \ + uri_escape (uri_str, str, sizeof (uri_str)); \ + strlcat (buffer, #field, buffer_size); \ + strlcat (buffer, "=", buffer_size); \ + strlcat (buffer, uri_str, buffer_size); \ +} while (0) + + COPY_FIELD(host); + strlcat (buffer, ";", buffer_size); + COPY_FIELD(plugin); + strlcat (buffer, ";", buffer_size); + COPY_FIELD(plugin_instance); + strlcat (buffer, ";", buffer_size); + COPY_FIELD(type); + strlcat (buffer, ";", buffer_size); + COPY_FIELD(type_instance); + +#undef COPY_FIELD + + return (0); +} /* }}} int graph_get_params */ + graph_ident_t *graph_get_selector (graph_config_t *cfg) /* {{{ */ { if (cfg == NULL) diff --git a/src/graph.h b/src/graph.h index 98014c5..7f1115c 100644 --- a/src/graph.h +++ b/src/graph.h @@ -19,6 +19,8 @@ int graph_add_file (graph_config_t *cfg, const graph_ident_t *file); int graph_get_title (graph_config_t *cfg, char *buffer, size_t buffer_size); +int graph_get_params (graph_config_t *cfg, char *buffer, size_t buffer_size); + graph_ident_t *graph_get_selector (graph_config_t *cfg); graph_instance_t *graph_get_instances (graph_config_t *cfg); -- 2.11.0