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