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