6 #include "action_list_graphs.h"
8 #include "graph_list.h"
9 #include "utils_params.h"
12 #include <fcgi_stdio.h>
14 static int print_graph_inst_json (__attribute__((unused)) graph_config_t *cfg, /* {{{ */
15 graph_instance_t *inst,
24 ident = inst_get_selector (inst);
28 json = ident_to_json (ident);
31 ident_destroy (ident);
38 printf (",\n%s", json);
42 ident_destroy (ident);
44 } /* }}} int print_graph_inst_json */
46 static int print_graph_json (graph_config_t *cfg, /* {{{ */
49 return (gl_graph_instance_get_all (cfg, print_graph_inst_json, user_data));
50 } /* }}} int print_graph_json */
52 static int list_graphs_json (void) /* {{{ */
56 printf ("Content-Type: application/json\n\n");
59 gl_graph_get_all (print_graph_json, /* user_data = */ &first);
63 } /* }}} int list_graphs_json */
65 static int print_graph_inst_html (graph_config_t *cfg, /* {{{ */
66 graph_instance_t *inst,
67 __attribute__((unused)) void *user_data)
72 memset (params, 0, sizeof (params));
73 inst_get_params (cfg, inst, params, sizeof (params));
75 memset (desc, 0, sizeof (desc));
76 inst_describe (cfg, inst, desc, sizeof (desc));
78 printf (" <li><a href=\"test.fcgi?action=graph;%s\">%s</a></li>\n",
82 } /* }}} int print_graph_inst_html */
84 static int print_graph_html (graph_config_t *cfg, /* {{{ */
85 __attribute__((unused)) void *user_data)
89 memset (buffer, 0, sizeof (buffer));
90 graph_get_title (cfg, buffer, sizeof (buffer));
92 printf (" <li>%s\n <ul>\n", buffer);
93 gl_graph_instance_get_all (cfg, print_graph_inst_html, /* user_data = */ NULL);
94 printf (" </ul></li>\n");
97 } /* }}} int print_graph_html */
99 static int list_graphs_html (void) /* {{{ */
101 printf ("Content-Type: text/html\n\n");
104 gl_graph_get_all (print_graph_html, /* user_data = */ NULL);
108 } /* }}} int list_graphs_html */
110 int action_list_graphs (void) /* {{{ */
116 format = param ("format");
120 if (strcmp ("json", format) == 0)
121 return (list_graphs_json ());
123 return (list_graphs_html ());
124 } /* }}} int action_list_graphs */
126 /* vim: set sw=2 sts=2 et fdm=marker : */