diff options
Diffstat (limited to 'libraries/ode-0.9/ode/src/error.cpp')
-rw-r--r-- | libraries/ode-0.9/ode/src/error.cpp | 172 |
1 files changed, 0 insertions, 172 deletions
diff --git a/libraries/ode-0.9/ode/src/error.cpp b/libraries/ode-0.9/ode/src/error.cpp deleted file mode 100644 index 9b33db5..0000000 --- a/libraries/ode-0.9/ode/src/error.cpp +++ /dev/null | |||
@@ -1,172 +0,0 @@ | |||
1 | /************************************************************************* | ||
2 | * * | ||
3 | * Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * | ||
4 | * All rights reserved. Email: russ@q12.org Web: www.q12.org * | ||
5 | * * | ||
6 | * This library is free software; you can redistribute it and/or * | ||
7 | * modify it under the terms of EITHER: * | ||
8 | * (1) The GNU Lesser General Public License as published by the Free * | ||
9 | * Software Foundation; either version 2.1 of the License, or (at * | ||
10 | * your option) any later version. The text of the GNU Lesser * | ||
11 | * General Public License is included with this library in the * | ||
12 | * file LICENSE.TXT. * | ||
13 | * (2) The BSD-style license that is included with this library in * | ||
14 | * the file LICENSE-BSD.TXT. * | ||
15 | * * | ||
16 | * This library is distributed in the hope that it will be useful, * | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * | ||
19 | * LICENSE.TXT and LICENSE-BSD.TXT for more details. * | ||
20 | * * | ||
21 | *************************************************************************/ | ||
22 | |||
23 | #include <ode/config.h> | ||
24 | #include <ode/error.h> | ||
25 | |||
26 | |||
27 | static dMessageFunction *error_function = 0; | ||
28 | static dMessageFunction *debug_function = 0; | ||
29 | static dMessageFunction *message_function = 0; | ||
30 | |||
31 | |||
32 | extern "C" void dSetErrorHandler (dMessageFunction *fn) | ||
33 | { | ||
34 | error_function = fn; | ||
35 | } | ||
36 | |||
37 | |||
38 | extern "C" void dSetDebugHandler (dMessageFunction *fn) | ||
39 | { | ||
40 | debug_function = fn; | ||
41 | } | ||
42 | |||
43 | |||
44 | extern "C" void dSetMessageHandler (dMessageFunction *fn) | ||
45 | { | ||
46 | message_function = fn; | ||
47 | } | ||
48 | |||
49 | |||
50 | extern "C" dMessageFunction *dGetErrorHandler() | ||
51 | { | ||
52 | return error_function; | ||
53 | } | ||
54 | |||
55 | |||
56 | extern "C" dMessageFunction *dGetDebugHandler() | ||
57 | { | ||
58 | return debug_function; | ||
59 | } | ||
60 | |||
61 | |||
62 | extern "C" dMessageFunction *dGetMessageHandler() | ||
63 | { | ||
64 | return message_function; | ||
65 | } | ||
66 | |||
67 | |||
68 | static void printMessage (int num, const char *msg1, const char *msg2, | ||
69 | va_list ap) | ||
70 | { | ||
71 | fflush (stderr); | ||
72 | fflush (stdout); | ||
73 | if (num) fprintf (stderr,"\n%s %d: ",msg1,num); | ||
74 | else fprintf (stderr,"\n%s: ",msg1); | ||
75 | vfprintf (stderr,msg2,ap); | ||
76 | fprintf (stderr,"\n"); | ||
77 | fflush (stderr); | ||
78 | } | ||
79 | |||
80 | //**************************************************************************** | ||
81 | // unix | ||
82 | |||
83 | #ifndef WIN32 | ||
84 | |||
85 | extern "C" void dError (int num, const char *msg, ...) | ||
86 | { | ||
87 | va_list ap; | ||
88 | va_start (ap,msg); | ||
89 | if (error_function) error_function (num,msg,ap); | ||
90 | else printMessage (num,"ODE Error",msg,ap); | ||
91 | exit (1); | ||
92 | } | ||
93 | |||
94 | |||
95 | extern "C" void dDebug (int num, const char *msg, ...) | ||
96 | { | ||
97 | va_list ap; | ||
98 | va_start (ap,msg); | ||
99 | if (debug_function) debug_function (num,msg,ap); | ||
100 | else printMessage (num,"ODE INTERNAL ERROR",msg,ap); | ||
101 | // *((char *)0) = 0; ... commit SEGVicide | ||
102 | abort(); | ||
103 | } | ||
104 | |||
105 | |||
106 | extern "C" void dMessage (int num, const char *msg, ...) | ||
107 | { | ||
108 | va_list ap; | ||
109 | va_start (ap,msg); | ||
110 | if (message_function) message_function (num,msg,ap); | ||
111 | else printMessage (num,"ODE Message",msg,ap); | ||
112 | } | ||
113 | |||
114 | #endif | ||
115 | |||
116 | //**************************************************************************** | ||
117 | // windows | ||
118 | |||
119 | #ifdef WIN32 | ||
120 | |||
121 | // isn't cygwin annoying! | ||
122 | #ifdef CYGWIN | ||
123 | #define _snprintf snprintf | ||
124 | #define _vsnprintf vsnprintf | ||
125 | #endif | ||
126 | |||
127 | |||
128 | #include "windows.h" | ||
129 | |||
130 | |||
131 | extern "C" void dError (int num, const char *msg, ...) | ||
132 | { | ||
133 | va_list ap; | ||
134 | va_start (ap,msg); | ||
135 | if (error_function) error_function (num,msg,ap); | ||
136 | else { | ||
137 | char s[1000],title[100]; | ||
138 | _snprintf (title,sizeof(title),"ODE Error %d",num); | ||
139 | _vsnprintf (s,sizeof(s),msg,ap); | ||
140 | s[sizeof(s)-1] = 0; | ||
141 | MessageBox(0,s,title,MB_OK | MB_ICONWARNING); | ||
142 | } | ||
143 | exit (1); | ||
144 | } | ||
145 | |||
146 | |||
147 | extern "C" void dDebug (int num, const char *msg, ...) | ||
148 | { | ||
149 | va_list ap; | ||
150 | va_start (ap,msg); | ||
151 | if (debug_function) debug_function (num,msg,ap); | ||
152 | else { | ||
153 | char s[1000],title[100]; | ||
154 | _snprintf (title,sizeof(title),"ODE INTERNAL ERROR %d",num); | ||
155 | _vsnprintf (s,sizeof(s),msg,ap); | ||
156 | s[sizeof(s)-1] = 0; | ||
157 | MessageBox(0,s,title,MB_OK | MB_ICONSTOP); | ||
158 | } | ||
159 | abort(); | ||
160 | } | ||
161 | |||
162 | |||
163 | extern "C" void dMessage (int num, const char *msg, ...) | ||
164 | { | ||
165 | va_list ap; | ||
166 | va_start (ap,msg); | ||
167 | if (message_function) message_function (num,msg,ap); | ||
168 | else printMessage (num,"ODE Message",msg,ap); | ||
169 | } | ||
170 | |||
171 | |||
172 | #endif | ||