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