Annotation of mandoc/libmdoc.h, Revision 1.100
1.100 ! schwarze 1: /* $Id: libmdoc.h,v 1.99 2015/04/02 23:48:19 schwarze Exp $ */
1.1 kristaps 2: /*
1.77 schwarze 3: * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.98 schwarze 4: * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
1.1 kristaps 5: *
6: * Permission to use, copy, modify, and distribute this software for any
1.6 kristaps 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.98 schwarze 10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
1.6 kristaps 11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1.98 schwarze 12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
1.6 kristaps 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.100 ! schwarze 19: #define MACRO_PROT_ARGS struct roff_man *mdoc, \
1.98 schwarze 20: int tok, \
1.55 kristaps 21: int line, \
22: int ppos, \
23: int *pos, \
24: char *buf
1.1 kristaps 25:
26: struct mdoc_macro {
1.92 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.82 schwarze 33: #define MDOC_IGNDELIM (1 << 4)
34: #define MDOC_JOIN (1 << 5)
1.1 kristaps 35: };
36:
1.36 kristaps 37: enum margserr {
1.35 kristaps 38: ARGS_ERROR,
1.73 kristaps 39: ARGS_EOLN, /* end-of-line */
40: ARGS_WORD, /* normal word */
41: ARGS_PUNCT, /* series of punctuation */
42: ARGS_QWORD, /* quoted word */
43: ARGS_PHRASE, /* Ta'd phrase (-column) */
44: ARGS_PPHRASE, /* tabbed phrase (-column) */
45: ARGS_PEND /* last phrase (-column) */
1.35 kristaps 46: };
47:
1.70 kristaps 48: /*
49: * A punctuation delimiter is opening, closing, or "middle mark"
50: * punctuation. These govern spacing.
51: * Opening punctuation (e.g., the opening parenthesis) suppresses the
52: * following space; closing punctuation (e.g., the closing parenthesis)
53: * suppresses the leading space; middle punctuation (e.g., the vertical
54: * bar) can do either. The middle punctuation delimiter bends the rules
55: * depending on usage.
56: */
57: enum mdelim {
58: DELIM_NONE = 0,
59: DELIM_OPEN,
60: DELIM_MIDDLE,
61: DELIM_CLOSE,
62: DELIM_MAX
63: };
64:
1.1 kristaps 65: extern const struct mdoc_macro *const mdoc_macros;
66:
67: __BEGIN_DECLS
68:
1.92 schwarze 69: void mdoc_macro(MACRO_PROT_ARGS);
1.100 ! schwarze 70: void mdoc_word_alloc(struct roff_man *, int, int, const char *);
! 71: void mdoc_word_append(struct roff_man *, const char *);
! 72: void mdoc_elem_alloc(struct roff_man *, int, int,
1.98 schwarze 73: int, struct mdoc_arg *);
1.100 ! schwarze 74: struct roff_node *mdoc_block_alloc(struct roff_man *, int, int,
1.98 schwarze 75: int, struct mdoc_arg *);
1.100 ! schwarze 76: struct roff_node *mdoc_head_alloc(struct roff_man *, int, int, int);
! 77: void mdoc_tail_alloc(struct roff_man *, int, int, int);
! 78: struct roff_node *mdoc_body_alloc(struct roff_man *, int, int, int);
! 79: struct roff_node *mdoc_endbody_alloc(struct roff_man *, int, int, int,
1.98 schwarze 80: struct roff_node *, enum mdoc_endbody);
1.100 ! schwarze 81: void mdoc_node_delete(struct roff_man *, struct roff_node *);
! 82: void mdoc_node_relink(struct roff_man *, struct roff_node *);
1.27 kristaps 83: void mdoc_hash_init(void);
1.98 schwarze 84: int mdoc_hash_find(const char *);
1.16 kristaps 85: const char *mdoc_a2att(const char *);
1.18 kristaps 86: const char *mdoc_a2lib(const char *);
1.17 kristaps 87: const char *mdoc_a2st(const char *);
1.1 kristaps 88: const char *mdoc_a2arch(const char *);
1.100 ! schwarze 89: void mdoc_valid_pre(struct roff_man *, struct roff_node *);
! 90: void mdoc_valid_post(struct roff_man *);
! 91: void mdoc_argv(struct roff_man *, int, int,
1.1 kristaps 92: struct mdoc_arg **, int *, char *);
93: void mdoc_argv_free(struct mdoc_arg *);
1.100 ! schwarze 94: enum margserr mdoc_args(struct roff_man *, int,
1.98 schwarze 95: int *, char *, int, char **);
1.100 ! schwarze 96: void mdoc_macroend(struct roff_man *);
1.70 kristaps 97: enum mdelim mdoc_isdelim(const char *);
1.1 kristaps 98:
99: __END_DECLS
CVSweb