source: golgotha/src/i4/error/error.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 12 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.6 KB
RevLine 
[80]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
19extern "C" {
20#endif
21
22#include <stdarg.h>
23
24typedef int (*i4_error_function_type)(const char *str);
25
26void i4_set_error_function(i4_error_function_type fun);
27i4_error_function_type i4_get_error_function();
28
29void i4_set_warning_function(i4_error_function_type fun);
30i4_error_function_type i4_get_warning_function();
31
32int i4_default_warning(const char *st);
33int i4_default_error(const char *st);
34
35
36int i4_error_file_line(char *file, int line, const char *format, ...);
37int i4_warning_file_line(char *file, int line, const char *format, ...);
38
39class i4_file_class;
40extern 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
44typedef int (*i4_error_pointer_type)(const char *format ...);
45i4_error_pointer_type i4_get_error_function_pointer(const char *file, int line);
46i4_error_pointer_type i4_get_warning_function_pointer(const char *file, int line);
47extern const char *i4_error_file_on;
48extern 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
Note: See TracBrowser for help on using the repository browser.