00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _AFLIBDEBUG_H_
00029 #define _AFLIBDEBUG_H_
00030
00031
00032
00033
00034
00035
00036
00037
00038 #define aflib_fatal ::aflibDebug::fatal
00039 #define aflib_warning ::aflibDebug::warning
00040 #define aflib_info ::aflibDebug::info
00041 #define aflib_debug ::aflibDebug::debug
00042
00043
00044 #define aflibdebug ::aflibDebug::debug
00045 #define setaflibdebug(x) aflib_warning("setaflibdebug is obsolete")
00046
00047 #ifdef __GNUC__
00048
00049 #define aflib_return_if_fail(expr) \
00050 if (!(expr)) \
00051 { \
00052 aflib_warning ("file %s: line %d (%s): assertion failed: (%s)", \
00053 __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
00054 return; \
00055 }
00056
00057 #define aflib_return_val_if_fail(expr,val) \
00058 if (!(expr)) \
00059 { \
00060 aflib_warning ("file %s: line %d (%s): assertion failed: (%s)", \
00061 __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
00062 return (val); \
00063 }
00064
00065 #define aflib_assert(expr) \
00066 if (!(expr)) \
00067 aflib_fatal ("file %s: line %d (%s): assertion failed: (%s)", \
00068 __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr); \
00069
00070 #else
00071
00072 #define aflib_return_if_fail(expr) \
00073 if (!(expr)) \
00074 { \
00075 aflib_warning ("file %s: line %d: assertion failed: (%s)", \
00076 __FILE__, __LINE__, #expr); \
00077 return; \
00078 }
00079
00080 #define aflib_return_val_if_fail(expr,val) \
00081 if (!(expr)) \
00082 { \
00083 aflib_warning ("file %s: line %d: assertion failed: (%s)", \
00084 __FILE__, __LINE__, #expr); \
00085 return (val); \
00086 }
00087
00088 #define aflib_assert(expr) \
00089 if (!(expr)) \
00090 aflib_fatal ("file %s: line %d: assertion failed: (%s)", \
00091 __FILE__, __LINE__, #expr); \
00092
00093 #endif
00094
00095 class aflibDebug {
00096 public:
00097 enum Level { lFatal = 3, lWarning = 2, lInfo = 1, lDebug = 0 };
00098
00103 static void init(const char *prefix, Level level);
00104
00105 static void fatal(const char *fmt,...);
00106 static void warning(const char *fmt,...);
00107 static void info(const char *fmt,...);
00108 static void debug(const char *fmt,...);
00109
00114 static void messageApp(const char *appName);
00115
00116 };
00117
00118 #endif