2 |
7u83 |
1 |
/*
|
6 |
7u83 |
2 |
* Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
*
|
|
|
5 |
* Redistribution and use in source and binary forms, with or without
|
|
|
6 |
* modification, are permitted provided that the following conditions are met:
|
|
|
7 |
*
|
|
|
8 |
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
9 |
* this list of conditions and the following disclaimer.
|
|
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
11 |
* this list of conditions and the following disclaimer in the documentation
|
|
|
12 |
* and/or other materials provided with the distribution.
|
|
|
13 |
* 3. Neither the name of The TenDRA Project nor the names of its contributors
|
|
|
14 |
* may be used to endorse or promote products derived from this software
|
|
|
15 |
* without specific, prior written permission.
|
|
|
16 |
*
|
|
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
|
|
18 |
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
19 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
|
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
22 |
* EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
23 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
|
24 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
25 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
|
26 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
27 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
28 |
*
|
|
|
29 |
* $Id$
|
|
|
30 |
*/
|
|
|
31 |
/*
|
2 |
7u83 |
32 |
Crown Copyright (c) 1997
|
6 |
7u83 |
33 |
|
2 |
7u83 |
34 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
35 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
36 |
acting through the Defence Evaluation and Research Agency
|
|
|
37 |
(DERA). It is made available to Recipients with a
|
|
|
38 |
royalty-free licence for its use, reproduction, transfer
|
|
|
39 |
to other parties and amendment for any purpose not excluding
|
|
|
40 |
product development provided that any such use et cetera
|
|
|
41 |
shall be deemed to be acceptance of the following conditions:-
|
6 |
7u83 |
42 |
|
2 |
7u83 |
43 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
44 |
reproduced upon any copies or amended versions of it;
|
6 |
7u83 |
45 |
|
2 |
7u83 |
46 |
(2) Any amended version of it shall be clearly marked to
|
|
|
47 |
show both the nature of and the organisation responsible
|
|
|
48 |
for the relevant amendment or amendments;
|
6 |
7u83 |
49 |
|
2 |
7u83 |
50 |
(3) Its onward transfer from a recipient to another
|
|
|
51 |
party shall be deemed to be that party's acceptance of
|
|
|
52 |
these conditions;
|
6 |
7u83 |
53 |
|
2 |
7u83 |
54 |
(4) DERA gives no warranty or assurance as to its
|
|
|
55 |
quality or suitability for any purpose and DERA accepts
|
|
|
56 |
no liability whatsoever in relation to any use to which
|
|
|
57 |
it may be put.
|
|
|
58 |
*/
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
/**** error.h --- Error reporting.
|
|
|
62 |
*
|
|
|
63 |
** Author: Steve Folkes <smf@hermes.mod.uk>
|
|
|
64 |
*
|
|
|
65 |
**** Commentary:
|
|
|
66 |
*
|
|
|
67 |
***=== INTRODUCTION =========================================================
|
|
|
68 |
*
|
|
|
69 |
* This file specifies the interface to an error message reporting facility.
|
|
|
70 |
* This facility allows for named errors, with variables (called tags) inside
|
|
|
71 |
* the error messages. This allows the messages to be redefined (e.g. in a
|
|
|
72 |
* different language) with the variable components of the message in a
|
|
|
73 |
* different order.
|
|
|
74 |
*
|
|
|
75 |
* In addition to the error mesage support, this facility also provides
|
|
|
76 |
* support for named strings whose text may be redefined. This is useful for
|
|
|
77 |
* allowing the text of help messages to be redefined.
|
|
|
78 |
*
|
|
|
79 |
***=== TYPES ================================================================
|
|
|
80 |
*
|
|
|
81 |
** Type: EseverityT
|
|
|
82 |
** Type: EseverityP
|
|
|
83 |
** Repr: enum {ERROR_SEVERITY_INFORMATION, ERROR_SEVERITY_WARNING,
|
|
|
84 |
* ERROR_SEVERITY_ERROR, ERROR_SEVERITY_FATAL,
|
|
|
85 |
* ERROR_SEVERITY_INTERNAL}
|
|
|
86 |
*
|
|
|
87 |
* This is the error severity level type. The lowest error severity is
|
|
|
88 |
* ``ERROR_SEVERITY_INFORMATION'', which is used for information messages (not
|
|
|
89 |
* normally printed out). The highest severity of error is
|
|
|
90 |
* ``ERROR_SEVERITY_INTERNAL'' which is used for internal program errors.
|
|
|
91 |
*
|
|
|
92 |
** Type: ETagT
|
|
|
93 |
** Type: ETagP
|
|
|
94 |
** Repr: <private>
|
|
|
95 |
*
|
|
|
96 |
* This is the error tag type. A tag is used to represent a variable inside
|
|
|
97 |
* an error message, such as the file name in which the error occured. A
|
|
|
98 |
* string of the form "${tag name}" inside an error message is replaced by the
|
|
|
99 |
* tag of the same name.
|
|
|
100 |
*
|
|
|
101 |
** Type: ErrorListT
|
|
|
102 |
** Type: ErrorListP
|
|
|
103 |
** Repr: <private>
|
|
|
104 |
*
|
|
|
105 |
* This is used by the error type.
|
|
|
106 |
*
|
|
|
107 |
** Type: ErrorT
|
|
|
108 |
** Type: ErrorP
|
|
|
109 |
** Repr: <private>
|
|
|
110 |
*
|
|
|
111 |
* This is the error type.
|
|
|
112 |
*
|
|
|
113 |
** Type: EStringT
|
|
|
114 |
** Type: EStringP
|
|
|
115 |
** Repr: <private>
|
|
|
116 |
*
|
|
|
117 |
* This is the named string type.
|
|
|
118 |
*
|
|
|
119 |
** Type: ErrorProcP
|
6 |
7u83 |
120 |
** Repr: void (*) (OStreamP, ETagP, GenericP)
|
2 |
7u83 |
121 |
*
|
|
|
122 |
* This is the type of a procedure that is used to display the contents of a
|
|
|
123 |
* tag when reporting an error.
|
|
|
124 |
*
|
|
|
125 |
** Type: ErrorInitProcP
|
6 |
7u83 |
126 |
** Repr: void (*) (void)
|
2 |
7u83 |
127 |
*
|
|
|
128 |
* This is the type of the procedure that will be called to define all of the
|
|
|
129 |
* error messages for the current program.
|
|
|
130 |
*
|
|
|
131 |
** Type: ETagDataT
|
|
|
132 |
** Type: ETagDataP
|
|
|
133 |
** Repr: union {CStringP name; ETagP tag;}
|
|
|
134 |
*
|
|
|
135 |
* This is the type of an element in a vector of error tags to be passed to
|
|
|
136 |
* the ``error_intern_tags'' function. The vector should be initialised with
|
|
|
137 |
* the tag names (surrounded by the ``UB'' and ``UE'' macros for union
|
|
|
138 |
* initialisation), terminated by the ``ERROR_END_TAG_LIST'' macro, e.g.
|
|
|
139 |
*
|
|
|
140 |
* static ETagDataT tags [] = {
|
|
|
141 |
* UB "tag 1" UE,
|
|
|
142 |
* UB "tag 2" UE,
|
|
|
143 |
* ERROR_END_TAG_LIST
|
|
|
144 |
* };
|
|
|
145 |
*
|
|
|
146 |
* Once the ``error_intern_tags'' function has been called, the ``tag'' field
|
|
|
147 |
* should be used to access the tag object.
|
|
|
148 |
*
|
|
|
149 |
** Type: ErrorDataT
|
|
|
150 |
** Type: ErrorDataP
|
|
|
151 |
** Repr: union {struct {CStringP name; EseverityP severity;
|
|
|
152 |
* CStringP message; GenericP data;} s;
|
|
|
153 |
* ErrorP error;}
|
|
|
154 |
*
|
|
|
155 |
* This is the type of an element in a vector of errors to be passed to the
|
|
|
156 |
* ``error_intern_errors'' function. The vector should be initialised with
|
|
|
157 |
* the error names, severity levels, message text, and a pointer to a
|
|
|
158 |
* non-function object (all surrounded by the ``UB'' and ``UE'' macros for
|
|
|
159 |
* union initialisation). The vector should be terminated by the
|
|
|
160 |
* ``ERROR_END_ERROR_LIST'' macro, e.g.
|
|
|
161 |
*
|
|
|
162 |
* static ErrorDataT errors [] = {
|
|
|
163 |
* UB {
|
|
|
164 |
* "error 1", ERROR_SEVERITY_ERROR,
|
|
|
165 |
* "error 1 occured at line ${line}", NIL (GenericP)
|
|
|
166 |
* } UE, ERROR_END_ERROR_LIST
|
|
|
167 |
* };
|
|
|
168 |
*
|
|
|
169 |
* Once the ``error_intern_errors'' function has been called, the ``error''
|
|
|
170 |
* field should be used to access the error object.
|
|
|
171 |
*
|
|
|
172 |
*
|
|
|
173 |
** Type: EStringDataT
|
|
|
174 |
** Type: EStringDataP
|
|
|
175 |
** Repr: union {struct {CStringP name; CStringP contents;} s;
|
|
|
176 |
* EStringP estring;}
|
|
|
177 |
*
|
|
|
178 |
* This is the type of an element in a vector of named strings to be passed to
|
|
|
179 |
* the ``error_intern_strings'' function. The vector should be initialised
|
|
|
180 |
* with the string names and contents (all surrounded by the ``UB'' and ``UE''
|
|
|
181 |
* macros for union initialisation). The vector should be terminated by the
|
|
|
182 |
* ``ERROR_END_STRING_LIST'' macro, e.g.
|
|
|
183 |
*
|
|
|
184 |
* static EStringDataT strings [] = {
|
|
|
185 |
* UB {"string name", "string contents"} UE,
|
|
|
186 |
* ERROR_END_STRING_LIST
|
|
|
187 |
* };
|
|
|
188 |
*
|
|
|
189 |
* Once the ``error_intern_strings'' function has been called, the ``estring''
|
|
|
190 |
* field should be used to access the error string object.
|
|
|
191 |
*
|
|
|
192 |
** Type: ErrorStatusT
|
|
|
193 |
** Type: ErrorStatusP
|
|
|
194 |
** Repr: enum {ERROR_STATUS_BAD_MESSAGE, ERROR_STATUS_SUCCESS,
|
|
|
195 |
* ERROR_STATUS_BAD_ERROR}
|
|
|
196 |
*
|
|
|
197 |
* This is the return type of the ``error_redefine_error'' function.
|
|
|
198 |
*
|
|
|
199 |
***=== FUNCTIONS ============================================================
|
|
|
200 |
*
|
|
|
201 |
** Function: void error_init
|
6 |
7u83 |
202 |
* (CStringP program, ErrorInitProcP proc)
|
2 |
7u83 |
203 |
** Exceptions: XX_dalloc_no_memory
|
|
|
204 |
*
|
|
|
205 |
* This function initialises the error reporting mechanism. It should only be
|
|
|
206 |
* called once, at the start of the program. The basename of the program
|
|
|
207 |
* string is used as the program name, for the "${program name}" tag. The
|
|
|
208 |
* procedure is registered as the error initialisation procedure. The error
|
|
|
209 |
* initialisation procedure should be called once before attempting to report
|
|
|
210 |
* errors. The best way of doing this, is to call the
|
|
|
211 |
* ``error_call_init_proc'' function which guarantees to only call the
|
|
|
212 |
* function once. Note that the error initialisation procedure is not
|
|
|
213 |
* expected to be used to initialise named strings: these should be explicitly
|
|
|
214 |
* initialised before they are used.
|
|
|
215 |
*
|
|
|
216 |
** Function: void error_call_init_proc
|
6 |
7u83 |
217 |
* (void)
|
2 |
7u83 |
218 |
** Exceptions:
|
|
|
219 |
*
|
|
|
220 |
* This calls the error initialisation procedure if it has not already been
|
|
|
221 |
* called. This function should be called before ``error_report'' (actually,
|
|
|
222 |
* it should be called before the error value that will be passed to that
|
|
|
223 |
* function is accessed).
|
|
|
224 |
*
|
|
|
225 |
** Function: ETagP error_define_tag
|
6 |
7u83 |
226 |
* (CStringP name)
|
2 |
7u83 |
227 |
** Exceptions: XX_dalloc_no_memory
|
|
|
228 |
*
|
|
|
229 |
* This function defines a tag with the specified name, and returns it. The
|
|
|
230 |
* name should not be modified or deallocated. It is possible to define the
|
|
|
231 |
* same tag more than once (but the same value will be returned each time).
|
|
|
232 |
*
|
|
|
233 |
** Function: ErrorP error_define_error
|
6 |
7u83 |
234 |
* (CStringP name, ESeverityT severity,
|
|
|
235 |
* CStringP message, GenericP data)
|
2 |
7u83 |
236 |
** Exceptions: XX_dalloc_no_memory
|
|
|
237 |
*
|
|
|
238 |
* This function defines an error with the specified name, and returns it.
|
|
|
239 |
* The name should not be modified or deallocated. The severity level is used
|
|
|
240 |
* to decide whether or not an error should be shown and whether or not the
|
|
|
241 |
* program should abort, when the ``error_report'' function is called. The
|
|
|
242 |
* message is split up into a list of strings and tags, which will be printed
|
|
|
243 |
* when the error is reported (the sequence "${tag name}" will be replaced by
|
|
|
244 |
* the value of the tag when the error is reported). The data is for use by
|
|
|
245 |
* the program.
|
|
|
246 |
*
|
|
|
247 |
** Function: void error_intern_tags
|
6 |
7u83 |
248 |
* (ETagDataP vector)
|
2 |
7u83 |
249 |
** Exceptions: XX_dalloc_no_memory
|
|
|
250 |
*
|
|
|
251 |
* This function changes the name entries in the specified vector into error
|
|
|
252 |
* tags. The vector should be terminated by the macro ``ERROR_END_TAG_LIST''.
|
|
|
253 |
* This function should only be called once on any vector.
|
|
|
254 |
*
|
|
|
255 |
** Function: void error_intern_errors
|
6 |
7u83 |
256 |
* (ErrorDataP vector)
|
2 |
7u83 |
257 |
** Exceptions: XX_dalloc_no_memory
|
|
|
258 |
*
|
|
|
259 |
* This function changes the name entries in the specified vector into errors.
|
|
|
260 |
* The vector should be terminated by the macro ``ERROR_END_ERROR_LIST''.
|
|
|
261 |
* This function should only be called once on any vector.
|
|
|
262 |
*
|
|
|
263 |
** Function: ErrorStatusT error_redefine_error
|
6 |
7u83 |
264 |
* (CStringP name, CStringP message)
|
2 |
7u83 |
265 |
** Exceptions: XX_dalloc_no_memory
|
|
|
266 |
*
|
|
|
267 |
* This function changes the error message for the error with the specified
|
|
|
268 |
* name. If necessary, the error initialisation procedure will be called to
|
|
|
269 |
* initialise the errors before they are redefined. If the error does not
|
|
|
270 |
* exist, the function will return ``ERROR_STATUS_BAD_ERROR''. If the error
|
|
|
271 |
* message contains an unterminated tag, the function will return
|
|
|
272 |
* ``ERROR_STATUS_BAD_MESSAGE''. If the function succeeds, it will return
|
|
|
273 |
* ``ERROR_STATUS_SUCCESS''.
|
|
|
274 |
*
|
|
|
275 |
** Function: ErrorP error_lookup_error
|
6 |
7u83 |
276 |
* (CStringP name)
|
2 |
7u83 |
277 |
** Exceptions:
|
|
|
278 |
*
|
|
|
279 |
* This function returns the error with the specified name. If the error does
|
|
|
280 |
* not exist, it returns the null pointer. If necessary, the error
|
|
|
281 |
* initialisation procedure will be called to initialise the error messages
|
|
|
282 |
* before they are looked up.
|
|
|
283 |
*
|
|
|
284 |
** Function: GenericP error_data
|
6 |
7u83 |
285 |
* (ErrorP error)
|
2 |
7u83 |
286 |
** Exceptions:
|
|
|
287 |
*
|
|
|
288 |
* This function returns the data associated with the specified error.
|
|
|
289 |
*
|
|
|
290 |
** Function: void error_report
|
6 |
7u83 |
291 |
* (ErrorP error, ErrorProcP proc,
|
|
|
292 |
* GenericP closure)
|
2 |
7u83 |
293 |
** Exceptions: XX_dalloc_no_memory, XX_ostream_write_error
|
|
|
294 |
*
|
|
|
295 |
* This function reports the specified error. The procedure is used to print
|
|
|
296 |
* out information for tags. It is called with the output stream, the tag and
|
|
|
297 |
* the specified closure. If the procedure doesn't know about the tag, it
|
|
|
298 |
* should ignore it. The error message is only reported if the severity level
|
|
|
299 |
* of the error is greater than or equal to the minimum severity level set by
|
|
|
300 |
* the ``error_set_min_severity'' function. The function will cause the
|
|
|
301 |
* program to exit if the error's severity level is ``ERROR_SEVERITY_FATAL''
|
|
|
302 |
* or higher.
|
|
|
303 |
*
|
|
|
304 |
** Function: void error_set_min_report_severity
|
6 |
7u83 |
305 |
* (ESeverityT severity)
|
2 |
7u83 |
306 |
** Exceptions:
|
|
|
307 |
*
|
|
|
308 |
* This function sets the minimum severity of error that should be reported.
|
|
|
309 |
*
|
|
|
310 |
** Function: ESeverityT error_get_min_report_severity
|
6 |
7u83 |
311 |
* (void)
|
2 |
7u83 |
312 |
** Exceptions:
|
|
|
313 |
*
|
|
|
314 |
* This function returns the minimum severity of error that will be reported.
|
|
|
315 |
*
|
|
|
316 |
** Function: ESeverityT error_max_reported_severity
|
6 |
7u83 |
317 |
* (void)
|
2 |
7u83 |
318 |
** Exceptions:
|
|
|
319 |
*
|
|
|
320 |
* This function returns the severity of the error with the highest severity
|
|
|
321 |
* that has been passed to ``error_report''.
|
|
|
322 |
*
|
|
|
323 |
** Function: void error_set_severity_message
|
6 |
7u83 |
324 |
* (ESeverityT severity, CStringP message)
|
2 |
7u83 |
325 |
** Exceptions:
|
|
|
326 |
*
|
|
|
327 |
* This function sets the message to be displayed when the "${severity}" tag
|
|
|
328 |
* is encountered for the specified severity. Tags are not expanded in the
|
|
|
329 |
* message. The message should not be modified or deallocated.
|
|
|
330 |
*
|
|
|
331 |
** Function: BoolT error_set_prefix_message
|
6 |
7u83 |
332 |
* (CStringP message)
|
2 |
7u83 |
333 |
** Exceptions: XX_dalloc_no_memory
|
|
|
334 |
*
|
|
|
335 |
* This function sets the error message prefix string. This string is output
|
|
|
336 |
* by ``error_display'' before outputting any actual error message. Tags are
|
|
|
337 |
* expanded, but only for the standard tags: "${program name}", "${severity}",
|
|
|
338 |
* "${dollar}", "${this error name}", "${open brace}", and "${close brace}".
|
|
|
339 |
* All other tags will be ignored. The function returns true if the message
|
|
|
340 |
* was valid, and false if there was an unterminated tag in the message.
|
|
|
341 |
*
|
|
|
342 |
** Function: EStringP error_define_string
|
6 |
7u83 |
343 |
* (CStringP name, CStringP contents)
|
2 |
7u83 |
344 |
** Exceptions: XX_dalloc_no_memory
|
|
|
345 |
*
|
|
|
346 |
* This function defines a named string with the specified name, and assigns
|
|
|
347 |
* it the specified contents. Neither the name nor the contents should be
|
|
|
348 |
* modified or deallocated. No tag splitting is performed on the contents.
|
|
|
349 |
*
|
|
|
350 |
** Function: void error_intern_strings
|
6 |
7u83 |
351 |
* (EStringDataP vector)
|
2 |
7u83 |
352 |
** Exceptions: XX_dalloc_no_memory
|
|
|
353 |
*
|
|
|
354 |
* This function changes the name and contents entries in the specified vector
|
|
|
355 |
* into named strings. The vector should be terminated by the macro
|
|
|
356 |
* ``ERROR_END_STRING_LIST''. This function should only be called once on any
|
|
|
357 |
* vector.
|
|
|
358 |
*
|
|
|
359 |
** Function: BoolT error_redefine_string
|
6 |
7u83 |
360 |
* (CStringP name, CStringP contents)
|
2 |
7u83 |
361 |
** Exceptions: XX_dalloc_no_memory
|
|
|
362 |
*
|
|
|
363 |
* This function changes the contents of the named string with the specified
|
|
|
364 |
* name. If the name does not exist, the function returns false, otherwise it
|
|
|
365 |
* returns true.
|
|
|
366 |
*
|
|
|
367 |
** Function: EStringP error_lookup_string
|
6 |
7u83 |
368 |
* (CStringP name)
|
2 |
7u83 |
369 |
** Exceptions:
|
|
|
370 |
*
|
|
|
371 |
* This function returns the named string with the specified name. If the
|
|
|
372 |
* named string does not exist, the function returns the null pointer.
|
|
|
373 |
*
|
|
|
374 |
** Function: CStringP error_string_contents
|
6 |
7u83 |
375 |
* (EStringP estring)
|
2 |
7u83 |
376 |
** Exceptions:
|
|
|
377 |
*
|
|
|
378 |
* This function returns the contents of the specified named string. The
|
|
|
379 |
* returned string should not be modified or deallocated.
|
|
|
380 |
*
|
|
|
381 |
** Function: void write_error_file
|
6 |
7u83 |
382 |
* (OStreamP ostream)
|
2 |
7u83 |
383 |
** Exceptions: XX_dalloc_no_memory, XX_ostream_write_error
|
|
|
384 |
*
|
|
|
385 |
* This function writes out an error file (in the same format as parsed by the
|
|
|
386 |
* functions in "error-file.[ch]") to the specified ostream.
|
|
|
387 |
*
|
|
|
388 |
***=== MACROS ===============================================================
|
|
|
389 |
*
|
|
|
390 |
** Macro: ERROR_END_TAG_LIST
|
|
|
391 |
** Exceptions:
|
|
|
392 |
*
|
|
|
393 |
* This macro should form the last entry in a vector of ``ETagDataT'' objects.
|
|
|
394 |
*
|
|
|
395 |
** Macro: ERROR_END_ERROR_LIST
|
|
|
396 |
** Exceptions:
|
|
|
397 |
*
|
|
|
398 |
* This macro should form the last entry in a vector of ``ErrorDataT''
|
|
|
399 |
* objects.
|
|
|
400 |
*
|
|
|
401 |
** Macro: ERROR_END_STRING_LIST
|
|
|
402 |
** Exceptions:
|
|
|
403 |
*
|
|
|
404 |
* This macro should form the last entry in a vector of ``EStringDataT''
|
|
|
405 |
* objects.
|
|
|
406 |
*
|
|
|
407 |
**** Change log:
|
|
|
408 |
* $Log: error.h,v $
|
|
|
409 |
* Revision 1.1.1.1 1998/01/17 15:57:42 release
|
|
|
410 |
* First version to be checked into rolling release.
|
|
|
411 |
*
|
|
|
412 |
* Revision 1.2 1994/12/12 11:44:43 smf
|
|
|
413 |
* Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
|
|
|
414 |
* OSSG C Coding Standards.
|
|
|
415 |
*
|
|
|
416 |
* Revision 1.1.1.1 1994/07/25 16:05:51 smf
|
|
|
417 |
* Initial import of library shared files.
|
|
|
418 |
*
|
|
|
419 |
**/
|
|
|
420 |
|
|
|
421 |
/****************************************************************************/
|
|
|
422 |
|
|
|
423 |
#ifndef H_ERROR
|
|
|
424 |
#define H_ERROR
|
|
|
425 |
|
|
|
426 |
#include "os-interface.h"
|
|
|
427 |
#include "cstring.h"
|
|
|
428 |
#include "dstring.h"
|
|
|
429 |
#include "ostream.h"
|
|
|
430 |
|
|
|
431 |
/*--------------------------------------------------------------------------*/
|
|
|
432 |
|
|
|
433 |
#ifdef FS_NO_ENUM
|
|
|
434 |
typedef int ESeverityT, *ESeverityP;
|
|
|
435 |
#define ERROR_SEVERITY_INFORMATION (0)
|
|
|
436 |
#define ERROR_SEVERITY_WARNING (1)
|
|
|
437 |
#define ERROR_SEVERITY_ERROR (2)
|
|
|
438 |
#define ERROR_SEVERITY_FATAL (3)
|
|
|
439 |
#define ERROR_SEVERITY_INTERNAL (4)
|
|
|
440 |
#else
|
|
|
441 |
typedef enum {
|
|
|
442 |
ERROR_SEVERITY_INFORMATION,
|
|
|
443 |
ERROR_SEVERITY_WARNING,
|
|
|
444 |
ERROR_SEVERITY_ERROR,
|
|
|
445 |
ERROR_SEVERITY_FATAL,
|
|
|
446 |
ERROR_SEVERITY_INTERNAL
|
6 |
7u83 |
447 |
} ESeverityT, *ESeverityP;
|
2 |
7u83 |
448 |
#endif /* defined (FS_NO_ENUM) */
|
|
|
449 |
|
|
|
450 |
typedef struct ETagT {
|
|
|
451 |
struct ETagT *next;
|
|
|
452 |
CStringP name;
|
|
|
453 |
} ETagT, *ETagP;
|
|
|
454 |
|
|
|
455 |
typedef struct ErrorListT {
|
|
|
456 |
struct ErrorListT *next;
|
|
|
457 |
#ifdef FS_NO_ENUM
|
|
|
458 |
int tag;
|
|
|
459 |
#define ERROR_TAG_STRING (0)
|
|
|
460 |
#define ERROR_TAG_TAG (1)
|
|
|
461 |
#else
|
|
|
462 |
enum {
|
|
|
463 |
ERROR_TAG_STRING,
|
|
|
464 |
ERROR_TAG_TAG
|
|
|
465 |
} tag;
|
|
|
466 |
#endif /* defined (FS_NO_ENUM) */
|
|
|
467 |
union {
|
|
|
468 |
NStringT string;
|
|
|
469 |
ETagP tag;
|
|
|
470 |
} u;
|
|
|
471 |
} ErrorListT, *ErrorListP;
|
|
|
472 |
|
|
|
473 |
typedef struct ErrorT {
|
|
|
474 |
struct ErrorT *next;
|
|
|
475 |
CStringP name;
|
|
|
476 |
ESeverityT severity;
|
|
|
477 |
ErrorListP error_list;
|
|
|
478 |
GenericP data;
|
|
|
479 |
} ErrorT, *ErrorP;
|
|
|
480 |
|
|
|
481 |
typedef struct EStringT {
|
|
|
482 |
struct EStringT *next;
|
|
|
483 |
CStringP name;
|
|
|
484 |
CStringP contents;
|
|
|
485 |
} EStringT, *EStringP;
|
|
|
486 |
|
6 |
7u83 |
487 |
typedef void(*ErrorProcP)(OStreamP, ETagP, GenericP);
|
|
|
488 |
typedef void(*ErrorInitProcP)(void);
|
2 |
7u83 |
489 |
typedef UNION ETagDataT {
|
|
|
490 |
CStringP name;
|
|
|
491 |
ETagP tag;
|
|
|
492 |
} ETagDataT, *ETagDataP;
|
|
|
493 |
typedef UNION ErrorDataT {
|
|
|
494 |
struct {
|
|
|
495 |
CStringP name;
|
|
|
496 |
ESeverityT severity;
|
|
|
497 |
CStringP message;
|
|
|
498 |
GenericP data;
|
|
|
499 |
} s;
|
|
|
500 |
ErrorP error;
|
|
|
501 |
} ErrorDataT, *ErrorDataP;
|
|
|
502 |
typedef UNION EStringDataT {
|
|
|
503 |
struct {
|
|
|
504 |
CStringP name;
|
|
|
505 |
CStringP contents;
|
|
|
506 |
} s;
|
|
|
507 |
EStringP estring;
|
|
|
508 |
} EStringDataT, *EStringDataP;
|
|
|
509 |
|
|
|
510 |
#ifdef FS_NO_ENUM
|
|
|
511 |
typedef int ErrorStatusT, *ErrorStatusP;
|
|
|
512 |
#define ERROR_STATUS_BAD_MESSAGE (0)
|
|
|
513 |
#define ERROR_STATUS_SUCCESS (1)
|
|
|
514 |
#define ERROR_STATUS_BAD_ERROR (2)
|
|
|
515 |
#else
|
|
|
516 |
typedef enum {
|
|
|
517 |
ERROR_STATUS_BAD_MESSAGE,
|
|
|
518 |
ERROR_STATUS_SUCCESS,
|
|
|
519 |
ERROR_STATUS_BAD_ERROR
|
|
|
520 |
} ErrorStatusT, *ErrorStatusP;
|
|
|
521 |
#endif /* defined (FS_NO_ENUM) */
|
|
|
522 |
|
|
|
523 |
/*--------------------------------------------------------------------------*/
|
|
|
524 |
|
6 |
7u83 |
525 |
extern void error_init(CStringP, ErrorInitProcP);
|
|
|
526 |
extern void error_call_init_proc(void);
|
|
|
527 |
extern ETagP error_define_tag(CStringP);
|
|
|
528 |
extern ErrorP error_define_error(CStringP, ESeverityT, CStringP,
|
|
|
529 |
GenericP);
|
|
|
530 |
extern void error_intern_tags(ETagDataP);
|
|
|
531 |
extern void error_intern_errors(ErrorDataP);
|
|
|
532 |
extern ErrorStatusT error_redefine_error(CStringP, CStringP);
|
|
|
533 |
extern ErrorP error_lookup_error(CStringP);
|
|
|
534 |
extern GenericP error_data(ErrorP);
|
|
|
535 |
extern void error_report(ErrorP, ErrorProcP, GenericP);
|
|
|
536 |
extern void error_set_min_report_severity(ESeverityT);
|
|
|
537 |
extern ESeverityT error_get_min_report_severity(void);
|
|
|
538 |
extern ESeverityT error_max_reported_severity(void);
|
|
|
539 |
extern void error_set_severity_message(ESeverityT, CStringP);
|
|
|
540 |
extern BoolT error_set_prefix_message(CStringP);
|
|
|
541 |
extern EStringP error_define_string(CStringP, CStringP);
|
|
|
542 |
extern void error_intern_strings(EStringDataP);
|
|
|
543 |
extern BoolT error_redefine_string(CStringP, CStringP);
|
|
|
544 |
extern EStringP error_lookup_string(CStringP);
|
|
|
545 |
extern CStringP error_string_contents(EStringP);
|
2 |
7u83 |
546 |
|
6 |
7u83 |
547 |
extern void write_error_file(OStreamP);
|
2 |
7u83 |
548 |
|
|
|
549 |
/*--------------------------------------------------------------------------*/
|
|
|
550 |
|
6 |
7u83 |
551 |
#define ERROR_END_TAG_LIST UB NIL(CStringP)UE
|
2 |
7u83 |
552 |
#define ERROR_END_ERROR_LIST \
|
6 |
7u83 |
553 |
UB {NIL(CStringP), (ESeverityT)0, NIL(CStringP), NIL(GenericP)} UE
|
|
|
554 |
#define ERROR_END_STRING_LIST UB {NIL(CStringP), NIL(CStringP)} UE
|
2 |
7u83 |
555 |
|
|
|
556 |
#endif /* !defined (H_ERROR) */
|
|
|
557 |
|
|
|
558 |
/*
|
|
|
559 |
* Local variables(smf):
|
|
|
560 |
* eval: (include::add-path-entry "../os-interface" "../generated")
|
|
|
561 |
* end:
|
|
|
562 |
**/
|