-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (47 loc) · 1.92 KB
/
main.cpp
File metadata and controls
54 lines (47 loc) · 1.92 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pcapurro <pcapurro@student.42nice.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/29 15:16:07 by pcapurro #+# #+# */
/* Updated: 2024/02/28 20:31:58 by pcapurro ### ########.fr */
/* */
/* ************************************************************************** */
#include "Irc.hpp"
#include "server/Server.hpp"
bool end_;
void shutdown(int signal)
{
end_ = true;
if (signal == SIGINT)
std::cout << std::endl << "\033[A^C Ctrl-C used. Shutting down..." << std::endl;
else if (signal == SIGTERM)
std::cout << "Terminate order. Shutting down..." << std::endl;
else if (signal == SIGTSTP)
std::cout << std::endl << "\033[A^Z Ctrl-Z used. Shutting down..." << std::endl;
}
int main(const int argc, const char **argv)
{
if (argc != 3)
return (printError(1));
else if (MAX_CANALS < 1 || MAX_CANALS > 1000 || MAX_CLIENTS < 1 || MAX_CLIENTS > 1000 || BOT < 0 || BOT > 1)
return (printError(9));
else
{
printTitle();
Server server(atoi(argv[1]), argv[2]);
if (server.fail() == true)
return (1);
else
{
end_ = false;
signal(SIGINT, shutdown);
signal(SIGTERM, shutdown);
signal(SIGTSTP, shutdown);
server.LoopRoutine();
}
}
return (0);
}