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 print_one_host (const char *host, /* {{{ */
39 __attribute__((unused)) void *user_data)
43 strncpy (host_html, host, sizeof (host_html));
44 host_html[sizeof (host_html) - 1] = 0;
45 html_escape_buffer (host_html, sizeof (host_html));
47 printf (" <li class=\"host\"><a href=\"%s?action=search;q=host:%s\">"
49 script_name (), host_html, host_html);
52 } /* }}} int print_one_host */
54 static int print_all_hosts (__attribute__((unused)) void *user_data) /* {{{ */
56 printf (" <ul class=\"host_list\">\n");
57 gl_foreach_host (print_one_host, /* user_data = */ NULL);
61 } /* }}} int print_all_hosts */
63 int action_list_hosts (void) /* {{{ */
67 page_callbacks_t pg_callbacks = PAGE_CALLBACKS_INIT;
70 strncpy (title, "List of all hosts", sizeof (title));
71 title[sizeof (title) - 1] = 0;
73 pg_callbacks.top_right = html_print_search_box;
74 pg_callbacks.middle_center = print_all_hosts;
76 html_print_page (title, &pg_callbacks, /* user data = */ NULL);
79 } /* }}} int action_list_hosts */
81 /* vim: set sw=2 sts=2 et fdm=marker : */