4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
44 * Descriptors for the various languages we know about.
45 * If you touch these, also touch lang_table
71 extern boolean notouch
;
74 * We analyze each line in the error message file, and
75 * attempt to categorize it by type, as well as language.
76 * Here are the type descriptors.
78 typedef int Errorclass
;
80 #define C_FIRST 0 /* first error category */
81 #define C_UNKNOWN 0 /* must be zero */
82 #define C_IGNORE 1 /* ignore the message; used for pi */
83 #define C_SYNC 2 /* synchronization errors */
84 #define C_DISCARD 3 /* touches dangerous files, so discard */
85 #define C_NONSPEC 4 /* not specific to any file */
86 #define C_THISFILE 5 /* specific to this file, but at no line */
87 #define C_NULLED 6 /* refers to special func; so null */
88 #define C_TRUE 7 /* fits into true error format */
89 #define C_DUPL 8 /* sub class only; duplicated error message */
90 #define C_LAST 9 /* last error category */
92 #define SORTABLE(x) (!(NOTSORTABLE(x)))
93 #define NOTSORTABLE(x) (x <= C_NONSPEC)
95 * Resources to count and print out the error categories
97 extern char *class_table
[];
98 extern int class_count
[];
100 #define nunknown class_count[C_UNKNOWN]
101 #define nignore class_count[C_IGNORE]
102 #define nsyncerrors class_count[C_SYNC]
103 #define ndiscard class_count[C_DISCARD]
104 #define nnonspec class_count[C_NONSPEC]
105 #define nthisfile class_count[C_THISFILE]
106 #define nnulled class_count[C_NULLED]
107 #define ntrue class_count[C_TRUE]
108 #define ndupl class_count[C_DUPL]
110 /* places to put the error complaints */
112 #define TOTHEFILE 1 /* touch the file */
113 #define TOSTDOUT 2 /* just print them out (ho-hum) */
115 FILE *errorfile
; /* where error file comes from */
116 FILE *queryfile
; /* where the query responses from the user come from */
118 extern char *currentfilename
;
119 extern char *processname
;
120 extern char *scriptname
;
122 extern boolean query
;
123 extern boolean terse
;
124 int inquire(char *format
, ...); /* inquire for yes/no */
126 * codes for inquire() to return
128 #define Q_NO 1 /* 'N' */
129 #define Q_no 2 /* 'n' */
130 #define Q_YES 3 /* 'Y' */
131 #define Q_yes 4 /* 'y' */
133 int probethisfile(char *name
);
135 * codes for probethisfile to return
143 * Describes attributes about a language
147 char *lang_incomment
; /* one of the following defines */
148 char *lang_outcomment
; /* one of the following defines */
150 extern struct lang_desc lang_table
[];
152 #define CINCOMMENT "/*###"
153 #define COUTCOMMENT "%%%*/\n"
154 #define FINCOMMENT "C###"
155 #define FOUTCOMMENT "%%%\n"
156 #define NEWLINE "%%%\n"
157 #define PIINCOMMENT "(*###"
158 #define PIOUTCOMMENT "%%%*)\n"
159 #define LISPINCOMMENT ";###"
160 #define ASINCOMMENT "####"
161 #define RIINCOMMENT CINCOMMENT
162 #define RIOUTCOMMENT COUTCOMMENT
163 #define TROFFINCOMMENT ".\\\"###"
164 #define TROFFOUTCOMMENT NEWLINE
165 #define MOD2INCOMMENT "(*###"
166 #define MOD2OUTCOMMENT "%%%*)\n"
168 * Defines and resources for determing if a given line
169 * is to be discarded because it refers to a file not to
170 * be touched, or if the function reference is to a
171 * function the user doesn't want recorded.
173 #define IG_FILE1 "llib-lc"
174 #define IG_FILE2 "llib-port"
175 #define IG_FILE3 "/usr/lib/llib-lc"
176 #define IG_FILE4 "/usr/lib/llib-port"
178 #define ERRORNAME "/.errorrc"
180 char **names_ignored
;
182 * Structure definition for a full error
184 typedef struct edesc Edesc
;
188 Eptr error_next
; /* linked together */
189 int error_lgtext
; /* how many on the right hand side */
190 char **error_text
; /* the right hand side proper */
191 Errorclass error_e_class
; /* error category of this error */
192 Errorclass error_s_class
; /* sub descriptor of error_e_class */
193 int error_language
; /* the language for this error */
194 int error_position
; /* oridinal position */
195 int error_line
; /* discovered line number */
196 int error_no
; /* sequence number on input */
199 * Resources for the true errors
205 * Resources for each of the files mentioned
208 extern Eptr
**files
; /* array of pointers into errors */
209 boolean
*touchedfiles
; /* which files we touched */
211 * The langauge the compilation is in, as intuited from
212 * the flavor of error messages analyzed.
215 extern char *currentfilename
;
217 * Functional forwards
219 void *Calloc(int nelements
, int size
);
220 char *strsave(char *instring
);
221 char lastchar(char *string
);
222 char firstchar(char *string
);
223 char next_lastchar(char *string
);
224 char **wordvsplice(int emptyhead
, int wordc
, char **wordv
);
225 int wordvcmp(char **wordv1
, int wordc
, char **wordv2
);
226 boolean
persperdexplode(char *string
, char **r_perd
, char **r_pers
);
231 char *verbform(int n
);
233 void erroradd(int errorlength
, char **errorv
, Errorclass errorclass
,
234 Errorclass errorsubclass
);
235 void eaterrors(int *r_errorc
, Eptr
**r_errorv
);
236 void wordvbuild(char *string
, int *r_wordc
, char ***r_wordv
);
237 void wordvprint(FILE *fyle
, int wordc
, char *wordv
[]);
238 void printerrors(boolean look_at_subclass
, int errorc
, Eptr errorv
[]);
239 void clob_last(char *string
, char newstuff
);
240 void arrayify(int *e_length
, Eptr
**e_array
, Eptr header
);
241 void getignored(char *auxname
);
242 void filenames(int nfiles
, Eptr
**files
);
243 void findfiles(int nerrors
, Eptr
*errors
, int *r_nfiles
, Eptr
***r_files
);
244 void onintr(int sig
);
245 boolean
touchfiles(int nfiles
, Eptr
**files
, int *r_edargc
, char ***r_edargv
);
246 Errorclass
discardit(Eptr errorp
);
247 char *substitute(char *string
, char chold
, char chnew
);
248 int position(char *string
, char ch
);
254 #endif /* _ERROR_H */