00001
00002
00003
00004
00005
00006
00007
00008
00009 #if !defined(__debug_h)
00010 #define __debug_h 1
00011
00012 #include <stdio.h>
00013 #include <ctype.h>
00014
00015 #if defined(DEBUG)
00016
00017 #define DBG_MSG(t) (void)fprintf(stderr,\
00018 "%s[%3d]: %.240s\n",\
00019 __FILE__, __LINE__, (t))
00020
00021 #define DBG_STRN(t,m) (void)fprintf(stderr,\
00022 "%s[%3d]: %d '%.*s'\n",\
00023 __FILE__, __LINE__,\
00024 (int)(m), (int)(m), (const char *)(t))
00025
00026 #define DBG_CHR(m) (void)fprintf(stderr,\
00027 "%s[%3d]: "#m" = %3d 0x%02x '%c'\n",\
00028 __FILE__, __LINE__,\
00029 (int)(m), (unsigned int)(unsigned char)(m),\
00030 isprint((int)(unsigned char)(m))?(char)(m):' ')
00031
00032 #define DBG_DEC(m) (void)fprintf(stderr,\
00033 "%s[%3d]: "#m" = %ld\n",\
00034 __FILE__, __LINE__, (long)(m))
00035
00036 #define DBG_HEX(m) (void)fprintf(stderr,\
00037 "%s[%3d]: "#m" = 0x%02lx\n",\
00038 __FILE__, __LINE__, (unsigned long)(m))
00039
00040 #define DBG_FLT(m) (void)fprintf(stderr,\
00041 "%s[%3d]: "#m" = %.3f\n",\
00042 __FILE__, __LINE__, (double)(m))
00043
00044 #define DBG_FIXME() (void)fprintf(stderr,\
00045 "%s[%3d]: FIXME\n",\
00046 __FILE__, __LINE__)
00047
00048 #define DBG_PRINT_BLOCK(b,m) vPrintBlock(__FILE__, __LINE__,(b),(m))
00049 #define DBG_UNICODE(t) vPrintUnicode(__FILE__, __LINE__,\
00050 (const UCHAR *)(t),unilen(t))
00051 #define DBG_UNICODE_N(t,m) vPrintUnicode(__FILE__, __LINE__,\
00052 (const UCHAR *)(t),(m))
00053
00054 #define DBG_MSG_C(c,t) do { if (c) DBG_MSG(t); } while(0)
00055 #define DBG_STRN_C(c,t,m) do { if (c) DBG_STRN(t,m); } while(0)
00056 #define DBG_CHR_C(c,m) do { if (c) DBG_CHR(m); } while(0)
00057 #define DBG_DEC_C(c,m) do { if (c) DBG_DEC(m); } while(0)
00058 #define DBG_HEX_C(c,m) do { if (c) DBG_HEX(m); } while(0)
00059 #define DBG_FLT_C(c,m) do { if (c) DBG_FLT(m); } while(0)
00060
00061 #else
00062
00063 #define DBG_MSG(t)
00064 #define DBG_STRN(t,m)
00065 #define DBG_CHR(m)
00066 #define DBG_DEC(m)
00067 #define DBG_HEX(m)
00068 #define DBG_FLT(m)
00069
00070 #define DBG_FIXME()
00071 #define DBG_PRINT_BLOCK(b,m)
00072 #define DBG_UNICODE(t)
00073 #define DBG_UNICODE_N(t,m)
00074
00075 #define DBG_MSG_C(c,t)
00076 #define DBG_STRN_C(c,t,m)
00077 #define DBG_CHR_C(c,m)
00078 #define DBG_DEC_C(c,m)
00079 #define DBG_HEX_C(c,m)
00080 #define DBG_FLT_C(c,m)
00081
00082 #endif
00083
00084 #define NO_DBG_MSG(t)
00085 #define NO_DBG_STRN(t,m)
00086 #define NO_DBG_CHR(m)
00087 #define NO_DBG_DEC(m)
00088 #define NO_DBG_HEX(m)
00089 #define NO_DBG_FLT(m)
00090
00091 #define NO_DBG_PRINT_BLOCK(b,m)
00092 #define NO_DBG_UNICODE(t)
00093 #define NO_DBG_UNICODE_N(t,m)
00094
00095 #define NO_DBG_MSG_C(c,t)
00096 #define NO_DBG_STRN_C(c,t,m)
00097 #define NO_DBG_CHR_C(c,m)
00098 #define NO_DBG_DEC_C(c,m)
00099 #define NO_DBG_HEX_C(c,m)
00100 #define NO_DBG_FLT_C(c,m)
00101
00102 #if defined(TRACE)
00103
00104 #define TRACE_MSG(t) do {\
00105 (void)fprintf(stderr,\
00106 "%s[%3d]: TRACE:%.40s\n",\
00107 __FILE__, __LINE__, (t));\
00108 (void)fflush(stderr);\
00109 } while(0)
00110
00111 #else
00112
00113 #define TRACE_MSG(t)
00114
00115 #endif
00116
00117 #endif