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