version 1.20, 2002/02/16 21:27:48 |
version 1.21, 2002/09/17 19:37:39 |
|
|
sigset_t blocksigs; |
sigset_t blocksigs; |
|
|
int |
int |
main(argc, argv) |
main(int argc, char *argv[]) |
int argc; |
|
char *argv[]; |
|
{ |
{ |
extern char *optarg; |
extern char *optarg; |
extern int optind; |
extern int optind; |
|
|
if ((ep = malloc(sizeof(ENTRY))) == NULL || |
if ((ep = malloc(sizeof(ENTRY))) == NULL || |
(ep->s = strdup(buf)) == NULL) |
(ep->s = strdup(buf)) == NULL) |
err(1, NULL); |
err(1, NULL); |
/* puts it at the end, should be at the top, but then the added |
/* |
entries would be in reverse order, fix later when all are added*/ |
* puts it at the end, should be at the top, |
|
* but then the added entries would be in |
|
* reverse order, fix later when all are added |
|
*/ |
TAILQ_INSERT_TAIL(&defp->list, ep, q); |
TAILQ_INSERT_TAIL(&defp->list, ep, q); |
if (e_sectp == NULL) /* save first added, to-be the new top */ |
if (e_sectp == NULL) |
|
/* save first added, to-be the new top */ |
e_sectp = ep; |
e_sectp = ep; |
} |
} |
} |
} |
if (e_sectp != NULL) { /* entries added, fix order */ |
if (e_sectp != NULL) { /* entries added, fix order */ |
ep->q.tqe_next = defp->list.tqh_first; /* save original head */ |
/* save original head */ |
defp->list.tqh_first = e_sectp; /* first added entry, new top */ |
ep->q.tqe_next = defp->list.tqh_first; |
*e_sectp->q.tqe_prev = NULL; /* terminate list */ |
/* first added entry, new top */ |
|
defp->list.tqh_first = e_sectp; |
|
/* terminate list */ |
|
*e_sectp->q.tqe_prev = NULL; |
} |
} |
} |
} |
/* |
/* |
|
|
* Build a man page for display. |
* Build a man page for display. |
*/ |
*/ |
static void |
static void |
build_page(fmt, pathp) |
build_page(char *fmt, char **pathp) |
char *fmt, **pathp; |
|
{ |
{ |
static int warned; |
static int warned; |
ENTRY *ep; |
ENTRY *ep; |
|
|
* display how information |
* display how information |
*/ |
*/ |
static void |
static void |
how(fname) |
how(char *fname) |
char *fname; |
|
{ |
{ |
FILE *fp; |
FILE *fp; |
|
|
|
|
* cat out the file |
* cat out the file |
*/ |
*/ |
static void |
static void |
cat(fname) |
cat(char *fname) |
char *fname; |
|
{ |
{ |
int fd, n; |
int fd, n; |
char buf[2048]; |
char buf[2048]; |
|
|
* check the user supplied page information |
* check the user supplied page information |
*/ |
*/ |
static char * |
static char * |
check_pager(name) |
check_pager(char *name) |
char *name; |
|
{ |
{ |
char *p, *save; |
char *p, *save; |
|
|
|
|
* strip out flag argument and jump |
* strip out flag argument and jump |
*/ |
*/ |
static void |
static void |
jump(argv, flag, name) |
jump(char **argv, char *flag, char *name) |
char **argv, *flag, *name; |
|
{ |
{ |
char **arg; |
char **arg; |
|
|
|
|
* If signaled, delete the temporary files. |
* If signaled, delete the temporary files. |
*/ |
*/ |
static void |
static void |
onsig(signo) |
onsig(int signo) |
int signo; |
|
{ |
{ |
(void)cleanup(); |
(void)cleanup(); /* XXX signal race */ |
|
|
(void)signal(signo, SIG_DFL); |
(void)signal(signo, SIG_DFL); |
(void)kill(getpid(), signo); |
(void)kill(getpid(), signo); |
|
|
* Clean up temporary files, show any error messages. |
* Clean up temporary files, show any error messages. |
*/ |
*/ |
static int |
static int |
cleanup() |
cleanup(void) |
{ |
{ |
TAG *intmpp, *missp; |
TAG *intmpp, *missp; |
ENTRY *ep; |
ENTRY *ep; |
|
|
* print usage message and die |
* print usage message and die |
*/ |
*/ |
static void |
static void |
usage() |
usage(void) |
{ |
{ |
(void)fprintf(stderr, "usage: %s [-achw] [-C file] [-M path] [-m path] " |
(void)fprintf(stderr, "usage: %s [-achw] [-C file] [-M path] [-m path] " |
"[-s section] [-S subsection] [section] title ...\n", __progname); |
"[-s section] [-S subsection] [section] title ...\n", __progname); |