projects
/
collection4.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
filesystem.[ch]: Move filesystem accessing functions into a separate module.
[collection4.git]
/
action_list_graphs.c
diff --git
a/action_list_graphs.c
b/action_list_graphs.c
index
16d5cc4
..
fc4ec14
100644
(file)
--- a/
action_list_graphs.c
+++ b/
action_list_graphs.c
@@
-3,56
+3,74
@@
#include <string.h>
#include <errno.h>
#include <string.h>
#include <errno.h>
-#include <fcgiapp.h>
-#include <fcgi_stdio.h>
-
#include "action_list_graphs.h"
#include "graph_list.h"
#include "utils_params.h"
#include "action_list_graphs.h"
#include "graph_list.h"
#include "utils_params.h"
-static int print_graph_json (const graph_list_t *gl, void *user_data) /* {{{ */
+#include <fcgiapp.h>
+#include <fcgi_stdio.h>
+
+static int print_graph_inst_json (__attribute__((unused)) graph_config_t *cfg, /* {{{ */
+ graph_instance_t *inst,
+ void *user_data)
{
_Bool *first;
{
_Bool *first;
+ graph_ident_t *ident;
+ char *json;
- if ((gl == NULL) || (user_data == NULL))
- return (EINVAL);
+ first = user_data;
- first = (_Bool *) user_data;
- if (!*first)
- printf (",\n");
- *first = 0;
+ ident = inst_get_selector (inst);
+ if (ident == NULL)
+ return (-1);
- printf (" {");
+ json = ident_to_json (ident);
+ if (json == NULL)
+ {
+ ident_destroy (ident);
+ return (ENOMEM);
+ }
- printf ("\"host\":\"%s\"", gl->host);
-
- printf (",\"plugin\":\"%s\"", gl->plugin);
- if (gl->plugin_instance != NULL)
- printf (",\"plugin_instance\":\"%s\"", gl->plugin_instance);
+ if (*first)
+ printf ("%s", json);
else
else
- printf (",\
"plugin_instance\":null"
);
+ printf (",\
n%s", json
);
- printf (",\"type\":\"%s\"", gl->type);
- if (gl->type_instance != NULL)
- printf (",\"type_instance\":\"%s\"", gl->type_instance);
- else
- printf (",\"type_instance\":null");
-
- printf ("}");
+ *first = 0;
+ ident_destroy (ident);
return (0);
return (0);
+} /* }}} int print_graph_inst_json */
+
+static int print_graph_json (graph_config_t *cfg, /* {{{ */
+ void *user_data)
+{
+ return (gl_graph_instance_get_all (cfg, print_graph_inst_json, user_data));
} /* }}} int print_graph_json */
} /* }}} int print_graph_json */
-static int print_graph_inst_html (__attribute__((unused)) graph_config_t *cfg, /* {{{ */
+static int list_graphs_json (void) /* {{{ */
+{
+ _Bool first = 1;
+
+ printf ("Content-Type: application/json\n\n");
+
+ printf ("[\n");
+ gl_graph_get_all (print_graph_json, /* user_data = */ &first);
+ printf ("\n]");
+
+ return (0);
+} /* }}} int list_graphs_json */
+
+static int print_graph_inst_html (graph_config_t *cfg, /* {{{ */
graph_instance_t *inst,
__attribute__((unused)) void *user_data)
{
char buffer[1024];
memset (buffer, 0, sizeof (buffer));
graph_instance_t *inst,
__attribute__((unused)) void *user_data)
{
char buffer[1024];
memset (buffer, 0, sizeof (buffer));
-
gl_instance_get_ident (
inst, buffer, sizeof (buffer));
+
inst_get_params (cfg,
inst, buffer, sizeof (buffer));
- printf ("<li>
%s</li>\n"
, buffer);
+ printf ("<li>
<a href=\"test.fcgi?action=graph;%s\">%s</a></li>\n", buffer
, buffer);
return (0);
} /* }}} int print_graph_inst_html */
return (0);
} /* }}} int print_graph_inst_html */
@@
-60,26
+78,18
@@
static int print_graph_inst_html (__attribute__((unused)) graph_config_t *cfg, /
static int print_graph_html (graph_config_t *cfg, /* {{{ */
__attribute__((unused)) void *user_data)
{
static int print_graph_html (graph_config_t *cfg, /* {{{ */
__attribute__((unused)) void *user_data)
{
- printf ("<li>%p\n<ul>\n", (void *) cfg);
+ char buffer[1024];
+
+ memset (buffer, 0, sizeof (buffer));
+ gl_graph_get_title (cfg, buffer, sizeof (buffer));
+
+ printf ("<li>%s\n<ul>\n", buffer);
gl_graph_instance_get_all (cfg, print_graph_inst_html, /* user_data = */ NULL);
printf ("</ul>\n");
return (0);
} /* }}} int print_graph_html */
gl_graph_instance_get_all (cfg, print_graph_inst_html, /* user_data = */ NULL);
printf ("</ul>\n");
return (0);
} /* }}} int print_graph_html */
-static int list_graphs_json (void) /* {{{ */
-{
- _Bool first = 1;
-
- printf ("Content-Type: application/json\n\n");
-
- printf ("[\n");
- gl_foreach (print_graph_json, /* user_data = */ &first);
- printf ("\n]");
-
- return (0);
-} /* }}} int list_graphs_json */
-
static int list_graphs_html (void) /* {{{ */
{
printf ("Content-Type: text/html\n\n");
static int list_graphs_html (void) /* {{{ */
{
printf ("Content-Type: text/html\n\n");