diff options
author | 2014-07-12 18:05:50 +0000 | |
---|---|---|
committer | 2014-07-12 18:05:50 +0000 | |
commit | 6fdade3e4aec538b504f1bbdb84def4af704ed80 (patch) | |
tree | 3c26e489568352965aa9e81e996ab4eff537bb87 | |
parent | Remove #ifndefs for OPENSSL_NO_DH, OPENSSL_NO_ECDH and (diff) | |
download | wireguard-openbsd-6fdade3e4aec538b504f1bbdb84def4af704ed80.tar.xz wireguard-openbsd-6fdade3e4aec538b504f1bbdb84def4af704ed80.zip |
No need for run-time configuration, add minimal compile-time
configuration facilities, just two paths and two HTML strings.
Show the title on all pages, not just the index page.
-rw-r--r-- | usr.bin/mandoc/Makefile | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/cgi.c | 26 | ||||
-rw-r--r-- | usr.bin/mandoc/cgi.h.example | 7 |
3 files changed, 18 insertions, 20 deletions
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile index 9f681b167d4..ab1b1c80e9a 100644 --- a/usr.bin/mandoc/Makefile +++ b/usr.bin/mandoc/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.78 2014/07/11 15:37:22 schwarze Exp $ +# $OpenBSD: Makefile,v 1.79 2014/07/12 18:05:50 schwarze Exp $ .include <bsd.own.mk> @@ -35,6 +35,7 @@ CLEANFILES += man.cgi cgi.o man.cgi.8.manlint # Variables and targets to build and install man.cgi(8), # not used during make build and make release. +# To configure, run: cp cgi.h.example cgi.h; vi cgi.h # To build, run: make man.cgi # To install, run: sudo make installcgi # After that, read: man man.cgi.8 @@ -49,7 +50,7 @@ HTML_OBJS = html.o mdoc_html.o man_html.o tbl_html.o eqn_html.o out.o CGI_OBJS = ${LIBMANDOC_OBJS} ${HTML_OBJS} \ mansearch.o mansearch_const.o cgi.o -cgi.o: main.h mandoc.h mandoc_aux.h manpath.h mansearch.h +cgi.o: main.h mandoc.h mandoc_aux.h manpath.h mansearch.h cgi.h man.cgi: ${CGI_OBJS} ${CC} ${LDFLAGS} -static -o ${.TARGET} ${CGI_OBJS} ${LDADD} diff --git a/usr.bin/mandoc/cgi.c b/usr.bin/mandoc/cgi.c index d89b8af3bf2..17828a00b4b 100644 --- a/usr.bin/mandoc/cgi.c +++ b/usr.bin/mandoc/cgi.c @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.6 2014/07/12 17:18:13 schwarze Exp $ */ +/* $Id: cgi.c,v 1.7 2014/07/12 18:05:50 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014 Ingo Schwarze <schwarze@usta.de> @@ -29,6 +29,7 @@ #include "main.h" #include "manpath.h" #include "mansearch.h" +#include "cgi.h" /* * A query as passed to the search function. @@ -74,8 +75,6 @@ static void resp_search(const struct req *, static void resp_searchform(const struct req *); static const char *scriptname; /* CGI script name */ -static const char *mandir; /* contains all manpath directories */ -static const char *cssdir; /* css directory */ static const char *httphost; /* hostname used in the URIs */ /* @@ -310,11 +309,11 @@ resp_begin_html(int code, const char *msg) " TYPE=\"text/css\" media=\"all\">\n" "<LINK REL=\"stylesheet\" HREF=\"%s/man.css\"" " TYPE=\"text/css\" media=\"all\">\n" - "<TITLE>System Manpage Reference</TITLE>\n" + "<TITLE>%s</TITLE>\n" "</HEAD>\n" "<BODY>\n" "<!-- Begin page content. //-->\n", - cssdir, cssdir); + CSS_DIR, CSS_DIR, CUSTOMIZE_TITLE); } static void @@ -330,6 +329,7 @@ resp_searchform(const struct req *req) { int i; + puts(CUSTOMIZE_BEGIN); puts("<!-- Begin search form. //-->"); printf("<DIV ID=\"mancgi\">\n" "<FORM ACTION=\"%s\" METHOD=\"get\">\n" @@ -387,10 +387,6 @@ resp_index(const struct req *req) { resp_begin_html(200, NULL); - puts("<H1>\n" - "Online manuals with " - "<A HREF=\"http://mdocml.bsd.lv/\">mandoc</A>\n" - "</H1>"); resp_searchform(req); printf("<P>\n" "This web interface is documented in the " @@ -797,27 +793,21 @@ main(void) /* Scan our run-time environment. */ - if (NULL == (mandir = getenv("MAN_DIR"))) - mandir = "/man"; - if (NULL == (scriptname = getenv("SCRIPT_NAME"))) scriptname = ""; - if (NULL == (cssdir = getenv("CSS_DIR"))) - cssdir = ""; - if (NULL == (httphost = getenv("HTTP_HOST"))) httphost = "localhost"; /* - * First we change directory into the mandir so that + * First we change directory into the MAN_DIR so that * subsequent scanning for manpath directories is rooted * relative to the same position. */ - if (-1 == chdir(mandir)) { + if (-1 == chdir(MAN_DIR)) { fprintf(stderr, "MAN_DIR: %s: %s\n", - mandir, strerror(errno)); + MAN_DIR, strerror(errno)); resp_error_internal(); return(EXIT_FAILURE); } diff --git a/usr.bin/mandoc/cgi.h.example b/usr.bin/mandoc/cgi.h.example new file mode 100644 index 00000000000..95508defe57 --- /dev/null +++ b/usr.bin/mandoc/cgi.h.example @@ -0,0 +1,7 @@ +/* Example compile-time configuration file for man.cgi(8). */ + +#define MAN_DIR "/var/www/man" +#define CSS_DIR "" +#define CUSTOMIZE_TITLE "Manual pages with mandoc" +#define CUSTOMIZE_BEGIN "<H2>\nManual pages with " \ + "<A HREF=\"http://mdocml.bsd.lv/\">mandoc</A>\n</H2>" |