-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (37 loc) · 956 Bytes
/
main.cpp
File metadata and controls
47 lines (37 loc) · 956 Bytes
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
#include "headers.hpp"
int main(int argc, char **argv)
{
try
{
std::string configFile;
if (argc != 1 && argc != 2)
throw std::runtime_error("Wrong number of Args.");
if (argc == 1)
configFile = "full_test.conf"; // setting the default conf
else if (argc == 2)
configFile = argv[1];
// Check if config file exists using stat
struct stat statbuf;
if (stat(configFile.c_str(), &statbuf) != 0)
{
throw std::runtime_error("Config file not found: " + configFile);
}
ConfigParser parser(configFile);
if (!parser.parse())
{
throw std::runtime_error("Failed to parse config file: " + configFile);
}
Config_struct config = parser.getConfig();
// final check of the config struct
configFinalCheck(config);
Server server(config);
// Server server;
server.start_server();
}
catch (const std::exception &e)
{
std::cerr << "Configuration error: " << e.what() << std::endl;
return 1;
}
return 0;
}