summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9215c4b)
raw | patch | inline | side by side (parent: 9215c4b)
author | Florian Forster <ff@octo.it> | |
Fri, 9 Jul 2010 12:56:14 +0000 (14:56 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 9 Jul 2010 12:56:14 +0000 (14:56 +0200) |
src/Makefile.am | patch | blob | history | |
src/action_list_hosts.c | [new file with mode: 0644] | patch | blob |
src/action_list_hosts.h | [new file with mode: 0644] | patch | blob |
src/main.c | patch | blob | history |
diff --git a/src/Makefile.am b/src/Makefile.am
index 82954cf1e9ea6e2ceabfafcebe23ff08d1847562..f2ba32282c002b5626985fdcbec54d4d49713b3a 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
oconfig.c oconfig.h aux_types.h scanner.l parser.y \
action_graph.c action_graph.h \
action_list_graphs.c action_list_graphs.h \
+ action_list_hosts.c action_list_hosts.h \
action_search.c action_search.h \
action_search_json.c action_search_json.h \
action_show_graph.c action_show_graph.h \
diff --git a/src/action_list_hosts.c b/src/action_list_hosts.c
--- /dev/null
+++ b/src/action_list_hosts.c
@@ -0,0 +1,81 @@
+/**
+ * collection4 - action_list_hosts.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 <ff at octo.it>
+ **/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include "action_list_hosts.h"
+#include "common.h"
+#include "graph.h"
+#include "graph_list.h"
+#include "utils_cgi.h"
+
+#include <fcgiapp.h>
+#include <fcgi_stdio.h>
+
+static int print_one_host (const char *host, /* {{{ */
+ __attribute__((unused)) void *user_data)
+{
+ char host_html[128];
+
+ strncpy (host_html, host, sizeof (host_html));
+ host_html[sizeof (host_html) - 1] = 0;
+ html_escape_buffer (host_html, sizeof (host_html));
+
+ printf (" <li class=\"host\"><a href=\"%s?action=search;q=host:%s\">"
+ "%s</a></li>\n",
+ script_name (), host_html, host_html);
+
+ return (0);
+} /* }}} int print_one_host */
+
+static int print_all_hosts (__attribute__((unused)) void *user_data) /* {{{ */
+{
+ printf (" <ul class=\"host_list\">\n");
+ gl_foreach_host (print_one_host, /* user_data = */ NULL);
+ printf (" </ul>\n");
+
+ return (0);
+} /* }}} int print_all_hosts */
+
+int action_list_hosts (void) /* {{{ */
+{
+ gl_update ();
+
+ page_callbacks_t pg_callbacks = PAGE_CALLBACKS_INIT;
+ char title[512];
+
+ strncpy (title, "List of all hosts", sizeof (title));
+ title[sizeof (title) - 1] = 0;
+
+ pg_callbacks.top_right = html_print_search_box;
+ pg_callbacks.middle_center = print_all_hosts;
+
+ html_print_page (title, &pg_callbacks, /* user data = */ NULL);
+
+ return (0);
+} /* }}} int action_list_hosts */
+
+/* vim: set sw=2 sts=2 et fdm=marker : */
diff --git a/src/action_list_hosts.h b/src/action_list_hosts.h
--- /dev/null
+++ b/src/action_list_hosts.h
@@ -0,0 +1,30 @@
+/**
+ * collection4 - action_list_hosts.h
+ * 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 <ff at octo.it>
+ **/
+
+#ifndef ACTION_LIST_HOSTS_H
+#define ACTION_LIST_HOSTS_H 1
+
+int action_list_hosts (void);
+
+#endif /* ACTION_LIST_HOSTS_H */
+/* vim: set sw=2 sts=2 et fdm=marker : */
diff --git a/src/main.c b/src/main.c
index 496754f8f73e129a5d1e9cad8b3a1fba235783a6..7bc024a8a12a0db056ad90c22d62ae8a37484db8 100644 (file)
--- a/src/main.c
+++ b/src/main.c
#include "action_graph.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"
{
{ "graph", action_graph },
{ "list_graphs", action_list_graphs },
+ { "list_hosts", action_list_hosts },
{ "search", action_search },
{ "search_json", action_search_json },
{ "show_graph", action_show_graph },