]> git.cameronkatri.com Git - mandoc.git/blob - mandoc.h
sync to OpenBSD:
[mandoc.git] / mandoc.h
1 /* $Id: mandoc.h,v 1.19 2010/09/26 20:22:28 schwarze Exp $ */
2 /*
3 * Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
4 *
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.
8 *
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.
16 */
17 #ifndef MANDOC_H
18 #define MANDOC_H
19
20 /*
21 * This contains declarations that are available system-wide.
22 */
23
24 #define ASCII_NBRSP 31 /* non-breaking space */
25 #define ASCII_HYPH 30 /* breakable hyphen */
26
27 __BEGIN_DECLS
28
29 enum mandoclevel {
30 MANDOCLEVEL_OK = 0,
31 MANDOCLEVEL_RESERVED,
32 MANDOCLEVEL_WARNING,
33 MANDOCLEVEL_ERROR,
34 MANDOCLEVEL_FATAL,
35 MANDOCLEVEL_BADARG,
36 MANDOCLEVEL_SYSERR,
37 MANDOCLEVEL_MAX
38 };
39
40 enum mandocerr {
41 MANDOCERR_OK,
42
43 MANDOCERR_WARNING, /* ===== end of warnings ===== */
44
45 MANDOCERR_UPPERCASE, /* text should be uppercase */
46 MANDOCERR_SECOOO, /* sections out of conventional order */
47 MANDOCERR_SECREP, /* section name repeats */
48 MANDOCERR_PROLOGOOO, /* out of order prologue */
49 MANDOCERR_PROLOGREP, /* repeated prologue entry */
50 MANDOCERR_LISTFIRST, /* list type must come first */
51 MANDOCERR_BADSTANDARD, /* bad standard */
52 MANDOCERR_BADLIB, /* bad library */
53 MANDOCERR_BADTAB, /* tab in non-literal context */
54 MANDOCERR_BADESCAPE, /* bad escape sequence */
55 MANDOCERR_BADQUOTE, /* unterminated quoted string */
56 MANDOCERR_NOWIDTHARG, /* argument requires the width argument */
57 /* FIXME: merge with MANDOCERR_IGNARGV. */
58 MANDOCERR_WIDTHARG, /* superfluous width argument */
59 MANDOCERR_IGNARGV, /* ignoring argument */
60 MANDOCERR_BADDATE, /* bad date argument */
61 MANDOCERR_BADWIDTH, /* bad width argument */
62 MANDOCERR_BADMSEC, /* unknown manual section */
63 MANDOCERR_SECMSEC, /* section not in conventional manual section */
64 MANDOCERR_EOLNSPACE, /* end of line whitespace */
65 MANDOCERR_SCOPENEST, /* blocks badly nested */
66
67 MANDOCERR_ERROR, /* ===== end of errors ===== */
68
69 MANDOCERR_NAMESECFIRST, /* NAME section must come first */
70 MANDOCERR_BADBOOL, /* bad Boolean value */
71 MANDOCERR_CHILD, /* child violates parent syntax */
72 MANDOCERR_BADATT, /* bad AT&T symbol */
73 MANDOCERR_LISTREP, /* list type repeated */
74 MANDOCERR_DISPREP, /* display type repeated */
75 MANDOCERR_ARGVREP, /* argument repeated */
76 MANDOCERR_NONAME, /* manual name not yet set */
77 MANDOCERR_MACROOBS, /* obsolete macro ignored */
78 MANDOCERR_MACROEMPTY, /* empty macro ignored */
79 MANDOCERR_BADBODY, /* macro not allowed in body */
80 MANDOCERR_BADPROLOG, /* macro not allowed in prologue */
81 MANDOCERR_BADCHAR, /* bad character */
82 MANDOCERR_BADNAMESEC, /* bad NAME section contents */
83 MANDOCERR_NOBLANKLN, /* no blank lines */
84 MANDOCERR_NOTEXT, /* no text in this context */
85 MANDOCERR_BADCOMMENT, /* bad comment style */
86 MANDOCERR_MACRO, /* unknown macro will be lost */
87 MANDOCERR_LINESCOPE, /* line scope broken */
88 MANDOCERR_ARGCOUNT, /* argument count wrong */
89 MANDOCERR_NOSCOPE, /* no such block is open */
90 MANDOCERR_SCOPEREP, /* scope already open */
91 MANDOCERR_SCOPEEXIT, /* scope open on exit */
92 /* FIXME: merge following with MANDOCERR_ARGCOUNT */
93 MANDOCERR_NOARGS, /* macro requires line argument(s) */
94 MANDOCERR_NOBODY, /* macro requires body argument(s) */
95 MANDOCERR_NOARGV, /* macro requires argument(s) */
96 MANDOCERR_NOTITLE, /* no title in document */
97 MANDOCERR_LISTTYPE, /* missing list type */
98 MANDOCERR_DISPTYPE, /* missing display type */
99 MANDOCERR_FONTTYPE, /* missing font type */
100 MANDOCERR_ARGSLOST, /* line argument(s) will be lost */
101 MANDOCERR_BODYLOST, /* body argument(s) will be lost */
102
103 MANDOCERR_FATAL, /* ===== end of fatal errors ===== */
104
105 MANDOCERR_COLUMNS, /* column syntax is inconsistent */
106 /* FIXME: this should be a MANDOCERR_ERROR */
107 MANDOCERR_NESTEDDISP, /* displays may not be nested */
108 MANDOCERR_BADDISP, /* unsupported display type */
109 MANDOCERR_SCOPEFATAL, /* blocks badly nested */
110 MANDOCERR_SYNTNOSCOPE, /* no scope to rewind: syntax violated */
111 MANDOCERR_SYNTLINESCOPE, /* line scope broken, syntax violated */
112 MANDOCERR_SYNTARGVCOUNT, /* argument count wrong, violates syntax */
113 MANDOCERR_SYNTCHILD, /* child violates parent syntax */
114 MANDOCERR_SYNTARGCOUNT, /* argument count wrong, violates syntax */
115 MANDOCERR_NODOCBODY, /* no document body */
116 MANDOCERR_NODOCPROLOG, /* no document prologue */
117 MANDOCERR_UTSNAME, /* utsname system call failed */
118 MANDOCERR_MEM, /* static buffer exhausted */
119
120 MANDOCERR_MAX
121 };
122
123 enum regs {
124 REG_nS = 0, /* register: nS */
125 REG__MAX
126 };
127
128 /*
129 * A single register entity. If "set" is zero, the value of the
130 * register should be the default one, which is per-register. It's
131 * assumed that callers know which type in "v" corresponds to which
132 * register value.
133 */
134 struct reg {
135 int set; /* whether set or not */
136 union {
137 unsigned u; /* unsigned integer */
138 } v;
139 };
140
141 /*
142 * The primary interface to setting register values is in libroff,
143 * although libmdoc and libman from time to time will manipulate
144 * registers (such as `.Sh SYNOPSIS' enabling REG_nS).
145 */
146 struct regset {
147 struct reg regs[REG__MAX];
148 };
149
150 /*
151 * Callback function for warnings, errors, and fatal errors as they
152 * occur in the compilers libroff, libmdoc, and libman.
153 */
154 typedef int (*mandocmsg)(enum mandocerr, void *,
155 int, int, const char *);
156
157 __END_DECLS
158
159 #endif /*!MANDOC_H*/