1 .\" $Id: mandoc_headers.3,v 1.35 2022/04/14 16:43:44 schwarze Exp $
3 .\" Copyright (c) 2014-2022 Ingo Schwarze <schwarze@openbsd.org>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .Dd $Mdocdate: April 14 2022 $
22 .Nd ordering of mandoc include files
24 To support a cleaner coding style, the mandoc header files do not
25 contain any include directives and do not guard against multiple
27 The application developer has to make sure that the headers are
28 included in the order shown in this manual page,
29 and that no header is included more than once.
31 The headers and functions form three major groups:
32 .Sx Parser interface ,
33 .Sx Parser internals ,
35 .Sx Formatter interface .
37 Various rules are given below prohibiting the inclusion of certain
38 combinations of headers into the same file.
39 The intention is to keep the following functional components
40 separate from each other:
42 .Bl -dash -offset indent -compact
68 Note that mere usage of an opaque struct type does
70 require inclusion of the header where that type is defined.
72 Each of the following headers can be included without including
73 any other mandoc header.
74 These headers should be included before any other mandoc headers.
76 .It Qq Pa mandoc_aux.h
77 Memory allocation utility functions; can be used everywhere.
84 Provides the functions documented in
87 When this header is included, the same file must not include
91 automatically includes
93 if and only if the preprocessor symbol
96 .It Qq Pa mandoc_dbg.h
97 Debugging utility functions and
98 debugging wrappers around memory allocation functions.
105 Provides the functions documented in
106 .Xr mandoc_dbg_init 3 .
108 This header must not be included unless the preprocessor symbol
111 When this header is included, the same file must not include
112 .Qq Pa mandoc_aux.h .
113 .It Qq Pa mandoc_ohash.h
114 Hashing utility functions; can be used everywhere.
128 .Fn mandoc_ohash_init .
130 Error handling, escape sequence, and character utilities;
131 can be used everywhere.
143 .Vt enum mandoc_esc ,
145 .Vt enum mandoclevel ,
147 .Xr mandoc_escape 3 ,
148 the functions described in
154 Common data types for all syntax trees and related functions;
155 can be used everywhere.
159 .Vt enum mdoc_endbody ,
160 .Vt enum roff_macroset ,
164 .Vt struct roff_man ,
165 .Vt struct roff_meta ,
166 .Vt struct roff_node ,
172 Uses pointers to the types
175 .Qq Pa mandoc_ohash.h ,
188 as opaque struct members.
190 Data structures for the
192 parse tree; can be used everywhere.
201 .Vt enum mandoc_esc .
207 .Vt struct tbl_opts ,
208 .Vt struct tbl_cell ,
212 .Vt struct tbl_span .
214 Data structures for the
216 parse tree; can be used everywhere.
229 .It Qq Pa mandoc_parse.h
230 Top level parser interface, for use in the main program
231 and in the main parser, but not in formatters.
248 for function prototypes.
253 as an opaque type for function prototypes.
254 .It Qq Pa mandoc_xr.h
255 Cross reference validation; intended for use in the main program
256 and in parsers, but not in formatters.
261 .Fn mandoc_xr_reset ,
267 Internal interfaces to tag syntax tree nodes,
268 for use by validation modules only.
275 Provides the functions
289 as an opaque type for function prototypes.
292 The following two require
294 but no other mandoc headers.
295 Afterwards, any other mandoc headers can be included as needed.
309 .Vt struct mdoc_argv ,
310 .Vt struct mdoc_arg ,
316 .Vt union mdoc_data ,
330 as opaque types for function prototypes.
332 When this header is included, the same file should not include
333 internals of different parsers.
335 Provides the functions
344 as an opaque type for function prototypes.
346 When this header is included, the same file should not include
347 internals of different parsers.
350 Most of the following headers require inclusion of a parser interface header
351 before they can be included.
352 All parser interface headers should precede all parser internal headers.
353 When any parser internal headers are included, the same file should
354 not include any formatter headers.
356 .It Qq Pa libmandoc.h
368 utility functions needed by multiple parsers,
369 and the top-level functions to call the parsers.
375 for function prototypes.
380 as an opaque type for function prototypes.
382 Parser internals shared by multiple parsers.
383 Can be used in all parsers, but not in main programs or formatters.
394 .Vt struct roff_man ,
397 to handle roff nodes,
403 and the two special functions
407 because the latter two are needed by
413 .Qq Pa mandoc_ohash.h ,
426 as opaque types for function prototypes.
438 .Vt struct mdoc_macro ,
439 and many functions internal to the
454 as opaque types for function prototypes.
456 When this header is included, the same file should not include
457 interfaces of different parsers.
466 and some functions internal to the
478 as opaque types for function prototypes.
480 When this header is included, the same file should not include
481 interfaces of different parsers.
482 .It Qq Pa eqn_parse.h
483 External interface of the
485 parser, for use in the
512 as an opaque type for function prototypes.
521 as opaque struct members.
523 When this header is included, the same file should not include
524 internals of different parsers.
525 .It Qq Pa tbl_parse.h
526 External interface of the
528 parser, for use in the
534 Provides the functions documented in
545 as opaque types for function prototypes.
547 When this header is included, the same file should not include
548 internals of different parsers.
550 Internal interfaces of the
552 parser, for use inside the
559 .Vt struct tbl_opts .
563 .Vt struct tbl_node ,
572 When this header is included, the same file should not include
573 interfaces of different parsers.
575 .Ss Formatter interface
576 These headers should be included after any parser interface headers.
577 No parser internal headers should be included by the same file.
598 as an opaque type for function prototypes.
600 When this header is included, the same file should not include
618 .Vt struct termp_tbl ,
621 and many terminal formatting functions.
639 as opaque types for function prototypes.
641 When this header is included, the same file should not include
655 Provides an interface to generate
659 functionality mentioned in
666 as an opaque type for function prototypes.
668 When this header is included, the same file should not include
679 .Vt enum mandoc_esc ,
696 .Vt struct htmlpair ,
699 and many HTML formatting functions.
711 as opaque types for function prototypes.
713 When this header is included, the same file should not include
719 Provides the top level steering functions for all formatters.
725 as an opaque type for function prototypes.
734 .Vt struct manpaths ,
735 .Vt struct manoutput ,
742 .It Qq Pa mansearch.h
755 .Vt struct mansearch ,
765 as an opaque type for function prototypes.
767 When this header is included, the same file should not include