Annotation of src/usr.bin/mandoc/man.h, Revision 1.30
1.30 ! schwarze 1: /* $Id: man.h,v 1.29 2010/11/29 00:12:02 schwarze Exp $ */
1.1 kristaps 2: /*
1.25 schwarze 3: * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
1.1 kristaps 4: *
5: * Permission to use, copy, modify, and distribute this software for any
1.2 schwarze 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.2 schwarze 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.28 schwarze 20: /*
21: * What follows is a list of ALL possible macros.
22: */
1.14 schwarze 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_i,
47: MAN_sp,
48: MAN_nf,
49: MAN_fi,
50: MAN_r,
51: MAN_RE,
52: MAN_RS,
53: MAN_DT,
54: MAN_UC,
55: MAN_PD,
1.21 schwarze 56: MAN_AT,
1.25 schwarze 57: MAN_in,
1.27 schwarze 58: MAN_TS,
59: MAN_TE,
1.29 schwarze 60: MAN_ft,
1.21 schwarze 61: MAN_MAX
1.14 schwarze 62: };
1.1 kristaps 63:
1.28 schwarze 64: /*
65: * Type of a syntax node.
66: */
1.1 kristaps 67: enum man_type {
68: MAN_TEXT,
69: MAN_ELEM,
1.7 schwarze 70: MAN_ROOT,
71: MAN_BLOCK,
72: MAN_HEAD,
73: MAN_BODY
1.1 kristaps 74: };
75:
1.28 schwarze 76: /*
77: * Information from prologue.
78: */
1.1 kristaps 79: struct man_meta {
1.28 schwarze 80: char *msec; /* `TH' section (1, 3p, etc.) */
81: time_t date; /* `TH' normalised date */
82: char *rawdate; /* raw `TH' date */
83: char *vol; /* `TH' volume */
84: char *title; /* `TH' title (e.g., FOO) */
85: char *source; /* `TH' source (e.g., GNU) */
1.1 kristaps 86: };
87:
1.28 schwarze 88: union man_data {
89: struct tbl *TS;
90: };
91:
92: /*
93: * Single node in tree-linked AST.
94: */
1.1 kristaps 95: struct man_node {
1.28 schwarze 96: struct man_node *parent; /* parent AST node */
97: struct man_node *child; /* first child AST node */
98: struct man_node *next; /* sibling AST node */
99: struct man_node *prev; /* prior sibling AST node */
100: int nchild; /* number children */
1.1 kristaps 101: int line;
102: int pos;
1.28 schwarze 103: enum mant tok; /* tok or MAN__MAX if none */
1.1 kristaps 104: int flags;
1.28 schwarze 105: #define MAN_VALID (1 << 0) /* has been validated */
106: #define MAN_ACTED (1 << 1) /* has been acted upon */
107: #define MAN_EOS (1 << 2) /* at sentence boundary */
108: enum man_type type; /* AST node type */
109: char *string; /* TEXT node argument */
110: struct man_node *head; /* BLOCK node HEAD ptr */
111: struct man_node *body; /* BLOCK node BODY ptr */
112: union man_data data;
1.1 kristaps 113: };
114:
1.28 schwarze 115: /*
116: * Names of macros. Index is enum mant. Indexing into this returns
117: * the normalised name, e.g., man_macronames[MAN_SH] -> "SH".
118: */
1.1 kristaps 119: extern const char *const *man_macronames;
120:
121: __BEGIN_DECLS
122:
123: struct man;
124:
125: void man_free(struct man *);
1.26 schwarze 126: struct man *man_alloc(struct regset *, void *, mandocmsg);
1.12 schwarze 127: void man_reset(struct man *);
1.20 schwarze 128: int man_parseln(struct man *, int, char *, int);
1.1 kristaps 129: int man_endparse(struct man *);
130:
131: const struct man_node *man_node(const struct man *);
132: const struct man_meta *man_meta(const struct man *);
133:
134: __END_DECLS
135:
136: #endif /*!MAN_H*/