1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
// 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.
#include "precomp.h"
HRESULT ScaGetHttpHeader7(
__in int iParentType,
__in_z LPCWSTR wzParentValue,
__in SCA_HTTP_HEADER** ppshhList,
__out SCA_HTTP_HEADER** ppshhOut
)
{
HRESULT hr = S_OK;
SCA_HTTP_HEADER* pshhAdd = NULL;
SCA_HTTP_HEADER* pshhLast = NULL;
*ppshhOut = NULL;
if (!*ppshhList)
{
return hr;
}
SCA_HTTP_HEADER* pshh = *ppshhList;
while (pshh)
{
if (iParentType == pshh->iParentType && 0 == wcscmp(wzParentValue, pshh->wzParentValue))
{
// Found a match, take this one out of the list and add it to the matched out list
pshhAdd = pshh;
if (pshhLast)
{
// If we're not at the beginning of the list tell the last node about it's new next (since we're taking away it's current next)
pshhLast->pshhNext = pshhAdd->pshhNext;
}
else
{
// If we are at the beginning (no pshhLast) update the beginning (since we're taking it)
*ppshhList = pshh->pshhNext;
}
pshh = pshh->pshhNext; // move on
// Add the one we've removed to the beginning of the out list
pshhAdd->pshhNext = *ppshhOut;
*ppshhOut = pshhAdd;
}
else
{
pshhLast = pshh; // remember the last we that didn't match
pshh = pshh->pshhNext; // move on
}
}
return hr;
}
HRESULT ScaWriteHttpHeader7(
__in_z LPCWSTR wzWebName,
__in_z LPCWSTR wzRoot,
SCA_HTTP_HEADER* pshhList
)
{
HRESULT hr = S_OK;
hr = ScaWriteConfigID(IIS_HTTP_HEADER_BEGIN);
ExitOnFailure(hr, "Fail to write httpHeader begin ID");
hr = ScaWriteConfigString(wzWebName);
ExitOnFailure(hr, "Fail to write httpHeader Web Key");
hr = ScaWriteConfigString(wzRoot);
ExitOnFailure(hr, "Fail to write httpHeader Vdir key");
// Loop through the HTTP headers
for (SCA_HTTP_HEADER* pshh = pshhList; pshh; pshh = pshh->pshhNext)
{
hr = ScaWriteConfigID(IIS_HTTP_HEADER);
ExitOnFailure(hr, "Fail to write httpHeader ID");
hr = ScaWriteConfigString(pshh->wzName);
ExitOnFailure(hr, "Fail to write httpHeader name");
hr = ScaWriteConfigString(pshh->wzValue);
ExitOnFailure(hr, "Fail to write httpHeader value");
}
hr = ScaWriteConfigID(IIS_HTTP_HEADER_END);
ExitOnFailure(hr, "Fail to write httpHeader end ID");
LExit:
return hr;
}
HRESULT ScaHttpHeaderCheckList7(
__in SCA_HTTP_HEADER* pshhList
)
{
if (!pshhList)
{
return S_OK;
}
while (pshhList)
{
WcaLog(LOGMSG_STANDARD, "Http Header: %ls for parent: %ls not used!", pshhList->wzName, pshhList->wzParentValue);
pshhList = pshhList->pshhNext;
}
return E_FAIL;
}
//static HRESULT AddHttpHeaderToList(
// __in SCA_HTTP_HEADER** ppshhList
// )
//{
// HRESULT hr = S_OK;
//
// SCA_HTTP_HEADER* pshh = static_cast<SCA_HTTP_HEADER*>(MemAlloc(sizeof(SCA_HTTP_HEADER), TRUE));
// ExitOnNull(pshh, hr, E_OUTOFMEMORY, "failed to allocate memory for new http header list element");
//
// pshh->pshhNext = *ppshhList;
// *ppshhList = pshh;
//
//LExit:
// return hr;
//}
|