/src/FreeRDP/winpr/include/winpr/collections.h
Line | Count | Source |
1 | | /** |
2 | | * WinPR: Windows Portable Runtime |
3 | | * Collections |
4 | | * |
5 | | * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com> |
6 | | * |
7 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | | * you may not use this file except in compliance with the License. |
9 | | * You may obtain a copy of the License at |
10 | | * |
11 | | * http://www.apache.org/licenses/LICENSE-2.0 |
12 | | * |
13 | | * Unless required by applicable law or agreed to in writing, software |
14 | | * distributed under the License is distributed on an "AS IS" BASIS, |
15 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | | * See the License for the specific language governing permissions and |
17 | | * limitations under the License. |
18 | | */ |
19 | | |
20 | | #ifndef WINPR_COLLECTIONS_H |
21 | | #define WINPR_COLLECTIONS_H |
22 | | |
23 | | #include <stdio.h> |
24 | | #include <stdlib.h> |
25 | | #include <string.h> |
26 | | #include <stdarg.h> |
27 | | |
28 | | #include <winpr/winpr.h> |
29 | | #include <winpr/wtypes.h> |
30 | | #include <winpr/assert.h> |
31 | | |
32 | | #include <winpr/crt.h> |
33 | | #include <winpr/synch.h> |
34 | | #include <winpr/stream.h> |
35 | | |
36 | | #ifdef __cplusplus |
37 | | extern "C" |
38 | | { |
39 | | #endif |
40 | | |
41 | | typedef void* (*OBJECT_NEW_FN)(const void* val); |
42 | | typedef void (*OBJECT_INIT_FN)(void* obj); |
43 | | typedef void (*OBJECT_UNINIT_FN)(void* obj); |
44 | | typedef void (*OBJECT_FREE_FN)(void* obj); |
45 | | typedef BOOL (*OBJECT_EQUALS_FN)(const void* objA, const void* objB); |
46 | | |
47 | | /** @struct wObject |
48 | | * @brief This struct contains function pointer to initialize/free objects |
49 | | * |
50 | | */ |
51 | | typedef struct |
52 | | { |
53 | | WINPR_ATTR_NODISCARD OBJECT_NEW_FN |
54 | | fnObjectNew; /**< A new function that creates a clone of the input */ |
55 | | OBJECT_INIT_FN |
56 | | fnObjectInit; /**< A function initializing an object, but not allocating it */ |
57 | | OBJECT_UNINIT_FN |
58 | | fnObjectUninit; /**< A function to deinitialize an object, but not free it */ |
59 | | OBJECT_FREE_FN fnObjectFree; /**< A function freeing an object */ |
60 | | WINPR_ATTR_NODISCARD OBJECT_EQUALS_FN |
61 | | fnObjectEquals; /**< A function to compare two objects */ |
62 | | } wObject; |
63 | | |
64 | | /* utility function with compatible arguments for string data */ |
65 | | |
66 | | /** @brief helper function to clone a string |
67 | | * @param pvstr the source string to clone |
68 | | * @return A clone of the source or \b nullptr |
69 | | * @since version 3.3.0 |
70 | | */ |
71 | | WINPR_ATTR_NODISCARD |
72 | | WINPR_API void* winpr_ObjectStringClone(const void* pvstr); |
73 | | |
74 | | /** @brief helper function to clone a WCHAR string |
75 | | * @param pvstr the source string to clone |
76 | | * @return A clone of the source or \b nullptr |
77 | | * @since version 3.3.0 |
78 | | */ |
79 | | WINPR_ATTR_NODISCARD |
80 | | WINPR_API void* winpr_ObjectWStringClone(const void* pvstr); |
81 | | |
82 | | /** @brief helper function to free a (WCHAR) string |
83 | | * @param pvstr the string to free |
84 | | * @since version 3.3.0 |
85 | | */ |
86 | | WINPR_API void winpr_ObjectStringFree(void* pvstr); |
87 | | |
88 | | /* System.Collections.Queue */ |
89 | | |
90 | | typedef struct s_wQueue wQueue; |
91 | | |
92 | | /** @brief Return the number of elements in the queue |
93 | | * |
94 | | * @param queue A pointer to a queue, must not be \b nullptr |
95 | | * |
96 | | * @return the number of objects queued |
97 | | */ |
98 | | WINPR_ATTR_NODISCARD |
99 | | WINPR_API size_t Queue_Count(wQueue* queue); |
100 | | |
101 | | /** @brief Return the allocated elements in the queue |
102 | | * |
103 | | * @param queue A pointer to a queue, must not be \b nullptr |
104 | | * |
105 | | * @return the number of objects allocated |
106 | | */ |
107 | | WINPR_ATTR_NODISCARD |
108 | | WINPR_API size_t Queue_Capacity(wQueue* queue); |
109 | | |
110 | | /** @brief Mutex-Lock a queue |
111 | | * |
112 | | * @param queue A pointer to a queue, must not be \b nullptr |
113 | | */ |
114 | | WINPR_API void Queue_Lock(wQueue* queue); |
115 | | |
116 | | /** @brief Mutex-Unlock a queue |
117 | | * |
118 | | * @param queue A pointer to a queue, must not be \b nullptr |
119 | | */ |
120 | | WINPR_API void Queue_Unlock(wQueue* queue); |
121 | | |
122 | | /** @brief Get an event handle for the queue, usable by \b WaitForSingleObject or \b |
123 | | * WaitForMultipleObjects |
124 | | * |
125 | | * @param queue A pointer to a queue, must not be \b nullptr |
126 | | */ |
127 | | WINPR_ATTR_NODISCARD |
128 | | WINPR_API HANDLE Queue_Event(wQueue* queue); |
129 | | |
130 | | /** @brief Mutex-Lock a queue |
131 | | * |
132 | | * @param queue A pointer to a queue, must not be \b nullptr |
133 | | * |
134 | | * @return A pointer to a \b wObject that contains the allocation/cleanup handlers for queue |
135 | | * elements |
136 | | */ |
137 | | WINPR_ATTR_NODISCARD |
138 | | WINPR_API wObject* Queue_Object(wQueue* queue); |
139 | | |
140 | | /** @brief Remove all elements from a queue, call \b wObject cleanup functions \b fnObjectFree |
141 | | * |
142 | | * @param queue A pointer to a queue, must not be \b nullptr |
143 | | */ |
144 | | WINPR_API void Queue_Clear(wQueue* queue); |
145 | | |
146 | | /** @brief Check if the queue contains an object |
147 | | * |
148 | | * @param queue A pointer to a queue, must not be \b nullptr |
149 | | * @param obj The object to look for. \b fnObjectEquals is called internally |
150 | | * |
151 | | * @return \b TRUE if the object was found, \b FALSE otherwise. |
152 | | */ |
153 | | WINPR_ATTR_NODISCARD |
154 | | WINPR_API BOOL Queue_Contains(wQueue* queue, const void* obj); |
155 | | |
156 | | /** \brief Pushes a new element into the queue. |
157 | | * If a \b fnObjectNew is set, the element is copied and the queue takes |
158 | | * ownership of the memory, otherwise the ownership stays with the caller. |
159 | | * |
160 | | * \param queue The queue to operate on |
161 | | * \param obj A pointer to the object to queue |
162 | | * |
163 | | * \return TRUE for success, FALSE if failed. |
164 | | */ |
165 | | WINPR_ATTR_NODISCARD |
166 | | WINPR_API BOOL Queue_Enqueue(wQueue* queue, const void* obj); |
167 | | |
168 | | /** \brief returns the element at the top of the queue. The element is removed from the queue, |
169 | | * ownership of the element is passed on to the caller. |
170 | | * |
171 | | * \param queue The queue to check |
172 | | * |
173 | | * \return nullptr if empty, a pointer to the memory on top of the queue otherwise. |
174 | | */ |
175 | | WINPR_ATTR_NODISCARD |
176 | | WINPR_API void* Queue_Dequeue(wQueue* queue); |
177 | | |
178 | | /** \brief returns the element at the top of the queue. The element is not removed from the |
179 | | * queue, ownership of the element stays with the queue. |
180 | | * |
181 | | * \param queue The queue to check |
182 | | * |
183 | | * \return nullptr if empty, a pointer to the memory on top of the queue otherwise. |
184 | | */ |
185 | | WINPR_ATTR_NODISCARD |
186 | | WINPR_API void* Queue_Peek(wQueue* queue); |
187 | | |
188 | | /** \brief Removes the element at the top of the queue. If fnObjectFree is set, the element is |
189 | | * freed. This can be used in combination with Queue_Peek to handle an element and discard it |
190 | | * with this function afterward. An alternative is Queue_Dequeue with calling the appropriate |
191 | | * free function afterward. |
192 | | * |
193 | | * \param queue The queue to operate on |
194 | | */ |
195 | | WINPR_API void Queue_Discard(wQueue* queue); |
196 | | |
197 | | /** @brief Clean up a queue, free all resources (e.g. calls \b Queue_Clear) |
198 | | * |
199 | | * @param queue The queue to free, may be \b nullptr |
200 | | */ |
201 | | WINPR_API void Queue_Free(wQueue* queue); |
202 | | |
203 | | /** @brief Creates a new queue |
204 | | * |
205 | | * @param synchronized If \b TRUE all functions are thread safe, if \b FALSE no synchronization |
206 | | * is done. |
207 | | * @param capacity The initial capacity of the queue. If \b 0 or \b -1 default settings are |
208 | | * applied. |
209 | | * @param growthFactor allocation behaviour when the queue capacity should be increased. Larger |
210 | | * values increase the allocation contingent. \b 0 or \b -1 apply default settings. |
211 | | * |
212 | | * |
213 | | * @return A newly allocated queue or \b nullptr in case of failure |
214 | | */ |
215 | | WINPR_ATTR_MALLOC(Queue_Free, 1) |
216 | | WINPR_API wQueue* Queue_New(BOOL synchronized, SSIZE_T capacity, SSIZE_T growthFactor); |
217 | | |
218 | | /* System.Collections.Stack */ |
219 | | |
220 | | typedef struct s_wStack wStack; |
221 | | |
222 | | WINPR_ATTR_NODISCARD |
223 | | WINPR_API size_t Stack_Count(wStack* stack); |
224 | | |
225 | | WINPR_ATTR_NODISCARD |
226 | | WINPR_API BOOL Stack_IsSynchronized(wStack* stack); |
227 | | |
228 | | WINPR_ATTR_NODISCARD |
229 | | WINPR_API wObject* Stack_Object(wStack* stack); |
230 | | |
231 | | WINPR_API void Stack_Clear(wStack* stack); |
232 | | |
233 | | WINPR_ATTR_NODISCARD |
234 | | WINPR_API BOOL Stack_Contains(wStack* stack, const void* obj); |
235 | | |
236 | | WINPR_API void Stack_Push(wStack* stack, void* obj); |
237 | | |
238 | | WINPR_ATTR_NODISCARD |
239 | | WINPR_API void* Stack_Pop(wStack* stack); |
240 | | |
241 | | WINPR_ATTR_NODISCARD |
242 | | WINPR_API void* Stack_Peek(wStack* stack); |
243 | | |
244 | | WINPR_API void Stack_Free(wStack* stack); |
245 | | |
246 | | WINPR_ATTR_MALLOC(Stack_Free, 1) |
247 | | WINPR_API wStack* Stack_New(BOOL synchronized); |
248 | | |
249 | | /* System.Collections.ArrayList */ |
250 | | |
251 | | typedef struct s_wArrayList wArrayList; |
252 | | |
253 | | WINPR_ATTR_NODISCARD |
254 | | WINPR_API size_t ArrayList_Capacity(wArrayList* arrayList); |
255 | | |
256 | | WINPR_ATTR_NODISCARD |
257 | | WINPR_API size_t ArrayList_Count(wArrayList* arrayList); |
258 | | |
259 | | WINPR_ATTR_NODISCARD |
260 | | WINPR_API size_t ArrayList_Items(wArrayList* arrayList, ULONG_PTR** ppItems); |
261 | | |
262 | | WINPR_ATTR_NODISCARD |
263 | | WINPR_API BOOL ArrayList_IsFixedSized(wArrayList* arrayList); |
264 | | |
265 | | WINPR_ATTR_NODISCARD |
266 | | WINPR_API BOOL ArrayList_IsReadOnly(wArrayList* arrayList); |
267 | | |
268 | | WINPR_ATTR_NODISCARD |
269 | | WINPR_API BOOL ArrayList_IsSynchronized(wArrayList* arrayList); |
270 | | |
271 | | WINPR_API void ArrayList_Lock(wArrayList* arrayList); |
272 | | WINPR_API void ArrayList_Unlock(wArrayList* arrayList); |
273 | | |
274 | | WINPR_ATTR_NODISCARD |
275 | | WINPR_API void* ArrayList_GetItem(wArrayList* arrayList, size_t index); |
276 | | |
277 | | WINPR_ATTR_NODISCARD |
278 | | WINPR_API BOOL ArrayList_SetItem(wArrayList* arrayList, size_t index, const void* obj); |
279 | | |
280 | | WINPR_ATTR_NODISCARD |
281 | | WINPR_API wObject* ArrayList_Object(wArrayList* arrayList); |
282 | | |
283 | | typedef BOOL (*ArrayList_ForEachFkt)(void* data, size_t index, va_list ap); |
284 | | |
285 | | WINPR_ATTR_NODISCARD |
286 | | WINPR_API BOOL ArrayList_ForEach(wArrayList* arrayList, ArrayList_ForEachFkt fkt, ...); |
287 | | |
288 | | WINPR_ATTR_NODISCARD |
289 | | WINPR_API BOOL ArrayList_ForEachAP(wArrayList* arrayList, ArrayList_ForEachFkt fkt, va_list ap); |
290 | | |
291 | | WINPR_API void ArrayList_Clear(wArrayList* arrayList); |
292 | | |
293 | | WINPR_ATTR_NODISCARD |
294 | | WINPR_API BOOL ArrayList_Contains(wArrayList* arrayList, const void* obj); |
295 | | |
296 | | #if defined(WITH_WINPR_DEPRECATED) |
297 | | WINPR_DEPRECATED(WINPR_ATTR_NODISCARD WINPR_API int ArrayList_Add(wArrayList* arrayList, |
298 | | const void* obj)); |
299 | | #endif |
300 | | |
301 | | WINPR_API BOOL ArrayList_Append(wArrayList* arrayList, const void* obj); |
302 | | |
303 | | WINPR_ATTR_NODISCARD |
304 | | WINPR_API BOOL ArrayList_Insert(wArrayList* arrayList, size_t index, const void* obj); |
305 | | |
306 | | WINPR_API BOOL ArrayList_Remove(wArrayList* arrayList, const void* obj); |
307 | | |
308 | | WINPR_API BOOL ArrayList_RemoveAt(wArrayList* arrayList, size_t index); |
309 | | |
310 | | WINPR_ATTR_NODISCARD |
311 | | WINPR_API SSIZE_T ArrayList_IndexOf(wArrayList* arrayList, const void* obj, SSIZE_T startIndex, |
312 | | SSIZE_T count); |
313 | | |
314 | | WINPR_ATTR_NODISCARD |
315 | | WINPR_API SSIZE_T ArrayList_LastIndexOf(wArrayList* arrayList, const void* obj, |
316 | | SSIZE_T startIndex, SSIZE_T count); |
317 | | |
318 | | WINPR_API void ArrayList_Free(wArrayList* arrayList); |
319 | | |
320 | | WINPR_ATTR_MALLOC(ArrayList_Free, 1) |
321 | | WINPR_API wArrayList* ArrayList_New(BOOL synchronized); |
322 | | |
323 | | /* System.Collections.DictionaryBase */ |
324 | | |
325 | | /* System.Collections.Specialized.ListDictionary */ |
326 | | typedef struct s_wListDictionary wListDictionary; |
327 | | |
328 | | /** @brief Get the \b wObject function pointer struct for the \b key of the dictionary. |
329 | | * |
330 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
331 | | * |
332 | | * @return a \b wObject used to initialize the key object, \b nullptr in case of failure |
333 | | */ |
334 | | WINPR_ATTR_NODISCARD |
335 | | WINPR_API wObject* ListDictionary_KeyObject(wListDictionary* listDictionary); |
336 | | |
337 | | /** @brief Get the \b wObject function pointer struct for the \b value of the dictionary. |
338 | | * |
339 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
340 | | * |
341 | | * @return a \b wObject used to initialize the value object, \b nullptr in case of failure |
342 | | */ |
343 | | WINPR_ATTR_NODISCARD |
344 | | WINPR_API wObject* ListDictionary_ValueObject(wListDictionary* listDictionary); |
345 | | |
346 | | /** @brief Return the number of entries in the dictionary |
347 | | * |
348 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
349 | | * |
350 | | * @return the number of entries |
351 | | */ |
352 | | WINPR_ATTR_NODISCARD |
353 | | WINPR_API size_t ListDictionary_Count(wListDictionary* listDictionary); |
354 | | |
355 | | /** @brief mutex-lock a dictionary |
356 | | * |
357 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
358 | | */ |
359 | | WINPR_API void ListDictionary_Lock(wListDictionary* listDictionary); |
360 | | /** @brief mutex-unlock a dictionary |
361 | | * |
362 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
363 | | */ |
364 | | WINPR_API void ListDictionary_Unlock(wListDictionary* listDictionary); |
365 | | |
366 | | /** @brief mutex-lock a dictionary |
367 | | * |
368 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
369 | | * @param key The key identifying the entry, if set cloned with \b fnObjectNew |
370 | | * @param value The value to store for the \b key. May be \b nullptr. if set cloned with \b |
371 | | * fnObjectNew |
372 | | * |
373 | | * @return \b TRUE for successful addition, \b FALSE for failure |
374 | | */ |
375 | | WINPR_ATTR_NODISCARD |
376 | | WINPR_API BOOL ListDictionary_Add(wListDictionary* listDictionary, const void* key, |
377 | | const void* value); |
378 | | |
379 | | /** @brief Remove an item from the dictionary and return the value. Cleanup is up to the caller. |
380 | | * |
381 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
382 | | * @param key The key identifying the entry |
383 | | * |
384 | | * @return a pointer to the value stored or \b nullptr in case of failure or not found |
385 | | */ |
386 | | WINPR_ATTR_NODISCARD |
387 | | WINPR_API void* ListDictionary_Take(wListDictionary* listDictionary, const void* key); |
388 | | |
389 | | /** @brief Remove an item from the dictionary and call \b fnObjectFree for key and value |
390 | | * |
391 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
392 | | * @param key The key identifying the entry |
393 | | */ |
394 | | WINPR_API void ListDictionary_Remove(wListDictionary* listDictionary, const void* key); |
395 | | |
396 | | /** @brief Remove the head item from the dictionary and return the value. Cleanup is up to the |
397 | | * caller. |
398 | | * |
399 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
400 | | * |
401 | | * @return a pointer to the value stored or \b nullptr in case of failure or not found |
402 | | */ |
403 | | WINPR_ATTR_NODISCARD |
404 | | WINPR_API void* ListDictionary_Take_Head(wListDictionary* listDictionary); |
405 | | |
406 | | /** @brief Remove the head item from the dictionary and call \b fnObjectFree for key and value |
407 | | * |
408 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
409 | | */ |
410 | | WINPR_API void ListDictionary_Remove_Head(wListDictionary* listDictionary); |
411 | | |
412 | | /** @brief Remove all items from the dictionary and call \b fnObjectFree for key and value |
413 | | * |
414 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
415 | | */ |
416 | | WINPR_API void ListDictionary_Clear(wListDictionary* listDictionary); |
417 | | |
418 | | /** @brief Check if a dictionary contains \b key (\b fnObjectEquals of the key object is called) |
419 | | * |
420 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
421 | | * @param key A key to look for |
422 | | * |
423 | | * @return \b TRUE if found, \b FALSE otherwise |
424 | | */ |
425 | | WINPR_ATTR_NODISCARD |
426 | | WINPR_API BOOL ListDictionary_Contains(wListDictionary* listDictionary, const void* key); |
427 | | |
428 | | /** @brief return all keys the dictionary contains |
429 | | * |
430 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
431 | | * @param ppKeys A pointer to a \b ULONG_PTR array that will hold the result keys. Call \b free |
432 | | * if no longer required |
433 | | * |
434 | | * @return the number of keys found in the dictionary or \b 0 if \b ppKeys is \b nullptr |
435 | | */ |
436 | | WINPR_ATTR_NODISCARD |
437 | | WINPR_API size_t ListDictionary_GetKeys(wListDictionary* listDictionary, ULONG_PTR** ppKeys); |
438 | | |
439 | | /** @brief Get the value in the dictionary for a \b key. The ownership of the data stays with |
440 | | * the dictionary. |
441 | | * |
442 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
443 | | * @param key A key to look for (\b fnObjectEquals of the key object is called) |
444 | | * |
445 | | * @return A pointer to the data in the dictionary or \b nullptr if not found |
446 | | */ |
447 | | WINPR_ATTR_NODISCARD |
448 | | WINPR_API void* ListDictionary_GetItemValue(wListDictionary* listDictionary, const void* key); |
449 | | |
450 | | /** @brief Set the value in the dictionary for a \b key. The entry must already exist, \b value |
451 | | * is copied if \b fnObjectNew is set |
452 | | * |
453 | | * @param listDictionary A dictionary to query, must not be \b nullptr |
454 | | * @param key A key to look for (\b fnObjectEquals of the key object is called) |
455 | | * @param value A pointer to the value to set |
456 | | * |
457 | | * @return \b TRUE for success, \b FALSE in case of failure |
458 | | */ |
459 | | WINPR_ATTR_NODISCARD |
460 | | WINPR_API BOOL ListDictionary_SetItemValue(wListDictionary* listDictionary, const void* key, |
461 | | const void* value); |
462 | | |
463 | | /** @brief Free memory allocated by a dictionary. Calls \b ListDictionary_Clear |
464 | | * |
465 | | * @param listDictionary A dictionary to query, may be \b nullptr |
466 | | */ |
467 | | WINPR_API void ListDictionary_Free(wListDictionary* listDictionary); |
468 | | |
469 | | /** @brief allocate a new dictionary |
470 | | * |
471 | | * @param synchronized Create the dictionary with automatic mutex lock |
472 | | * |
473 | | * @return A newly allocated dictionary or \b nullptr in case of failure |
474 | | */ |
475 | | WINPR_ATTR_MALLOC(ListDictionary_Free, 1) |
476 | | WINPR_API wListDictionary* ListDictionary_New(BOOL synchronized); |
477 | | |
478 | | /* System.Collections.Generic.LinkedList<T> */ |
479 | | |
480 | | typedef struct s_wLinkedList wLinkedList; |
481 | | |
482 | | /** @brief Return the current number of elements in the linked list |
483 | | * |
484 | | * @param list A pointer to the list, must not be \b nullptr |
485 | | * |
486 | | * @return the number of elements in the list |
487 | | */ |
488 | | WINPR_ATTR_NODISCARD |
489 | | WINPR_API size_t LinkedList_Count(wLinkedList* list); |
490 | | |
491 | | /** @brief Return the first element of the list, ownership stays with the list |
492 | | * |
493 | | * @param list A pointer to the list, must not be \b nullptr |
494 | | * |
495 | | * @return A pointer to the element or \b nullptr if empty |
496 | | */ |
497 | | WINPR_ATTR_NODISCARD |
498 | | WINPR_API void* LinkedList_First(wLinkedList* list); |
499 | | |
500 | | /** @brief Return the last element of the list, ownership stays with the list |
501 | | * |
502 | | * @param list A pointer to the list, must not be \b nullptr |
503 | | * |
504 | | * @return A pointer to the element or \b nullptr if empty |
505 | | */ |
506 | | WINPR_ATTR_NODISCARD |
507 | | WINPR_API void* LinkedList_Last(wLinkedList* list); |
508 | | |
509 | | /** @brief Check if the linked list contains a value |
510 | | * |
511 | | * @param list A pointer to the list, must not be \b nullptr |
512 | | * @param value A value to check for |
513 | | * |
514 | | * @return \b TRUE if found, \b FALSE otherwise |
515 | | */ |
516 | | WINPR_ATTR_NODISCARD |
517 | | WINPR_API BOOL LinkedList_Contains(wLinkedList* list, const void* value); |
518 | | |
519 | | /** @brief Remove all elements of the linked list. \b fnObjectUninit and \b fnObjectFree are |
520 | | * called for each entry |
521 | | * |
522 | | * @param list A pointer to the list, must not be \b nullptr |
523 | | * |
524 | | */ |
525 | | WINPR_API void LinkedList_Clear(wLinkedList* list); |
526 | | |
527 | | /** @brief Add a new element at the start of the linked list. \b fnObjectNew and \b fnObjectInit |
528 | | * is called for the new entry |
529 | | * |
530 | | * @param list A pointer to the list, must not be \b nullptr |
531 | | * @param value The value to add |
532 | | * |
533 | | * @return \b TRUE if successful, \b FALSE otherwise. |
534 | | */ |
535 | | WINPR_ATTR_NODISCARD |
536 | | WINPR_API BOOL LinkedList_AddFirst(wLinkedList* list, const void* value); |
537 | | |
538 | | /** @brief Add a new element at the end of the linked list. \b fnObjectNew and \b fnObjectInit |
539 | | * is called for the new entry |
540 | | * |
541 | | * @param list A pointer to the list, must not be \b nullptr |
542 | | * @param value The value to add |
543 | | * |
544 | | * @return \b TRUE if successful, \b FALSE otherwise. |
545 | | */ |
546 | | WINPR_ATTR_NODISCARD |
547 | | WINPR_API BOOL LinkedList_AddLast(wLinkedList* list, const void* value); |
548 | | |
549 | | /** @brief Remove a element identified by \b value from the linked list. \b fnObjectUninit and |
550 | | * \b fnObjectFree is called for the entry |
551 | | * |
552 | | * @param list A pointer to the list, must not be \b nullptr |
553 | | * @param value The value to remove |
554 | | * |
555 | | * @return \b TRUE if successful, \b FALSE otherwise. |
556 | | */ |
557 | | WINPR_API BOOL LinkedList_Remove(wLinkedList* list, const void* value); |
558 | | |
559 | | /** @brief Remove the first element from the linked list. \b fnObjectUninit and \b fnObjectFree |
560 | | * is called for the entry |
561 | | * |
562 | | * @param list A pointer to the list, must not be \b nullptr |
563 | | * |
564 | | */ |
565 | | WINPR_API void LinkedList_RemoveFirst(wLinkedList* list); |
566 | | |
567 | | /** @brief Remove the last element from the linked list. \b fnObjectUninit and \b fnObjectFree |
568 | | * is called for the entry |
569 | | * |
570 | | * @param list A pointer to the list, must not be \b nullptr |
571 | | * |
572 | | */ |
573 | | WINPR_API void LinkedList_RemoveLast(wLinkedList* list); |
574 | | |
575 | | /** @brief Move enumerator to the first element |
576 | | * |
577 | | * @param list A pointer to the list, must not be \b nullptr |
578 | | * |
579 | | */ |
580 | | WINPR_API void LinkedList_Enumerator_Reset(wLinkedList* list); |
581 | | |
582 | | /** @brief Return the value for the current position of the enumerator |
583 | | * |
584 | | * @param list A pointer to the list, must not be \b nullptr |
585 | | * |
586 | | * @return A pointer to the current entry or \b nullptr |
587 | | */ |
588 | | WINPR_ATTR_NODISCARD |
589 | | WINPR_API void* LinkedList_Enumerator_Current(wLinkedList* list); |
590 | | |
591 | | /** @brief Move enumerator to the next element |
592 | | * |
593 | | * @param list A pointer to the list, must not be \b nullptr |
594 | | * |
595 | | * @return \b TRUE if the move was successful, \b FALSE if not (e.g. no more entries) |
596 | | */ |
597 | | WINPR_ATTR_NODISCARD |
598 | | WINPR_API BOOL LinkedList_Enumerator_MoveNext(wLinkedList* list); |
599 | | |
600 | | /** @brief Free a linked list |
601 | | * |
602 | | * @param list A pointer to the list, may be \b nullptr |
603 | | */ |
604 | | WINPR_API void LinkedList_Free(wLinkedList* list); |
605 | | |
606 | | /** @brief Allocate a linked list |
607 | | * |
608 | | * @return A pointer to the newly allocated linked list or \b nullptr in case of failure |
609 | | */ |
610 | | WINPR_ATTR_MALLOC(LinkedList_Free, 1) |
611 | | WINPR_API wLinkedList* LinkedList_New(void); |
612 | | |
613 | | /** @brief Return the \b wObject function pointers for list elements |
614 | | * |
615 | | * @param list A pointer to the list, must not be \b nullptr |
616 | | * |
617 | | * @return A pointer to the wObject or \b nullptr in case of failure |
618 | | */ |
619 | | WINPR_ATTR_NODISCARD |
620 | | WINPR_API wObject* LinkedList_Object(wLinkedList* list); |
621 | | |
622 | | /* System.Collections.Generic.KeyValuePair<TKey,TValue> */ |
623 | | |
624 | | /* Countdown Event */ |
625 | | |
626 | | typedef struct CountdownEvent wCountdownEvent; |
627 | | |
628 | | /** @brief return the current event count of the CountdownEvent |
629 | | * |
630 | | * @param countdown A pointer to a CountdownEvent, must not be \b nullptr |
631 | | * |
632 | | * @return The current event count |
633 | | */ |
634 | | WINPR_ATTR_NODISCARD |
635 | | WINPR_API size_t CountdownEvent_CurrentCount(wCountdownEvent* countdown); |
636 | | |
637 | | /** @brief return the initial event count of the CountdownEvent |
638 | | * |
639 | | * @param countdown A pointer to a CountdownEvent, must not be \b nullptr |
640 | | * |
641 | | * @return The initial event count |
642 | | */ |
643 | | WINPR_ATTR_NODISCARD |
644 | | WINPR_API size_t CountdownEvent_InitialCount(wCountdownEvent* countdown); |
645 | | |
646 | | /** @brief return the current event state of the CountdownEvent |
647 | | * |
648 | | * @param countdown A pointer to a CountdownEvent, must not be \b nullptr |
649 | | * |
650 | | * @return \b TRUE if set, \b FALSE otherwise |
651 | | */ |
652 | | WINPR_ATTR_NODISCARD |
653 | | WINPR_API BOOL CountdownEvent_IsSet(wCountdownEvent* countdown); |
654 | | |
655 | | /** @brief return the event HANDLE of the CountdownEvent to be used by \b WaitForSingleObject or |
656 | | * \b WaitForMultipleObjects |
657 | | * |
658 | | * @param countdown A pointer to a CountdownEvent, must not be \b nullptr |
659 | | * |
660 | | * @return a \b HANDLE or \b nullptr in case of failure |
661 | | */ |
662 | | WINPR_ATTR_NODISCARD |
663 | | WINPR_API HANDLE CountdownEvent_WaitHandle(wCountdownEvent* countdown); |
664 | | |
665 | | /** @brief add \b signalCount to the current event count of the CountdownEvent |
666 | | * |
667 | | * @param countdown A pointer to a CountdownEvent, must not be \b nullptr |
668 | | * @param signalCount The amount to add to CountdownEvent |
669 | | * |
670 | | */ |
671 | | WINPR_API void CountdownEvent_AddCount(wCountdownEvent* countdown, size_t signalCount); |
672 | | |
673 | | /** @brief Increase the current event signal state of the CountdownEvent |
674 | | * |
675 | | * @param countdown A pointer to a CountdownEvent, must not be \b nullptr |
676 | | * @param signalCount The amount of signaled events to add |
677 | | * |
678 | | * @return \b TRUE if event is set, \b FALSE otherwise |
679 | | */ |
680 | | WINPR_API BOOL CountdownEvent_Signal(wCountdownEvent* countdown, size_t signalCount); |
681 | | |
682 | | /** @brief reset the CountdownEvent |
683 | | * |
684 | | * @param countdown A pointer to a CountdownEvent, must not be \b nullptr |
685 | | * |
686 | | */ |
687 | | WINPR_API void CountdownEvent_Reset(wCountdownEvent* countdown, size_t count); |
688 | | |
689 | | /** @brief Free a CountdownEvent |
690 | | * |
691 | | * @param countdown A pointer to a CountdownEvent, may be \b nullptr |
692 | | */ |
693 | | WINPR_API void CountdownEvent_Free(wCountdownEvent* countdown); |
694 | | |
695 | | /** @brief Allocate a CountdownEvent with \b initialCount |
696 | | * |
697 | | * @param initialCount The initial value of the event |
698 | | * |
699 | | * @return The newly allocated event or \b nullptr in case of failure |
700 | | */ |
701 | | WINPR_ATTR_MALLOC(CountdownEvent_Free, 1) |
702 | | WINPR_API wCountdownEvent* CountdownEvent_New(size_t initialCount); |
703 | | |
704 | | /* Hash Table */ |
705 | | |
706 | | typedef UINT32 (*HASH_TABLE_HASH_FN)(const void* key); |
707 | | |
708 | | typedef struct s_wHashTable wHashTable; |
709 | | |
710 | | typedef BOOL (*HASH_TABLE_FOREACH_FN)(const void* key, void* value, void* arg); |
711 | | |
712 | | WINPR_ATTR_NODISCARD |
713 | | WINPR_API size_t HashTable_Count(wHashTable* table); |
714 | | |
715 | | #if defined(WITH_WINPR_DEPRECATED) |
716 | | WINPR_DEPRECATED(WINPR_ATTR_NODISCARD WINPR_API int HashTable_Add(wHashTable* table, |
717 | | const void* key, |
718 | | const void* value)); |
719 | | #endif |
720 | | |
721 | | WINPR_ATTR_NODISCARD |
722 | | WINPR_API BOOL HashTable_Insert(wHashTable* table, const void* key, const void* value); |
723 | | |
724 | | WINPR_API BOOL HashTable_Remove(wHashTable* table, const void* key); |
725 | | |
726 | | WINPR_API void HashTable_Clear(wHashTable* table); |
727 | | |
728 | | WINPR_ATTR_NODISCARD |
729 | | WINPR_API BOOL HashTable_Contains(wHashTable* table, const void* key); |
730 | | |
731 | | WINPR_ATTR_NODISCARD |
732 | | WINPR_API BOOL HashTable_ContainsKey(wHashTable* table, const void* key); |
733 | | |
734 | | WINPR_ATTR_NODISCARD |
735 | | WINPR_API BOOL HashTable_ContainsValue(wHashTable* table, const void* value); |
736 | | |
737 | | WINPR_ATTR_NODISCARD |
738 | | WINPR_API void* HashTable_GetItemValue(wHashTable* table, const void* key); |
739 | | |
740 | | WINPR_ATTR_NODISCARD |
741 | | WINPR_API BOOL HashTable_SetItemValue(wHashTable* table, const void* key, const void* value); |
742 | | |
743 | | WINPR_ATTR_NODISCARD |
744 | | WINPR_API size_t HashTable_GetKeys(wHashTable* table, ULONG_PTR** ppKeys); |
745 | | |
746 | | WINPR_ATTR_NODISCARD |
747 | | WINPR_API BOOL HashTable_Foreach(wHashTable* table, HASH_TABLE_FOREACH_FN fn, VOID* arg); |
748 | | |
749 | | WINPR_ATTR_NODISCARD |
750 | | WINPR_API UINT32 HashTable_PointerHash(const void* pointer); |
751 | | |
752 | | WINPR_ATTR_NODISCARD |
753 | | WINPR_API BOOL HashTable_PointerCompare(const void* pointer1, const void* pointer2); |
754 | | |
755 | | WINPR_ATTR_NODISCARD |
756 | | WINPR_API UINT32 HashTable_StringHash(const void* key); |
757 | | |
758 | | WINPR_ATTR_NODISCARD |
759 | | WINPR_API BOOL HashTable_StringCompare(const void* string1, const void* string2); |
760 | | |
761 | | WINPR_ATTR_NODISCARD |
762 | | WINPR_API void* HashTable_StringClone(const void* str); |
763 | | |
764 | | WINPR_API void HashTable_StringFree(void* str); |
765 | | |
766 | | WINPR_API void HashTable_Free(wHashTable* table); |
767 | | |
768 | | WINPR_ATTR_MALLOC(HashTable_Free, 1) |
769 | | WINPR_API wHashTable* HashTable_New(BOOL synchronized); |
770 | | |
771 | | WINPR_API void HashTable_Lock(wHashTable* table); |
772 | | WINPR_API void HashTable_Unlock(wHashTable* table); |
773 | | |
774 | | WINPR_ATTR_NODISCARD |
775 | | WINPR_API wObject* HashTable_KeyObject(wHashTable* table); |
776 | | |
777 | | WINPR_ATTR_NODISCARD |
778 | | WINPR_API wObject* HashTable_ValueObject(wHashTable* table); |
779 | | |
780 | | WINPR_ATTR_NODISCARD |
781 | | WINPR_API BOOL HashTable_SetHashFunction(wHashTable* table, HASH_TABLE_HASH_FN fn); |
782 | | |
783 | | /* Utility function to setup hash table for strings */ |
784 | | WINPR_ATTR_NODISCARD |
785 | | WINPR_API BOOL HashTable_SetupForStringData(wHashTable* table, BOOL stringValues); |
786 | | |
787 | | /* BufferPool */ |
788 | | |
789 | | typedef struct s_wBufferPool wBufferPool; |
790 | | |
791 | | WINPR_ATTR_NODISCARD |
792 | | WINPR_API SSIZE_T BufferPool_GetPoolSize(wBufferPool* pool); |
793 | | |
794 | | WINPR_ATTR_NODISCARD |
795 | | WINPR_API SSIZE_T BufferPool_GetBufferSize(wBufferPool* pool, const void* buffer); |
796 | | |
797 | | WINPR_ATTR_NODISCARD |
798 | | WINPR_API void* BufferPool_Take(wBufferPool* pool, SSIZE_T bufferSize); |
799 | | |
800 | | WINPR_API BOOL BufferPool_Return(wBufferPool* pool, void* buffer); |
801 | | |
802 | | WINPR_API void BufferPool_Clear(wBufferPool* pool); |
803 | | |
804 | | WINPR_API void BufferPool_Free(wBufferPool* pool); |
805 | | |
806 | | WINPR_ATTR_MALLOC(BufferPool_Free, 1) |
807 | | WINPR_API wBufferPool* BufferPool_New(BOOL synchronized, SSIZE_T fixedSize, DWORD alignment); |
808 | | |
809 | | /* ObjectPool */ |
810 | | |
811 | | typedef struct s_wObjectPool wObjectPool; |
812 | | |
813 | | WINPR_ATTR_NODISCARD |
814 | | |
815 | | WINPR_API void* ObjectPool_Take(wObjectPool* pool); |
816 | | WINPR_API void ObjectPool_Return(wObjectPool* pool, void* obj); |
817 | | WINPR_API void ObjectPool_Clear(wObjectPool* pool); |
818 | | |
819 | | WINPR_ATTR_NODISCARD |
820 | | WINPR_API wObject* ObjectPool_Object(wObjectPool* pool); |
821 | | |
822 | | WINPR_API void ObjectPool_Free(wObjectPool* pool); |
823 | | |
824 | | WINPR_ATTR_MALLOC(ObjectPool_Free, 1) |
825 | | WINPR_API wObjectPool* ObjectPool_New(BOOL synchronized); |
826 | | |
827 | | /* Message Queue */ |
828 | | |
829 | | typedef struct s_wMessage wMessage; |
830 | | |
831 | | typedef void (*MESSAGE_FREE_FN)(wMessage* message); |
832 | | |
833 | | struct s_wMessage |
834 | | { |
835 | | UINT32 id; |
836 | | void* context; |
837 | | void* wParam; |
838 | | void* lParam; |
839 | | UINT64 time; |
840 | | MESSAGE_FREE_FN Free; |
841 | | }; |
842 | | |
843 | | typedef struct s_wMessageQueue wMessageQueue; |
844 | | |
845 | | #define WMQ_QUIT 0xFFFFFFFF |
846 | | |
847 | | WINPR_ATTR_NODISCARD |
848 | | WINPR_API wObject* MessageQueue_Object(wMessageQueue* queue); |
849 | | |
850 | | WINPR_ATTR_NODISCARD |
851 | | WINPR_API HANDLE MessageQueue_Event(wMessageQueue* queue); |
852 | | |
853 | | WINPR_ATTR_NODISCARD |
854 | | WINPR_API BOOL MessageQueue_Wait(wMessageQueue* queue); |
855 | | |
856 | | /** @brief return the currently used number of elements in the queue |
857 | | * |
858 | | * @param queue A pointer to the queue to query. Must not be \b nullptr |
859 | | * |
860 | | * @return The number of elements in the queue |
861 | | */ |
862 | | WINPR_ATTR_NODISCARD |
863 | | WINPR_API size_t MessageQueue_Size(wMessageQueue* queue); |
864 | | |
865 | | /** @brief return the currently allocated elements in the queue |
866 | | * |
867 | | * @param queue A pointer to the queue to query. Must not be \b nullptr |
868 | | * |
869 | | * @return The number of currently allocated elements in the queue |
870 | | */ |
871 | | WINPR_ATTR_NODISCARD |
872 | | WINPR_API size_t MessageQueue_Capacity(wMessageQueue* queue); |
873 | | |
874 | | WINPR_ATTR_NODISCARD |
875 | | WINPR_API BOOL MessageQueue_Dispatch(wMessageQueue* queue, const wMessage* message); |
876 | | |
877 | | WINPR_ATTR_NODISCARD |
878 | | WINPR_API BOOL MessageQueue_Post(wMessageQueue* queue, void* context, UINT32 type, void* wParam, |
879 | | void* lParam); |
880 | | |
881 | | WINPR_API BOOL MessageQueue_PostQuit(wMessageQueue* queue, int nExitCode); |
882 | | |
883 | | WINPR_ATTR_NODISCARD |
884 | | WINPR_API int MessageQueue_Get(wMessageQueue* queue, wMessage* message); |
885 | | |
886 | | WINPR_ATTR_NODISCARD |
887 | | WINPR_API int MessageQueue_Peek(wMessageQueue* queue, wMessage* message, BOOL remove); |
888 | | |
889 | | /*! \brief Clears all elements in a message queue. |
890 | | * |
891 | | * \note If dynamically allocated data is part of the messages, |
892 | | * a custom cleanup handler must be passed in the 'callback' |
893 | | * argument for MessageQueue_New. |
894 | | * |
895 | | * \param queue The queue to clear. |
896 | | * |
897 | | * \return 0 in case of success or a error code otherwise. |
898 | | */ |
899 | | WINPR_API int MessageQueue_Clear(wMessageQueue* queue); |
900 | | |
901 | | /*! \brief Frees resources allocated by a message queue. |
902 | | * This function will only free resources allocated |
903 | | * internally. |
904 | | * |
905 | | * \note Empty the queue before calling this function with |
906 | | * 'MessageQueue_Clear', 'MessageQueue_Get' or |
907 | | * 'MessageQueue_Peek' to free all resources allocated |
908 | | * by the message contained. |
909 | | * |
910 | | * \param queue A pointer to the queue to be freed. |
911 | | */ |
912 | | WINPR_API void MessageQueue_Free(wMessageQueue* queue); |
913 | | |
914 | | /*! \brief Creates a new message queue. |
915 | | * If 'callback' is null, no custom cleanup will be done |
916 | | * on message queue deallocation. |
917 | | * If the 'callback' argument contains valid uninit or |
918 | | * free functions those will be called by |
919 | | * 'MessageQueue_Clear'. |
920 | | * |
921 | | * \param callback a pointer to custom initialization / cleanup functions. |
922 | | * Can be nullptr if not used. |
923 | | * |
924 | | * \return A pointer to a newly allocated MessageQueue or nullptr. |
925 | | */ |
926 | | WINPR_ATTR_MALLOC(MessageQueue_Free, 1) |
927 | | WINPR_API wMessageQueue* MessageQueue_New(const wObject* callback); |
928 | | |
929 | | /* Message Pipe */ |
930 | | |
931 | | typedef struct |
932 | | { |
933 | | wMessageQueue* In; |
934 | | wMessageQueue* Out; |
935 | | } wMessagePipe; |
936 | | |
937 | | WINPR_API void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode); |
938 | | |
939 | | WINPR_API void MessagePipe_Free(wMessagePipe* pipe); |
940 | | |
941 | | WINPR_ATTR_MALLOC(MessagePipe_Free, 1) |
942 | | WINPR_API wMessagePipe* MessagePipe_New(void); |
943 | | |
944 | | /* Publisher/Subscriber Pattern */ |
945 | | |
946 | | typedef struct |
947 | | { |
948 | | DWORD Size; |
949 | | const char* Sender; |
950 | | } wEventArgs; |
951 | | |
952 | | typedef void (*pEventHandler)(void* context, const wEventArgs* e); |
953 | | |
954 | | #ifdef __cplusplus |
955 | | #define WINPR_EVENT_CAST(t, val) reinterpret_cast<t>(val) |
956 | | #else |
957 | | #define WINPR_EVENT_CAST(t, val) (t)(val) |
958 | | #endif |
959 | | |
960 | | #define MAX_EVENT_HANDLERS 32 |
961 | | |
962 | | typedef struct |
963 | | { |
964 | | const char* EventName; |
965 | | wEventArgs EventArgs; |
966 | | size_t EventHandlerCount; |
967 | | pEventHandler EventHandlers[MAX_EVENT_HANDLERS]; |
968 | | } wEventType; |
969 | | |
970 | | #define EventArgsInit(_event_args, _sender) \ |
971 | | memset(_event_args, 0, sizeof(*_event_args)); \ |
972 | | (_event_args)->e.Size = sizeof(*_event_args); \ |
973 | | (_event_args)->e.Sender = _sender |
974 | | |
975 | | #define DEFINE_EVENT_HANDLER(name) \ |
976 | | typedef void (*p##name##EventHandler)(void* context, const name##EventArgs* e) |
977 | | |
978 | | #define DEFINE_EVENT_RAISE(name) \ |
979 | | WINPR_ATTR_NODISCARD static inline int PubSub_On##name(wPubSub* pubSub, void* context, \ |
980 | | const name##EventArgs* e) \ |
981 | 0 | { \ |
982 | 0 | WINPR_ASSERT(e); \ |
983 | 0 | return PubSub_OnEvent(pubSub, #name, context, &e->e); \ |
984 | 0 | } Unexecuted instantiation: certificate.c:PubSub_OnWindowStateChange Unexecuted instantiation: certificate.c:PubSub_OnResizeWindow Unexecuted instantiation: certificate.c:PubSub_OnPanningChange Unexecuted instantiation: certificate.c:PubSub_OnZoomingChange Unexecuted instantiation: certificate.c:PubSub_OnLocalResizeWindow Unexecuted instantiation: certificate.c:PubSub_OnEmbedWindow Unexecuted instantiation: certificate.c:PubSub_OnErrorInfo Unexecuted instantiation: certificate.c:PubSub_OnActivated Unexecuted instantiation: certificate.c:PubSub_OnConnectionStateChange Unexecuted instantiation: certificate.c:PubSub_OnTerminate Unexecuted instantiation: certificate.c:PubSub_OnConnectionResult Unexecuted instantiation: certificate.c:PubSub_OnChannelConnected Unexecuted instantiation: certificate.c:PubSub_OnChannelDisconnected Unexecuted instantiation: certificate.c:PubSub_OnChannelAttached Unexecuted instantiation: certificate.c:PubSub_OnChannelDetached Unexecuted instantiation: certificate.c:PubSub_OnMouseEvent Unexecuted instantiation: certificate.c:PubSub_OnMouseEventEx Unexecuted instantiation: certificate.c:PubSub_OnTimer Unexecuted instantiation: certificate.c:PubSub_OnGraphicsReset Unexecuted instantiation: certificate.c:PubSub_OnUserNotification Unexecuted instantiation: crypto.c:PubSub_OnWindowStateChange Unexecuted instantiation: crypto.c:PubSub_OnResizeWindow Unexecuted instantiation: crypto.c:PubSub_OnPanningChange Unexecuted instantiation: crypto.c:PubSub_OnZoomingChange Unexecuted instantiation: crypto.c:PubSub_OnLocalResizeWindow Unexecuted instantiation: crypto.c:PubSub_OnEmbedWindow Unexecuted instantiation: crypto.c:PubSub_OnErrorInfo Unexecuted instantiation: crypto.c:PubSub_OnActivated Unexecuted instantiation: crypto.c:PubSub_OnConnectionStateChange Unexecuted instantiation: crypto.c:PubSub_OnTerminate Unexecuted instantiation: crypto.c:PubSub_OnConnectionResult Unexecuted instantiation: crypto.c:PubSub_OnChannelConnected Unexecuted instantiation: crypto.c:PubSub_OnChannelDisconnected Unexecuted instantiation: crypto.c:PubSub_OnChannelAttached Unexecuted instantiation: crypto.c:PubSub_OnChannelDetached Unexecuted instantiation: crypto.c:PubSub_OnMouseEvent Unexecuted instantiation: crypto.c:PubSub_OnMouseEventEx Unexecuted instantiation: crypto.c:PubSub_OnTimer Unexecuted instantiation: crypto.c:PubSub_OnGraphicsReset Unexecuted instantiation: crypto.c:PubSub_OnUserNotification Unexecuted instantiation: cert_common.c:PubSub_OnWindowStateChange Unexecuted instantiation: cert_common.c:PubSub_OnResizeWindow Unexecuted instantiation: cert_common.c:PubSub_OnPanningChange Unexecuted instantiation: cert_common.c:PubSub_OnZoomingChange Unexecuted instantiation: cert_common.c:PubSub_OnLocalResizeWindow Unexecuted instantiation: cert_common.c:PubSub_OnEmbedWindow Unexecuted instantiation: cert_common.c:PubSub_OnErrorInfo Unexecuted instantiation: cert_common.c:PubSub_OnActivated Unexecuted instantiation: cert_common.c:PubSub_OnConnectionStateChange Unexecuted instantiation: cert_common.c:PubSub_OnTerminate Unexecuted instantiation: cert_common.c:PubSub_OnConnectionResult Unexecuted instantiation: cert_common.c:PubSub_OnChannelConnected Unexecuted instantiation: cert_common.c:PubSub_OnChannelDisconnected Unexecuted instantiation: cert_common.c:PubSub_OnChannelAttached Unexecuted instantiation: cert_common.c:PubSub_OnChannelDetached Unexecuted instantiation: cert_common.c:PubSub_OnMouseEvent Unexecuted instantiation: cert_common.c:PubSub_OnMouseEventEx Unexecuted instantiation: cert_common.c:PubSub_OnTimer Unexecuted instantiation: cert_common.c:PubSub_OnGraphicsReset Unexecuted instantiation: cert_common.c:PubSub_OnUserNotification Unexecuted instantiation: privatekey.c:PubSub_OnWindowStateChange Unexecuted instantiation: privatekey.c:PubSub_OnResizeWindow Unexecuted instantiation: privatekey.c:PubSub_OnPanningChange Unexecuted instantiation: privatekey.c:PubSub_OnZoomingChange Unexecuted instantiation: privatekey.c:PubSub_OnLocalResizeWindow Unexecuted instantiation: privatekey.c:PubSub_OnEmbedWindow Unexecuted instantiation: privatekey.c:PubSub_OnErrorInfo Unexecuted instantiation: privatekey.c:PubSub_OnActivated Unexecuted instantiation: privatekey.c:PubSub_OnConnectionStateChange Unexecuted instantiation: privatekey.c:PubSub_OnTerminate Unexecuted instantiation: privatekey.c:PubSub_OnConnectionResult Unexecuted instantiation: privatekey.c:PubSub_OnChannelConnected Unexecuted instantiation: privatekey.c:PubSub_OnChannelDisconnected Unexecuted instantiation: privatekey.c:PubSub_OnChannelAttached Unexecuted instantiation: privatekey.c:PubSub_OnChannelDetached Unexecuted instantiation: privatekey.c:PubSub_OnMouseEvent Unexecuted instantiation: privatekey.c:PubSub_OnMouseEventEx Unexecuted instantiation: privatekey.c:PubSub_OnTimer Unexecuted instantiation: privatekey.c:PubSub_OnGraphicsReset Unexecuted instantiation: privatekey.c:PubSub_OnUserNotification |
985 | | |
986 | | #define DEFINE_EVENT_SUBSCRIBE(name) \ |
987 | | WINPR_ATTR_NODISCARD static inline int PubSub_Subscribe##name( \ |
988 | | wPubSub* pubSub, p##name##EventHandler EventHandler) \ |
989 | 0 | { \ |
990 | 0 | return PubSub_Subscribe(pubSub, #name, EventHandler); \ |
991 | 0 | } Unexecuted instantiation: certificate.c:PubSub_SubscribeWindowStateChange Unexecuted instantiation: certificate.c:PubSub_SubscribeResizeWindow Unexecuted instantiation: certificate.c:PubSub_SubscribePanningChange Unexecuted instantiation: certificate.c:PubSub_SubscribeZoomingChange Unexecuted instantiation: certificate.c:PubSub_SubscribeLocalResizeWindow Unexecuted instantiation: certificate.c:PubSub_SubscribeEmbedWindow Unexecuted instantiation: certificate.c:PubSub_SubscribeErrorInfo Unexecuted instantiation: certificate.c:PubSub_SubscribeActivated Unexecuted instantiation: certificate.c:PubSub_SubscribeConnectionStateChange Unexecuted instantiation: certificate.c:PubSub_SubscribeTerminate Unexecuted instantiation: certificate.c:PubSub_SubscribeConnectionResult Unexecuted instantiation: certificate.c:PubSub_SubscribeChannelConnected Unexecuted instantiation: certificate.c:PubSub_SubscribeChannelDisconnected Unexecuted instantiation: certificate.c:PubSub_SubscribeChannelAttached Unexecuted instantiation: certificate.c:PubSub_SubscribeChannelDetached Unexecuted instantiation: certificate.c:PubSub_SubscribeMouseEvent Unexecuted instantiation: certificate.c:PubSub_SubscribeMouseEventEx Unexecuted instantiation: certificate.c:PubSub_SubscribeTimer Unexecuted instantiation: certificate.c:PubSub_SubscribeGraphicsReset Unexecuted instantiation: certificate.c:PubSub_SubscribeUserNotification Unexecuted instantiation: crypto.c:PubSub_SubscribeWindowStateChange Unexecuted instantiation: crypto.c:PubSub_SubscribeResizeWindow Unexecuted instantiation: crypto.c:PubSub_SubscribePanningChange Unexecuted instantiation: crypto.c:PubSub_SubscribeZoomingChange Unexecuted instantiation: crypto.c:PubSub_SubscribeLocalResizeWindow Unexecuted instantiation: crypto.c:PubSub_SubscribeEmbedWindow Unexecuted instantiation: crypto.c:PubSub_SubscribeErrorInfo Unexecuted instantiation: crypto.c:PubSub_SubscribeActivated Unexecuted instantiation: crypto.c:PubSub_SubscribeConnectionStateChange Unexecuted instantiation: crypto.c:PubSub_SubscribeTerminate Unexecuted instantiation: crypto.c:PubSub_SubscribeConnectionResult Unexecuted instantiation: crypto.c:PubSub_SubscribeChannelConnected Unexecuted instantiation: crypto.c:PubSub_SubscribeChannelDisconnected Unexecuted instantiation: crypto.c:PubSub_SubscribeChannelAttached Unexecuted instantiation: crypto.c:PubSub_SubscribeChannelDetached Unexecuted instantiation: crypto.c:PubSub_SubscribeMouseEvent Unexecuted instantiation: crypto.c:PubSub_SubscribeMouseEventEx Unexecuted instantiation: crypto.c:PubSub_SubscribeTimer Unexecuted instantiation: crypto.c:PubSub_SubscribeGraphicsReset Unexecuted instantiation: crypto.c:PubSub_SubscribeUserNotification Unexecuted instantiation: cert_common.c:PubSub_SubscribeWindowStateChange Unexecuted instantiation: cert_common.c:PubSub_SubscribeResizeWindow Unexecuted instantiation: cert_common.c:PubSub_SubscribePanningChange Unexecuted instantiation: cert_common.c:PubSub_SubscribeZoomingChange Unexecuted instantiation: cert_common.c:PubSub_SubscribeLocalResizeWindow Unexecuted instantiation: cert_common.c:PubSub_SubscribeEmbedWindow Unexecuted instantiation: cert_common.c:PubSub_SubscribeErrorInfo Unexecuted instantiation: cert_common.c:PubSub_SubscribeActivated Unexecuted instantiation: cert_common.c:PubSub_SubscribeConnectionStateChange Unexecuted instantiation: cert_common.c:PubSub_SubscribeTerminate Unexecuted instantiation: cert_common.c:PubSub_SubscribeConnectionResult Unexecuted instantiation: cert_common.c:PubSub_SubscribeChannelConnected Unexecuted instantiation: cert_common.c:PubSub_SubscribeChannelDisconnected Unexecuted instantiation: cert_common.c:PubSub_SubscribeChannelAttached Unexecuted instantiation: cert_common.c:PubSub_SubscribeChannelDetached Unexecuted instantiation: cert_common.c:PubSub_SubscribeMouseEvent Unexecuted instantiation: cert_common.c:PubSub_SubscribeMouseEventEx Unexecuted instantiation: cert_common.c:PubSub_SubscribeTimer Unexecuted instantiation: cert_common.c:PubSub_SubscribeGraphicsReset Unexecuted instantiation: cert_common.c:PubSub_SubscribeUserNotification Unexecuted instantiation: privatekey.c:PubSub_SubscribeWindowStateChange Unexecuted instantiation: privatekey.c:PubSub_SubscribeResizeWindow Unexecuted instantiation: privatekey.c:PubSub_SubscribePanningChange Unexecuted instantiation: privatekey.c:PubSub_SubscribeZoomingChange Unexecuted instantiation: privatekey.c:PubSub_SubscribeLocalResizeWindow Unexecuted instantiation: privatekey.c:PubSub_SubscribeEmbedWindow Unexecuted instantiation: privatekey.c:PubSub_SubscribeErrorInfo Unexecuted instantiation: privatekey.c:PubSub_SubscribeActivated Unexecuted instantiation: privatekey.c:PubSub_SubscribeConnectionStateChange Unexecuted instantiation: privatekey.c:PubSub_SubscribeTerminate Unexecuted instantiation: privatekey.c:PubSub_SubscribeConnectionResult Unexecuted instantiation: privatekey.c:PubSub_SubscribeChannelConnected Unexecuted instantiation: privatekey.c:PubSub_SubscribeChannelDisconnected Unexecuted instantiation: privatekey.c:PubSub_SubscribeChannelAttached Unexecuted instantiation: privatekey.c:PubSub_SubscribeChannelDetached Unexecuted instantiation: privatekey.c:PubSub_SubscribeMouseEvent Unexecuted instantiation: privatekey.c:PubSub_SubscribeMouseEventEx Unexecuted instantiation: privatekey.c:PubSub_SubscribeTimer Unexecuted instantiation: privatekey.c:PubSub_SubscribeGraphicsReset Unexecuted instantiation: privatekey.c:PubSub_SubscribeUserNotification |
992 | | |
993 | | #define DEFINE_EVENT_UNSUBSCRIBE(name) \ |
994 | | static inline int PubSub_Unsubscribe##name(wPubSub* pubSub, \ |
995 | | p##name##EventHandler EventHandler) \ |
996 | 0 | { \ |
997 | 0 | return PubSub_Unsubscribe(pubSub, #name, EventHandler); \ |
998 | 0 | } Unexecuted instantiation: certificate.c:PubSub_UnsubscribeWindowStateChange Unexecuted instantiation: certificate.c:PubSub_UnsubscribeResizeWindow Unexecuted instantiation: certificate.c:PubSub_UnsubscribePanningChange Unexecuted instantiation: certificate.c:PubSub_UnsubscribeZoomingChange Unexecuted instantiation: certificate.c:PubSub_UnsubscribeLocalResizeWindow Unexecuted instantiation: certificate.c:PubSub_UnsubscribeEmbedWindow Unexecuted instantiation: certificate.c:PubSub_UnsubscribeErrorInfo Unexecuted instantiation: certificate.c:PubSub_UnsubscribeActivated Unexecuted instantiation: certificate.c:PubSub_UnsubscribeConnectionStateChange Unexecuted instantiation: certificate.c:PubSub_UnsubscribeTerminate Unexecuted instantiation: certificate.c:PubSub_UnsubscribeConnectionResult Unexecuted instantiation: certificate.c:PubSub_UnsubscribeChannelConnected Unexecuted instantiation: certificate.c:PubSub_UnsubscribeChannelDisconnected Unexecuted instantiation: certificate.c:PubSub_UnsubscribeChannelAttached Unexecuted instantiation: certificate.c:PubSub_UnsubscribeChannelDetached Unexecuted instantiation: certificate.c:PubSub_UnsubscribeMouseEvent Unexecuted instantiation: certificate.c:PubSub_UnsubscribeMouseEventEx Unexecuted instantiation: certificate.c:PubSub_UnsubscribeTimer Unexecuted instantiation: certificate.c:PubSub_UnsubscribeGraphicsReset Unexecuted instantiation: certificate.c:PubSub_UnsubscribeUserNotification Unexecuted instantiation: crypto.c:PubSub_UnsubscribeWindowStateChange Unexecuted instantiation: crypto.c:PubSub_UnsubscribeResizeWindow Unexecuted instantiation: crypto.c:PubSub_UnsubscribePanningChange Unexecuted instantiation: crypto.c:PubSub_UnsubscribeZoomingChange Unexecuted instantiation: crypto.c:PubSub_UnsubscribeLocalResizeWindow Unexecuted instantiation: crypto.c:PubSub_UnsubscribeEmbedWindow Unexecuted instantiation: crypto.c:PubSub_UnsubscribeErrorInfo Unexecuted instantiation: crypto.c:PubSub_UnsubscribeActivated Unexecuted instantiation: crypto.c:PubSub_UnsubscribeConnectionStateChange Unexecuted instantiation: crypto.c:PubSub_UnsubscribeTerminate Unexecuted instantiation: crypto.c:PubSub_UnsubscribeConnectionResult Unexecuted instantiation: crypto.c:PubSub_UnsubscribeChannelConnected Unexecuted instantiation: crypto.c:PubSub_UnsubscribeChannelDisconnected Unexecuted instantiation: crypto.c:PubSub_UnsubscribeChannelAttached Unexecuted instantiation: crypto.c:PubSub_UnsubscribeChannelDetached Unexecuted instantiation: crypto.c:PubSub_UnsubscribeMouseEvent Unexecuted instantiation: crypto.c:PubSub_UnsubscribeMouseEventEx Unexecuted instantiation: crypto.c:PubSub_UnsubscribeTimer Unexecuted instantiation: crypto.c:PubSub_UnsubscribeGraphicsReset Unexecuted instantiation: crypto.c:PubSub_UnsubscribeUserNotification Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeWindowStateChange Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeResizeWindow Unexecuted instantiation: cert_common.c:PubSub_UnsubscribePanningChange Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeZoomingChange Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeLocalResizeWindow Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeEmbedWindow Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeErrorInfo Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeActivated Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeConnectionStateChange Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeTerminate Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeConnectionResult Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeChannelConnected Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeChannelDisconnected Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeChannelAttached Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeChannelDetached Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeMouseEvent Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeMouseEventEx Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeTimer Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeGraphicsReset Unexecuted instantiation: cert_common.c:PubSub_UnsubscribeUserNotification Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeWindowStateChange Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeResizeWindow Unexecuted instantiation: privatekey.c:PubSub_UnsubscribePanningChange Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeZoomingChange Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeLocalResizeWindow Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeEmbedWindow Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeErrorInfo Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeActivated Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeConnectionStateChange Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeTerminate Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeConnectionResult Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeChannelConnected Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeChannelDisconnected Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeChannelAttached Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeChannelDetached Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeMouseEvent Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeMouseEventEx Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeTimer Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeGraphicsReset Unexecuted instantiation: privatekey.c:PubSub_UnsubscribeUserNotification |
999 | | |
1000 | | #define DEFINE_EVENT_BEGIN(name) \ |
1001 | | typedef struct \ |
1002 | | { \ |
1003 | | wEventArgs e; |
1004 | | |
1005 | | #define DEFINE_EVENT_END(name) \ |
1006 | | } \ |
1007 | | name##EventArgs; \ |
1008 | | DEFINE_EVENT_HANDLER(name); \ |
1009 | | DEFINE_EVENT_RAISE(name) \ |
1010 | | DEFINE_EVENT_SUBSCRIBE(name) \ |
1011 | | DEFINE_EVENT_UNSUBSCRIBE(name) |
1012 | | |
1013 | | #define DEFINE_EVENT_ENTRY(name) \ |
1014 | | { \ |
1015 | | #name, { sizeof(name##EventArgs), nullptr }, 0, \ |
1016 | | { \ |
1017 | | nullptr \ |
1018 | | } \ |
1019 | | } |
1020 | | |
1021 | | typedef struct s_wPubSub wPubSub; |
1022 | | |
1023 | | WINPR_API void PubSub_Lock(wPubSub* pubSub); |
1024 | | WINPR_API void PubSub_Unlock(wPubSub* pubSub); |
1025 | | |
1026 | | WINPR_ATTR_NODISCARD |
1027 | | WINPR_API wEventType* PubSub_GetEventTypes(wPubSub* pubSub, size_t* count); |
1028 | | |
1029 | | WINPR_API void PubSub_AddEventTypes(wPubSub* pubSub, wEventType* events, size_t count); |
1030 | | |
1031 | | WINPR_ATTR_NODISCARD |
1032 | | WINPR_API wEventType* PubSub_FindEventType(wPubSub* pubSub, const char* EventName); |
1033 | | |
1034 | | WINPR_ATTR_NODISCARD |
1035 | | WINPR_API int PubSub_Subscribe(wPubSub* pubSub, const char* EventName, ...); |
1036 | | |
1037 | | WINPR_API int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, ...); |
1038 | | |
1039 | | WINPR_ATTR_NODISCARD |
1040 | | WINPR_API int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, |
1041 | | const wEventArgs* e); |
1042 | | |
1043 | | WINPR_API void PubSub_Free(wPubSub* pubSub); |
1044 | | |
1045 | | WINPR_ATTR_MALLOC(PubSub_Free, 1) |
1046 | | WINPR_API wPubSub* PubSub_New(BOOL synchronized); |
1047 | | |
1048 | | #ifdef __cplusplus |
1049 | | } |
1050 | | #endif |
1051 | | |
1052 | | #endif /* WINPR_COLLECTIONS_H */ |