From a1307cd4e76a89598c53cb68309358a7012db553 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 9 Sep 2022 16:03:29 -0500 Subject: Move `Bundle/@CommandLineVariables` into Bal.wixext. Implements 6858 --- src/api/burn/balutil/balinfo.cpp | 47 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'src/api/burn/balutil/balinfo.cpp') diff --git a/src/api/burn/balutil/balinfo.cpp b/src/api/burn/balutil/balinfo.cpp index 52a7f911..751ba4f1 100644 --- a/src/api/burn/balutil/balinfo.cpp +++ b/src/api/burn/balutil/balinfo.cpp @@ -348,7 +348,6 @@ DAPI_(HRESULT) BalSetOverridableVariablesFromEngine( ) { HRESULT hr = S_OK; - LPWSTR sczKey = NULL; BAL_INFO_OVERRIDABLE_VARIABLE* pOverridableVariable = NULL; for (DWORD i = 0; i < pCommand->cVariables; ++i) @@ -356,14 +355,6 @@ DAPI_(HRESULT) BalSetOverridableVariablesFromEngine( LPCWSTR wzVariableName = pCommand->rgVariableNames[i]; LPCWSTR wzVariableValue = pCommand->rgVariableValues[i]; - if (BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_UPPER_CASE == pOverridableVariables->commandLineType) - { - hr = StrAllocStringToUpperInvariant(&sczKey, wzVariableName, 0); - ExitOnFailure(hr, "Failed to upper case variable name."); - - wzVariableName = sczKey; - } - hr = DictGetValue(pOverridableVariables->sdVariables, wzVariableName, reinterpret_cast(&pOverridableVariable)); if (E_NOTFOUND == hr) { @@ -378,8 +369,6 @@ DAPI_(HRESULT) BalSetOverridableVariablesFromEngine( } LExit: - ReleaseStr(sczKey); - return hr; } @@ -604,29 +593,37 @@ static HRESULT ParseOverridableVariablesFromXml( { HRESULT hr = S_OK; IXMLDOMNode* pCommandLineNode = NULL; + BOOL fXmlFound = FALSE; LPWSTR scz = NULL; IXMLDOMNode* pNode = NULL; IXMLDOMNodeList* pNodes = NULL; BAL_INFO_OVERRIDABLE_VARIABLE* pOverridableVariable = NULL; - hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/CommandLine", &pCommandLineNode); - ExitOnRequiredXmlQueryFailure(hr, "Failed to select command line information."); - - // @Variables - hr = XmlGetAttributeEx(pCommandLineNode, L"Variables", &scz); - ExitOnRequiredXmlQueryFailure(hr, "Failed to get command line variable type."); + hr = XmlSelectSingleNode(pixdManifest, L"/BootstrapperApplicationData/WixStdbaCommandLine", &pCommandLineNode); + ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to select command line information."); - if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"upperCase", -1)) - { - pOverridableVariables->commandLineType = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_UPPER_CASE; - } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"caseSensitive", -1)) + if (!fXmlFound) { pOverridableVariables->commandLineType = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_SENSITIVE; } else { - ExitWithRootFailure(hr, E_INVALIDARG, "Invalid value for CommandLine/@Variables: %ls", scz); + // @Variables + hr = XmlGetAttributeEx(pCommandLineNode, L"VariableType", &scz); + ExitOnRequiredXmlQueryFailure(hr, "Failed to get command line variable type."); + + if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"caseInsensitive", -1)) + { + pOverridableVariables->commandLineType = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_INSENSITIVE; + } + else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"caseSensitive", -1)) + { + pOverridableVariables->commandLineType = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_SENSITIVE; + } + else + { + ExitWithRootFailure(hr, E_INVALIDARG, "Invalid value for CommandLine/@Variables: %ls", scz); + } } // Get the list of variables users can override on the command line. @@ -638,7 +635,9 @@ static HRESULT ParseOverridableVariablesFromXml( if (pOverridableVariables->cVariables) { - hr = DictCreateWithEmbeddedKey(&pOverridableVariables->sdVariables, pOverridableVariables->cVariables, reinterpret_cast(&pOverridableVariables->rgVariables), offsetof(BAL_INFO_OVERRIDABLE_VARIABLE, sczName), DICT_FLAG_NONE); + DICT_FLAG dfFlags = BAL_INFO_VARIABLE_COMMAND_LINE_TYPE_CASE_INSENSITIVE == pOverridableVariables->commandLineType ? DICT_FLAG_CASEINSENSITIVE : DICT_FLAG_NONE; + + hr = DictCreateWithEmbeddedKey(&pOverridableVariables->sdVariables, pOverridableVariables->cVariables, reinterpret_cast(&pOverridableVariables->rgVariables), offsetof(BAL_INFO_OVERRIDABLE_VARIABLE, sczName), dfFlags); ExitOnFailure(hr, "Failed to create the overridable variables string dictionary."); hr = MemAllocArray(reinterpret_cast(&pOverridableVariables->rgVariables), sizeof(pOverridableVariable), pOverridableVariables->cVariables); -- cgit v1.2.3-55-g6feb