break out special local mail processing (e.g., mapping to the
[unix-history] / usr / src / usr.bin / error / error.h
CommitLineData
442fe3bf 1/*
d6dcb673
KB
2 * Copyright (c) 1980, 1993
3 * The Regents of the University of California. All rights reserved.
442fe3bf 4 *
6ecf3d85 5 * %sccs.include.redist.c%
c9bf2796 6 *
d6dcb673 7 * @(#)error.h 8.1 (Berkeley) %G%
442fe3bf 8 */
524aa063 9
c7be6007 10typedef int boolean;
58195f21 11#define reg register
c7be6007
BJ
12
13#define TRUE 1
14#define FALSE 0
58195f21
RH
15
16#define true 1
17#define false 0
c7be6007
BJ
18/*
19 * Descriptors for the various languages we know about.
20 * If you touch these, also touch lang_table
21 */
22#define INUNKNOWN 0
23#define INCPP 1
24#define INCC 2
25#define INAS 3
26#define INLD 4
27#define INLINT 5
28#define INF77 6
29#define INPI 7
30#define INPC 8
31#define INFRANZ 9
32#define INLISP 10
33#define INVAXIMA 11
34#define INRATFOR 12
35#define INLEX 13
36#define INYACC 14
37#define INAPL 15
38#define INMAKE 16
39#define INRI 17
243bdea5 40#define INTROFF 18
07e24738 41#define INMOD2 19
c7be6007
BJ
42
43extern int language;
44/*
45 * We analyze each line in the error message file, and
46 * attempt to categorize it by type, as well as language.
47 * Here are the type descriptors.
48 */
49typedef int Errorclass;
50
58195f21 51#define C_FIRST 0 /* first error category */
c7be6007
BJ
52#define C_UNKNOWN 0 /* must be zero */
53#define C_IGNORE 1 /* ignore the message; used for pi */
54#define C_SYNC 2 /* synchronization errors */
55#define C_DISCARD 3 /* touches dangerous files, so discard */
56#define C_NONSPEC 4 /* not specific to any file */
57#define C_THISFILE 5 /* specific to this file, but at no line */
58#define C_NULLED 6 /* refers to special func; so null */
59#define C_TRUE 7 /* fits into true error format */
60#define C_DUPL 8 /* sub class only; duplicated error message */
58195f21 61#define C_LAST 9 /* last error category */
c7be6007
BJ
62
63#define SORTABLE(x) (!(NOTSORTABLE(x)))
64#define NOTSORTABLE(x) (x <= C_NONSPEC)
65/*
66 * Resources to count and print out the error categories
67 */
68extern char *class_table[];
69extern int class_count[];
70
71#define nunknown class_count[C_UNKNOWN]
72#define nignore class_count[C_IGNORE]
58195f21 73#define nsyncerrors class_count[C_SYNC]
c7be6007
BJ
74#define ndiscard class_count[C_DISCARD]
75#define nnonspec class_count[C_NONSPEC]
76#define nthisfile class_count[C_THISFILE]
58195f21
RH
77#define nnulled class_count[C_NULLED]
78#define ntrue class_count[C_TRUE]
c7be6007
BJ
79#define ndupl class_count[C_DUPL]
80
81/* places to put the error complaints */
82
58195f21 83#define TOTHEFILE 1 /* touch the file */
c7be6007
BJ
84#define TOSTDOUT 2 /* just print them out (ho-hum) */
85
86FILE *errorfile; /* where error file comes from */
87FILE *queryfile; /* where the query responses from the user come from*/
88
89extern char *currentfilename;
90extern char *processname;
91extern char *scriptname;
92
93extern boolean query;
58195f21
RH
94extern boolean terse;
95int inquire(); /* inquire for yes/no */
96/*
97 * codes for inquire() to return
98 */
99#define Q_NO 1 /* 'N' */
100#define Q_no 2 /* 'n' */
101#define Q_YES 3 /* 'Y' */
102#define Q_yes 4 /* 'y' */
103
104int probethisfile();
105/*
106 * codes for probethisfile to return
107 */
108#define F_NOTEXIST 1
109#define F_NOTREAD 2
110#define F_NOTWRITE 3
111#define F_TOUCHIT 4
112
c7be6007
BJ
113/*
114 * Describes attributes about a language
115 */
116struct lang_desc{
117 char *lang_name;
118 char *lang_incomment; /* one of the following defines */
119 char *lang_outcomment; /* one of the following defines */
120};
121extern struct lang_desc lang_table[];
122
123#define CINCOMMENT "/*###"
124#define COUTCOMMENT "%%%*/\n"
125#define FINCOMMENT "C###"
126#define FOUTCOMMENT "%%%\n"
127#define NEWLINE "%%%\n"
128#define PIINCOMMENT "(*###"
129#define PIOUTCOMMENT "%%%*)\n"
130#define LISPINCOMMENT ";###"
131#define ASINCOMMENT "####"
58195f21 132#define RIINCOMMENT CINCOMMENT
c7be6007 133#define RIOUTCOMMENT COUTCOMMENT
243bdea5
RH
134#define TROFFINCOMMENT ".\\\"###"
135#define TROFFOUTCOMMENT NEWLINE
07e24738
RH
136#define MOD2INCOMMENT "(*###"
137#define MOD2OUTCOMMENT "%%%*)\n"
c7be6007
BJ
138/*
139 * Defines and resources for determing if a given line
140 * is to be discarded because it refers to a file not to
141 * be touched, or if the function reference is to a
142 * function the user doesn't want recorded.
143 */
c7be6007 144
58195f21 145#define ERRORNAME "/.errorrc"
c7be6007
BJ
146int nignored;
147char **names_ignored;
148/*
149 * Structure definition for a full error
150 */
58195f21
RH
151typedef struct edesc Edesc;
152typedef Edesc *Eptr;
153
154struct edesc{
155 Eptr error_next; /*linked together*/
c7be6007
BJ
156 int error_lgtext; /* how many on the right hand side*/
157 char **error_text; /* the right hand side proper*/
158 Errorclass error_e_class; /* error category of this error*/
159 Errorclass error_s_class; /* sub descriptor of error_e_class*/
160 int error_language; /* the language for this error*/
161 int error_position; /* oridinal position */
162 int error_line; /* discovered line number*/
163 int error_no; /* sequence number on input */
164};
165/*
166 * Resources for the true errors
167 */
168extern int nerrors;
58195f21
RH
169extern Eptr er_head;
170extern Eptr *errors;
c7be6007
BJ
171/*
172 * Resources for each of the files mentioned
173 */
174extern int nfiles;
58195f21
RH
175extern Eptr **files; /* array of pointers into errors*/
176boolean *touchedfiles; /* which files we touched */
c7be6007
BJ
177/*
178 * The langauge the compilation is in, as intuited from
179 * the flavor of error messages analyzed.
180 */
181extern int langauge;
182extern char *currentfilename;
183/*
184 * Functional forwards
185 */
186char *Calloc();
187char *strsave();
188char *clobberfirst();
189char lastchar();
190char firstchar();
191char next_lastchar();
192char **wordvsplice();
193int wordvcmp();
194boolean persperdexplode();
58195f21
RH
195/*
196 * Printing hacks
197 */
198char *plural(), *verbform();