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

Annotation of mandoc/private.h, Revision 1.69

1.69    ! kristaps    1: /* $Id: private.h,v 1.68 2009/01/17 20:10:36 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: #ifndef PRIVATE_H
                     20: #define PRIVATE_H
                     21:
1.41      kristaps   22: #include "mdoc.h"
1.27      kristaps   23:
1.52      kristaps   24: enum   mdoc_next {
                     25:        MDOC_NEXT_SIBLING = 0,
                     26:        MDOC_NEXT_CHILD
                     27: };
                     28:
1.41      kristaps   29: struct mdoc {
                     30:        void             *data;
                     31:        struct mdoc_cb    cb;
                     32:        void             *htab;
1.52      kristaps   33:        int               flags;
1.57      kristaps   34: #define        MDOC_HALT        (1 << 0)
1.52      kristaps   35:        enum mdoc_next    next;
1.41      kristaps   36:        struct mdoc_node *last;
                     37:        struct mdoc_node *first;
1.43      kristaps   38:        struct mdoc_meta  meta;
1.42      kristaps   39:        enum mdoc_sec     sec_lastn;
                     40:        enum mdoc_sec     sec_last;
1.36      kristaps   41: };
                     42:
1.58      kristaps   43:
1.65      kristaps   44: /* FIXME: it's 9 (this isn't used properly). */
                     45:
                     46: #define        MDOC_LINEARG_MAX 12
                     47:
1.58      kristaps   48: #define        MACRO_PROT_ARGS struct mdoc *mdoc, int tok, int line, \
                     49:                        int ppos, int *pos, char *buf
                     50:
