=================================================================== RCS file: /cvs/mandoc/cgi.c,v retrieving revision 1.57 retrieving revision 1.58 diff -u -p -r1.57 -r1.58 --- mandoc/cgi.c 2014/07/09 12:09:04 1.57 +++ mandoc/cgi.c 2014/07/09 14:18:59 1.58 @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.57 2014/07/09 12:09:04 schwarze Exp $ */ +/* $Id: cgi.c,v 1.58 2014/07/09 14:18:59 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2014 Ingo Schwarze @@ -20,6 +20,7 @@ #endif #include +#include #include #include #include @@ -44,7 +45,7 @@ enum page { * A query as passed to the search function. */ struct query { - const char *manroot; /* manual root directory */ + const char *manpath; /* desired manual directory */ const char *arch; /* architecture */ const char *sec; /* manual section */ const char *expr; /* unparsed expression string */ @@ -52,10 +53,10 @@ struct query { }; struct req { - struct query q; - char **p; /* array of available manroots */ - size_t psz; /* number of available manroots */ - enum page page; + struct query q; + char **p; /* array of available manpaths */ + size_t psz; /* number of available manpaths */ + enum page page; }; static void catman(const struct req *, const char *); @@ -85,10 +86,10 @@ static void resp_search(const struct req *, struct manpage *, size_t); static void resp_searchform(const struct req *); -static const char *progname; /* cgi script name */ -static const char *cache; /* cache directory */ -static const char *css; /* css directory */ -static const char *host; /* hostname */ +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 */ static const char * const pages[PAGE__MAX] = { "index", /* PAGE_INDEX */ @@ -127,9 +128,9 @@ static void http_printquery(const struct req *req) { - if (NULL != req->q.manroot) { + if (NULL != req->q.manpath) { printf("&manpath="); - http_print(req->q.manroot); + http_print(req->q.manpath); } if (NULL != req->q.sec) { printf("&sec="); @@ -149,9 +150,9 @@ static void html_printquery(const struct req *req) { - if (NULL != req->q.manroot) { + if (NULL != req->q.manpath) { printf("&manpath="); - html_print(req->q.manroot); + html_print(req->q.manpath); } if (NULL != req->q.sec) { printf("&sec="); @@ -203,7 +204,7 @@ http_parse(struct req *req, char *p) int legacy; memset(&req->q, 0, sizeof(struct query)); - req->q.manroot = req->p[0]; + req->q.manpath = req->p[0]; legacy = -1; while ('\0' != *p) { @@ -237,7 +238,7 @@ http_parse(struct req *req, char *p) else if (0 == strcmp(key, "arch")) req->q.arch = val; else if (0 == strcmp(key, "manpath")) - req->q.manroot = val; + req->q.manpath = val; else if (0 == strcmp(key, "apropos")) legacy = 0 == strcmp(val, "0"); } @@ -342,7 +343,8 @@ resp_begin_html(int code, const char *msg) "System Manpage Reference\n" "\n" "\n" - "\n", css, css); + "\n", + cssdir, cssdir); } static void @@ -366,7 +368,7 @@ resp_searchform(const struct req *req) " for manuals satisfying \n" "q.expr ? req->q.expr : ""); printf("\">, section " ""); for (i = 0; i < (int)req->psz; i++) { printf("