- int i;
- const char *expr, *sec, *arch;
-
- expr = sec = arch = "";
-
- for (i = 0; i < (int)req->fieldsz; i++)
- if (0 == strcmp(req->fields[i].key, "expr"))
- expr = req->fields[i].val;
- else if (0 == strcmp(req->fields[i].key, "query"))
- expr = req->fields[i].val;
- else if (0 == strcmp(req->fields[i].key, "sec"))
- sec = req->fields[i].val;
- else if (0 == strcmp(req->fields[i].key, "sektion"))
- sec = req->fields[i].val;
- else if (0 == strcmp(req->fields[i].key, "arch"))
- arch = req->fields[i].val;
-
- if (NULL != sec && 0 == strcmp(sec, "0"))
- sec = NULL;
-
- puts("<!-- Begin search form. //-->");
- printf("<FORM ACTION=\"");
- html_print(progname);
- printf("/search.html\" METHOD=\"get\">\n");
- printf("<FIELDSET>\n"
- "<LEGEND>Search Parameters</LEGEND>\n"
- "<INPUT TYPE=\"submit\" NAME=\"op\" "
- "VALUE=\"Whatis\"> or \n"
- "<INPUT TYPE=\"submit\" NAME=\"op\" "
- "VALUE=\"apropos\"> for manuals satisfying \n"
- "<INPUT TYPE=\"text\" NAME=\"expr\" VALUE=\"");
- html_print(expr);
- printf("\">, section "
- "<INPUT TYPE=\"text\" "
- "SIZE=\"4\" NAME=\"sec\" VALUE=\"");
- html_print(sec);
- printf("\">, arch "
- "<INPUT TYPE=\"text\" "
- "SIZE=\"8\" NAME=\"arch\" VALUE=\"");
- html_print(arch);
- puts("\">.\n"
- "<INPUT TYPE=\"reset\" VALUE=\"Reset\">\n"
- "</FIELDSET>\n"
- "</FORM>\n"
- "<!-- End search form. //-->");
+ int i;
+
+ printf("<form action=\"/%s\" method=\"get\">\n"
+ " <fieldset>\n"
+ " <legend>Manual Page Search Parameters</legend>\n",
+ scriptname);
+
+ /* Write query input box. */
+
+ printf(" <input type=\"text\" name=\"query\" value=\"");
+ if (req->q.query != NULL)
+ html_print(req->q.query);
+ printf( "\" size=\"40\"");
+ if (focus == FOCUS_QUERY)
+ printf(" autofocus");
+ puts(">");
+
+ /* Write submission buttons. */
+
+ printf( " <button type=\"submit\" name=\"apropos\" value=\"0\">"
+ "man</button>\n"
+ " <button type=\"submit\" name=\"apropos\" value=\"1\">"
+ "apropos</button>\n"
+ " <br/>\n");
+
+ /* Write section selector. */
+
+ puts(" <select name=\"sec\">");
+ for (i = 0; i < sec_MAX; i++) {
+ printf(" <option value=\"%s\"", sec_numbers[i]);
+ if (NULL != req->q.sec &&
+ 0 == strcmp(sec_numbers[i], req->q.sec))
+ printf(" selected=\"selected\"");
+ printf(">%s</option>\n", sec_names[i]);
+ }
+ puts(" </select>");
+
+ /* Write architecture selector. */
+
+ printf( " <select name=\"arch\">\n"
+ " <option value=\"default\"");
+ if (NULL == req->q.arch)
+ printf(" selected=\"selected\"");
+ puts(">All Architectures</option>");
+ for (i = 0; i < arch_MAX; i++) {
+ printf(" <option value=\"%s\"", arch_names[i]);
+ if (NULL != req->q.arch &&
+ 0 == strcmp(arch_names[i], req->q.arch))
+ printf(" selected=\"selected\"");
+ printf(">%s</option>\n", arch_names[i]);
+ }
+ puts(" </select>");
+
+ /* Write manpath selector. */
+
+ if (req->psz > 1) {
+ puts(" <select name=\"manpath\">");
+ for (i = 0; i < (int)req->psz; i++) {
+ printf(" <option ");
+ if (strcmp(req->q.manpath, req->p[i]) == 0)
+ printf("selected=\"selected\" ");
+ printf("value=\"");
+ html_print(req->p[i]);
+ printf("\">");
+ html_print(req->p[i]);
+ puts("</option>");
+ }
+ puts(" </select>");
+ }
+
+ puts(" </fieldset>\n"
+ "</form>");