[pubsub] fix API definitons to avoid warnings

This commit is contained in:
Armin Novak 2023-10-11 14:17:51 +02:00 committed by akallabeth
parent 4778203340
commit 9f7cfe51ba
2 changed files with 16 additions and 12 deletions

View File

@ -790,16 +790,14 @@ extern "C"
#define DEFINE_EVENT_SUBSCRIBE(name) \
static INLINE int PubSub_Subscribe##name(wPubSub* pubSub, p##name##EventHandler EventHandler) \
{ \
pEventHandler handler = WINPR_EVENT_CAST(pEventHandler, EventHandler); \
return PubSub_Subscribe(pubSub, #name, handler); \
return PubSub_Subscribe(pubSub, #name, EventHandler); \
}
#define DEFINE_EVENT_UNSUBSCRIBE(name) \
static INLINE int PubSub_Unsubscribe##name(wPubSub* pubSub, \
p##name##EventHandler EventHandler) \
{ \
pEventHandler handler = WINPR_EVENT_CAST(pEventHandler, EventHandler); \
return PubSub_Unsubscribe(pubSub, #name, handler); \
return PubSub_Unsubscribe(pubSub, #name, EventHandler); \
}
#define DEFINE_EVENT_BEGIN(name) \
@ -832,10 +830,8 @@ extern "C"
WINPR_API void PubSub_AddEventTypes(wPubSub* pubSub, wEventType* events, size_t 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_Subscribe(wPubSub* pubSub, const char* EventName, ...);
WINPR_API int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, ...);
WINPR_API int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context,
const wEventArgs* e);

View File

@ -115,12 +115,15 @@ void PubSub_AddEventTypes(wPubSub* pubSub, wEventType* events, size_t count)
PubSub_Unlock(pubSub);
}
int PubSub_Subscribe(wPubSub* pubSub, const char* EventName, pEventHandler EventHandler)
int PubSub_Subscribe(wPubSub* pubSub, const char* EventName, ...)
{
wEventType* event;
int status = -1;
WINPR_ASSERT(pubSub);
WINPR_ASSERT(EventHandler);
va_list ap;
va_start(ap, EventName);
pEventHandler EventHandler = va_arg(ap, pEventHandler);
if (pubSub->synchronized)
PubSub_Lock(pubSub);
@ -140,17 +143,21 @@ int PubSub_Subscribe(wPubSub* pubSub, const char* EventName, pEventHandler Event
if (pubSub->synchronized)
PubSub_Unlock(pubSub);
va_end(ap);
return status;
}
int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, pEventHandler EventHandler)
int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, ...)
{
size_t index;
wEventType* event;
int status = -1;
WINPR_ASSERT(pubSub);
WINPR_ASSERT(EventName);
WINPR_ASSERT(EventHandler);
va_list ap;
va_start(ap, EventName);
pEventHandler EventHandler = va_arg(ap, pEventHandler);
if (pubSub->synchronized)
PubSub_Lock(pubSub);
@ -177,6 +184,7 @@ int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, pEventHandler Eve
if (pubSub->synchronized)
PubSub_Unlock(pubSub);
va_end(ap);
return status;
}