2 * collection4 - action_list_graphs.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_graphs.h"
32 #include "graph_list.h"
33 #include "utils_cgi.h"
36 #include <fcgi_stdio.h>
38 static int print_one_graph (graph_config_t *cfg, /* {{{ */
39 __attribute__((unused)) void *user_data)
45 num_instances = graph_num_instances (cfg);
46 if (num_instances < 1)
49 memset (title, 0, sizeof (title));
50 graph_get_title (cfg, title, sizeof (title));
51 html_escape_buffer (title, sizeof (title));
53 memset (params, 0, sizeof (params));
54 graph_get_params (cfg, params, sizeof (params));
55 html_escape_buffer (params, sizeof (params));
57 printf (" <li class=\"graph\"><a href=\"%s?action=show_graph;%s\">"
58 "%s</a> <span class=\"num_instances\">(%lu %s)</span></li>\n",
59 script_name (), params, title,
60 (unsigned long) num_instances,
61 (num_instances == 1) ? "instance" : "instances");
64 } /* }}} int print_one_graph */
66 static int print_all_graphs (__attribute__((unused)) void *user_data) /* {{{ */
68 printf (" <ul id=\"search-output\" class=\"graph_list\">\n");
69 gl_graph_get_all (print_one_graph, /* user_data = */ NULL);
73 } /* }}} int print_all_graphs */
75 int action_list_graphs (void) /* {{{ */
79 page_callbacks_t pg_callbacks = PAGE_CALLBACKS_INIT;
82 strncpy (title, "List of all graphs", sizeof (title));
83 title[sizeof (title) - 1] = 0;
85 pg_callbacks.top_right = html_print_search_box;
86 pg_callbacks.middle_center = print_all_graphs;
88 html_print_page (title, &pg_callbacks, /* user data = */ NULL);
91 } /* }}} int action_list_graphs */
93 /* vim: set sw=2 sts=2 et fdm=marker : */