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