xref: /csrg-svn/usr.bin/error/error.h (revision 5596)
11454Sroot /*
2*5596Srrh  *  @(#)error.h	1.2 (Berkeley) 01/22/82
31454Sroot  */
41454Sroot typedef	int	boolean;
5*5596Srrh #define	reg	register
61454Sroot 
71454Sroot #define	TRUE	1
81454Sroot #define	FALSE	0
9*5596Srrh 
10*5596Srrh #define	true	1
11*5596Srrh #define	false	0
121454Sroot /*
131454Sroot  *	Descriptors for the various languages we know about.
141454Sroot  *	If you touch these, also touch lang_table
151454Sroot  */
161454Sroot #define	INUNKNOWN	0
171454Sroot #define	INCPP	1
181454Sroot #define	INCC	2
191454Sroot #define	INAS	3
201454Sroot #define	INLD	4
211454Sroot #define	INLINT	5
221454Sroot #define	INF77	6
231454Sroot #define	INPI	7
241454Sroot #define	INPC	8
251454Sroot #define	INFRANZ	9
261454Sroot #define	INLISP	10
271454Sroot #define	INVAXIMA	11
281454Sroot #define	INRATFOR	12
291454Sroot #define	INLEX	13
301454Sroot #define	INYACC	14
311454Sroot #define	INAPL	15
321454Sroot #define	INMAKE	16
331454Sroot #define	INRI	17
341454Sroot 
351454Sroot extern	int	language;
361454Sroot /*
371454Sroot  *	We analyze each line in the error message file, and
381454Sroot  *	attempt to categorize it by type, as well as language.
391454Sroot  *	Here are the type descriptors.
401454Sroot  */
411454Sroot typedef	int	Errorclass;
421454Sroot 
43*5596Srrh #define	C_FIRST	0		/* first error category */
441454Sroot #define	C_UNKNOWN	0	/* must be zero */
451454Sroot #define	C_IGNORE	1	/* ignore the message; used for pi */
461454Sroot #define	C_SYNC		2	/* synchronization errors */
471454Sroot #define	C_DISCARD	3	/* touches dangerous files, so discard */
481454Sroot #define	C_NONSPEC	4	/* not specific to any file */
491454Sroot #define	C_THISFILE	5	/* specific to this file, but at no line */
501454Sroot #define	C_NULLED	6	/* refers to special func; so null */
511454Sroot #define	C_TRUE		7	/* fits into true error format */
521454Sroot #define	C_DUPL		8	/* sub class only; duplicated error message */
53*5596Srrh #define	C_LAST	9		/* last error category */
541454Sroot 
551454Sroot #define	SORTABLE(x)	(!(NOTSORTABLE(x)))
561454Sroot #define	NOTSORTABLE(x)	(x <= C_NONSPEC)
571454Sroot /*
581454Sroot  *	Resources to count and print out the error categories
591454Sroot  */
601454Sroot extern	char		*class_table[];
611454Sroot extern	int		class_count[];
621454Sroot 
631454Sroot #define	nunknown	class_count[C_UNKNOWN]
641454Sroot #define	nignore		class_count[C_IGNORE]
65*5596Srrh #define	nsyncerrors	class_count[C_SYNC]
661454Sroot #define	ndiscard	class_count[C_DISCARD]
671454Sroot #define	nnonspec	class_count[C_NONSPEC]
681454Sroot #define	nthisfile	class_count[C_THISFILE]
69*5596Srrh #define	nnulled		class_count[C_NULLED]
70*5596Srrh #define	ntrue		class_count[C_TRUE]
711454Sroot #define	ndupl		class_count[C_DUPL]
721454Sroot 
731454Sroot /* places to put the error complaints */
741454Sroot 
75*5596Srrh #define	TOTHEFILE	1	/* touch the file */
761454Sroot #define	TOSTDOUT	2	/* just print them out (ho-hum) */
771454Sroot 
781454Sroot FILE	*errorfile;	/* where error file comes from */
791454Sroot FILE	*queryfile;	/* where the query responses from the user come from*/
801454Sroot 
811454Sroot extern	char	*currentfilename;
821454Sroot extern	char	*processname;
831454Sroot extern	char	*scriptname;
841454Sroot 
851454Sroot extern	boolean	query;
86*5596Srrh extern	boolean	terse;
87*5596Srrh int	inquire();			/* inquire for yes/no */
88*5596Srrh /*
89*5596Srrh  *	codes for inquire() to return
90*5596Srrh  */
91*5596Srrh #define	Q_NO	1			/* 'N' */
92*5596Srrh #define	Q_no	2			/* 'n' */
93*5596Srrh #define	Q_YES	3			/* 'Y' */
94*5596Srrh #define	Q_yes	4			/* 'y' */
95*5596Srrh 
96*5596Srrh int	probethisfile();
971454Sroot /*
98*5596Srrh  *	codes for probethisfile to return
99*5596Srrh  */
100*5596Srrh #define	F_NOTEXIST	1
101*5596Srrh #define	F_NOTREAD	2
102*5596Srrh #define	F_NOTWRITE	3
103*5596Srrh #define	F_TOUCHIT	4
104*5596Srrh 
105*5596Srrh /*
1061454Sroot  *	Describes attributes about a language
1071454Sroot  */
1081454Sroot struct lang_desc{
1091454Sroot 	char	*lang_name;
1101454Sroot 	char	*lang_incomment;	/* one of the following defines */
1111454Sroot 	char	*lang_outcomment;	/* one of the following defines */
1121454Sroot };
1131454Sroot extern struct lang_desc lang_table[];
1141454Sroot 
1151454Sroot #define	CINCOMMENT	"/*###"
1161454Sroot #define	COUTCOMMENT	"%%%*/\n"
1171454Sroot #define	FINCOMMENT	"C###"
1181454Sroot #define	FOUTCOMMENT	"%%%\n"
1191454Sroot #define	NEWLINE		"%%%\n"
1201454Sroot #define	PIINCOMMENT	"(*###"
1211454Sroot #define	PIOUTCOMMENT	"%%%*)\n"
1221454Sroot #define	LISPINCOMMENT	";###"
1231454Sroot #define	ASINCOMMENT	"####"
124*5596Srrh #define	RIINCOMMENT	CINCOMMENT
1251454Sroot #define	RIOUTCOMMENT	COUTCOMMENT
1261454Sroot /*
1271454Sroot  *	Defines and resources for determing if a given line
1281454Sroot  *	is to be discarded because it refers to a file not to
1291454Sroot  *	be touched, or if the function reference is to a
1301454Sroot  *	function the user doesn't want recorded.
1311454Sroot  */
132*5596Srrh #define	IG_FILE1	"llib-lc"
133*5596Srrh #define	IG_FILE2	"llib-port"
1341454Sroot #define	IG_FILE3	"/usr/lib/llib-lc"
1351454Sroot #define	IG_FILE4	"/usr/lib/llib-port"
1361454Sroot 
137*5596Srrh #define	ERRORNAME	"/.errorrc"
1381454Sroot int	nignored;
1391454Sroot char	**names_ignored;
1401454Sroot /*
1411454Sroot  *	Structure definition for a full error
1421454Sroot  */
143*5596Srrh typedef struct edesc	Edesc;
144*5596Srrh typedef	Edesc	*Eptr;
145*5596Srrh 
146*5596Srrh struct edesc{
147*5596Srrh 	Eptr	error_next;		/*linked together*/
1481454Sroot 	int	error_lgtext;		/* how many on the right hand side*/
1491454Sroot 	char	**error_text;		/* the right hand side proper*/
1501454Sroot 	Errorclass	error_e_class;	/* error category of this error*/
1511454Sroot 	Errorclass	error_s_class;	/* sub descriptor of error_e_class*/
1521454Sroot 	int	error_language;		/* the language for this error*/
1531454Sroot 	int	error_position;		/* oridinal position */
1541454Sroot 	int	error_line;		/* discovered line number*/
1551454Sroot 	int	error_no;		/* sequence number on input */
1561454Sroot };
1571454Sroot /*
1581454Sroot  *	Resources for the true errors
1591454Sroot  */
1601454Sroot extern	int	nerrors;
161*5596Srrh extern	Eptr	er_head;
162*5596Srrh extern	Eptr	*errors;
1631454Sroot /*
1641454Sroot  *	Resources for each of the files mentioned
1651454Sroot  */
1661454Sroot extern	int	nfiles;
167*5596Srrh extern	Eptr	**files;	/* array of pointers into errors*/
168*5596Srrh boolean	*touchedfiles;			/* which files we touched */
1691454Sroot /*
1701454Sroot  *	The langauge the compilation is in, as intuited from
1711454Sroot  *	the flavor of error messages analyzed.
1721454Sroot  */
1731454Sroot extern	int	langauge;
1741454Sroot extern	char	*currentfilename;
1751454Sroot /*
1761454Sroot  *	Functional forwards
1771454Sroot  */
1781454Sroot char	*Calloc();
1791454Sroot char	*strsave();
1801454Sroot char	*clobberfirst();
1811454Sroot char	lastchar();
1821454Sroot char	firstchar();
1831454Sroot char	next_lastchar();
1841454Sroot char	**wordvsplice();
1851454Sroot int	wordvcmp();
1861454Sroot boolean	persperdexplode();
187*5596Srrh /*
188*5596Srrh  *	Printing hacks
189*5596Srrh  */
190*5596Srrh char	*plural(), *verbform();
191