1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef __I4_ERROR_HPP_
|
---|
10 | #define __I4_ERROR_HPP_
|
---|
11 | #include "dll_export.hh"
|
---|
12 |
|
---|
13 | /* This is stub error and warning handler.
|
---|
14 | Currently error calls exit() and warn continues with a fprintf.
|
---|
15 | I expect this will be changed to pop up a dialog with an OK or something
|
---|
16 | of the like. */
|
---|
17 |
|
---|
18 | #ifdef __cplusplus
|
---|
19 | extern "C" {
|
---|
20 | #endif
|
---|
21 |
|
---|
22 | #include <stdarg.h>
|
---|
23 |
|
---|
24 | typedef int (*i4_error_function_type)(const char *str);
|
---|
25 |
|
---|
26 | void i4_set_error_function(i4_error_function_type fun);
|
---|
27 | i4_error_function_type i4_get_error_function();
|
---|
28 |
|
---|
29 | void i4_set_warning_function(i4_error_function_type fun);
|
---|
30 | i4_error_function_type i4_get_warning_function();
|
---|
31 |
|
---|
32 | int i4_default_warning(const char *st);
|
---|
33 | int i4_default_error(const char *st);
|
---|
34 |
|
---|
35 |
|
---|
36 | int i4_error_file_line(char *file, int line, const char *format, ...);
|
---|
37 | int i4_warning_file_line(char *file, int line, const char *format, ...);
|
---|
38 |
|
---|
39 | class i4_file_class;
|
---|
40 | extern i4_file_class *i4_debug; // stream you can print debug messages to
|
---|
41 |
|
---|
42 |
|
---|
43 | // this are so we can get the line and file an error occured on
|
---|
44 | typedef int (*i4_error_pointer_type)(const char *format ...);
|
---|
45 | i4_error_pointer_type i4_get_error_function_pointer(const char *file, int line);
|
---|
46 | i4_error_pointer_type i4_get_warning_function_pointer(const char *file, int line);
|
---|
47 | extern const char *i4_error_file_on;
|
---|
48 | extern int i4_error_line_on;
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 | #ifdef DEBUG
|
---|
53 | #define I4_LF __LINE__, __FILE__
|
---|
54 | #define I4_LF_ARGS int I4_LINE, char *I4_FILE
|
---|
55 | #define I4_DEBUG
|
---|
56 | #else
|
---|
57 | #define I4_LF
|
---|
58 | #define I4_LF_ARGS
|
---|
59 | #define I4_LINE 0
|
---|
60 | #define I4_FILE ""
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | #define I4_LF_ARG (char *I4_FILE, int I4_LINE)
|
---|
64 |
|
---|
65 |
|
---|
66 |
|
---|
67 | // i4_error and i4_warning looks like i4_error(char *fmt, ...) to the user
|
---|
68 | #define i4_error (i4_get_error_function_pointer(__FILE__,__LINE__))
|
---|
69 | #define i4_warning (i4_get_warning_function_pointer(__FILE__,__LINE__))
|
---|
70 |
|
---|
71 |
|
---|
72 | #ifdef I4_DEBUG
|
---|
73 |
|
---|
74 | #define I4_ASSERT(x,y) ((x)?0:i4_error("%s:%d - %s\n",__FILE__,__LINE__,y))
|
---|
75 | #define I4_TEST(x,y) ((x)?0:i4_warning("%s:%d - %s\n",__FILE__,__LINE__,y))
|
---|
76 | #define H() i4_warning("Reached %s:%d\n",__FILE__,__LINE__)
|
---|
77 |
|
---|
78 | #else
|
---|
79 |
|
---|
80 | #define I4_ASSERT(x,y) (0)
|
---|
81 | #define I4_TEST(x,y) (0)
|
---|
82 | #define H() (0)
|
---|
83 |
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | #ifdef __cplusplus
|
---|
87 | }
|
---|
88 | #endif
|
---|
89 |
|
---|
90 | #endif
|
---|
91 |
|
---|