aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/iis7util.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-03-02 14:19:14 -0600
committerSean Hall <r.sean.hall@gmail.com>2021-03-02 15:40:02 -0600
commit10ebf674da5df9224e4eddd3545518434c5b455b (patch)
treeea1f4063edd46e9942eab94dd7adb2f75c6c589e /src/dutil/iis7util.cpp
parent3bbf1347b900ec115a12faf8f46965c9b7649696 (diff)
downloadwix-10ebf674da5df9224e4eddd3545518434c5b455b.tar.gz
wix-10ebf674da5df9224e4eddd3545518434c5b455b.tar.bz2
wix-10ebf674da5df9224e4eddd3545518434c5b455b.zip
Update rest of dutil to use their own source with the Exit* macros.
Fix some CA warnings.
Diffstat (limited to 'src/dutil/iis7util.cpp')
-rw-r--r--src/dutil/iis7util.cpp57
1 files changed, 37 insertions, 20 deletions
diff --git a/src/dutil/iis7util.cpp b/src/dutil/iis7util.cpp
index 04165a8d..d0a0b000 100644
--- a/src/dutil/iis7util.cpp
+++ b/src/dutil/iis7util.cpp
@@ -3,6 +3,21 @@
3#include "precomp.h" 3#include "precomp.h"
4#include "iis7util.h" 4#include "iis7util.h"
5 5
6
7// Exit macros
8#define IisExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_IIS7UTIL, x, s, __VA_ARGS__)
9#define IisExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_IIS7UTIL, x, s, __VA_ARGS__)
10#define IisExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_IIS7UTIL, x, s, __VA_ARGS__)
11#define IisExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_IIS7UTIL, x, s, __VA_ARGS__)
12#define IisExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_IIS7UTIL, x, s, __VA_ARGS__)
13#define IisExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_IIS7UTIL, x, s, __VA_ARGS__)
14#define IisExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_IIS7UTIL, p, x, e, s, __VA_ARGS__)
15#define IisExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_IIS7UTIL, p, x, s, __VA_ARGS__)
16#define IisExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_IIS7UTIL, p, x, e, s, __VA_ARGS__)
17#define IisExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_IIS7UTIL, p, x, s, __VA_ARGS__)
18#define IisExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_IIS7UTIL, e, x, s, __VA_ARGS__)
19#define IisExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_IIS7UTIL, g, x, s, __VA_ARGS__)
20
6#define ISSTRINGVARIANT(vt) (VT_BSTR == vt || VT_LPWSTR == vt) 21#define ISSTRINGVARIANT(vt) (VT_BSTR == vt || VT_LPWSTR == vt)
7 22
8extern "C" HRESULT DAPI Iis7PutPropertyVariant( 23extern "C" HRESULT DAPI Iis7PutPropertyVariant(
@@ -16,13 +31,13 @@ extern "C" HRESULT DAPI Iis7PutPropertyVariant(
16 BSTR bstrPropName = NULL; 31 BSTR bstrPropName = NULL;
17 32
18 bstrPropName = ::SysAllocString(wzPropName); 33 bstrPropName = ::SysAllocString(wzPropName);
19 ExitOnNull(bstrPropName, hr, E_OUTOFMEMORY, "failed SysAllocString"); 34 IisExitOnNull(bstrPropName, hr, E_OUTOFMEMORY, "failed SysAllocString");
20 35
21 hr = pElement->GetPropertyByName(bstrPropName, &pProperty); 36 hr = pElement->GetPropertyByName(bstrPropName, &pProperty);
22 ExitOnFailure(hr, "Failed to get property object for %ls", wzPropName); 37 IisExitOnFailure(hr, "Failed to get property object for %ls", wzPropName);
23 38
24 hr = pProperty->put_Value(vtPut); 39 hr = pProperty->put_Value(vtPut);
25 ExitOnFailure(hr, "Failed to set property value for %ls", wzPropName); 40 IisExitOnFailure(hr, "Failed to set property value for %ls", wzPropName);
26 41
27LExit: 42LExit:
28 ReleaseBSTR(bstrPropName); 43 ReleaseBSTR(bstrPropName);
@@ -44,7 +59,7 @@ extern "C" HRESULT DAPI Iis7PutPropertyString(
44 ::VariantInit(&vtPut); 59 ::VariantInit(&vtPut);
45 vtPut.vt = VT_BSTR; 60 vtPut.vt = VT_BSTR;
46 vtPut.bstrVal = ::SysAllocString(wzString); 61 vtPut.bstrVal = ::SysAllocString(wzString);
47 ExitOnNull(vtPut.bstrVal, hr, E_OUTOFMEMORY, "failed SysAllocString"); 62 IisExitOnNull(vtPut.bstrVal, hr, E_OUTOFMEMORY, "failed SysAllocString");
48 63
49 hr = Iis7PutPropertyVariant(pElement, wzPropName, vtPut); 64 hr = Iis7PutPropertyVariant(pElement, wzPropName, vtPut);
50 65
@@ -92,13 +107,13 @@ extern "C" HRESULT DAPI Iis7GetPropertyVariant(
92 BSTR bstrPropName = NULL; 107 BSTR bstrPropName = NULL;
93 108
94 bstrPropName = ::SysAllocString(wzPropName); 109 bstrPropName = ::SysAllocString(wzPropName);
95 ExitOnNull(bstrPropName, hr, E_OUTOFMEMORY, "failed SysAllocString"); 110 IisExitOnNull(bstrPropName, hr, E_OUTOFMEMORY, "failed SysAllocString");
96 111
97 hr = pElement->GetPropertyByName(bstrPropName, &pProperty); 112 hr = pElement->GetPropertyByName(bstrPropName, &pProperty);
98 ExitOnFailure(hr, "Failed to get property object for %ls", wzPropName); 113 IisExitOnFailure(hr, "Failed to get property object for %ls", wzPropName);
99 114
100 hr = pProperty->get_Value(vtGet); 115 hr = pProperty->get_Value(vtGet);
101 ExitOnFailure(hr, "Failed to get property value for %ls", wzPropName); 116 IisExitOnFailure(hr, "Failed to get property value for %ls", wzPropName);
102 117
103LExit: 118LExit:
104 ReleaseBSTR(bstrPropName); 119 ReleaseBSTR(bstrPropName);
@@ -119,12 +134,12 @@ extern "C" HRESULT DAPI Iis7GetPropertyString(
119 134
120 ::VariantInit(&vtGet); 135 ::VariantInit(&vtGet);
121 hr = Iis7GetPropertyVariant(pElement, wzPropName, &vtGet); 136 hr = Iis7GetPropertyVariant(pElement, wzPropName, &vtGet);
122 ExitOnFailure(hr, "Failed to get iis7 property variant with name: %ls", wzPropName); 137 IisExitOnFailure(hr, "Failed to get iis7 property variant with name: %ls", wzPropName);
123 138
124 if (!ISSTRINGVARIANT(vtGet.vt)) 139 if (!ISSTRINGVARIANT(vtGet.vt))
125 { 140 {
126 hr = E_UNEXPECTED; 141 hr = E_UNEXPECTED;
127 ExitOnFailure(hr, "Tried to get property as a string, but type was %d instead.", vtGet.vt); 142 IisExitOnFailure(hr, "Tried to get property as a string, but type was %d instead.", vtGet.vt);
128 } 143 }
129 144
130 hr = StrAllocString(psczGet, vtGet.bstrVal, 0); 145 hr = StrAllocString(psczGet, vtGet.bstrVal, 0);
@@ -198,13 +213,13 @@ BOOL DAPI CompareVariantPath(
198 if (ISSTRINGVARIANT(pVariant1->vt)) 213 if (ISSTRINGVARIANT(pVariant1->vt))
199 { 214 {
200 hr = PathExpand(&wzValue1, pVariant1->bstrVal, PATH_EXPAND_ENVIRONMENT | PATH_EXPAND_FULLPATH); 215 hr = PathExpand(&wzValue1, pVariant1->bstrVal, PATH_EXPAND_ENVIRONMENT | PATH_EXPAND_FULLPATH);
201 ExitOnFailure(hr, "Failed to expand path %ls", pVariant1->bstrVal); 216 IisExitOnFailure(hr, "Failed to expand path %ls", pVariant1->bstrVal);
202 } 217 }
203 218
204 if (ISSTRINGVARIANT(pVariant2->vt)) 219 if (ISSTRINGVARIANT(pVariant2->vt))
205 { 220 {
206 hr = PathExpand(&wzValue2, pVariant2->bstrVal, PATH_EXPAND_ENVIRONMENT | PATH_EXPAND_FULLPATH); 221 hr = PathExpand(&wzValue2, pVariant2->bstrVal, PATH_EXPAND_ENVIRONMENT | PATH_EXPAND_FULLPATH);
207 ExitOnFailure(hr, "Failed to expand path %ls", pVariant2->bstrVal); 222 IisExitOnFailure(hr, "Failed to expand path %ls", pVariant2->bstrVal);
208 } 223 }
209 224
210 fEqual = CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzValue1, -1, wzValue2, -1); 225 fEqual = CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzValue1, -1, wzValue2, -1);
@@ -242,14 +257,14 @@ extern "C" BOOL DAPI Iis7IsMatchingAppHostElement(
242 VARIANTCOMPARATORPROC pComparator = pComparison->pComparator ? pComparison->pComparator : CompareVariantDefault; 257 VARIANTCOMPARATORPROC pComparator = pComparison->pComparator ? pComparison->pComparator : CompareVariantDefault;
243 258
244 hr = pElement->get_Name(&bstrElementName); 259 hr = pElement->get_Name(&bstrElementName);
245 ExitOnFailure(hr, "Failed to get name of element"); 260 IisExitOnFailure(hr, "Failed to get name of element");
246 if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pComparison->sczElementName, -1, bstrElementName, -1)) 261 if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pComparison->sczElementName, -1, bstrElementName, -1))
247 { 262 {
248 ExitFunction(); 263 ExitFunction();
249 } 264 }
250 265
251 hr = Iis7GetPropertyVariant(pElement, pComparison->sczAttributeName, &vPropValue); 266 hr = Iis7GetPropertyVariant(pElement, pComparison->sczAttributeName, &vPropValue);
252 ExitOnFailure(hr, "Failed to get value of %ls attribute of %ls element", pComparison->sczAttributeName, pComparison->sczElementName); 267 IisExitOnFailure(hr, "Failed to get value of %ls attribute of %ls element", pComparison->sczAttributeName, pComparison->sczElementName);
253 268
254 if (TRUE == pComparator(pComparison->pvAttributeValue, &vPropValue)) 269 if (TRUE == pComparator(pComparison->pvAttributeValue, &vPropValue))
255 { 270 {
@@ -274,7 +289,9 @@ BOOL DAPI IsMatchingAppHostMethod(
274 BSTR bstrName = NULL; 289 BSTR bstrName = NULL;
275 290
276 hr = pMethod->get_Name(&bstrName); 291 hr = pMethod->get_Name(&bstrName);
277 ExitOnFailure(hr, "Failed to get name of element"); 292 IisExitOnFailure(hr, "Failed to get name of element");
293
294 Assert(bstrName);
278 295
279 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzMethodName, -1, bstrName, -1)) 296 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzMethodName, -1, bstrName, -1))
280 { 297 {
@@ -303,7 +320,7 @@ extern "C" HRESULT DAPI Iis7FindAppHostElementPath(
303 320
304 vtValue.vt = VT_BSTR; 321 vtValue.vt = VT_BSTR;
305 vtValue.bstrVal = ::SysAllocString(wzAttributeValue); 322 vtValue.bstrVal = ::SysAllocString(wzAttributeValue);
306 ExitOnNull(vtValue.bstrVal, hr, E_OUTOFMEMORY, "failed SysAllocString"); 323 IisExitOnNull(vtValue.bstrVal, hr, E_OUTOFMEMORY, "failed SysAllocString");
307 324
308 comparison.sczElementName = wzElementName; 325 comparison.sczElementName = wzElementName;
309 comparison.sczAttributeName = wzAttributeName; 326 comparison.sczAttributeName = wzAttributeName;
@@ -337,7 +354,7 @@ extern "C" HRESULT DAPI Iis7FindAppHostElementString(
337 354
338 vtValue.vt = VT_BSTR; 355 vtValue.vt = VT_BSTR;
339 vtValue.bstrVal = ::SysAllocString(wzAttributeValue); 356 vtValue.bstrVal = ::SysAllocString(wzAttributeValue);
340 ExitOnNull(vtValue.bstrVal, hr, E_OUTOFMEMORY, "failed SysAllocString"); 357 IisExitOnNull(vtValue.bstrVal, hr, E_OUTOFMEMORY, "failed SysAllocString");
341 358
342 hr = Iis7FindAppHostElementVariant(pCollection, 359 hr = Iis7FindAppHostElementVariant(pCollection,
343 wzElementName, 360 wzElementName,
@@ -427,14 +444,14 @@ extern "C" HRESULT DAPI Iis7EnumAppHostElements(
427 } 444 }
428 445
429 hr = pCollection->get_Count(&dwElements); 446 hr = pCollection->get_Count(&dwElements);
430 ExitOnFailure(hr, "Failed get application IAppHostElementCollection count"); 447 IisExitOnFailure(hr, "Failed get application IAppHostElementCollection count");
431 448
432 vtIndex.vt = VT_UI4; 449 vtIndex.vt = VT_UI4;
433 for (DWORD i = 0; i < dwElements; ++i) 450 for (DWORD i = 0; i < dwElements; ++i)
434 { 451 {
435 vtIndex.ulVal = i; 452 vtIndex.ulVal = i;
436 hr = pCollection->get_Item(vtIndex , &pElement); 453 hr = pCollection->get_Item(vtIndex , &pElement);
437 ExitOnFailure(hr, "Failed get IAppHostElement element"); 454 IisExitOnFailure(hr, "Failed get IAppHostElement element");
438 455
439 if (pCallback(pElement, pContext)) 456 if (pCallback(pElement, pContext))
440 { 457 {
@@ -484,14 +501,14 @@ extern "C" HRESULT DAPI Iis7FindAppHostMethod(
484 } 501 }
485 502
486 hr = pCollection->get_Count(&dwMethods); 503 hr = pCollection->get_Count(&dwMethods);
487 ExitOnFailure(hr, "Failed get application IAppHostMethodCollection count"); 504 IisExitOnFailure(hr, "Failed get application IAppHostMethodCollection count");
488 505
489 vtIndex.vt = VT_UI4; 506 vtIndex.vt = VT_UI4;
490 for (DWORD i = 0; i < dwMethods; ++i) 507 for (DWORD i = 0; i < dwMethods; ++i)
491 { 508 {
492 vtIndex.ulVal = i; 509 vtIndex.ulVal = i;
493 hr = pCollection->get_Item(vtIndex , &pMethod); 510 hr = pCollection->get_Item(vtIndex , &pMethod);
494 ExitOnFailure(hr, "Failed get IAppHostMethod element"); 511 IisExitOnFailure(hr, "Failed get IAppHostMethod element");
495 512
496 if (IsMatchingAppHostMethod(pMethod, wzMethodName)) 513 if (IsMatchingAppHostMethod(pMethod, wzMethodName))
497 { 514 {