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