]> git.cameronkatri.com Git - mandoc.git/blob - private.h
Removed superfluous structures from rofftree.
[mandoc.git] / private.h
1 /* $Id: private.h,v 1.15 2008/11/28 15:25:49 kristaps Exp $ */
2 /*
3 * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the
7 * above copyright notice and this permission notice appear in all
8 * copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 */
19 #ifndef PRIVATE_H
20 #define PRIVATE_H
21
22 /* Input buffer (input read into buffer, then filled when empty). */
23 struct md_rbuf {
24 int fd; /* Open descriptor. */
25 char *name; /* Name of file. */
26 char *buf; /* Buffer. */
27 size_t bufsz; /* Size of buffer. */
28 size_t line; /* Current line number. */
29 };
30
31 /* Output buffer (output buffered until full, then flushed). */
32 struct md_mbuf {
33 int fd; /* Open descriptor. */
34 char *name; /* Name of file. */
35 char *buf; /* Buffer. */
36 size_t bufsz; /* Size of buffer. */
37 size_t pos; /* Position in buffer. */
38 };
39
40 #define ROFF___ 0
41 #define ROFF_Dd 1
42 #define ROFF_Dt 2
43 #define ROFF_Os 3
44 #define ROFF_Sh 4
45 #define ROFF_Ss 5
46 #define ROFF_Pp 6
47 #define ROFF_D1 7
48 #define ROFF_Dl 8
49 #define ROFF_Bd 9
50 #define ROFF_Ed 10
51 #define ROFF_Bl 11
52 #define ROFF_El 12
53 #define ROFF_It 13
54 #define ROFF_Ad 14
55 #define ROFF_An 15
56 #define ROFF_Ar 16
57 #define ROFF_Cd 17
58 #define ROFF_Cm 18
59 #define ROFF_Dv 19
60 #define ROFF_Er 20
61 #define ROFF_Ev 21
62 #define ROFF_Ex 22
63 #define ROFF_Fa 23
64 #define ROFF_Fd 24
65 #define ROFF_Fl 25
66 #define ROFF_Fn 26
67 #define ROFF_Ft 27
68 #define ROFF_Ic 28
69 #define ROFF_In 29
70 #define ROFF_Li 30
71 #define ROFF_Nd 31
72 #define ROFF_Nm 32
73 #define ROFF_Op 33
74 #define ROFF_Ot 34
75 #define ROFF_Pa 35
76 #define ROFF_Rv 36
77 #define ROFF_St 37
78 #define ROFF_Va 38
79 #define ROFF_Vt 39
80 #define ROFF_Xr 40
81 #define ROFF__A 41
82 #define ROFF__B 42
83 #define ROFF__D 43
84 #define ROFF__I 44
85 #define ROFF__J 45
86 #define ROFF__N 46
87 #define ROFF__O 47
88 #define ROFF__P 48
89 #define ROFF__R 49
90 #define ROFF__T 50
91 #define ROFF__V 51
92 #define ROFF_Ac 52
93 #define ROFF_Ao 53
94 #define ROFF_Aq 54
95 #define ROFF_At 55
96 #define ROFF_Bc 56
97 #define ROFF_Bf 57
98 #define ROFF_Bo 58
99 #define ROFF_Bq 59
100 #define ROFF_Bsx 60
101 #define ROFF_Bx 61
102 #define ROFF_Db 62
103 #define ROFF_Dc 63
104 #define ROFF_Do 64
105 #define ROFF_Dq 65
106 #define ROFF_Ec 66
107 #define ROFF_Ef 67
108 #define ROFF_Em 68
109 #define ROFF_Eo 69
110 #define ROFF_Fx 70
111 #define ROFF_Ms 71
112 #define ROFF_No 72
113 #define ROFF_Ns 73
114 #define ROFF_Nx 74
115 #define ROFF_Ox 75
116 #define ROFF_Pc 76
117 #define ROFF_Pf 77
118 #define ROFF_Po 78
119 #define ROFF_Pq 79
120 #define ROFF_Qc 80
121 #define ROFF_Ql 81
122 #define ROFF_Qo 82
123 #define ROFF_Qq 83
124 #define ROFF_Re 84
125 #define ROFF_Rs 85
126 #define ROFF_Sc 86
127 #define ROFF_So 87
128 #define ROFF_Sq 88
129 #define ROFF_Sm 89
130 #define ROFF_Sx 90
131 #define ROFF_Sy 91
132 #define ROFF_Tn 92
133 #define ROFF_Ux 93
134 #define ROFF_Xc 94
135 #define ROFF_Xo 95
136 #define ROFF_Fo 96
137 #define ROFF_Fc 97
138 #define ROFF_Oo 98
139 #define ROFF_Oc 99
140 #define ROFF_Bk 100
141 #define ROFF_Ek 101
142 #define ROFF_MAX 102
143
144 #define ROFF_Split 0
145 #define ROFF_Nosplit 1
146 #define ROFF_Ragged 2
147 #define ROFF_Unfilled 3
148 #define ROFF_Literal 4
149 #define ROFF_File 5
150 #define ROFF_Offset 6
151 #define ROFF_Bullet 7
152 #define ROFF_Dash 8
153 #define ROFF_Hyphen 9
154 #define ROFF_Item 10
155 #define ROFF_Enum 11
156 #define ROFF_Tag 12
157 #define ROFF_Diag 13
158 #define ROFF_Hang 14
159 #define ROFF_Ohang 15
160 #define ROFF_Inset 16
161 #define ROFF_Column 17
162 #define ROFF_Width 18
163 #define ROFF_Compact 19
164 #define ROFF_Std 20
165 #define ROFF_p1003_1_88 21
166 #define ROFF_p1003_1_90 22
167 #define ROFF_p1003_1_96 23
168 #define ROFF_p1003_1_2001 24
169 #define ROFF_p1003_1_2004 25
170 #define ROFF_p1003_1 26
171 #define ROFF_p1003_1b 27
172 #define ROFF_p1003_1b_93 28
173 #define ROFF_p1003_1c_95 29
174 #define ROFF_p1003_1g_2000 30
175 #define ROFF_p1003_2_92 31
176 #define ROFF_p1387_2_95 32
177 #define ROFF_p1003_2 33
178 #define ROFF_p1387_2 34
179 #define ROFF_isoC_90 35
180 #define ROFF_isoC_amd1 36
181 #define ROFF_isoC_tcor1 37
182 #define ROFF_isoC_tcor2 38
183 #define ROFF_isoC_99 39
184 #define ROFF_ansiC 40
185 #define ROFF_ansiC_89 41
186 #define ROFF_ansiC_99 42
187 #define ROFF_ieee754 43
188 #define ROFF_iso8802_3 44
189 #define ROFF_xpg3 45
190 #define ROFF_xpg4 46
191 #define ROFF_xpg4_2 47
192 #define ROFF_xpg4_3 48
193 #define ROFF_xbd5 49
194 #define ROFF_xcu5 50
195 #define ROFF_xsh5 51
196 #define ROFF_xns5 52
197 #define ROFF_xns5_2d2_0 53
198 #define ROFF_xcurses4_2 54
199 #define ROFF_susv2 55
200 #define ROFF_susv3 56
201 #define ROFF_svid4 57
202 #define ROFF_Filled 58
203 #define ROFF_Words 59
204 #define ROFF_ARGMAX 60
205
206 extern const char *const *toknames;
207 extern const char *const *tokargnames;
208
209 enum roffmsg { ROFF_WARN, ROFF_ERROR };
210
211 struct roffcb {
212 void (*roffmsg)(void *, enum roffmsg,
213 const char *, const char *, char *);
214 int (*roffhead)(void *);
215 int (*rofftail)(void *);
216 int (*roffin)(void *, int, int *, char **);
217 int (*roffdata)(void *, const char *);
218 int (*roffout)(void *, int);
219 int (*roffblkin)(void *, int);
220 int (*roffblkout)(void *, int);
221 int (*roffspecial)(void *, int);
222 };
223
224 __BEGIN_DECLS
225
226 typedef void (*(*md_init)(const struct md_args *,
227 struct md_mbuf *, const struct md_rbuf *));
228 typedef int (*md_line)(void *, char *, size_t);
229 typedef int (*md_exit)(void *, int);
230
231 void *md_init_html4_strict(const struct md_args *,
232 struct md_mbuf *, const struct md_rbuf *);
233 int md_line_html4_strict(void *, char *, size_t);
234 int md_exit_html4_strict(void *, int);
235
236 void *md_init_valid(const struct md_args *,
237 struct md_mbuf *, const struct md_rbuf *);
238 int md_line_valid(void *, char *, size_t);
239 int md_exit_valid(void *, int);
240
241 int md_buf_puts(struct md_mbuf *, const char *, size_t);
242 int md_buf_putchar(struct md_mbuf *, char);
243 int md_buf_putstring(struct md_mbuf *, const char *);
244
245 struct rofftree;
246
247 struct rofftree *roff_alloc(const struct roffcb *, void *);
248 int roff_engine(struct rofftree *, char *, size_t);
249 int roff_free(struct rofftree *, int);
250
251 __END_DECLS
252
253 #endif /*!PRIVATE_H*/