]>
git.cameronkatri.com Git - mandoc.git/blob - mdoc.h
1 /* $Id: mdoc.h,v 1.31 2009/02/22 14:31:08 kristaps Exp $ */
3 * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
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
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.
22 /* What follows is a list of ALL possible macros. */
132 /* What follows is a list of ALL possible macro arguments. */
135 #define MDOC_Nosplit 1
136 #define MDOC_Ragged 2
137 #define MDOC_Unfilled 3
138 #define MDOC_Literal 4
140 #define MDOC_Offset 6
141 #define MDOC_Bullet 7
143 #define MDOC_Hyphen 9
149 #define MDOC_Ohang 15
150 #define MDOC_Inset 16
151 #define MDOC_Column 17
152 #define MDOC_Width 18
153 #define MDOC_Compact 19
155 #define MDOC_p1003_1_88 21
156 #define MDOC_p1003_1_90 22
157 #define MDOC_p1003_1_96 23
158 #define MDOC_p1003_1_2001 24
159 #define MDOC_p1003_1_2004 25
160 #define MDOC_p1003_1 26
161 #define MDOC_p1003_1b 27
162 #define MDOC_p1003_1b_93 28
163 #define MDOC_p1003_1c_95 29
164 #define MDOC_p1003_1g_2000 30
165 #define MDOC_p1003_2_92 31
166 #define MDOC_p1387_2_95 32
167 #define MDOC_p1003_2 33
168 #define MDOC_p1387_2 34
169 #define MDOC_isoC_90 35
170 #define MDOC_isoC_amd1 36
171 #define MDOC_isoC_tcor1 37
172 #define MDOC_isoC_tcor2 38
173 #define MDOC_isoC_99 39
174 #define MDOC_ansiC 40
175 #define MDOC_ansiC_89 41
176 #define MDOC_ansiC_99 42
177 #define MDOC_ieee754 43
178 #define MDOC_iso8802_3 44
181 #define MDOC_xpg4_2 47
182 #define MDOC_xpg4_3 48
187 #define MDOC_xns5_2d2_0 53
188 #define MDOC_xcurses4_2 54
189 #define MDOC_susv2 55
190 #define MDOC_susv3 56
191 #define MDOC_svid4 57
192 #define MDOC_Filled 58
193 #define MDOC_Words 59
194 #define MDOC_Emphasis 60
195 #define MDOC_Symbolic 61
196 #define MDOC_ARG_MAX 62
198 /* Warnings are either syntax or groff-compatibility. */
204 /* Possible values for the `At' macro. */
221 /* An argument to a macro (multiple values = `It -column'). */
230 /* Type of a syntax node. */
241 /* Manual section. */
264 /* Section (named/unnamed) of `Ss'. */
286 /* Volume of `Dt'. */
300 /* Architecture of `Dt'. */
331 /* Information from prologue. */
342 /* Text-only node. */
347 /* Block (scoped) node. */
350 struct mdoc_arg
*argv
;
351 struct mdoc_node
*head
;
352 struct mdoc_node
*body
;
353 struct mdoc_node
*tail
;
356 /* In-line element node. */
361 struct mdoc_arg
*argv
;
364 /* Typed nodes of an AST node. */
366 struct mdoc_text text
;
367 struct mdoc_elem elem
;
368 struct mdoc_block block
;
373 struct mdoc_node
*parent
;
374 struct mdoc_node
*child
;
375 struct mdoc_node
*next
;
376 struct mdoc_node
*prev
;
381 #define MDOC_VALID (1 << 0)
382 #define MDOC_ACTED (1 << 1)
384 union mdoc_data data
;
388 /* Call-backs for parse messages. */
390 void (*mdoc_msg
)(void *, int, int, const char *);
391 int (*mdoc_err
)(void *, int, int, const char *);
392 int (*mdoc_warn
)(void *, int, int,
393 enum mdoc_warn
, const char *);
396 /* Global table of macro names (`Bd', `Ed', etc.). */
397 extern const char *const *mdoc_macronames
;
399 /* Global table of argument names (`column', `tag', etc.). */
400 extern const char *const *mdoc_argnames
;
406 /* Free memory allocated with mdoc_alloc. */
407 void mdoc_free(struct mdoc
*);
409 /* Allocate a new parser instance. */
410 struct mdoc
*mdoc_alloc(void *data
, const struct mdoc_cb
*);
412 /* Parse a single line in a stream (boolean retval). */
413 int mdoc_parseln(struct mdoc
*, int, char *buf
);
415 /* Get result first node (after mdoc_endparse!). */
416 const struct mdoc_node
*mdoc_node(struct mdoc
*);
418 /* Get result meta-information (after mdoc_endparse!). */
419 const struct mdoc_meta
*mdoc_meta(struct mdoc
*);
421 /* Signal end of parse sequence (boolean retval). */
422 int mdoc_endparse(struct mdoc
*);
424 const char *mdoc_arch2a(enum mdoc_arch
);
426 const char *mdoc_vol2a(enum mdoc_vol
);
428 const char *mdoc_msec2a(enum mdoc_msec
);
430 int mdoc_isdelim(const char *);