xref: /csrg-svn/usr.bin/error/error.h (revision 14545)
1*14545Ssam /*	error.h	1.4	83/08/11	*/
2*14545Ssam 
31454Sroot typedef	int	boolean;
45596Srrh #define	reg	register
51454Sroot 
61454Sroot #define	TRUE	1
71454Sroot #define	FALSE	0
85596Srrh 
95596Srrh #define	true	1
105596Srrh #define	false	0
111454Sroot /*
121454Sroot  *	Descriptors for the various languages we know about.
131454Sroot  *	If you touch these, also touch lang_table
141454Sroot  */
151454Sroot #define	INUNKNOWN	0
161454Sroot #define	INCPP	1
171454Sroot #define	INCC	2
181454Sroot #define	INAS	3
191454Sroot #define	INLD	4
201454Sroot #define	INLINT	5
211454Sroot #define	INF77	6
221454Sroot #define	INPI	7
231454Sroot #define	INPC	8
241454Sroot #define	INFRANZ	9
251454Sroot #define	INLISP	10
261454Sroot #define	INVAXIMA	11
271454Sroot #define	INRATFOR	12
281454Sroot #define	INLEX	13
291454Sroot #define	INYACC	14
301454Sroot #define	INAPL	15
311454Sroot #define	INMAKE	16
321454Sroot #define	INRI	17
3313106Srrh #define	INTROFF	18
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 
435596Srrh #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 */
535596Srrh #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]
655596Srrh #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]
695596Srrh #define	nnulled		class_count[C_NULLED]
705596Srrh #define	ntrue		class_count[C_TRUE]
711454Sroot #define	ndupl		class_count[C_DUPL]
721454Sroot 
731454Sroot /* places to put the error complaints */
741454Sroot 
755596Srrh #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;
865596Srrh extern	boolean	terse;
875596Srrh int	inquire();			/* inquire for yes/no */
885596Srrh /*
895596Srrh  *	codes for inquire() to return
905596Srrh  */
915596Srrh #define	Q_NO	1			/* 'N' */
925596Srrh #define	Q_no	2			/* 'n' */
935596Srrh #define	Q_YES	3			/* 'Y' */
945596Srrh #define	Q_yes	4			/* 'y' */
955596Srrh 
965596Srrh int	probethisfile();
971454Sroot /*
985596Srrh  *	codes for probethisfile to return
995596Srrh  */
1005596Srrh #define	F_NOTEXIST	1
1015596Srrh #define	F_NOTREAD	2
1025596Srrh #define	F_NOTWRITE	3
1035596Srrh #define	F_TOUCHIT	4
1045596Srrh 
1055596Srrh /*
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	"####"
1245596Srrh #define	RIINCOMMENT	CINCOMMENT
1251454Sroot #define	RIOUTCOMMENT	COUTCOMMENT
12613106Srrh #define	TROFFINCOMMENT	".\\\"###"
12713106Srrh #define	TROFFOUTCOMMENT	NEWLINE
1281454Sroot /*
1291454Sroot  *	Defines and resources for determing if a given line
1301454Sroot  *	is to be discarded because it refers to a file not to
1311454Sroot  *	be touched, or if the function reference is to a
1321454Sroot  *	function the user doesn't want recorded.
1331454Sroot  */
1345596Srrh #define	IG_FILE1	"llib-lc"
1355596Srrh #define	IG_FILE2	"llib-port"
1361454Sroot #define	IG_FILE3	"/usr/lib/llib-lc"
1371454Sroot #define	IG_FILE4	"/usr/lib/llib-port"
1381454Sroot 
1395596Srrh #define	ERRORNAME	"/.errorrc"
1401454Sroot int	nignored;
1411454Sroot char	**names_ignored;
1421454Sroot /*
1431454Sroot  *	Structure definition for a full error
1441454Sroot  */
1455596Srrh typedef struct edesc	Edesc;
1465596Srrh typedef	Edesc	*Eptr;
1475596Srrh 
1485596Srrh struct edesc{
1495596Srrh 	Eptr	error_next;		/*linked together*/
1501454Sroot 	int	error_lgtext;		/* how many on the right hand side*/
1511454Sroot 	char	**error_text;		/* the right hand side proper*/
1521454Sroot 	Errorclass	error_e_class;	/* error category of this error*/
1531454Sroot 	Errorclass	error_s_class;	/* sub descriptor of error_e_class*/
1541454Sroot 	int	error_language;		/* the language for this error*/
1551454Sroot 	int	error_position;		/* oridinal position */
1561454Sroot 	int	error_line;		/* discovered line number*/
1571454Sroot 	int	error_no;		/* sequence number on input */
1581454Sroot };
1591454Sroot /*
1601454Sroot  *	Resources for the true errors
1611454Sroot  */
1621454Sroot extern	int	nerrors;
1635596Srrh extern	Eptr	er_head;
1645596Srrh extern	Eptr	*errors;
1651454Sroot /*
1661454Sroot  *	Resources for each of the files mentioned
1671454Sroot  */
1681454Sroot extern	int	nfiles;
1695596Srrh extern	Eptr	**files;	/* array of pointers into errors*/
1705596Srrh boolean	*touchedfiles;			/* which files we touched */
1711454Sroot /*
1721454Sroot  *	The langauge the compilation is in, as intuited from
1731454Sroot  *	the flavor of error messages analyzed.
1741454Sroot  */
1751454Sroot extern	int	langauge;
1761454Sroot extern	char	*currentfilename;
1771454Sroot /*
1781454Sroot  *	Functional forwards
1791454Sroot  */
1801454Sroot char	*Calloc();
1811454Sroot char	*strsave();
1821454Sroot char	*clobberfirst();
1831454Sroot char	lastchar();
1841454Sroot char	firstchar();
1851454Sroot char	next_lastchar();
1861454Sroot char	**wordvsplice();
1871454Sroot int	wordvcmp();
1881454Sroot boolean	persperdexplode();
1895596Srrh /*
1905596Srrh  *	Printing hacks
1915596Srrh  */
1925596Srrh char	*plural(), *verbform();
193