version 1.120, 2016/04/13 15:38:45 |
version 1.125, 2016/04/15 00:51:59 |
|
|
struct query q; |
struct query q; |
char **p; /* array of available manpaths */ |
char **p; /* array of available manpaths */ |
size_t psz; /* number of available manpaths */ |
size_t psz; /* number of available manpaths */ |
|
int isquery; /* QUERY_STRING used, not PATH_INFO */ |
}; |
}; |
|
|
static void catman(const struct req *, const char *); |
static void catman(const struct req *, const char *); |
Line 107 static const int sec_MAX = sizeof(sec_names) / sizeof( |
|
Line 108 static const int sec_MAX = sizeof(sec_names) / sizeof( |
|
|
|
static const char *const arch_names[] = { |
static const char *const arch_names[] = { |
"amd64", "alpha", "armish", "armv7", |
"amd64", "alpha", "armish", "armv7", |
"aviion", "hppa", "hppa64", "i386", |
"hppa", "hppa64", "i386", "landisk", |
"ia64", "landisk", "loongson", "luna88k", |
"loongson", "luna88k", "macppc", "mips64", |
"macppc", "mips64", "octeon", "sgi", |
"octeon", "sgi", "socppc", "sparc", |
"socppc", "solbourne", "sparc", "sparc64", |
"sparc64", "zaurus", |
"vax", "zaurus", |
|
"amiga", "arc", "arm32", "atari", |
"amiga", "arc", "arm32", "atari", |
"beagle", "cats", "hp300", "mac68k", |
"aviion", "beagle", "cats", "hp300", |
"mvme68k", "mvme88k", "mvmeppc", "palm", |
"ia64", "mac68k", "mvme68k", "mvme88k", |
"pc532", "pegasos", "pmax", "powerpc", |
"mvmeppc", "palm", "pc532", "pegasos", |
"sun3", "wgrisc", "x68k" |
"pmax", "powerpc", "solbourne", "sun3", |
|
"vax", "wgrisc", "x68k" |
}; |
}; |
static const int arch_MAX = sizeof(arch_names) / sizeof(char *); |
static const int arch_MAX = sizeof(arch_names) / sizeof(char *); |
|
|
Line 188 http_parse(struct req *req, const char *qs) |
|
Line 189 http_parse(struct req *req, const char *qs) |
|
char *key, *val; |
char *key, *val; |
size_t keysz, valsz; |
size_t keysz, valsz; |
|
|
|
req->isquery = 1; |
req->q.manpath = NULL; |
req->q.manpath = NULL; |
req->q.arch = NULL; |
req->q.arch = NULL; |
req->q.sec = NULL; |
req->q.sec = NULL; |
Line 568 pg_searchres(const struct req *req, struct manpage *r, |
|
Line 570 pg_searchres(const struct req *req, struct manpage *r, |
|
return; |
return; |
} |
} |
|
|
if (1 == sz) { |
if (req->isquery && sz == 1) { |
/* |
/* |
* If we have just one result, then jump there now |
* If we have just one result, then jump there now |
* without any delay. |
* without any delay. |
Line 586 pg_searchres(const struct req *req, struct manpage *r, |
|
Line 588 pg_searchres(const struct req *req, struct manpage *r, |
|
|
|
resp_begin_html(200, NULL); |
resp_begin_html(200, NULL); |
resp_searchform(req); |
resp_searchform(req); |
puts("<DIV CLASS=\"results\">"); |
|
puts("<TABLE>"); |
|
|
|
for (i = 0; i < sz; i++) { |
if (sz > 1) { |
printf("<TR>\n" |
puts("<DIV CLASS=\"results\">"); |
"<TD CLASS=\"title\">\n" |
puts("<TABLE>"); |
"<A HREF=\"/%s%s%s/%s", |
|
scriptname, *scriptname == '\0' ? "" : "/", |
|
req->q.manpath, r[i].file); |
|
printf("\">"); |
|
html_print(r[i].names); |
|
printf("</A>\n" |
|
"</TD>\n" |
|
"<TD CLASS=\"desc\">"); |
|
html_print(r[i].output); |
|
puts("</TD>\n" |
|
"</TR>"); |
|
} |
|
|
|
puts("</TABLE>\n" |
for (i = 0; i < sz; i++) { |
"</DIV>"); |
printf("<TR>\n" |
|
"<TD CLASS=\"title\">\n" |
|
"<A HREF=\"/%s%s%s/%s", |
|
scriptname, *scriptname == '\0' ? "" : "/", |
|
req->q.manpath, r[i].file); |
|
printf("\">"); |
|
html_print(r[i].names); |
|
printf("</A>\n" |
|
"</TD>\n" |
|
"<TD CLASS=\"desc\">"); |
|
html_print(r[i].output); |
|
puts("</TD>\n" |
|
"</TR>"); |
|
} |
|
|
|
puts("</TABLE>\n" |
|
"</DIV>"); |
|
} |
|
|
/* |
/* |
* In man(1) mode, show one of the pages |
* In man(1) mode, show one of the pages |
* even if more than one is found. |
* even if more than one is found. |
*/ |
*/ |
|
|
if (req->q.equal) { |
if (req->q.equal || sz == 1) { |
puts("<HR>"); |
puts("<HR>"); |
iuse = 0; |
iuse = 0; |
priouse = 20; |
priouse = 20; |
Line 814 format(const struct req *req, const char *file) |
|
Line 819 format(const struct req *req, const char *file) |
|
memset(&conf, 0, sizeof(conf)); |
memset(&conf, 0, sizeof(conf)); |
conf.fragment = 1; |
conf.fragment = 1; |
usepath = strcmp(req->q.manpath, req->p[0]); |
usepath = strcmp(req->q.manpath, req->p[0]); |
mandoc_asprintf(&conf.man, "/%s?query=%%N&sec=%%S%s%s%s%s", |
mandoc_asprintf(&conf.man, "/%s%s%%N.%%S", |
scriptname, |
usepath ? req->q.manpath : "", usepath ? "/" : ""); |
req->q.arch ? "&arch=" : "", |
|
req->q.arch ? req->q.arch : "", |
|
usepath ? "&manpath=" : "", |
|
usepath ? req->q.manpath : ""); |
|
|
|
mparse_result(mp, &man, NULL); |
mparse_result(mp, &man, NULL); |
if (man == NULL) { |
if (man == NULL) { |
|
|
else if (*path == '/') |
else if (*path == '/') |
path++; |
path++; |
|
|
if (*path != '\0' && access(path, F_OK) == -1) { |
if (*path != '\0') { |
path_parse(&req, path); |
path_parse(&req, path); |
path = ""; |
if (access(path, F_OK) == -1) |
|
path = ""; |
} else if ((querystring = getenv("QUERY_STRING")) != NULL) |
} else if ((querystring = getenv("QUERY_STRING")) != NULL) |
http_parse(&req, querystring); |
http_parse(&req, querystring); |
|
|
Line 1085 path_parse(struct req *req, const char *path) |
|
Line 1087 path_parse(struct req *req, const char *path) |
|
{ |
{ |
int dir_done; |
int dir_done; |
|
|
|
req->isquery = 0; |
req->q.equal = 1; |
req->q.equal = 1; |
req->q.manpath = mandoc_strdup(path); |
req->q.manpath = mandoc_strdup(path); |
|
|