7 #include <fcgi_stdio.h>
9 #include "graph_list.h"
10 #include "utils_params.h"
12 static int print_graph_json (const graph_list_t *gl, void *user_data) /* {{{ */
16 if ((gl == NULL) || (user_data == NULL))
19 first = (_Bool *) user_data;
26 printf ("\"host\":\"%s\"", gl->host);
28 printf (",\"plugin\":\"%s\"", gl->plugin);
29 if (gl->plugin_instance != NULL)
30 printf (",\"plugin_instance\":\"%s\"", gl->plugin_instance);
32 printf (",\"plugin_instance\":null");
34 printf (",\"type\":\"%s\"", gl->type);
35 if (gl->type_instance != NULL)
36 printf (",\"type_instance\":\"%s\"", gl->type_instance);
38 printf (",\"type_instance\":null");
43 } /* }}} int print_graph_json */
45 static int print_graph_html (const graph_list_t *gl,
46 void __attribute__((unused)) *user_data)
51 printf ("<li>%s/%s", gl->host, gl->plugin);
52 if (gl->plugin_instance != NULL)
53 printf ("-%s", gl->plugin_instance);
54 printf ("/%s", gl->type);
55 if (gl->type_instance != NULL)
56 printf ("-%s", gl->type_instance);
62 static int list_graphs_json (void) /* {{{ */
66 printf ("Content-Type: application/json\n\n");
69 gl_foreach (print_graph_json, /* user_data = */ &first);
73 } /* }}} int list_graphs_json */
75 static int list_graphs_html (void) /* {{{ */
77 printf ("Content-Type: text/html\n\n");
80 gl_foreach (print_graph_html, /* user_data = */ NULL);
84 } /* }}} int list_graphs_html */
86 int action_list_graphs (void) /* {{{ */
92 format = param ("format");
96 if (strcmp ("json", format) == 0)
97 return (list_graphs_json ());
99 return (list_graphs_html ());
100 } /* }}} int action_list_graphs */
102 /* vim: set sw=2 sts=2 et fdm=marker : */