utils_params.o: utils_params.c utils_params.h
+action_list_graphs.o: action_list_graphs.c action_list_graphs.h
+
test: test.c utils_params.o
fcgi_test: LDLIBS = -lfcgi
-fcgi_test: fcgi_test.c common.o graph_list.o utils_params.o
+fcgi_test: fcgi_test.c common.o graph_list.o utils_params.o action_list_graphs.o
.PHONY: clean
--- /dev/null
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <fcgiapp.h>
+#include <fcgi_stdio.h>
+
+#include "graph_list.h"
+
+static int print_graph (const graph_list_t *gl, void *user_data) /* {{{ */
+{
+ _Bool *first;
+
+ if ((gl == NULL) || (user_data == NULL))
+ return (EINVAL);
+
+ first = (_Bool *) user_data;
+ if (!*first)
+ printf (",\n");
+ *first = 0;
+
+ printf (" {");
+
+ printf ("\"host\":\"%s\"", gl->host);
+
+ printf (",\"plugin\":\"%s\"", gl->plugin);
+ if (gl->plugin_instance != NULL)
+ printf (",\"plugin_instance\":\"%s\"", gl->plugin_instance);
+ else
+ printf (",\"plugin_instance\":null");
+
+ printf (",\"type\":\"%s\"", gl->type);
+ if (gl->type_instance != NULL)
+ printf (",\"type_instance\":\"%s\"", gl->type_instance);
+ else
+ printf (",\"type_instance\":null");
+
+ printf ("}");
+
+ return (0);
+} /* }}} int print_graph */
+
+int action_list_graphs (void) /* {{{ */
+{
+ _Bool first = 1;
+
+ printf ("Content-Type: text/plain\n\n");
+
+ gl_update ();
+
+ printf ("[\n");
+ gl_foreach (print_graph, /* user_data = */ &first);
+ printf ("\n]");
+} /* }}} int action_list_graphs */
+
+/* vim: set sw=2 sts=2 et fdm=marker : */
--- /dev/null
+#ifndef ACTION_LIST_GRAPHS_H
+#define ACTION_LIST_GRAPHS_H 1
+
+int action_list_graphs (void);
+
+#endif /* ACTION_LIST_GRAPHS_H */
+/* vim: set sw=2 sts=2 et fdm=marker : */
#include "graph_list.h"
#include "utils_params.h"
+#include "action_list_graphs.h"
+
struct str_array_s
{
char **ptr;
return (0);
} /* }}} int array_add */
-static int print_graph (const graph_list_t *gl, void *user_data)
+static int print_graph (const graph_list_t *gl, void *user_data) /* {{{ */
{
if (gl == NULL)
return (EINVAL);
{
return (action_usage ());
}
+ else if (strcmp ("list_graphs", action) == 0)
+ {
+ return (action_list_graphs ());
+ }
else if (strcmp ("hello", action) == 0)
{
return (action_hello ());