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