mirror of
https://git.suyu.dev/suyu/Yucom.git
synced 2025-12-21 21:26:03 +01:00
lsteamclient: Execute debug callbacks from within Steam_BGetCallback.
CW-Bug-Id: #22729
This commit is contained in:
parent
1b4cd4fc7a
commit
77e83d193a
10 changed files with 422 additions and 463 deletions
80
lsteamclient/unixlib.cpp
Normal file
80
lsteamclient/unixlib.cpp
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
#include "unix_private.h"
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(steamclient);
|
||||
|
||||
struct callback_entry
|
||||
{
|
||||
struct list entry;
|
||||
struct callback callback;
|
||||
};
|
||||
|
||||
static struct list callbacks = LIST_INIT( callbacks );
|
||||
static pthread_mutex_t callbacks_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
void queue_sockets_debug_output( void (*W_STDCALL pfnFunc)( uint32_t, const char * ), uint32_t type, const char *msg )
|
||||
{
|
||||
uint32_t msg_size = strlen( msg ) + 1, size = msg_size;
|
||||
struct callback_entry *entry;
|
||||
|
||||
size += sizeof(struct callback_entry);
|
||||
if (!(entry = (struct callback_entry *)malloc( size ))) return;
|
||||
|
||||
entry->callback.type = SOCKETS_DEBUG_OUTPUT;
|
||||
size -= offsetof( struct callback_entry, callback );
|
||||
entry->callback.size = size;
|
||||
|
||||
entry->callback.sockets_debug_output.pfnFunc = pfnFunc;
|
||||
entry->callback.sockets_debug_output.type = type;
|
||||
memcpy( (char *)entry->callback.sockets_debug_output.msg, msg, msg_size );
|
||||
|
||||
pthread_mutex_lock( &callbacks_lock );
|
||||
list_add_tail( &callbacks, &entry->entry );
|
||||
pthread_mutex_unlock( &callbacks_lock );
|
||||
}
|
||||
|
||||
void queue_warning_message_hook( void (*W_CDECL pFunction)( int32_t, const char * ), int32_t severity, const char *msg )
|
||||
{
|
||||
uint32_t msg_size = strlen( msg ) + 1, size = msg_size;
|
||||
struct callback_entry *entry;
|
||||
|
||||
size += sizeof(struct callback_entry);
|
||||
if (!(entry = (struct callback_entry *)malloc( size ))) return;
|
||||
|
||||
entry->callback.type = WARNING_MESSAGE_HOOK;
|
||||
size -= offsetof( struct callback_entry, callback );
|
||||
entry->callback.size = size;
|
||||
|
||||
entry->callback.warning_message_hook.pFunction = pFunction;
|
||||
entry->callback.warning_message_hook.severity = severity;
|
||||
memcpy( (char *)entry->callback.warning_message_hook.msg, msg, msg_size );
|
||||
|
||||
pthread_mutex_lock( &callbacks_lock );
|
||||
list_add_tail( &callbacks, &entry->entry );
|
||||
pthread_mutex_unlock( &callbacks_lock );
|
||||
}
|
||||
|
||||
bool unix_steamclient_next_callback( struct callback *callback, uint32_t *size )
|
||||
{
|
||||
struct list *ptr;
|
||||
|
||||
pthread_mutex_lock( &callbacks_lock );
|
||||
if ((ptr = list_head( &callbacks )))
|
||||
{
|
||||
struct callback_entry *entry = LIST_ENTRY( ptr, struct callback_entry, entry );
|
||||
|
||||
if (entry->callback.size <= *size)
|
||||
{
|
||||
memcpy( callback, &entry->callback, entry->callback.size );
|
||||
list_remove( &entry->entry );
|
||||
free( entry );
|
||||
}
|
||||
|
||||
*size = entry->callback.size;
|
||||
}
|
||||
pthread_mutex_unlock( &callbacks_lock );
|
||||
|
||||
return !!ptr;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue