/usr/include/winpr2/winpr/collections.h is in libwinpr2-dev 2.0.0~git20170725.1.1648deb+dfsg1-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | /**
* WinPR: Windows Portable Runtime
* Collections
*
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef WINPR_COLLECTIONS_H
#define WINPR_COLLECTIONS_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/winpr.h>
#include <winpr/wtypes.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <winpr/stream.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void* (*OBJECT_NEW_FN)(void);
typedef void (*OBJECT_INIT_FN)(void* obj);
typedef void (*OBJECT_UNINIT_FN)(void* obj);
typedef void (*OBJECT_FREE_FN)(void* obj);
typedef BOOL (*OBJECT_EQUALS_FN)(void* objA, void* objB);
struct _wObject
{
OBJECT_NEW_FN fnObjectNew;
OBJECT_INIT_FN fnObjectInit;
OBJECT_UNINIT_FN fnObjectUninit;
OBJECT_FREE_FN fnObjectFree;
OBJECT_EQUALS_FN fnObjectEquals;
};
typedef struct _wObject wObject;
/* System.Collections.Queue */
struct _wQueue
{
int capacity;
int growthFactor;
BOOL synchronized;
int head;
int tail;
int size;
void** array;
CRITICAL_SECTION lock;
HANDLE event;
wObject object;
};
typedef struct _wQueue wQueue;
WINPR_API int Queue_Count(wQueue* queue);
WINPR_API void Queue_Lock(wQueue* queue);
WINPR_API void Queue_Unlock(wQueue* queue);
WINPR_API HANDLE Queue_Event(wQueue* queue);
#define Queue_Object(_queue) (&_queue->object)
WINPR_API void Queue_Clear(wQueue* queue);
WINPR_API BOOL Queue_Contains(wQueue* queue, void* obj);
WINPR_API BOOL Queue_Enqueue(wQueue* queue, void* obj);
WINPR_API void* Queue_Dequeue(wQueue* queue);
WINPR_API void* Queue_Peek(wQueue* queue);
WINPR_API wQueue* Queue_New(BOOL synchronized, int capacity, int growthFactor);
WINPR_API void Queue_Free(wQueue* queue);
/* System.Collections.Stack */
struct _wStack
{
int size;
int capacity;
void** array;
CRITICAL_SECTION lock;
BOOL synchronized;
wObject object;
};
typedef struct _wStack wStack;
WINPR_API int Stack_Count(wStack* stack);
WINPR_API BOOL Stack_IsSynchronized(wStack* stack);
#define Stack_Object(_stack) (&_stack->object)
WINPR_API void Stack_Clear(wStack* stack);
WINPR_API BOOL Stack_Contains(wStack* stack, void* obj);
WINPR_API void Stack_Push(wStack* stack, void* obj);
WINPR_API void* Stack_Pop(wStack* stack);
WINPR_API void* Stack_Peek(wStack* stack);
WINPR_API wStack* Stack_New(BOOL synchronized);
WINPR_API void Stack_Free(wStack* stack);
/* System.Collections.ArrayList */
struct _wArrayList
{
int capacity;
int growthFactor;
BOOL synchronized;
int size;
void** array;
CRITICAL_SECTION lock;
wObject object;
};
typedef struct _wArrayList wArrayList;
WINPR_API int ArrayList_Capacity(wArrayList* arrayList);
WINPR_API int ArrayList_Count(wArrayList* arrayList);
WINPR_API int ArrayList_Items(wArrayList* arrayList, ULONG_PTR** ppItems);
WINPR_API BOOL ArrayList_IsFixedSized(wArrayList* arrayList);
WINPR_API BOOL ArrayList_IsReadOnly(wArrayList* arrayList);
WINPR_API BOOL ArrayList_IsSynchronized(wArrayList* arrayList);
WINPR_API void ArrayList_Lock(wArrayList* arrayList);
WINPR_API void ArrayList_Unlock(wArrayList* arrayList);
WINPR_API void* ArrayList_GetItem(wArrayList* arrayList, int index);
WINPR_API void ArrayList_SetItem(wArrayList* arrayList, int index, void* obj);
#define ArrayList_Object(_arrayList) (&_arrayList->object)
WINPR_API void ArrayList_Clear(wArrayList* arrayList);
WINPR_API BOOL ArrayList_Contains(wArrayList* arrayList, void* obj);
WINPR_API int ArrayList_Add(wArrayList* arrayList, void* obj);
WINPR_API BOOL ArrayList_Insert(wArrayList* arrayList, int index, void* obj);
WINPR_API BOOL ArrayList_Remove(wArrayList* arrayList, void* obj);
WINPR_API BOOL ArrayList_RemoveAt(wArrayList* arrayList, int index);
WINPR_API int ArrayList_IndexOf(wArrayList* arrayList, void* obj, int startIndex, int count);
WINPR_API int ArrayList_LastIndexOf(wArrayList* arrayList, void* obj, int startIndex, int count);
WINPR_API wArrayList* ArrayList_New(BOOL synchronized);
WINPR_API void ArrayList_Free(wArrayList* arrayList);
/* System.Collections.DictionaryBase */
struct _wDictionary
{
BOOL synchronized;
CRITICAL_SECTION lock;
};
typedef struct _wDictionary wDictionary;
/* System.Collections.Specialized.ListDictionary */
typedef struct _wListDictionaryItem wListDictionaryItem;
struct _wListDictionaryItem
{
void* key;
void* value;
wListDictionaryItem* next;
};
struct _wListDictionary
{
BOOL synchronized;
CRITICAL_SECTION lock;
wListDictionaryItem* head;
wObject objectKey;
wObject objectValue;
};
typedef struct _wListDictionary wListDictionary;
#define ListDictionary_KeyObject(_dictionary) (&_dictionary->objectKey)
#define ListDictionary_ValueObject(_dictionary) (&_dictionary->objectValue)
WINPR_API int ListDictionary_Count(wListDictionary* listDictionary);
WINPR_API void ListDictionary_Lock(wListDictionary* listDictionary);
WINPR_API void ListDictionary_Unlock(wListDictionary* listDictionary);
WINPR_API BOOL ListDictionary_Add(wListDictionary* listDictionary, void* key, void* value);
WINPR_API void* ListDictionary_Remove(wListDictionary* listDictionary, void* key);
WINPR_API void* ListDictionary_Remove_Head(wListDictionary* listDictionary);
WINPR_API void ListDictionary_Clear(wListDictionary* listDictionary);
WINPR_API BOOL ListDictionary_Contains(wListDictionary* listDictionary, void* key);
WINPR_API int ListDictionary_GetKeys(wListDictionary* listDictionary, ULONG_PTR** ppKeys);
WINPR_API void* ListDictionary_GetItemValue(wListDictionary* listDictionary, void* key);
WINPR_API BOOL ListDictionary_SetItemValue(wListDictionary* listDictionary, void* key, void* value);
WINPR_API wListDictionary* ListDictionary_New(BOOL synchronized);
WINPR_API void ListDictionary_Free(wListDictionary* listDictionary);
/* System.Collections.Generic.LinkedList<T> */
typedef struct _wLinkedListItem wLinkedListNode;
struct _wLinkedListItem
{
void* value;
wLinkedListNode* prev;
wLinkedListNode* next;
};
struct _wLinkedList
{
int count;
int initial;
wLinkedListNode* head;
wLinkedListNode* tail;
wLinkedListNode* current;
};
typedef struct _wLinkedList wLinkedList;
WINPR_API int LinkedList_Count(wLinkedList* list);
WINPR_API void* LinkedList_First(wLinkedList* list);
WINPR_API void* LinkedList_Last(wLinkedList* list);
WINPR_API BOOL LinkedList_Contains(wLinkedList* list, void* value);
WINPR_API void LinkedList_Clear(wLinkedList* list);
WINPR_API BOOL LinkedList_AddFirst(wLinkedList* list, void* value);
WINPR_API BOOL LinkedList_AddLast(wLinkedList* list, void* value);
WINPR_API BOOL LinkedList_Remove(wLinkedList* list, void* value);
WINPR_API void LinkedList_RemoveFirst(wLinkedList* list);
WINPR_API void LinkedList_RemoveLast(wLinkedList* list);
WINPR_API void LinkedList_Enumerator_Reset(wLinkedList* list);
WINPR_API void* LinkedList_Enumerator_Current(wLinkedList* list);
WINPR_API BOOL LinkedList_Enumerator_MoveNext(wLinkedList* list);
WINPR_API wLinkedList* LinkedList_New(void);
WINPR_API void LinkedList_Free(wLinkedList* list);
/* System.Collections.Generic.KeyValuePair<TKey,TValue> */
typedef struct _wKeyValuePair wKeyValuePair;
struct _wKeyValuePair
{
void* key;
void* value;
wKeyValuePair* next;
};
/* Reference Table */
struct _wReference
{
UINT32 Count;
void* Pointer;
};
typedef struct _wReference wReference;
typedef int (*REFERENCE_FREE)(void* context, void* ptr);
struct _wReferenceTable
{
UINT32 size;
CRITICAL_SECTION lock;
void* context;
BOOL synchronized;
wReference* array;
REFERENCE_FREE ReferenceFree;
};
typedef struct _wReferenceTable wReferenceTable;
WINPR_API UINT32 ReferenceTable_Add(wReferenceTable* referenceTable, void* ptr);
WINPR_API UINT32 ReferenceTable_Release(wReferenceTable* referenceTable, void* ptr);
WINPR_API wReferenceTable* ReferenceTable_New(BOOL synchronized, void* context, REFERENCE_FREE ReferenceFree);
WINPR_API void ReferenceTable_Free(wReferenceTable* referenceTable);
/* Countdown Event */
struct _wCountdownEvent
{
DWORD count;
CRITICAL_SECTION lock;
HANDLE event;
DWORD initialCount;
};
typedef struct _wCountdownEvent wCountdownEvent;
WINPR_API DWORD CountdownEvent_CurrentCount(wCountdownEvent* countdown);
WINPR_API DWORD CountdownEvent_InitialCount(wCountdownEvent* countdown);
WINPR_API BOOL CountdownEvent_IsSet(wCountdownEvent* countdown);
WINPR_API HANDLE CountdownEvent_WaitHandle(wCountdownEvent* countdown);
WINPR_API void CountdownEvent_AddCount(wCountdownEvent* countdown, DWORD signalCount);
WINPR_API BOOL CountdownEvent_Signal(wCountdownEvent* countdown, DWORD signalCount);
WINPR_API void CountdownEvent_Reset(wCountdownEvent* countdown, DWORD count);
WINPR_API wCountdownEvent* CountdownEvent_New(DWORD initialCount);
WINPR_API void CountdownEvent_Free(wCountdownEvent* countdown);
/* Hash Table */
typedef UINT32 (*HASH_TABLE_HASH_FN)(void* key);
typedef BOOL (*HASH_TABLE_KEY_COMPARE_FN)(void* key1, void* key2);
typedef BOOL (*HASH_TABLE_VALUE_COMPARE_FN)(void* value1, void* value2);
typedef void* (*HASH_TABLE_KEY_CLONE_FN)(void* key);
typedef void* (*HASH_TABLE_VALUE_CLONE_FN)(void* value);
typedef void (*HASH_TABLE_KEY_FREE_FN)(void* key);
typedef void (*HASH_TABLE_VALUE_FREE_FN)(void* value);
struct _wHashTable
{
BOOL synchronized;
CRITICAL_SECTION lock;
int numOfBuckets;
int numOfElements;
float idealRatio;
float lowerRehashThreshold;
float upperRehashThreshold;
wKeyValuePair** bucketArray;
HASH_TABLE_HASH_FN hash;
HASH_TABLE_KEY_COMPARE_FN keyCompare;
HASH_TABLE_VALUE_COMPARE_FN valueCompare;
HASH_TABLE_KEY_CLONE_FN keyClone;
HASH_TABLE_VALUE_CLONE_FN valueClone;
HASH_TABLE_KEY_FREE_FN keyFree;
HASH_TABLE_VALUE_FREE_FN valueFree;
};
typedef struct _wHashTable wHashTable;
WINPR_API int HashTable_Count(wHashTable* table);
WINPR_API int HashTable_Add(wHashTable* table, void* key, void* value);
WINPR_API BOOL HashTable_Remove(wHashTable* table, void* key);
WINPR_API void HashTable_Clear(wHashTable* table);
WINPR_API BOOL HashTable_Contains(wHashTable* table, void* key);
WINPR_API BOOL HashTable_ContainsKey(wHashTable* table, void* key);
WINPR_API BOOL HashTable_ContainsValue(wHashTable* table, void* value);
WINPR_API void* HashTable_GetItemValue(wHashTable* table, void* key);
WINPR_API BOOL HashTable_SetItemValue(wHashTable* table, void* key, void* value);
WINPR_API int HashTable_GetKeys(wHashTable* table, ULONG_PTR** ppKeys);
WINPR_API UINT32 HashTable_PointerHash(void* pointer);
WINPR_API BOOL HashTable_PointerCompare(void* pointer1, void* pointer2);
WINPR_API UINT32 HashTable_StringHash(void* key);
WINPR_API BOOL HashTable_StringCompare(void* string1, void* string2);
WINPR_API void* HashTable_StringClone(void* str);
WINPR_API void HashTable_StringFree(void* str);
WINPR_API wHashTable* HashTable_New(BOOL synchronized);
WINPR_API void HashTable_Free(wHashTable* table);
/* BufferPool */
struct _wBufferPoolItem
{
int size;
void* buffer;
};
typedef struct _wBufferPoolItem wBufferPoolItem;
struct _wBufferPool
{
int fixedSize;
DWORD alignment;
BOOL synchronized;
CRITICAL_SECTION lock;
int size;
int capacity;
void** array;
int aSize;
int aCapacity;
wBufferPoolItem* aArray;
int uSize;
int uCapacity;
wBufferPoolItem* uArray;
};
typedef struct _wBufferPool wBufferPool;
WINPR_API int BufferPool_GetPoolSize(wBufferPool* pool);
WINPR_API int BufferPool_GetBufferSize(wBufferPool* pool, void* buffer);
WINPR_API void* BufferPool_Take(wBufferPool* pool, int bufferSize);
WINPR_API BOOL BufferPool_Return(wBufferPool* pool, void* buffer);
WINPR_API void BufferPool_Clear(wBufferPool* pool);
WINPR_API wBufferPool* BufferPool_New(BOOL synchronized, int fixedSize, DWORD alignment);
WINPR_API void BufferPool_Free(wBufferPool* pool);
/* ObjectPool */
struct _wObjectPool
{
int size;
int capacity;
void** array;
CRITICAL_SECTION lock;
wObject object;
BOOL synchronized;
};
typedef struct _wObjectPool wObjectPool;
WINPR_API void* ObjectPool_Take(wObjectPool* pool);
WINPR_API void ObjectPool_Return(wObjectPool* pool, void* obj);
WINPR_API void ObjectPool_Clear(wObjectPool* pool);
#define ObjectPool_Object(_pool) (&_pool->object)
WINPR_API wObjectPool* ObjectPool_New(BOOL synchronized);
WINPR_API void ObjectPool_Free(wObjectPool* pool);
/* Message Queue */
typedef struct _wMessage wMessage;
typedef void (*MESSAGE_FREE_FN)(wMessage* message);
struct _wMessage
{
UINT32 id;
void* context;
void* wParam;
void* lParam;
UINT64 time;
MESSAGE_FREE_FN Free;
};
struct _wMessageQueue
{
int head;
int tail;
int size;
int capacity;
wMessage* array;
CRITICAL_SECTION lock;
HANDLE event;
wObject object;
};
typedef struct _wMessageQueue wMessageQueue;
#define WMQ_QUIT 0xFFFFFFFF
WINPR_API HANDLE MessageQueue_Event(wMessageQueue* queue);
WINPR_API BOOL MessageQueue_Wait(wMessageQueue* queue);
WINPR_API int MessageQueue_Size(wMessageQueue* queue);
WINPR_API BOOL MessageQueue_Dispatch(wMessageQueue* queue, wMessage* message);
WINPR_API BOOL MessageQueue_Post(wMessageQueue* queue, void* context, UINT32 type, void* wParam, void* lParam);
WINPR_API BOOL MessageQueue_PostQuit(wMessageQueue* queue, int nExitCode);
WINPR_API int MessageQueue_Get(wMessageQueue* queue, wMessage* message);
WINPR_API int MessageQueue_Peek(wMessageQueue* queue, wMessage* message, BOOL remove);
/*! \brief Clears all elements in a message queue.
*
* \note If dynamically allocated data is part of the messages,
* a custom cleanup handler must be passed in the 'callback'
* argument for MessageQueue_New.
*
* \param queue The queue to clear.
*
* \return 0 in case of success or a error code otherwise.
*/
WINPR_API int MessageQueue_Clear(wMessageQueue *queue);
/*! \brief Creates a new message queue.
* If 'callback' is null, no custom cleanup will be done
* on message queue deallocation.
* If the 'callback' argument contains valid uninit or
* free functions those will be called by
* 'MessageQueue_Clear'.
*
* \param callback a pointer to custom initialization / cleanup functions.
* Can be NULL if not used.
*
* \return A pointer to a newly allocated MessageQueue or NULL.
*/
WINPR_API wMessageQueue* MessageQueue_New(const wObject *callback);
/*! \brief Frees resources allocated by a message queue.
* This function will only free resources allocated
* internally.
*
* \note Empty the queue before calling this function with
* 'MessageQueue_Clear', 'MessageQueue_Get' or
* 'MessageQueue_Peek' to free all resources allocated
* by the message contained.
*
* \param queue A pointer to the queue to be freed.
*/
WINPR_API void MessageQueue_Free(wMessageQueue* queue);
/* Message Pipe */
struct _wMessagePipe
{
wMessageQueue* In;
wMessageQueue* Out;
};
typedef struct _wMessagePipe wMessagePipe;
WINPR_API void MessagePipe_PostQuit(wMessagePipe* pipe, int nExitCode);
WINPR_API wMessagePipe* MessagePipe_New(void);
WINPR_API void MessagePipe_Free(wMessagePipe* pipe);
/* Publisher/Subscriber Pattern */
struct _wEventArgs
{
DWORD Size;
const char* Sender;
};
typedef struct _wEventArgs wEventArgs;
typedef void (*pEventHandler)(void* context, wEventArgs* e);
#define MAX_EVENT_HANDLERS 32
struct _wEventType
{
const char* EventName;
wEventArgs EventArgs;
int EventHandlerCount;
pEventHandler EventHandlers[MAX_EVENT_HANDLERS];
};
typedef struct _wEventType wEventType;
#define EventArgsInit(_event_args, _sender) \
memset(_event_args, 0, sizeof(*_event_args)); \
((wEventArgs*) _event_args)->Size = sizeof(*_event_args); \
((wEventArgs*) _event_args)->Sender = _sender
#define DEFINE_EVENT_HANDLER(_name) \
typedef void (*p ## _name ## EventHandler)(void* context, _name ## EventArgs* e)
#define DEFINE_EVENT_RAISE(_name) \
static INLINE int PubSub_On ## _name (wPubSub* pubSub, void* context, _name ## EventArgs* e) { \
return PubSub_OnEvent(pubSub, #_name, context, (wEventArgs*) e); }
#define DEFINE_EVENT_SUBSCRIBE(_name) \
static INLINE int PubSub_Subscribe ## _name (wPubSub* pubSub, p ## _name ## EventHandler EventHandler) { \
return PubSub_Subscribe(pubSub, #_name, (pEventHandler) EventHandler); }
#define DEFINE_EVENT_UNSUBSCRIBE(_name) \
static INLINE int PubSub_Unsubscribe ## _name (wPubSub* pubSub, p ## _name ## EventHandler EventHandler) { \
return PubSub_Unsubscribe(pubSub, #_name, (pEventHandler) EventHandler); }
#define DEFINE_EVENT_BEGIN(_name) \
typedef struct _ ## _name ## EventArgs { \
wEventArgs e;
#define DEFINE_EVENT_END(_name) \
} _name ## EventArgs; \
DEFINE_EVENT_HANDLER(_name); \
DEFINE_EVENT_RAISE(_name) \
DEFINE_EVENT_SUBSCRIBE(_name) \
DEFINE_EVENT_UNSUBSCRIBE(_name)
#define DEFINE_EVENT_ENTRY(_name) \
{ #_name, { sizeof( _name ## EventArgs) }, 0, { \
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } },
struct _wPubSub
{
CRITICAL_SECTION lock;
BOOL synchronized;
int size;
int count;
wEventType* events;
};
typedef struct _wPubSub wPubSub;
WINPR_API void PubSub_Lock(wPubSub* pubSub);
WINPR_API void PubSub_Unlock(wPubSub* pubSub);
WINPR_API wEventType* PubSub_GetEventTypes(wPubSub* pubSub, int* count);
WINPR_API void PubSub_AddEventTypes(wPubSub* pubSub, wEventType* events, int count);
WINPR_API wEventType* PubSub_FindEventType(wPubSub* pubSub, const char* EventName);
WINPR_API int PubSub_Subscribe(wPubSub* pubSub, const char* EventName, pEventHandler EventHandler);
WINPR_API int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, pEventHandler EventHandler);
WINPR_API int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, wEventArgs* e);
WINPR_API wPubSub* PubSub_New(BOOL synchronized);
WINPR_API void PubSub_Free(wPubSub* pubSub);
/* BipBuffer */
struct _wBipBlock
{
size_t index;
size_t size;
};
typedef struct _wBipBlock wBipBlock;
struct _wBipBuffer
{
size_t size;
BYTE* buffer;
size_t pageSize;
wBipBlock blockA;
wBipBlock blockB;
wBipBlock readR;
wBipBlock writeR;
};
typedef struct _wBipBuffer wBipBuffer;
WINPR_API BOOL BipBuffer_Grow(wBipBuffer* bb, size_t size);
WINPR_API void BipBuffer_Clear(wBipBuffer* bb);
WINPR_API size_t BipBuffer_UsedSize(wBipBuffer* bb);
WINPR_API size_t BipBuffer_BufferSize(wBipBuffer* bb);
WINPR_API BYTE* BipBuffer_WriteReserve(wBipBuffer* bb, size_t size);
WINPR_API BYTE* BipBuffer_WriteTryReserve(wBipBuffer* bb, size_t size, size_t* reserved);
WINPR_API void BipBuffer_WriteCommit(wBipBuffer* bb, size_t size);
WINPR_API BYTE* BipBuffer_ReadReserve(wBipBuffer* bb, size_t size);
WINPR_API BYTE* BipBuffer_ReadTryReserve(wBipBuffer* bb, size_t size, size_t* reserved);
WINPR_API void BipBuffer_ReadCommit(wBipBuffer* bb, size_t size);
WINPR_API int BipBuffer_Read(wBipBuffer* bb, BYTE* data, size_t size);
WINPR_API int BipBuffer_Write(wBipBuffer* bb, BYTE* data, size_t size);
WINPR_API wBipBuffer* BipBuffer_New(size_t size);
WINPR_API void BipBuffer_Free(wBipBuffer* bb);
#ifdef __cplusplus
}
#endif
#endif /* WINPR_COLLECTIONS_H */
|