aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cgi.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-12-10 23:04:31 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-12-10 23:04:31 +0000
commitf5050a7a94fe2713e123c515c13900a73dbee9c1 (patch)
tree99f8245c430c05ecca6f22adc47ac844d3a14618 /cgi.c
parent876bce67dbedbec3c6aba7e84e4fdb8c8c7a91c5 (diff)
downloadmandoc-f5050a7a94fe2713e123c515c13900a73dbee9c1.tar.gz
mandoc-f5050a7a94fe2713e123c515c13900a73dbee9c1.tar.zst
mandoc-f5050a7a94fe2713e123c515c13900a73dbee9c1.zip
Finishing touches on multi-manroot man.cgi. If more than one root is
specified, write them out using a SELECT box. Else write nothing (the manroot will still be checked if it's specified).
Diffstat (limited to 'cgi.c')
-rw-r--r--cgi.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/cgi.c b/cgi.c
index f3dff9fe..adc34929 100644
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-/* $Id: cgi.c,v 1.26 2011/12/10 22:45:47 kristaps Exp $ */
+/* $Id: cgi.c,v 1.27 2011/12/10 23:04:31 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -364,6 +364,7 @@ resp_end_html(void)
static void
resp_searchform(const struct req *req)
{
+ int i;
puts("<!-- Begin search form. //-->");
printf("<FORM ACTION=\"");
@@ -385,7 +386,22 @@ resp_searchform(const struct req *req)
"<INPUT TYPE=\"text\""
" SIZE=\"8\" NAME=\"arch\" VALUE=\"");
html_print(req->q.arch ? req->q.arch : "");
- puts("\">.\n"
+ printf("\">");
+ if (req->psz > 1) {
+ puts(", <SELECT NAME=\"manpath\">");
+ for (i = 0; i < (int)req->psz; i++) {
+ printf("<OPTION %s VALUE=\"",
+ (i == req->q.manroot) ||
+ (0 == i && -1 == req->q.manroot) ?
+ "SELECTED=\"selected\"" : "");
+ html_print(req->p[i].name);
+ printf("\">");
+ html_print(req->p[i].name);
+ puts("</OPTION>");
+ }
+ puts("</SELECT>");
+ }
+ puts(".\n"
"<INPUT TYPE=\"reset\" VALUE=\"Reset\">\n"
"</FIELDSET>\n"
"</FORM>");
@@ -1100,14 +1116,17 @@ pathgen(DIR *dir, char *path, struct req *req)
if (rc > 0) {
/* This also strips the trailing slash. */
- path[(int)sz - 1] = '\0';
+ path[(int)--sz] = '\0';
req->p = mandoc_realloc
(req->p,
(req->psz + 1) * sizeof(struct paths));
+ /*
+ * Strip out the leading "./" unless we're just a ".",
+ * in which case use an empty string as our name.
+ */
req->p[(int)req->psz].path = mandoc_strdup(path);
- /* And this strips out the leading "./". */
req->p[(int)req->psz].name =
- cp = mandoc_strdup(path + 2);
+ cp = mandoc_strdup(path + (1 == sz ? 1 : 2));
req->psz++;
/*
* The name is just the path with all the slashes taken