| 1 | /*---------------------------------------------------------------------------+ | 
|---|
| 2 | | | 
|---|
| 3 | |     (C)opyright Dennis Bareis (developed at home, in own time) 1996 - ALL RIGHTS RESERVED | 
|---|
| 4 | |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 
|---|
| 5 | | | 
|---|
| 6 | |     MODULE NAME:   WPSDEBUG.H | 
|---|
| 7 | | | 
|---|
| 8 | | | 
|---|
| 9 | |         $Author: umoeller $ | 
|---|
| 10 | |       $Revision: 41 $ | 
|---|
| 11 | |           $Date: 2001-03-03 10:58:48 +0000 (Sat, 03 Mar 2001) $ | 
|---|
| 12 | |        $Logfile:   V:/SUEPVCS/SUPPORT/TEMPLATE.H_V  $ | 
|---|
| 13 | | | 
|---|
| 14 | |     DESCRIPTION:   Note that any items that begin with an "I_" are for | 
|---|
| 15 | |                    internal use, not for general debugging. | 
|---|
| 16 | | | 
|---|
| 17 | |                    This header file is for SOM/WPS debugging and uses | 
|---|
| 18 | |                    the PMPRINTF.EXE program to display the output.  Use | 
|---|
| 19 | |                    of this API instead of my PMPRINTF API ensures that | 
|---|
| 20 | |                    SOM/WPS messages other than those you put out (for | 
|---|
| 21 | |                    example base OS/2 errors) should and will be mingled | 
|---|
| 22 | |                    with your messages and hopefully being of some use! | 
|---|
| 23 | | | 
|---|
| 24 | |         CONTACT:   If you have any problems to report or better yet | 
|---|
| 25 | |                    suggestions, you may email me | 
|---|
| 26 | |                    at "dbareis@ozemail.com.au"... | 
|---|
| 27 | +---------------------------------------------------------------------------*/ | 
|---|
| 28 | #ifndef  HEADER_WPSDEBUG_H | 
|---|
| 29 | #define  HEADER_WPSDEBUG_H | 
|---|
| 30 |  | 
|---|
| 31 | /*--- Need access to "PMPRINTF" ---------------------------------------------*/ | 
|---|
| 32 | #ifndef  HEADER_PMPRINTF_H | 
|---|
| 33 | #include "PMPRINTF.H" | 
|---|
| 34 | #endif | 
|---|
| 35 |  | 
|---|
| 36 | /*--- If C++ declare header as 'C' ------------------------------------------*/ | 
|---|
| 37 | #ifdef __cplusplus | 
|---|
| 38 | extern "C" | 
|---|
| 39 | { | 
|---|
| 40 | #endif | 
|---|
| 41 |  | 
|---|
| 42 | /*--- Define version number -------------------------------------------------*/ | 
|---|
| 43 | #define WPSDEBUG_VERSION  "96.175" | 
|---|
| 44 |  | 
|---|
| 45 | /*--- Make sure the "__FUNCTION__" macro exists -----------------------------*/ | 
|---|
| 46 | #ifndef __FUNCTION__ | 
|---|
| 47 | #define __FUNCTION__ "FunctionUnknown(?)"   //IBM CSET 2.01 and onwards support this | 
|---|
| 48 | #endif | 
|---|
| 49 |  | 
|---|
| 50 | /*--- Define the maximum line length ----------------------------------------*/ | 
|---|
| 51 | #define WPSDEBUG_MAX_LINE_CHARS   PMPRINTF_MAX_LINE_CHARS | 
|---|
| 52 |  | 
|---|
| 53 |  | 
|---|
| 54 | /*--- Use this macro to turn on/off tracing ---------------------------------*/ | 
|---|
| 55 | #define  WpsDebugHigh()                                \ | 
|---|
| 56 | WpsDebugInstall(WPSDEBUG_TLEVEL_CORE_AND_USER, PMPRINTF_ALL_HEADER_FIELDS_EXCEPT_TIME) | 
|---|
| 57 | #define  WpsDebugInstall(TraceLevel, PmprintfMode)     \ | 
|---|
| 58 | I_WpsDebugInstall(TraceLevel, PmprintfMode, (void *)&SOMOutCharRoutine, &SOM_TraceLevel) | 
|---|
| 59 |  | 
|---|
| 60 |  | 
|---|
| 61 | /*--- Better debug macro ----------------------------------------------------*/ | 
|---|
| 62 | #define WpsDebug(FmtAndVariableParmsInBrackets)                                  \ | 
|---|
| 63 | do                                                                       \ | 
|---|
| 64 | {                                                                        \ | 
|---|
| 65 | /*--- Don't do anything if debugging is not turned on -----------*/  \ | 
|---|
| 66 | if  (SOM_TraceLevel != 0)                                            \ | 
|---|
| 67 | {                                                                    \ | 
|---|
| 68 | /*--- Output a header ---------------------------------------*/  \ | 
|---|
| 69 | I_WpsDebugOutputModuleIdHeader(__FILE__, __LINE__, NULL);        \ | 
|---|
| 70 | \ | 
|---|
| 71 | /*--- Output the message ------------------------------------*/  \ | 
|---|
| 72 | somPrintf FmtAndVariableParmsInBrackets;                         \ | 
|---|
| 73 | }                                                                    \ | 
|---|
| 74 | }                                                                        \ | 
|---|
| 75 | while   (0) | 
|---|
| 76 | #define WpsDebugF(FmtAndVariableParmsInBrackets)                                 \ | 
|---|
| 77 | do                                                                       \ | 
|---|
| 78 | {                                                                        \ | 
|---|
| 79 | /*--- Don't do anything if debugging is not turned on -----------*/  \ | 
|---|
| 80 | if  (SOM_TraceLevel != 0)                                            \ | 
|---|
| 81 | {                                                                    \ | 
|---|
| 82 | /*--- Output a header ---------------------------------------*/  \ | 
|---|
| 83 | I_WpsDebugOutputModuleIdHeader(__FILE__, __LINE__, __FUNCTION__);\ | 
|---|
| 84 | \ | 
|---|
| 85 | /*--- Output the message ------------------------------------*/  \ | 
|---|
| 86 | somPrintf FmtAndVariableParmsInBrackets;                         \ | 
|---|
| 87 | }                                                                    \ | 
|---|
| 88 | }                                                                        \ | 
|---|
| 89 | while   (0) | 
|---|
| 90 |  | 
|---|
| 91 | /*--- Simple to use "Here I am" macros --------------------------------------*/ | 
|---|
| 92 | #ifndef  WPSDEBUG_HERE_I_AM_MSG | 
|---|
| 93 | #define WPSDEBUG_HERE_I_AM_MSG  " Here I am" | 
|---|
| 94 | #endif | 
|---|
| 95 | #define WpsDebugHereIAm()       WpsDebugF((WPSDEBUG_HERE_I_AM_MSG "\n")) | 
|---|
| 96 |  | 
|---|
| 97 |  | 
|---|
| 98 | /*--- Method starting & stopping macros -------------------------------------*/ | 
|---|
| 99 | #define WpsDebugMethodStart()   WpsDebugF(("Method Starting" "\n")) | 
|---|
| 100 | #define WpsDebugMethodEnd()     WpsDebugF(("Method ending"   "\n")) | 
|---|
| 101 |  | 
|---|
| 102 |  | 
|---|
| 103 | /*--- The following macros allow you to conditionly include debug code ------*/ | 
|---|
| 104 | #ifdef  _WPSDEBUG_ | 
|---|
| 105 | /*--- The user wants to include these debug lines -------------------*/ | 
|---|
| 106 | #define _WpsDebugHigh()                            WpsDebugHigh() | 
|---|
| 107 | #define _WpsDebugInstall(TraceLevel, PmprintfMode) WpsDebugInstall(TraceLevel, PmprintfMode) | 
|---|
| 108 | #define _WpsDebug(FmtAndVariableParmsInBrackets)   WpsDebug(FmtAndVariableParmsInBrackets) | 
|---|
| 109 | #define _WpsDebugF(FmtAndVariableParmsInBrackets)  WpsDebugF(FmtAndVariableParmsInBrackets) | 
|---|
| 110 | #define _WpsDebugHereIAm()                         WpsDebugHereIAm() | 
|---|
| 111 | #define _WpsDebugMethodStart()                     WpsDebugMethodStart() | 
|---|
| 112 | #define _WpsDebugMethodEnd()                       WpsDebugMethodEnd() | 
|---|
| 113 | #else | 
|---|
| 114 | /*--- The user does not wish to include the debug stuff -------------*/ | 
|---|
| 115 | #define _WpsDebugHigh() | 
|---|
| 116 | #define _WpsDebugInstall(TraceLevel, PmprintfMode) | 
|---|
| 117 | #define _WpsDebug(FmtAndVariableParmsInBrackets) | 
|---|
| 118 | #define _WpsDebugF(FmtAndVariableParmsInBrackets) | 
|---|
| 119 | #define _WpsDebugHereIAm() | 
|---|
| 120 | #define _WpsDebugMethodStart() | 
|---|
| 121 | #define _WpsDebugMethodEnd() | 
|---|
| 122 | #endif | 
|---|
| 123 |  | 
|---|
| 124 |  | 
|---|
| 125 | /*--- Definitions for "WPSDEBUG.C" ------------------------------------------*/ | 
|---|
| 126 | void _Optlink I_WpsDebugOutputModuleIdHeader(UCHAR *SourceModule, int LineNumber, UCHAR *Function); | 
|---|
| 127 | void _Optlink I_WpsDebugInstall( int           TraceLevel, | 
|---|
| 128 | #define   WPSDEBUG_TLEVEL_NONE          0 | 
|---|
| 129 | #define   WPSDEBUG_TLEVEL_USER          1 | 
|---|
| 130 | #define   WPSDEBUG_TLEVEL_CORE_AND_USER 2 | 
|---|
| 131 | PMPRINTF_MODE PmprintfMode, | 
|---|
| 132 | void       * *AddressOfSOMOutCharRoutine, | 
|---|
| 133 | int        *  AddressOfSOM_TraceLevel | 
|---|
| 134 | ); | 
|---|
| 135 | void _Optlink WpsDebugPmMsgBox( UCHAR * Title, | 
|---|
| 136 | UCHAR * Format, | 
|---|
| 137 | ... | 
|---|
| 138 | ); | 
|---|
| 139 |  | 
|---|
| 140 |  | 
|---|
| 141 |  | 
|---|
| 142 |  | 
|---|
| 143 | /*--- Override the default "SOMMethodDebug()" macro -------------------------*/ | 
|---|
| 144 | #define  WPSDEBUG_SOMMETHODDEBUG(ClassName, MethodName)          \ | 
|---|
| 145 | _WpsDebugF(("Class = \"%s\"\n", ClassName))      /* Default action */ | 
|---|
| 146 | #ifdef   SOMMethodDebug | 
|---|
| 147 | #undef  SOMMethodDebug | 
|---|
| 148 | #endif | 
|---|
| 149 | #define  SOMMethodDebug(ClassName, MethodName)                   \ | 
|---|
| 150 | WPSDEBUG_SOMMETHODDEBUG(ClassName, MethodName); | 
|---|
| 151 |  | 
|---|
| 152 |  | 
|---|
| 153 | /*--- If C++ end declaration of header as 'C' -------------------------------*/ | 
|---|
| 154 | #ifdef __cplusplus | 
|---|
| 155 | } | 
|---|
| 156 | #endif | 
|---|
| 157 | #endif | 
|---|
| 158 |  | 
|---|
| 159 |  | 
|---|