version 1.32, 2011/12/15 12:05:19 |
version 1.35, 2011/12/16 12:06:35 |
Line 497 resp_search(struct res *r, size_t sz, void *arg) |
|
Line 497 resp_search(struct res *r, size_t sz, void *arg) |
|
resp_begin_html(200, NULL); |
resp_begin_html(200, NULL); |
resp_searchform(req); |
resp_searchform(req); |
|
|
|
puts("<DIV CLASS=\"results\">"); |
|
|
if (0 == sz) { |
if (0 == sz) { |
printf("<P>\n" |
printf("<P>\n" |
"No %s results found.\n", |
"No %s results found.\n", |
Line 512 resp_search(struct res *r, size_t sz, void *arg) |
|
Line 514 resp_search(struct res *r, size_t sz, void *arg) |
|
puts("\">apropos</A>?)"); |
puts("\">apropos</A>?)"); |
} |
} |
puts("</P>"); |
puts("</P>"); |
|
puts("</DIV>"); |
resp_end_html(); |
resp_end_html(); |
return; |
return; |
} |
} |
|
|
puts("<P></P>\n" |
puts("<TABLE>"); |
"<TABLE>"); |
|
|
|
for (i = 0; i < (int)sz; i++) { |
for (i = 0; i < (int)sz; i++) { |
printf("<TR>\n" |
printf("<TR>\n" |
Line 540 resp_search(struct res *r, size_t sz, void *arg) |
|
Line 542 resp_search(struct res *r, size_t sz, void *arg) |
|
"</TR>"); |
"</TR>"); |
} |
} |
|
|
puts("</TABLE>"); |
puts("</TABLE>\n" |
|
"</DIV>"); |
resp_end_html(); |
resp_end_html(); |
} |
} |
|
|
|
|
pg_show(const struct req *req, char *path) |
pg_show(const struct req *req, char *path) |
{ |
{ |
struct manpaths ps; |
struct manpaths ps; |
|
size_t sz; |
char *sub; |
char *sub; |
char file[MAXPATHLEN]; |
char file[MAXPATHLEN]; |
const char *fn, *cp; |
const char *cp; |
int rc; |
int rc, catm; |
unsigned int vol, rec, mr; |
unsigned int vol, rec, mr; |
DB *idx; |
DB *idx; |
DBT key, val; |
DBT key, val; |
Line 801 pg_show(const struct req *req, char *path) |
|
Line 805 pg_show(const struct req *req, char *path) |
|
goto out; |
goto out; |
} |
} |
|
|
strlcpy(file, ps.paths[vol], MAXPATHLEN); |
sz = strlcpy(file, ps.paths[vol], MAXPATHLEN); |
|
assert(sz < MAXPATHLEN); |
strlcat(file, "/mandoc.index", MAXPATHLEN); |
strlcat(file, "/mandoc.index", MAXPATHLEN); |
|
|
/* Open the index recno(3) database. */ |
/* Open the index recno(3) database. */ |
Line 819 pg_show(const struct req *req, char *path) |
|
Line 824 pg_show(const struct req *req, char *path) |
|
if (0 != (rc = (*idx->get)(idx, &key, &val, 0))) { |
if (0 != (rc = (*idx->get)(idx, &key, &val, 0))) { |
rc < 0 ? resp_baddb() : resp_error400(); |
rc < 0 ? resp_baddb() : resp_error400(); |
goto out; |
goto out; |
} |
} else if (0 == val.size) { |
|
resp_baddb(); |
|
goto out; |
|
} |
|
|
cp = (char *)val.data; |
cp = (char *)val.data; |
|
catm = 'c' == *cp++; |
|
|
if (NULL == (fn = memchr(cp, '\0', val.size))) |
if (NULL == memchr(cp, '\0', val.size - 1)) |
resp_baddb(); |
resp_baddb(); |
else if (++fn - cp >= (int)val.size) |
|
resp_baddb(); |
|
else if (NULL == memchr(fn, '\0', val.size - (fn - cp))) |
|
resp_baddb(); |
|
else { |
else { |
if (0 == strcmp(cp, "cat")) |
file[(int)sz] = '\0'; |
catman(req, fn + 1); |
strlcat(file, "/", MAXPATHLEN); |
|
strlcat(file, cp, MAXPATHLEN); |
|
if (catm) |
|
catman(req, file); |
else |
else |
format(req, fn + 1); |
format(req, file); |
} |
} |
out: |
out: |
if (idx) |
if (idx) |