1/* $Id: libmdoc.h,v 1.108 2015/11/07 14:01:16 schwarze Exp $ */ 2/* 3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 4 * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19#define MACRO_PROT_ARGS struct roff_man *mdoc, \ 20 int tok, \ 21 int line, \ 22 int ppos, \ 23 int *pos, \ 24 char *buf 25 26struct mdoc_macro { 27 void (*fp)(MACRO_PROT_ARGS); 28 int flags; 29#define MDOC_CALLABLE (1 << 0) 30#define MDOC_PARSED (1 << 1) 31#define MDOC_EXPLICIT (1 << 2) 32#define MDOC_PROLOGUE (1 << 3) 33#define MDOC_IGNDELIM (1 << 4) 34#define MDOC_JOIN (1 << 5) 35}; 36 37enum margserr { 38 ARGS_ERROR, 39 ARGS_EOLN, /* end-of-line */ 40 ARGS_WORD, /* normal word */ 41 ARGS_PUNCT, /* series of punctuation */ 42 ARGS_QWORD, /* quoted word */ 43 ARGS_PHRASE /* Bl -column phrase */ 44}; 45 46/* 47 * A punctuation delimiter is opening, closing, or "middle mark" 48 * punctuation. These govern spacing. 49 * Opening punctuation (e.g., the opening parenthesis) suppresses the 50 * following space; closing punctuation (e.g., the closing parenthesis) 51 * suppresses the leading space; middle punctuation (e.g., the vertical 52 * bar) can do either. The middle punctuation delimiter bends the rules 53 * depending on usage. 54 */ 55enum mdelim { 56 DELIM_NONE = 0, 57 DELIM_OPEN, 58 DELIM_MIDDLE, 59 DELIM_CLOSE, 60 DELIM_MAX 61}; 62 63extern const struct mdoc_macro *const mdoc_macros; 64 65 66void mdoc_macro(MACRO_PROT_ARGS); 67void mdoc_elem_alloc(struct roff_man *, int, int, 68 int, struct mdoc_arg *); 69struct roff_node *mdoc_block_alloc(struct roff_man *, int, int, 70 int, struct mdoc_arg *); 71void mdoc_tail_alloc(struct roff_man *, int, int, int); 72struct roff_node *mdoc_endbody_alloc(struct roff_man *, int, int, int, 73 struct roff_node *, enum mdoc_endbody); 74void mdoc_node_relink(struct roff_man *, struct roff_node *); 75void mdoc_node_validate(struct roff_man *); 76void mdoc_state(struct roff_man *, struct roff_node *); 77void mdoc_state_reset(struct roff_man *); 78int mdoc_hash_find(const char *); 79const char *mdoc_a2arch(const char *); 80const char *mdoc_a2att(const char *); 81const char *mdoc_a2lib(const char *); 82enum roff_sec mdoc_a2sec(const char *); 83const char *mdoc_a2st(const char *); 84void mdoc_argv(struct roff_man *, int, int, 85 struct mdoc_arg **, int *, char *); 86enum margserr mdoc_args(struct roff_man *, int, 87 int *, char *, int, char **); 88enum mdelim mdoc_isdelim(const char *); 89