/[ascend]/trunk/base/generic/utilities/ascPanic.h
ViewVC logotype

Annotation of /trunk/base/generic/utilities/ascPanic.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 593 - (hide annotations) (download) (as text)
Fri May 12 10:03:59 2006 UTC (14 years, 5 months ago) by johnpye
File MIME type: text/x-chdr
File size: 4703 byte(s)
Bumped version to 0.9.5.91.
Changed WITH_CUNIT_TESTS to WITH_CUNIT.
Added GCOV scons option.
Fixed up 'test' target for SCons.
Added lots of export symbols to libascend.so.

1 johnpye 127 /*
2     ASCEND Language Interpreter
3     AscPanic by Mark Thomas, created 15 May 1997
4     Copyright (C) 2005 Carnegie-Mellon University
5 aw0a 1
6 johnpye 127 This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10 aw0a 1
11 johnpye 127 This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     GNU General Public License for more details.
15 aw0a 1
16 johnpye 127 You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19     This file is part of the SLV solver.
20     */
21 jds 59
22 johnpye 127 /** @file
23     Ascend Panic - fatal error handling.
24 jds 59
25 johnpye 127 Requires
26     #include <stdarg.h>
27     #include "utilities/ascConfig.h"
28     */
29 jds 59
30 johnpye 127 /* removed changelog -- see ViewCVS for full history */
31 jds 59
32 johnpye 127 #ifndef ASC_ASCPANIC_H
33     #define ASC_ASCPANIC_H
34 jds 59
35 johnpye 127 /**
36     Our assert macro. Uses Asc_Panic() to report & handle assertion failure. Disabled if ASC_NO_ASSERTIONS is defined.
37     */
38     #ifdef ASC_NO_ASSERTIONS
39     # define asc_assert(x) ((void)0)
40     #else
41     # define asc_assert(cond) \
42     ((cond) ? (void)0 : Asc_Panic(ASCERR_ASSERTION_FAILED, NULL, \
43     "Assertion failed in %s:%d: '%s'", __FILE__, __LINE__, #cond))
44     #endif
45    
46 johnpye 522 ASC_DLLSPEC(void ) Asc_Panic(CONST int status, CONST char *function,
47 jds 59 CONST char *format, ...);
48 johnpye 127 /**< Print fatal error message, run callback function & (usually) exit the program.
49 aw0a 1
50 johnpye 127 @param status Status code passed by the calling function.
51     @param function Pointer to the name of the calling function.
52     @param format printf-style format string for VAR_ARGS to follow.
53    
54     This is the fatal error handler for the ASCEND system. It prints
55     the printf-style variable arguments using the specified format to
56     ASCERR file handle. The message is formatted with a header
57     (e.g. 'ASCEND PANIC!!) and the name of the function (if non-NULL),
58     followed by the variables & format passed as arguments. ASCERR
59     should have been initialized to a valid file stream or else the
60     message will not be printed (checked by assertion). @par
61    
62     If a valid file name has been previously set using
63     Asc_PanicSetOutfile(), the message is printed to this file also.
64     Under Windows, a MessageBox will also be displayed with the
65     message. @par
66    
67     If a callback has been set using Asc_PanicSetCallback(), the
68     registered function will be called with the specified status.
69     If the callback returns non-NULL, then exit() is called to end
70     the program. This is the default behavior. If the callback
71     is able to resolve the problem, then it should return zero and
72     Asc_Panic() will just return. This will be useful mostly for
73     testing purposes, and should be used with caution.
74     */
75    
76 johnpye 593 ASC_DLLSPEC(void ) Asc_PanicSetOutfile(CONST char *filename);
77 johnpye 127 /**< Sets a file name for reporting of Asc_Panic() messages.
78    
79     @param filename Pointer to the name of the file to print messages to.
80    
81     Calling this function with a non-NULL "filename" will cause
82     Asc_Panic() to write panic messages to "filename" in addition to the
83     ASCERR file handle. Passing in a "filename" of NULL causes panic
84     messages not to be written to disk---this undoes the effect of
85     previous calls to Asc_PanicSetOutfile().
86 aw0a 1 */
87    
88 jds 59 typedef int (*PanicCallbackFunc)(int);
89 johnpye 127 /**< Signature of the callback function called by Asc_Panic().
90 jds 54
91 johnpye 127 @param the status code passed to Asc_Panic() by the original caller.
92     @return nonzero if ASCEND should exit, 0 if Asc_Panic should just return.
93    
94     This functionality is provided primarily for internal testing
95     purposes. It should be used with extreme caution in release
96     code. Asc_Panic() is called from all over ASCEND for many
97     error conditions, and current calls assume no return.
98     */
99    
100 johnpye 593 ASC_DLLSPEC(PanicCallbackFunc ) Asc_PanicSetCallback(PanicCallbackFunc func);
101 johnpye 127 /**< Registers a callback function to be called by Asc_Panic().
102 jds 59
103 johnpye 127 @param func Pointer to the new function to call during an Asc_Panic().
104     @return A pointer to the previously-registered callback, or NULL
105     if none was registered.
106    
107     This allows the user to specify a cleanup function to be
108     called during a fatal error.
109    
110     @see PanicCallbackFunc for the form this callback function takes.
111     */
112    
113 johnpye 593 ASC_DLLSPEC(void ) Asc_PanicDisplayMessageBox(int is_displayed);
114 jds 59 /**<
115 johnpye 127 Controls whether a MessageBox is displayed by Asc_Panic() on Windows.
116 jds 59
117 johnpye 127 @param is_displayed if non-zero, messagebox should be displayed, else not.
118 jds 59
119 johnpye 127 Has no effect on non-Windows platforms.
120     */
121    
122     #endif /* ASC_ASCPANIC_H */

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22