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