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