00001 #ifndef __UT_Debug__
00002 #define __UT_Debug__
00003
00004 #include "UT_API.h"
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef UT_DEBUG
00024
00025 #include <stdlib.h>
00026 #include <string.h>
00027
00028 #define UT_IF(s) s
00029 #define UT_IFNOT(s)
00030 #define UT_IFELSE(t, f) t
00031
00032 class UT_API UT_Debug
00033 {
00034 public:
00035 explicit UT_Debug(const char *name) { myState = getenv(name) != 0; }
00036 int on() const { return myState; }
00037 void setDebugFile(const char *) const;
00038 void output(const char *fmt, ...) const;
00039 private:
00040 int myState;
00041 };
00042
00043 #else
00044
00045 #define UT_IF(s)
00046 #define UT_IFNOT(s) s
00047 #define UT_IFELSE(t, f) f
00048
00049 class UT_API UT_Debug
00050 {
00051 public:
00052 explicit UT_Debug(const char *) {}
00053 int on() const { return 0; }
00054 void setDebugFile(const char *) const;
00055 void output(const char *, ...) const;
00056 };
00057
00058 #endif
00059
00060
00061
00062 #ifdef UT_DEBUG
00063 #include <stdio.h>
00064
00065 #define UT_DBGOUT(ZZ) { \
00066 const char *basename = strrchr(__FILE__, '/'); \
00067 if (!basename) basename = __FILE__; \
00068 else basename++; \
00069 printf( "%s(%d): ", basename, __LINE__ ); \
00070 printf ZZ ; \
00071 printf( "\n" ); \
00072 }
00073 #define UT_DBGPRINTF(ZZ) printf ZZ
00074 #define UT_DBG_CHECKMEMORY UTdebugCheckMemory()
00075 #else
00076 #define UT_DBGOUT(ZZ)
00077 #define UT_DBGPRINTF(ZZ)
00078 #define UT_DBG_CHECKMEMORY
00079 #endif
00080
00081
00082
00083
00084
00085
00086
00087 UT_API int UTgetSESIlogFlag(int env_control);
00088
00089
00090
00091
00092
00093
00094 UT_API int UTisSESImachine();
00095
00096 UT_API int UTdebugCheckMemory();
00097
00098 #endif