xref: /csrg-svn/usr.bin/error/error.h (revision 13106)
11454Sroot /*
2*13106Srrh  *  @(#)error.h	1.3 (Berkeley) 06/14/83
31454Sroot  */
41454Sroot typedef	int	boolean;
55596Srrh #define	reg	register
61454Sroot 
71454Sroot #define	TRUE	1
81454Sroot #define	FALSE	0
95596Srrh 
105596Srrh #define	true	1
115596Srrh #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
34*13106Srrh #define	INTROFF	18
351454Sroot 
361454Sroot extern	int	language;
371454Sroot /*
381454Sroot  *	We analyze each line in the error message file, and
391454Sroot  *	attempt to categorize it by type, as well as language.
401454Sroot  *	Here are the type descriptors.
411454Sroot  */
421454Sroot typedef	int	Errorclass;
431454Sroot 
445596Srrh #define	C_FIRST	0		/* first error category */
451454Sroot #define	C_UNKNOWN	0	/* must be zero */
461454Sroot #define	C_IGNORE	1	/* ignore the message; used for pi */
471454Sroot #define	C_SYNC		2	/* synchronization errors */
481454Sroot #define	C_DISCARD	3	/* touches dangerous files, so discard */
491454Sroot #define	C_NONSPEC	4	/* not specific to any file */
501454Sroot #define	C_THISFILE	5	/* specific to this file, but at no line */
511454Sroot #define	C_NULLED	6	/* refers to special func; so null */
521454Sroot #define	C_TRUE		7	/* fits into true error format */
531454Sroot #define	C_DUPL		8	/* sub class only; duplicated error message */
545596Srrh #define	C_LAST	9		/* last error category */
551454Sroot 
561454Sroot #define	SORTABLE(x)	(!(NOTSORTABLE(x)))
571454Sroot #define	NOTSORTABLE(x)	(x <= C_NONSPEC)
581454Sroot /*
591454Sroot  *	Resources to count and print out the error categories
601454Sroot  */
611454Sroot extern	char		*class_table[];
621454Sroot extern	int		class_count[];
631454Sroot 
641454Sroot #define	nunknown	class_count[C_UNKNOWN]
651454Sroot #define	nignore		class_count[C_IGNORE]
665596Srrh #define	nsyncerrors	class_count[C_SYNC]
671454Sroot #define	ndiscard	class_count[C_DISCARD]
681454Sroot #define	nnonspec	class_count[C_NONSPEC]
691454Sroot #define	nthisfile	class_count[C_THISFILE]
705596Srrh #define	nnulled		class_count[C_NULLED]
715596Srrh #define	ntrue		class_count[C_TRUE]
721454Sroot #define	ndupl		class_count[C_DUPL]
731454Sroot 
741454Sroot /* places to put the error complaints */
751454Sroot 
765596Srrh #define	TOTHEFILE	1	/* touch the file */
771454Sroot #define	TOSTDOUT	2	/* just print them out (ho-hum) */
781454Sroot 
791454Sroot FILE	*errorfile;	/* where error file comes from */
801454Sroot FILE	*queryfile;	/* where the query responses from the user come from*/
811454Sroot 
821454Sroot extern	char	*currentfilename;
831454Sroot extern	char	*processname;
841454Sroot extern	char	*scriptname;
851454Sroot 
861454Sroot extern	boolean	query;
875596Srrh extern	boolean	terse;
885596Srrh int	inquire();			/* inquire for yes/no */
895596Srrh /*
905596Srrh  *	codes for inquire() to return
915596Srrh  */
925596Srrh #define	Q_NO	1			/* 'N' */
935596Srrh #define	Q_no	2			/* 'n' */
945596Srrh #define	Q_YES	3			/* 'Y' */
955596Srrh #define	Q_yes	4			/* 'y' */
965596Srrh 
975596Srrh int	probethisfile();
981454Sroot /*
995596Srrh  *	codes for probethisfile to return
1005596Srrh  */
1015596Srrh #define	F_NOTEXIST	1
1025596Srrh #define	F_NOTREAD	2
1035596Srrh #define	F_NOTWRITE	3
1045596Srrh #define	F_TOUCHIT	4
1055596Srrh 
1065596Srrh /*
1071454Sroot  *	Describes attributes about a language
1081454Sroot  */
1091454Sroot struct lang_desc{
1101454Sroot 	char	*lang_name;
1111454Sroot 	char	*lang_incomment;	/* one of the following defines */
1121454Sroot 	char	*lang_outcomment;	/* one of the following defines */
1131454Sroot };
1141454Sroot extern struct lang_desc lang_table[];
1151454Sroot 
1161454Sroot #define	CINCOMMENT	"/*###"
1171454Sroot #define	COUTCOMMENT	"%%%*/\n"
1181454Sroot #define	FINCOMMENT	"C###"
1191454Sroot #define	FOUTCOMMENT	"%%%\n"
1201454Sroot #define	NEWLINE		"%%%\n"
1211454Sroot #define	PIINCOMMENT	"(*###"
1221454Sroot #define	PIOUTCOMMENT	"%%%*)\n"
1231454Sroot #define	LISPINCOMMENT	";###"
1241454Sroot #define	ASINCOMMENT	"####"
1255596Srrh #define	RIINCOMMENT	CINCOMMENT
1261454Sroot #define	RIOUTCOMMENT	COUTCOMMENT
127*13106Srrh #define	TROFFINCOMMENT	".\\\"###"
128*13106Srrh #define	TROFFOUTCOMMENT	NEWLINE
1291454Sroot /*
1301454Sroot  *	Defines and resources for determing if a given line
1311454Sroot  *	is to be discarded because it refers to a file not to
1321454Sroot  *	be touched, or if the function reference is to a
1331454Sroot  *	function the user doesn't want recorded.
1341454Sroot  */
1355596Srrh #define	IG_FILE1	"llib-lc"
1365596Srrh #define	IG_FILE2	"llib-port"
1371454Sroot #define	IG_FILE3	"/usr/lib/llib-lc"
1381454Sroot #define	IG_FILE4	"/usr/lib/llib-port"
1391454Sroot 
1405596Srrh #define	ERRORNAME	"/.errorrc"
1411454Sroot int	nignored;
1421454Sroot char	**names_ignored;
1431454Sroot /*
1441454Sroot  *	Structure definition for a full error
1451454Sroot  */
1465596Srrh typedef struct edesc	Edesc;
1475596Srrh typedef	Edesc	*Eptr;
1485596Srrh 
1495596Srrh struct edesc{
1505596Srrh 	Eptr	error_next;		/*linked together*/
1511454Sroot 	int	error_lgtext;		/* how many on the right hand side*/
1521454Sroot 	char	**error_text;		/* the right hand side proper*/
1531454Sroot 	Errorclass	error_e_class;	/* error category of this error*/
1541454Sroot 	Errorclass	error_s_class;	/* sub descriptor of error_e_class*/
1551454Sroot 	int	error_language;		/* the language for this error*/
1561454Sroot 	int	error_position;		/* oridinal position */
1571454Sroot 	int	error_line;		/* discovered line number*/
1581454Sroot 	int	error_no;		/* sequence number on input */
1591454Sroot };
1601454Sroot /*
1611454Sroot  *	Resources for the true errors
1621454Sroot  */
1631454Sroot extern	int	nerrors;
1645596Srrh extern	Eptr	er_head;
1655596Srrh extern	Eptr	*errors;
1661454Sroot /*
1671454Sroot  *	Resources for each of the files mentioned
1681454Sroot  */
1691454Sroot extern	int	nfiles;
1705596Srrh extern	Eptr	**files;	/* array of pointers into errors*/
1715596Srrh boolean	*touchedfiles;			/* which files we touched */
1721454Sroot /*
1731454Sroot  *	The langauge the compilation is in, as intuited from
1741454Sroot  *	the flavor of error messages analyzed.
1751454Sroot  */
1761454Sroot extern	int	langauge;
1771454Sroot extern	char	*currentfilename;
1781454Sroot /*
1791454Sroot  *	Functional forwards
1801454Sroot  */
1811454Sroot char	*Calloc();
1821454Sroot char	*strsave();
1831454Sroot char	*clobberfirst();
1841454Sroot char	lastchar();
1851454Sroot char	firstchar();
1861454Sroot char	next_lastchar();
1871454Sroot char	**wordvsplice();
1881454Sroot int	wordvcmp();
1891454Sroot boolean	persperdexplode();
1905596Srrh /*
1915596Srrh  *	Printing hacks
1925596Srrh  */
1935596Srrh char	*plural(), *verbform();
194