2 * NOTICE and LICENSE for Tecplot Input/Output Library (TecIO) - OpenFOAM
4 * Copyright (C) 1988-2009 Tecplot, Inc. All rights reserved worldwide.
6 * Tecplot hereby grants OpenCFD limited authority to distribute without
7 * alteration the source code to the Tecplot Input/Output library, known
8 * as TecIO, as part of its distribution of OpenFOAM and the
9 * OpenFOAM_to_Tecplot converter. Users of this converter are also hereby
10 * granted access to the TecIO source code, and may redistribute it for the
11 * purpose of maintaining the converter. However, no authority is granted
12 * to alter the TecIO source code in any form or manner.
14 * This limited grant of distribution does not supersede Tecplot, Inc.'s
15 * copyright in TecIO. Contact Tecplot, Inc. for further information.
18 * 3535 Factoria Blvd, Ste. 550
19 * Bellevue, WA 98006, USA
20 * Phone: +1 425 653 1200
21 * http://www.tecplot.com/
26 #define TECPLOTENGINEMODULE
29 *****************************************************************
30 *****************************************************************
32 ****** Copyright (C) 1988-2008 Tecplot, Inc. *******
34 *****************************************************************
35 *****************************************************************
41 #include "Q_UNICODE.h"
42 #if defined TECPLOTKERNEL
43 /* CORE SOURCE CODE REMOVED */
50 using namespace tecplot::strutil
;
53 #define MAX_ERRMSG_LENGTH 2096
55 /* the mopup from assert and the writing out of crash.lay are */
56 /* used by TUASSERT and thus are needed even if NO_ASSERTS */
58 #if !defined NO_TU_ASSERTS || !defined NO_ASSERTS
60 #if defined TECPLOTKERNEL
61 /* CORE SOURCE CODE REMOVED */
62 #if defined MSWIN /* ...Unix/Linux calls this via signal handlers */
64 #endif /* TECPLOTKERNEL */
66 #endif /* Mopup function needed ... */
70 #if !defined STD_ASSERTS
72 * Define the final assertion notification function.
74 #if defined UNIXX && !defined NO_ASSERTS
75 /*******************************************************************
79 *******************************************************************/
84 * if NDEBUG is defined __assert is NOT defined so we must supply
85 * our own assertion notification function.....
87 # define ASSERT assert
88 static void UnixAssert(const char *expression
,
89 const char *file_name
,
92 fprintf(stderr
, "Assertion: %s\n"
93 "Tecplot version: %s\n"
96 expression
, TecVersionId
, file_name
, line
);
97 exit(ExitCode_AssertionFailure
);
99 static TAssertFailureNotifyFunc assert_failure_notify
= UnixAssert
;
102 * NDEBUG is not defined so __assert is available....
105 # define LOWLEVELASSERTFUNCTION __linuxassertproxy
107 * In linux, __assert does not exist but rather
108 * __assert_fail which has a differnt API. Thus
109 * a proxy is provided
111 static void __linuxassertproxy(const char *__assertion
,
115 __assert_fail(__assertion
, __file
, __line
, __ASSERT_FUNCTION
);
117 # elif defined DARWIN
118 # define LOWLEVELASSERTFUNCTION __darwinassertproxy
120 * In Darwin (Mac OS X), __assert is #defined to a call to __eprintf,
121 * which also has a different API. Another proxy...
123 static void __darwinassertproxy(const char *__assertion
,
127 __eprintf("Assertion: %s\n"
128 "Tecplot version: %s\n"
131 __assertion
, TecVersionId
, __file
, (unsigned)__line
);
134 # define LOWLEVELASSERTFUNCTION __assert
137 static TAssertFailureNotifyFunc assert_failure_notify
= (TAssertFailureNotifyFunc
) LOWLEVELASSERTFUNCTION
;
142 #if defined UNIXX && !defined NO_ASSERTS
144 * Replace the current assert failure notification function and
145 * return the current one.
148 * new function points to valid function (not null) that
149 * conforms to the specified prototype
152 * result is a pointer to the previously installed
153 * function (not null)
155 TAssertFailureNotifyFunc
InstallTAssertFailureNotify(
156 TAssertFailureNotifyFunc new_function
) /* new notification function */
158 TAssertFailureNotifyFunc result
= 0; /* old function address */
160 ASSERT(new_function
!= 0);
162 result
= assert_failure_notify
;
163 assert_failure_notify
= new_function
;
175 * Perform the installed assert failure notification action.
177 void TAssert(const char *expression
, /* text representation of the assertion */
178 const char *file_name
, /* name of the file containing the assertion */
179 int line
) /* line number in the file of the assertion */
181 static Boolean_t InTAssert
= FALSE
;
182 #if defined TECPLOTKERNEL
183 /* CORE SOURCE CODE REMOVED */
185 char Message
[MAX_ERRMSG_LENGTH
+1];
186 ASSERT(expression
!= 0 && strlen(expression
) != 0);
187 ASSERT(file_name
!= 0 && strlen(file_name
) != 0);
190 /* check for recursion */
193 fprintf(stderr
, "Already in assert!\n");
194 fprintf(stderr
, "Assertion: %s\n"
195 "Tecplot version: %s\n"
198 expression
, TecVersionId
, file_name
, line
);
199 PrintCurBacktrace(stderr
, 100);
200 ASSERT(FALSE
); /*... really exit */
205 sprintf(Message
, "Assertion: %s\n"
206 "Tecplot version: %s\n"
209 expression
, TecVersionId
, file_name
, line
);
211 #if defined TECPLOTKERNEL
212 /* CORE SOURCE CODE REMOVED */
215 # if defined TECPLOTKERNEL
216 /* CORE SOURCE CODE REMOVED */
218 fprintf(stderr
, "%s", Message
);
221 #if defined TECPLOTKERNEL
222 /* CORE SOURCE CODE REMOVED */
225 (*assert_failure_notify
)(expression
, file_name
, line
);
226 #if defined TECPLOTKERNEL
227 /* CORE SOURCE CODE REMOVED */
230 #if defined TECPLOTKERNEL
231 /* CORE SOURCE CODE REMOVED */
234 InTAssert
= FALSE
; /* just in case assert_failure_notify has an ignore */
236 #endif /* defined UNIXX && !defined NO_ASSERTS */
237 #endif /* STD_ASSERTS */
240 #if defined MSWIN && defined TECPLOTKERNEL
241 /* CORE SOURCE CODE REMOVED */
242 #if defined CHECKED_BUILD
245 # if defined CHECKED_BUILD
246 # endif // CHECKED_BUILD
251 #if defined NICE_NOT_IMPLEMENTED
252 static Boolean_t NotImplementedCalled
= FALSE
;
253 void NiceNotImplemented(void)
255 if (!NotImplementedCalled
)
257 Warning("Not Implemented!");
258 NotImplementedCalled
= TRUE
;