Annotation of src/usr.bin/error/error.h, Revision 1.4
1.4 ! deraadt 1: /* $OpenBSD: error.h,v 1.3 1998/07/10 14:09:53 mickey 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 *scriptname;
120:
121: extern boolean query;
122: extern boolean terse;
123: int inquire(); /* inquire for yes/no */
124: /*
125: * codes for inquire() to return
126: */
127: #define Q_NO 1 /* 'N' */
128: #define Q_no 2 /* 'n' */
129: #define Q_YES 3 /* 'Y' */
130: #define Q_yes 4 /* 'y' */
131:
132: int probethisfile();
133: /*
134: * codes for probethisfile to return
135: */
136: #define F_NOTEXIST 1
137: #define F_NOTREAD 2
138: #define F_NOTWRITE 3
139: #define F_TOUCHIT 4
140:
141: /*
142: * Describes attributes about a language
143: */
144: struct lang_desc{
145: char *lang_name;
146: char *lang_incomment; /* one of the following defines */
147: char *lang_outcomment; /* one of the following defines */
148: };
149: extern struct lang_desc lang_table[];
150:
151: #define CINCOMMENT "/*###"
152: #define COUTCOMMENT "%%%*/\n"
153: #define FINCOMMENT "C###"
154: #define FOUTCOMMENT "%%%\n"
155: #define NEWLINE "%%%\n"
156: #define PIINCOMMENT "(*###"
157: #define PIOUTCOMMENT "%%%*)\n"
158: #define LISPINCOMMENT ";###"
159: #define ASINCOMMENT "####"
160: #define RIINCOMMENT CINCOMMENT
161: #define RIOUTCOMMENT COUTCOMMENT
162: #define TROFFINCOMMENT ".\\\"###"
163: #define TROFFOUTCOMMENT NEWLINE
164: #define MOD2INCOMMENT "(*###"
165: #define MOD2OUTCOMMENT "%%%*)\n"
166: /*
167: * Defines and resources for determing if a given line
168: * is to be discarded because it refers to a file not to
169: * be touched, or if the function reference is to a
170: * function the user doesn't want recorded.
171: */
172:
173: #define ERRORNAME "/.errorrc"
174: int nignored;
175: char **names_ignored;
176: /*
177: * Structure definition for a full error
178: */
179: typedef struct edesc Edesc;
180: typedef Edesc *Eptr;
181:
182: struct edesc{
183: Eptr error_next; /*linked together*/
184: int error_lgtext; /* how many on the right hand side*/
185: char **error_text; /* the right hand side proper*/
186: Errorclass error_e_class; /* error category of this error*/
187: Errorclass error_s_class; /* sub descriptor of error_e_class*/
188: int error_language; /* the language for this error*/
189: int error_position; /* oridinal position */
190: int error_line; /* discovered line number*/
191: int error_no; /* sequence number on input */
192: };
193: /*
194: * Resources for the true errors
195: */
196: extern int nerrors;
197: extern Eptr er_head;
198: extern Eptr *errors;
199: /*
200: * Resources for each of the files mentioned
201: */
202: extern int nfiles;
203: extern Eptr **files; /* array of pointers into errors*/
204: boolean *touchedfiles; /* which files we touched */
205: /*
1.4 ! deraadt 206: * The language the compilation is in, as intuited from
1.1 deraadt 207: * the flavor of error messages analyzed.
208: */
1.4 ! deraadt 209: extern int language;
1.1 deraadt 210: extern char *currentfilename;
211: /*
212: * Functional forwards
213: */
214: char *Calloc();
215: char *strsave();
216: char *clobberfirst();
217: char lastchar();
218: char firstchar();
219: char next_lastchar();
220: char **wordvsplice();
221: int wordvcmp();
222: boolean persperdexplode();
223: /*
224: * Printing hacks
225: */
226: char *plural(), *verbform();