xref: /original-bsd/usr.bin/error/error.h (revision 241757c4)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)error.h	5.1 (Berkeley) 05/31/85
7  */
8 
9 typedef	int	boolean;
10 #define	reg	register
11 
12 #define	TRUE	1
13 #define	FALSE	0
14 
15 #define	true	1
16 #define	false	0
17 /*
18  *	Descriptors for the various languages we know about.
19  *	If you touch these, also touch lang_table
20  */
21 #define	INUNKNOWN	0
22 #define	INCPP	1
23 #define	INCC	2
24 #define	INAS	3
25 #define	INLD	4
26 #define	INLINT	5
27 #define	INF77	6
28 #define	INPI	7
29 #define	INPC	8
30 #define	INFRANZ	9
31 #define	INLISP	10
32 #define	INVAXIMA	11
33 #define	INRATFOR	12
34 #define	INLEX	13
35 #define	INYACC	14
36 #define	INAPL	15
37 #define	INMAKE	16
38 #define	INRI	17
39 #define	INTROFF	18
40 #define	INMOD2	19
41 
42 extern	int	language;
43 /*
44  *	We analyze each line in the error message file, and
45  *	attempt to categorize it by type, as well as language.
46  *	Here are the type descriptors.
47  */
48 typedef	int	Errorclass;
49 
50 #define	C_FIRST	0		/* first error category */
51 #define	C_UNKNOWN	0	/* must be zero */
52 #define	C_IGNORE	1	/* ignore the message; used for pi */
53 #define	C_SYNC		2	/* synchronization errors */
54 #define	C_DISCARD	3	/* touches dangerous files, so discard */
55 #define	C_NONSPEC	4	/* not specific to any file */
56 #define	C_THISFILE	5	/* specific to this file, but at no line */
57 #define	C_NULLED	6	/* refers to special func; so null */
58 #define	C_TRUE		7	/* fits into true error format */
59 #define	C_DUPL		8	/* sub class only; duplicated error message */
60 #define	C_LAST	9		/* last error category */
61 
62 #define	SORTABLE(x)	(!(NOTSORTABLE(x)))
63 #define	NOTSORTABLE(x)	(x <= C_NONSPEC)
64 /*
65  *	Resources to count and print out the error categories
66  */
67 extern	char		*class_table[];
68 extern	int		class_count[];
69 
70 #define	nunknown	class_count[C_UNKNOWN]
71 #define	nignore		class_count[C_IGNORE]
72 #define	nsyncerrors	class_count[C_SYNC]
73 #define	ndiscard	class_count[C_DISCARD]
74 #define	nnonspec	class_count[C_NONSPEC]
75 #define	nthisfile	class_count[C_THISFILE]
76 #define	nnulled		class_count[C_NULLED]
77 #define	ntrue		class_count[C_TRUE]
78 #define	ndupl		class_count[C_DUPL]
79 
80 /* places to put the error complaints */
81 
82 #define	TOTHEFILE	1	/* touch the file */
83 #define	TOSTDOUT	2	/* just print them out (ho-hum) */
84 
85 FILE	*errorfile;	/* where error file comes from */
86 FILE	*queryfile;	/* where the query responses from the user come from*/
87 
88 extern	char	*currentfilename;
89 extern	char	*processname;
90 extern	char	*scriptname;
91 
92 extern	boolean	query;
93 extern	boolean	terse;
94 int	inquire();			/* inquire for yes/no */
95 /*
96  *	codes for inquire() to return
97  */
98 #define	Q_NO	1			/* 'N' */
99 #define	Q_no	2			/* 'n' */
100 #define	Q_YES	3			/* 'Y' */
101 #define	Q_yes	4			/* 'y' */
102 
103 int	probethisfile();
104 /*
105  *	codes for probethisfile to return
106  */
107 #define	F_NOTEXIST	1
108 #define	F_NOTREAD	2
109 #define	F_NOTWRITE	3
110 #define	F_TOUCHIT	4
111 
112 /*
113  *	Describes attributes about a language
114  */
115 struct lang_desc{
116 	char	*lang_name;
117 	char	*lang_incomment;	/* one of the following defines */
118 	char	*lang_outcomment;	/* one of the following defines */
119 };
120 extern struct lang_desc lang_table[];
121 
122 #define	CINCOMMENT	"/*###"
123 #define	COUTCOMMENT	"%%%*/\n"
124 #define	FINCOMMENT	"C###"
125 #define	FOUTCOMMENT	"%%%\n"
126 #define	NEWLINE		"%%%\n"
127 #define	PIINCOMMENT	"(*###"
128 #define	PIOUTCOMMENT	"%%%*)\n"
129 #define	LISPINCOMMENT	";###"
130 #define	ASINCOMMENT	"####"
131 #define	RIINCOMMENT	CINCOMMENT
132 #define	RIOUTCOMMENT	COUTCOMMENT
133 #define	TROFFINCOMMENT	".\\\"###"
134 #define	TROFFOUTCOMMENT	NEWLINE
135 #define	MOD2INCOMMENT	"(*###"
136 #define	MOD2OUTCOMMENT	"%%%*)\n"
137 /*
138  *	Defines and resources for determing if a given line
139  *	is to be discarded because it refers to a file not to
140  *	be touched, or if the function reference is to a
141  *	function the user doesn't want recorded.
142  */
143 #define	IG_FILE1	"llib-lc"
144 #define	IG_FILE2	"llib-port"
145 #define	IG_FILE3	"/usr/lib/llib-lc"
146 #define	IG_FILE4	"/usr/lib/llib-port"
147 
148 #define	ERRORNAME	"/.errorrc"
149 int	nignored;
150 char	**names_ignored;
151 /*
152  *	Structure definition for a full error
153  */
154 typedef struct edesc	Edesc;
155 typedef	Edesc	*Eptr;
156 
157 struct edesc{
158 	Eptr	error_next;		/*linked together*/
159 	int	error_lgtext;		/* how many on the right hand side*/
160 	char	**error_text;		/* the right hand side proper*/
161 	Errorclass	error_e_class;	/* error category of this error*/
162 	Errorclass	error_s_class;	/* sub descriptor of error_e_class*/
163 	int	error_language;		/* the language for this error*/
164 	int	error_position;		/* oridinal position */
165 	int	error_line;		/* discovered line number*/
166 	int	error_no;		/* sequence number on input */
167 };
168 /*
169  *	Resources for the true errors
170  */
171 extern	int	nerrors;
172 extern	Eptr	er_head;
173 extern	Eptr	*errors;
174 /*
175  *	Resources for each of the files mentioned
176  */
177 extern	int	nfiles;
178 extern	Eptr	**files;	/* array of pointers into errors*/
179 boolean	*touchedfiles;			/* which files we touched */
180 /*
181  *	The langauge the compilation is in, as intuited from
182  *	the flavor of error messages analyzed.
183  */
184 extern	int	langauge;
185 extern	char	*currentfilename;
186 /*
187  *	Functional forwards
188  */
189 char	*Calloc();
190 char	*strsave();
191 char	*clobberfirst();
192 char	lastchar();
193 char	firstchar();
194 char	next_lastchar();
195 char	**wordvsplice();
196 int	wordvcmp();
197 boolean	persperdexplode();
198 /*
199  *	Printing hacks
200  */
201 char	*plural(), *verbform();
202