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