X-Git-Url: https://git.octo.it/?p=collection4.git;a=blobdiff_plain;f=src%2Fmain.c;h=0722403fac4f885883d6a9c1765ab081a408037f;hp=1132cba80dcda7ed1c666660e1022e53b07f5e92;hb=e3fb09073a64cc051c11c4a1bdcec493f937b764;hpb=b6f9e3cecc5474305f3d2a51ced04b186552d9ab diff --git a/src/main.c b/src/main.c index 1132cba..0722403 100644 --- a/src/main.c +++ b/src/main.c @@ -37,7 +37,11 @@ #include "utils_cgi.h" #include "action_graph.h" +#include "action_instance_data_json.h" +#include "action_graph_def_json.h" #include "action_list_graphs.h" +#include "action_list_hosts.h" +#include "action_search.h" #include "action_search_json.h" #include "action_show_graph.h" #include "action_show_graph_json.h" @@ -60,7 +64,11 @@ static int action_usage (void); static const action_t actions[] = { { "graph", action_graph }, + { "instance_data_json", action_instance_data_json }, + { "graph_def_json", action_graph_def_json }, { "list_graphs", action_list_graphs }, + { "list_hosts", action_list_hosts }, + { "search", action_search }, { "search_json", action_search_json }, { "show_graph", action_show_graph }, { "show_graph_json", action_show_graph_json }, @@ -98,19 +106,33 @@ static int handle_request (void) /* {{{ */ action = param ("action"); if (action == NULL) { - return (action_usage ()); + return (action_list_graphs ()); } else { size_t i; + int status = ENOENT; + + gl_update (/* request_served = */ 0); for (i = 0; i < actions_num; i++) { if (strcmp (action, actions[i].name) == 0) - return ((*actions[i].callback) ()); + { + status = (*actions[i].callback) (); + break; + } } - return (action_usage ()); + if (i >= actions_num) + status = action_usage (); + + fflush (stdout); + fclose (stdout); + + gl_update (/* request_served = */ 1); + + return (status); } } /* }}} int handle_request */