update zpl
parent
4ea2ba6188
commit
e056395f8f
|
@ -2,23 +2,24 @@
|
||||||
#include "zpl.h"
|
#include "zpl.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#ifdef ZPL_SYSTEM_WINDOWS
|
#ifdef ZPL_SYSTEM_WINDOWS
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
static BOOL WINAPI _sighandler_win32_control_handler(DWORD control_type)
|
static BOOL WINAPI _sighandler_win32_control_handler(DWORD control_type)
|
||||||
{
|
{
|
||||||
switch (control_type)
|
switch (control_type)
|
||||||
{
|
{
|
||||||
case CTRL_C_EVENT:
|
case CTRL_C_EVENT:
|
||||||
case DBG_CONTROL_C:
|
case DBG_CONTROL_C:
|
||||||
platform_shutdown();
|
platform_shutdown();
|
||||||
return 0;
|
return 0;
|
||||||
case CTRL_CLOSE_EVENT:
|
case CTRL_CLOSE_EVENT:
|
||||||
case CTRL_LOGOFF_EVENT:
|
case CTRL_LOGOFF_EVENT:
|
||||||
case CTRL_BREAK_EVENT:
|
case CTRL_BREAK_EVENT:
|
||||||
case CTRL_SHUTDOWN_EVENT:
|
case CTRL_SHUTDOWN_EVENT:
|
||||||
platform_shutdown();
|
platform_shutdown();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else //POSIX complaint
|
#else //POSIX complaint
|
||||||
|
@ -29,25 +30,25 @@ static void _sighandler_posix_signal_handler(int sig) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void sighandler_register() {
|
void sighandler_register() {
|
||||||
#ifdef ZPL_SYSTEM_WINDOWS
|
#ifdef ZPL_SYSTEM_WINDOWS
|
||||||
{
|
{
|
||||||
if (!SetConsoleCtrlHandler(_sighandler_win32_control_handler, 1)) {
|
if (!SetConsoleCtrlHandler(_sighandler_win32_control_handler, 1)) {
|
||||||
zpl_printf("Could not set up signal handler!\n");
|
zpl_printf("Could not set up signal handler!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else // POSIX compliant
|
#else // POSIX compliant
|
||||||
signal(SIGINT, &_sighandler_posix_signal_handler);
|
signal(SIGINT, &_sighandler_posix_signal_handler);
|
||||||
signal(SIGTERM, &_sighandler_posix_signal_handler);
|
signal(SIGTERM, &_sighandler_posix_signal_handler);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void sighandler_unregister() {
|
void sighandler_unregister() {
|
||||||
#ifdef ZPL_SYSTEM_WINDOWS
|
#ifdef ZPL_SYSTEM_WINDOWS
|
||||||
{
|
{
|
||||||
if (!SetConsoleCtrlHandler(_sighandler_win32_control_handler, 0)) {
|
if (!SetConsoleCtrlHandler(_sighandler_win32_control_handler, 0)) {
|
||||||
zpl_printf("Could not uninstall signal handler!");
|
zpl_printf("Could not uninstall signal handler!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else // POSIX compliant
|
#else // POSIX compliant
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue