[BACK]Return to mdoctree.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/mdoctree.c, Revision 1.2

1.2     ! kristaps    1:        /* $Id: mdocterm.c,v 1.1 2009/02/21 21:00:06 kristaps Exp $ */
1.1       kristaps    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:
1.2     ! kristaps   24: #include "mmain.h"
1.1       kristaps   25:
1.2     ! kristaps   26: extern void    treeprint(const struct mdoc_node *,
        !            27:                        const struct mdoc_meta *);
1.1       kristaps   28:
                     29: int
                     30: main(int argc, char *argv[])
                     31: {
1.2     ! kristaps   32:        struct mmain    *p;
        !            33:        const struct mdoc *mdoc;
1.1       kristaps   34:        int              c;
1.2     ! kristaps   35:
        !            36:        extern int       optreset;
1.1       kristaps   37:        extern int       optind;
                     38:
1.2     ! kristaps   39:        p = mmain_alloc();
1.1       kristaps   40:
1.2     ! kristaps   41:        if ( ! mmain_getopt(p, argc, argv, NULL))
        !            42:                mmain_exit(p, 1);
1.1       kristaps   43:
1.2     ! kristaps   44:        optreset = optind = 1;
        !            45:        printf("here\n");
1.1       kristaps   46:
1.2     ! kristaps   47:        while (-1 != (c = getopt(argc, argv, "f:")))
        !            48:                switch (c) {
        !            49:                case ('f'):
        !            50:                        printf("%s\n", optarg);
1.1       kristaps   51:                        break;
1.2     ! kristaps   52:                case ('?'):
        !            53:                        if (mmain_isopt(optopt)) {
        !            54:                                printf("ok: %d\n", optopt);
        !            55:                                break;
        !            56:                        }
        !            57:                        printf("bad: %d\n", optopt);
        !            58:                        /* FALLTHROUGH */
1.1       kristaps   59:                default:
1.2     ! kristaps   60:                        mmain_usage(NULL);
        !            61:                        mmain_exit(p, 1);
        !            62:                        /* NOTREACHED */
1.1       kristaps   63:                }
                     64:
1.2     ! kristaps   65:        if (NULL == (mdoc = mmain_mdoc(p)))
        !            66:                mmain_exit(p, 1);
1.1       kristaps   67:
1.2     ! kristaps   68:        treeprint(mdoc_node(mdoc), mdoc_meta(mdoc));
        !            69:        mmain_exit(p, 0);
        !            70:        /* NOTREACHED */
1.1       kristaps   71: }
                     72:
                     73:

CVSweb