xref: /titanic_52/usr/src/cmd/mandoc/man.h (revision 260e9a87725c090ba5835b1f9f0b62fa2f96036f)
1*260e9a87SYuri Pankov /*	$Id: man.h,v 1.69 2015/01/24 02:41:49 schwarze Exp $ */
295c635efSGarrett D'Amore /*
395c635efSGarrett D'Amore  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4*260e9a87SYuri Pankov  * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
595c635efSGarrett D'Amore  *
695c635efSGarrett D'Amore  * Permission to use, copy, modify, and distribute this software for any
795c635efSGarrett D'Amore  * purpose with or without fee is hereby granted, provided that the above
895c635efSGarrett D'Amore  * copyright notice and this permission notice appear in all copies.
995c635efSGarrett D'Amore  *
1095c635efSGarrett D'Amore  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1195c635efSGarrett D'Amore  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1295c635efSGarrett D'Amore  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1395c635efSGarrett D'Amore  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1495c635efSGarrett D'Amore  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1595c635efSGarrett D'Amore  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1695c635efSGarrett D'Amore  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1795c635efSGarrett D'Amore  */
1895c635efSGarrett D'Amore 
1995c635efSGarrett D'Amore enum	mant {
2095c635efSGarrett D'Amore 	MAN_br = 0,
2195c635efSGarrett D'Amore 	MAN_TH,
2295c635efSGarrett D'Amore 	MAN_SH,
2395c635efSGarrett D'Amore 	MAN_SS,
2495c635efSGarrett D'Amore 	MAN_TP,
2595c635efSGarrett D'Amore 	MAN_LP,
2695c635efSGarrett D'Amore 	MAN_PP,
2795c635efSGarrett D'Amore 	MAN_P,
2895c635efSGarrett D'Amore 	MAN_IP,
2995c635efSGarrett D'Amore 	MAN_HP,
3095c635efSGarrett D'Amore 	MAN_SM,
3195c635efSGarrett D'Amore 	MAN_SB,
3295c635efSGarrett D'Amore 	MAN_BI,
3395c635efSGarrett D'Amore 	MAN_IB,
3495c635efSGarrett D'Amore 	MAN_BR,
3595c635efSGarrett D'Amore 	MAN_RB,
3695c635efSGarrett D'Amore 	MAN_R,
3795c635efSGarrett D'Amore 	MAN_B,
3895c635efSGarrett D'Amore 	MAN_I,
3995c635efSGarrett D'Amore 	MAN_IR,
4095c635efSGarrett D'Amore 	MAN_RI,
4195c635efSGarrett D'Amore 	MAN_sp,
4295c635efSGarrett D'Amore 	MAN_nf,
4395c635efSGarrett D'Amore 	MAN_fi,
4495c635efSGarrett D'Amore 	MAN_RE,
4595c635efSGarrett D'Amore 	MAN_RS,
4695c635efSGarrett D'Amore 	MAN_DT,
4795c635efSGarrett D'Amore 	MAN_UC,
4895c635efSGarrett D'Amore 	MAN_PD,
4995c635efSGarrett D'Amore 	MAN_AT,
5095c635efSGarrett D'Amore 	MAN_in,
5195c635efSGarrett D'Amore 	MAN_ft,
5295c635efSGarrett D'Amore 	MAN_OP,
53698f87a4SGarrett D'Amore 	MAN_EX,
54698f87a4SGarrett D'Amore 	MAN_EE,
55698f87a4SGarrett D'Amore 	MAN_UR,
56698f87a4SGarrett D'Amore 	MAN_UE,
57*260e9a87SYuri Pankov 	MAN_ll,
5895c635efSGarrett D'Amore 	MAN_MAX
5995c635efSGarrett D'Amore };
6095c635efSGarrett D'Amore 
6195c635efSGarrett D'Amore enum	man_type {
6295c635efSGarrett D'Amore 	MAN_TEXT,
6395c635efSGarrett D'Amore 	MAN_ELEM,
6495c635efSGarrett D'Amore 	MAN_ROOT,
6595c635efSGarrett D'Amore 	MAN_BLOCK,
6695c635efSGarrett D'Amore 	MAN_HEAD,
6795c635efSGarrett D'Amore 	MAN_BODY,
6895c635efSGarrett D'Amore 	MAN_TBL,
6995c635efSGarrett D'Amore 	MAN_EQN
7095c635efSGarrett D'Amore };
7195c635efSGarrett D'Amore 
7295c635efSGarrett D'Amore struct	man_meta {
7395c635efSGarrett D'Amore 	char		*msec; /* `TH' section (1, 3p, etc.) */
7495c635efSGarrett D'Amore 	char		*date; /* `TH' normalised date */
7595c635efSGarrett D'Amore 	char		*vol; /* `TH' volume */
7695c635efSGarrett D'Amore 	char		*title; /* `TH' title (e.g., FOO) */
7795c635efSGarrett D'Amore 	char		*source; /* `TH' source (e.g., GNU) */
78*260e9a87SYuri Pankov 	int		 hasbody; /* document is not empty */
7995c635efSGarrett D'Amore };
8095c635efSGarrett D'Amore 
8195c635efSGarrett D'Amore struct	man_node {
8295c635efSGarrett D'Amore 	struct man_node	*parent; /* parent AST node */
8395c635efSGarrett D'Amore 	struct man_node	*child; /* first child AST node */
8495c635efSGarrett D'Amore 	struct man_node	*next; /* sibling AST node */
8595c635efSGarrett D'Amore 	struct man_node	*prev; /* prior sibling AST node */
8695c635efSGarrett D'Amore 	int		 nchild; /* number children */
8795c635efSGarrett D'Amore 	int		 line;
8895c635efSGarrett D'Amore 	int		 pos;
8995c635efSGarrett D'Amore 	enum mant	 tok; /* tok or MAN__MAX if none */
9095c635efSGarrett D'Amore 	int		 flags;
9195c635efSGarrett D'Amore #define	MAN_VALID	(1 << 0) /* has been validated */
9295c635efSGarrett D'Amore #define	MAN_EOS		(1 << 2) /* at sentence boundary */
9395c635efSGarrett D'Amore #define	MAN_LINE	(1 << 3) /* first macro/text on line */
9495c635efSGarrett D'Amore 	enum man_type	 type; /* AST node type */
9595c635efSGarrett D'Amore 	char		*string; /* TEXT node argument */
9695c635efSGarrett D'Amore 	struct man_node	*head; /* BLOCK node HEAD ptr */
9795c635efSGarrett D'Amore 	struct man_node *tail; /* BLOCK node TAIL ptr */
9895c635efSGarrett D'Amore 	struct man_node	*body; /* BLOCK node BODY ptr */
9995c635efSGarrett D'Amore 	const struct tbl_span *span; /* TBL */
10095c635efSGarrett D'Amore 	const struct eqn *eqn; /* EQN */
101*260e9a87SYuri Pankov 	int		 aux; /* decoded node data, type-dependent */
10295c635efSGarrett D'Amore };
10395c635efSGarrett D'Amore 
10495c635efSGarrett D'Amore /* Names of macros.  Index is enum mant. */
10595c635efSGarrett D'Amore extern	const char *const *man_macronames;
10695c635efSGarrett D'Amore 
10795c635efSGarrett D'Amore __BEGIN_DECLS
10895c635efSGarrett D'Amore 
10995c635efSGarrett D'Amore struct	man;
11095c635efSGarrett D'Amore 
11195c635efSGarrett D'Amore const struct man_node *man_node(const struct man *);
11295c635efSGarrett D'Amore const struct man_meta *man_meta(const struct man *);
11395c635efSGarrett D'Amore const struct mparse   *man_mparse(const struct man *);
114*260e9a87SYuri Pankov void man_deroff(char **, const struct man_node *);
11595c635efSGarrett D'Amore 
11695c635efSGarrett D'Amore __END_DECLS
117