Home | History | Annotate | Line # | Download | only in dist
libmdoc.h revision 1.1.1.10
      1  1.1.1.10  joerg /*	$Vendor-Id: libmdoc.h,v 1.63 2010/11/30 13:04:14 kristaps Exp $ */
      2       1.1  joerg /*
      3   1.1.1.9  joerg  * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps (at) bsd.lv>
      4       1.1  joerg  *
      5       1.1  joerg  * Permission to use, copy, modify, and distribute this software for any
      6       1.1  joerg  * purpose with or without fee is hereby granted, provided that the above
      7       1.1  joerg  * copyright notice and this permission notice appear in all copies.
      8       1.1  joerg  *
      9       1.1  joerg  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
     10       1.1  joerg  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     11       1.1  joerg  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
     12       1.1  joerg  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     13       1.1  joerg  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     14       1.1  joerg  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
     15       1.1  joerg  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     16       1.1  joerg  */
     17       1.1  joerg #ifndef LIBMDOC_H
     18       1.1  joerg #define LIBMDOC_H
     19       1.1  joerg 
     20       1.1  joerg #include "mdoc.h"
     21       1.1  joerg 
     22       1.1  joerg enum	mdoc_next {
     23       1.1  joerg 	MDOC_NEXT_SIBLING = 0,
     24       1.1  joerg 	MDOC_NEXT_CHILD
     25       1.1  joerg };
     26       1.1  joerg 
     27       1.1  joerg struct	mdoc {
     28   1.1.1.8  joerg 	void		 *data; /* private application data */
     29   1.1.1.8  joerg 	mandocmsg	  msg; /* message callback */
     30       1.1  joerg 	int		  flags;
     31   1.1.1.5  joerg #define	MDOC_HALT	 (1 << 0) /* error in parse: halt */
     32   1.1.1.5  joerg #define	MDOC_LITERAL	 (1 << 1) /* in a literal scope */
     33   1.1.1.5  joerg #define	MDOC_PBODY	 (1 << 2) /* in the document body */
     34   1.1.1.5  joerg #define	MDOC_NEWLINE	 (1 << 3) /* first macro/text in a line */
     35   1.1.1.5  joerg #define	MDOC_PHRASELIT	 (1 << 4) /* literal within a partila phrase */
     36   1.1.1.5  joerg #define	MDOC_PPHRASE	 (1 << 5) /* within a partial phrase */
     37   1.1.1.6  joerg #define	MDOC_FREECOL	 (1 << 6) /* `It' invocation should close */
     38   1.1.1.8  joerg #define	MDOC_SYNOPSIS	 (1 << 7) /* SYNOPSIS-style formatting */
     39   1.1.1.8  joerg 	enum mdoc_next	  next; /* where to put the next node */
     40   1.1.1.8  joerg 	struct mdoc_node *last; /* the last node parsed */
     41   1.1.1.8  joerg 	struct mdoc_node *first; /* the first node parsed */
     42   1.1.1.8  joerg 	struct mdoc_meta  meta; /* document meta-data */
     43       1.1  joerg 	enum mdoc_sec	  lastnamed;
     44       1.1  joerg 	enum mdoc_sec	  lastsec;
     45   1.1.1.8  joerg 	struct regset	 *regs; /* registers */
     46       1.1  joerg };
     47       1.1  joerg 
     48   1.1.1.8  joerg #define	MACRO_PROT_ARGS	struct mdoc *m, \
     49   1.1.1.8  joerg 			enum mdoct tok, \
     50   1.1.1.8  joerg 			int line, \
     51   1.1.1.8  joerg 			int ppos, \
     52   1.1.1.8  joerg 			int *pos, \
     53   1.1.1.8  joerg 			char *buf
     54       1.1  joerg 
     55       1.1  joerg struct	mdoc_macro {
     56       1.1  joerg 	int		(*fp)(MACRO_PROT_ARGS);
     57       1.1  joerg 	int		  flags;
     58       1.1  joerg #define	MDOC_CALLABLE	 (1 << 0)
     59       1.1  joerg #define	MDOC_PARSED	 (1 << 1)
     60       1.1  joerg #define	MDOC_EXPLICIT	 (1 << 2)
     61       1.1  joerg #define	MDOC_PROLOGUE	 (1 << 3)
     62       1.1  joerg #define	MDOC_IGNDELIM	 (1 << 4)
     63       1.1  joerg 	/* Reserved words in arguments treated as text. */
     64       1.1  joerg };
     65       1.1  joerg 
     66   1.1.1.5  joerg enum	margserr {
     67   1.1.1.5  joerg 	ARGS_ERROR,
     68   1.1.1.5  joerg 	ARGS_EOLN,
     69   1.1.1.5  joerg 	ARGS_WORD,
     70   1.1.1.5  joerg 	ARGS_PUNCT,
     71   1.1.1.5  joerg 	ARGS_QWORD,
     72   1.1.1.5  joerg 	ARGS_PHRASE,
     73   1.1.1.5  joerg 	ARGS_PPHRASE,
     74   1.1.1.5  joerg 	ARGS_PEND
     75   1.1.1.5  joerg };
     76   1.1.1.5  joerg 
     77   1.1.1.5  joerg enum	margverr {
     78   1.1.1.5  joerg 	ARGV_ERROR,
     79   1.1.1.5  joerg 	ARGV_EOLN,
     80   1.1.1.5  joerg 	ARGV_ARG,
     81   1.1.1.5  joerg 	ARGV_WORD
     82   1.1.1.5  joerg };
     83   1.1.1.5  joerg 
     84   1.1.1.5  joerg enum	mdelim {
     85   1.1.1.5  joerg 	DELIM_NONE = 0,
     86   1.1.1.5  joerg 	DELIM_OPEN,
     87   1.1.1.5  joerg 	DELIM_MIDDLE,
     88   1.1.1.5  joerg 	DELIM_CLOSE
     89   1.1.1.5  joerg };
     90   1.1.1.5  joerg 
     91       1.1  joerg extern	const struct mdoc_macro *const mdoc_macros;
     92       1.1  joerg 
     93       1.1  joerg __BEGIN_DECLS
     94       1.1  joerg 
     95   1.1.1.5  joerg #define		  mdoc_pmsg(m, l, p, t) \
     96   1.1.1.5  joerg 		  (*(m)->msg)((t), (m)->data, (l), (p), NULL)
     97   1.1.1.5  joerg #define		  mdoc_nmsg(m, n, t) \
     98   1.1.1.5  joerg 		  (*(m)->msg)((t), (m)->data, (n)->line, (n)->pos, NULL)
     99   1.1.1.5  joerg int		  mdoc_vmsg(struct mdoc *, enum mandocerr,
    100   1.1.1.5  joerg 			int, int, const char *, ...);
    101       1.1  joerg int		  mdoc_macro(MACRO_PROT_ARGS);
    102       1.1  joerg int		  mdoc_word_alloc(struct mdoc *,
    103       1.1  joerg 			int, int, const char *);
    104       1.1  joerg int		  mdoc_elem_alloc(struct mdoc *, int, int,
    105   1.1.1.3  joerg 			enum mdoct, struct mdoc_arg *);
    106       1.1  joerg int		  mdoc_block_alloc(struct mdoc *, int, int,
    107   1.1.1.3  joerg 			enum mdoct, struct mdoc_arg *);
    108   1.1.1.3  joerg int		  mdoc_head_alloc(struct mdoc *, int, int, enum mdoct);
    109   1.1.1.3  joerg int		  mdoc_tail_alloc(struct mdoc *, int, int, enum mdoct);
    110   1.1.1.3  joerg int		  mdoc_body_alloc(struct mdoc *, int, int, enum mdoct);
    111   1.1.1.8  joerg int		  mdoc_endbody_alloc(struct mdoc *m, int line, int pos,
    112   1.1.1.8  joerg 			enum mdoct tok, struct mdoc_node *body,
    113   1.1.1.8  joerg 			enum mdoc_endbody end);
    114   1.1.1.4  joerg void		  mdoc_node_delete(struct mdoc *, struct mdoc_node *);
    115       1.1  joerg void		  mdoc_hash_init(void);
    116   1.1.1.3  joerg enum mdoct	  mdoc_hash_find(const char *);
    117   1.1.1.5  joerg enum mdelim	  mdoc_iscdelim(char);
    118   1.1.1.5  joerg enum mdelim	  mdoc_isdelim(const char *);
    119       1.1  joerg size_t		  mdoc_isescape(const char *);
    120   1.1.1.5  joerg enum	mdoc_sec  mdoc_str2sec(const char *);
    121       1.1  joerg time_t		  mdoc_atotime(const char *);
    122   1.1.1.5  joerg size_t		  mdoc_macro2len(enum mdoct);
    123       1.1  joerg const char	 *mdoc_a2att(const char *);
    124       1.1  joerg const char	 *mdoc_a2lib(const char *);
    125       1.1  joerg const char	 *mdoc_a2st(const char *);
    126       1.1  joerg const char	 *mdoc_a2arch(const char *);
    127       1.1  joerg const char	 *mdoc_a2vol(const char *);
    128       1.1  joerg const char	 *mdoc_a2msec(const char *);
    129   1.1.1.6  joerg int		  mdoc_valid_pre(struct mdoc *, struct mdoc_node *);
    130       1.1  joerg int		  mdoc_valid_post(struct mdoc *);
    131   1.1.1.5  joerg enum margverr	  mdoc_argv(struct mdoc *, int, enum mdoct,
    132       1.1  joerg 			struct mdoc_arg **, int *, char *);
    133       1.1  joerg void		  mdoc_argv_free(struct mdoc_arg *);
    134   1.1.1.4  joerg void		  mdoc_argn_free(struct mdoc_arg *, int);
    135   1.1.1.5  joerg enum margserr	  mdoc_args(struct mdoc *, int,
    136   1.1.1.3  joerg 			int *, char *, enum mdoct, char **);
    137   1.1.1.5  joerg enum margserr	  mdoc_zargs(struct mdoc *, int,
    138       1.1  joerg 			int *, char *, int, char **);
    139   1.1.1.5  joerg #define	ARGS_DELIM	(1 << 1)
    140   1.1.1.5  joerg #define	ARGS_TABSEP	(1 << 2)
    141   1.1.1.5  joerg #define	ARGS_NOWARN	(1 << 3)
    142   1.1.1.5  joerg 
    143       1.1  joerg int		  mdoc_macroend(struct mdoc *);
    144       1.1  joerg 
    145       1.1  joerg __END_DECLS
    146       1.1  joerg 
    147       1.1  joerg #endif /*!LIBMDOC_H*/
    148