From a37013d41f0702cbdf2aee6dce95d26dafc069b4 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 1 Aug 2020 10:20:31 -0600 Subject: WIXFEAT:4763 Change "string" variable type to literal and add "formatted". --- src/bextutil/BextBundleExtensionEngine.cpp | 21 ++----------- src/bextutil/bextutil.cpp | 50 +++++++++++++++++++++++++++--- src/bextutil/bextutil.vcxproj | 8 ++--- src/bextutil/inc/IBundleExtensionEngine.h | 8 ++--- src/bextutil/inc/bextutil.h | 20 ++++++++++++ src/bextutil/packages.config | 4 +-- 6 files changed, 77 insertions(+), 34 deletions(-) (limited to 'src/bextutil') diff --git a/src/bextutil/BextBundleExtensionEngine.cpp b/src/bextutil/BextBundleExtensionEngine.cpp index 02070a6f..a78b3130 100644 --- a/src/bextutil/BextBundleExtensionEngine.cpp +++ b/src/bextutil/BextBundleExtensionEngine.cpp @@ -225,23 +225,6 @@ public: // IBundleExtensionEngine return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_LOG, &args, &results, m_pvBundleExtensionEngineProcContext); } - virtual STDMETHODIMP SetVariableLiteralString( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue - ) - { - BUNDLE_EXTENSION_ENGINE_SETVARIABLELITERALSTRING_ARGS args = { }; - BUNDLE_EXTENSION_ENGINE_SETVARIABLELITERALSTRING_RESULTS results = { }; - - args.cbSize = sizeof(args); - args.wzVariable = wzVariable; - args.wzValue = wzValue; - - results.cbSize = sizeof(results); - - return m_pfnBundleExtensionEngineProc(BUNDLE_EXTENSION_ENGINE_MESSAGE_SETVARIABLELITERALSTRING, &args, &results, m_pvBundleExtensionEngineProcContext); - } - virtual STDMETHODIMP SetVariableNumeric( __in_z LPCWSTR wzVariable, __in LONGLONG llValue @@ -261,7 +244,8 @@ public: // IBundleExtensionEngine virtual STDMETHODIMP SetVariableString( __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted ) { BUNDLE_EXTENSION_ENGINE_SETVARIABLESTRING_ARGS args = { }; @@ -270,6 +254,7 @@ public: // IBundleExtensionEngine args.cbSize = sizeof(args); args.wzVariable = wzVariable; args.wzValue = wzValue; + args.fFormatted = fFormatted; results.cbSize = sizeof(results); diff --git a/src/bextutil/bextutil.cpp b/src/bextutil/bextutil.cpp index baf35591..4b22d502 100644 --- a/src/bextutil/bextutil.cpp +++ b/src/bextutil/bextutil.cpp @@ -119,6 +119,29 @@ DAPIV_(HRESULT) BextLog( { HRESULT hr = S_OK; va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BextInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = BextLogArgs(level, szFormat, args); + va_end(args); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BextLogArgs( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + HRESULT hr = S_OK; LPSTR sczFormattedAnsi = NULL; LPWSTR sczMessage = NULL; @@ -128,9 +151,7 @@ DAPIV_(HRESULT) BextLog( ExitOnRootFailure(hr, "BextInitialize() must be called first."); } - va_start(args, szFormat); hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); - va_end(args); ExitOnFailure(hr, "Failed to format log string."); hr = StrAllocStringAnsi(&sczMessage, sczFormattedAnsi, 0, CP_UTF8); @@ -153,6 +174,29 @@ DAPIV_(HRESULT) BextLogError( { HRESULT hr = S_OK; va_list args; + + if (!vpEngine) + { + hr = E_POINTER; + ExitOnRootFailure(hr, "BextInitialize() must be called first."); + } + + va_start(args, szFormat); + hr = BextLogErrorArgs(hrError, szFormat, args); + va_end(args); + +LExit: + return hr; +} + + +DAPI_(HRESULT) BextLogErrorArgs( + __in HRESULT hrError, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ) +{ + HRESULT hr = S_OK; LPSTR sczFormattedAnsi = NULL; LPWSTR sczMessage = NULL; @@ -162,9 +206,7 @@ DAPIV_(HRESULT) BextLogError( ExitOnRootFailure(hr, "BextInitialize() must be called first."); } - va_start(args, szFormat); hr = StrAnsiAllocFormattedArgs(&sczFormattedAnsi, szFormat, args); - va_end(args); ExitOnFailure(hr, "Failed to format error log string."); hr = StrAllocFormatted(&sczMessage, L"Error 0x%08x: %S", hrError, sczFormattedAnsi); diff --git a/src/bextutil/bextutil.vcxproj b/src/bextutil/bextutil.vcxproj index 78ff290d..32518202 100644 --- a/src/bextutil/bextutil.vcxproj +++ b/src/bextutil/bextutil.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -95,8 +95,8 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/bextutil/inc/IBundleExtensionEngine.h b/src/bextutil/inc/IBundleExtensionEngine.h index 869c6695..7772b016 100644 --- a/src/bextutil/inc/IBundleExtensionEngine.h +++ b/src/bextutil/inc/IBundleExtensionEngine.h @@ -42,11 +42,6 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973 __in_z LPCWSTR wzMessage ) = 0; - STDMETHOD(SetVariableLiteralString)( - __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue - ) = 0; - STDMETHOD(SetVariableNumeric)( __in_z LPCWSTR wzVariable, __in LONGLONG llValue @@ -54,7 +49,8 @@ DECLARE_INTERFACE_IID_(IBundleExtensionEngine, IUnknown, "9D027A39-F6B6-42CC-973 STDMETHOD(SetVariableString)( __in_z LPCWSTR wzVariable, - __in_z_opt LPCWSTR wzValue + __in_z_opt LPCWSTR wzValue, + __in BOOL fFormatted ) = 0; STDMETHOD(SetVariableVersion)( diff --git a/src/bextutil/inc/bextutil.h b/src/bextutil/inc/bextutil.h index e80d3944..ac9c0062 100644 --- a/src/bextutil/inc/bextutil.h +++ b/src/bextutil/inc/bextutil.h @@ -71,6 +71,16 @@ DAPIV_(HRESULT) BextLog( ... ); +/******************************************************************* + BextLogArgs - logs a message with the engine. + +********************************************************************/ +DAPI_(HRESULT) BextLogArgs( + __in BUNDLE_EXTENSION_LOG_LEVEL level, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ); + /******************************************************************* BextLogError - logs an error message with the engine. @@ -81,6 +91,16 @@ DAPIV_(HRESULT) BextLogError( ... ); +/******************************************************************* + BextLogErrorArgs - logs an error message with the engine. + +********************************************************************/ +DAPI_(HRESULT) BextLogErrorArgs( + __in HRESULT hr, + __in_z __format_string LPCSTR szFormat, + __in va_list args + ); + #ifdef __cplusplus } #endif diff --git a/src/bextutil/packages.config b/src/bextutil/packages.config index 56f0cea3..e8417860 100644 --- a/src/bextutil/packages.config +++ b/src/bextutil/packages.config @@ -1,6 +1,6 @@  - - + + \ No newline at end of file -- cgit v1.2.3-55-g6feb