Webserv
Loading...
Searching...
No Matches
webserv.cpp
Go to the documentation of this file.
1
9#include "webserv.hpp"
10
11fd_set Master::_readfds;
12int Master::_min_fd = INT_MAX;
13int Master::_max_fd = 0;
14int Master::_amount = 0;
15
16/* *******************************/
25/* *******************************/
26int main(int ac, char **av) {
27 try {
28 // Parse config file
29 if (ac > 2)
30 throw std::runtime_error("Too many arguments");
31 std::string config_file = "default.json";
32 if (ac == 2)
33 config_file = av[1];
34 std::ifstream file(config_file.c_str());
35 if (!file.good())
36 throw std::runtime_error("File not found");
37 cout << "Parsing configuration file from JSON conf file.\n";
38 cout << "You must be sure the syntax is correct\n";
39 JSONParser parser(config_file);
40 JSONNode *conf = parser.parse();
41 // Here we start the server and his environment using conf
42 cout << "Initialization of server...\n";
43 Env env(conf);
44 while (1)
45 env.cycle();
46 } catch (const std::exception &e) {
47 std::cerr << e.what() << '\n';
48 return EXIT_FAILURE;
49 }
50 return EXIT_SUCCESS;
51}
Definition: Env.hpp:4
void cycle(void)
A Wevserv cycle:
Definition: Env.cpp:55
JSONNode * parse()
Definition: Parser.cpp:5
static fd_set _readfds
Definition: Master.hpp:19
static int _amount
< The higher one
Definition: Master.hpp:20
static int _max_fd
< The lower socket fd
Definition: Master.hpp:20
static int _min_fd
< The sockets fd which will be select
Definition: Master.hpp:20
int main(int ac, char **av)
< The amount of sockets listens
Definition: webserv.cpp:26