Line -... |
Line 1... |
- |
|
1 |
/*
|
- |
|
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 |
*/
|
1 |
/*
|
31 |
/*
|
2 |
Crown Copyright (c) 1997
|
32 |
Crown Copyright (c) 1997
|
3 |
|
33 |
|
4 |
This TenDRA(r) Computer Program is subject to Copyright
|
34 |
This TenDRA(r) Computer Program is subject to Copyright
|
5 |
owned by the United Kingdom Secretary of State for Defence
|
35 |
owned by the United Kingdom Secretary of State for Defence
|
6 |
acting through the Defence Evaluation and Research Agency
|
36 |
acting through the Defence Evaluation and Research Agency
|
7 |
(DERA). It is made available to Recipients with a
|
37 |
(DERA). It is made available to Recipients with a
|
8 |
royalty-free licence for its use, reproduction, transfer
|
38 |
royalty-free licence for its use, reproduction, transfer
|
9 |
to other parties and amendment for any purpose not excluding
|
39 |
to other parties and amendment for any purpose not excluding
|
10 |
product development provided that any such use et cetera
|
40 |
product development provided that any such use et cetera
|
11 |
shall be deemed to be acceptance of the following conditions:-
|
41 |
shall be deemed to be acceptance of the following conditions:-
|
12 |
|
42 |
|
13 |
(1) Its Recipients shall ensure that this Notice is
|
43 |
(1) Its Recipients shall ensure that this Notice is
|
14 |
reproduced upon any copies or amended versions of it;
|
44 |
reproduced upon any copies or amended versions of it;
|
15 |
|
45 |
|
16 |
(2) Any amended version of it shall be clearly marked to
|
46 |
(2) Any amended version of it shall be clearly marked to
|
17 |
show both the nature of and the organisation responsible
|
47 |
show both the nature of and the organisation responsible
|
18 |
for the relevant amendment or amendments;
|
48 |
for the relevant amendment or amendments;
|
19 |
|
49 |
|
20 |
(3) Its onward transfer from a recipient to another
|
50 |
(3) Its onward transfer from a recipient to another
|
21 |
party shall be deemed to be that party's acceptance of
|
51 |
party shall be deemed to be that party's acceptance of
|
22 |
these conditions;
|
52 |
these conditions;
|
23 |
|
53 |
|
24 |
(4) DERA gives no warranty or assurance as to its
|
54 |
(4) DERA gives no warranty or assurance as to its
|
25 |
quality or suitability for any purpose and DERA accepts
|
55 |
quality or suitability for any purpose and DERA accepts
|
26 |
no liability whatsoever in relation to any use to which
|
56 |
no liability whatsoever in relation to any use to which
|
27 |
it may be put.
|
57 |
it may be put.
|
28 |
*/
|
58 |
*/
|
Line 42... |
Line 72... |
42 |
* implemented as a set of macros.
|
72 |
* implemented as a set of macros.
|
43 |
*
|
73 |
*
|
44 |
* This file requires that two external functions are provided:
|
74 |
* This file requires that two external functions are provided:
|
45 |
*
|
75 |
*
|
46 |
* extern void E_exception_unhandled
|
76 |
* extern void E_exception_unhandled
|
47 |
* PROTO_S ((ExceptionP, CStringP, unsigned));
|
77 |
* (ExceptionP, CStringP, unsigned);
|
48 |
* extern void E_exception_corrupt_handler
|
78 |
* extern void E_exception_corrupt_handler
|
49 |
* PROTO_S ((CStringP, unsigned));
|
79 |
* (CStringP, unsigned);
|
50 |
*
|
80 |
*
|
51 |
* The first of these functions will be called if there is an unhandled
|
81 |
* The first of these functions will be called if there is an unhandled
|
52 |
* exception. The exception will be given as an argument, along with the name
|
82 |
* exception. The exception will be given as an argument, along with the name
|
53 |
* of the file, and the line within that file that the exception was thrown
|
83 |
* of the file, and the line within that file that the exception was thrown
|
54 |
* from. The second function will be called if a corrupt exception handler
|
84 |
* from. The second function will be called if a corrupt exception handler
|
Line 89... |
Line 119... |
89 |
* stack.
|
119 |
* stack.
|
90 |
*
|
120 |
*
|
91 |
***=== FUNCTIONS ============================================================
|
121 |
***=== FUNCTIONS ============================================================
|
92 |
*
|
122 |
*
|
93 |
** Function: CStringP exception_name
|
123 |
** Function: CStringP exception_name
|
94 |
* PROTO_S ((ExceptionP exception))
|
124 |
* (ExceptionP exception)
|
95 |
*
|
125 |
*
|
96 |
* This function returns the name of the specified exception. The return
|
126 |
* This function returns the name of the specified exception. The return
|
97 |
* value should not be modified or deallocated.
|
127 |
* value should not be modified or deallocated.
|
98 |
*
|
128 |
*
|
99 |
***=== MACROS ===============================================================
|
129 |
***=== MACROS ===============================================================
|
Line 248... |
Line 278... |
248 |
#endif /* defined (PO_EXCEPTION_STACK_DIRECTION) */
|
278 |
#endif /* defined (PO_EXCEPTION_STACK_DIRECTION) */
|
249 |
} HandlerT, *HandlerP;
|
279 |
} HandlerT, *HandlerP;
|
250 |
|
280 |
|
251 |
/*--------------------------------------------------------------------------*/
|
281 |
/*--------------------------------------------------------------------------*/
|
252 |
|
282 |
|
253 |
extern CStringP exception_name
|
283 |
extern CStringP exception_name(ExceptionP);
|
254 |
PROTO_S ((ExceptionP));
|
- |
|
255 |
|
284 |
|
256 |
/*--------------------------------------------------------------------------*/
|
285 |
/*--------------------------------------------------------------------------*/
|
257 |
|
286 |
|
258 |
extern HandlerP X__exception_handler_stack;
|
287 |
extern HandlerP X__exception_handler_stack;
|
259 |
extern ThrowDataT X__exception_throw_data;
|
288 |
extern ThrowDataT X__exception_throw_data;
|
260 |
extern NoReturnT X__exception_throw
|
289 |
extern NoReturnT X__exception_throw(void);
|
261 |
PROTO_S ((void));
|
- |
|
262 |
|
290 |
|
263 |
/*--------------------------------------------------------------------------*/
|
291 |
/*--------------------------------------------------------------------------*/
|
264 |
|
292 |
|
265 |
#define EXCEPTION(name) name
|
293 |
#define EXCEPTION(name)name
|
266 |
|
294 |
|
267 |
#define THROW(exc) \
|
295 |
#define THROW(exc)\
|
268 |
{X__exception_throw_data.exception = (exc); \
|
296 |
{X__exception_throw_data.exception = (exc); \
|
269 |
X__exception_throw_data.data = NIL (GenericP); \
|
297 |
X__exception_throw_data.data = NIL(GenericP); \
|
270 |
X__exception_throw_data.line = __LINE__; \
|
298 |
X__exception_throw_data.line = __LINE__; \
|
271 |
X__exception_throw_data.file = __FILE__; \
|
299 |
X__exception_throw_data.file = __FILE__; \
|
272 |
X__exception_throw ();}
|
300 |
X__exception_throw();}
|
273 |
|
301 |
|
274 |
#define THROW_VALUE(exc,val) \
|
302 |
#define THROW_VALUE(exc,val)\
|
275 |
{X__exception_throw_data.exception = (exc); \
|
303 |
{X__exception_throw_data.exception = (exc); \
|
276 |
X__exception_throw_data.data = ((GenericP) (val)); \
|
304 |
X__exception_throw_data.data = ((GenericP)(val)); \
|
277 |
X__exception_throw_data.line = __LINE__; \
|
305 |
X__exception_throw_data.line = __LINE__; \
|
278 |
X__exception_throw_data.file = __FILE__; \
|
306 |
X__exception_throw_data.file = __FILE__; \
|
279 |
X__exception_throw ();}
|
307 |
X__exception_throw();}
|
280 |
|
308 |
|
281 |
#ifdef PO_EXCEPTION_STACK_DIRECTION
|
309 |
#ifdef PO_EXCEPTION_STACK_DIRECTION
|
282 |
#define X__EXCEPTION_MAGIC (0x1234)
|
310 |
#define X__EXCEPTION_MAGIC(0x1234)
|
283 |
|
311 |
|
284 |
#define HANDLE \
|
312 |
#define HANDLE \
|
285 |
{HandlerT X___exception_handler; \
|
313 |
{HandlerT X___exception_handler; \
|
286 |
X___exception_handler.magic_start = X__EXCEPTION_MAGIC; \
|
314 |
X___exception_handler.magic_start = X__EXCEPTION_MAGIC; \
|
287 |
X___exception_handler.file = __FILE__; \
|
315 |
X___exception_handler.file = __FILE__; \
|
288 |
X___exception_handler.line = __LINE__; \
|
316 |
X___exception_handler.line = __LINE__; \
|
289 |
X___exception_handler.next = X__exception_handler_stack; \
|
317 |
X___exception_handler.next = X__exception_handler_stack; \
|
290 |
X___exception_handler.magic_end = X__EXCEPTION_MAGIC; \
|
318 |
X___exception_handler.magic_end = X__EXCEPTION_MAGIC; \
|
291 |
X__exception_handler_stack = &X___exception_handler; \
|
319 |
X__exception_handler_stack = &X___exception_handler; \
|
292 |
if (!setjmp (X___exception_handler.buffer)) {
|
320 |
if (!setjmp(X___exception_handler.buffer)) {
|
293 |
#else
|
321 |
#else
|
294 |
#define HANDLE \
|
322 |
#define HANDLE \
|
295 |
{HandlerT X___exception_handler; \
|
323 |
{HandlerT X___exception_handler; \
|
296 |
X___exception_handler.next = X__exception_handler_stack; \
|
324 |
X___exception_handler.next = X__exception_handler_stack; \
|
297 |
X__exception_handler_stack = &X___exception_handler; \
|
325 |
X__exception_handler_stack = &X___exception_handler; \
|
298 |
if (!setjmp (X___exception_handler.buffer)) {
|
326 |
if (!setjmp(X___exception_handler.buffer)) {
|
299 |
#endif /* defined (PO_EXCEPTION_STACK_DIRECTION) */
|
327 |
#endif /* defined (PO_EXCEPTION_STACK_DIRECTION) */
|
300 |
|
328 |
|
301 |
#define WITH \
|
329 |
#define WITH \
|
302 |
X__exception_handler_stack = X___exception_handler.next; \
|
330 |
X__exception_handler_stack = X___exception_handler.next; \
|
303 |
} else { \
|
331 |
} else { \
|
304 |
X__exception_handler_stack = X___exception_handler.next; {
|
332 |
X__exception_handler_stack = X___exception_handler.next; {
|
305 |
|
333 |
|
306 |
#define END_HANDLE }}}
|
334 |
#define END_HANDLE }}}
|
307 |
|
335 |
|
308 |
#define EXCEPTION_EXCEPTION() \
|
336 |
#define EXCEPTION_EXCEPTION()\
|
309 |
X__exception_throw_data.exception
|
337 |
X__exception_throw_data.exception
|
310 |
|
338 |
|
311 |
#define EXCEPTION_VALUE() \
|
339 |
#define EXCEPTION_VALUE()\
|
312 |
X__exception_throw_data.data
|
340 |
X__exception_throw_data.data
|
313 |
|
341 |
|
314 |
#define EXCEPTION_LINE() \
|
342 |
#define EXCEPTION_LINE()\
|
315 |
X__exception_throw_data.line
|
343 |
X__exception_throw_data.line
|
316 |
|
344 |
|
317 |
#define EXCEPTION_FILE() \
|
345 |
#define EXCEPTION_FILE()\
|
318 |
X__exception_throw_data.file
|
346 |
X__exception_throw_data.file
|
319 |
|
347 |
|
320 |
#define RETHROW() \
|
348 |
#define RETHROW()\
|
321 |
X__exception_throw ();
|
349 |
X__exception_throw();
|
322 |
|
350 |
|
323 |
#define UNHANDLE X__exception_handler_stack = X___exception_handler.next;
|
351 |
#define UNHANDLE X__exception_handler_stack = X___exception_handler.next;
|
324 |
|
352 |
|
325 |
#endif /* !defined (H_EXCEPTION) */
|
353 |
#endif /* !defined (H_EXCEPTION) */
|