1*698f87a4SGarrett D'Amore /* $Id: libman.h,v 1.56 2012/11/17 00:26:33 schwarze Exp $ */ 295c635efSGarrett D'Amore /* 395c635efSGarrett D'Amore * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 495c635efSGarrett D'Amore * 595c635efSGarrett D'Amore * Permission to use, copy, modify, and distribute this software for any 695c635efSGarrett D'Amore * purpose with or without fee is hereby granted, provided that the above 795c635efSGarrett D'Amore * copyright notice and this permission notice appear in all copies. 895c635efSGarrett D'Amore * 995c635efSGarrett D'Amore * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1095c635efSGarrett D'Amore * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1195c635efSGarrett D'Amore * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1295c635efSGarrett D'Amore * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1395c635efSGarrett D'Amore * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1495c635efSGarrett D'Amore * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1595c635efSGarrett D'Amore * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1695c635efSGarrett D'Amore */ 1795c635efSGarrett D'Amore #ifndef LIBMAN_H 1895c635efSGarrett D'Amore #define LIBMAN_H 1995c635efSGarrett D'Amore 2095c635efSGarrett D'Amore enum man_next { 2195c635efSGarrett D'Amore MAN_NEXT_SIBLING = 0, 2295c635efSGarrett D'Amore MAN_NEXT_CHILD 2395c635efSGarrett D'Amore }; 2495c635efSGarrett D'Amore 2595c635efSGarrett D'Amore struct man { 2695c635efSGarrett D'Amore struct mparse *parse; /* parse pointer */ 2795c635efSGarrett D'Amore int flags; /* parse flags */ 2895c635efSGarrett D'Amore #define MAN_HALT (1 << 0) /* badness happened: die */ 2995c635efSGarrett D'Amore #define MAN_ELINE (1 << 1) /* Next-line element scope. */ 3095c635efSGarrett D'Amore #define MAN_BLINE (1 << 2) /* Next-line block scope. */ 3195c635efSGarrett D'Amore #define MAN_ILINE (1 << 3) /* Ignored in next-line scope. */ 3295c635efSGarrett D'Amore #define MAN_LITERAL (1 << 4) /* Literal input. */ 3395c635efSGarrett D'Amore #define MAN_BPLINE (1 << 5) 3495c635efSGarrett D'Amore #define MAN_NEWLINE (1 << 6) /* first macro/text in a line */ 3595c635efSGarrett D'Amore enum man_next next; /* where to put the next node */ 3695c635efSGarrett D'Amore struct man_node *last; /* the last parsed node */ 3795c635efSGarrett D'Amore struct man_node *first; /* the first parsed node */ 3895c635efSGarrett D'Amore struct man_meta meta; /* document meta-data */ 3995c635efSGarrett D'Amore struct roff *roff; 4095c635efSGarrett D'Amore }; 4195c635efSGarrett D'Amore 42*698f87a4SGarrett D'Amore #define MACRO_PROT_ARGS struct man *man, \ 4395c635efSGarrett D'Amore enum mant tok, \ 4495c635efSGarrett D'Amore int line, \ 4595c635efSGarrett D'Amore int ppos, \ 4695c635efSGarrett D'Amore int *pos, \ 4795c635efSGarrett D'Amore char *buf 4895c635efSGarrett D'Amore 4995c635efSGarrett D'Amore struct man_macro { 5095c635efSGarrett D'Amore int (*fp)(MACRO_PROT_ARGS); 5195c635efSGarrett D'Amore int flags; 5295c635efSGarrett D'Amore #define MAN_SCOPED (1 << 0) 5395c635efSGarrett D'Amore #define MAN_EXPLICIT (1 << 1) /* See blk_imp(). */ 5495c635efSGarrett D'Amore #define MAN_FSCOPED (1 << 2) /* See blk_imp(). */ 5595c635efSGarrett D'Amore #define MAN_NSCOPED (1 << 3) /* See in_line_eoln(). */ 5695c635efSGarrett D'Amore #define MAN_NOCLOSE (1 << 4) /* See blk_exp(). */ 5795c635efSGarrett D'Amore #define MAN_BSCOPE (1 << 5) /* Break BLINE scope. */ 5895c635efSGarrett D'Amore }; 5995c635efSGarrett D'Amore 6095c635efSGarrett D'Amore extern const struct man_macro *const man_macros; 6195c635efSGarrett D'Amore 6295c635efSGarrett D'Amore __BEGIN_DECLS 6395c635efSGarrett D'Amore 64*698f87a4SGarrett D'Amore #define man_pmsg(man, l, p, t) \ 65*698f87a4SGarrett D'Amore mandoc_msg((t), (man)->parse, (l), (p), NULL) 66*698f87a4SGarrett D'Amore #define man_nmsg(man, n, t) \ 67*698f87a4SGarrett D'Amore mandoc_msg((t), (man)->parse, (n)->line, (n)->pos, NULL) 6895c635efSGarrett D'Amore int man_word_alloc(struct man *, int, int, const char *); 6995c635efSGarrett D'Amore int man_block_alloc(struct man *, int, int, enum mant); 7095c635efSGarrett D'Amore int man_head_alloc(struct man *, int, int, enum mant); 7195c635efSGarrett D'Amore int man_tail_alloc(struct man *, int, int, enum mant); 7295c635efSGarrett D'Amore int man_body_alloc(struct man *, int, int, enum mant); 7395c635efSGarrett D'Amore int man_elem_alloc(struct man *, int, int, enum mant); 7495c635efSGarrett D'Amore void man_node_delete(struct man *, struct man_node *); 7595c635efSGarrett D'Amore void man_hash_init(void); 7695c635efSGarrett D'Amore enum mant man_hash_find(const char *); 7795c635efSGarrett D'Amore int man_macroend(struct man *); 7895c635efSGarrett D'Amore int man_valid_post(struct man *); 7995c635efSGarrett D'Amore int man_valid_pre(struct man *, struct man_node *); 8095c635efSGarrett D'Amore int man_unscope(struct man *, 8195c635efSGarrett D'Amore const struct man_node *, enum mandocerr); 8295c635efSGarrett D'Amore 8395c635efSGarrett D'Amore __END_DECLS 8495c635efSGarrett D'Amore 8595c635efSGarrett D'Amore #endif /*!LIBMAN_H*/ 86