xref: /titanic_41/usr/src/cmd/mandoc/libmandoc.h (revision ffb8ebfab4941f959e7caea93ecfb348cfa3515e)
1*ffb8ebfaSGarrett D'Amore /*	$Id: libmandoc.h,v 1.35 2013/12/15 21:23:52 schwarze Exp $ */
232a712daSGarrett D'Amore /*
3*ffb8ebfaSGarrett D'Amore  * Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4*ffb8ebfaSGarrett D'Amore  * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
532a712daSGarrett D'Amore  *
632a712daSGarrett D'Amore  * Permission to use, copy, modify, and distribute this software for any
732a712daSGarrett D'Amore  * purpose with or without fee is hereby granted, provided that the above
832a712daSGarrett D'Amore  * copyright notice and this permission notice appear in all copies.
932a712daSGarrett D'Amore  *
1032a712daSGarrett D'Amore  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1132a712daSGarrett D'Amore  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1232a712daSGarrett D'Amore  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1332a712daSGarrett D'Amore  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1432a712daSGarrett D'Amore  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1532a712daSGarrett D'Amore  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1632a712daSGarrett D'Amore  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1732a712daSGarrett D'Amore  */
1832a712daSGarrett D'Amore #ifndef LIBMANDOC_H
1932a712daSGarrett D'Amore #define LIBMANDOC_H
2032a712daSGarrett D'Amore 
2132a712daSGarrett D'Amore enum	rofferr {
2232a712daSGarrett D'Amore 	ROFF_CONT, /* continue processing line */
2332a712daSGarrett D'Amore 	ROFF_RERUN, /* re-run roff interpreter with offset */
2432a712daSGarrett D'Amore 	ROFF_APPEND, /* re-run main parser, appending next line */
2532a712daSGarrett D'Amore 	ROFF_REPARSE, /* re-run main parser on the result */
2632a712daSGarrett D'Amore 	ROFF_SO, /* include another file */
2732a712daSGarrett D'Amore 	ROFF_IGN, /* ignore current line */
2832a712daSGarrett D'Amore 	ROFF_TBL, /* a table row was successfully parsed */
2932a712daSGarrett D'Amore 	ROFF_EQN, /* an equation was successfully parsed */
3032a712daSGarrett D'Amore 	ROFF_ERR /* badness: puke and stop */
3132a712daSGarrett D'Amore };
3232a712daSGarrett D'Amore 
3332a712daSGarrett D'Amore __BEGIN_DECLS
3432a712daSGarrett D'Amore 
3532a712daSGarrett D'Amore struct	roff;
3632a712daSGarrett D'Amore struct	mdoc;
3732a712daSGarrett D'Amore struct	man;
3832a712daSGarrett D'Amore 
3932a712daSGarrett D'Amore void		 mandoc_msg(enum mandocerr, struct mparse *,
4032a712daSGarrett D'Amore 			int, int, const char *);
4132a712daSGarrett D'Amore void		 mandoc_vmsg(enum mandocerr, struct mparse *,
4232a712daSGarrett D'Amore 			int, int, const char *, ...);
4332a712daSGarrett D'Amore char		*mandoc_getarg(struct mparse *, char **, int, int *);
4432a712daSGarrett D'Amore char		*mandoc_normdate(struct mparse *, char *, int, int);
4532a712daSGarrett D'Amore int		 mandoc_eos(const char *, size_t, int);
4632a712daSGarrett D'Amore int		 mandoc_strntoi(const char *, size_t, int);
4732a712daSGarrett D'Amore const char	*mandoc_a2msec(const char*);
4832a712daSGarrett D'Amore 
4932a712daSGarrett D'Amore void	 	 mdoc_free(struct mdoc *);
50*ffb8ebfaSGarrett D'Amore struct	mdoc	*mdoc_alloc(struct roff *, struct mparse *, char *);
5132a712daSGarrett D'Amore void		 mdoc_reset(struct mdoc *);
5232a712daSGarrett D'Amore int	 	 mdoc_parseln(struct mdoc *, int, char *, int);
5332a712daSGarrett D'Amore int		 mdoc_endparse(struct mdoc *);
5432a712daSGarrett D'Amore int		 mdoc_addspan(struct mdoc *, const struct tbl_span *);
5532a712daSGarrett D'Amore int		 mdoc_addeqn(struct mdoc *, const struct eqn *);
5632a712daSGarrett D'Amore 
5732a712daSGarrett D'Amore void	 	 man_free(struct man *);
5832a712daSGarrett D'Amore struct	man	*man_alloc(struct roff *, struct mparse *);
5932a712daSGarrett D'Amore void		 man_reset(struct man *);
6032a712daSGarrett D'Amore int	 	 man_parseln(struct man *, int, char *, int);
6132a712daSGarrett D'Amore int		 man_endparse(struct man *);
6232a712daSGarrett D'Amore int		 man_addspan(struct man *, const struct tbl_span *);
6332a712daSGarrett D'Amore int		 man_addeqn(struct man *, const struct eqn *);
6432a712daSGarrett D'Amore 
6532a712daSGarrett D'Amore void	 	 roff_free(struct roff *);
66*ffb8ebfaSGarrett D'Amore struct roff	*roff_alloc(enum mparset, struct mparse *);
6732a712daSGarrett D'Amore void		 roff_reset(struct roff *);
6832a712daSGarrett D'Amore enum rofferr	 roff_parseln(struct roff *, int,
6932a712daSGarrett D'Amore 			char **, size_t *, int, int *);
7032a712daSGarrett D'Amore void		 roff_endparse(struct roff *);
71*ffb8ebfaSGarrett D'Amore void		 roff_setreg(struct roff *, const char *, int, char sign);
72*ffb8ebfaSGarrett D'Amore int		 roff_getreg(const struct roff *, const char *);
7332a712daSGarrett D'Amore char		*roff_strdup(const struct roff *, const char *);
74*ffb8ebfaSGarrett D'Amore int		 roff_getcontrol(const struct roff *,
75*ffb8ebfaSGarrett D'Amore 			const char *, int *);
7632a712daSGarrett D'Amore #if 0
7732a712daSGarrett D'Amore char		 roff_eqndelim(const struct roff *);
7832a712daSGarrett D'Amore void		 roff_openeqn(struct roff *, const char *,
7932a712daSGarrett D'Amore 			int, int, const char *);
8032a712daSGarrett D'Amore int		 roff_closeeqn(struct roff *);
8132a712daSGarrett D'Amore #endif
8232a712daSGarrett D'Amore 
8332a712daSGarrett D'Amore const struct tbl_span	*roff_span(const struct roff *);
8432a712daSGarrett D'Amore const struct eqn	*roff_eqn(const struct roff *);
8532a712daSGarrett D'Amore 
8632a712daSGarrett D'Amore __END_DECLS
8732a712daSGarrett D'Amore 
8832a712daSGarrett D'Amore #endif /*!LIBMANDOC_H*/
89