6 #include "action_list_graphs.h"
7 #include "graph_list.h"
8 #include "utils_params.h"
11 #include <fcgi_stdio.h>
13 static int print_graph_inst_json (__attribute__((unused)) graph_config_t *cfg, /* {{{ */
14 graph_instance_t *inst,
23 ident = gl_instance_get_selector (inst);
27 json = ident_to_json (ident);
30 ident_destroy (ident);
37 printf (",\n%s", json);
41 ident_destroy (ident);
43 } /* }}} int print_graph_inst_json */
45 static int print_graph_json (graph_config_t *cfg, /* {{{ */
48 return (gl_graph_instance_get_all (cfg, print_graph_inst_json, user_data));
49 } /* }}} int print_graph_json */
51 static int list_graphs_json (void) /* {{{ */
55 printf ("Content-Type: application/json\n\n");
58 gl_graph_get_all (print_graph_json, /* user_data = */ &first);
62 } /* }}} int list_graphs_json */
64 static int print_graph_inst_html (graph_config_t *cfg, /* {{{ */
65 graph_instance_t *inst,
66 __attribute__((unused)) void *user_data)
70 memset (buffer, 0, sizeof (buffer));
71 gl_instance_get_params (cfg, inst, buffer, sizeof (buffer));
73 printf ("<li><a href=\"test.fcgi?action=graph;%s\">%s</a></li>\n", buffer, buffer);
76 } /* }}} int print_graph_inst_html */
78 static int print_graph_html (graph_config_t *cfg, /* {{{ */
79 __attribute__((unused)) void *user_data)
83 memset (buffer, 0, sizeof (buffer));
84 gl_graph_get_title (cfg, buffer, sizeof (buffer));
86 printf ("<li>%s\n<ul>\n", buffer);
87 gl_graph_instance_get_all (cfg, print_graph_inst_html, /* user_data = */ NULL);
91 } /* }}} int print_graph_html */
93 static int list_graphs_html (void) /* {{{ */
95 printf ("Content-Type: text/html\n\n");
98 gl_graph_get_all (print_graph_html, /* user_data = */ NULL);
102 } /* }}} int list_graphs_html */
104 int action_list_graphs (void) /* {{{ */
110 format = param ("format");
114 if (strcmp ("json", format) == 0)
115 return (list_graphs_json ());
117 return (list_graphs_html ());
118 } /* }}} int action_list_graphs */
120 /* vim: set sw=2 sts=2 et fdm=marker : */