OpenCBM
ctrlbreak.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version
5  * 2 of the License, or (at your option) any later version.
6  *
7  * Copyright 2006 Spiro Trikaliotis
8  *
9 */
10 
21 #define DBG_USERMODE
22 
24 #define DBG_PROGNAME "ARCH.LIB"
25 
26 #include "debug.h"
27 
28 #include "arch.h"
29 
30 #include <windows.h>
31 
32 static ARCH_CTRLBREAK_HANDLER handler;
33 
34 static BOOL WINAPI
35 ControlHandler(DWORD dwCtrlType)
36 {
37  switch (dwCtrlType)
38  {
39  case CTRL_BREAK_EVENT:
40  case CTRL_C_EVENT:
41  case CTRL_CLOSE_EVENT:
42  case CTRL_LOGOFF_EVENT:
43  case CTRL_SHUTDOWN_EVENT:
44  handler(0);
45  return TRUE;
46  break;
47  }
48  return FALSE;
49 }
50 
51 
61 void
62 arch_set_ctrlbreak_handler(ARCH_CTRLBREAK_HANDLER Handler)
63 {
64  handler = Handler;
65  SetConsoleCtrlHandler(ControlHandler, TRUE);
66 }
Define makros for debugging purposes.
#define WINAPI
Definition: opencbm.h:86
void arch_set_ctrlbreak_handler(ARCH_CTRLBREAK_HANDLER Handler)
Set the Ctrl+C / Ctrl+Break handler.
Definition: ctrlbreak.c:62
Define makros and functions which account for differences between the different architectures.