version 1.1, 2011/11/26 19:54:13 |
version 1.3, 2011/12/04 22:52:50 |
|
|
} while (/* CONSTCOND */0) |
} while (/* CONSTCOND */0) |
|
|
static int indexhtml(char *); |
static int indexhtml(char *); |
|
#if 0 |
static int jobstart(const char *, const char *, pid_t *); |
static int jobstart(const char *, const char *, pid_t *); |
static int jobwait(pid_t); |
static int jobwait(pid_t); |
|
#endif |
static int manup(const struct manpaths *, const char *); |
static int manup(const struct manpaths *, const char *); |
static int mkpath(char *, mode_t, mode_t); |
static int mkpath(char *, mode_t, mode_t); |
static int treecpy(char *, char *); |
static int treecpy(char *, char *); |
|
|
return(rc); |
return(rc); |
} |
} |
|
|
|
#if 0 |
/* |
/* |
* Clean up existing child. |
* Clean up existing child. |
* Return 1 if cleaned up fine (or none was started) and 0 otherwise. |
* Return 1 if cleaned up fine (or none was started) and 0 otherwise. |
Line 252 jobstart(const char *dst, const char *src, pid_t *pid) |
|
Line 255 jobstart(const char *dst, const char *src, pid_t *pid) |
|
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
/* NOTREACHED */ |
/* NOTREACHED */ |
} |
} |
|
#endif |
|
|
/* |
/* |
* Pass over the recno database and re-create HTML pages if they're |
* Pass over the recno database and re-create HTML pages if they're |
Line 261 jobstart(const char *dst, const char *src, pid_t *pid) |
|
Line 265 jobstart(const char *dst, const char *src, pid_t *pid) |
|
static int |
static int |
indexhtml(char *dst) |
indexhtml(char *dst) |
{ |
{ |
DB *db; |
DB *idx; |
DBT key, val; |
DBT key, val; |
size_t sz; |
size_t sz; |
int c, rc; |
int c, rc; |
unsigned int fl; |
unsigned int fl; |
const char *f; |
const char *f, *cp; |
char *d; |
char *d; |
char fname[MAXPATHLEN]; |
char fname[MAXPATHLEN]; |
pid_t pid; |
pid_t pid; |
Line 277 indexhtml(char *dst) |
|
Line 281 indexhtml(char *dst) |
|
xstrlcpy(fname, dst, MAXPATHLEN); |
xstrlcpy(fname, dst, MAXPATHLEN); |
xstrlcat(fname, "/mandoc.index", MAXPATHLEN); |
xstrlcat(fname, "/mandoc.index", MAXPATHLEN); |
|
|
db = dbopen(fname, O_RDONLY, 0, DB_RECNO, NULL); |
idx = dbopen(fname, O_RDONLY, 0, DB_RECNO, NULL); |
if (NULL == db) { |
if (NULL == idx) { |
perror(fname); |
perror(fname); |
return(-1); |
return(-1); |
} |
} |
|
|
fl = R_FIRST; |
fl = R_FIRST; |
while (0 == (c = (*db->seq)(db, &key, &val, fl))) { |
while (0 == (c = (*idx->seq)(idx, &key, &val, fl))) { |
fl = R_NEXT; |
fl = R_NEXT; |
f = (const char *)val.data; |
cp = (const char *)val.data; |
|
if (0 == val.size) |
|
continue; |
|
if (NULL == (f = memchr(cp, '\0', val.size))) |
|
break; |
|
if (++f - cp >= (int)val.size) |
|
break; |
|
if (NULL == memchr(f, '\0', val.size - (f - cp))) |
|
break; |
|
|
dst[(int)sz] = '\0'; |
dst[(int)sz] = '\0'; |
|
|
xstrlcat(dst, "/", MAXPATHLEN); |
xstrlcat(dst, "/", MAXPATHLEN); |
xstrlcat(dst, f, MAXPATHLEN); |
xstrlcat(dst, f, MAXPATHLEN); |
xstrlcat(dst, ".html", MAXPATHLEN); |
|
|
|
if (-1 == (rc = isnewer(dst, f))) { |
if (-1 == (rc = isnewer(dst, f))) { |
fprintf(stderr, "%s: Manpage missing\n", f); |
fprintf(stderr, "%s: File missing\n", f); |
break; |
break; |
} else if (0 == rc) |
} else if (0 == rc) |
continue; |
continue; |
Line 310 indexhtml(char *dst) |
|
Line 321 indexhtml(char *dst) |
|
} |
} |
|
|
*d = '/'; |
*d = '/'; |
|
|
|
if ( ! filecpy(dst, f)) |
|
break; |
|
#if 0 |
if ( ! jobstart(dst, f, &pid)) |
if ( ! jobstart(dst, f, &pid)) |
break; |
break; |
|
#endif |
if (verbose) |
if (verbose) |
printf("%s\n", dst); |
printf("%s\n", dst); |
} |
} |
|
|
(*db->close)(db); |
(*idx->close)(idx); |
|
|
if (c < 0) |
if (c < 0) |
perror(fname); |
perror(fname); |
|
else if (0 == c) |
|
fprintf(stderr, "%s: Corrupt index\n", fname); |
|
#if 0 |
if ( ! jobwait(pid)) |
if ( ! jobwait(pid)) |
c = -1; |
c = -1; |
|
#endif |
|
|
return(1 == c ? 1 : -1); |
return(1 == c ? 1 : -1); |
} |
} |
Line 425 manup(const struct manpaths *dirs, const char *dir) |
|
Line 445 manup(const struct manpaths *dirs, const char *dir) |
|
return(0); |
return(0); |
} |
} |
|
|
xstrlcat(dst, "/man.conf", MAXPATHLEN); |
xstrlcat(dst, "/catman.conf", MAXPATHLEN); |
|
|
if (verbose) |
if (verbose) |
printf("%s\n", dst); |
printf("%s\n", dst); |