[BACK]Return to libmdoc.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Annotation of src/usr.bin/mandoc/libmdoc.h, Revision 1.2

1.2     ! miod        1: /* $Id: libmdoc.h,v 1.1 2009/04/06 20:30:40 kristaps Exp $ */
1.1       kristaps    2: /*
                      3:  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@openbsd.org>
                      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: #ifndef LIBMDOC_H
                     20: #define LIBMDOC_H
                     21:
                     22: #include "mdoc.h"
                     23:
                     24: enum   mdoc_next {
                     25:        MDOC_NEXT_SIBLING = 0,
                     26:        MDOC_NEXT_CHILD
                     27: };
                     28:
                     29: struct mdoc {
                     30:        void             *data;
                     31:        struct mdoc_cb    cb;
                     32:        void             *htab;
                     33:        int               flags;
                     34: #define        MDOC_HALT        (1 << 0)
                     35: #define        MDOC_LITERAL     (1 << 1)
                     36:        int               pflags;
                     37:        enum mdoc_next    next;
                     38:        struct mdoc_node *last;
                     39:        struct mdoc_node *first;
                     40:        struct mdoc_meta  meta;
                     41:        enum mdoc_sec     lastnamed;
                     42:        enum mdoc_sec     lastsec;
                     43: };
                     44:
                     45:
                     46: #define        MACRO_PROT_ARGS struct mdoc *mdoc, int tok, int line, \
                     47:                        int ppos, int *pos, char *buf
                     48:
                     49: struct mdoc_macro {
                     50:        int             (*fp)(MACRO_PROT_ARGS);
                     51:        int               flags;
                     52: #define        MDOC_CALLABLE    (1 << 0)
                     53: #define        MDOC_PARSED      (1 << 1)
                     54: #define        MDOC_EXPLICIT    (1 << 2)
                     55: #define        MDOC_PROLOGUE    (1 << 3)
                     56: #define        MDOC_IGNDELIM    (1 << 4)
                     57:        /* Reserved words in arguments treated as text. */
                     58: };
                     59:
                     60: extern const struct mdoc_macro *const mdoc_macros;
                     61:
                     62: __BEGIN_DECLS
                     63:
                     64: int              mdoc_vwarn(struct mdoc *, int, int,
                     65:                        enum mdoc_warn, const char *, ...);
                     66: void             mdoc_vmsg(struct mdoc *, int, int,
                     67:                        const char *, ...);
                     68: int              mdoc_verr(struct mdoc *, int, int,
                     69:                        const char *, ...);
1.2     ! miod       70: int              mdoc_nwarn(struct mdoc *, const struct mdoc_node *,
        !            71:                        enum mdoc_warn, const char *, ...);
        !            72: int              mdoc_nerr(struct mdoc *, const struct mdoc_node *,
        !            73:                        const char *, ...);
        !            74: int              mdoc_warn(struct mdoc *, enum mdoc_warn, const char *, ...);
        !            75: int              mdoc_err(struct mdoc *, const char *, ...);
        !            76: void             mdoc_msg(struct mdoc *, const char *, ...);
        !            77: void             mdoc_pmsg(struct mdoc *, int, int, const char *, ...);
        !            78: int              mdoc_pwarn(struct mdoc *, int, int,
        !            79:                        enum mdoc_warn,const char *, ...);
        !            80: int              mdoc_perr(struct mdoc *, int, int, const char *, ...);
1.1       kristaps   81: int              mdoc_macro(MACRO_PROT_ARGS);
                     82: int              mdoc_word_alloc(struct mdoc *,
                     83:                        int, int, const char *);
                     84: int              mdoc_elem_alloc(struct mdoc *, int, int,
                     85:                        int, struct mdoc_arg *);
                     86: int              mdoc_block_alloc(struct mdoc *, int, int,
                     87:                        int, struct mdoc_arg *);
                     88: int              mdoc_head_alloc(struct mdoc *, int, int, int);
                     89: int              mdoc_tail_alloc(struct mdoc *, int, int, int);
                     90: int              mdoc_body_alloc(struct mdoc *, int, int, int);
                     91: void             mdoc_node_free(struct mdoc_node *);
                     92: void             mdoc_node_freelist(struct mdoc_node *);
                     93: void            *mdoc_hash_alloc(void);
                     94: int              mdoc_hash_find(const void *, const char *);
                     95: void             mdoc_hash_free(void *);
                     96: int              mdoc_iscdelim(char);
                     97: int              mdoc_isdelim(const char *);
                     98: size_t           mdoc_isescape(const char *);
                     99: enum   mdoc_sec  mdoc_atosec(const char *);
                    100: time_t           mdoc_atotime(const char *);
                    101:
                    102: size_t           mdoc_macro2len(int);
                    103: const char      *mdoc_a2arch(const char *);
                    104: const char      *mdoc_a2vol(const char *);
                    105: const char      *mdoc_a2msec(const char *);
                    106: int              mdoc_valid_pre(struct mdoc *,
                    107:                        const struct mdoc_node *);
                    108: int              mdoc_valid_post(struct mdoc *);
                    109: int              mdoc_action_pre(struct mdoc *,
                    110:                        const struct mdoc_node *);
                    111: int              mdoc_action_post(struct mdoc *);
                    112: int              mdoc_argv(struct mdoc *, int, int,
                    113:                        struct mdoc_arg **, int *, char *);
                    114: #define        ARGV_ERROR      (-1)
                    115: #define        ARGV_EOLN       (0)
                    116: #define        ARGV_ARG        (1)
                    117: #define        ARGV_WORD       (2)
                    118: void             mdoc_argv_free(struct mdoc_arg *);
                    119: int              mdoc_args(struct mdoc *, int,
                    120:                        int *, char *, int, char **);
                    121: #define        ARGS_ERROR      (-1)
                    122: #define        ARGS_EOLN       (0)
                    123: #define        ARGS_WORD       (1)
                    124: #define        ARGS_PUNCT      (2)
                    125: #define        ARGS_QWORD      (3)
                    126: #define        ARGS_PHRASE     (4)
                    127:
                    128: /* FIXME: get rid of these. */
                    129: int              xstrlcpys(char *, const struct mdoc_node *, size_t);
                    130: void            *xrealloc(void *, size_t);
                    131: char            *xstrdup(const char *);
                    132: int              mdoc_macroend(struct mdoc *);
                    133:
                    134: __END_DECLS
                    135:
                    136: #endif /*!LIBMDOC_H*/