13 #include "graph_list.h"
14 #include "utils_cgi.h"
16 #include "action_graph.h"
17 #include "action_list_graphs.h"
19 /* Include this last, so the macro magic of <fcgi_stdio.h> doesn't interfere
20 * with our own header files. */
22 #include <fcgi_stdio.h>
27 int (*callback) (void);
29 typedef struct action_s action_t;
31 static int action_usage (void);
33 static const action_t actions[] =
35 { "graph", action_graph },
36 { "list_graphs", action_list_graphs },
37 { "usage", action_usage }
39 static const size_t actions_num = sizeof (actions) / sizeof (actions[0]);
42 static int action_usage (void) /* {{{ */
46 printf ("Content-Type: text/plain\n\n");
50 " Available actions:\n"
53 for (i = 0; i < actions_num; i++)
54 printf (" * %s\n", actions[i].name);
59 } /* }}} int action_usage */
61 static int handle_request (void) /* {{{ */
67 action = param ("action");
70 return (action_usage ());
76 for (i = 0; i < actions_num; i++)
78 if (strcmp (action, actions[i].name) == 0)
79 return ((*actions[i].callback) ());
82 return (action_usage ());
84 } /* }}} int handle_request */
86 static int run (void) /* {{{ */
88 while (FCGI_Accept() >= 0)
97 int main (int argc, char **argv) /* {{{ */
105 status = handle_request ();
109 exit ((status == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
112 /* vim: set sw=2 sts=2 et fdm=marker : */