version 1.69, 2014/07/13 09:39:32 |
version 1.70, 2014/07/13 12:31:23 |
Line 77 static void resp_noresult(const struct req *, |
|
Line 77 static void resp_noresult(const struct req *, |
|
static void resp_search(const struct req *, |
static void resp_search(const struct req *, |
struct manpage *, size_t); |
struct manpage *, size_t); |
static void resp_searchform(const struct req *); |
static void resp_searchform(const struct req *); |
|
static void resp_show(const struct req *, const char *); |
|
|
static const char *scriptname; /* CGI script name */ |
static const char *scriptname; /* CGI script name */ |
static const char *httphost; /* hostname used in the URIs */ |
static const char *httphost; /* hostname used in the URIs */ |
|
|
|
static const int sec_prios[] = {1, 4, 5, 8, 6, 3, 7, 2, 9}; |
static const char *const sec_numbers[] = { |
static const char *const sec_numbers[] = { |
"0", "1", "2", "3", "3p", "4", "5", "6", "7", "8", "9" |
"0", "1", "2", "3", "3p", "4", "5", "6", "7", "8", "9" |
}; |
}; |
Line 508 resp_error_internal(void) |
|
Line 510 resp_error_internal(void) |
|
static void |
static void |
resp_search(const struct req *req, struct manpage *r, size_t sz) |
resp_search(const struct req *req, struct manpage *r, size_t sz) |
{ |
{ |
size_t i; |
size_t i, iuse, isec; |
|
int prio, priouse; |
|
char sec; |
|
|
if (1 == sz) { |
if (1 == sz) { |
/* |
/* |
Line 550 resp_search(const struct req *req, struct manpage *r, |
|
Line 554 resp_search(const struct req *req, struct manpage *r, |
|
|
|
puts("</TABLE>\n" |
puts("</TABLE>\n" |
"</DIV>"); |
"</DIV>"); |
|
|
|
/* |
|
* In man(1) mode, show one of the pages |
|
* even if more than one is found. |
|
*/ |
|
|
|
if (req->q.equal) { |
|
puts("<HR>"); |
|
iuse = 0; |
|
priouse = 10; |
|
for (i = 0; i < sz; i++) { |
|
isec = strcspn(r[i].file, "123456789"); |
|
sec = r[i].file[isec]; |
|
if ('\0' == sec) |
|
continue; |
|
prio = sec_prios[sec - '1']; |
|
if (prio >= priouse) |
|
continue; |
|
priouse = prio; |
|
iuse = i; |
|
} |
|
resp_show(req, r[iuse].file); |
|
} |
|
|
resp_end_html(); |
resp_end_html(); |
} |
} |
|
|
Line 563 catman(const struct req *req, const char *file) |
|
Line 591 catman(const struct req *req, const char *file) |
|
int italic, bold; |
int italic, bold; |
|
|
if (NULL == (f = fopen(file, "r"))) { |
if (NULL == (f = fopen(file, "r"))) { |
resp_error_badrequest( |
puts("<P>You specified an invalid manual file.</P>"); |
"You specified an invalid manual file."); |
|
return; |
return; |
} |
} |
|
|
resp_begin_html(200, NULL); |
|
resp_searchform(req); |
|
puts("<DIV CLASS=\"catman\">\n" |
puts("<DIV CLASS=\"catman\">\n" |
"<PRE>"); |
"<PRE>"); |
|
|
Line 683 catman(const struct req *req, const char *file) |
|
Line 708 catman(const struct req *req, const char *file) |
|
} |
} |
|
|
puts("</PRE>\n" |
puts("</PRE>\n" |
"</DIV>\n" |
"</DIV>"); |
"</BODY>\n" |
|
"</HTML>"); |
|
|
|
fclose(f); |
fclose(f); |
} |
} |
Line 702 format(const struct req *req, const char *file) |
|
Line 725 format(const struct req *req, const char *file) |
|
char opts[PATH_MAX + 128]; |
char opts[PATH_MAX + 128]; |
|
|
if (-1 == (fd = open(file, O_RDONLY, 0))) { |
if (-1 == (fd = open(file, O_RDONLY, 0))) { |
resp_error_badrequest( |
puts("<P>You specified an invalid manual file.</P>"); |
"You specified an invalid manual file."); |
|
return; |
return; |
} |
} |
|
|
Line 732 format(const struct req *req, const char *file) |
|
Line 754 format(const struct req *req, const char *file) |
|
return; |
return; |
} |
} |
|
|
resp_begin_html(200, NULL); |
|
resp_searchform(req); |
|
|
|
vp = html_alloc(opts); |
vp = html_alloc(opts); |
|
|
if (NULL != mdoc) |
if (NULL != mdoc) |
Line 742 format(const struct req *req, const char *file) |
|
Line 761 format(const struct req *req, const char *file) |
|
else |
else |
html_man(vp, man); |
html_man(vp, man); |
|
|
puts("</BODY>\n" |
|
"</HTML>"); |
|
|
|
html_free(vp); |
html_free(vp); |
mparse_free(mp); |
mparse_free(mp); |
} |
} |
|
|
static void |
static void |
|
resp_show(const struct req *req, const char *file) |
|
{ |
|
|
|
if ('c' == *file) |
|
catman(req, file); |
|
else |
|
format(req, file); |
|
} |
|
|
|
static void |
pg_show(const struct req *req, const char *path) |
pg_show(const struct req *req, const char *path) |
{ |
{ |
char *sub; |
char *sub; |
Line 773 pg_show(const struct req *req, const char *path) |
|
Line 799 pg_show(const struct req *req, const char *path) |
|
return; |
return; |
} |
} |
|
|
if ('c' == *sub) |
resp_begin_html(200, NULL); |
catman(req, sub); |
resp_searchform(req); |
else |
resp_show(req, sub); |
format(req, sub); |
resp_end_html(); |
} |
} |
|
|
static void |
static void |