=================================================================== RCS file: /cvs/mandoc/cgi.c,v retrieving revision 1.111 retrieving revision 1.114 diff -u -p -r1.111 -r1.114 --- mandoc/cgi.c 2015/10/20 02:01:31 1.111 +++ mandoc/cgi.c 2015/11/05 20:55:41 1.114 @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.111 2015/10/20 02:01:31 schwarze Exp $ */ +/* $Id: cgi.c,v 1.114 2015/11/05 20:55:41 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014, 2015 Ingo Schwarze @@ -34,6 +34,7 @@ #include "mandoc.h" #include "roff.h" #include "mdoc.h" +#include "man.h" #include "main.h" #include "manconf.h" #include "mansearch.h" @@ -76,6 +77,7 @@ static void pg_searchres(const struct req *, static void pg_show(struct req *, const char *); static void resp_begin_html(int, const char *); static void resp_begin_http(int, const char *); +static void resp_copy(const char *); static void resp_end_html(void); static void resp_searchform(const struct req *); static void resp_show(const struct req *, const char *); @@ -367,6 +369,20 @@ resp_begin_http(int code, const char *msg) } static void +resp_copy(const char *filename) +{ + char buf[4096]; + ssize_t sz; + int fd; + + if ((fd = open(filename, O_RDONLY)) != -1) { + fflush(stdout); + while ((sz = read(fd, buf, sizeof(buf))) > 0) + write(STDOUT_FILENO, buf, sz); + } +} + +static void resp_begin_html(int code, const char *msg) { @@ -376,21 +392,23 @@ resp_begin_html(int code, const char *msg) "\n" "\n" "\n" - "\n" - "\n" "%s\n" "\n" "\n" "\n", - CSS_DIR, CSS_DIR, CUSTOMIZE_TITLE); + CSS_DIR, CUSTOMIZE_TITLE); + + resp_copy(MAN_DIR "/header.html"); } static void resp_end_html(void) { + resp_copy(MAN_DIR "/footer.html"); + puts("\n" ""); } @@ -400,7 +418,6 @@ resp_searchform(const struct req *req) { int i; - puts(CUSTOMIZE_BEGIN); puts(""); printf("
\n" "
\n" @@ -860,8 +877,10 @@ format(const struct req *req, const char *file) if (man->macroset == MACROSET_MDOC) { mdoc_validate(man); html_mdoc(vp, man); - } else + } else { + man_validate(man); html_man(vp, man); + } html_free(vp); mparse_free(mp);