2 * collection4 - action_list_hosts.c
3 * Copyright (C) 2010 Florian octo Forster
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA
21 * Florian octo Forster <ff at octo.it>
29 #include "action_list_hosts.h"
32 #include "graph_list.h"
33 #include "utils_cgi.h"
36 #include <fcgi_stdio.h>
38 static int left_menu (__attribute__((unused)) void *user_data) /* {{{ */
40 printf ("\n<ul class=\"menu left\">\n"
41 " <li><a href=\"%s?action=search\">Search</a></li>\n"
42 " <li><a href=\"%s?action=list_graphs\">All graphs</a></li>\n"
44 script_name (), script_name ());
47 } /* }}} int left_menu */
49 static int print_one_host (const char *host, /* {{{ */
50 __attribute__((unused)) void *user_data)
54 strncpy (host_html, host, sizeof (host_html));
55 host_html[sizeof (host_html) - 1] = 0;
56 html_escape_buffer (host_html, sizeof (host_html));
58 printf (" <li class=\"host\"><a href=\"%s?action=search;q=host:%s\">"
60 script_name (), host_html, host_html);
63 } /* }}} int print_one_host */
65 static int print_all_hosts (__attribute__((unused)) void *user_data) /* {{{ */
67 printf (" <ul class=\"host_list\">\n");
68 gl_foreach_host (print_one_host, /* user_data = */ NULL);
72 } /* }}} int print_all_hosts */
74 int action_list_hosts (void) /* {{{ */
76 page_callbacks_t pg_callbacks = PAGE_CALLBACKS_INIT;
79 strncpy (title, "List of all hosts", sizeof (title));
80 title[sizeof (title) - 1] = 0;
82 pg_callbacks.top_right = html_print_search_box;
83 pg_callbacks.middle_left = left_menu;
84 pg_callbacks.middle_center = print_all_hosts;
86 html_print_page (title, &pg_callbacks, /* user data = */ NULL);
89 } /* }}} int action_list_hosts */
91 /* vim: set sw=2 sts=2 et fdm=marker : */