Annotation of src/usr.bin/error/error.h, Revision 1.2
1.2 ! deraadt 1: /* $OpenBSD: error.h,v 1.3 1995/09/02 06:15:25 jtc Exp $ */
1.1 deraadt 2: /* $NetBSD: error.h,v 1.3 1995/09/02 06:15:25 jtc Exp $ */
3:
4: /*
5: * Copyright (c) 1980, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by the University of
19: * California, Berkeley and its contributors.
20: * 4. Neither the name of the University nor the names of its contributors
21: * may be used to endorse or promote products derived from this software
22: * without specific prior written permission.
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34: * SUCH DAMAGE.
35: *
36: * @(#)error.h 8.1 (Berkeley) 6/6/93
37: */
38:
39: typedef int boolean;
40: #define reg register
41:
42: #define TRUE 1
43: #define FALSE 0
44:
45: #define true 1
46: #define false 0
47: /*
48: * Descriptors for the various languages we know about.
49: * If you touch these, also touch lang_table
50: */
51: #define INUNKNOWN 0
52: #define INCPP 1
53: #define INCC 2
54: #define INAS 3
55: #define INLD 4
56: #define INLINT 5
57: #define INF77 6
58: #define INPI 7
59: #define INPC 8
60: #define INFRANZ 9
61: #define INLISP 10
62: #define INVAXIMA 11
63: #define INRATFOR 12
64: #define INLEX 13
65: #define INYACC 14
66: #define INAPL 15
67: #define INMAKE 16
68: #define INRI 17
69: #define INTROFF 18
70: #define INMOD2 19
71:
72: extern int language;
73: /*
74: * We analyze each line in the error message file, and
75: * attempt to categorize it by type, as well as language.
76: * Here are the type descriptors.
77: */
78: typedef int Errorclass;
79:
80: #define C_FIRST 0 /* first error category */
81: #define C_UNKNOWN 0 /* must be zero */
82: #define C_IGNORE 1 /* ignore the message; used for pi */
83: #define C_SYNC 2 /* synchronization errors */
84: #define C_DISCARD 3 /* touches dangerous files, so discard */
85: #define C_NONSPEC 4 /* not specific to any file */
86: #define C_THISFILE 5 /* specific to this file, but at no line */
87: #define C_NULLED 6 /* refers to special func; so null */
88: #define C_TRUE 7 /* fits into true error format */
89: #define C_DUPL 8 /* sub class only; duplicated error message */
90: #define C_LAST 9 /* last error category */
91:
92: #define SORTABLE(x) (!(NOTSORTABLE(x)))
93: #define NOTSORTABLE(x) (x <= C_NONSPEC)
94: /*
95: * Resources to count and print out the error categories
96: */
97: extern char *class_table[];
98: extern int class_count[];
99:
100: #define nunknown class_count[C_UNKNOWN]
101: #define nignore class_count[C_IGNORE]
102: #define nsyncerrors class_count[C_SYNC]
103: #define ndiscard class_count[C_DISCARD]
104: #define nnonspec class_count[C_NONSPEC]
105: #define nthisfile class_count[C_THISFILE]
106: #define nnulled class_count[C_NULLED]
107: #define ntrue class_count[C_TRUE]
108: #define ndupl class_count[C_DUPL]
109:
110: /* places to put the error complaints */
111:
112: #define TOTHEFILE 1 /* touch the file */
113: #define TOSTDOUT 2 /* just print them out (ho-hum) */
114:
115: FILE *errorfile; /* where error file comes from */
116: FILE *queryfile; /* where the query responses from the user come from*/
117:
118: extern char *currentfilename;
119: extern char *processname;
120: extern char *scriptname;
121:
122: extern boolean query;
123: extern boolean terse;
124: int inquire(); /* inquire for yes/no */
125: /*
126: * codes for inquire() to return
127: */
128: #define Q_NO 1 /* 'N' */
129: #define Q_no 2 /* 'n' */
130: #define Q_YES 3 /* 'Y' */
131: #define Q_yes 4 /* 'y' */
132:
133: int probethisfile();
134: /*
135: * codes for probethisfile to return
136: */
137: #define F_NOTEXIST 1
138: #define F_NOTREAD 2
139: #define F_NOTWRITE 3
140: #define F_TOUCHIT 4
141:
142: /*
143: * Describes attributes about a language
144: */
145: struct lang_desc{
146: char *lang_name;
147: char *lang_incomment; /* one of the following defines */
148: char *lang_outcomment; /* one of the following defines */
149: };
150: extern struct lang_desc lang_table[];
151:
152: #define CINCOMMENT "/*###"
153: #define COUTCOMMENT "%%%*/\n"
154: #define FINCOMMENT "C###"
155: #define FOUTCOMMENT "%%%\n"
156: #define NEWLINE "%%%\n"
157: #define PIINCOMMENT "(*###"
158: #define PIOUTCOMMENT "%%%*)\n"
159: #define LISPINCOMMENT ";###"
160: #define ASINCOMMENT "####"
161: #define RIINCOMMENT CINCOMMENT
162: #define RIOUTCOMMENT COUTCOMMENT
163: #define TROFFINCOMMENT ".\\\"###"
164: #define TROFFOUTCOMMENT NEWLINE
165: #define MOD2INCOMMENT "(*###"
166: #define MOD2OUTCOMMENT "%%%*)\n"
167: /*
168: * Defines and resources for determing if a given line
169: * is to be discarded because it refers to a file not to
170: * be touched, or if the function reference is to a
171: * function the user doesn't want recorded.
172: */
173:
174: #define ERRORNAME "/.errorrc"
175: int nignored;
176: char **names_ignored;
177: /*
178: * Structure definition for a full error
179: */
180: typedef struct edesc Edesc;
181: typedef Edesc *Eptr;
182:
183: struct edesc{
184: Eptr error_next; /*linked together*/
185: int error_lgtext; /* how many on the right hand side*/
186: char **error_text; /* the right hand side proper*/
187: Errorclass error_e_class; /* error category of this error*/
188: Errorclass error_s_class; /* sub descriptor of error_e_class*/
189: int error_language; /* the language for this error*/
190: int error_position; /* oridinal position */
191: int error_line; /* discovered line number*/
192: int error_no; /* sequence number on input */
193: };
194: /*
195: * Resources for the true errors
196: */
197: extern int nerrors;
198: extern Eptr er_head;
199: extern Eptr *errors;
200: /*
201: * Resources for each of the files mentioned
202: */
203: extern int nfiles;
204: extern Eptr **files; /* array of pointers into errors*/
205: boolean *touchedfiles; /* which files we touched */
206: /*
207: * The langauge the compilation is in, as intuited from
208: * the flavor of error messages analyzed.
209: */
210: extern int langauge;
211: extern char *currentfilename;
212: /*
213: * Functional forwards
214: */
215: char *Calloc();
216: char *strsave();
217: char *clobberfirst();
218: char lastchar();
219: char firstchar();
220: char next_lastchar();
221: char **wordvsplice();
222: int wordvcmp();
223: boolean persperdexplode();
224: /*
225: * Printing hacks
226: */
227: char *plural(), *verbform();