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