]> git.cameronkatri.com Git - mandoc.git/blob - mdoctree.c
2c62359c39327b5646f2584b716845598e71d49d
[mandoc.git] / mdoctree.c
1 /* $Id: mdoctree.c,v 1.2 2009/02/22 22:58:39 kristaps Exp $ */
2 /*
3 * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
8 * copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 */
19 #include <assert.h>
20 #include <err.h>
21 #include <getopt.h>
22 #include <stdlib.h>
23
24 #include "mmain.h"
25
26 extern void treeprint(const struct mdoc_node *,
27 const struct mdoc_meta *);
28
29 int
30 main(int argc, char *argv[])
31 {
32 struct mmain *p;
33 const struct mdoc *mdoc;
34 int c;
35
36 extern int optreset;
37 extern int optind;
38
39 p = mmain_alloc();
40
41 if ( ! mmain_getopt(p, argc, argv, NULL))
42 mmain_exit(p, 1);
43
44 optreset = optind = 1;
45 printf("here\n");
46
47 while (-1 != (c = getopt(argc, argv, "f:")))
48 switch (c) {
49 case ('f'):
50 printf("%s\n", optarg);
51 break;
52 case ('?'):
53 if (mmain_isopt(optopt)) {
54 printf("ok: %d\n", optopt);
55 break;
56 }
57 printf("bad: %d\n", optopt);
58 /* FALLTHROUGH */
59 default:
60 mmain_usage(NULL);
61 mmain_exit(p, 1);
62 /* NOTREACHED */
63 }
64
65 if (NULL == (mdoc = mmain_mdoc(p)))
66 mmain_exit(p, 1);
67
68 treeprint(mdoc_node(mdoc), mdoc_meta(mdoc));
69 mmain_exit(p, 0);
70 /* NOTREACHED */
71 }
72
73