aboutsummaryrefslogtreecommitdiff
path: root/src/bextutil/inc
diff options
context:
space:
mode:
Diffstat (limited to 'src/bextutil/inc')
-rw-r--r--src/bextutil/inc/BextBaseBundleExtension.h120
-rw-r--r--src/bextutil/inc/BextBaseBundleExtensionProc.h48
-rw-r--r--src/bextutil/inc/BextBundleExtensionEngine.h17
-rw-r--r--src/bextutil/inc/IBundleExtension.h20
-rw-r--r--src/bextutil/inc/IBundleExtensionEngine.h64
-rw-r--r--src/bextutil/inc/bextutil.h76
6 files changed, 345 insertions, 0 deletions
diff --git a/src/bextutil/inc/BextBaseBundleExtension.h b/src/bextutil/inc/BextBaseBundleExtension.h
new file mode 100644
index 00000000..69c338e4
--- /dev/null
+++ b/src/bextutil/inc/BextBaseBundleExtension.h
@@ -0,0 +1,120 @@
1// 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.
2
3#include <windows.h>
4
5#include "BundleExtensionEngine.h"
6#include "BundleExtension.h"
7#include "IBundleExtensionEngine.h"
8#include "IBundleExtension.h"
9
10#include "bextutil.h"
11
12class CBextBaseBundleExtension : public IBundleExtension
13{
14public: // IUnknown
15 virtual STDMETHODIMP QueryInterface(
16 __in REFIID riid,
17 __out LPVOID *ppvObject
18 )
19 {
20 if (!ppvObject)
21 {
22 return E_INVALIDARG;
23 }
24
25 *ppvObject = NULL;
26
27 if (::IsEqualIID(__uuidof(IBundleExtension), riid))
28 {
29 *ppvObject = static_cast<IBundleExtension*>(this);
30 }
31 else if (::IsEqualIID(IID_IUnknown, riid))
32 {
33 *ppvObject = static_cast<IUnknown*>(this);
34 }
35 else // no interface for requested iid
36 {
37 return E_NOINTERFACE;
38 }
39
40 AddRef();
41 return S_OK;
42 }
43
44 virtual STDMETHODIMP_(ULONG) AddRef()
45 {
46 return ::InterlockedIncrement(&this->m_cReferences);
47 }
48
49 virtual STDMETHODIMP_(ULONG) Release()
50 {
51 long l = ::InterlockedDecrement(&this->m_cReferences);
52 if (0 < l)
53 {
54 return l;
55 }
56
57 delete this;
58 return 0;
59 }
60
61public: // IBundleExtension
62 virtual STDMETHODIMP Search(
63 __in LPCWSTR /*wzId*/,
64 __in LPCWSTR /*wzVariable*/
65 )
66 {
67 return E_NOTIMPL;
68 }
69
70 virtual STDMETHODIMP BundleExtensionProc(
71 __in BUNDLE_EXTENSION_MESSAGE /*message*/,
72 __in const LPVOID /*pvArgs*/,
73 __inout LPVOID /*pvResults*/,
74 __in_opt LPVOID /*pvContext*/
75 )
76 {
77 return E_NOTIMPL;
78 }
79
80public: //CBextBaseBundleExtension
81 virtual STDMETHODIMP Initialize(
82 __in const BUNDLE_EXTENSION_CREATE_ARGS* pCreateArgs
83 )
84 {
85 HRESULT hr = S_OK;
86
87 hr = StrAllocString(&m_sczBundleExtensionDataPath, pCreateArgs->wzBundleExtensionDataPath, 0);
88 ExitOnFailure(hr, "Failed to copy BundleExtensionDataPath.");
89
90 LExit:
91 return hr;
92 }
93
94protected:
95
96 CBextBaseBundleExtension(
97 __in IBundleExtensionEngine* pEngine
98 )
99 {
100 m_cReferences = 1;
101
102 pEngine->AddRef();
103 m_pEngine = pEngine;
104
105 m_sczBundleExtensionDataPath = NULL;
106 }
107
108 virtual ~CBextBaseBundleExtension()
109 {
110 ReleaseNullObject(m_pEngine);
111 ReleaseStr(m_sczBundleExtensionDataPath);
112 }
113
114protected:
115 IBundleExtensionEngine* m_pEngine;
116 LPWSTR m_sczBundleExtensionDataPath;
117
118private:
119 long m_cReferences;
120};
diff --git a/src/bextutil/inc/BextBaseBundleExtensionProc.h b/src/bextutil/inc/BextBaseBundleExtensionProc.h
new file mode 100644
index 00000000..f71e3b92
--- /dev/null
+++ b/src/bextutil/inc/BextBaseBundleExtensionProc.h
@@ -0,0 +1,48 @@
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 <windows.h>
6
7#include "BundleExtensionEngine.h"
8#include "BundleExtension.h"
9#include "IBundleExtensionEngine.h"
10#include "IBundleExtension.h"
11
12static HRESULT BextBaseBEProcSearch(
13 __in IBundleExtension* pBE,
14 __in BUNDLE_EXTENSION_SEARCH_ARGS* pArgs,
15 __inout BUNDLE_EXTENSION_SEARCH_RESULTS* /*pResults*/
16 )
17{
18 return pBE->Search(pArgs->wzId, pArgs->wzVariable);
19}
20
21/*******************************************************************
22BextBaseBundleExtensionProc - requires pvContext to be of type IBundleExtension.
23 Provides a default mapping between the message based
24 BundleExtension interface and the COM-based BundleExtension interface.
25
26*******************************************************************/
27static HRESULT WINAPI BextBaseBundleExtensionProc(
28 __in BUNDLE_EXTENSION_MESSAGE message,
29 __in const LPVOID pvArgs,
30 __inout LPVOID pvResults,
31 __in_opt LPVOID pvContext
32 )
33{
34 IBundleExtension* pBE = reinterpret_cast<IBundleExtension*>(pvContext);
35 HRESULT hr = pBE->BundleExtensionProc(message, pvArgs, pvResults, pvContext);
36
37 if (E_NOTIMPL == hr)
38 {
39 switch (message)
40 {
41 case BUNDLE_EXTENSION_MESSAGE_SEARCH:
42 hr = BextBaseBEProcSearch(pBE, reinterpret_cast<BUNDLE_EXTENSION_SEARCH_ARGS*>(pvArgs), reinterpret_cast<BUNDLE_EXTENSION_SEARCH_RESULTS*>(pvResults));
43 break;
44 }
45 }
46
47 return hr;
48}
diff --git a/src/bextutil/inc/BextBundleExtensionEngine.h b/src/bextutil/inc/BextBundleExtensionEngine.h
new file mode 100644
index 00000000..9fdcb700
--- /dev/null
+++ b/src/bextutil/inc/BextBundleExtensionEngine.h
@@ -0,0 +1,17 @@
1// 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.
2
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7// function declarations
8
9HRESULT BextBundleExtensionEngineCreate(
10 __in PFN_BUNDLE_EXTENSION_ENGINE_PROC pfnBundleExtensionEngineProc,
11 __in_opt LPVOID pvBundleExtensionEngineProcContext,
12 __out IBundleExtensionEngine** ppEngineForExtension
13 );
14
15#ifdef __cplusplus
16}
17#endif
diff --git a/src/bextutil/inc/IBundleExtension.h b/src/bextutil/inc/IBundleExtension.h
new file mode 100644
index 00000000..7516c11b
--- /dev/null
+++ b/src/bextutil/inc/IBundleExtension.h
@@ -0,0 +1,20 @@
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
5DECLARE_INTERFACE_IID_(IBundleExtension, IUnknown, "93123C9D-796B-4FCD-A507-6EDEF9A925FD")
6{
7 STDMETHOD(Search)(
8 __in LPCWSTR wzId,
9 __in LPCWSTR wzVariable
10 ) = 0;
11
12 // BundleExtensionProc - The PFN_BUNDLE_EXTENSION_PROC can call this method to give the BundleExtension raw access to the callback from the engine.
13 // This might be used to help the BundleExtension support more than one version of the engine.
14 STDMETHOD(BundleExtensionProc)(
15 __in BUNDLE_EXTENSION_MESSAGE message,
16 __in const LPVOID pvArgs,
17 __inout LPVOID pvResults,
18 __in_opt LPVOID pvContext
19 ) = 0;
20};
diff --git a/src/bextutil/inc/IBundleExtensionEngine.h b/src/bextutil/inc/IBundleExtensionEngine.h
new file mode 100644
index 00000000..869c6695
--- /dev/null
+++ b/src/bextutil/inc/IBundleExtensionEngine.h
@@ -0,0 +1,64 @@
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
5DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-9737-C185089EB263")
6{
7 STDMETHOD(EscapeString)(
8 __in_z LPCWSTR wzIn,
9 __out_ecount_opt(*pcchOut) LPWSTR wzOut,
10 __inout DWORD * pcchOut
11 ) = 0;
12
13 STDMETHOD(EvaluateCondition)(
14 __in_z LPCWSTR wzCondition,
15 __out BOOL * pf
16 ) = 0;
17
18 STDMETHOD(FormatString)(
19 __in_z LPCWSTR wzIn,
20 __out_ecount_opt(*pcchOut) LPWSTR wzOut,
21 __inout DWORD * pcchOut
22 ) = 0;
23
24 STDMETHOD(GetVariableNumeric)(
25 __in_z LPCWSTR wzVariable,
26 __out LONGLONG* pllValue
27 ) = 0;
28
29 STDMETHOD(GetVariableString)(
30 __in_z LPCWSTR wzVariable,
31 __out_ecount_opt(*pcchValue) LPWSTR wzValue,
32 __inout DWORD* pcchValue
33 ) = 0;
34
35 STDMETHOD(GetVariableVersion)(
36 __in_z LPCWSTR wzVariable,
37 __out DWORD64* pqwValue
38 ) = 0;
39
40 STDMETHOD(Log)(
41 __in BUNDLE_EXTENSION_LOG_LEVEL level,
42 __in_z LPCWSTR wzMessage
43 ) = 0;
44
45 STDMETHOD(SetVariableLiteralString)(
46 __in_z LPCWSTR wzVariable,
47 __in_z_opt LPCWSTR wzValue
48 ) = 0;
49
50 STDMETHOD(SetVariableNumeric)(
51 __in_z LPCWSTR wzVariable,
52 __in LONGLONG llValue
53 ) = 0;
54
55 STDMETHOD(SetVariableString)(
56 __in_z LPCWSTR wzVariable,
57 __in_z_opt LPCWSTR wzValue
58 ) = 0;
59
60 STDMETHOD(SetVariableVersion)(
61 __in_z LPCWSTR wzVariable,
62 __in DWORD64 qwValue
63 ) = 0;
64};
diff --git a/src/bextutil/inc/bextutil.h b/src/bextutil/inc/bextutil.h
new file mode 100644
index 00000000..0472f854
--- /dev/null
+++ b/src/bextutil/inc/bextutil.h
@@ -0,0 +1,76 @@
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
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#define BextExitOnFailure(x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); ExitTrace(x, f, __VA_ARGS__); goto LExit; }
13#define BextExitOnRootFailure(x, f, ...) if (FAILED(x)) { BextLogError(x, f, __VA_ARGS__); Dutil_RootFailure(__FILE__, __LINE__, x); ExitTrace(x, f, __VA_ARGS__); goto LExit; }
14#define BextExitOnNullWithLastError(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__); ExitTrace(x, f, __VA_ARGS__); goto LExit; }
15
16const LPCWSTR BUNDLE_EXTENSION_MANIFEST_FILENAME = L"BundleExtensionData.xml";
17
18
19/*******************************************************************
20 BextInitialize - remembers the engine interface to enable logging and
21 other functions.
22
23********************************************************************/
24DAPI_(void) BextInitialize(
25 __in IBundleExtensionEngine* pEngine
26 );
27
28/*******************************************************************
29 BextInitializeFromCreateArgs - convenience function to call BextBundleExtensionEngineCreate
30 then pass it along to BextInitialize.
31
32********************************************************************/
33DAPI_(HRESULT) BextInitializeFromCreateArgs(
34 __in const BUNDLE_EXTENSION_CREATE_ARGS* pArgs,
35 __out IBundleExtensionEngine** ppEngine
36 );
37
38/*******************************************************************
39 BextUninitialize - cleans up utility layer internals.
40
41********************************************************************/
42DAPI_(void) BextUninitialize();
43
44/*******************************************************************
45 BextGetBundleExtensionDataNode - gets the requested BundleExtension node.
46
47********************************************************************/
48DAPI_(HRESULT) BextGetBundleExtensionDataNode(
49 __in IXMLDOMDocument* pixdManifest,
50 __in LPCWSTR wzExtensionId,
51 __out IXMLDOMNode** ppixnBundleExtension
52 );
53
54/*******************************************************************
55 BextLog - logs a message with the engine.
56
57********************************************************************/
58DAPIV_(HRESULT) BextLog(
59 __in BUNDLE_EXTENSION_LOG_LEVEL level,
60 __in_z __format_string LPCSTR szFormat,
61 ...
62 );
63
64/*******************************************************************
65 BextLogError - logs an error message with the engine.
66
67********************************************************************/
68DAPIV_(HRESULT) BextLogError(
69 __in HRESULT hr,
70 __in_z __format_string LPCSTR szFormat,
71 ...
72 );
73
74#ifdef __cplusplus
75}
76#endif