version 1.33, 2011/12/15 12:18:57 |
version 1.35, 2011/12/16 12:06:35 |
|
|
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 804 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 822 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) |