xref: /onnv-gate/usr/src/cmd/sgs/error/common/error.h (revision 291:0ac955735323)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
23*291Smike_s  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
27*291Smike_s #ifndef _ERROR_H
28*291Smike_s #define	_ERROR_H
29*291Smike_s 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
32*291Smike_s #ifdef  __cplusplus
33*291Smike_s extern "C" {
34*291Smike_s #endif
35*291Smike_s 
360Sstevel@tonic-gate typedef	int	boolean;
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #define	TRUE	1
390Sstevel@tonic-gate #define	FALSE	0
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #define	true	1
420Sstevel@tonic-gate #define	false	0
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate  *	Descriptors for the various languages we know about.
450Sstevel@tonic-gate  *	If you touch these, also touch lang_table
460Sstevel@tonic-gate  */
470Sstevel@tonic-gate #define	INUNKNOWN	0
480Sstevel@tonic-gate #define	INCPP	1
490Sstevel@tonic-gate #define	INCC	2
500Sstevel@tonic-gate #define	INAS	3
510Sstevel@tonic-gate #define	INLD	4
520Sstevel@tonic-gate #define	INLINT	5
530Sstevel@tonic-gate #define	INF77	6
540Sstevel@tonic-gate #define	INPI	7
550Sstevel@tonic-gate #define	INPC	8
560Sstevel@tonic-gate #define	INFRANZ	9
570Sstevel@tonic-gate #define	INLISP	10
580Sstevel@tonic-gate #define	INVAXIMA	11
590Sstevel@tonic-gate #define	INRATFOR	12
600Sstevel@tonic-gate #define	INLEX	13
610Sstevel@tonic-gate #define	INYACC	14
620Sstevel@tonic-gate #define	INAPL	15
630Sstevel@tonic-gate #define	INMAKE	16
640Sstevel@tonic-gate #define	INRI	17
650Sstevel@tonic-gate #define	INTROFF	18
660Sstevel@tonic-gate #define	INMOD2	19
67*291Smike_s #define	INSUNF77 20
680Sstevel@tonic-gate 
690Sstevel@tonic-gate extern	int	language;
70*291Smike_s 
71*291Smike_s extern  boolean notouch;
72*291Smike_s 
730Sstevel@tonic-gate /*
740Sstevel@tonic-gate  *	We analyze each line in the error message file, and
750Sstevel@tonic-gate  *	attempt to categorize it by type, as well as language.
760Sstevel@tonic-gate  *	Here are the type descriptors.
770Sstevel@tonic-gate  */
780Sstevel@tonic-gate typedef	int	Errorclass;
790Sstevel@tonic-gate 
800Sstevel@tonic-gate #define	C_FIRST	0		/* first error category */
810Sstevel@tonic-gate #define	C_UNKNOWN	0	/* must be zero */
820Sstevel@tonic-gate #define	C_IGNORE	1	/* ignore the message; used for pi */
830Sstevel@tonic-gate #define	C_SYNC		2	/* synchronization errors */
840Sstevel@tonic-gate #define	C_DISCARD	3	/* touches dangerous files, so discard */
850Sstevel@tonic-gate #define	C_NONSPEC	4	/* not specific to any file */
860Sstevel@tonic-gate #define	C_THISFILE	5	/* specific to this file, but at no line */
870Sstevel@tonic-gate #define	C_NULLED	6	/* refers to special func; so null */
880Sstevel@tonic-gate #define	C_TRUE		7	/* fits into true error format */
890Sstevel@tonic-gate #define	C_DUPL		8	/* sub class only; duplicated error message */
900Sstevel@tonic-gate #define	C_LAST	9		/* last error category */
910Sstevel@tonic-gate 
920Sstevel@tonic-gate #define	SORTABLE(x)	(!(NOTSORTABLE(x)))
930Sstevel@tonic-gate #define	NOTSORTABLE(x)	(x <= C_NONSPEC)
940Sstevel@tonic-gate /*
950Sstevel@tonic-gate  *	Resources to count and print out the error categories
960Sstevel@tonic-gate  */
970Sstevel@tonic-gate extern	char		*class_table[];
980Sstevel@tonic-gate extern	int		class_count[];
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate #define	nunknown	class_count[C_UNKNOWN]
1010Sstevel@tonic-gate #define	nignore		class_count[C_IGNORE]
1020Sstevel@tonic-gate #define	nsyncerrors	class_count[C_SYNC]
1030Sstevel@tonic-gate #define	ndiscard	class_count[C_DISCARD]
1040Sstevel@tonic-gate #define	nnonspec	class_count[C_NONSPEC]
1050Sstevel@tonic-gate #define	nthisfile	class_count[C_THISFILE]
1060Sstevel@tonic-gate #define	nnulled		class_count[C_NULLED]
1070Sstevel@tonic-gate #define	ntrue		class_count[C_TRUE]
1080Sstevel@tonic-gate #define	ndupl		class_count[C_DUPL]
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate /* places to put the error complaints */
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate #define	TOTHEFILE	1	/* touch the file */
1130Sstevel@tonic-gate #define	TOSTDOUT	2	/* just print them out (ho-hum) */
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate FILE	*errorfile;	/* where error file comes from */
116*291Smike_s FILE	*queryfile;	/* where the query responses from the user come from */
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate extern	char	*currentfilename;
1190Sstevel@tonic-gate extern	char	*processname;
1200Sstevel@tonic-gate extern	char	*scriptname;
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate extern	boolean	query;
1230Sstevel@tonic-gate extern	boolean	terse;
124*291Smike_s int	inquire(char *format, ...);			/* inquire for yes/no */
125*291Smike_s /*
1260Sstevel@tonic-gate  *	codes for inquire() to return
1270Sstevel@tonic-gate  */
1280Sstevel@tonic-gate #define	Q_NO	1			/* 'N' */
1290Sstevel@tonic-gate #define	Q_no	2			/* 'n' */
1300Sstevel@tonic-gate #define	Q_YES	3			/* 'Y' */
1310Sstevel@tonic-gate #define	Q_yes	4			/* 'y' */
1320Sstevel@tonic-gate 
133*291Smike_s int	probethisfile(char *name);
1340Sstevel@tonic-gate /*
1350Sstevel@tonic-gate  *	codes for probethisfile to return
1360Sstevel@tonic-gate  */
1370Sstevel@tonic-gate #define	F_NOTEXIST	1
1380Sstevel@tonic-gate #define	F_NOTREAD	2
1390Sstevel@tonic-gate #define	F_NOTWRITE	3
1400Sstevel@tonic-gate #define	F_TOUCHIT	4
1410Sstevel@tonic-gate 
1420Sstevel@tonic-gate /*
1430Sstevel@tonic-gate  *	Describes attributes about a language
1440Sstevel@tonic-gate  */
145*291Smike_s struct lang_desc {
1460Sstevel@tonic-gate 	char	*lang_name;
1470Sstevel@tonic-gate 	char	*lang_incomment;	/* one of the following defines */
1480Sstevel@tonic-gate 	char	*lang_outcomment;	/* one of the following defines */
1490Sstevel@tonic-gate };
1500Sstevel@tonic-gate extern struct lang_desc lang_table[];
1510Sstevel@tonic-gate 
1520Sstevel@tonic-gate #define	CINCOMMENT	"/*###"
1530Sstevel@tonic-gate #define	COUTCOMMENT	"%%%*/\n"
1540Sstevel@tonic-gate #define	FINCOMMENT	"C###"
1550Sstevel@tonic-gate #define	FOUTCOMMENT	"%%%\n"
1560Sstevel@tonic-gate #define	NEWLINE		"%%%\n"
1570Sstevel@tonic-gate #define	PIINCOMMENT	"(*###"
1580Sstevel@tonic-gate #define	PIOUTCOMMENT	"%%%*)\n"
1590Sstevel@tonic-gate #define	LISPINCOMMENT	";###"
1600Sstevel@tonic-gate #define	ASINCOMMENT	"####"
1610Sstevel@tonic-gate #define	RIINCOMMENT	CINCOMMENT
1620Sstevel@tonic-gate #define	RIOUTCOMMENT	COUTCOMMENT
1630Sstevel@tonic-gate #define	TROFFINCOMMENT	".\\\"###"
1640Sstevel@tonic-gate #define	TROFFOUTCOMMENT	NEWLINE
1650Sstevel@tonic-gate #define	MOD2INCOMMENT	"(*###"
1660Sstevel@tonic-gate #define	MOD2OUTCOMMENT	"%%%*)\n"
1670Sstevel@tonic-gate /*
1680Sstevel@tonic-gate  *	Defines and resources for determing if a given line
1690Sstevel@tonic-gate  *	is to be discarded because it refers to a file not to
1700Sstevel@tonic-gate  *	be touched, or if the function reference is to a
1710Sstevel@tonic-gate  *	function the user doesn't want recorded.
1720Sstevel@tonic-gate  */
1730Sstevel@tonic-gate #define	IG_FILE1	"llib-lc"
1740Sstevel@tonic-gate #define	IG_FILE2	"llib-port"
1750Sstevel@tonic-gate #define	IG_FILE3	"/usr/lib/llib-lc"
1760Sstevel@tonic-gate #define	IG_FILE4	"/usr/lib/llib-port"
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate #define	ERRORNAME	"/.errorrc"
1790Sstevel@tonic-gate int	nignored;
1800Sstevel@tonic-gate char	**names_ignored;
181*291Smike_s /*
1820Sstevel@tonic-gate  *	Structure definition for a full error
1830Sstevel@tonic-gate  */
1840Sstevel@tonic-gate typedef struct edesc	Edesc;
1850Sstevel@tonic-gate typedef	Edesc	*Eptr;
1860Sstevel@tonic-gate 
187*291Smike_s struct edesc {
188*291Smike_s 	Eptr	error_next;		/* linked together */
189*291Smike_s 	int	error_lgtext;		/* how many on the right hand side */
190*291Smike_s 	char	**error_text;		/* the right hand side proper */
191*291Smike_s 	Errorclass	error_e_class;	/* error category of this error */
192*291Smike_s 	Errorclass	error_s_class;	/* sub descriptor of error_e_class */
193*291Smike_s 	int	error_language;		/* the language for this error */
1940Sstevel@tonic-gate 	int	error_position;		/* oridinal position */
195*291Smike_s 	int	error_line;		/* discovered line number */
1960Sstevel@tonic-gate 	int	error_no;		/* sequence number on input */
1970Sstevel@tonic-gate };
1980Sstevel@tonic-gate /*
1990Sstevel@tonic-gate  *	Resources for the true errors
2000Sstevel@tonic-gate  */
2010Sstevel@tonic-gate extern	int	nerrors;
2020Sstevel@tonic-gate extern	Eptr	er_head;
203*291Smike_s extern	Eptr	*errors;
2040Sstevel@tonic-gate /*
2050Sstevel@tonic-gate  *	Resources for each of the files mentioned
2060Sstevel@tonic-gate  */
2070Sstevel@tonic-gate extern	int	nfiles;
208*291Smike_s extern	Eptr	**files;	/* array of pointers into errors */
2090Sstevel@tonic-gate boolean	*touchedfiles;			/* which files we touched */
2100Sstevel@tonic-gate /*
2110Sstevel@tonic-gate  *	The langauge the compilation is in, as intuited from
2120Sstevel@tonic-gate  *	the flavor of error messages analyzed.
2130Sstevel@tonic-gate  */
2140Sstevel@tonic-gate extern	int	langauge;
2150Sstevel@tonic-gate extern	char	*currentfilename;
2160Sstevel@tonic-gate /*
2170Sstevel@tonic-gate  *	Functional forwards
2180Sstevel@tonic-gate  */
219*291Smike_s void	*Calloc(int nelements, int size);
220*291Smike_s char	*strsave(char *instring);
221*291Smike_s char	lastchar(char *string);
222*291Smike_s char	firstchar(char *string);
223*291Smike_s char	next_lastchar(char *string);
224*291Smike_s char	**wordvsplice(int emptyhead, int wordc, char **wordv);
225*291Smike_s int	wordvcmp(char **wordv1, int wordc, char **wordv2);
226*291Smike_s boolean	persperdexplode(char *string, char **r_perd, char **r_pers);
2270Sstevel@tonic-gate /*
2280Sstevel@tonic-gate  *	Printing hacks
2290Sstevel@tonic-gate  */
230*291Smike_s char	*plural(int n);
231*291Smike_s char	*verbform(int n);
232*291Smike_s 
233*291Smike_s void erroradd(int errorlength, char **errorv, Errorclass errorclass,
234*291Smike_s     Errorclass errorsubclass);
235*291Smike_s void eaterrors(int *r_errorc, Eptr **r_errorv);
236*291Smike_s void wordvbuild(char *string, int *r_wordc, char ***r_wordv);
237*291Smike_s void wordvprint(FILE *fyle, int wordc, char *wordv[]);
238*291Smike_s void printerrors(boolean look_at_subclass, int errorc, Eptr errorv[]);
239*291Smike_s void clob_last(char *string, char newstuff);
240*291Smike_s void arrayify(int *e_length, Eptr **e_array, Eptr header);
241*291Smike_s void getignored(char *auxname);
242*291Smike_s void filenames(int nfiles, Eptr **files);
243*291Smike_s void findfiles(int nerrors, Eptr *errors, int *r_nfiles, Eptr ***r_files);
244*291Smike_s void onintr(int sig);
245*291Smike_s boolean touchfiles(int nfiles, Eptr **files, int *r_edargc, char ***r_edargv);
246*291Smike_s Errorclass discardit(Eptr errorp);
247*291Smike_s char *substitute(char *string, char chold, char chnew);
248*291Smike_s int position(char *string, char ch);
249*291Smike_s 
250*291Smike_s #ifdef  __cplusplus
251*291Smike_s }
252*291Smike_s #endif
253*291Smike_s 
254*291Smike_s #endif /* _ERROR_H */
255