X-Git-Url: https://git.octo.it/?p=collection4.git;a=blobdiff_plain;f=src%2Fmain.c;h=2d05baa6495548f13192af8345ac5122ce27e12b;hp=208318d5fd3d349c855d746654ff2d875d53122c;hb=643c2293a8b65f8970e3ef9ea288b20d117592f2;hpb=15279357255dbcccab890a29c7ceecc144ba3e63 diff --git a/src/main.c b/src/main.c index 208318d..2d05baa 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,26 @@ +/** + * collection4 - main.c + * Copyright (C) 2010 Florian octo Forster + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authors: + * Florian octo Forster + **/ + #include #include #include @@ -14,8 +37,14 @@ #include "utils_cgi.h" #include "action_graph.h" +#include "action_graph_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" #include "action_show_instance.h" /* Include this last, so the macro magic of doesn't interfere @@ -35,9 +64,15 @@ static int action_usage (void); static const action_t actions[] = { { "graph", action_graph }, + { "graph_data_json", action_graph_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_instance }, + { "show_graph", action_show_graph }, + { "show_graph_json", action_show_graph_json }, + { "show_instance", action_show_instance }, { "usage", action_usage } }; static const size_t actions_num = sizeof (actions) / sizeof (actions[0]); @@ -76,14 +111,28 @@ static int handle_request (void) /* {{{ */ 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 */