aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/inc/conutil.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/dutil/inc/conutil.h')
-rw-r--r--src/dutil/inc/conutil.h78
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
6extern "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
21typedef enum CONSOLE_COLOR { CONSOLE_COLOR_NORMAL, CONSOLE_COLOR_RED, CONSOLE_COLOR_YELLOW, CONSOLE_COLOR_GREEN } CONSOLE_COLOR;
22
23// structs
24
25// functions
26HRESULT DAPI ConsoleInitialize();
27void DAPI ConsoleUninitialize();
28
29void DAPI ConsoleGreen();
30void DAPI ConsoleRed();
31void DAPI ConsoleYellow();
32void DAPI ConsoleNormal();
33
34HRESULT DAPI ConsoleWrite(
35 CONSOLE_COLOR cc,
36 __in_z __format_string LPCSTR szFormat,
37 ...
38 );
39HRESULT DAPI ConsoleWriteLine(
40 CONSOLE_COLOR cc,
41 __in_z __format_string LPCSTR szFormat,
42 ...
43 );
44HRESULT DAPI ConsoleWriteError(
45 HRESULT hrError,
46 CONSOLE_COLOR cc,
47 __in_z __format_string LPCSTR szFormat,
48 ...
49 );
50
51HRESULT DAPI ConsoleReadW(
52 __deref_out_z LPWSTR* ppwzBuffer
53 );
54
55HRESULT DAPI ConsoleReadStringA(
56 __deref_out_ecount_part(cchCharBuffer,*pcchNumCharReturn) LPSTR* szCharBuffer,
57 CONST DWORD cchCharBuffer,
58 __out DWORD* pcchNumCharReturn
59 );
60HRESULT DAPI ConsoleReadStringW(
61 __deref_out_ecount_part(cchCharBuffer,*pcchNumCharReturn) LPWSTR* szCharBuffer,
62 CONST DWORD cchCharBuffer,
63 __out DWORD* pcchNumCharReturn
64 );
65
66HRESULT DAPI ConsoleReadNonBlockingW(
67 __deref_out_ecount_opt(*pcchSize) LPWSTR* ppwzBuffer,
68 __out DWORD* pcchSize,
69 BOOL fReadLine
70 );
71
72HRESULT DAPI ConsoleSetReadHidden(void);
73HRESULT DAPI ConsoleSetReadNormal(void);
74
75#ifdef __cplusplus
76}
77#endif
78