~jterrell/nunitv2/nunitv2

« back to all changes in this revision

Viewing changes to tools/WiX/sdk/inc/conutil.h

  • Committer: Charlie Poole
  • Date: 2012-02-02 01:55:11 UTC
  • mfrom: (3368.1.11 work)
  • Revision ID: charlie@nunit.org-20120202015511-0sspxs5miu16uzse
Merge changes from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#pragma once
 
2
//-------------------------------------------------------------------------------------------------
 
3
// <copyright file="conutil.h" company="Microsoft">
 
4
//    Copyright (c) Microsoft Corporation.  All rights reserved.
 
5
//    
 
6
//    The use and distribution terms for this software are covered by the
 
7
//    Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php)
 
8
//    which can be found in the file CPL.TXT at the root of this distribution.
 
9
//    By using this software in any fashion, you are agreeing to be bound by
 
10
//    the terms of this license.
 
11
//    
 
12
//    You must not remove this notice, or any other, from this software.
 
13
// </copyright>
 
14
// 
 
15
// <summary>
 
16
//    Console helper functions.
 
17
// </summary>
 
18
//-------------------------------------------------------------------------------------------------
 
19
 
 
20
#ifdef __cplusplus
 
21
extern "C" {
 
22
#endif
 
23
 
 
24
#define ConsoleExitOnFailure(x, c, f) if (FAILED(x)) { ConsoleWriteError(x, c, f); ExitTrace(x, f); goto LExit; }
 
25
#define ConsoleExitOnFailure1(x, c, f, s) if (FAILED(x)) { ConsoleWriteError(x, c, f, s, NULL); ExitTrace1(x, f, s); goto LExit; }
 
26
#define ConsoleExitOnFailure2(x, c, f, s, t) if (FAILED(x)) { ConsoleWriteError(x, c, f, s, t); ExitTrace2(x, f, s, t); goto LExit; }
 
27
#define ConsoleExitOnFailure3(x, c, f, s, t, u) if (FAILED(x)) { ConsoleWriteError(x, c, f, s, t, u); ExitTrace3(x, f, s, t, u); goto LExit; }
 
28
 
 
29
#define ConsoleExitOnLastError(x, c, f) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f); ExitTrace(x, f); goto LExit; } }
 
30
#define ConsoleExitOnLastError1(x, c, f, s) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f, s, NULL); ExitTrace1(x, f, s); goto LExit; } }
 
31
#define ConsoleExitOnLastError2(x, c, f, s, t) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f, s, t); ExitTrace2(x, f, s, t); goto LExit; } }
 
32
#define ConsoleExitOnLastError3(x, c, f, s, t, u) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { ConsoleWriteError(x, c, f, s, t, u); ExitTrace3(x, f, s, t, u); goto LExit; } }
 
33
 
 
34
#define ConsoleExitOnNull(p, x, e, c, f) if (NULL == p) { x = e; ConsoleWriteError(x, c, f); ExitTrace(x, f); goto LExit; }
 
35
#define ConsoleExitOnNull1(p, x, e, c, f, s) if (NULL == p) { x = e; ConsoleWriteError(x, c, f, s, NULL); ExitTrace1(x, f, s); goto LExit; }
 
36
#define ConsoleExitOnNull2(p, x, e, c, f, s, t) if (NULL == p) { x = e; ConsoleWriteError(x, c, f, s, t); ExitTrace2(x, f, s, t); goto LExit; }
 
37
#define ConsoleExitOnNull3(p, x, e, c, f, s, t, u) if (NULL == p) { x = e; ConsoleWriteError(x, c, f, s, t, u); ExitTrace2(x, f, s, t, u); goto LExit; }
 
38
 
 
39
 
 
40
// the following macros need to go away
 
41
#define ConsoleTrace(l, f) { ConsoleWriteLine(CONSOLE_COLOR_NORMAL, f); Trace(l, f); }
 
42
#define ConsoleTrace1(l, f, s) { ConsoleWriteLine(CONSOLE_COLOR_NORMAL, f, s); Trace1(l, f, s); }
 
43
#define ConsoleTrace2(l, f, s, t) { ConsoleWriteLine(CONSOLE_COLOR_NORMAL, f, s, t); Trace2(l, f, s, t); }
 
44
#define ConsoleTrace3(l, f, s, t, u) { ConsoleWriteLine(CONSOLE_COLOR_NORMAL, f, s, t, u); Trace3(l, f, s, t, u); }
 
45
 
 
46
#define ConsoleWarning(f) { ConsoleWriteLine(CONSOLE_COLOR_YELLOW, f); Trace(REPORT_STANDARD, f); }
 
47
#define ConsoleWarning1(f, s) { ConsoleWriteLine(CONSOLE_COLOR_YELLOW, f, s); Trace1(REPORT_STANDARD, f, s); }
 
48
#define ConsoleWarning2(f, s, t) { ConsoleWriteLine(CONSOLE_COLOR_YELLOW, f, s, t); Trace2(REPORT_STANDARD, f, s, t); }
 
49
#define ConsoleWarning3(f, s, t, u) { ConsoleWriteLine(CONSOLE_COLOR_YELLOW, f, s, t, u); Trace3(REPORT_STANDARD, f, s, t, u); }
 
50
 
 
51
#define ConsoleError(x, f) { ConsoleWriteError(x, CONSOLE_COLOR_RED, f); TraceError(x, f); }
 
52
#define ConsoleError1(x, f, s) { ConsoleWriteError(x, CONSOLE_COLOR_RED, f, s); TraceError1(x, f, s); }
 
53
#define ConsoleError2(x, f, s, t) { ConsoleWriteError(x, CONSOLE_COLOR_RED, f, s, t); TraceError2(x, f, s, t); }
 
54
#define ConsoleError3(x, f, s, t, u) { ConsoleWriteError(x, CONSOLE_COLOR_RED, f, s, t, u); TraceError3(x, f, s, t, u); }
 
55
 
 
56
 
 
57
// enums
 
58
enum CONSOLE_COLOR { CONSOLE_COLOR_NORMAL, CONSOLE_COLOR_RED, CONSOLE_COLOR_YELLOW, CONSOLE_COLOR_GREEN };
 
59
 
 
60
// structs
 
61
 
 
62
// functions
 
63
HRESULT DAPI ConsoleInitialize();
 
64
void DAPI ConsoleUninitialize();
 
65
 
 
66
void DAPI ConsoleGreen();
 
67
void DAPI ConsoleRed();
 
68
void DAPI ConsoleYellow();
 
69
void DAPI ConsoleNormal();
 
70
 
 
71
HRESULT DAPI ConsoleWrite(
 
72
    CONSOLE_COLOR cc,
 
73
    __in_z __format_string LPCSTR szFormat,
 
74
    ...
 
75
    );
 
76
HRESULT DAPI ConsoleWriteLine(
 
77
    CONSOLE_COLOR cc,
 
78
    __in_z __format_string LPCSTR szFormat,
 
79
    ...
 
80
    );
 
81
HRESULT DAPI ConsoleWriteError(
 
82
    HRESULT hrError,
 
83
    CONSOLE_COLOR cc,
 
84
    __in_z __format_string LPCSTR szFormat,
 
85
    ...
 
86
    );
 
87
 
 
88
HRESULT DAPI ConsoleReadW(
 
89
    __deref_out_z LPWSTR* ppwzBuffer
 
90
    );
 
91
 
 
92
HRESULT DAPI ConsoleReadStringA(
 
93
    __deref_out_ecount_part(cchCharBuffer,*pcchNumCharReturn) LPSTR* szCharBuffer,
 
94
    CONST DWORD cchCharBuffer,
 
95
    __out DWORD* pcchNumCharReturn
 
96
    );
 
97
HRESULT DAPI ConsoleReadStringW(
 
98
    __deref_out_ecount_part(cchCharBuffer,*pcchNumCharReturn) LPWSTR* szCharBuffer,
 
99
    CONST DWORD cchCharBuffer,
 
100
    __out DWORD* pcchNumCharReturn
 
101
    );
 
102
 
 
103
HRESULT DAPI ConsoleReadNonBlockingW(
 
104
    __deref_out_ecount_opt(*pcchSize) LPWSTR* ppwzBuffer,
 
105
    __out DWORD* pcchSize,
 
106
    BOOL fReadLine
 
107
    );
 
108
 
 
109
HRESULT ConsoleSetReadHidden(void);
 
110
HRESULT ConsoleSetReadNormal(void);
 
111
 
 
112
#ifdef __cplusplus
 
113
}
 
114
#endif
 
115