version 1.45, 2013/06/05 02:00:26 |
version 1.50, 2014/03/23 12:19:03 |
|
|
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
|
#if defined(__sun) |
|
/* for stat() */ |
|
#include <fcntl.h> |
|
#include <sys/types.h> |
|
#include <sys/stat.h> |
|
#endif |
|
|
#include "apropos_db.h" |
#include "apropos_db.h" |
#include "mandoc.h" |
#include "mandoc.h" |
|
#include "mandoc_aux.h" |
#include "mdoc.h" |
#include "mdoc.h" |
#include "man.h" |
#include "man.h" |
#include "main.h" |
#include "main.h" |
#include "manpath.h" |
#include "manpath.h" |
#include "mandocdb.h" |
#include "mandocdb.h" |
|
|
#ifdef __linux__ |
#if defined(__linux__) || defined(__sun) |
# include <db_185.h> |
# include <db_185.h> |
#else |
#else |
# include <db.h> |
# include <db.h> |
Line 732 format(const struct req *req, const char *file) |
|
Line 740 format(const struct req *req, const char *file) |
|
return; |
return; |
} |
} |
|
|
mp = mparse_alloc(MPARSE_AUTO, MANDOCLEVEL_FATAL, NULL, NULL, NULL); |
mp = mparse_alloc(MPARSE_SO, MANDOCLEVEL_FATAL, NULL, NULL); |
rc = mparse_readfd(mp, fd, file); |
rc = mparse_readfd(mp, fd, file); |
close(fd); |
close(fd); |
|
|
Line 746 format(const struct req *req, const char *file) |
|
Line 754 format(const struct req *req, const char *file) |
|
/*"includes=/cgi-bin/man.cgi/usr/include/%%I"*/, |
/*"includes=/cgi-bin/man.cgi/usr/include/%%I"*/, |
progname); |
progname); |
|
|
mparse_result(mp, &mdoc, &man); |
mparse_result(mp, &mdoc, &man, NULL); |
if (NULL == man && NULL == mdoc) { |
if (NULL == man && NULL == mdoc) { |
resp_baddb(); |
resp_baddb(); |
mparse_free(mp); |
mparse_free(mp); |
|
|
pathstop(DIR *dir) |
pathstop(DIR *dir) |
{ |
{ |
struct dirent *d; |
struct dirent *d; |
|
#if defined(__sun) |
|
struct stat sb; |
|
#endif |
|
|
while (NULL != (d = readdir(dir))) |
while (NULL != (d = readdir(dir))) { |
|
#if defined(__sun) |
|
stat(d->d_name, &sb); |
|
if (S_IFREG & sb.st_mode) |
|
#else |
if (DT_REG == d->d_type) |
if (DT_REG == d->d_type) |
|
#endif |
if (0 == strcmp(d->d_name, "catman.conf")) |
if (0 == strcmp(d->d_name, "catman.conf")) |
return(1); |
return(1); |
|
} |
|
|
return(0); |
return(0); |
} |
} |
Line 1118 pathgen(DIR *dir, char *path, struct req *req) |
|
Line 1135 pathgen(DIR *dir, char *path, struct req *req) |
|
DIR *cd; |
DIR *cd; |
int rc; |
int rc; |
size_t sz, ssz; |
size_t sz, ssz; |
|
#if defined(__sun) |
|
struct stat sb; |
|
#endif |
|
|
sz = strlcat(path, "/", PATH_MAX); |
sz = strlcat(path, "/", PATH_MAX); |
if (sz >= PATH_MAX) { |
if (sz >= PATH_MAX) { |
Line 1133 pathgen(DIR *dir, char *path, struct req *req) |
|
Line 1153 pathgen(DIR *dir, char *path, struct req *req) |
|
|
|
rc = 0; |
rc = 0; |
while (0 == rc && NULL != (d = readdir(dir))) { |
while (0 == rc && NULL != (d = readdir(dir))) { |
if (DT_DIR != d->d_type || strcmp(d->d_name, "etc")) |
#if defined(__sun) |
|
stat(d->d_name, &sb); |
|
if (!(S_IFDIR & sb.st_mode) |
|
#else |
|
if (DT_DIR != d->d_type |
|
#endif |
|
|| strcmp(d->d_name, "etc")) |
continue; |
continue; |
|
|
path[(int)sz] = '\0'; |
path[(int)sz] = '\0'; |
Line 1182 pathgen(DIR *dir, char *path, struct req *req) |
|
Line 1208 pathgen(DIR *dir, char *path, struct req *req) |
|
|
|
rewinddir(dir); |
rewinddir(dir); |
while (NULL != (d = readdir(dir))) { |
while (NULL != (d = readdir(dir))) { |
if (DT_DIR != d->d_type || '.' == d->d_name[0]) |
#if defined(__sun) |
|
stat(d->d_name, &sb); |
|
if (!(S_IFDIR & sb.st_mode) |
|
#else |
|
if (DT_DIR != d->d_type |
|
#endif |
|
|| '.' == d->d_name[0]) |
continue; |
continue; |
|
|
path[(int)sz] = '\0'; |
path[(int)sz] = '\0'; |