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