00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
#ifndef _DEBUG_H_
00017 
#define _DEBUG_H_
00018 
00019 
#ifdef DBG
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 PSTR StripDirPrefixA(PSTR);
00031 
VOID MyDebugPrintW(PWSTR, ...);
00032 
VOID MyDebugPrintA(PSTR, ...);
00033 
00034 
#ifdef UNICODE
00035 
#define MyDebugPrint    MyDebugPrintW
00036 
#else
00037 
#define MyDebugPrint    MyDebugPrintA
00038 
#endif
00039 
00040 
#define DBGPRINT            MyDebugPrint
00041 
#define DBGPRINTA           MyDebugPrintA
00042 
#define DBGBREAK()          DebugBreak()
00043 
00044 
00045 
00046 
00047 
00048 
#define DBG_LEVEL_VERBOSE   0x00000001
00049 
#define DBG_LEVEL_TERSE     0x00000002
00050 
#define DBG_LEVEL_WARNING   0x00000003
00051 
#define DBG_LEVEL_ERROR     0x00000004
00052 
#define DBG_LEVEL_FATAL     0x00000005
00053 
00054 
00055 
00056 
00057 
00058 
#define FLAG_TRACEAPI       0x00010000      // Trace API entries
00059 
00060 
#define CHECK_DBG_LEVEL(level)  ((level) >= gdwDebugControl)
00061 
00062 
#define TRACEAPI(funcname)                                              \
00063 
    {                                                                   \
00064 
        if (gdwDebugControl & FLAG_TRACEAPI)                            \
00065 
        {                                                               \
00066 
            DBGPRINTA("ICM: Entering function ");                       \
00067 
            DBGPRINT funcname;                                          \
00068 
        }                                                               \
00069 
    }
00070 
00071 
#define DBGMSG(level, mesg)                                             \
00072 
    {                                                                   \
00073 
        if (CHECK_DBG_LEVEL(level))                                     \
00074 
        {                                                               \
00075 
            DBGPRINTA("ICM: %s (%d): ",                                 \
00076 
                    StripDirPrefixA(__FILE__), __LINE__);               \
00077 
            DBGPRINT mesg;                                              \
00078 
        }                                                               \
00079 
    }
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
#define VERBOSE(mesg)       DBGMSG(DBG_LEVEL_VERBOSE, mesg)
00091 
#define TERSE(mesg)         DBGMSG(DBG_LEVEL_TERSE,   mesg)
00092 
#define WARNING(mesg)       DBGMSG(DBG_LEVEL_WARNING, mesg)
00093 
#define ERR(mesg)           DBGMSG(DBG_LEVEL_ERROR,   mesg)
00094 
#define FATAL(mesg)         DBGMSG(DBG_LEVEL_FATAL,   mesg)
00095 
00096 
00097 
00098 
00099 
00100 
00101 
#define ASSERT(expr)                                                    \
00102 
    {                                                                   \
00103 
        if (! (expr)) {                                                 \
00104 
            DBGPRINTA("ICM: Assertion failed: %s (%d)\n",               \
00105 
                    StripDirPrefixA(__FILE__), __LINE__);               \
00106 
            DBGBREAK();                                                 \
00107 
        }                                                               \
00108 
    }
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
#define ASSERTMSG(expr, mesg)                                           \
00119 
    {                                                                   \
00120 
        if (! (expr)) {                                                 \
00121 
            DBGPRINTA("ICM: Assertion failed: %s (%d)\n",               \
00122 
                    StripDirPrefixA(__FILE__), __LINE__);               \
00123 
            DBGPRINT mesg;                                              \
00124 
            DBGPRINTA("\n");                                            \
00125 
            DBGBREAK();                                                 \
00126 
        }                                                               \
00127 
    }
00128 
00129 
#define RIP(mesg)                                                       \
00130 
    {                                                                   \
00131 
        DBGPRINTA("ICM: ");                                             \
00132 
        DBGPRINT mesg;                                                  \
00133 
        DBGBREAK();                                                     \
00134 
    }
00135 
00136 
#else   // !DBG
00137 
00138 #define TRACEAPI(mesg)
00139 #define DBGMSG(level, mesg)
00140 #define VERBOSE(mesg)
00141 #define TERSE(mesg)
00142 #define WARNING(mesg)
00143 #define ERR(mesg)
00144 #define FATAL(mesg)
00145 
00146 #define ASSERT(expr)
00147 #define ASSERTMSG(expr, mesg)
00148 
00149 #define RIP(mesg)
00150 
00151 
#endif  // !DBG
00152 
00153 
#endif  // ifndef _DEBUG_H_
00154