-
Notifications
You must be signed in to change notification settings - Fork 0
/
OtherFunctions.cpp
98 lines (87 loc) · 2.76 KB
/
OtherFunctions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "OtherFunctions.hpp"
BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
{
switch (fdwCtrlType)
{
// Handle the CTRL-C signal.
case CTRL_C_EVENT:
{
std::cout << "Received CTRL-C signal. Removing mappings..." << std::endl;
Beep(750, 300);
uint_fast8_t retval = RemoveCreatedMappings(SentPackets, OutputInterface);
if (0 == retval)
{
std::cout << "All mapping removal request are sent." << std::endl;
}
else
{
std::cerr << "An error occured during mapping removal process" << std::endl;
}
return TRUE;
}
// CTRL-CLOSE: confirm that the user wants to exit.
case CTRL_CLOSE_EVENT:
{
Beep(600, 200);
std::cout << "Received Ctrl-Close signal." << std::endl;
uint_fast8_t retval = RemoveCreatedMappings(SentPackets, OutputInterface);
if (0 == retval)
{
std::cout << "All mapping removal request are sent." << std::endl;
}
else
{
std::cerr << "An error occured during mapping removal process" << std::endl;
}
return TRUE;
}
// Pass other signals to the next handler.
case CTRL_BREAK_EVENT:
{
Beep(900, 200);
std::cout << "Recieved Ctrl-Break signal." << std::endl;
uint_fast8_t retval = RemoveCreatedMappings(SentPackets, OutputInterface);
if (0 == retval)
{
std::cout << "All mapping removal request are sent." << std::endl;
}
else
{
std::cerr << "An error occured during mapping removal process" << std::endl;
}
return FALSE;
}
case CTRL_LOGOFF_EVENT:
{
Beep(1000, 200);
std::cout << "Recieved Ctrl-Logoff signal." << std::endl;
uint_fast8_t retval = RemoveCreatedMappings(SentPackets, OutputInterface);
if (0 == retval)
{
std::cout << "All mapping removal request are sent." << std::endl;
}
else
{
std::cerr << "An error occured during mapping removal process" << std::endl;
}
return FALSE;
}
case CTRL_SHUTDOWN_EVENT:
{
Beep(750, 500);
std::cout << "Received Ctrl-Shutdown signal." << std::endl;
uint_fast8_t retval = RemoveCreatedMappings(SentPackets, OutputInterface);
if (0 == retval)
{
std::cout << "All mapping removal request are sent." << std::endl;
}
else
{
std::cerr << "An error occured during mapping removal process" << std::endl;
}
return FALSE;
}
default:
return FALSE;
}
}