From: Florian Forster Date: Thu, 22 Dec 2011 08:07:04 +0000 (+0100) Subject: list_graphs_json action: Export the selector rather than a parameter string. X-Git-Url: https://git.octo.it/?p=collection4.git;a=commitdiff_plain;h=91fc67b06fa84edac2bec2bd52101a9d9491d9da list_graphs_json action: Export the selector rather than a parameter string. --- diff --git a/src/action_list_graphs_json.c b/src/action_list_graphs_json.c index 120e419..f8485ce 100644 --- a/src/action_list_graphs_json.c +++ b/src/action_list_graphs_json.c @@ -44,9 +44,9 @@ static void write_callback (__attribute__((unused)) void *ctx, /* {{{ */ static int print_one_graph (graph_config_t *cfg, /* {{{ */ void *user_data) { - char params[1024]; char title[1024]; size_t num_instances; + graph_ident_t *selector; yajl_gen handler = user_data; @@ -54,14 +54,18 @@ static int print_one_graph (graph_config_t *cfg, /* {{{ */ if (num_instances < 1) return (0); + selector = graph_get_selector (cfg); + if (selector == NULL) + { + /* TODO: Print error. */ + return (0); + } + yajl_gen_map_open (handler); memset (title, 0, sizeof (title)); graph_get_title (cfg, title, sizeof (title)); - memset (params, 0, sizeof (params)); - graph_get_params (cfg, params, sizeof (params)); - yajl_gen_string (handler, (unsigned char *) "title", (unsigned int) strlen ("title")); @@ -70,11 +74,9 @@ static int print_one_graph (graph_config_t *cfg, /* {{{ */ (unsigned int) strlen (title)); yajl_gen_string (handler, - (unsigned char *) "params", - (unsigned int) strlen ("params")); - yajl_gen_string (handler, - (unsigned char *) params, - (unsigned int) strlen (params)); + (unsigned char *) "selector", + (unsigned int) strlen ("selector")); + ident_to_json (selector, handler); yajl_gen_string (handler, (unsigned char *) "num_instances", @@ -83,6 +85,8 @@ static int print_one_graph (graph_config_t *cfg, /* {{{ */ yajl_gen_map_close (handler); + ident_destroy (selector); + return (0); } /* }}} int print_one_graph */