-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrintRoutine.h
383 lines (280 loc) · 11.5 KB
/
PrintRoutine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
/*
************************************************************************************
*
* File: PrintRoutine.h
* Class:
*
************************************************************************************
* Description:
*
************************************************************************************
* Notes:
*
************************************************************************************
*
* E/Mail: ian.macallan@gmail.com
* (c) 2003 - 2023 / Macallan
*
************************************************************************************
*
*/
#pragma once
#include <Windows.h>
#include <locale.h>
#include <stdarg.h>
//
//////////////////////////////////////////////////////////////////////////////
// Colors
//////////////////////////////////////////////////////////////////////////////
#ifndef FOREGROUND_YELLOW
#define FOREGROUND_YELLOW FOREGROUND_RED|FOREGROUND_GREEN
#endif // !FOREGROUND_YELLOW
#ifndef FOREGROUND_CYAN
#define FOREGROUND_CYAN FOREGROUND_GREEN|FOREGROUND_BLUE
#endif // !FOREGROUND_CYAN
#ifndef FOREGROUND_MAGENTA
#define FOREGROUND_MAGENTA FOREGROUND_RED|FOREGROUND_BLUE
#endif // !FOREGROUND_MAGENTA
#ifndef FOREGROUND_WHITE
#define FOREGROUND_WHITE FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE
#endif // !FOREGROUND_WHITE
//
#ifndef BACKGROUND_YELLOW
#define BACKGROUND_YELLOW BACKGROUND_RED|BACKGROUND_GREEN
#endif // !BACKGROUND_YELLOW
#ifndef BACKGROUND_CYAN
#define BACKGROUND_CYAN BACKGROUND_GREEN|BACKGROUND_BLUE
#endif // !BACKGROUND_CYAN
#ifndef BACKGROUND_MAGENTA
#define BACKGROUND_MAGENTA BACKGROUND_RED|BACKGROUND_BLUE
#endif // !BACKGROUND_MAGENTA
#ifndef BACKGROUND_WHITE
#define BACKGROUND_WHITE BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE
#endif // !BACKGROUND_WHITE
//
// Intensity
#ifndef FOREGROUND_HRED
#define FOREGROUND_HRED FOREGROUND_RED|FOREGROUND_INTENSITY
#endif // !FOREGROUND_HRED
//
#ifndef FOREGROUND_HGREEN
#define FOREGROUND_HGREEN FOREGROUND_GREEN|FOREGROUND_INTENSITY
#endif // !FOREGROUND_HGREEN
//
#ifndef FOREGROUND_HBLUE
#define FOREGROUND_HBLUE FOREGROUND_BLUE|FOREGROUND_INTENSITY
#endif // !FOREGROUND_HBLUE
//
#ifndef BACKGROUND_HRED
#define BACKGROUND_HRED BACKGROUND_RED|BACKGROUND_INTENSITY
#endif // !BACKGROUND_HRED
//
#ifndef BACKGROUND_HGREEN
#define BACKGROUND_HGREEN BACKGROUND_GREEN|BACKGROUND_INTENSITY
#endif // !BACKGROUND_HGREEN
//
#ifndef BACKGROUND_HBLUE
#define BACKGROUND_HBLUE BACKGROUND_BLUE|BACKGROUND_INTENSITY
#endif // !BACKGROUND_HBLUE
//
// Intensity C/M/Y
#ifndef FOREGROUND_HYELLOW
#define FOREGROUND_HYELLOW FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY
#endif // !FOREGROUND_HYELLOW
#ifndef FOREGROUND_HCYAN
#define FOREGROUND_HCYAN FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY
#endif // !FOREGROUND_HCYAN
#ifndef FOREGROUND_HMAGENTA
#define FOREGROUND_HMAGENTA FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY
#endif // !FOREGROUND_HMAGENTA
#ifndef FOREGROUND_HWHITE
#define FOREGROUND_HWHITE FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY
#endif // !FOREGROUND_HWHITE
// Background
#ifndef BACKGROUND_HYELLOW
#define BACKGROUND_HYELLOW BACKGROUND_RED|BACKGROUND_GREEN|FOREGROUND_INTENSITY
#endif // !BACKGROUND_HYELLOW
#ifndef BACKGROUND_HCYAN
#define BACKGROUND_HCYAN BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY
#endif // !BACKGROUND_CYAN
#ifndef BACKGROUND_HMAGENTA
#define BACKGROUND_HMAGENTA BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_INTENSITY
#endif // !BACKGROUND_MAGENTA
#ifndef BACKGROUND_HWHITE
#define BACKGROUND_HWHITE BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|FOREGROUND_INTENSITY
#endif // !BACKGROUND_WHITE
//
//====================================================================================
//
//====================================================================================
#ifdef UNICODE
// Print ... If Verbose or stderr
#define PrintStd PrintStdW
// Print ... If Verbose
#define PrintStdout PrintStdoutW
// Print ... anyway
#define PrintStderr PrintStderrW
// Print anyway to stdout
#define PrintDirect PrintDirectW
// Print ... If Not Quiet
#define PrintNormal PrintNormalW
// Print ... If Not Quiet
#define PrintStandard PrintStandardW
// Print ... If Verbose
#define PrintVerbose PrintVerboseW
// Print ... If Verbose
#define PrintStdoutLocale PrintStdoutLocaleW
// Print ... If Debug
#define PrintDebug PrintDebugW
// Print ... If Debug
#define PrintDebugFL PrintDebugFLW
// Print ... If Performance
#define PrintPerformance PrintPerformanceW
// Print ... If Trace
#define PrintTrace PrintTraceW
// Print Help Line width, option, text
#define PrintHelpLine PrintHelpLineW
#define CreateLocalePointer CreateLocalePointerW
// MBCS
#else
// Print ... If Verbose or stderr
#define PrintStd PrintStdA
// Print ... If Verbose
#define PrintStdout PrintStdoutA
// Print anyway
#define PrintStderr PrintStderrA
// Print anyway to stdout
#define PrintDirect PrintDirectA
// Print ... If Not Quiet
#define PrintNormal PrintNormalA
// Print ... If Not Quiet
#define PrintStandard PrintStandardA
// Print ... If Verbose
#define PrintVerbose PrintVerboseA
// Print ... If Verbose
#define PrintStdoutLocale PrintStdoutLocaleA
// Print ... If Performance
#define PrintPerformance PrintPerformanceA
// Print ... If Debug
#define PrintDebug PrintDebugA
// Print ... If Debug
#define PrintDebugFL PrintDebugFLA
// Print ... If Trace
#define PrintTrace PrintTraceA
// Print Help Line width, option, text
#define PrintHelpLine PrintHelpLineA
#define CreateLocalePointer CreateLocalePointerA
#endif
extern void InitStdHandlers ();
extern void SetStdoutIntensity ();
//
extern BOOL SetForeGroundZero ( bool bStdout = true );
extern BOOL SetForeGroundColor ( bool bStdout = true, WORD attribute = 0, bool bErase = false );
extern BOOL SetForeGroundIntensity ( bool bStdout = true, bool bErase = false );
#define SetForeGroundRed(x,y) SetForeGroundColor(x,FOREGROUND_RED,y);
#define SetForeGroundGreen(x,y) SetForeGroundColor(x,FOREGROUND_GREEN,y);
#define SetForeGroundBlue(x,y) SetForeGroundColor(x,FOREGROUND_BLUE,y);
extern BOOL SetBackGroundZero ( bool bStdout = true );
extern BOOL SetBackGroundColor ( bool bStdout = true, WORD attribute = 0, bool bErase = false );
extern BOOL SetBackGroundIntensity ( bool bStdout = true, bool bErase = false );
#define SetBackGroundRed(x,y) SetBackGroundColor(x,FOREGROUND_RED,y);
#define SetBackGroundGreen(x,y) SetBackGroundColor(x,FOREGROUND_GREEN,y);
#define SetBackGroundBlue(x,y) SetBackGroundColor(x,FOREGROUND_BLUE,y);
extern BOOL SetAllGroundRestore ( bool bStdout = true );
//
extern void SetStdoutRestore ();
extern BOOL SetStdoutTextAttribute ( WORD wCurrentAttribute );
extern CONSOLE_SCREEN_BUFFER_INFO *GetStdoutScreenInfo();
// Print va_list If Do Print or stderr
// Base Routine
extern int PrintVW ( bool localize, bool verbose, FILE *file, const WCHAR *format, va_list argptr );
// Print va_list If Do Print or stderr
// Base Routine
extern int PrintVA ( bool localize, bool verbose, FILE *file, const char *format, va_list argptr );
// Print va_list
// Base Routine
extern int PrintVW ( FILE *file, const WCHAR *format, va_list argptr );
// Print va_list
// Base Routine
extern int PrintVA ( FILE *file, const char *format, va_list argptr );
// Print va_list to stdout
extern int PrintVW ( const WCHAR *format, va_list argptr );
// Print va_list to stdout
extern int PrintVA ( const char *format, va_list argptr );
// Print ... If Do Print or stderr
extern int PrintW ( bool localize, bool verbose, FILE *file, const WCHAR *format, ... );
// Print ... If Do Print or stderr
extern int PrintA ( bool localize, bool verbose, FILE *file, const char *format, ... );
// Print ... If Verbose or stderr
extern int PrintStdW ( FILE *file, const WCHAR *format, ... );
// Print ... If Verbose or stderr
extern int PrintStdA ( FILE *file, const char *format, ... );
// Print ... If Verbose
extern int PrintStdoutW ( const WCHAR *format, ... );
// Print ... If Verbose
extern int PrintStdoutA ( const char *format, ... );
// Print ... If Verbose
extern int PrintVerboseW ( const WCHAR *format, ... );
// Print ... If Verbose
extern int PrintVerboseA ( const char *format, ... );
// Print To Stdout
extern int PrintDirectW ( const WCHAR *format, ... );
// Print To Stdout
extern int PrintDirectA ( const char *format, ... );
// Print ... If Not Quiet
extern int PrintNormalW ( const WCHAR *format, ... );
// Print ... If Not Quiet
extern int PrintNormalA ( const char *format, ... );
// Print ... If Not Quiet
extern int PrintStandardW ( const WCHAR *format, ... );
// Print ... If Not Quiet
extern int PrintStandardA ( const char *format, ... );
// Print ... If Verbose
extern int PrintStdoutLocaleW ( const WCHAR *format, ... );
// Print ... If Verbose
extern int PrintStdoutLocaleA ( const char *format, ... );
// Print ... anyway
extern int PrintStderrW ( const WCHAR *format, ... );
// Print ... anyway
extern int PrintStderrA ( const char *format, ... );
// Print ... Only If Debug
extern int PrintDebugW ( const WCHAR *format, ... );
// Print ... Only If Debug
extern int PrintDebugA ( const char *format, ... );
// Print ... Only If Performance
extern int PrintPerformanceW ( const WCHAR *format, ... );
// Print ... Only If Performance
extern int PrintPerformanceA ( const char *format, ... );
// Print ... Only If Debug
extern int PrintDebugFLW ( const char *filename, int linenumber, const WCHAR *format, ... );
// Print ... Only If Debug
extern int PrintDebugFLA ( const char *filename, int linenumber, const char *format, ... );
// Print ... Only If Trace
extern int PrintTraceW ( const WCHAR *format, ... );
// Print ... Only If Trace
extern int PrintTraceA ( const char *format, ... );
// Print Help Line
extern int PrintHelpLineW ( const WCHAR *format, ... );
extern int PrintHelpLineW ( int iWidth, const WCHAR *pOption, const WCHAR *pText );
extern int PrintHelpLineW ( int iWidth, const WCHAR *pOption, const WCHAR *pText1, const WCHAR *pText2 );
extern int PrintHelpLineW ( );
// Print Help Line
extern int PrintHelpLineA ( const char *format, ... );
extern int PrintHelpLineA ( int iWidth, const char *pOption, const char *pText );
extern int PrintHelpLineA ( int iWidth, const char *pOption, const char *pText1, const char *pText2 );
extern int PrintHelpLineA ( );
// Create Locale Pointer and set it as LC_ALL
extern BOOL CreateLocalePointerW ( const WCHAR *pLocaleString, int lcValue = LC_ALL );
// Create Locale Pointer and set it as LC_ALL
extern BOOL CreateLocalePointerA ( const char *pLocaleString, int lcValue = LC_ALL );
//
//////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////
extern _locale_t LocalePointer;
extern bool LocaleMode;
extern bool VerboseMode;
extern bool QuietMode;
extern bool DebugMode;
extern bool TraceMode;
extern bool PerformanceMode;