main
h 116 lines 6.27 KB
Raw
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 #include "dutil.h"
6
7 #include "IBootstrapperExtensionEngine.h"
8 #include "IBootstrapperExtension.h"
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 #define BextExitOnFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
15 #define BextExitOnRootFailureSource(d, x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
16 #define BextExitWithRootFailureSource(d, x, e, f, ...) { x = FAILED(e) ? e : E_FAIL; BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
17 #define BextExitOnLastErrorSource(d, x, f, ...) { x = ::GetLastError(); x = HRESULT_FROM_WIN32(x); if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; } }
18 #define BextExitOnNullSource(d, p, x, e, f, ...) if (NULL == p) { x = e; BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
19 #define BextExitOnNullWithLastErrorSource(d, p, x, f, ...) if (NULL == p) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
20 #define BextExitWithLastErrorSource(d, x, f, ...) { DWORD Dutil_er = ::GetLastError(); x = HRESULT_FROM_WIN32(Dutil_er); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
21 #define BextExitOnWin32ErrorSource(d, e, x, f, ...) if (ERROR_SUCCESS != e) { x = HRESULT_FROM_WIN32(e); if (!FAILED(x)) { x = E_FAIL; } BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTraceSource(d, x, f, __VA_ARGS__); goto LExit; }
22 #define BextExitOnOptionalXmlQueryFailureSource(d, x, b, f, ...) { { if (S_FALSE == x || E_NOTFOUND == x) { b = FALSE; x = S_OK; } else { b = SUCCEEDED(x); } }; BextExitOnRootFailureSource(d, x, f, __VA_ARGS__); }
23 #define BextExitOnRequiredXmlQueryFailureSource(d, x, f, ...) { if (S_FALSE == x) { x = E_NOTFOUND; } BextExitOnRootFailureSource(d, x, f, __VA_ARGS__); }
24
25 #define BextExitOnFailure(x, f, ...) BextExitOnFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
26 #define BextExitOnRootFailure(x, f, ...) BextExitOnRootFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
27 #define BextExitWithRootFailure(x, e, f, ...) BextExitWithRootFailureSource(DUTIL_SOURCE_DEFAULT, x, e, f, __VA_ARGS__)
28 #define BextExitOnLastError(x, f, ...) BextExitOnLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
29 #define BextExitOnNull(p, x, e, f, ...) BextExitOnNullSource(DUTIL_SOURCE_DEFAULT, p, x, e, f, __VA_ARGS__)
30 #define BextExitOnNullWithLastError(p, x, f, ...) BextExitOnNullWithLastErrorSource(DUTIL_SOURCE_DEFAULT, p, x, f, __VA_ARGS__)
31 #define BextExitWithLastError(x, f, ...) BextExitWithLastErrorSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
32 #define BextExitOnWin32Error(e, x, f, ...) BextExitOnWin32ErrorSource(DUTIL_SOURCE_DEFAULT, e, x, f, __VA_ARGS__)
33 #define BextExitOnOptionalXmlQueryFailure(x, b, f, ...) BextExitOnOptionalXmlQueryFailureSource(DUTIL_SOURCE_DEFAULT, x, b, f, __VA_ARGS__)
34 #define BextExitOnRequiredXmlQueryFailure(x, f, ...) BextExitOnRequiredXmlQueryFailureSource(DUTIL_SOURCE_DEFAULT, x, f, __VA_ARGS__)
35
36 const LPCWSTR BOOTSTRAPPER_EXTENSION_MANIFEST_FILENAME = L"BootstrapperExtensionData.xml";
37
38
39 /*******************************************************************
40 BextInitialize - remembers the engine interface to enable logging and
41 other functions.
42
43 ********************************************************************/
44 DAPI_(void) BextInitialize(
45 __in IBootstrapperExtensionEngine* pEngine
46 );
47
48 /*******************************************************************
49 BextInitializeFromCreateArgs - convenience function to call BextBootstrapperExtensionEngineCreate
50 then pass it along to BextInitialize.
51
52 ********************************************************************/
53 DAPI_(HRESULT) BextInitializeFromCreateArgs(
54 __in const BOOTSTRAPPER_EXTENSION_CREATE_ARGS* pArgs,
55 __out IBootstrapperExtensionEngine** ppEngine
56 );
57
58 /*******************************************************************
59 BextUninitialize - cleans up utility layer internals.
60
61 ********************************************************************/
62 DAPI_(void) BextUninitialize();
63
64 /*******************************************************************
65 BextGetBootstrapperExtensionDataNode - gets the requested BootstrapperExtension node.
66
67 ********************************************************************/
68 DAPI_(HRESULT) BextGetBootstrapperExtensionDataNode(
69 __in IXMLDOMDocument* pixdManifest,
70 __in LPCWSTR wzExtensionId,
71 __out IXMLDOMNode** ppixnBootstrapperExtension
72 );
73
74 /*******************************************************************
75 BextLog - logs a message with the engine.
76
77 ********************************************************************/
78 DAPIV_(HRESULT) BextLog(
79 __in BOOTSTRAPPER_EXTENSION_LOG_LEVEL level,
80 __in_z __format_string LPCSTR szFormat,
81 ...
82 );
83
84 /*******************************************************************
85 BextLogArgs - logs a message with the engine.
86
87 ********************************************************************/
88 DAPI_(HRESULT) BextLogArgs(
89 __in BOOTSTRAPPER_EXTENSION_LOG_LEVEL level,
90 __in_z __format_string LPCSTR szFormat,
91 __in va_list args
92 );
93
94 /*******************************************************************
95 BextLogError - logs an error message with the engine.
96
97 ********************************************************************/
98 DAPIV_(HRESULT) BextLogError(
99 __in HRESULT hr,
100 __in_z __format_string LPCSTR szFormat,
101 ...
102 );
103
104 /*******************************************************************
105 BextLogErrorArgs - logs an error message with the engine.
106
107 ********************************************************************/
108 DAPI_(HRESULT) BextLogErrorArgs(
109 __in HRESULT hr,
110 __in_z __format_string LPCSTR szFormat,
111 __in va_list args
112 );
113
114 #ifdef __cplusplus
115 }
116 #endif