libmdoc.h revision 1.1.1.17.12.1 1 1.1.1.17.12.1 christos /* Id: libmdoc.h,v 1.117 2018/12/31 04:55:46 schwarze Exp */
2 1.1 joerg /*
3 1.1.1.12 joerg * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps (at) bsd.lv>
4 1.1.1.17.12.1 christos * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze (at) openbsd.org>
5 1.1 joerg *
6 1.1 joerg * Permission to use, copy, modify, and distribute this software for any
7 1.1 joerg * purpose with or without fee is hereby granted, provided that the above
8 1.1 joerg * copyright notice and this permission notice appear in all copies.
9 1.1 joerg *
10 1.1.1.16 christos * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11 1.1 joerg * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 1.1.1.16 christos * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13 1.1 joerg * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 1.1 joerg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 1.1 joerg * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 1.1 joerg * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 1.1 joerg */
18 1.1 joerg
19 1.1.1.17.12.1 christos struct roff_node;
20 1.1.1.17.12.1 christos struct roff_man;
21 1.1.1.17.12.1 christos struct mdoc_arg;
22 1.1.1.17.12.1 christos
23 1.1.1.16 christos #define MACRO_PROT_ARGS struct roff_man *mdoc, \
24 1.1.1.17.12.1 christos enum roff_tok tok, \
25 1.1.1.8 joerg int line, \
26 1.1.1.8 joerg int ppos, \
27 1.1.1.8 joerg int *pos, \
28 1.1.1.8 joerg char *buf
29 1.1 joerg
30 1.1 joerg struct mdoc_macro {
31 1.1.1.15 christos void (*fp)(MACRO_PROT_ARGS);
32 1.1 joerg int flags;
33 1.1 joerg #define MDOC_CALLABLE (1 << 0)
34 1.1 joerg #define MDOC_PARSED (1 << 1)
35 1.1 joerg #define MDOC_EXPLICIT (1 << 2)
36 1.1 joerg #define MDOC_PROLOGUE (1 << 3)
37 1.1.1.14 joerg #define MDOC_IGNDELIM (1 << 4)
38 1.1.1.14 joerg #define MDOC_JOIN (1 << 5)
39 1.1 joerg };
40 1.1 joerg
41 1.1.1.5 joerg enum margserr {
42 1.1.1.5 joerg ARGS_ERROR,
43 1.1.1.12 joerg ARGS_EOLN, /* end-of-line */
44 1.1.1.12 joerg ARGS_WORD, /* normal word */
45 1.1.1.17.12.1 christos ARGS_ALLOC, /* normal word from roff_getarg() */
46 1.1.1.12 joerg ARGS_PUNCT, /* series of punctuation */
47 1.1.1.16 christos ARGS_PHRASE /* Bl -column phrase */
48 1.1.1.5 joerg };
49 1.1.1.5 joerg
50 1.1.1.11 joerg /*
51 1.1.1.11 joerg * A punctuation delimiter is opening, closing, or "middle mark"
52 1.1.1.11 joerg * punctuation. These govern spacing.
53 1.1.1.11 joerg * Opening punctuation (e.g., the opening parenthesis) suppresses the
54 1.1.1.11 joerg * following space; closing punctuation (e.g., the closing parenthesis)
55 1.1.1.11 joerg * suppresses the leading space; middle punctuation (e.g., the vertical
56 1.1.1.11 joerg * bar) can do either. The middle punctuation delimiter bends the rules
57 1.1.1.11 joerg * depending on usage.
58 1.1.1.11 joerg */
59 1.1.1.5 joerg enum mdelim {
60 1.1.1.5 joerg DELIM_NONE = 0,
61 1.1.1.5 joerg DELIM_OPEN,
62 1.1.1.5 joerg DELIM_MIDDLE,
63 1.1.1.11 joerg DELIM_CLOSE,
64 1.1.1.11 joerg DELIM_MAX
65 1.1.1.5 joerg };
66 1.1.1.5 joerg
67 1.1.1.17.12.1 christos const struct mdoc_macro *mdoc_macro(enum roff_tok);
68 1.1 joerg
69 1.1.1.16 christos void mdoc_elem_alloc(struct roff_man *, int, int,
70 1.1.1.17.12.1 christos enum roff_tok, struct mdoc_arg *);
71 1.1.1.16 christos struct roff_node *mdoc_block_alloc(struct roff_man *, int, int,
72 1.1.1.17.12.1 christos enum roff_tok, struct mdoc_arg *);
73 1.1.1.17.12.1 christos void mdoc_tail_alloc(struct roff_man *, int, int,
74 1.1.1.17.12.1 christos enum roff_tok);
75 1.1.1.17.12.1 christos struct roff_node *mdoc_endbody_alloc(struct roff_man *, int, int,
76 1.1.1.17.12.1 christos enum roff_tok, struct roff_node *);
77 1.1.1.16 christos void mdoc_state(struct roff_man *, struct roff_node *);
78 1.1.1.16 christos const char *mdoc_a2arch(const char *);
79 1.1 joerg const char *mdoc_a2att(const char *);
80 1.1 joerg const char *mdoc_a2lib(const char *);
81 1.1.1.16 christos enum roff_sec mdoc_a2sec(const char *);
82 1.1 joerg const char *mdoc_a2st(const char *);
83 1.1.1.17.12.1 christos void mdoc_argv(struct roff_man *, int, enum roff_tok,
84 1.1 joerg struct mdoc_arg **, int *, char *);
85 1.1.1.16 christos enum margserr mdoc_args(struct roff_man *, int,
86 1.1.1.17.12.1 christos int *, char *, enum roff_tok, char **);
87 1.1.1.11 joerg enum mdelim mdoc_isdelim(const char *);
88