version 1.37, 2011/12/16 20:05:31 |
version 1.40, 2012/03/23 09:03:07 |
|
|
#include "man.h" |
#include "man.h" |
#include "main.h" |
#include "main.h" |
#include "manpath.h" |
#include "manpath.h" |
|
#include "mandocdb.h" |
|
|
#ifdef __linux__ |
#ifdef __linux__ |
# include <db_185.h> |
# include <db_185.h> |
|
|
const char *sec; /* manual section */ |
const char *sec; /* manual section */ |
const char *expr; /* unparsed expression string */ |
const char *expr; /* unparsed expression string */ |
int manroot; /* manroot index (or -1)*/ |
int manroot; /* manroot index (or -1)*/ |
int whatis; /* whether whatis mode */ |
|
int legacy; /* whether legacy mode */ |
int legacy; /* whether legacy mode */ |
}; |
}; |
|
|
Line 134 atou(const char *buf, unsigned *v) |
|
Line 134 atou(const char *buf, unsigned *v) |
|
return(0); |
return(0); |
if ((errno == ERANGE && (lval == LONG_MAX || |
if ((errno == ERANGE && (lval == LONG_MAX || |
lval == LONG_MIN)) || |
lval == LONG_MIN)) || |
(lval > UINT_MAX || lval < 0)) |
(lval > INT_MAX || lval < 0)) |
return(0); |
return(0); |
|
|
*v = (unsigned int)lval; |
*v = (unsigned int)lval; |
Line 229 http_parse(struct req *req, char *p) |
|
Line 229 http_parse(struct req *req, char *p) |
|
|
|
memset(&req->q, 0, sizeof(struct query)); |
memset(&req->q, 0, sizeof(struct query)); |
|
|
req->q.whatis = 1; |
|
legacy = -1; |
legacy = -1; |
manroot = NULL; |
manroot = NULL; |
|
|
Line 267 http_parse(struct req *req, char *p) |
|
Line 266 http_parse(struct req *req, char *p) |
|
manroot = val; |
manroot = val; |
else if (0 == strcmp(key, "apropos")) |
else if (0 == strcmp(key, "apropos")) |
legacy = 0 == strcmp(val, "0"); |
legacy = 0 == strcmp(val, "0"); |
else if (0 == strcmp(key, "op")) |
|
req->q.whatis = 0 == strcasecmp(val, "whatis"); |
|
} |
} |
|
|
/* Test for old man.cgi compatibility mode. */ |
/* Test for old man.cgi compatibility mode. */ |
|
|
if (legacy == 0) { |
req->q.legacy = legacy > 0; |
req->q.whatis = 0; |
|
req->q.legacy = 1; |
|
} else if (legacy > 0) { |
|
req->q.legacy = 1; |
|
req->q.whatis = 1; |
|
} |
|
|
|
/* |
/* |
* Section "0" means no section when in legacy mode. |
* Section "0" means no section when in legacy mode. |
Line 407 resp_searchform(const struct req *req) |
|
Line 398 resp_searchform(const struct req *req) |
|
"<FORM ACTION=\"%s/search.html\" METHOD=\"get\">\n" |
"<FORM ACTION=\"%s/search.html\" METHOD=\"get\">\n" |
"<FIELDSET>\n" |
"<FIELDSET>\n" |
"<LEGEND>Search Parameters</LEGEND>\n" |
"<LEGEND>Search Parameters</LEGEND>\n" |
"<INPUT TYPE=\"submit\" NAME=\"op\"" |
"<INPUT TYPE=\"submit\" " |
" VALUE=\"Whatis\"> or \n" |
" VALUE=\"Search\"> for manuals satisfying \n" |
"<INPUT TYPE=\"submit\" NAME=\"op\"" |
|
" VALUE=\"apropos\"> for manuals satisfying \n" |
|
"<INPUT TYPE=\"text\" NAME=\"expr\" VALUE=\"", |
"<INPUT TYPE=\"text\" NAME=\"expr\" VALUE=\"", |
progname); |
progname); |
html_print(req->q.expr ? req->q.expr : ""); |
html_print(req->q.expr ? req->q.expr : ""); |
Line 537 resp_search(struct res *r, size_t sz, void *arg) |
|
Line 526 resp_search(struct res *r, size_t sz, void *arg) |
|
puts("<DIV CLASS=\"results\">"); |
puts("<DIV CLASS=\"results\">"); |
|
|
if (0 == sz) { |
if (0 == sz) { |
printf("<P>\n" |
puts("<P>\n" |
"No %s results found.\n", |
"No results found.\n" |
req->q.whatis ? "whatis" : "apropos"); |
"</P>\n" |
if (req->q.whatis) { |
"</DIV>"); |
printf("(Try " |
|
"<A HREF=\"%s/search.html?op=apropos", |
|
progname); |
|
html_printquery(req); |
|
puts("\">apropos</A>?)"); |
|
} |
|
puts("</P>"); |
|
puts("</DIV>"); |
|
resp_end_html(); |
resp_end_html(); |
return; |
return; |
} |
} |
Line 843 pg_show(const struct req *req, char *path) |
|
Line 824 pg_show(const struct req *req, char *path) |
|
|
|
sz = strlcpy(file, ps.paths[vol], MAXPATHLEN); |
sz = strlcpy(file, ps.paths[vol], MAXPATHLEN); |
assert(sz < MAXPATHLEN); |
assert(sz < MAXPATHLEN); |
strlcat(file, "/mandoc.index", MAXPATHLEN); |
strlcat(file, "/", MAXPATHLEN); |
|
strlcat(file, MANDOC_IDX, MAXPATHLEN); |
|
|
/* Open the index recno(3) database. */ |
/* Open the index recno(3) database. */ |
|
|
Line 951 pg_search(const struct req *req, char *path) |
|
Line 933 pg_search(const struct req *req, char *path) |
|
* The resp_search() function is called with the results. |
* The resp_search() function is called with the results. |
*/ |
*/ |
|
|
expr = req->q.whatis ? |
expr = req->q.legacy ? |
termcomp(sz, cp, &tt) : exprcomp(sz, cp, &tt); |
termcomp(sz, cp, &tt) : exprcomp(sz, cp, &tt); |
|
|
if (NULL != expr) |
if (NULL != expr) |