=================================================================== RCS file: /cvs/mandoc/cgi.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -p -r1.11 -r1.12 --- mandoc/cgi.c 2011/12/07 11:52:36 1.11 +++ mandoc/cgi.c 2011/12/07 13:00:40 1.12 @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.11 2011/12/07 11:52:36 kristaps Exp $ */ +/* $Id: cgi.c,v 1.12 2011/12/07 13:00:40 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * @@ -297,6 +297,8 @@ resp_begin_html(int code, const char *msg) " " "\n" " " "\n" + " " "\n" " System Manpage Reference" "\n" " " "\n" " " "\n" @@ -330,21 +332,27 @@ resp_searchform(const struct req *req) printf("
\n"); - puts("
\n" - " "); - printf(" Terms: \n" + " or \n" + " for manuals satisfying \n" + ""); - printf(" Section: , section " + ""); - printf(" Arch: , arch " + ""); - puts("
\n
\n"); + puts("\">.\n" + "\n" + "\n" + "\n" + ""); } static void @@ -361,12 +369,12 @@ resp_error400(void) { resp_begin_html(400, "Query Malformed"); - puts("

Malformed Query

\n" - "

\n" - " The query your entered was malformed.\n" - " Try again from the\n" - " main page\n" - "

"); + printf("

Malformed Query

\n" + "

\n" + " The query your entered was malformed.\n" + " Try again from the\n" + " main page\n" + "

", progname); resp_end_html(); } @@ -380,11 +388,11 @@ resp_error404(const char *page) " The page you're looking for, "); printf(" "); html_print(page); - puts(",\n" - " could not be found.\n" - " Try searching from the\n" - " main page\n" - "

"); + printf(",\n" + " could not be found.\n" + " Try searching from the\n" + " main page\n" + "

", progname); resp_end_html(); } @@ -423,21 +431,7 @@ resp_search(struct res *r, size_t sz, void *arg) return; } - resp_begin_http(200, NULL); - puts("" "\n" - "" "\n" - " " "\n" - " " "\n" - " " "\n" - " System Manpage Reference" "\n" - " " "\n" - " " "\n" - ""); - + resp_begin_html(200, NULL); resp_searchform((const struct req *)arg); if (0 == sz) @@ -484,7 +478,20 @@ catman(const char *file) return; } - resp_begin_html(200, NULL); + resp_begin_http(200, NULL); + puts("" "\n" + "" "\n" + " " "\n" + " " "\n" + " " "\n" + " System Manpage Reference" "\n" + " " "\n" + " " "\n" + ""); puts("
");
 	while (NULL != (p = fgetln(f, &len))) {
@@ -721,7 +728,7 @@ static void
 pg_search(const struct manpaths *ps, const struct req *req, char *path)
 {
 	size_t		  tt;
-	int		  i, sz, rc;
+	int		  i, sz, rc, whatis;
 	const char	 *ep, *start;
 	char		**cp;
 	struct opts	  opt;
@@ -731,6 +738,7 @@ pg_search(const struct manpaths *ps, const struct req 
 	cp = NULL;
 	ep = NULL;
 	sz = 0;
+	whatis = 0;
 
 	memset(&opt, 0, sizeof(struct opts));
 
@@ -741,6 +749,9 @@ pg_search(const struct manpaths *ps, const struct req 
 			opt.cat = req->fields[i].val;
 		else if (0 == strcmp(req->fields[i].key, "arch"))
 			opt.arch = req->fields[i].val;
+		else if (0 == strcmp(req->fields[i].key, "op"))
+			whatis = 0 == strcasecmp
+				(req->fields[i].val, "whatis");
 
 	/*
 	 * Poor man's tokenisation.
@@ -770,7 +781,10 @@ pg_search(const struct manpaths *ps, const struct req 
 	 * The resp_search() function is called with the results.
 	 */
 
-	if (NULL != (expr = exprcomp(sz, cp, &tt)))
+	expr = whatis ? termcomp(sz, cp, &tt) :
+		        exprcomp(sz, cp, &tt);
+
+	if (NULL != expr)
 		rc = apropos_search
 			(ps->sz, ps->paths, &opt,
 			 expr, tt, (void *)req, resp_search);