xref: /titanic_44/usr/src/cmd/mandoc/libroff.h (revision 698f87a48e2e945bfe5493ce168e0d0ae1cedd5c)
1*698f87a4SGarrett D'Amore /*	$Id: libroff.h,v 1.28 2013/05/31 21:37:17 schwarze Exp $ */
295c635efSGarrett D'Amore /*
395c635efSGarrett D'Amore  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
495c635efSGarrett D'Amore  *
595c635efSGarrett D'Amore  * Permission to use, copy, modify, and distribute this software for any
695c635efSGarrett D'Amore  * purpose with or without fee is hereby granted, provided that the above
795c635efSGarrett D'Amore  * copyright notice and this permission notice appear in all copies.
895c635efSGarrett D'Amore  *
995c635efSGarrett D'Amore  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1095c635efSGarrett D'Amore  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1195c635efSGarrett D'Amore  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1295c635efSGarrett D'Amore  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1395c635efSGarrett D'Amore  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1495c635efSGarrett D'Amore  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1595c635efSGarrett D'Amore  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1695c635efSGarrett D'Amore  */
1795c635efSGarrett D'Amore #ifndef LIBROFF_H
1895c635efSGarrett D'Amore #define LIBROFF_H
1995c635efSGarrett D'Amore 
2095c635efSGarrett D'Amore __BEGIN_DECLS
2195c635efSGarrett D'Amore 
2295c635efSGarrett D'Amore enum	tbl_part {
2395c635efSGarrett D'Amore 	TBL_PART_OPTS, /* in options (first line) */
2495c635efSGarrett D'Amore 	TBL_PART_LAYOUT, /* describing layout */
2595c635efSGarrett D'Amore 	TBL_PART_DATA, /* creating data rows */
2695c635efSGarrett D'Amore 	TBL_PART_CDATA /* continue previous row */
2795c635efSGarrett D'Amore };
2895c635efSGarrett D'Amore 
2995c635efSGarrett D'Amore struct	tbl_node {
3095c635efSGarrett D'Amore 	struct mparse	 *parse; /* parse point */
3195c635efSGarrett D'Amore 	int		  pos; /* invocation column */
3295c635efSGarrett D'Amore 	int		  line; /* invocation line */
3395c635efSGarrett D'Amore 	enum tbl_part	  part;
34*698f87a4SGarrett D'Amore 	struct tbl_opts	  opts;
3595c635efSGarrett D'Amore 	struct tbl_row	 *first_row;
3695c635efSGarrett D'Amore 	struct tbl_row	 *last_row;
3795c635efSGarrett D'Amore 	struct tbl_span	 *first_span;
3895c635efSGarrett D'Amore 	struct tbl_span	 *current_span;
3995c635efSGarrett D'Amore 	struct tbl_span	 *last_span;
4095c635efSGarrett D'Amore 	struct tbl_head	 *first_head;
4195c635efSGarrett D'Amore 	struct tbl_head	 *last_head;
4295c635efSGarrett D'Amore 	struct tbl_node	 *next;
4395c635efSGarrett D'Amore };
4495c635efSGarrett D'Amore 
4595c635efSGarrett D'Amore struct	eqn_node {
4695c635efSGarrett D'Amore 	struct eqn_def	 *defs;
4795c635efSGarrett D'Amore 	size_t		  defsz;
4895c635efSGarrett D'Amore 	char		 *data;
4995c635efSGarrett D'Amore 	size_t		  rew;
5095c635efSGarrett D'Amore 	size_t		  cur;
5195c635efSGarrett D'Amore 	size_t		  sz;
5295c635efSGarrett D'Amore 	int		  gsize;
5395c635efSGarrett D'Amore 	struct eqn	  eqn;
5495c635efSGarrett D'Amore 	struct mparse	 *parse;
5595c635efSGarrett D'Amore 	struct eqn_node  *next;
5695c635efSGarrett D'Amore };
5795c635efSGarrett D'Amore 
5895c635efSGarrett D'Amore struct	eqn_def {
5995c635efSGarrett D'Amore 	char		 *key;
6095c635efSGarrett D'Amore 	size_t		  keysz;
6195c635efSGarrett D'Amore 	char		 *val;
6295c635efSGarrett D'Amore 	size_t		  valsz;
6395c635efSGarrett D'Amore };
6495c635efSGarrett D'Amore 
6595c635efSGarrett D'Amore struct tbl_node	*tbl_alloc(int, int, struct mparse *);
6695c635efSGarrett D'Amore void		 tbl_restart(int, int, struct tbl_node *);
6795c635efSGarrett D'Amore void		 tbl_free(struct tbl_node *);
6895c635efSGarrett D'Amore void		 tbl_reset(struct tbl_node *);
6995c635efSGarrett D'Amore enum rofferr 	 tbl_read(struct tbl_node *, int, const char *, int);
7095c635efSGarrett D'Amore int		 tbl_option(struct tbl_node *, int, const char *);
7195c635efSGarrett D'Amore int		 tbl_layout(struct tbl_node *, int, const char *);
7295c635efSGarrett D'Amore int		 tbl_data(struct tbl_node *, int, const char *);
7395c635efSGarrett D'Amore int		 tbl_cdata(struct tbl_node *, int, const char *);
7495c635efSGarrett D'Amore const struct tbl_span	*tbl_span(struct tbl_node *);
7595c635efSGarrett D'Amore void		 tbl_end(struct tbl_node **);
7695c635efSGarrett D'Amore struct eqn_node	*eqn_alloc(const char *, int, int, struct mparse *);
7795c635efSGarrett D'Amore enum rofferr	 eqn_end(struct eqn_node **);
7895c635efSGarrett D'Amore void		 eqn_free(struct eqn_node *);
7995c635efSGarrett D'Amore enum rofferr 	 eqn_read(struct eqn_node **, int,
8095c635efSGarrett D'Amore 			const char *, int, int *);
8195c635efSGarrett D'Amore 
8295c635efSGarrett D'Amore __END_DECLS
8395c635efSGarrett D'Amore 
8495c635efSGarrett D'Amore #endif /*LIBROFF_H*/
85