[7] | 1 | /*---------------------------------------------------------------------------+
|
---|
| 2 | |
|
---|
| 3 | | (C)opyright Dennis Bareis (developed at home, in own time) 1996 - ALL RIGHTS RESERVED
|
---|
| 4 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
---|
| 5 | |
|
---|
| 6 | | MODULE NAME: PMPRINTF.H
|
---|
| 7 | |
|
---|
| 8 | |
|
---|
| 9 | | $Author: umoeller $
|
---|
| 10 | | $Revision: 185 $
|
---|
| 11 | | $Date: 2002-07-05 09:22:37 +0000 (Fri, 05 Jul 2002) $
|
---|
| 12 | | $Logfile: V:/SUEPVCS/SUPPORT/TEMPLATE.H_V $
|
---|
| 13 | |
|
---|
| 14 | | DESCRIPTION:
|
---|
| 15 | |
|
---|
| 16 | | CONTACT: If you have any problems to report or better yet
|
---|
| 17 | | suggestions, you may email me
|
---|
| 18 | | at "dbareis@ozemail.com.au"...
|
---|
| 19 | +---------------------------------------------------------------------------*/
|
---|
| 20 | #ifndef HEADER_PMPRINTF_H
|
---|
| 21 | #define HEADER_PMPRINTF_H
|
---|
| 22 |
|
---|
| 23 | /*--- We need access to "stdarg.h" ------------------------------------------*/
|
---|
| 24 | #ifndef __stdarg_h
|
---|
| 25 | #include <stdarg.h>
|
---|
| 26 | #endif
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | /*--- If C++ declare header as 'C' ------------------------------------------*/
|
---|
| 30 | #ifdef __cplusplus
|
---|
| 31 | extern "C"
|
---|
| 32 | {
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
| 35 | /*--- Ensure we have the packing we require ---------------------------------*/
|
---|
| 36 | #pragma pack(1)
|
---|
| 37 |
|
---|
| 38 | /*--- General definitions ---------------------------------------------------*/
|
---|
| 39 | #define PMPRINTF_VERSION "96.174"
|
---|
| 40 | #define PMPRINTF_QUEUE_PREFIX "\\QUEUES\\"
|
---|
| 41 | #define PMPRINTF_DEFAULT_QUEUE_NAME PMPRINTF_QUEUE_PREFIX "PRINTF32"
|
---|
| 42 | typedef ULONG PMPRINTF_MODE;
|
---|
| 43 | /*--- For each line send ... ----------------------------------------*/
|
---|
| 44 | #define PMPRINTF_SEND_TIME 0x00000001
|
---|
| 45 | #define PMPRINTF_SEND_PROC_INFO 0x00000002
|
---|
| 46 |
|
---|
| 47 | /*--- Other flags which don't effect the line sent to PMPRINTF.EXE ---*/
|
---|
| 48 | #define PMPRINTF_NOISE_ON_OK_AGAIN 0x40000000
|
---|
| 49 | #define PMPRINTF_NO_NOISE_ON_ERROR 0x80000000
|
---|
| 50 |
|
---|
| 51 | /*--- Combine flags for ease of use ---------------------------------*/
|
---|
| 52 | #define PMPRINTF_ALL_HEADER_FIELDS_EXCEPT_TIME (PMPRINTF_SEND_PROC_INFO)
|
---|
| 53 | #define PMPRINTF_ALL_HEADER_FIELDS (PMPRINTF_ALL_HEADER_FIELDS_EXCEPT_TIME | PMPRINTF_SEND_TIME)
|
---|
| 54 | #define PMPRINTF_DEFAULT_MODE PMPRINTF_ALL_HEADER_FIELDS_EXCEPT_TIME
|
---|
| 55 |
|
---|
| 56 | /*--- Define some per thread data (for efficiency) --------------------------*/
|
---|
| 57 | #define PMPRINTF_MAX_DATA_CHARS 2000 //The output from sprintf() should not produce output whose strlen() is greater than this
|
---|
| 58 | #define PMPRINTF_MAX_LINE_CHARS 500 //This is the maximum line length that is sent to PMPRINTF.EXE
|
---|
| 59 | #define PMPRINTF_MAX_HEADER_CHARS 100 //This is the maximum length of any possible header.
|
---|
| 60 | #define MAX_THREADS 255 //Per Process! (can't find real limit documented or in C/Toolkit headers)
|
---|
| 61 | typedef struct PER_THREAD
|
---|
| 62 | {
|
---|
| 63 | /*--- The following value indicates that PMPRINTF.EXE should beep -------*/
|
---|
| 64 | BOOL Beep;
|
---|
| 65 |
|
---|
| 66 | /*--- The following is used to sprintf() data into ----------------------*/
|
---|
| 67 | char FormattedMessage[PMPRINTF_MAX_DATA_CHARS+1];
|
---|
| 68 |
|
---|
| 69 | /*--- The following is used as a line buffer, when full sent to PMPRINTF.EXE ---*/
|
---|
| 70 | char Line[PMPRINTF_MAX_LINE_CHARS+1];
|
---|
| 71 |
|
---|
| 72 | /*--- If this value is non-zero then "Line" contains "header" information ---*/
|
---|
| 73 | ULONG MacroHeaderLength;
|
---|
| 74 |
|
---|
| 75 | /*--- Define a header buffer where "standard" header info is formatted ---*/
|
---|
| 76 | char LineHeader[PMPRINTF_MAX_HEADER_CHARS+1];
|
---|
| 77 |
|
---|
| 78 | /*--- Some other interesting information --------------------------------*/
|
---|
| 79 | void * Pib;
|
---|
| 80 | void * Tib;
|
---|
| 81 | } PER_THREAD;
|
---|
| 82 |
|
---|
| 83 |
|
---|
| 84 | /*--- Definitions for "PMPRINTF.C" ------------------------------------------*/
|
---|
| 85 | PMPRINTF_MODE _System PmPrintfModeSet(PMPRINTF_MODE NewMode);
|
---|
| 86 | char * _System PmPrintfQueueNameThisProcess(PSZ StaticPmprintfQueueName);
|
---|
| 87 | ULONG _System PmPrintf(PSZ Format, ...);
|
---|
| 88 | ULONG _System PmPrintfVa(PSZ Format, va_list args);
|
---|
| 89 | ULONG _System PmPrintfString(PSZ String);
|
---|
| 90 | ULONG _System PmPrintfDisplayInterfaceVersionInfo(void);
|
---|
| 91 | ULONG _System I_PmpfSetMacroHeader(PSZ SourceModule, int LineNumber, PSZ Function);
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 | /*--- Make sure the "__FUNCTION__" macro exists -----------------------------*/
|
---|
| 95 | #ifndef __FUNCTION__
|
---|
| 96 | #define __FUNCTION__ "FunctionUnknown(?)" //IBM CSET 2.01 and onwards support this
|
---|
| 97 | #endif
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | /*--- Useful Macros ---------------------------------------------------------*/
|
---|
| 101 | #define Pmpf(FmtAndVariableParmsInBrackets) \
|
---|
| 102 | do \
|
---|
| 103 | { \
|
---|
| 104 | /*--- Output a header ---------------------------------------*/ \
|
---|
| 105 | I_PmpfSetMacroHeader(__FILE__, __LINE__, NULL); \
|
---|
| 106 | \
|
---|
| 107 | /*--- Output the message ------------------------------------*/ \
|
---|
| 108 | PmPrintf FmtAndVariableParmsInBrackets; \
|
---|
| 109 | } \
|
---|
| 110 | while (0)
|
---|
| 111 | #define PmpfF(FmtAndVariableParmsInBrackets) \
|
---|
| 112 | do \
|
---|
| 113 | { \
|
---|
| 114 | /*--- Output a header ---------------------------------------*/ \
|
---|
| 115 | I_PmpfSetMacroHeader(__FILE__, __LINE__, __FUNCTION__); \
|
---|
| 116 | \
|
---|
| 117 | /*--- Output the message ------------------------------------*/ \
|
---|
| 118 | PmPrintf FmtAndVariableParmsInBrackets; \
|
---|
| 119 | } \
|
---|
| 120 | while (0)
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | /*--- Simple to use "Here I am" macros --------------------------------------*/
|
---|
| 124 | #ifndef PMPRINTF_HERE_I_AM_MSG
|
---|
| 125 | #define PMPRINTF_HERE_I_AM_MSG " DebugHereIAm()"
|
---|
| 126 | #endif
|
---|
| 127 | #define DebugHereIAm() PmpfF((PMPRINTF_HERE_I_AM_MSG))
|
---|
| 128 |
|
---|
| 129 |
|
---|
| 130 | /*--- Macros you can conditionally include ----------------------------------*/
|
---|
| 131 | #ifdef _PMPRINTF_
|
---|
| 132 | /*--- The user wants to include these debug lines -------------------*/
|
---|
[185] | 133 | #define _Pmpf(FmtAndVariableParmsInBrackets) Pmpf(FmtAndVariableParmsInBrackets)
|
---|
| 134 | #define _PmpfF(FmtAndVariableParmsInBrackets) PmpfF(FmtAndVariableParmsInBrackets)
|
---|
[7] | 135 | #define _DebugHereIAm() DebugHereIAm()
|
---|
| 136 | #else
|
---|
| 137 | /*--- The user does not wish to include the debug stuff -------------*/
|
---|
| 138 | #define _Pmpf(FmtAndVariableParmsInBrackets)
|
---|
| 139 | #define _PmpfF(FmtAndVariableParmsInBrackets)
|
---|
| 140 | #define _DebugHereIAm()
|
---|
| 141 | #endif
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | /*--- Restore original pacing level -----------------------------------------*/
|
---|
| 145 | #pragma pack()
|
---|
| 146 |
|
---|
| 147 | /*--- If C++ end declaration of header as 'C' -------------------------------*/
|
---|
| 148 | #ifdef __cplusplus
|
---|
| 149 | }
|
---|
| 150 | #endif
|
---|
| 151 | #endif
|
---|
| 152 |
|
---|
| 153 |
|
---|