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