:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / lib / shell32 / control / trace.c
1 /////////////////////////////////////////////////////////////////////////////
2 // Diagnostic Trace
3 //
4 #include <stdio.h> 
5 #include <stdarg.h>
6 #define WIN32_LEAN_AND_MEAN
7 #include "windows.h"
8 #include "trace.h"
9
10
11 #ifdef _DEBUG
12
13 #ifdef WIN32
14 //#define WIN32_LEAN_AND_MEAN           // Exclude rarely-used stuff from Windows headers
15 //#include <windows.h>
16 //#include <assert.h>
17 //WINBASEAPI VOID WINAPI DebugBreak(VOID);
18 //WINBASEAPI VOID WINAPI OutputDebugStringA(LPCSTR lpOutputString);
19 //WINBASEAPI VOID WINAPI OutputDebugStringW(LPCWSTR lpOutputString);
20 //void __stdcall DebugBreak(void);
21 //void __stdcall OutputDebugStringA(char* lpOutputString);
22 //void __stdcall OutputDebugStringW(wchar_t* lpOutputString);
23 #ifdef UNICODE
24 #define OutputDebugString  OutputDebugStringW
25 #else
26 #define OutputDebugString  OutputDebugStringA
27 #endif // !UNICODE
28
29 #else
30 #include "hardware.h"
31 #endif // WIN32
32
33
34 #undef THIS_FILE
35 static char THIS_FILE[] = __FILE__;
36
37 void _DebugBreak(void)
38 {
39     DebugBreak();
40 }
41
42 void Trace(TCHAR* lpszFormat, ...)
43 {
44     va_list args;
45     int nBuf;
46     TCHAR szBuffer[512];
47
48     va_start(args, lpszFormat);
49 //  nBuf = vsprintf(szBuffer, lpszFormat, args);
50 //  nBuf = _vsntprintf(szBuffer, _countof(szBuffer), lpszFormat, args);
51 #ifdef _UNICODE
52     nBuf = _vsnwprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
53 #else
54     nBuf = _vsnprintf(szBuffer, sizeof(szBuffer)/sizeof(TCHAR), lpszFormat, args);
55 #endif
56     OutputDebugString(szBuffer);
57     // was there an error? was the expanded string too long?
58 //    ASSERT(nBuf >= 0);
59     va_end(args);
60 }
61
62 void Assert(void* assert, TCHAR* file, int line, void* msg)
63 {
64     if (msg == NULL) {
65         printf("ASSERT -- %s occured on line %u of file %s.\n",
66                assert, line, file);
67     } else {
68         printf("ASSERT -- %s occured on line %u of file %s: Message = %s.\n",
69                assert, line, file, msg);
70     }
71 }
72
73
74 #else
75
76 //inline void Trace(TCHAR* lpszFormat, ...) { };
77 //inline void Assert(void* assert, TCHAR* file, int line, void* msg) { };
78 void Trace(TCHAR* lpszFormat, ...) { };
79 void Assert(void* assert, TCHAR* file, int line, void* msg) { };
80
81 #endif //_DEBUG
82 /////////////////////////////////////////////////////////////////////////////