-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
69 lines (63 loc) · 2.3 KB
/
main.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: doduwole <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/01 10:47:12 by doduwole #+# #+# */
/* Updated: 2024/06/01 10:47:14 by doduwole ### ########.fr */
/* */
/* ************************************************************************** */
#include "./inc/AllHeaders.hpp"
int g_signal;
Servers *servers = NULL;
void handle_servers(int signo) {
if (signo == SIGINT) {
std::cout << "Server(s) are being stopped..." << std::endl;
if (servers != NULL) {
delete servers;
servers = NULL;
}
exit(0);
}
}
void handle_signal(void) {
struct sigaction sa;
sa.sa_handler = handle_servers;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGINT, &sa, NULL);
}
void printWelcome(void) {
std::cout << "+------------------------------------+" << std::endl;
std::cout << "| Welcome to " << HIBGGREEN << " Webserv " << RESET
<< " |" << std::endl;
}
int main(int argc, char **argv) {
if (argc < 2)
ft_errors(argv[0], 1);
printWelcome();
handle_signal();
ConfigDB base;
base.execParser(argv);
/**
* @brief print your choice of data.
* void ConfigDB::printChoice(bool allRootData, int rootDataIdx, bool
* allServersData, int serverDataIdx, bool allConfig)
* @param allRootData true prints all root data
* @param rootDataIdx prints root data at n index. where n >= 0
* @param allServersData true prints all server data
* @param rootDataIdx prints server data at n index. where n >= 0
*
* @return NULL;
*/
base.printChoice(false, -1, false, -1, false);
// Servers servers(base);
servers = new Servers(base);
if (servers != NULL) {
delete servers;
servers = NULL;
}
return 0;
}