]> git.cameronkatri.com Git - mandoc.git/blob - private.h
Considerable clean-ups.
[mandoc.git] / private.h
1 /* $Id: private.h,v 1.35 2008/12/09 17:09:12 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 #include <stdio.h>
23 #include <time.h>
24
25 #include "libmdocml.h"
26
27 struct md_rbuf {
28 int fd; /* Open descriptor. */
29 char *name; /* Name of file. */
30 char *buf; /* Buffer. */
31 size_t bufsz; /* Size of buffer. */
32 size_t line; /* Current line number. */
33 #define MD_LINE (BUFSIZ)
34 char linebuf[MD_LINE];
35 };
36
37 struct md_mbuf {
38 int fd; /* Open descriptor. */
39 char *name; /* Name of file. */
40 char *buf; /* Buffer. */
41 size_t bufsz; /* Size of buffer. */
42 size_t pos; /* Position in buffer. */
43 };
44
45 #define ROFFTok_Sp_A 0
46 #define ROFFTok_Sp_B 1
47 #define ROFFTok_Sp_F 2
48 #define ROFFTok_Sp_N 3
49 #define ROFFTok_Sp_R 4
50 #define ROFFTok_Sp_T 5
51 #define ROFFTok_Sp_V 6
52 #define ROFFTok_Space 7
53 #define ROFFTok_Null 8
54 #define ROFFTok_Hyphen 9
55 #define ROFFTok_Em 10
56 #define ROFFTok_En 11
57 #define ROFFTok_Ge 12
58 #define ROFFTok_Le 13
59 #define ROFFTok_Rquote 14
60 #define ROFFTok_Lquote 15
61 #define ROFFTok_Uparrow 16
62 #define ROFFTok_Acute 17
63 #define ROFFTok_Grave 18
64 #define ROFFTok_Pi 19
65 #define ROFFTok_Ne 20
66 #define ROFFTok_Lt 21
67 #define ROFFTok_Gt 22
68 #define ROFFTok_Plusmin 23
69 #define ROFFTok_Infty 24
70 #define ROFFTok_Bar 25
71 #define ROFFTok_Nan 26
72 #define ROFFTok_Quote 27
73 #define ROFFTok_Sp_0 28
74 #define ROFFTok_Slash 29
75 #define ROFFTok_MAX 30
76
77 #define ROFF___ 0
78 #define ROFF_Dd 1
79 #define ROFF_Dt 2
80 #define ROFF_Os 3
81 #define ROFF_Sh 4
82 #define ROFF_Ss 5
83 #define ROFF_Pp 6
84 #define ROFF_D1 7
85 #define ROFF_Dl 8
86 #define ROFF_Bd 9
87 #define ROFF_Ed 10
88 #define ROFF_Bl 11
89 #define ROFF_El 12
90 #define ROFF_It 13
91 #define ROFF_Ad 14
92 #define ROFF_An 15
93 #define ROFF_Ar 16
94 #define ROFF_Cd 17
95 #define ROFF_Cm 18
96 #define ROFF_Dv 19
97 #define ROFF_Er 20
98 #define ROFF_Ev 21
99 #define ROFF_Ex 22
100 #define ROFF_Fa 23
101 #define ROFF_Fd 24
102 #define ROFF_Fl 25
103 #define ROFF_Fn 26
104 #define ROFF_Ft 27
105 #define ROFF_Ic 28
106 #define ROFF_In 29
107 #define ROFF_Li 30
108 #define ROFF_Nd 31
109 #define ROFF_Nm 32
110 #define ROFF_Op 33
111 #define ROFF_Ot 34
112 #define ROFF_Pa 35
113 #define ROFF_Rv 36
114 #define ROFF_St 37
115 #define ROFF_Va 38
116 #define ROFF_Vt 39
117 #define ROFF_Xr 40
118 #define ROFF__A 41
119 #define ROFF__B 42
120 #define ROFF__D 43
121 #define ROFF__I 44
122 #define ROFF__J 45
123 #define ROFF__N 46
124 #define ROFF__O 47
125 #define ROFF__P 48
126 #define ROFF__R 49
127 #define ROFF__T 50
128 #define ROFF__V 51
129 #define ROFF_Ac 52
130 #define ROFF_Ao 53
131 #define ROFF_Aq 54
132 #define ROFF_At 55
133 #define ROFF_Bc 56
134 #define ROFF_Bf 57
135 #define ROFF_Bo 58
136 #define ROFF_Bq 59
137 #define ROFF_Bsx 60
138 #define ROFF_Bx 61
139 #define ROFF_Db 62
140 #define ROFF_Dc 63
141 #define ROFF_Do 64
142 #define ROFF_Dq 65
143 #define ROFF_Ec 66
144 #define ROFF_Ef 67
145 #define ROFF_Em 68
146 #define ROFF_Eo 69
147 #define ROFF_Fx 70
148 #define ROFF_Ms 71
149 #define ROFF_No 72
150 #define ROFF_Ns 73
151 #define ROFF_Nx 74
152 #define ROFF_Ox 75
153 #define ROFF_Pc 76
154 #define ROFF_Pf 77
155 #define ROFF_Po 78
156 #define ROFF_Pq 79
157 #define ROFF_Qc 80
158 #define ROFF_Ql 81
159 #define ROFF_Qo 82
160 #define ROFF_Qq 83
161 #define ROFF_Re 84
162 #define ROFF_Rs 85
163 #define ROFF_Sc 86
164 #define ROFF_So 87
165 #define ROFF_Sq 88
166 #define ROFF_Sm 89
167 #define ROFF_Sx 90
168 #define ROFF_Sy 91
169 #define ROFF_Tn 92
170 #define ROFF_Ux 93
171 #define ROFF_Xc 94
172 #define ROFF_Xo 95
173 #define ROFF_Fo 96
174 #define ROFF_Fc 97
175 #define ROFF_Oo 98
176 #define ROFF_Oc 99
177 #define ROFF_Bk 100
178 #define ROFF_Ek 101
179 #define ROFF_Bt 102
180 #define ROFF_Hf 103
181 #define ROFF_Fr 104
182 #define ROFF_Ud 105
183 #define ROFF_MAX 106
184
185 #define ROFF_Split 0
186 #define ROFF_Nosplit 1
187 #define ROFF_Ragged 2
188 #define ROFF_Unfilled 3
189 #define ROFF_Literal 4
190 #define ROFF_File 5
191 #define ROFF_Offset 6
192 #define ROFF_Bullet 7
193 #define ROFF_Dash 8
194 #define ROFF_Hyphen 9
195 #define ROFF_Item 10
196 #define ROFF_Enum 11
197 #define ROFF_Tag 12
198 #define ROFF_Diag 13
199 #define ROFF_Hang 14
200 #define ROFF_Ohang 15
201 #define ROFF_Inset 16
202 #define ROFF_Column 17
203 #define ROFF_Width 18
204 #define ROFF_Compact 19
205 #define ROFF_Std 20
206 #define ROFF_p1003_1_88 21
207 #define ROFF_p1003_1_90 22
208 #define ROFF_p1003_1_96 23
209 #define ROFF_p1003_1_2001 24
210 #define ROFF_p1003_1_2004 25
211 #define ROFF_p1003_1 26
212 #define ROFF_p1003_1b 27
213 #define ROFF_p1003_1b_93 28
214 #define ROFF_p1003_1c_95 29
215 #define ROFF_p1003_1g_2000 30
216 #define ROFF_p1003_2_92 31
217 #define ROFF_p1387_2_95 32
218 #define ROFF_p1003_2 33
219 #define ROFF_p1387_2 34
220 #define ROFF_isoC_90 35
221 #define ROFF_isoC_amd1 36
222 #define ROFF_isoC_tcor1 37
223 #define ROFF_isoC_tcor2 38
224 #define ROFF_isoC_99 39
225 #define ROFF_ansiC 40
226 #define ROFF_ansiC_89 41
227 #define ROFF_ansiC_99 42
228 #define ROFF_ieee754 43
229 #define ROFF_iso8802_3 44
230 #define ROFF_xpg3 45
231 #define ROFF_xpg4 46
232 #define ROFF_xpg4_2 47
233 #define ROFF_xpg4_3 48
234 #define ROFF_xbd5 49
235 #define ROFF_xcu5 50
236 #define ROFF_xsh5 51
237 #define ROFF_xns5 52
238 #define ROFF_xns5_2d2_0 53
239 #define ROFF_xcurses4_2 54
240 #define ROFF_susv2 55
241 #define ROFF_susv3 56
242 #define ROFF_svid4 57
243 #define ROFF_Filled 58
244 #define ROFF_Words 59
245 #define ROFF_ARGMAX 60
246
247 #define ROFF_MAXLINEARG 32
248
249 extern const char *const *toknames;
250 extern const char *const *tokargnames;
251
252 enum roffmsg {
253 ROFF_WARN,
254 ROFF_ERROR
255 };
256
257 enum roffmsec {
258 ROFF_MSEC_1,
259 ROFF_MSEC_2,
260 ROFF_MSEC_3,
261 ROFF_MSEC_3p,
262 ROFF_MSEC_4,
263 ROFF_MSEC_5,
264 ROFF_MSEC_6,
265 ROFF_MSEC_7,
266 ROFF_MSEC_8,
267 ROFF_MSEC_9,
268 ROFF_MSEC_UNASS,
269 ROFF_MSEC_DRAFT,
270 ROFF_MSEC_PAPER,
271 ROFF_MSEC_MAX
272 };
273
274 enum roffatt {
275 ROFF_ATT_V1,
276 ROFF_ATT_V2,
277 ROFF_ATT_V3,
278 ROFF_ATT_V6,
279 ROFF_ATT_V7,
280 ROFF_ATT_32V,
281 ROFF_ATT_V_1,
282 ROFF_ATT_V_4,
283 ROFF_ATT_MAX
284 };
285
286 #define ROFFSec_NMASK (0x07)
287
288 #define ROFFSec_NAME (1 << 0)
289 #define ROFFSec_SYNOP (1 << 1)
290 #define ROFFSec_DESC (1 << 2)
291 #define ROFFSec_RETVAL (1 << 3)
292 #define ROFFSec_ENV (1 << 4)
293 #define ROFFSec_FILES (1 << 5)
294 #define ROFFSec_EX (1 << 6)
295 #define ROFFSec_DIAG (1 << 7)
296 #define ROFFSec_ERRS (1 << 8)
297 #define ROFFSec_SEEALSO (1 << 9)
298 #define ROFFSec_STAND (1 << 10)
299 #define ROFFSec_HIST (1 << 11)
300 #define ROFFSec_AUTH (1 << 12)
301 #define ROFFSec_CAVEATS (1 << 13)
302 #define ROFFSec_BUGS (1 << 14)
303 #define ROFFSec_OTHER (1 << 15)
304
305 struct roffcb {
306 int (*roffmsg)(void *, enum roffmsg,
307 const char *, const char *, const char *);
308 int (*roffhead)(void *, const struct tm *, const char *,
309 const char *, enum roffmsec, const char *);
310 int (*rofftail)(void *);
311 int (*roffdata)(void *, int, const char *, const char *);
312 int (*roffin)(void *, int, int *, const char **);
313 int (*roffout)(void *, int);
314 int (*roffblkin)(void *, int, int *, const char **);
315 int (*roffblkout)(void *, int);
316 int (*roffblkheadin)(void *, int, int *, const char **);
317 int (*roffblkheadout)(void *, int);
318 int (*roffblkbodyin)(void *, int, int *, const char **);
319 int (*roffblkbodyout)(void *, int);
320 int (*roffspecial)(void *, int, const char *,
321 const int *, const char **, const char **);
322 };
323
324 struct rofftree;
325
326 __BEGIN_DECLS
327
328 typedef void (*(*md_init)(const struct md_args *,
329 struct md_mbuf *, const struct md_rbuf *));
330 typedef int (*md_line)(void *, char *);
331 typedef int (*md_exit)(void *, int);
332
333 void *md_init_html(const struct md_args *,
334 struct md_mbuf *, const struct md_rbuf *);
335 int md_line_html(void *, char *);
336 int md_exit_html(void *, int);
337
338 void *md_init_xml(const struct md_args *,
339 struct md_mbuf *, const struct md_rbuf *);
340 int md_line_xml(void *, char *);
341 int md_exit_xml(void *, int);
342
343 int md_buf_puts(struct md_mbuf *, const char *, size_t);
344 int md_buf_putchar(struct md_mbuf *, char);
345 int md_buf_putstring(struct md_mbuf *, const char *);
346
347 struct rofftree *roff_alloc(const struct roffcb *, void *);
348 int roff_engine(struct rofftree *, char *);
349 int roff_free(struct rofftree *, int);
350
351 int rofftok_scan(const char *, int *);
352
353 char *roff_literal(int, const int *,
354 const char **, const char **);
355 char *roff_fmtstring(int);
356 char *roff_msecname(enum roffmsec);
357 enum roffmsec roff_msec(const char *);
358 int roff_sec(const char **);
359 enum roffatt roff_att(const char *);
360
361 __END_DECLS
362
363 #endif /*!PRIVATE_H*/