version 1.60, 2014/07/09 17:03:07 |
version 1.63, 2014/07/11 22:27:35 |
Line 165 html_printquery(const struct req *req) |
|
Line 165 html_printquery(const struct req *req) |
|
} |
} |
if (NULL != req->q.expr) { |
if (NULL != req->q.expr) { |
printf("&expr="); |
printf("&expr="); |
html_print(req->q.expr ? req->q.expr : ""); |
html_print(req->q.expr); |
} |
} |
} |
} |
|
|
|
|
http_decode(char *p) |
http_decode(char *p) |
{ |
{ |
char hex[3]; |
char hex[3]; |
|
char *q; |
int c; |
int c; |
|
|
hex[2] = '\0'; |
hex[2] = '\0'; |
|
|
for ( ; '\0' != *p; p++) { |
q = p; |
|
for ( ; '\0' != *p; p++, q++) { |
if ('%' == *p) { |
if ('%' == *p) { |
if ('\0' == (hex[0] = *(p + 1))) |
if ('\0' == (hex[0] = *(p + 1))) |
return(0); |
return(0); |
Line 299 http_decode(char *p) |
|
Line 301 http_decode(char *p) |
|
if ('\0' == c) |
if ('\0' == c) |
return(0); |
return(0); |
|
|
*p = (char)c; |
*q = (char)c; |
memmove(p + 1, p + 3, strlen(p + 3) + 1); |
p += 2; |
} else |
} else |
*p = '+' == *p ? ' ' : *p; |
*q = '+' == *p ? ' ' : *p; |
} |
} |
|
|
*p = '\0'; |
*q = '\0'; |
return(1); |
return(1); |
} |
} |
|
|
Line 314 resp_begin_http(int code, const char *msg) |
|
Line 316 resp_begin_http(int code, const char *msg) |
|
{ |
{ |
|
|
if (200 != code) |
if (200 != code) |
printf("Status: %d %s\n", code, msg); |
printf("Status: %d %s\r\n", code, msg); |
|
|
puts("Content-Type: text/html; charset=utf-8\n" |
printf("Content-Type: text/html; charset=utf-8\r\n" |
"Cache-Control: no-cache\n" |
"Cache-Control: no-cache\r\n" |
"Pragma: no-cache\n" |
"Pragma: no-cache\r\n" |
""); |
"\r\n"); |
|
|
fflush(stdout); |
fflush(stdout); |
} |
} |
Line 367 resp_searchform(const struct req *req) |
|
Line 369 resp_searchform(const struct req *req) |
|
"<FIELDSET>\n" |
"<FIELDSET>\n" |
"<LEGEND>Search Parameters</LEGEND>\n" |
"<LEGEND>Search Parameters</LEGEND>\n" |
"<INPUT TYPE=\"submit\" " |
"<INPUT TYPE=\"submit\" " |
" VALUE=\"Search\"> for manuals satisfying \n" |
" VALUE=\"Search\"> for manuals matching \n" |
"<INPUT TYPE=\"text\" NAME=\"expr\" VALUE=\"", |
"<INPUT TYPE=\"text\" NAME=\"expr\" VALUE=\"", |
scriptname); |
scriptname); |
html_print(req->q.expr ? req->q.expr : ""); |
html_print(req->q.expr ? req->q.expr : ""); |
Line 414 resp_index(const struct req *req) |
|
Line 416 resp_index(const struct req *req) |
|
"</H1>"); |
"</H1>"); |
resp_searchform(req); |
resp_searchform(req); |
puts("<P>\n" |
puts("<P>\n" |
"The <A HREF=\"search?expr=Nm~^apropos$&sec=1\">" |
"This web interface is documented in the " |
|
"<A HREF=\"search?expr=Nm~^man\\.cgi$&sec=8\">" |
|
"man.cgi</A> manual, and the " |
|
"<A HREF=\"search?expr=Nm~^apropos$&sec=1\">" |
"apropos</A> manual explains the query syntax.\n" |
"apropos</A> manual explains the query syntax.\n" |
"</P>"); |
"</P>"); |
resp_end_html(); |
resp_end_html(); |
Line 481 resp_search(const struct req *req, struct manpage *r, |
|
Line 486 resp_search(const struct req *req, struct manpage *r, |
|
* 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. |
*/ |
*/ |
puts("Status: 303 See Other"); |
printf("Status: 303 See Other\r\n"); |
printf("Location: http://%s%s/show/%s/%s?", |
printf("Location: http://%s%s/show/%s/%s?", |
httphost, scriptname, req->q.manpath, r[0].file); |
httphost, scriptname, req->q.manpath, r[0].file); |
http_printquery(req); |
http_printquery(req); |
puts("\n" |
printf("\r\n" |
"Content-Type: text/html; charset=utf-8\n"); |
"Content-Type: text/html; charset=utf-8\r\n" |
|
"\r\n"); |
return; |
return; |
} |
} |
|
|