graph_data_json action: Implemented action to query graph data via JSON.
[collection4.git] / src / main.c
index 496754f..2d05baa 100644 (file)
 #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"
@@ -61,7 +64,10 @@ 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_graph },
@@ -105,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 */