:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / lib / ole32 / include / debug.h
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS WinSock 2 DLL
4  * FILE:        include/debug.h
5  * PURPOSE:     Debugging support macros
6  * DEFINES:     DBG     - Enable debug output
7  *              NASSERT - Disable assertions
8  */
9 #ifndef __DEBUG_H
10 #define __DEBUG_H
11
12 #define NORMAL_MASK    0x000000FF
13 #define SPECIAL_MASK   0xFFFFFF00
14 #define MIN_TRACE      0x00000001
15 #define MID_TRACE      0x00000002
16 #define MAX_TRACE      0x00000003
17
18 #define DEBUG_CHECK    0x00000100
19 #define DEBUG_ULTRA    0xFFFFFFFF
20
21 #ifdef DBG
22
23 extern DWORD DebugTraceLevel;
24
25 #define Print(_t_, _x_) \
26     if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
27         ((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
28         DbgPrint("(%hS:%d)(%hS) ", __FILE__, __LINE__, __FUNCTION__); \
29                 DbgPrint _x_; \
30     }
31
32 #ifdef ASSERT
33 #undef ASSERT
34 #endif
35
36 #ifdef NASSERT
37 #define ASSERT(x)
38 #else /* NASSERT */
39 #define ASSERT(x) if (!(x)) { Print(MIN_TRACE, ("Assertion "#x" failed at %s:%d\n", __FILE__, __LINE__)); ExitProcess(0); }
40 #endif /* NASSERT */
41
42 #else /* DBG */
43
44 #define Print(_t_, _x_)
45
46 #define ASSERT_IRQL(x)
47 #define ASSERT(x)
48
49 #endif /* DBG */
50
51
52 #define assert(x) ASSERT(x)
53 #define assert_irql(x) ASSERT_IRQL(x)
54
55
56 #define UNIMPLEMENTED \
57     Print(MIN_TRACE, ("is unimplemented, please try again later.\n"));
58
59 #define CHECKPOINT \
60     Print(DEBUG_CHECK, ("\n"));
61
62 #define CP CHECKPOINT
63
64
65 static char GuidBufferSpace[40];
66
67 static inline PCHAR PRINT_GUID( const GUID *id )
68 {
69     CHAR *str;
70
71     if (!id) return "(null)";
72
73     str = &GuidBufferSpace[0];
74
75     if (!HIWORD(id))
76     {
77         sprintf( str, "<guid-0x%04x>", LOWORD((ULONG)id) );
78     }
79     else
80     {
81         sprintf( str, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
82                  id->Data1, id->Data2, id->Data3,
83                  id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
84                  id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] );
85     }
86     return str;
87 }
88
89 #endif /* __DEBUG_H */
90
91 /* EOF */