source: trunk/include/helpers/pmprintf.h@ 24

Last change on this file since 24 was 7, checked in by umoeller, 25 years ago

Initial checkin of helpers code, which used to be in WarpIN.

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