
#include "Webserv.hpp"

Webserv::Webserv()
{
	std::cerr << "Server init\n";

	_epfd = ::epoll_create1(0); // (EPOLL_CLOEXEC) for CGI fork ?
	if (_epfd == -1)
	{
		std::perror("err epoll_create1()");
		throw std::runtime_error("Epoll init");
	}

	_init_http_status_map();
	_init_mime_types_map();

	std::signal(SIGPIPE, signal_handler);
	std::signal(SIGINT, signal_handler);
}

/* Webserv::Webserv(Webserv const &src)
{
	
} */

// we'll come back to this
/*
Webserv::Webserv(std::vector<ServerConfig>* servers)
: _servers(servers)
{
	// talk to luke about what all this does
		// the Param Constructor might need to do dif stuff
	std::cout << "Server init\n";

	_epfd = ::epoll_create1(0); // (EPOLL_CLOEXEC) for CGI fork ?
	if (_epfd == -1)
	{
		std::perror("err epoll_create1(): ");
		throw std::runtime_error("Epoll init");
	}
}
*/


Webserv::~Webserv()
{
	close(_epfd);
	_close_all_clients();
	_close_all_listen_sockets();
	std::cerr << "Server destroyed\n";
}

/* Webserv &	Webserv::operator=(Webserv const &rhs)
{
	
} */
