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)
71 memset (buffer, 0, sizeof (buffer));
72 inst_get_params (cfg, inst, buffer, sizeof (buffer));
74 printf ("<li><a href=\"test.fcgi?action=graph;%s\">%s</a></li>\n", buffer, buffer);
77 } /* }}} int print_graph_inst_html */
79 static int print_graph_html (graph_config_t *cfg, /* {{{ */
80 __attribute__((unused)) void *user_data)
84 memset (buffer, 0, sizeof (buffer));
85 graph_get_title (cfg, buffer, sizeof (buffer));
87 printf ("<li>%s\n<ul>\n", buffer);
88 gl_graph_instance_get_all (cfg, print_graph_inst_html, /* user_data = */ NULL);
92 } /* }}} int print_graph_html */
94 static int list_graphs_html (void) /* {{{ */
96 printf ("Content-Type: text/html\n\n");
99 gl_graph_get_all (print_graph_html, /* user_data = */ NULL);
103 } /* }}} int list_graphs_html */
105 int action_list_graphs (void) /* {{{ */
111 format = param ("format");
115 if (strcmp ("json", format) == 0)
116 return (list_graphs_json ());
118 return (list_graphs_html ());
119 } /* }}} int action_list_graphs */
121 /* vim: set sw=2 sts=2 et fdm=marker : */