xref: /titanic_51/usr/src/cmd/mandoc/man.h (revision 95c635efb7c3b86efc493e0447eaec7aecca3f0f)
1*95c635efSGarrett D'Amore /*	$Id: man.h,v 1.60 2012/01/03 15:16:24 kristaps Exp $ */
2*95c635efSGarrett D'Amore /*
3*95c635efSGarrett D'Amore  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4*95c635efSGarrett D'Amore  *
5*95c635efSGarrett D'Amore  * Permission to use, copy, modify, and distribute this software for any
6*95c635efSGarrett D'Amore  * purpose with or without fee is hereby granted, provided that the above
7*95c635efSGarrett D'Amore  * copyright notice and this permission notice appear in all copies.
8*95c635efSGarrett D'Amore  *
9*95c635efSGarrett D'Amore  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*95c635efSGarrett D'Amore  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*95c635efSGarrett D'Amore  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*95c635efSGarrett D'Amore  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*95c635efSGarrett D'Amore  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*95c635efSGarrett D'Amore  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*95c635efSGarrett D'Amore  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*95c635efSGarrett D'Amore  */
17*95c635efSGarrett D'Amore #ifndef MAN_H
18*95c635efSGarrett D'Amore #define MAN_H
19*95c635efSGarrett D'Amore 
20*95c635efSGarrett D'Amore enum	mant {
21*95c635efSGarrett D'Amore 	MAN_br = 0,
22*95c635efSGarrett D'Amore 	MAN_TH,
23*95c635efSGarrett D'Amore 	MAN_SH,
24*95c635efSGarrett D'Amore 	MAN_SS,
25*95c635efSGarrett D'Amore 	MAN_TP,
26*95c635efSGarrett D'Amore 	MAN_LP,
27*95c635efSGarrett D'Amore 	MAN_PP,
28*95c635efSGarrett D'Amore 	MAN_P,
29*95c635efSGarrett D'Amore 	MAN_IP,
30*95c635efSGarrett D'Amore 	MAN_HP,
31*95c635efSGarrett D'Amore 	MAN_SM,
32*95c635efSGarrett D'Amore 	MAN_SB,
33*95c635efSGarrett D'Amore 	MAN_BI,
34*95c635efSGarrett D'Amore 	MAN_IB,
35*95c635efSGarrett D'Amore 	MAN_BR,
36*95c635efSGarrett D'Amore 	MAN_RB,
37*95c635efSGarrett D'Amore 	MAN_R,
38*95c635efSGarrett D'Amore 	MAN_B,
39*95c635efSGarrett D'Amore 	MAN_I,
40*95c635efSGarrett D'Amore 	MAN_IR,
41*95c635efSGarrett D'Amore 	MAN_RI,
42*95c635efSGarrett D'Amore 	MAN_na,
43*95c635efSGarrett D'Amore 	MAN_sp,
44*95c635efSGarrett D'Amore 	MAN_nf,
45*95c635efSGarrett D'Amore 	MAN_fi,
46*95c635efSGarrett D'Amore 	MAN_RE,
47*95c635efSGarrett D'Amore 	MAN_RS,
48*95c635efSGarrett D'Amore 	MAN_DT,
49*95c635efSGarrett D'Amore 	MAN_UC,
50*95c635efSGarrett D'Amore 	MAN_PD,
51*95c635efSGarrett D'Amore 	MAN_AT,
52*95c635efSGarrett D'Amore 	MAN_in,
53*95c635efSGarrett D'Amore 	MAN_ft,
54*95c635efSGarrett D'Amore 	MAN_OP,
55*95c635efSGarrett D'Amore 	MAN_MAX
56*95c635efSGarrett D'Amore };
57*95c635efSGarrett D'Amore 
58*95c635efSGarrett D'Amore enum	man_type {
59*95c635efSGarrett D'Amore 	MAN_TEXT,
60*95c635efSGarrett D'Amore 	MAN_ELEM,
61*95c635efSGarrett D'Amore 	MAN_ROOT,
62*95c635efSGarrett D'Amore 	MAN_BLOCK,
63*95c635efSGarrett D'Amore 	MAN_HEAD,
64*95c635efSGarrett D'Amore 	MAN_BODY,
65*95c635efSGarrett D'Amore 	MAN_TAIL,
66*95c635efSGarrett D'Amore 	MAN_TBL,
67*95c635efSGarrett D'Amore 	MAN_EQN
68*95c635efSGarrett D'Amore };
69*95c635efSGarrett D'Amore 
70*95c635efSGarrett D'Amore struct	man_meta {
71*95c635efSGarrett D'Amore 	char		*msec; /* `TH' section (1, 3p, etc.) */
72*95c635efSGarrett D'Amore 	char		*date; /* `TH' normalised date */
73*95c635efSGarrett D'Amore 	char		*vol; /* `TH' volume */
74*95c635efSGarrett D'Amore 	char		*title; /* `TH' title (e.g., FOO) */
75*95c635efSGarrett D'Amore 	char		*source; /* `TH' source (e.g., GNU) */
76*95c635efSGarrett D'Amore };
77*95c635efSGarrett D'Amore 
78*95c635efSGarrett D'Amore struct	man_node {
79*95c635efSGarrett D'Amore 	struct man_node	*parent; /* parent AST node */
80*95c635efSGarrett D'Amore 	struct man_node	*child; /* first child AST node */
81*95c635efSGarrett D'Amore 	struct man_node	*next; /* sibling AST node */
82*95c635efSGarrett D'Amore 	struct man_node	*prev; /* prior sibling AST node */
83*95c635efSGarrett D'Amore 	int		 nchild; /* number children */
84*95c635efSGarrett D'Amore 	int		 line;
85*95c635efSGarrett D'Amore 	int		 pos;
86*95c635efSGarrett D'Amore 	enum mant	 tok; /* tok or MAN__MAX if none */
87*95c635efSGarrett D'Amore 	int		 flags;
88*95c635efSGarrett D'Amore #define	MAN_VALID	(1 << 0) /* has been validated */
89*95c635efSGarrett D'Amore #define	MAN_EOS		(1 << 2) /* at sentence boundary */
90*95c635efSGarrett D'Amore #define	MAN_LINE	(1 << 3) /* first macro/text on line */
91*95c635efSGarrett D'Amore 	enum man_type	 type; /* AST node type */
92*95c635efSGarrett D'Amore 	char		*string; /* TEXT node argument */
93*95c635efSGarrett D'Amore 	struct man_node	*head; /* BLOCK node HEAD ptr */
94*95c635efSGarrett D'Amore 	struct man_node *tail; /* BLOCK node TAIL ptr */
95*95c635efSGarrett D'Amore 	struct man_node	*body; /* BLOCK node BODY ptr */
96*95c635efSGarrett D'Amore 	const struct tbl_span *span; /* TBL */
97*95c635efSGarrett D'Amore 	const struct eqn *eqn; /* EQN */
98*95c635efSGarrett D'Amore };
99*95c635efSGarrett D'Amore 
100*95c635efSGarrett D'Amore /* Names of macros.  Index is enum mant. */
101*95c635efSGarrett D'Amore extern	const char *const *man_macronames;
102*95c635efSGarrett D'Amore 
103*95c635efSGarrett D'Amore __BEGIN_DECLS
104*95c635efSGarrett D'Amore 
105*95c635efSGarrett D'Amore struct	man;
106*95c635efSGarrett D'Amore 
107*95c635efSGarrett D'Amore const struct man_node *man_node(const struct man *);
108*95c635efSGarrett D'Amore const struct man_meta *man_meta(const struct man *);
109*95c635efSGarrett D'Amore const struct mparse   *man_mparse(const struct man *);
110*95c635efSGarrett D'Amore 
111*95c635efSGarrett D'Amore __END_DECLS
112*95c635efSGarrett D'Amore 
113*95c635efSGarrett D'Amore #endif /*!MAN_H*/
114