| 1 | /*
 | 
|---|
| 2 |  * Miscellaneous definitions
 | 
|---|
| 3 |  * Debug prototypes and macros
 | 
|---|
| 4 |  */
 | 
|---|
| 5 | 
 | 
|---|
| 6 | 
 | 
|---|
| 7 | #ifndef __DBGLOG_H__
 | 
|---|
| 8 | #define __DBGLOG_H__
 | 
|---|
| 9 | 
 | 
|---|
| 10 | #if !defined(_OS2WIN_H) && !defined(__INCLUDE_WINUSER_H) && !defined(__WINE_WINBASE_H) && !defined(__WINE_WINDEF_H)
 | 
|---|
| 11 |   #include <win32type.h>
 | 
|---|
| 12 | #endif
 | 
|---|
| 13 | 
 | 
|---|
| 14 | #ifdef __cplusplus
 | 
|---|
| 15 |       extern "C" {
 | 
|---|
| 16 | #endif
 | 
|---|
| 17 | 
 | 
|---|
| 18 | #ifdef DEBUG
 | 
|---|
| 19 | #ifdef PRIVATE_LOGGING
 | 
|---|
| 20 |   //To use private dll logging, define PRIVATE_LOGGING and
 | 
|---|
| 21 |   //add Open/ClosePrivateLogFiles (see below) functions to the dll
 | 
|---|
| 22 |   //to open close the private logfile. The logfile handle should
 | 
|---|
| 23 |   //be stored in the _privateLogFile variable
 | 
|---|
| 24 |   //dprintf can be called like this:
 | 
|---|
| 25 |   //dprintf((LOG, "PE file           : %s", szFileName));
 | 
|---|
| 26 |   #define LOG             (void*)_privateLogFile
 | 
|---|
| 27 |   #define dprintf(a)      WritePrivateLog a
 | 
|---|
| 28 |   #define dprintfGlobal(a)      WriteLog a
 | 
|---|
| 29 | #else
 | 
|---|
| 30 |   #define dprintf(a)      WriteLog a
 | 
|---|
| 31 |   #define dprintfNoEOL(a)      WriteLogNoEOL a
 | 
|---|
| 32 | #endif
 | 
|---|
| 33 |   #define eprintf(a)      WriteLog a 
 | 
|---|
| 34 |   #define dassert(a, b)   if(!(a)) dprintf b
 | 
|---|
| 35 |   #define dbgCheckObj(a)        a->checkObject()
 | 
|---|
| 36 |   #define DisableLogging()  DecreaseLogCount()
 | 
|---|
| 37 |   #define EnableLogging()   IncreaseLogCount()
 | 
|---|
| 38 | 
 | 
|---|
| 39 | #ifdef DEBUG_ENABLELOG_LEVEL2
 | 
|---|
| 40 | #ifdef PRIVATE_LOGGING
 | 
|---|
| 41 |   #define dprintf2(a)      WritePrivateLog a
 | 
|---|
| 42 | #else
 | 
|---|
| 43 |   #define dprintf2(a)      WriteLog a
 | 
|---|
| 44 | #endif
 | 
|---|
| 45 | #else
 | 
|---|
| 46 |   #define dprintf2(a)
 | 
|---|
| 47 | #endif
 | 
|---|
| 48 | 
 | 
|---|
| 49 | #else
 | 
|---|
| 50 |   #define dprintfGlobal(a)
 | 
|---|
| 51 |   #define dprintf(a)
 | 
|---|
| 52 |   #define dprintf2(a)
 | 
|---|
| 53 |   #define dprintfNoEOL(a)
 | 
|---|
| 54 |   #define eprintf(a)
 | 
|---|
| 55 |   #define dassert(a, b)
 | 
|---|
| 56 |   #define dbgCheckObj(a)
 | 
|---|
| 57 |   #define DisableLogging()
 | 
|---|
| 58 |   #define EnableLogging()
 | 
|---|
| 59 | #endif
 | 
|---|
| 60 | 
 | 
|---|
| 61 | 
 | 
|---|
| 62 | // necessary types
 | 
|---|
| 63 | #ifndef __WINE_WINDEF_H
 | 
|---|
| 64 | #ifdef ULONG
 | 
|---|
| 65 |   #error ULONG definition is bad.
 | 
|---|
| 66 |   #define ULONG nope.
 | 
|---|
| 67 | #endif
 | 
|---|
| 68 | #ifndef NO_ULONG
 | 
|---|
| 69 |   typedef unsigned long ULONG;
 | 
|---|
| 70 |   typedef unsigned long HMODULE;
 | 
|---|
| 71 | #endif
 | 
|---|
| 72 | #endif //!__WINE_WINDEF_H
 | 
|---|
| 73 | 
 | 
|---|
| 74 | #ifndef SYSTEM
 | 
|---|
| 75 | #  define SYSTEM _System
 | 
|---|
| 76 | #endif
 | 
|---|
| 77 | 
 | 
|---|
| 78 | 
 | 
|---|
| 79 | int  SYSTEM WriteLog(char *tekst, ...);
 | 
|---|
| 80 | int  SYSTEM WriteLogNoEOL(char *tekst, ...);
 | 
|---|
| 81 | int  SYSTEM WritePrivateLog(void *logfile, char *tekst, ...);
 | 
|---|
| 82 | 
 | 
|---|
| 83 | void SYSTEM DecreaseLogCount();
 | 
|---|
| 84 | void SYSTEM IncreaseLogCount();
 | 
|---|
| 85 | 
 | 
|---|
| 86 | void SYSTEM CheckVersion(ULONG version, char *modname);
 | 
|---|
| 87 | 
 | 
|---|
| 88 | void SYSTEM CheckVersionFromHMOD(ULONG version, HMODULE hModule);
 | 
|---|
| 89 | 
 | 
|---|
| 90 | int  SYSTEM DebugErrorBox(ULONG  iErrorCode,
 | 
|---|
| 91 |                           char*  pszFormat,
 | 
|---|
| 92 |                           ...);
 | 
|---|
| 93 | 
 | 
|---|
| 94 | //To use private logfiles for dlls, you must have these functions and call
 | 
|---|
| 95 | //them when the dll is loaded (open) and the exitlist handler is called (close)
 | 
|---|
| 96 | void OpenPrivateLogFiles();
 | 
|---|
| 97 | void ClosePrivateLogFiles();
 | 
|---|
| 98 | 
 | 
|---|
| 99 | /* enable support for the _interrupt() statement */
 | 
|---|
| 100 | #if (defined(__IBMCPP__) || defined(__IBMC__))
 | 
|---|
| 101 | #  include <builtin.h>
 | 
|---|
| 102 | #ifdef DEBUG
 | 
|---|
| 103 | #ifdef __cplusplus
 | 
|---|
| 104 | void inline BreakPoint(char *szFile, char *szFunction)
 | 
|---|
| 105 | {
 | 
|---|
| 106 |   dprintf(("BREAKPOINT %s %s", szFile, szFunction));
 | 
|---|
| 107 |   _interrupt(3);
 | 
|---|
| 108 | }
 | 
|---|
| 109 |   #define DebugInt3()   BreakPoint(__FILE__, __FUNCTION__)
 | 
|---|
| 110 | 
 | 
|---|
| 111 | #else
 | 
|---|
| 112 |   #define DebugInt3()   _interrupt(3)
 | 
|---|
| 113 | #endif
 | 
|---|
| 114 | #else
 | 
|---|
| 115 |   #define DebugInt3()
 | 
|---|
| 116 | #endif
 | 
|---|
| 117 | 
 | 
|---|
| 118 | #else
 | 
|---|
| 119 | #ifdef DEBUG
 | 
|---|
| 120 |   #define DebugInt3()   _asm int 3;
 | 
|---|
| 121 | #else
 | 
|---|
| 122 |   #define DebugInt3()
 | 
|---|
| 123 | #endif
 | 
|---|
| 124 | 
 | 
|---|
| 125 | #endif
 | 
|---|
| 126 | 
 | 
|---|
| 127 | #ifdef __cplusplus
 | 
|---|
| 128 |         }
 | 
|---|
| 129 | #endif
 | 
|---|
| 130 | 
 | 
|---|
| 131 | 
 | 
|---|
| 132 | #endif //__DBGLOG_H__
 | 
|---|
| 133 | 
 | 
|---|