version 1.52, 2014/07/09 07:30:47 |
version 1.56, 2014/07/09 11:34:46 |
|
|
#endif |
#endif |
|
|
#include <ctype.h> |
#include <ctype.h> |
#include <dirent.h> |
|
#include <fcntl.h> |
#include <fcntl.h> |
#include <limits.h> |
#include <limits.h> |
#include <stdio.h> |
#include <stdio.h> |
Line 77 static void http_parse(struct req *, char *); |
|
Line 76 static void http_parse(struct req *, char *); |
|
static void http_print(const char *); |
static void http_print(const char *); |
static void http_putchar(char); |
static void http_putchar(char); |
static void http_printquery(const struct req *); |
static void http_printquery(const struct req *); |
static void pathgen(DIR *, struct req *); |
static void pathgen(struct req *); |
static void pg_index(const struct req *, char *); |
static void pg_index(const struct req *, char *); |
static void pg_search(const struct req *, char *); |
static void pg_search(const struct req *, char *); |
static void pg_show(const struct req *, char *); |
static void pg_show(const struct req *, char *); |
|
|
http_printquery(const struct req *req) |
http_printquery(const struct req *req) |
{ |
{ |
|
|
printf("&expr="); |
if (NULL != req->q.manroot) { |
http_print(req->q.expr ? req->q.expr : ""); |
printf("&manpath="); |
printf("&sec="); |
http_print(req->q.manroot); |
http_print(req->q.sec ? req->q.sec : ""); |
} |
printf("&arch="); |
if (NULL != req->q.sec) { |
http_print(req->q.arch ? req->q.arch : ""); |
printf("&sec="); |
|
http_print(req->q.sec); |
|
} |
|
if (NULL != req->q.arch) { |
|
printf("&arch="); |
|
http_print(req->q.arch); |
|
} |
|
if (NULL != req->q.expr) { |
|
printf("&expr="); |
|
http_print(req->q.expr ? req->q.expr : ""); |
|
} |
} |
} |
|
|
|
|
|
|
html_printquery(const struct req *req) |
html_printquery(const struct req *req) |
{ |
{ |
|
|
printf("&expr="); |
if (NULL != req->q.manroot) { |
html_print(req->q.expr ? req->q.expr : ""); |
printf("&manpath="); |
printf("&sec="); |
html_print(req->q.manroot); |
html_print(req->q.sec ? req->q.sec : ""); |
} |
printf("&arch="); |
if (NULL != req->q.sec) { |
html_print(req->q.arch ? req->q.arch : ""); |
printf("&sec="); |
|
html_print(req->q.sec); |
|
} |
|
if (NULL != req->q.arch) { |
|
printf("&arch="); |
|
html_print(req->q.arch); |
|
} |
|
if (NULL != req->q.expr) { |
|
printf("&expr="); |
|
html_print(req->q.expr ? req->q.expr : ""); |
|
} |
} |
} |
|
|
static void |
static void |
Line 664 format(const struct req *req, const char *file) |
|
Line 683 format(const struct req *req, const char *file) |
|
return; |
return; |
} |
} |
|
|
mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_FATAL, NULL, NULL); |
mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_FATAL, NULL, |
|
req->q.manroot); |
rc = mparse_readfd(mp, fd, file); |
rc = mparse_readfd(mp, fd, file); |
close(fd); |
close(fd); |
|
|
|
|
main(void) |
main(void) |
{ |
{ |
int i; |
int i; |
DIR *cwd; |
|
struct req req; |
struct req req; |
char *p, *path, *subpath; |
char *p, *path, *subpath; |
|
|
|
|
perror(cache); |
perror(cache); |
resp_bad(); |
resp_bad(); |
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} else if (NULL == (cwd = opendir(cache))) { |
|
perror(cache); |
|
resp_bad(); |
|
return(EXIT_FAILURE); |
|
} |
} |
|
|
memset(&req, 0, sizeof(struct req)); |
memset(&req, 0, sizeof(struct req)); |
|
pathgen(&req); |
|
|
pathgen(cwd, &req); |
|
closedir(cwd); |
|
|
|
/* Next parse out the query string. */ |
/* Next parse out the query string. */ |
|
|
if (NULL != (p = getenv("QUERY_STRING"))) |
if (NULL != (p = getenv("QUERY_STRING"))) |
Line 918 cmp(const void *p1, const void *p2) |
|
Line 931 cmp(const void *p1, const void *p2) |
|
* Scan for indexable paths. |
* Scan for indexable paths. |
*/ |
*/ |
static void |
static void |
pathgen(DIR *dir, struct req *req) |
pathgen(struct req *req) |
{ |
{ |
struct dirent *d; |
FILE *fp; |
#if defined(__sun) |
char *dp; |
struct stat sb; |
size_t dpsz; |
#endif |
|
|
|
while (NULL != (d = readdir(dir))) { |
if (NULL == (fp = fopen("manpath.conf", "r"))) |
#if defined(__sun) |
return; |
stat(d->d_name, &sb); |
|
if (!(S_IFDIR & sb.st_mode) |
while (NULL != (dp = fgetln(fp, &dpsz))) { |
#else |
if ('\n' == dp[dpsz - 1]) |
if (DT_DIR != d->d_type |
dpsz--; |
#endif |
req->p = mandoc_realloc(req->p, |
|| '.' != d->d_name[0]) { |
(req->psz + 1) * sizeof(char *)); |
req->p = mandoc_realloc(req->p, |
req->p[req->psz++] = mandoc_strndup(dp, dpsz); |
(req->psz + 1) * sizeof(char *)); |
|
req->p[req->psz++] = mandoc_strdup(d->d_name); |
|
} |
|
} |
} |
} |
} |