man.c revision 1.9 1 /* $NetBSD: man.c,v 1.9 1997/10/17 06:42:11 mikel Exp $ */
2
3 /*
4 * Copyright (c) 1987, 1993, 1994, 1995
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36 #include <sys/cdefs.h>
37
38 #ifndef lint
39 __COPYRIGHT("@(#) Copyright (c) 1987, 1993, 1994, 1995\n\
40 The Regents of the University of California. All rights reserved.\n");
41 #endif /* not lint */
42
43 #ifndef lint
44 #if 0
45 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
46 #else
47 __RCSID("$NetBSD: man.c,v 1.9 1997/10/17 06:42:11 mikel Exp $");
48 #endif
49 #endif /* not lint */
50
51 #include <sys/param.h>
52 #include <sys/queue.h>
53
54 #include <ctype.h>
55 #include <err.h>
56 #include <errno.h>
57 #include <fcntl.h>
58 #include <fnmatch.h>
59 #include <glob.h>
60 #include <signal.h>
61 #include <stdio.h>
62 #include <stdlib.h>
63 #include <string.h>
64 #include <unistd.h>
65
66 #include "config.h"
67 #include "pathnames.h"
68
69 int f_all, f_where;
70
71 int main __P((int, char **));
72 static void build_page __P((char *, char **));
73 static void cat __P((char *));
74 static char *check_pager __P((char *));
75 static int cleanup __P((void));
76 static void how __P((char *));
77 static void jump __P((char **, char *, char *));
78 static int manual __P((char *, TAG *, glob_t *));
79 static void onsig __P((int));
80 static void usage __P((void));
81
82 int
83 main(argc, argv)
84 int argc;
85 char *argv[];
86 {
87 TAG *defp, *defnewp, *section, *sectnewp, *subp;
88 ENTRY *e_defp, *e_sectp, *e_subp, *ep;
89 glob_t pg;
90 size_t len;
91 int ch, f_cat, f_how, found;
92 char **ap, *cmd, *machine, *p, *p_add, *p_path, *pager, *slashp;
93 char *conffile, buf[MAXPATHLEN * 2];
94
95 #ifdef __GNUC__
96 pager = NULL; /* XXX gcc -Wuninitialized */
97 #endif
98
99 f_cat = f_how = 0;
100 conffile = p_add = p_path = NULL;
101 while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:w")) != -1)
102 switch (ch) {
103 case 'a':
104 f_all = 1;
105 break;
106 case 'C':
107 conffile = optarg;
108 break;
109 case 'c':
110 case '-': /* Deprecated. */
111 f_cat = 1;
112 break;
113 case 'h':
114 f_how = 1;
115 break;
116 case 'm':
117 p_add = optarg;
118 break;
119 case 'M':
120 case 'P': /* Backward compatibility. */
121 p_path = optarg;
122 break;
123 /*
124 * The -f and -k options are backward compatible,
125 * undocumented ways of calling whatis(1) and apropos(1).
126 */
127 case 'f':
128 jump(argv, "-f", "whatis");
129 /* NOTREACHED */
130 case 'k':
131 jump(argv, "-k", "apropos");
132 /* NOTREACHED */
133 case 'w':
134 f_all = f_where = 1;
135 break;
136 case '?':
137 default:
138 usage();
139 }
140 argc -= optind;
141 argv += optind;
142
143 if (!*argv)
144 usage();
145
146 if (!f_cat && !f_how && !f_where)
147 if (!isatty(1))
148 f_cat = 1;
149 else if ((pager = getenv("PAGER")) != NULL)
150 pager = check_pager(pager);
151 else
152 pager = _PATH_PAGER;
153
154 /* Read the configuration file. */
155 config(conffile);
156
157 /* Get the machine type. */
158 if ((machine = getenv("MACHINE")) == NULL)
159 machine = MACHINE;
160
161 /* If there's no _default list, create an empty one. */
162 if ((defp = getlist("_default")) == NULL)
163 defp = addlist("_default");
164
165 /*
166 * 1: If the user specified a MANPATH variable, or set the -M
167 * option, we replace the _default list with the user's list,
168 * appending the entries in the _subdir list and the machine.
169 */
170 if (p_path == NULL)
171 p_path = getenv("MANPATH");
172 if (p_path != NULL) {
173 while ((e_defp = defp->list.tqh_first) != NULL) {
174 free(e_defp->s);
175 TAILQ_REMOVE(&defp->list, e_defp, q);
176 }
177 for (p = strtok(p_path, ":");
178 p != NULL; p = strtok(NULL, ":")) {
179 slashp = p[strlen(p) - 1] == '/' ? "" : "/";
180 e_subp = (subp = getlist("_subdir")) == NULL ?
181 NULL : subp->list.tqh_first;
182 for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
183 (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
184 p, slashp, e_subp->s, machine);
185 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
186 (ep->s = strdup(buf)) == NULL)
187 err(1, "malloc");
188 TAILQ_INSERT_TAIL(&defp->list, ep, q);
189 }
190 }
191 }
192
193 /*
194 * 2: If the user did not specify MANPATH, -M or a section, rewrite
195 * the _default list to include the _subdir list and the machine.
196 */
197 if (argv[1] == NULL)
198 section = NULL;
199 else if ((section = getlist(*argv)) != NULL)
200 ++argv;
201 if (p_path == NULL && section == NULL) {
202 defnewp = addlist("_default_new");
203 e_defp =
204 defp->list.tqh_first == NULL ? NULL : defp->list.tqh_first;
205 for (; e_defp != NULL; e_defp = e_defp->q.tqe_next) {
206 slashp =
207 e_defp->s[strlen(e_defp->s) - 1] == '/' ? "" : "/";
208 e_subp = (subp = getlist("_subdir")) == NULL ?
209 NULL : subp->list.tqh_first;
210 for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
211 (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
212 e_defp->s, slashp, e_subp->s, machine);
213 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
214 (ep->s = strdup(buf)) == NULL)
215 err(1, "malloc");
216 TAILQ_INSERT_TAIL(&defnewp->list, ep, q);
217 }
218 }
219 defp = getlist("_default");
220 while ((e_defp = defp->list.tqh_first) != NULL) {
221 free(e_defp->s);
222 TAILQ_REMOVE(&defp->list, e_defp, q);
223 }
224 free(defp->s);
225 TAILQ_REMOVE(&head, defp, q);
226 defnewp = getlist("_default_new");
227 free(defnewp->s);
228 defnewp->s = "_default";
229 defp = defnewp;
230 }
231
232 /*
233 * 3: If the user set the -m option, insert the user's list before
234 * whatever list we have, again appending the _subdir list and
235 * the machine.
236 */
237 if (p_add != NULL)
238 for (p = strtok(p_add, ":"); p != NULL; p = strtok(NULL, ":")) {
239 slashp = p[strlen(p) - 1] == '/' ? "" : "/";
240 e_subp = (subp = getlist("_subdir")) == NULL ?
241 NULL : subp->list.tqh_first;
242 for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
243 (void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
244 p, slashp, e_subp->s, machine);
245 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
246 (ep->s = strdup(buf)) == NULL)
247 err(1, "malloc");
248 TAILQ_INSERT_HEAD(&defp->list, ep, q);
249 }
250 }
251
252 /*
253 * 4: If no -m was specified, and a section was, rewrite the section's
254 * paths (if they have a trailing slash) to append the _subdir list
255 * and the machine. This then becomes the _default list.
256 */
257 if (p_add == NULL && section != NULL) {
258 sectnewp = addlist("_section_new");
259 for (e_sectp = section->list.tqh_first;
260 e_sectp != NULL; e_sectp = e_sectp->q.tqe_next) {
261 if (e_sectp->s[strlen(e_sectp->s) - 1] != '/') {
262 (void)snprintf(buf, sizeof(buf),
263 "%s{/%s,}", e_sectp->s, machine);
264 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
265 (ep->s = strdup(buf)) == NULL)
266 err(1, "malloc");
267 TAILQ_INSERT_TAIL(§newp->list, ep, q);
268 continue;
269 }
270 e_subp = (subp = getlist("_subdir")) == NULL ?
271 NULL : subp->list.tqh_first;
272 for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
273 (void)snprintf(buf, sizeof(buf), "%s%s{/%s,}",
274 e_sectp->s, e_subp->s, machine);
275 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
276 (ep->s = strdup(buf)) == NULL)
277 err(1, "malloc");
278 TAILQ_INSERT_TAIL(§newp->list, ep, q);
279 }
280 }
281 sectnewp->s = section->s;
282 defp = sectnewp;
283 TAILQ_REMOVE(&head, section, q);
284 }
285
286 /*
287 * 5: Search for the files. Set up an interrupt handler, so the
288 * temporary files go away.
289 */
290 (void)signal(SIGINT, onsig);
291 (void)signal(SIGHUP, onsig);
292
293 memset(&pg, 0, sizeof(pg));
294 for (found = 0; *argv; ++argv)
295 if (manual(*argv, defp, &pg))
296 found = 1;
297
298 /* 6: If nothing found, we're done. */
299 if (!found) {
300 (void)cleanup();
301 exit (1);
302 }
303
304 /* 7: If it's simple, display it fast. */
305 if (f_cat) {
306 for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
307 if (**ap == '\0')
308 continue;
309 cat(*ap);
310 }
311 exit (cleanup());
312 }
313 if (f_how) {
314 for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
315 if (**ap == '\0')
316 continue;
317 how(*ap);
318 }
319 exit(cleanup());
320 }
321 if (f_where) {
322 for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
323 if (**ap == '\0')
324 continue;
325 (void)printf("%s\n", *ap);
326 }
327 exit(cleanup());
328 }
329
330 /*
331 * 8: We display things in a single command; build a list of things
332 * to display.
333 */
334 for (ap = pg.gl_pathv, len = strlen(pager) + 1; *ap != NULL; ++ap) {
335 if (**ap == '\0')
336 continue;
337 len += strlen(*ap) + 1;
338 }
339 if ((cmd = malloc(len)) == NULL) {
340 warn("malloc");
341 (void)cleanup();
342 exit(1);
343 }
344 p = cmd;
345 len = strlen(pager);
346 memmove(p, pager, len);
347 p += len;
348 *p++ = ' ';
349 for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
350 if (**ap == '\0')
351 continue;
352 len = strlen(*ap);
353 memmove(p, *ap, len);
354 p += len;
355 *p++ = ' ';
356 }
357 *p = '\0';
358
359 /* Use system(3) in case someone's pager is "pager arg1 arg2". */
360 (void)system(cmd);
361
362 exit(cleanup());
363 }
364
365 /*
366 * manual --
367 * Search the manuals for the pages.
368 */
369 static int
370 manual(page, tag, pg)
371 char *page;
372 TAG *tag;
373 glob_t *pg;
374 {
375 ENTRY *ep, *e_sufp, *e_tag;
376 TAG *missp, *sufp;
377 int anyfound, cnt, found;
378 char *p, buf[MAXPATHLEN];
379
380 anyfound = 0;
381 buf[0] = '*';
382
383 /* For each element in the list... */
384 e_tag = tag == NULL ? NULL : tag->list.tqh_first;
385 for (; e_tag != NULL; e_tag = e_tag->q.tqe_next) {
386 (void)snprintf(buf, sizeof(buf), "%s/%s.*", e_tag->s, page);
387 if (glob(buf,
388 GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT | GLOB_QUOTE,
389 NULL, pg)) {
390 warn("globbing");
391 (void)cleanup();
392 exit(1);
393 }
394 if (pg->gl_matchc == 0)
395 continue;
396
397 /* Find out if it's really a man page. */
398 for (cnt = pg->gl_pathc - pg->gl_matchc;
399 cnt < pg->gl_pathc; ++cnt) {
400
401 /*
402 * Try the _suffix key words first.
403 *
404 * XXX
405 * Older versions of man.conf didn't have the suffix
406 * key words, it was assumed that everything was a .0.
407 * We just test for .0 first, it's fast and probably
408 * going to hit.
409 */
410 (void)snprintf(buf, sizeof(buf), "*/%s.0", page);
411 if (!fnmatch(buf, pg->gl_pathv[cnt], 0))
412 goto next;
413
414 e_sufp = (sufp = getlist("_suffix")) == NULL ?
415 NULL : sufp->list.tqh_first;
416 for (found = 0;
417 e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) {
418 (void)snprintf(buf,
419 sizeof(buf), "*/%s%s", page, e_sufp->s);
420 if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {
421 found = 1;
422 break;
423 }
424 }
425 if (found)
426 goto next;
427
428 /* Try the _build key words next. */
429 e_sufp = (sufp = getlist("_build")) == NULL ?
430 NULL : sufp->list.tqh_first;
431 for (found = 0;
432 e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) {
433 for (p = e_sufp->s;
434 *p != '\0' && !isspace(*p); ++p);
435 if (*p == '\0')
436 continue;
437 *p = '\0';
438 (void)snprintf(buf,
439 sizeof(buf), "*/%s%s", page, e_sufp->s);
440 if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {
441 if (!f_where)
442 build_page(p + 1,
443 &pg->gl_pathv[cnt]);
444 *p = ' ';
445 found = 1;
446 break;
447 }
448 *p = ' ';
449 }
450 if (found) {
451 next: anyfound = 1;
452 if (!f_all) {
453 /* Delete any other matches. */
454 while (++cnt< pg->gl_pathc)
455 pg->gl_pathv[cnt] = "";
456 break;
457 }
458 continue;
459 }
460
461 /* It's not a man page, forget about it. */
462 pg->gl_pathv[cnt] = "";
463 }
464
465 if (anyfound && !f_all)
466 break;
467 }
468
469 /* If not found, enter onto the missing list. */
470 if (!anyfound) {
471 if ((missp = getlist("_missing")) == NULL)
472 missp = addlist("_missing");
473 if ((ep = malloc(sizeof(ENTRY))) == NULL ||
474 (ep->s = strdup(page)) == NULL) {
475 warn("malloc");
476 (void)cleanup();
477 exit(1);
478 }
479 TAILQ_INSERT_TAIL(&missp->list, ep, q);
480 }
481 return (anyfound);
482 }
483
484 /*
485 * build_page --
486 * Build a man page for display.
487 */
488 static void
489 build_page(fmt, pathp)
490 char *fmt, **pathp;
491 {
492 static int warned;
493 ENTRY *ep;
494 TAG *intmpp;
495 int fd, n;
496 char *p, *b;
497 char buf[MAXPATHLEN], cmd[MAXPATHLEN], tpath[sizeof(_PATH_TMP)];
498
499 /* Let the user know this may take awhile. */
500 if (!warned) {
501 warned = 1;
502 warnx("Formatting manual page...");
503 }
504
505 /*
506 * Historically man chdir'd to the root of the man tree.
507 * This was used in man pages that contained relative ".so"
508 * directives (including other man pages for command aliases etc.)
509 * It even went one step farther, by examining the first line
510 * of the man page and parsing the .so filename so it would
511 * make hard(?) links to the cat'ted man pages for space savings.
512 * (We don't do that here, but we could).
513 */
514
515 /* copy and find the end */
516 for (b = buf, p = *pathp; (*b++ = *p++) != '\0';)
517 continue;
518
519 /* skip the last two path components, page name and man[n] */
520 for (--b, n = 2; b != buf; b--)
521 if (*b == '/')
522 if (--n == 0) {
523 *b = '\0';
524 (void) chdir(buf);
525 }
526
527
528 /* Add a remove-when-done list. */
529 if ((intmpp = getlist("_intmp")) == NULL)
530 intmpp = addlist("_intmp");
531
532 /* Move to the printf(3) format string. */
533 for (; *fmt && isspace(*fmt); ++fmt);
534
535 /*
536 * Get a temporary file and build a version of the file
537 * to display. Replace the old file name with the new one.
538 */
539 (void)strcpy(tpath, _PATH_TMP);
540 if ((fd = mkstemp(tpath)) == -1) {
541 warn("%s", tpath);
542 (void)cleanup();
543 exit(1);
544 }
545 (void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath);
546 (void)snprintf(cmd, sizeof(cmd), buf, *pathp);
547 (void)system(cmd);
548 (void)close(fd);
549 if ((*pathp = strdup(tpath)) == NULL) {
550 warn("malloc");
551 (void)cleanup();
552 exit(1);
553 }
554
555 /* Link the built file into the remove-when-done list. */
556 if ((ep = malloc(sizeof(ENTRY))) == NULL) {
557 warn("malloc");
558 (void)cleanup();
559 exit(1);
560 }
561 ep->s = *pathp;
562 TAILQ_INSERT_TAIL(&intmpp->list, ep, q);
563 }
564
565 /*
566 * how --
567 * display how information
568 */
569 static void
570 how(fname)
571 char *fname;
572 {
573 FILE *fp;
574
575 int lcnt, print;
576 char *p, buf[256];
577
578 if (!(fp = fopen(fname, "r"))) {
579 warn("%s", fname);
580 (void)cleanup();
581 exit (1);
582 }
583 #define S1 "SYNOPSIS"
584 #define S2 "S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS"
585 #define D1 "DESCRIPTION"
586 #define D2 "D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN"
587 for (lcnt = print = 0; fgets(buf, sizeof(buf), fp);) {
588 if (!strncmp(buf, S1, sizeof(S1) - 1) ||
589 !strncmp(buf, S2, sizeof(S2) - 1)) {
590 print = 1;
591 continue;
592 } else if (!strncmp(buf, D1, sizeof(D1) - 1) ||
593 !strncmp(buf, D2, sizeof(D2) - 1))
594 return;
595 if (!print)
596 continue;
597 if (*buf == '\n')
598 ++lcnt;
599 else {
600 for(; lcnt; --lcnt)
601 (void)putchar('\n');
602 for (p = buf; isspace(*p); ++p);
603 (void)fputs(p, stdout);
604 }
605 }
606 (void)fclose(fp);
607 }
608
609 /*
610 * cat --
611 * cat out the file
612 */
613 static void
614 cat(fname)
615 char *fname;
616 {
617 int fd, n;
618 char buf[2048];
619
620 if ((fd = open(fname, O_RDONLY, 0)) < 0) {
621 warn("%s", fname);
622 (void)cleanup();
623 exit(1);
624 }
625 while ((n = read(fd, buf, sizeof(buf))) > 0)
626 if (write(STDOUT_FILENO, buf, n) != n) {
627 warn("write");
628 (void)cleanup();
629 exit (1);
630 }
631 if (n == -1) {
632 warn("read");
633 (void)cleanup();
634 exit(1);
635 }
636 (void)close(fd);
637 }
638
639 /*
640 * check_pager --
641 * check the user supplied page information
642 */
643 static char *
644 check_pager(name)
645 char *name;
646 {
647 char *p, *save;
648
649 /*
650 * if the user uses "more", we make it "more -s"; watch out for
651 * PAGER = "mypager /usr/ucb/more"
652 */
653 for (p = name; *p && !isspace(*p); ++p);
654 for (; p > name && *p != '/'; --p);
655 if (p != name)
656 ++p;
657
658 /* make sure it's "more", not "morex" */
659 if (!strncmp(p, "more", 4) && (!p[4] || isspace(p[4]))){
660 save = name;
661 /* allocate space to add the "-s" */
662 if (!(name =
663 malloc((u_int)(strlen(save) + sizeof("-s") + 1))))
664 err(1, "malloc");
665 (void)sprintf(name, "%s %s", save, "-s");
666 }
667 return(name);
668 }
669
670 /*
671 * jump --
672 * strip out flag argument and jump
673 */
674 static void
675 jump(argv, flag, name)
676 char **argv, *flag, *name;
677 {
678 char **arg;
679
680 argv[0] = name;
681 for (arg = argv + 1; *arg; ++arg)
682 if (!strcmp(*arg, flag))
683 break;
684 for (; *arg; ++arg)
685 arg[0] = arg[1];
686 execvp(name, argv);
687 (void)fprintf(stderr, "%s: Command not found.\n", name);
688 exit(1);
689 }
690
691 /*
692 * onsig --
693 * If signaled, delete the temporary files.
694 */
695 static void
696 onsig(signo)
697 int signo;
698 {
699 (void)cleanup();
700
701 (void)signal(signo, SIG_DFL);
702 (void)kill(getpid(), signo);
703
704 /* NOTREACHED */
705 exit (1);
706 }
707
708 /*
709 * cleanup --
710 * Clean up temporary files, show any error messages.
711 */
712 static int
713 cleanup()
714 {
715 TAG *intmpp, *missp;
716 ENTRY *ep;
717 int rval;
718
719 rval = 0;
720 ep = (missp = getlist("_missing")) == NULL ?
721 NULL : missp->list.tqh_first;
722 if (ep != NULL)
723 for (; ep != NULL; ep = ep->q.tqe_next) {
724 warnx("no entry for %s in the manual.", ep->s);
725 rval = 1;
726 }
727
728 ep = (intmpp = getlist("_intmp")) == NULL ?
729 NULL : intmpp->list.tqh_first;
730 for (; ep != NULL; ep = ep->q.tqe_next)
731 (void)unlink(ep->s);
732 return (rval);
733 }
734
735 /*
736 * usage --
737 * print usage message and die
738 */
739 static void
740 usage()
741 {
742 (void)fprintf(stderr,
743 "usage: man [-achw] [-C file] [-M path] [-m path] [section] title ...\n");
744 exit(1);
745 }
746