mirror of
https://github.com/wiiu-env/wut.git
synced 2024-12-05 03:24:17 +01:00
whb: Add ability to remove logging functions
* WHBRemoveLogHandler will look through the "registry" of logging functions, and will set the entry to NULL if it matches what the user passes. * WHBLogUdpDeinit will correctly close the socket and shut down the socket library in addition to removing its entry in the registry.
This commit is contained in:
parent
ac4ce95f84
commit
20c7dbf2fb
@ -116,5 +116,6 @@ exit:
|
||||
WHBUnmountSdCard();
|
||||
WHBGfxShutdown();
|
||||
WHBProcShutdown();
|
||||
WHBLogUdpDeinit();
|
||||
return result;
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ typedef void (*LogHandlerFn)(const char *msg);
|
||||
BOOL
|
||||
WHBAddLogHandler(LogHandlerFn fn);
|
||||
|
||||
BOOL
|
||||
WHBRemoveLogHandler(LogHandlerFn fn);
|
||||
|
||||
BOOL
|
||||
WHBLogWrite(const char *str);
|
||||
|
||||
|
@ -14,6 +14,9 @@ extern "C" {
|
||||
BOOL
|
||||
WHBLogCafeInit();
|
||||
|
||||
BOOL
|
||||
WHBLogCafeDeinit();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -14,6 +14,9 @@ extern "C" {
|
||||
BOOL
|
||||
WHBLogUdpInit();
|
||||
|
||||
BOOL
|
||||
WHBLogUdpDeinit();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -25,6 +25,21 @@ WHBAddLogHandler(LogHandlerFn fn)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBRemoveLogHandler(LogHandlerFn fn)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < MAX_HANDLERS; ++i) {
|
||||
if(sHandlers[i] == fn) {
|
||||
sHandlers[i] = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogWrite(const char *str)
|
||||
{
|
||||
|
@ -19,6 +19,11 @@ cafeLogHandler(const char * msg)
|
||||
BOOL
|
||||
WHBLogCafeInit()
|
||||
{
|
||||
WHBAddLogHandler(cafeLogHandler);
|
||||
return TRUE;
|
||||
return WHBAddLogHandler(cafeLogHandler);
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogCafeDeinit()
|
||||
{
|
||||
return WHBRemoveLogHandler(cafeLogHandler);
|
||||
}
|
||||
|
@ -42,6 +42,16 @@ WHBLogUdpInit()
|
||||
sSendAddr.sin_port = htons(SERVER_PORT);
|
||||
sSendAddr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
|
||||
|
||||
WHBAddLogHandler(udpLogHandler);
|
||||
return TRUE;
|
||||
return WHBAddLogHandler(udpLogHandler);
|
||||
}
|
||||
|
||||
BOOL
|
||||
WHBLogUdpDeinit()
|
||||
{
|
||||
if(shutdown(sSocket, SHUT_WR) != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
socket_lib_finish();
|
||||
return WHBRemoveLogHandler(udpLogHandler);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user