-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.cc
87 lines (77 loc) · 1.78 KB
/
event.cc
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
// -*- C++ -*-
//
// Event and derived classes, implementations.
//
// Copyright 1992-2021 Deven T. Corzine <[email protected]>
//
// SPDX-License-Identifier: MIT
//
#include "phoenix.h"
void ShutdownEvent::ShutdownWarning(char *by, time_t when)
{
final = false;
Log("Shutdown requested by %s in %d seconds.", by, when);
Session::announce("\a>>> This server will shutdown in %d seconds... <<<\n\a",
when);
}
void ShutdownEvent::FinalWarning()
{
final = true;
SetRelTime(FinalWarningTime);
Log("Final shutdown warning.");
Session::announce("\a>>> Server shutting down NOW! Goodbye. <<<\n\a");
}
void ShutdownEvent::ShutdownServer()
{
Log("Server down.");
if (logfile) fclose(logfile);
exit(0);
}
boolean ShutdownEvent::Execute()
{
if (final) {
ShutdownServer();
return false;
} else {
FinalWarning();
return true;
}
}
void RestartEvent::RestartWarning(char *by, time_t when)
{
final = false;
Log("Restart requested by %s in %d seconds.", by, when);
Session::announce("\a>>> This server will restart in %d seconds... <<<\n\a",
when);
}
void RestartEvent::FinalWarning()
{
final = true;
SetRelTime(FinalWarningTime);
Log("Final restart warning.");
Session::announce("\a>>> Server restarting NOW! Goodbye. <<<\n\a");
}
void RestartEvent::RestartServer()
{
Log("Restarting server.");
if (logfile) fclose(logfile);
FD::CloseAll();
execl(SERVER_PATH, SERVER_PATH, (const char *) NULL);
error(SERVER_PATH);
}
boolean RestartEvent::Execute()
{
if (final) {
RestartServer();
return false;
} else {
FinalWarning();
return true;
}
}
boolean LoginTimeoutEvent::Execute()
{
telnet->output("\nLogin timed out!\n");
telnet->Close();
return false;
}