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

Annotation of mandoc/libmdoc.h, Revision 1.12

1.12    ! kristaps    1: /*     $Id: libmdoc.h,v 1.11 2009/06/17 10:53:32 kristaps Exp $ */
1.1       kristaps    2: /*
1.7       kristaps    3:  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
1.1       kristaps    4:  *
                      5:  * Permission to use, copy, modify, and distribute this software for any
1.6       kristaps    6:  * purpose with or without fee is hereby granted, provided that the above
                      7:  * copyright notice and this permission notice appear in all copies.
1.1       kristaps    8:  *
1.6       kristaps    9:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     10:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     11:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     12:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     13:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     14:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     15:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1       kristaps   16:  */
                     17: #ifndef LIBMDOC_H
                     18: #define LIBMDOC_H
                     19:
                     20: #include "mdoc.h"
                     21:
                     22: enum   mdoc_next {
                     23:        MDOC_NEXT_SIBLING = 0,
                     24:        MDOC_NEXT_CHILD
                     25: };
                     26:
                     27: struct mdoc {
                     28:        void             *data;
                     29:        struct mdoc_cb    cb;
                     30:        void             *htab;
                     31:        int               flags;
1.11      kristaps   32: #define        MDOC_HALT        (1 << 0)       /* Error in parse. Halt. */
                     33: #define        MDOC_LITERAL     (1 << 1)       /* In a literal scope. */
                     34: #define        MDOC_PBODY       (1 << 2)       /* In the document body. */
1.1       kristaps   35:        int               pflags;
                     36:        enum mdoc_next    next;
                     37:        struct mdoc_node *last;
                     38:        struct mdoc_node *first;
                     39:        struct mdoc_meta  meta;
                     40:        enum mdoc_sec     lastnamed;
                     41:        enum mdoc_sec     lastsec;
                     42: };
                     43:
                     44:
                     45: #define        MACRO_PROT_ARGS struct mdoc *mdoc, int tok, int line, \
                     46:                        int ppos, int *pos, char *buf
                     47:
                     48: struct mdoc_macro {
                     49:        int             (*fp)(MACRO_PROT_ARGS);
                     50:        int               flags;
                     51: #define        MDOC_CALLABLE    (1 << 0)
                     52: #define        MDOC_PARSED      (1 << 1)
                     53: #define        MDOC_EXPLICIT    (1 << 2)
                     54: #define        MDOC_PROLOGUE    (1 << 3)
                     55: #define        MDOC_IGNDELIM    (1 << 4)
                     56:        /* Reserved words in arguments treated as text. */
                     57: };
                     58:
                     59: extern const struct mdoc_macro *const mdoc_macros;
                     60:
                     61: __BEGIN_DECLS
                     62:
1.8       kristaps   63: /*
                     64:  * When GCC2 is deprecated, most of these can be reverted to #define
1.10      kristaps   65:  * as mdoc_vXXX using __VA_ARGS__.  Until then, use real functions.
1.8       kristaps   66:  */
1.12    ! kristaps   67: int              mdoc_vwarn(struct mdoc *, int, int, const char *, ...);
        !            68: int              mdoc_verr(struct mdoc *, int, int, const char *, ...);
1.8       kristaps   69: int              mdoc_nerr(struct mdoc *, const struct mdoc_node *,
                     70:                        const char *, ...);
1.12    ! kristaps   71: int              mdoc_warn(struct mdoc *, const char *, ...);
1.8       kristaps   72: int              mdoc_err(struct mdoc *, const char *, ...);
1.12    ! kristaps   73: int              mdoc_pwarn(struct mdoc *, int, int, const char *, ...);
1.8       kristaps   74: int              mdoc_perr(struct mdoc *, int, int, const char *, ...);
1.1       kristaps   75: int              mdoc_macro(MACRO_PROT_ARGS);
                     76: int              mdoc_word_alloc(struct mdoc *,
                     77:                        int, int, const char *);
                     78: int              mdoc_elem_alloc(struct mdoc *, int, int,
                     79:                        int, struct mdoc_arg *);
                     80: int              mdoc_block_alloc(struct mdoc *, int, int,
                     81:                        int, struct mdoc_arg *);
                     82: int              mdoc_head_alloc(struct mdoc *, int, int, int);
                     83: int              mdoc_tail_alloc(struct mdoc *, int, int, int);
                     84: int              mdoc_body_alloc(struct mdoc *, int, int, int);
                     85: void             mdoc_node_free(struct mdoc_node *);
                     86: void             mdoc_node_freelist(struct mdoc_node *);
1.4       kristaps   87: void            *mdoc_hash_alloc(void);
                     88: int              mdoc_hash_find(const void *, const char *);
                     89: void             mdoc_hash_free(void *);
1.1       kristaps   90: int              mdoc_iscdelim(char);
                     91: int              mdoc_isdelim(const char *);
                     92: size_t           mdoc_isescape(const char *);
                     93: enum   mdoc_sec  mdoc_atosec(const char *);
                     94: time_t           mdoc_atotime(const char *);
                     95:
                     96: size_t           mdoc_macro2len(int);
                     97: const char      *mdoc_a2arch(const char *);
                     98: const char      *mdoc_a2vol(const char *);
                     99: const char      *mdoc_a2msec(const char *);
                    100: int              mdoc_valid_pre(struct mdoc *,
                    101:                        const struct mdoc_node *);
                    102: int              mdoc_valid_post(struct mdoc *);
                    103: int              mdoc_action_pre(struct mdoc *,
                    104:                        const struct mdoc_node *);
                    105: int              mdoc_action_post(struct mdoc *);
                    106: int              mdoc_argv(struct mdoc *, int, int,
                    107:                        struct mdoc_arg **, int *, char *);
                    108: #define        ARGV_ERROR      (-1)
                    109: #define        ARGV_EOLN       (0)
                    110: #define        ARGV_ARG        (1)
                    111: #define        ARGV_WORD       (2)
                    112: void             mdoc_argv_free(struct mdoc_arg *);
                    113: int              mdoc_args(struct mdoc *, int,
                    114:                        int *, char *, int, char **);
                    115: #define        ARGS_ERROR      (-1)
                    116: #define        ARGS_EOLN       (0)
                    117: #define        ARGS_WORD       (1)
                    118: #define        ARGS_PUNCT      (2)
                    119: #define        ARGS_QWORD      (3)
                    120: #define        ARGS_PHRASE     (4)
                    121:
1.2       kristaps  122: int              mdoc_macroend(struct mdoc *);
1.1       kristaps  123:
                    124: __END_DECLS
                    125:
                    126: #endif /*!LIBMDOC_H*/

CVSweb