X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Futils_cgi.c;h=97dfc7c60b9a9bdd6e8b588d7645fcd9a8ea63c4;hb=c048f2d5c5dab7e4944ca9a50463fdf4d2748aff;hp=9efa01f72af575af7eb035b881517aa67d1f1cdb;hpb=007477dd79b3ada9abba7b332306c92025197d32;p=collection4.git diff --git a/src/utils_cgi.c b/src/utils_cgi.c index 9efa01f..97dfc7c 100644 --- a/src/utils_cgi.c +++ b/src/utils_cgi.c @@ -7,6 +7,9 @@ #include "utils_cgi.h" +#include +#include + struct parameter_s { char *key; @@ -328,7 +331,7 @@ char *html_escape_copy (char *dest, const char *src, size_t n) /* {{{ */ break; } - return (src); + return (dest); } /* }}} char *html_escape_copy */ #undef COPY_ENTITY @@ -347,9 +350,108 @@ char *html_escape (const char *string) /* {{{ */ { char buffer[4096]; + if (string == NULL) + return (NULL); + html_escape_copy (buffer, string, sizeof (buffer)); return (strdup (buffer)); } /* }}} char *html_escape */ +int html_print_page (const char *title, /* {{{ */ + const page_callbacks_t *cb, void *user_data) +{ + char *title_html; + + printf ("Content-Type: text/html\n\n"); + + if (title == NULL) + title = "c4: collection4 graph interface"; + + title_html = html_escape (title); + + printf ("\n" + " \n" + " %s\n" + " \n" + " \n" + " \n" + " \n", + title_html); + + printf (" \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + "
"); + if (cb->top_left != NULL) + (*cb->top_left) (user_data); + printf (""); + if (cb->top_center != NULL) + (*cb->top_center) (user_data); + else + printf ("

%s

", title_html); + printf ("
"); + if (cb->top_right != NULL) + (*cb->top_right) (user_data); + printf ("
"); + if (cb->middle_left != NULL) + (*cb->middle_left) (user_data); + printf (""); + if (cb->middle_center != NULL) + (*cb->middle_center) (user_data); + printf (""); + if (cb->middle_right != NULL) + (*cb->middle_right) (user_data); + printf ("
"); + if (cb->bottom_left != NULL) + (*cb->bottom_left) (user_data); + printf (""); + if (cb->bottom_center != NULL) + (*cb->bottom_center) (user_data); + printf (""); + if (cb->bottom_right != NULL) + (*cb->bottom_right) (user_data); + printf ("
\n" + " \n" + "\n"); + + free (title_html); + return (0); +} /* }}} int html_print_page */ + +int html_print_search_box (__attribute__((unused)) void *user_data) /* {{{ */ +{ + char *term_html; + + term_html = html_escape (param ("q")); + + 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 : */