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