xref: /csrg-svn/usr.bin/error/error.h (revision 61987)
121640Sdist /*
2*61987Sbostic  * Copyright (c) 1980, 1993
3*61987Sbostic  *	The Regents of the University of California.  All rights reserved.
421640Sdist  *
542683Sbostic  * %sccs.include.redist.c%
634664Sbostic  *
7*61987Sbostic  *	@(#)error.h	8.1 (Berkeley) 06/06/93
821640Sdist  */
914545Ssam 
101454Sroot typedef	int	boolean;
115596Srrh #define	reg	register
121454Sroot 
131454Sroot #define	TRUE	1
141454Sroot #define	FALSE	0
155596Srrh 
165596Srrh #define	true	1
175596Srrh #define	false	0
181454Sroot /*
191454Sroot  *	Descriptors for the various languages we know about.
201454Sroot  *	If you touch these, also touch lang_table
211454Sroot  */
221454Sroot #define	INUNKNOWN	0
231454Sroot #define	INCPP	1
241454Sroot #define	INCC	2
251454Sroot #define	INAS	3
261454Sroot #define	INLD	4
271454Sroot #define	INLINT	5
281454Sroot #define	INF77	6
291454Sroot #define	INPI	7
301454Sroot #define	INPC	8
311454Sroot #define	INFRANZ	9
321454Sroot #define	INLISP	10
331454Sroot #define	INVAXIMA	11
341454Sroot #define	INRATFOR	12
351454Sroot #define	INLEX	13
361454Sroot #define	INYACC	14
371454Sroot #define	INAPL	15
381454Sroot #define	INMAKE	16
391454Sroot #define	INRI	17
4013106Srrh #define	INTROFF	18
4117499Srrh #define	INMOD2	19
421454Sroot 
431454Sroot extern	int	language;
441454Sroot /*
451454Sroot  *	We analyze each line in the error message file, and
461454Sroot  *	attempt to categorize it by type, as well as language.
471454Sroot  *	Here are the type descriptors.
481454Sroot  */
491454Sroot typedef	int	Errorclass;
501454Sroot 
515596Srrh #define	C_FIRST	0		/* first error category */
521454Sroot #define	C_UNKNOWN	0	/* must be zero */
531454Sroot #define	C_IGNORE	1	/* ignore the message; used for pi */
541454Sroot #define	C_SYNC		2	/* synchronization errors */
551454Sroot #define	C_DISCARD	3	/* touches dangerous files, so discard */
561454Sroot #define	C_NONSPEC	4	/* not specific to any file */
571454Sroot #define	C_THISFILE	5	/* specific to this file, but at no line */
581454Sroot #define	C_NULLED	6	/* refers to special func; so null */
591454Sroot #define	C_TRUE		7	/* fits into true error format */
601454Sroot #define	C_DUPL		8	/* sub class only; duplicated error message */
615596Srrh #define	C_LAST	9		/* last error category */
621454Sroot 
631454Sroot #define	SORTABLE(x)	(!(NOTSORTABLE(x)))
641454Sroot #define	NOTSORTABLE(x)	(x <= C_NONSPEC)
651454Sroot /*
661454Sroot  *	Resources to count and print out the error categories
671454Sroot  */
681454Sroot extern	char		*class_table[];
691454Sroot extern	int		class_count[];
701454Sroot 
711454Sroot #define	nunknown	class_count[C_UNKNOWN]
721454Sroot #define	nignore		class_count[C_IGNORE]
735596Srrh #define	nsyncerrors	class_count[C_SYNC]
741454Sroot #define	ndiscard	class_count[C_DISCARD]
751454Sroot #define	nnonspec	class_count[C_NONSPEC]
761454Sroot #define	nthisfile	class_count[C_THISFILE]
775596Srrh #define	nnulled		class_count[C_NULLED]
785596Srrh #define	ntrue		class_count[C_TRUE]
791454Sroot #define	ndupl		class_count[C_DUPL]
801454Sroot 
811454Sroot /* places to put the error complaints */
821454Sroot 
835596Srrh #define	TOTHEFILE	1	/* touch the file */
841454Sroot #define	TOSTDOUT	2	/* just print them out (ho-hum) */
851454Sroot 
861454Sroot FILE	*errorfile;	/* where error file comes from */
871454Sroot FILE	*queryfile;	/* where the query responses from the user come from*/
881454Sroot 
891454Sroot extern	char	*currentfilename;
901454Sroot extern	char	*processname;
911454Sroot extern	char	*scriptname;
921454Sroot 
931454Sroot extern	boolean	query;
945596Srrh extern	boolean	terse;
955596Srrh int	inquire();			/* inquire for yes/no */
965596Srrh /*
975596Srrh  *	codes for inquire() to return
985596Srrh  */
995596Srrh #define	Q_NO	1			/* 'N' */
1005596Srrh #define	Q_no	2			/* 'n' */
1015596Srrh #define	Q_YES	3			/* 'Y' */
1025596Srrh #define	Q_yes	4			/* 'y' */
1035596Srrh 
1045596Srrh int	probethisfile();
1051454Sroot /*
1065596Srrh  *	codes for probethisfile to return
1075596Srrh  */
1085596Srrh #define	F_NOTEXIST	1
1095596Srrh #define	F_NOTREAD	2
1105596Srrh #define	F_NOTWRITE	3
1115596Srrh #define	F_TOUCHIT	4
1125596Srrh 
1135596Srrh /*
1141454Sroot  *	Describes attributes about a language
1151454Sroot  */
1161454Sroot struct lang_desc{
1171454Sroot 	char	*lang_name;
1181454Sroot 	char	*lang_incomment;	/* one of the following defines */
1191454Sroot 	char	*lang_outcomment;	/* one of the following defines */
1201454Sroot };
1211454Sroot extern struct lang_desc lang_table[];
1221454Sroot 
1231454Sroot #define	CINCOMMENT	"/*###"
1241454Sroot #define	COUTCOMMENT	"%%%*/\n"
1251454Sroot #define	FINCOMMENT	"C###"
1261454Sroot #define	FOUTCOMMENT	"%%%\n"
1271454Sroot #define	NEWLINE		"%%%\n"
1281454Sroot #define	PIINCOMMENT	"(*###"
1291454Sroot #define	PIOUTCOMMENT	"%%%*)\n"
1301454Sroot #define	LISPINCOMMENT	";###"
1311454Sroot #define	ASINCOMMENT	"####"
1325596Srrh #define	RIINCOMMENT	CINCOMMENT
1331454Sroot #define	RIOUTCOMMENT	COUTCOMMENT
13413106Srrh #define	TROFFINCOMMENT	".\\\"###"
13513106Srrh #define	TROFFOUTCOMMENT	NEWLINE
13617499Srrh #define	MOD2INCOMMENT	"(*###"
13717499Srrh #define	MOD2OUTCOMMENT	"%%%*)\n"
1381454Sroot /*
1391454Sroot  *	Defines and resources for determing if a given line
1401454Sroot  *	is to be discarded because it refers to a file not to
1411454Sroot  *	be touched, or if the function reference is to a
1421454Sroot  *	function the user doesn't want recorded.
1431454Sroot  */
1441454Sroot 
1455596Srrh #define	ERRORNAME	"/.errorrc"
1461454Sroot int	nignored;
1471454Sroot char	**names_ignored;
1481454Sroot /*
1491454Sroot  *	Structure definition for a full error
1501454Sroot  */
1515596Srrh typedef struct edesc	Edesc;
1525596Srrh typedef	Edesc	*Eptr;
1535596Srrh 
1545596Srrh struct edesc{
1555596Srrh 	Eptr	error_next;		/*linked together*/
1561454Sroot 	int	error_lgtext;		/* how many on the right hand side*/
1571454Sroot 	char	**error_text;		/* the right hand side proper*/
1581454Sroot 	Errorclass	error_e_class;	/* error category of this error*/
1591454Sroot 	Errorclass	error_s_class;	/* sub descriptor of error_e_class*/
1601454Sroot 	int	error_language;		/* the language for this error*/
1611454Sroot 	int	error_position;		/* oridinal position */
1621454Sroot 	int	error_line;		/* discovered line number*/
1631454Sroot 	int	error_no;		/* sequence number on input */
1641454Sroot };
1651454Sroot /*
1661454Sroot  *	Resources for the true errors
1671454Sroot  */
1681454Sroot extern	int	nerrors;
1695596Srrh extern	Eptr	er_head;
1705596Srrh extern	Eptr	*errors;
1711454Sroot /*
1721454Sroot  *	Resources for each of the files mentioned
1731454Sroot  */
1741454Sroot extern	int	nfiles;
1755596Srrh extern	Eptr	**files;	/* array of pointers into errors*/
1765596Srrh boolean	*touchedfiles;			/* which files we touched */
1771454Sroot /*
1781454Sroot  *	The langauge the compilation is in, as intuited from
1791454Sroot  *	the flavor of error messages analyzed.
1801454Sroot  */
1811454Sroot extern	int	langauge;
1821454Sroot extern	char	*currentfilename;
1831454Sroot /*
1841454Sroot  *	Functional forwards
1851454Sroot  */
1861454Sroot char	*Calloc();
1871454Sroot char	*strsave();
1881454Sroot char	*clobberfirst();
1891454Sroot char	lastchar();
1901454Sroot char	firstchar();
1911454Sroot char	next_lastchar();
1921454Sroot char	**wordvsplice();
1931454Sroot int	wordvcmp();
1941454Sroot boolean	persperdexplode();
1955596Srrh /*
1965596Srrh  *	Printing hacks
1975596Srrh  */
1985596Srrh char	*plural(), *verbform();
199