]>
git.cameronkatri.com Git - mandoc.git/blob - libmdoc.h
1 /* $Id: libmdoc.h,v 1.86 2014/07/09 11:31:43 schwarze Exp $ */
3 * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2013 Ingo Schwarze <schwarze@openbsd.org>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
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.
22 MDOC_NEXT_SIBLING
= 0,
27 struct mparse
*parse
; /* parse pointer */
28 const char *defos
; /* default argument for .Os */
29 int quick
; /* abort parse early */
30 int flags
; /* parse flags */
31 #define MDOC_HALT (1 << 0) /* error in parse: halt */
32 #define MDOC_LITERAL (1 << 1) /* in a literal scope */
33 #define MDOC_PBODY (1 << 2) /* in the document body */
34 #define MDOC_NEWLINE (1 << 3) /* first macro/text in a line */
35 #define MDOC_PHRASELIT (1 << 4) /* literal within a partila phrase */
36 #define MDOC_PPHRASE (1 << 5) /* within a partial phrase */
37 #define MDOC_FREECOL (1 << 6) /* `It' invocation should close */
38 #define MDOC_SYNOPSIS (1 << 7) /* SYNOPSIS-style formatting */
39 #define MDOC_KEEP (1 << 8) /* in a word keep */
40 #define MDOC_SMOFF (1 << 9) /* spacing is off */
41 enum mdoc_next next
; /* where to put the next node */
42 struct mdoc_node
*last
; /* the last node parsed */
43 struct mdoc_node
*first
; /* the first node parsed */
44 struct mdoc_node
*last_es
; /* the most recent Es node */
45 struct mdoc_meta meta
; /* document meta-data */
46 enum mdoc_sec lastnamed
;
47 enum mdoc_sec lastsec
;
51 #define MACRO_PROT_ARGS struct mdoc *mdoc, \
59 int (*fp
)(MACRO_PROT_ARGS
);
61 #define MDOC_CALLABLE (1 << 0)
62 #define MDOC_PARSED (1 << 1)
63 #define MDOC_EXPLICIT (1 << 2)
64 #define MDOC_PROLOGUE (1 << 3)
65 #define MDOC_IGNDELIM (1 << 4)
66 #define MDOC_JOIN (1 << 5)
71 ARGS_EOLN
, /* end-of-line */
72 ARGS_WORD
, /* normal word */
73 ARGS_PUNCT
, /* series of punctuation */
74 ARGS_QWORD
, /* quoted word */
75 ARGS_PHRASE
, /* Ta'd phrase (-column) */
76 ARGS_PPHRASE
, /* tabbed phrase (-column) */
77 ARGS_PEND
/* last phrase (-column) */
82 ARGV_EOLN
, /* end of line */
83 ARGV_ARG
, /* valid argument */
84 ARGV_WORD
/* normal word (or bad argument---same thing) */
88 * A punctuation delimiter is opening, closing, or "middle mark"
89 * punctuation. These govern spacing.
90 * Opening punctuation (e.g., the opening parenthesis) suppresses the
91 * following space; closing punctuation (e.g., the closing parenthesis)
92 * suppresses the leading space; middle punctuation (e.g., the vertical
93 * bar) can do either. The middle punctuation delimiter bends the rules
104 extern const struct mdoc_macro
*const mdoc_macros
;
108 #define mdoc_pmsg(mdoc, l, p, t) \
109 mandoc_msg((t), (mdoc)->parse, (l), (p), NULL)
110 #define mdoc_nmsg(mdoc, n, t) \
111 mandoc_msg((t), (mdoc)->parse, (n)->line, (n)->pos, NULL)
112 int mdoc_macro(MACRO_PROT_ARGS
);
113 int mdoc_word_alloc(struct mdoc
*,
114 int, int, const char *);
115 void mdoc_word_append(struct mdoc
*, const char *);
116 int mdoc_elem_alloc(struct mdoc
*, int, int,
117 enum mdoct
, struct mdoc_arg
*);
118 int mdoc_block_alloc(struct mdoc
*, int, int,
119 enum mdoct
, struct mdoc_arg
*);
120 int mdoc_head_alloc(struct mdoc
*, int, int, enum mdoct
);
121 int mdoc_tail_alloc(struct mdoc
*, int, int, enum mdoct
);
122 int mdoc_body_alloc(struct mdoc
*, int, int, enum mdoct
);
123 int mdoc_endbody_alloc(struct mdoc
*, int, int, enum mdoct
,
124 struct mdoc_node
*, enum mdoc_endbody
);
125 void mdoc_node_delete(struct mdoc
*, struct mdoc_node
*);
126 int mdoc_node_relink(struct mdoc
*, struct mdoc_node
*);
127 void mdoc_hash_init(void);
128 enum mdoct
mdoc_hash_find(const char *);
129 const char *mdoc_a2att(const char *);
130 const char *mdoc_a2lib(const char *);
131 const char *mdoc_a2st(const char *);
132 const char *mdoc_a2arch(const char *);
133 const char *mdoc_a2vol(const char *);
134 int mdoc_valid_pre(struct mdoc
*, struct mdoc_node
*);
135 int mdoc_valid_post(struct mdoc
*);
136 enum margverr
mdoc_argv(struct mdoc
*, int, enum mdoct
,
137 struct mdoc_arg
**, int *, char *);
138 void mdoc_argv_free(struct mdoc_arg
*);
139 enum margserr
mdoc_args(struct mdoc
*, int,
140 int *, char *, enum mdoct
, char **);
141 enum margserr
mdoc_zargs(struct mdoc
*, int,
142 int *, char *, char **);
143 int mdoc_macroend(struct mdoc
*);
144 enum mdelim
mdoc_isdelim(const char *);
148 #endif /*!LIBMDOC_H*/