13 #include "graph_list.h"
14 #include "utils_cgi.h"
16 #include "action_graph.h"
17 #include "action_list_graphs.h"
18 #include "action_search_json.h"
20 /* Include this last, so the macro magic of <fcgi_stdio.h> doesn't interfere
21 * with our own header files. */
23 #include <fcgi_stdio.h>
28 int (*callback) (void);
30 typedef struct action_s action_t;
32 static int action_usage (void);
34 static const action_t actions[] =
36 { "graph", action_graph },
37 { "list_graphs", action_list_graphs },
38 { "search_json", action_search_json },
39 { "usage", action_usage }
41 static const size_t actions_num = sizeof (actions) / sizeof (actions[0]);
44 static int action_usage (void) /* {{{ */
48 printf ("Content-Type: text/plain\n\n");
52 " Available actions:\n"
55 for (i = 0; i < actions_num; i++)
56 printf (" * %s\n", actions[i].name);
61 } /* }}} int action_usage */
63 static int handle_request (void) /* {{{ */
69 action = param ("action");
72 return (action_usage ());
78 for (i = 0; i < actions_num; i++)
80 if (strcmp (action, actions[i].name) == 0)
81 return ((*actions[i].callback) ());
84 return (action_usage ());
86 } /* }}} int handle_request */
88 static int run (void) /* {{{ */
90 while (FCGI_Accept() >= 0)
99 int main (int argc, char **argv) /* {{{ */
107 status = handle_request ();
111 exit ((status == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
114 /* vim: set sw=2 sts=2 et fdm=marker : */