]> git.cameronkatri.com Git - mandoc.git/blob - private.h
Considerable fixes.
[mandoc.git] / private.h
1 /* $Id: private.h,v 1.9 2008/11/26 21:42: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 /* 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_MAX 100
141
142 #define ROFF_Split 0
143 #define ROFF_Nosplit 1
144 #define ROFF_Ragged 2
145 #define ROFF_Unfilled 3
146 #define ROFF_Literal 4
147 #define ROFF_File 5
148 #define ROFF_Offset 6
149 #define ROFF_Bullet 7
150 #define ROFF_Dash 8
151 #define ROFF_Hyphen 9
152 #define ROFF_Item 10
153 #define ROFF_Enum 11
154 #define ROFF_Tag 12
155 #define ROFF_Diag 13
156 #define ROFF_Hang 14
157 #define ROFF_Ohang 15
158 #define ROFF_Inset 16
159 #define ROFF_Column 17
160 #define ROFF_Width 18
161 #define ROFF_Compact 19
162 #define ROFF_Std 20
163 #define ROFF_p1003_1_88 21
164 #define ROFF_p1003_1_90 22
165 #define ROFF_p1003_1_96 23
166 #define ROFF_p1003_1_2001 24
167 #define ROFF_p1003_1_2004 25
168 #define ROFF_p1003_1 26
169 #define ROFF_p1003_1b 27
170 #define ROFF_p1003_1b_93 28
171 #define ROFF_p1003_1c_95 29
172 #define ROFF_p1003_1g_2000 30
173 #define ROFF_p1003_2_92 31
174 #define ROFF_p1387_2_95 32
175 #define ROFF_p1003_2 33
176 #define ROFF_p1387_2 34
177 #define ROFF_isoC_90 35
178 #define ROFF_isoC_amd1 36
179 #define ROFF_isoC_tcor1 37
180 #define ROFF_isoC_tcor2 38
181 #define ROFF_isoC_99 39
182 #define ROFF_ansiC 40
183 #define ROFF_ansiC_89 41
184 #define ROFF_ansiC_99 42
185 #define ROFF_ieee754 43
186 #define ROFF_iso8802_3 44
187 #define ROFF_xpg3 45
188 #define ROFF_xpg4 46
189 #define ROFF_xpg4_2 47
190 #define ROFF_xpg4_3 48
191 #define ROFF_xbd5 49
192 #define ROFF_xcu5 50
193 #define ROFF_xsh5 51
194 #define ROFF_xns5 52
195 #define ROFF_xns5_2d2_0 53
196 #define ROFF_xcurses4_2 54
197 #define ROFF_susv2 55
198 #define ROFF_susv3 56
199 #define ROFF_svid4 57
200 #define ROFF_ARGMAX 58
201
202 extern const char *const *toknames;
203 extern const char *const *tokargnames;
204
205 /* FIXME: have a md_roff with all necessary parameters. */
206
207 /* FIXME: have roffbegin and roffend for doc head/foot. */
208
209 struct roffcb {
210 int (*roffhead)(void);
211 int (*rofftail)(void);
212 int (*roffin)(int, int *, char **);
213 int (*roffout)(int);
214 int (*roffblkin)(int);
215 int (*roffblkout)(int);
216 };
217
218 __BEGIN_DECLS
219
220 typedef void (*(*md_init)(const struct md_args *,
221 struct md_mbuf *, const struct md_rbuf *));
222 typedef int (*md_line)(void *, char *, size_t);
223 typedef int (*md_exit)(void *, int);
224
225 void *md_init_html4_strict(const struct md_args *,
226 struct md_mbuf *, const struct md_rbuf *);
227 int md_line_html4_strict(void *, char *, size_t);
228 int md_exit_html4_strict(void *, int);
229
230 void *md_init_dummy(const struct md_args *,
231 struct md_mbuf *, const struct md_rbuf *);
232 int md_line_dummy(void *, char *, size_t);
233 int md_exit_dummy(void *, int);
234
235 int md_buf_puts(struct md_mbuf *, const char *, size_t);
236 int md_buf_putchar(struct md_mbuf *, char);
237 int md_buf_putstring(struct md_mbuf *, const char *);
238
239 struct rofftree;
240
241 struct rofftree *roff_alloc(const struct md_args *,
242 struct md_mbuf *, const struct md_rbuf *,
243 const struct roffcb *);
244 int roff_engine(struct rofftree *, char *, size_t);
245 int roff_free(struct rofftree *, int);
246
247 __END_DECLS
248
249 #endif /*!PRIVATE_H*/