1*95c635efSGarrett D'Amore /* $Id: libman.h,v 1.55 2011/11/07 01:24:40 schwarze Exp $ */ 2*95c635efSGarrett D'Amore /* 3*95c635efSGarrett D'Amore * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 4*95c635efSGarrett D'Amore * 5*95c635efSGarrett D'Amore * Permission to use, copy, modify, and distribute this software for any 6*95c635efSGarrett D'Amore * purpose with or without fee is hereby granted, provided that the above 7*95c635efSGarrett D'Amore * copyright notice and this permission notice appear in all copies. 8*95c635efSGarrett D'Amore * 9*95c635efSGarrett D'Amore * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10*95c635efSGarrett D'Amore * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11*95c635efSGarrett D'Amore * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12*95c635efSGarrett D'Amore * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13*95c635efSGarrett D'Amore * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14*95c635efSGarrett D'Amore * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15*95c635efSGarrett D'Amore * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16*95c635efSGarrett D'Amore */ 17*95c635efSGarrett D'Amore #ifndef LIBMAN_H 18*95c635efSGarrett D'Amore #define LIBMAN_H 19*95c635efSGarrett D'Amore 20*95c635efSGarrett D'Amore enum man_next { 21*95c635efSGarrett D'Amore MAN_NEXT_SIBLING = 0, 22*95c635efSGarrett D'Amore MAN_NEXT_CHILD 23*95c635efSGarrett D'Amore }; 24*95c635efSGarrett D'Amore 25*95c635efSGarrett D'Amore struct man { 26*95c635efSGarrett D'Amore struct mparse *parse; /* parse pointer */ 27*95c635efSGarrett D'Amore int flags; /* parse flags */ 28*95c635efSGarrett D'Amore #define MAN_HALT (1 << 0) /* badness happened: die */ 29*95c635efSGarrett D'Amore #define MAN_ELINE (1 << 1) /* Next-line element scope. */ 30*95c635efSGarrett D'Amore #define MAN_BLINE (1 << 2) /* Next-line block scope. */ 31*95c635efSGarrett D'Amore #define MAN_ILINE (1 << 3) /* Ignored in next-line scope. */ 32*95c635efSGarrett D'Amore #define MAN_LITERAL (1 << 4) /* Literal input. */ 33*95c635efSGarrett D'Amore #define MAN_BPLINE (1 << 5) 34*95c635efSGarrett D'Amore #define MAN_NEWLINE (1 << 6) /* first macro/text in a line */ 35*95c635efSGarrett D'Amore enum man_next next; /* where to put the next node */ 36*95c635efSGarrett D'Amore struct man_node *last; /* the last parsed node */ 37*95c635efSGarrett D'Amore struct man_node *first; /* the first parsed node */ 38*95c635efSGarrett D'Amore struct man_meta meta; /* document meta-data */ 39*95c635efSGarrett D'Amore struct roff *roff; 40*95c635efSGarrett D'Amore }; 41*95c635efSGarrett D'Amore 42*95c635efSGarrett D'Amore #define MACRO_PROT_ARGS struct man *m, \ 43*95c635efSGarrett D'Amore enum mant tok, \ 44*95c635efSGarrett D'Amore int line, \ 45*95c635efSGarrett D'Amore int ppos, \ 46*95c635efSGarrett D'Amore int *pos, \ 47*95c635efSGarrett D'Amore char *buf 48*95c635efSGarrett D'Amore 49*95c635efSGarrett D'Amore struct man_macro { 50*95c635efSGarrett D'Amore int (*fp)(MACRO_PROT_ARGS); 51*95c635efSGarrett D'Amore int flags; 52*95c635efSGarrett D'Amore #define MAN_SCOPED (1 << 0) 53*95c635efSGarrett D'Amore #define MAN_EXPLICIT (1 << 1) /* See blk_imp(). */ 54*95c635efSGarrett D'Amore #define MAN_FSCOPED (1 << 2) /* See blk_imp(). */ 55*95c635efSGarrett D'Amore #define MAN_NSCOPED (1 << 3) /* See in_line_eoln(). */ 56*95c635efSGarrett D'Amore #define MAN_NOCLOSE (1 << 4) /* See blk_exp(). */ 57*95c635efSGarrett D'Amore #define MAN_BSCOPE (1 << 5) /* Break BLINE scope. */ 58*95c635efSGarrett D'Amore }; 59*95c635efSGarrett D'Amore 60*95c635efSGarrett D'Amore extern const struct man_macro *const man_macros; 61*95c635efSGarrett D'Amore 62*95c635efSGarrett D'Amore __BEGIN_DECLS 63*95c635efSGarrett D'Amore 64*95c635efSGarrett D'Amore #define man_pmsg(m, l, p, t) \ 65*95c635efSGarrett D'Amore mandoc_msg((t), (m)->parse, (l), (p), NULL) 66*95c635efSGarrett D'Amore #define man_nmsg(m, n, t) \ 67*95c635efSGarrett D'Amore mandoc_msg((t), (m)->parse, (n)->line, (n)->pos, NULL) 68*95c635efSGarrett D'Amore int man_word_alloc(struct man *, int, int, const char *); 69*95c635efSGarrett D'Amore int man_block_alloc(struct man *, int, int, enum mant); 70*95c635efSGarrett D'Amore int man_head_alloc(struct man *, int, int, enum mant); 71*95c635efSGarrett D'Amore int man_tail_alloc(struct man *, int, int, enum mant); 72*95c635efSGarrett D'Amore int man_body_alloc(struct man *, int, int, enum mant); 73*95c635efSGarrett D'Amore int man_elem_alloc(struct man *, int, int, enum mant); 74*95c635efSGarrett D'Amore void man_node_delete(struct man *, struct man_node *); 75*95c635efSGarrett D'Amore void man_hash_init(void); 76*95c635efSGarrett D'Amore enum mant man_hash_find(const char *); 77*95c635efSGarrett D'Amore int man_macroend(struct man *); 78*95c635efSGarrett D'Amore int man_valid_post(struct man *); 79*95c635efSGarrett D'Amore int man_valid_pre(struct man *, struct man_node *); 80*95c635efSGarrett D'Amore int man_unscope(struct man *, 81*95c635efSGarrett D'Amore const struct man_node *, enum mandocerr); 82*95c635efSGarrett D'Amore 83*95c635efSGarrett D'Amore __END_DECLS 84*95c635efSGarrett D'Amore 85*95c635efSGarrett D'Amore #endif /*!LIBMAN_H*/ 86