1.41      kristaps   51: struct mdoc_macro {
1.64      kristaps   52:        int             (*fp)(MACRO_PROT_ARGS);
                     53:        int               flags;
                     54: #define        MDOC_CALLABLE    (1 << 0)
                     55: #define        MDOC_PARSED      (1 << 1)
                     56: #define        MDOC_EXPLICIT    (1 << 2)
                     57: #define        MDOC_QUOTABLE    (1 << 3)
                     58: #define        MDOC_PROLOGUE    (1 << 4)
                     59: #define        MDOC_TABSEP      (1 << 5)
1.69    ! kristaps   60: #define        MDOC_NOKEEP      (1 << 6)
1.8       kristaps   61: };
1.5       kristaps   62:
1.64      kristaps   63: #define        mdoc_nwarn(mdoc, node, type, fmt, ...) \
                     64:                  mdoc_vwarn((mdoc), (node)->line, \
                     65:                  (node)->pos, (type), (fmt), ##__VA_ARGS__)
                     66:
                     67: #define        mdoc_nerr(mdoc, node, fmt, ...) \
                     68:                  mdoc_verr((mdoc), (node)->line, \
                     69:                  (node)->pos, (fmt), ##__VA_ARGS__)
                     70:
                     71: #define        mdoc_warn(mdoc, type, fmt, ...) \
                     72:                  mdoc_vwarn((mdoc), (mdoc)->last->line, \
                     73:                  (mdoc)->last->pos, (type), (fmt), ##__VA_ARGS__)
                     74:
                     75: #define        mdoc_err(mdoc, fmt, ...) \
                     76:                  mdoc_verr((mdoc), (mdoc)->last->line, \
                     77:                  (mdoc)->last->pos, (fmt), ##__VA_ARGS__)
                     78:
                     79: #define        mdoc_msg(mdoc, fmt, ...) \
                     80:                  mdoc_vmsg((mdoc), (mdoc)->last->line, \
                     81:                  (mdoc)->last->pos, (fmt), ##__VA_ARGS__)
                     82:
                     83: #define        mdoc_pmsg(mdoc, line, pos, fmt, ...) \
                     84:                  mdoc_vmsg((mdoc), (line), \
                     85:                  (pos), (fmt), ##__VA_ARGS__)
                     86:
                     87: #define        mdoc_pwarn(mdoc, line, pos, type, fmt, ...) \
                     88:                  mdoc_vwarn((mdoc), (line), \
                     89:                  (pos), (type), (fmt), ##__VA_ARGS__)
                     90:
                     91: #define        mdoc_perr(mdoc, line, pos, fmt, ...) \
                     92:                  mdoc_verr((mdoc), (line), \
                     93:                  (pos), (fmt), ##__VA_ARGS__)
                     94:
1.41      kristaps   95: extern const struct mdoc_macro *const mdoc_macros;
1.24      kristaps   96:
1.1       kristaps   97: __BEGIN_DECLS
                     98:
1.64      kristaps   99: int              mdoc_vwarn(struct mdoc *, int, int,
                    100:                        enum mdoc_warn, const char *, ...);
                    101: void             mdoc_vmsg(struct mdoc *, int, int,
                    102:                        const char *, ...);
                    103: int              mdoc_verr(struct mdoc *, int, int,
                    104:                        const char *, ...);
                    105:
1.58      kristaps  106: int              mdoc_macro(MACRO_PROT_ARGS);
1.41      kristaps  107: int              mdoc_find(const struct mdoc *, const char *);
1.60      kristaps  108: int              mdoc_word_alloc(struct mdoc *,
1.59      kristaps  109:                        int, int, const char *);
1.60      kristaps  110: int              mdoc_elem_alloc(struct mdoc *, int, int,
1.59      kristaps  111:                        int, size_t, const struct mdoc_arg *);
1.60      kristaps  112: int              mdoc_block_alloc(struct mdoc *, int, int,
1.59      kristaps  113:                        int, size_t, const struct mdoc_arg *);
1.61      kristaps  114: int              mdoc_root_alloc(struct mdoc *);
1.60      kristaps  115: int              mdoc_head_alloc(struct mdoc *, int, int, int);
                    116: int              mdoc_tail_alloc(struct mdoc *, int, int, int);
                    117: int              mdoc_body_alloc(struct mdoc *, int, int, int);
1.41      kristaps  118: void             mdoc_node_free(struct mdoc_node *);
1.69    ! kristaps  119: void             mdoc_node_freelist(struct mdoc_node *);
1.41      kristaps  120: void             mdoc_sibling(struct mdoc *, int, struct mdoc_node **,
                    121:                        struct mdoc_node **, struct mdoc_node *);
1.44      kristaps  122: void            *mdoc_tokhash_alloc(void);
                    123: int              mdoc_tokhash_find(const void *, const char *);
                    124: void             mdoc_tokhash_free(void *);
1.42      kristaps  125: int              mdoc_isdelim(const char *);
1.45      kristaps  126: int              mdoc_iscdelim(char);
1.67      kristaps  127: enum   mdoc_sec  mdoc_atosec(const char *);
1.43      kristaps  128: enum   mdoc_msec mdoc_atomsec(const char *);
                    129: enum   mdoc_vol  mdoc_atovol(const char *);
                    130: enum   mdoc_arch mdoc_atoarch(const char *);
1.48      kristaps  131: enum   mdoc_att  mdoc_atoatt(const char *);
1.43      kristaps  132: time_t           mdoc_atotime(const char *);
                    133:
1.66      kristaps  134: char            *mdoc_type2a(enum mdoc_type);
1.68      kristaps  135: char            *mdoc_node2a(struct mdoc_node *);
1.66      kristaps  136:
1.60      kristaps  137: int              mdoc_valid_pre(struct mdoc *, struct mdoc_node *);
                    138: int              mdoc_valid_post(struct mdoc *);
                    139: int              mdoc_action_pre(struct mdoc *, struct mdoc_node *);
                    140: int              mdoc_action_post(struct mdoc *);
1.50      kristaps  141:
1.60      kristaps  142: int              mdoc_argv(struct mdoc *, int, int,
1.45      kristaps  143:                        struct mdoc_arg *, int *, char *);
1.52      kristaps  144: #define        ARGV_ERROR      (-1)
                    145: #define        ARGV_EOLN       (0)
                    146: #define        ARGV_ARG        (1)
                    147: #define        ARGV_WORD       (2)
1.44      kristaps  148: void             mdoc_argv_free(int, struct mdoc_arg *);
1.45      kristaps  149: int              mdoc_args(struct mdoc *, int,
                    150:                        int *, char *, int, char **);
                    151: #define        ARGS_ERROR      (-1)
                    152: #define        ARGS_EOLN       (0)
                    153: #define        ARGS_WORD       (1)
                    154: #define        ARGS_PUNCT      (2)
                    155:
                    156: #define        ARGS_QUOTED     (1 << 0)
                    157: #define        ARGS_DELIM      (1 << 1)
1.62      kristaps  158: #define        ARGS_TABSEP     (1 << 2)
1.44      kristaps  159:
1.67      kristaps  160: int              xstrlcats(char *, const struct mdoc_node *, size_t);
1.44      kristaps  161: int              xstrlcat(char *, const char *, size_t);
                    162: int              xstrlcpy(char *, const char *, size_t);
                    163: int              xstrcmp(const char *, const char *);
                    164: void            *xcalloc(size_t, size_t);
                    165: char            *xstrdup(const char *);
                    166:
1.51      kristaps  167: int              macro_obsolete(MACRO_PROT_ARGS);
1.48      kristaps  168: int              macro_constant(MACRO_PROT_ARGS);
1.55      kristaps  169: int              macro_constant_scoped(MACRO_PROT_ARGS);
1.47      kristaps  170: int              macro_constant_delimited(MACRO_PROT_ARGS);
1.43      kristaps  171: int              macro_text(MACRO_PROT_ARGS);
1.52      kristaps  172: int              macro_scoped(MACRO_PROT_ARGS);
1.63      kristaps  173: int              macro_scoped_close(MACRO_PROT_ARGS);
1.46      kristaps  174: int              macro_scoped_line(MACRO_PROT_ARGS);
1.52      kristaps  175: int              macro_prologue(MACRO_PROT_ARGS);
1.57      kristaps  176: int              macro_end(struct mdoc *);
1.35      kristaps  177:
1.1       kristaps  178: __END_DECLS
                    179:
                    180: #endif /*!PRIVATE_H*/

CVSweb