death to trailing whitespace
[openafs.git] / src / WINNT / afsclass / c_debug.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef DEBUG_H
11 #define DEBUG_H
12
13 #include <WINNT/afsclass.h>
14
15 #ifndef DEBUG // building retail?
16
17 #ifndef ASSERT
18 #define ASSERT(b)  ((b) ? TRUE : FALSE)  // take failure paths if retail asserts
19 #endif
20
21 #else // building debug?
22
23 #ifndef ASSERT
24 #define ASSERT(b)  AssertFn(b, #b, __LINE__, __FILE__)
25 #endif
26
27 #include <windows.h>
28
29
30          typedef unsigned char    uchar;
31          typedef unsigned short   ushort;
32
33 #define ANGLES_ON   "[AnglesOn]"
34 #define ANGLES_OFF  "[AnglesOff]"
35 #define LASTERROR   "[LastError]"
36
37
38 /*
39  * DEFINITIONS ________________________________________________________________
40  *
41  */
42
43 #define minX 2
44 #define minY 2
45
46 #define yMAX 60
47 #define xMAX 300
48
49
50 /*
51  * TYPEDEFS ___________________________________________________________________
52  *
53  */
54
55
56          class Debugstr
57             {
58             public:
59
60                Debugstr & operator<< (char   *psz);
61                Debugstr & operator<< (void   *psz);
62                Debugstr & operator<< (long    v);
63                Debugstr & operator<< (size_t  v);
64                Debugstr & operator<< (ushort  v);
65                Debugstr & operator<< (short   v);
66                Debugstr & operator<< (uchar   ch);
67                Debugstr & operator<< (char    ch);
68                Debugstr & operator<< (double  f);
69                Debugstr & operator<< (RECT    r);
70                Debugstr & operator<< (LPIDENT lpi);
71
72                Debugstr  (void);
73                ~Debugstr (void);
74
75                static LRESULT APIENTRY DebugWndProc (HWND, UINT, WPARAM, LPARAM);
76
77                void          OutString   (char *str, BOOL fRecord);
78
79             private:
80
81                HBRUSH        brBack;
82                HFONT         hfNew;
83                TEXTMETRIC    tm;
84
85                static void   Register    (void);
86                static void   Initialize  (void);
87                void          Output      (HDC hdc, char *str, BOOL fRecord);
88
89                static int    fRegistered;
90                static BOOL   fInit;
91                static HWND   hwnd;
92
93                static ushort gx, gcX;
94                static ushort gy, gcY;
95                static char gdata[ yMAX ][ xMAX ];
96
97                static BOOL   fAngles;
98             };
99
100
101 #define MAX_ARGS 10
102
103          class LogOut
104             {
105             public:
106
107                cdecl LogOut  (char *format, ...);
108                ~LogOut (void);
109
110             private:
111                char     pszFormat[ 256 ];
112
113                char    *aPtr[ MAX_ARGS ];
114                ushort   nArgs;
115             };
116
117
118
119 /*
120  * VARIABLES __________________________________________________________________
121  *
122  */
123
124          extern  Debugstr  debug;
125
126
127 /*
128  * PROTOTYPES _________________________________________________________________
129  *
130  */
131
132          extern  int   AssertFn   (int, char *, int, char *);
133
134
135 #endif // DEBUG
136
137 #endif // DEBUG_H
138