diff options
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/inc/conutil.h')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/inc/conutil.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/conutil.h b/src/libs/dutil/WixToolset.DUtil/inc/conutil.h new file mode 100644 index 00000000..38aaea84 --- /dev/null +++ b/src/libs/dutil/WixToolset.DUtil/inc/conutil.h | |||
@@ -0,0 +1,80 @@ | |||
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 ConsoleExitOnFailureSource(d, x, c, f, ...) if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
10 | #define ConsoleExitOnLastErrorSource(d, x, c, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } } | ||
11 | #define ConsoleExitOnNullSource(d, p, x, e, c, f, ...) if (NULL == p) { x = e; ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
12 | #define ConsoleExitOnNullWithLastErrorSource(d, p, x, c, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
13 | #define ConsoleExitWithLastErrorSource(d, x, c, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } ConsoleWriteError(x, c, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } | ||
14 | |||
15 | |||
16 | #define ConsoleExitOnFailure(x, c, f, ...) ConsoleExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, c, f, __VA_ARGS__) | ||
17 | #define ConsoleExitOnLastError(x, c, f, ...) ConsoleExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, c, f, __VA_ARGS__) | ||
18 | #define ConsoleExitOnNull(p, x, e, c, f, ...) ConsoleExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, c, f, __VA_ARGS__) | ||
19 | #define ConsoleExitOnNullWithLastError(p, x, c, f, ...) ConsoleExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, c, f, __VA_ARGS__) | ||
20 | #define ConsoleExitWithLastError(x, c, f, ...) ConsoleExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, c, f, __VA_ARGS__) | ||
21 | |||
22 | // enums | ||
23 | typedef enum CONSOLE_COLOR { CONSOLE_COLOR_NORMAL, CONSOLE_COLOR_RED, CONSOLE_COLOR_YELLOW, CONSOLE_COLOR_GREEN } CONSOLE_COLOR; | ||
24 | |||
25 | // structs | ||
26 | |||
27 | // functions | ||
28 | HRESULT DAPI ConsoleInitialize(); | ||
29 | void DAPI ConsoleUninitialize(); | ||
30 | |||
31 | void DAPI ConsoleGreen(); | ||
32 | void DAPI ConsoleRed(); | ||
33 | void DAPI ConsoleYellow(); | ||
34 | void DAPI ConsoleNormal(); | ||
35 | |||
36 | HRESULT DAPI ConsoleWrite( | ||
37 | CONSOLE_COLOR cc, | ||
38 | __in_z __format_string LPCSTR szFormat, | ||
39 | ... | ||
40 | ); | ||
41 | HRESULT DAPI ConsoleWriteLine( | ||
42 | CONSOLE_COLOR cc, | ||
43 | __in_z __format_string LPCSTR szFormat, | ||
44 | ... | ||
45 | ); | ||
46 | HRESULT DAPI ConsoleWriteError( | ||
47 | HRESULT hrError, | ||
48 | CONSOLE_COLOR cc, | ||
49 | __in_z __format_string LPCSTR szFormat, | ||
50 | ... | ||
51 | ); | ||
52 | |||
53 | HRESULT DAPI ConsoleReadW( | ||
54 | __deref_out_z LPWSTR* ppwzBuffer | ||
55 | ); | ||
56 | |||
57 | HRESULT DAPI ConsoleReadStringA( | ||
58 | __deref_inout_ecount_part(cchCharBuffer,*pcchNumCharReturn) LPSTR* szCharBuffer, | ||
59 | CONST DWORD cchCharBuffer, | ||
60 | __out DWORD* pcchNumCharReturn | ||
61 | ); | ||
62 | HRESULT DAPI ConsoleReadStringW( | ||
63 | __deref_inout_ecount_part(cchCharBuffer,*pcchNumCharReturn) LPWSTR* szCharBuffer, | ||
64 | CONST DWORD cchCharBuffer, | ||
65 | __out DWORD* pcchNumCharReturn | ||
66 | ); | ||
67 | |||
68 | HRESULT DAPI ConsoleReadNonBlockingW( | ||
69 | __deref_out_ecount_opt(*pcchSize) LPWSTR* ppwzBuffer, | ||
70 | __out DWORD* pcchSize, | ||
71 | BOOL fReadLine | ||
72 | ); | ||
73 | |||
74 | HRESULT DAPI ConsoleSetReadHidden(void); | ||
75 | HRESULT DAPI ConsoleSetReadNormal(void); | ||
76 | |||
77 | #ifdef __cplusplus | ||
78 | } | ||
79 | #endif | ||
80 | |||