From c4939342ce1aa40bc845f0d2c826c21cc56d17d7 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 21 Jun 2010 10:52:26 +0200 Subject: [PATCH] src/utils_cgi.[ch]: Move "html_print_search_box" to here. --- src/action_list_graphs.c | 28 +--------------------------- src/utils_cgi.c | 19 +++++++++++++++++++ src/utils_cgi.h | 2 ++ 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/action_list_graphs.c b/src/action_list_graphs.c index dad4367..a236517 100644 --- a/src/action_list_graphs.c +++ b/src/action_list_graphs.c @@ -185,32 +185,6 @@ struct page_data_s }; typedef struct page_data_s page_data_t; -static int print_search_box (void *user_data) /* {{{ */ -{ - page_data_t *data = user_data; - char *term_html; - - if (data == NULL) - { - fprintf (stderr, "print_search_box: data == NULL\n"); - return (EINVAL); - } - - term_html = html_escape (data->search_term); - - printf ("
\n" - " \n" - " \n" - " \n" - "
\n", - script_name (), - (term_html != NULL) ? term_html : ""); - - free (term_html); - - return (0); -} /* }}} int print_search_box */ - static int print_search_result (void *user_data) /* {{{ */ { page_data_t *pg_data = user_data; @@ -346,7 +320,7 @@ static int list_graphs_html (const char *term) /* {{{ */ memset (&pg_data, 0, sizeof (pg_data)); pg_data.search_term = term; - pg_callbacks.top_right = print_search_box; + pg_callbacks.top_right = html_print_search_box; pg_callbacks.middle_left = print_host_list; pg_callbacks.middle_center = print_search_result; diff --git a/src/utils_cgi.c b/src/utils_cgi.c index daf9765..9030eb8 100644 --- a/src/utils_cgi.c +++ b/src/utils_cgi.c @@ -435,4 +435,23 @@ int html_print_page (const char *title, /* {{{ */ return (0); } /* }}} int html_print_page */ +int html_print_search_box (__attribute__((unused)) void *user_data) /* {{{ */ +{ + char *term_html; + + term_html = html_escape (param ("search")); + + printf ("
\n" + " \n" + " \n" + " \n" + "
\n", + script_name (), + (term_html != NULL) ? term_html : ""); + + free (term_html); + + return (0); +} /* }}} int html_print_search_box */ + /* vim: set sw=2 sts=2 et fdm=marker : */ diff --git a/src/utils_cgi.h b/src/utils_cgi.h index 20f806c..e8e847e 100644 --- a/src/utils_cgi.h +++ b/src/utils_cgi.h @@ -42,5 +42,7 @@ char *html_escape_copy (char *dest, const char *src, size_t n); int html_print_page (const char *title, const page_callbacks_t *cb, void *user_data); +int html_print_search_box (void *user_data); + /* vim: set sw=2 sts=2 et fdm=marker : */ #endif /* UTILS_CGI_H */ -- 2.30.2