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