diff options
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/dutil.vcxproj | 2 | ||||
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/dutil.vcxproj.filters | 6 | ||||
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/inc/dutilsources.h | 1 | ||||
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/inc/queutil.h | 52 | ||||
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/precomp.h | 1 | ||||
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/queutil.cpp | 144 |
6 files changed, 206 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/dutil.vcxproj b/src/libs/dutil/WixToolset.DUtil/dutil.vcxproj index c84b98fe..dc6b913f 100644 --- a/src/libs/dutil/WixToolset.DUtil/dutil.vcxproj +++ b/src/libs/dutil/WixToolset.DUtil/dutil.vcxproj | |||
@@ -91,6 +91,7 @@ | |||
91 | <ClCompile Include="proc2utl.cpp" /> | 91 | <ClCompile Include="proc2utl.cpp" /> |
92 | <ClCompile Include="proc3utl.cpp" /> | 92 | <ClCompile Include="proc3utl.cpp" /> |
93 | <ClCompile Include="procutil.cpp" /> | 93 | <ClCompile Include="procutil.cpp" /> |
94 | <ClCompile Include="queutil.cpp" /> | ||
94 | <ClCompile Include="regutil.cpp" /> | 95 | <ClCompile Include="regutil.cpp" /> |
95 | <ClCompile Include="resrutil.cpp" /> | 96 | <ClCompile Include="resrutil.cpp" /> |
96 | <ClCompile Include="reswutil.cpp" /> | 97 | <ClCompile Include="reswutil.cpp" /> |
@@ -153,6 +154,7 @@ | |||
153 | <ClInclude Include="inc\perfutil.h" /> | 154 | <ClInclude Include="inc\perfutil.h" /> |
154 | <ClInclude Include="inc\polcutil.h" /> | 155 | <ClInclude Include="inc\polcutil.h" /> |
155 | <ClInclude Include="inc\procutil.h" /> | 156 | <ClInclude Include="inc\procutil.h" /> |
157 | <ClInclude Include="inc\queutil.h" /> | ||
156 | <ClInclude Include="inc\regutil.h" /> | 158 | <ClInclude Include="inc\regutil.h" /> |
157 | <ClInclude Include="inc\resrutil.h" /> | 159 | <ClInclude Include="inc\resrutil.h" /> |
158 | <ClInclude Include="inc\reswutil.h" /> | 160 | <ClInclude Include="inc\reswutil.h" /> |
diff --git a/src/libs/dutil/WixToolset.DUtil/dutil.vcxproj.filters b/src/libs/dutil/WixToolset.DUtil/dutil.vcxproj.filters index efadef6f..c1095651 100644 --- a/src/libs/dutil/WixToolset.DUtil/dutil.vcxproj.filters +++ b/src/libs/dutil/WixToolset.DUtil/dutil.vcxproj.filters | |||
@@ -135,6 +135,9 @@ | |||
135 | <ClCompile Include="procutil.cpp"> | 135 | <ClCompile Include="procutil.cpp"> |
136 | <Filter>Source Files</Filter> | 136 | <Filter>Source Files</Filter> |
137 | </ClCompile> | 137 | </ClCompile> |
138 | <ClCompile Include="queutil.cpp"> | ||
139 | <Filter>Source Files</Filter> | ||
140 | </ClCompile> | ||
138 | <ClCompile Include="resrutil.cpp"> | 141 | <ClCompile Include="resrutil.cpp"> |
139 | <Filter>Source Files</Filter> | 142 | <Filter>Source Files</Filter> |
140 | </ClCompile> | 143 | </ClCompile> |
@@ -314,6 +317,9 @@ | |||
314 | <ClInclude Include="inc\procutil.h"> | 317 | <ClInclude Include="inc\procutil.h"> |
315 | <Filter>Header Files</Filter> | 318 | <Filter>Header Files</Filter> |
316 | </ClInclude> | 319 | </ClInclude> |
320 | <ClInclude Include="inc\queutil.h"> | ||
321 | <Filter>Header Files</Filter> | ||
322 | </ClInclude> | ||
317 | <ClInclude Include="inc\regutil.h"> | 323 | <ClInclude Include="inc\regutil.h"> |
318 | <Filter>Header Files</Filter> | 324 | <Filter>Header Files</Filter> |
319 | </ClInclude> | 325 | </ClInclude> |
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/dutilsources.h b/src/libs/dutil/WixToolset.DUtil/inc/dutilsources.h index 664c21e5..cf10f910 100644 --- a/src/libs/dutil/WixToolset.DUtil/inc/dutilsources.h +++ b/src/libs/dutil/WixToolset.DUtil/inc/dutilsources.h | |||
@@ -64,6 +64,7 @@ typedef enum DUTIL_SOURCE | |||
64 | DUTIL_SOURCE_WNDUTIL, | 64 | DUTIL_SOURCE_WNDUTIL, |
65 | DUTIL_SOURCE_ENVUTIL, | 65 | DUTIL_SOURCE_ENVUTIL, |
66 | DUTIL_SOURCE_THRDUTIL, | 66 | DUTIL_SOURCE_THRDUTIL, |
67 | DUTIL_SOURCE_QUEUTIL, | ||
67 | 68 | ||
68 | DUTIL_SOURCE_EXTERNAL = 256, | 69 | DUTIL_SOURCE_EXTERNAL = 256, |
69 | } DUTIL_SOURCE; | 70 | } DUTIL_SOURCE; |
diff --git a/src/libs/dutil/WixToolset.DUtil/inc/queutil.h b/src/libs/dutil/WixToolset.DUtil/inc/queutil.h new file mode 100644 index 00000000..3b88825e --- /dev/null +++ b/src/libs/dutil/WixToolset.DUtil/inc/queutil.h | |||
@@ -0,0 +1,52 @@ | |||
1 | #pragma once | ||
2 | // 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. | ||
3 | |||
4 | |||
5 | #ifdef __cplusplus | ||
6 | extern "C" { | ||
7 | #endif | ||
8 | |||
9 | #define ReleaseQueue(qh, pfn, pv) if (qh) { QueDestroy(qh, pfn, pv); } | ||
10 | #define ReleaseNullQue(qh, pfv, pv) if (qh) { QueDestroy(qh, pfn, pv); qh = NULL; } | ||
11 | |||
12 | typedef void* QUEUTIL_QUEUE_HANDLE; | ||
13 | |||
14 | typedef void(CALLBACK* PFNQUEUTIL_QUEUE_RELEASE_VALUE)( | ||
15 | __in void* pvValue, | ||
16 | __in void* pvContext | ||
17 | ); | ||
18 | |||
19 | extern const int QUEUTIL_QUEUE_HANDLE_BYTES; | ||
20 | |||
21 | /******************************************************************** | ||
22 | QueCreate - Creates a simple queue. It is not thread safe. | ||
23 | |||
24 | ********************************************************************/ | ||
25 | HRESULT DAPI QueCreate( | ||
26 | __out_bcount(QUEUTIL_QUEUE_HANDLE_BYTES) QUEUTIL_QUEUE_HANDLE* phQueue | ||
27 | ); | ||
28 | |||
29 | HRESULT DAPI QueEnqueue( | ||
30 | __in_bcount(QUEUTIL_QUEUE_HANDLE_BYTES) QUEUTIL_QUEUE_HANDLE hQueue, | ||
31 | __in void* pvValue | ||
32 | ); | ||
33 | |||
34 | /******************************************************************** | ||
35 | QueDequeue - Returns the value from the beginning of the queue, | ||
36 | or E_NOMOREITEMS if the queue is empty. | ||
37 | |||
38 | ********************************************************************/ | ||
39 | HRESULT DAPI QueDequeue( | ||
40 | __in_bcount(QUEUTIL_QUEUE_HANDLE_BYTES) QUEUTIL_QUEUE_HANDLE hQueue, | ||
41 | __out void** ppvValue | ||
42 | ); | ||
43 | |||
44 | void DAPI QueDestroy( | ||
45 | __in_bcount(QUEUTIL_QUEUE_HANDLE_BYTES) QUEUTIL_QUEUE_HANDLE hQueue, | ||
46 | __in_opt PFNQUEUTIL_QUEUE_RELEASE_VALUE pfnReleaseValue, | ||
47 | __in_opt void* pvContext | ||
48 | ); | ||
49 | |||
50 | #ifdef __cplusplus | ||
51 | } | ||
52 | #endif | ||
diff --git a/src/libs/dutil/WixToolset.DUtil/precomp.h b/src/libs/dutil/WixToolset.DUtil/precomp.h index b628d271..607f7ce6 100644 --- a/src/libs/dutil/WixToolset.DUtil/precomp.h +++ b/src/libs/dutil/WixToolset.DUtil/precomp.h | |||
@@ -75,6 +75,7 @@ | |||
75 | #include "perfutil.h" | 75 | #include "perfutil.h" |
76 | #include "polcutil.h" | 76 | #include "polcutil.h" |
77 | #include "procutil.h" | 77 | #include "procutil.h" |
78 | #include "queutil.h" | ||
78 | #include "regutil.h" | 79 | #include "regutil.h" |
79 | #include "butil.h" // NOTE: Butil must come after Regutil. | 80 | #include "butil.h" // NOTE: Butil must come after Regutil. |
80 | #include "resrutil.h" | 81 | #include "resrutil.h" |
diff --git a/src/libs/dutil/WixToolset.DUtil/queutil.cpp b/src/libs/dutil/WixToolset.DUtil/queutil.cpp new file mode 100644 index 00000000..c5d2d736 --- /dev/null +++ b/src/libs/dutil/WixToolset.DUtil/queutil.cpp | |||
@@ -0,0 +1,144 @@ | |||
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 | |||
5 | |||
6 | // Exit macros | ||
7 | #define QueExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_QUEUTIL, x, s, __VA_ARGS__) | ||
8 | #define QueExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_QUEUTIL, x, s, __VA_ARGS__) | ||
9 | #define QueExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_QUEUTIL, x, s, __VA_ARGS__) | ||
10 | #define QueExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_QUEUTIL, x, s, __VA_ARGS__) | ||
11 | #define QueExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_QUEUTIL, x, s, __VA_ARGS__) | ||
12 | #define QueExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_QUEUTIL, x, s, __VA_ARGS__) | ||
13 | #define QueExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_QUEUTIL, p, x, e, s, __VA_ARGS__) | ||
14 | #define QueExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_QUEUTIL, p, x, s, __VA_ARGS__) | ||
15 | #define QueExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_QUEUTIL, p, x, e, s, __VA_ARGS__) | ||
16 | #define QueExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_QUEUTIL, p, x, s, __VA_ARGS__) | ||
17 | #define QueExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_QUEUTIL, e, x, s, __VA_ARGS__) | ||
18 | #define QueExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_QUEUTIL, g, x, s, __VA_ARGS__) | ||
19 | |||
20 | |||
21 | struct QUEUTIL_QUEUE_ITEM | ||
22 | { | ||
23 | QUEUTIL_QUEUE_ITEM* pNext; | ||
24 | void* pvValue; | ||
25 | }; | ||
26 | |||
27 | struct QUEUTIL_QUEUE_STRUCT | ||
28 | { | ||
29 | QUEUTIL_QUEUE_ITEM* pFirst; | ||
30 | QUEUTIL_QUEUE_ITEM* pLast; | ||
31 | }; | ||
32 | |||
33 | const int QUEUTIL_QUEUE_HANDLE_BYTES = sizeof(QUEUTIL_QUEUE_STRUCT); | ||
34 | |||
35 | extern "C" HRESULT DAPI QueCreate( | ||
36 | __out_bcount(QUEUTIL_QUEUE_HANDLE_BYTES) QUEUTIL_QUEUE_HANDLE* phQueue | ||
37 | ) | ||
38 | { | ||
39 | HRESULT hr = S_OK; | ||
40 | |||
41 | QueExitOnNull(phQueue, hr, E_INVALIDARG, "Handle not specified while creating queue."); | ||
42 | |||
43 | *phQueue = reinterpret_cast<QUEUTIL_QUEUE_HANDLE>(MemAlloc(QUEUTIL_QUEUE_HANDLE_BYTES, TRUE)); | ||
44 | QueExitOnNull(*phQueue, hr, E_OUTOFMEMORY, "Failed to allocate queue object."); | ||
45 | |||
46 | LExit: | ||
47 | return hr; | ||
48 | } | ||
49 | |||
50 | extern "C" HRESULT DAPI QueEnqueue( | ||
51 | __in_bcount(QUEUTIL_QUEUE_HANDLE_BYTES) QUEUTIL_QUEUE_HANDLE hQueue, | ||
52 | __in void* pvValue | ||
53 | ) | ||
54 | { | ||
55 | HRESULT hr = S_OK; | ||
56 | QUEUTIL_QUEUE_ITEM* pItem = NULL; | ||
57 | QUEUTIL_QUEUE_STRUCT* pQueue = reinterpret_cast<QUEUTIL_QUEUE_STRUCT*>(hQueue); | ||
58 | |||
59 | QueExitOnNull(pQueue, hr, E_INVALIDARG, "Handle not specified while enqueing value."); | ||
60 | |||
61 | pItem = reinterpret_cast<QUEUTIL_QUEUE_ITEM*>(MemAlloc(sizeof(QUEUTIL_QUEUE_ITEM), TRUE)); | ||
62 | QueExitOnNull(pItem, hr, E_OUTOFMEMORY, "Failed to allocate queue item."); | ||
63 | |||
64 | pItem->pvValue = pvValue; | ||
65 | |||
66 | if (!pQueue->pLast) | ||
67 | { | ||
68 | pQueue->pFirst = pItem; | ||
69 | } | ||
70 | else | ||
71 | { | ||
72 | pQueue->pLast->pNext = pItem; | ||
73 | } | ||
74 | |||
75 | pQueue->pLast = pItem; | ||
76 | |||
77 | pItem = NULL; | ||
78 | |||
79 | LExit: | ||
80 | ReleaseMem(pItem); | ||
81 | |||
82 | return hr; | ||
83 | } | ||
84 | |||
85 | extern "C" HRESULT DAPI QueDequeue( | ||
86 | __in_bcount(QUEUTIL_QUEUE_HANDLE_BYTES) QUEUTIL_QUEUE_HANDLE hQueue, | ||
87 | __out void** ppvValue | ||
88 | ) | ||
89 | { | ||
90 | HRESULT hr = S_OK; | ||
91 | QUEUTIL_QUEUE_ITEM* pItem = NULL; | ||
92 | QUEUTIL_QUEUE_STRUCT* pQueue = reinterpret_cast<QUEUTIL_QUEUE_STRUCT*>(hQueue); | ||
93 | |||
94 | QueExitOnNull(pQueue, hr, E_INVALIDARG, "Handle not specified while dequeing value."); | ||
95 | |||
96 | if (!pQueue->pFirst) | ||
97 | { | ||
98 | *ppvValue = NULL; | ||
99 | ExitFunction1(hr = E_NOMOREITEMS); | ||
100 | } | ||
101 | |||
102 | pItem = pQueue->pFirst; | ||
103 | |||
104 | if (!pItem->pNext) | ||
105 | { | ||
106 | pQueue->pFirst = NULL; | ||
107 | pQueue->pLast = NULL; | ||
108 | } | ||
109 | else | ||
110 | { | ||
111 | pQueue->pFirst = pItem->pNext; | ||
112 | } | ||
113 | |||
114 | *ppvValue = pItem->pvValue; | ||
115 | |||
116 | LExit: | ||
117 | ReleaseMem(pItem); | ||
118 | |||
119 | return hr; | ||
120 | } | ||
121 | |||
122 | extern "C" void DAPI QueDestroy( | ||
123 | __in_bcount(QUEUTIL_QUEUE_HANDLE_BYTES) QUEUTIL_QUEUE_HANDLE hQueue, | ||
124 | __in_opt PFNQUEUTIL_QUEUE_RELEASE_VALUE pfnReleaseValue, | ||
125 | __in_opt void* pvContext | ||
126 | ) | ||
127 | { | ||
128 | HRESULT hr = S_OK; | ||
129 | void* pvValue = NULL; | ||
130 | |||
131 | hr = hQueue ? QueDequeue(hQueue, &pvValue) : E_NOMOREITEMS; | ||
132 | |||
133 | while (SUCCEEDED(hr)) | ||
134 | { | ||
135 | if (pfnReleaseValue) | ||
136 | { | ||
137 | pfnReleaseValue(pvValue, pvContext); | ||
138 | } | ||
139 | |||
140 | hr = QueDequeue(hQueue, &pvValue); | ||
141 | } | ||
142 | |||
143 | ReleaseMem(hQueue); | ||
144 | } | ||