From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id s6CIWmjH028607 for ; Sat, 12 Jul 2014 14:32:48 -0400 (EDT) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s6CIWmPg000990; Sat, 12 Jul 2014 14:32:48 -0400 (EDT) Date: Sat, 12 Jul 2014 14:32:48 -0400 (EDT) Message-Id: <201407121832.s6CIWmPg000990@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: No need for run-time configuration, add minimal compile-time X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- 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. Modified Files: -------------- mdocml: Makefile cgi.c Added Files: ----------- mdocml: cgi.h.example Revision Data ------------- --- /dev/null +++ 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 "

\nManual pages with " \ + "mandoc\n

" Index: cgi.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/cgi.c,v retrieving revision 1.66 retrieving revision 1.67 diff -Lcgi.c -Lcgi.c -u -p -r1.66 -r1.67 --- cgi.c +++ cgi.c @@ -33,6 +33,7 @@ #include "main.h" #include "manpath.h" #include "mansearch.h" +#include "cgi.h" /* * A query as passed to the search function. @@ -78,8 +79,6 @@ static void resp_search(const struct r 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 */ /* @@ -314,11 +313,11 @@ resp_begin_html(int code, const char *ms " TYPE=\"text/css\" media=\"all\">\n" "\n" - "System Manpage Reference\n" + "%s\n" "\n" "\n" "\n", - cssdir, cssdir); + CSS_DIR, CSS_DIR, CUSTOMIZE_TITLE); } static void @@ -334,6 +333,7 @@ resp_searchform(const struct req *req) { int i; + puts(CUSTOMIZE_BEGIN); puts(""); printf("
\n" "
\n" @@ -391,10 +391,6 @@ resp_index(const struct req *req) { resp_begin_html(200, NULL); - puts("

\n" - "Online manuals with " - "mandoc\n" - "

"); resp_searchform(req); printf("

\n" "This web interface is documented in the " @@ -801,27 +797,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); } Index: Makefile =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/Makefile,v retrieving revision 1.422 retrieving revision 1.423 diff -LMakefile -LMakefile -u -p -r1.422 -r1.423 --- Makefile +++ Makefile @@ -65,7 +65,10 @@ INSTALL_MAN = $(INSTALL_DATA) # the dependency on SQLite3, comment the following two lines. DBLIB = -L/usr/local/lib -lsqlite3 DBBIN = makewhatis manpage apropos -DBBIN += man.cgi + +# To build man.cgi, copy cgi.h.example to cgi.h, edit it, and +# either enable the following line or run "make man.cgi" by hand. +#DBBIN += man.cgi # OpenBSD has the ohash functions in libutil. # Comment the following line if your system doesn't. @@ -250,6 +253,7 @@ msec.o: msec.in roff.o: predefs.in st.o: st.in vol.o: vol.in +cgi.o: cgi.h $(LIBMAN_OBJS): libman.h $(LIBMDOC_OBJS): libmdoc.h -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv