diff options
Diffstat (limited to 'src/dutil/inc/conutil.h')
-rw-r--r-- | src/dutil/inc/conutil.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/dutil/inc/conutil.h b/src/dutil/inc/conutil.h new file mode 100644 index 00000000..cfb65332 --- /dev/null +++ b/src/dutil/inc/conutil.h | |||
@@ -0,0 +1,78 @@ | |||
1 | #pragma once | ||
2 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
3 | |||
4 | |||
5 | #ifdef __cplusplus | ||
6 | extern "C" { | ||
7 | #endif | ||
8 | |||
9 | #define ConsoleExitOnFailure(x, c, f, ...) if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | ||
10 | #define ConsoleExitOnLastError(x, c, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } } | ||
11 | #define ConsoleExitOnNull(p, x, e, c, f, ...) if (NULL == p) { x = e; ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; } | ||
12 | |||
13 | |||
14 | // the following macros need to go away | ||
15 | #define ConsoleTrace(l, f, ...) { ConsoleWriteLine(CONSOLE_COLOR_NORMAL, f, __VA_ARGS__); Trace(l, f, __VA_ARGS__); } | ||
16 | #define ConsoleWarning(f, ...) { ConsoleWriteLine(CONSOLE_COLOR_YELLOW, f, __VA_ARGS__); Trace(REPORT_STANDARD, f, __VA_ARGS__); } | ||
17 | #define ConsoleError(x, f, ...) { ConsoleWriteError(x, CONSOLE_COLOR_RED, f, __VA_ARGS__); TraceError(x, f, __VA_ARGS__); } | ||
18 | |||
19 | |||
20 | // enums | ||
21 | typedef enum CONSOLE_COLOR { CONSOLE_COLOR_NORMAL, CONSOLE_COLOR_RED, CONSOLE_COLOR_YELLOW, CONSOLE_COLOR_GREEN } CONSOLE_COLOR; | ||
22 | |||
23 | // structs | ||
24 | |||
25 | // functions | ||
26 | HRESULT DAPI ConsoleInitialize(); | ||
27 | void DAPI ConsoleUninitialize(); | ||
28 | |||
29 | void DAPI ConsoleGreen(); | ||
30 | void DAPI ConsoleRed(); | ||
31 | void DAPI ConsoleYellow(); | ||
32 | void DAPI ConsoleNormal(); | ||
33 | |||
34 | HRESULT DAPI ConsoleWrite( | ||
35 | CONSOLE_COLOR cc, | ||
36 | __in_z __format_string LPCSTR szFormat, | ||
37 | ... | ||
38 | ); | ||
39 | HRESULT DAPI ConsoleWriteLine( | ||
40 | CONSOLE_COLOR cc, | ||
41 | __in_z __format_string LPCSTR szFormat, | ||
42 | ... | ||
43 | ); | ||
44 | HRESULT DAPI ConsoleWriteError( | ||
45 | HRESULT hrError, | ||
46 | CONSOLE_COLOR cc, | ||
47 | __in_z __format_string LPCSTR szFormat, | ||
48 | ... | ||
49 | ); | ||
50 | |||
51 | HRESULT DAPI ConsoleReadW( | ||
52 | __deref_out_z LPWSTR* ppwzBuffer | ||
53 | ); | ||
54 | |||
55 | HRESULT DAPI ConsoleReadStringA( | ||
56 | __deref_out_ecount_part(cchCharBuffer,*pcchNumCharReturn) LPSTR* szCharBuffer, | ||
57 | CONST DWORD cchCharBuffer, | ||
58 | __out DWORD* pcchNumCharReturn | ||
59 | ); | ||
60 | HRESULT DAPI ConsoleReadStringW( | ||
61 | __deref_out_ecount_part(cchCharBuffer,*pcchNumCharReturn) LPWSTR* szCharBuffer, | ||
62 | CONST DWORD cchCharBuffer, | ||
63 | __out DWORD* pcchNumCharReturn | ||
64 | ); | ||
65 | |||
66 | HRESULT DAPI ConsoleReadNonBlockingW( | ||
67 | __deref_out_ecount_opt(*pcchSize) LPWSTR* ppwzBuffer, | ||
68 | __out DWORD* pcchSize, | ||
69 | BOOL fReadLine | ||
70 | ); | ||
71 | |||
72 | HRESULT DAPI ConsoleSetReadHidden(void); | ||
73 | HRESULT DAPI ConsoleSetReadNormal(void); | ||
74 | |||
75 | #ifdef __cplusplus | ||
76 | } | ||
77 | #endif | ||
78 | |||