1*260e9a87SYuri Pankov /* $Id: libman.h,v 1.67 2014/12/28 14:42:27 schwarze Exp $ */ 295c635efSGarrett D'Amore /* 395c635efSGarrett D'Amore * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 4*260e9a87SYuri Pankov * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> 595c635efSGarrett D'Amore * 695c635efSGarrett D'Amore * Permission to use, copy, modify, and distribute this software for any 795c635efSGarrett D'Amore * purpose with or without fee is hereby granted, provided that the above 895c635efSGarrett D'Amore * copyright notice and this permission notice appear in all copies. 995c635efSGarrett D'Amore * 1095c635efSGarrett D'Amore * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1195c635efSGarrett D'Amore * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1295c635efSGarrett D'Amore * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1395c635efSGarrett D'Amore * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1495c635efSGarrett D'Amore * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1595c635efSGarrett D'Amore * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1695c635efSGarrett D'Amore * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1795c635efSGarrett D'Amore */ 1895c635efSGarrett D'Amore 1995c635efSGarrett D'Amore enum man_next { 2095c635efSGarrett D'Amore MAN_NEXT_SIBLING = 0, 2195c635efSGarrett D'Amore MAN_NEXT_CHILD 2295c635efSGarrett D'Amore }; 2395c635efSGarrett D'Amore 2495c635efSGarrett D'Amore struct man { 2595c635efSGarrett D'Amore struct mparse *parse; /* parse pointer */ 26*260e9a87SYuri Pankov const char *defos; /* default OS argument for .TH */ 27*260e9a87SYuri Pankov int quick; /* abort parse early */ 2895c635efSGarrett D'Amore int flags; /* parse flags */ 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_LITERAL (1 << 4) /* Literal input. */ 3295c635efSGarrett D'Amore #define MAN_NEWLINE (1 << 6) /* first macro/text in a line */ 3395c635efSGarrett D'Amore enum man_next next; /* where to put the next node */ 3495c635efSGarrett D'Amore struct man_node *last; /* the last parsed node */ 3595c635efSGarrett D'Amore struct man_node *first; /* the first parsed node */ 3695c635efSGarrett D'Amore struct man_meta meta; /* document meta-data */ 3795c635efSGarrett D'Amore struct roff *roff; 3895c635efSGarrett D'Amore }; 3995c635efSGarrett D'Amore 40698f87a4SGarrett D'Amore #define MACRO_PROT_ARGS struct man *man, \ 4195c635efSGarrett D'Amore enum mant tok, \ 4295c635efSGarrett D'Amore int line, \ 4395c635efSGarrett D'Amore int ppos, \ 4495c635efSGarrett D'Amore int *pos, \ 4595c635efSGarrett D'Amore char *buf 4695c635efSGarrett D'Amore 4795c635efSGarrett D'Amore struct man_macro { 48*260e9a87SYuri Pankov void (*fp)(MACRO_PROT_ARGS); 4995c635efSGarrett D'Amore int flags; 5095c635efSGarrett D'Amore #define MAN_SCOPED (1 << 0) 5195c635efSGarrett D'Amore #define MAN_EXPLICIT (1 << 1) /* See blk_imp(). */ 5295c635efSGarrett D'Amore #define MAN_FSCOPED (1 << 2) /* See blk_imp(). */ 5395c635efSGarrett D'Amore #define MAN_NSCOPED (1 << 3) /* See in_line_eoln(). */ 5495c635efSGarrett D'Amore #define MAN_NOCLOSE (1 << 4) /* See blk_exp(). */ 5595c635efSGarrett D'Amore #define MAN_BSCOPE (1 << 5) /* Break BLINE scope. */ 56*260e9a87SYuri Pankov #define MAN_JOIN (1 << 6) /* Join arguments together. */ 5795c635efSGarrett D'Amore }; 5895c635efSGarrett D'Amore 5995c635efSGarrett D'Amore extern const struct man_macro *const man_macros; 6095c635efSGarrett D'Amore 6195c635efSGarrett D'Amore __BEGIN_DECLS 6295c635efSGarrett D'Amore 63*260e9a87SYuri Pankov void man_word_alloc(struct man *, int, int, const char *); 64*260e9a87SYuri Pankov void man_word_append(struct man *, const char *); 65*260e9a87SYuri Pankov void man_block_alloc(struct man *, int, int, enum mant); 66*260e9a87SYuri Pankov void man_head_alloc(struct man *, int, int, enum mant); 67*260e9a87SYuri Pankov void man_body_alloc(struct man *, int, int, enum mant); 68*260e9a87SYuri Pankov void man_elem_alloc(struct man *, int, int, enum mant); 6995c635efSGarrett D'Amore void man_node_delete(struct man *, struct man_node *); 7095c635efSGarrett D'Amore void man_hash_init(void); 7195c635efSGarrett D'Amore enum mant man_hash_find(const char *); 72*260e9a87SYuri Pankov void man_macroend(struct man *); 73*260e9a87SYuri Pankov void man_valid_post(struct man *); 74*260e9a87SYuri Pankov void man_unscope(struct man *, const struct man_node *); 7595c635efSGarrett D'Amore 7695c635efSGarrett D'Amore __END_DECLS 77