diff --git a/Makefile b/Makefile index 9284e55..8e87798 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ NAME= server -SRCS= srcs/server.cpp srcs/tools.cpp +SRCS= srcs/server.cpp srcs/tools.cpp srcs/read_conf.cpp OBJS= $(SRCS:.cpp=.o) CXX=c++ CXXFLAGS= -Wextra -Wall -std=c++98 diff --git a/srcs/read_conf.cpp b/srcs/read_conf.cpp new file mode 100644 index 0000000..7176675 --- /dev/null +++ b/srcs/read_conf.cpp @@ -0,0 +1,3 @@ +#include "server.hpp" + + diff --git a/srcs/server.cpp b/srcs/server.cpp index 65262a6..6a75ebc 100644 --- a/srcs/server.cpp +++ b/srcs/server.cpp @@ -1,21 +1,4 @@ -/** - Handle multiple socket connections with select and fd_set on Linux -*/ - -#include - -#include -#include -#include //strlen -#include -#include -#include //close -#include //close -#include -#include -#include -#include //FD_SET, FD_ISSET, FD_ZERO macros - +#include "server.hpp" #define PORT 80 int main(void) @@ -39,7 +22,7 @@ int main(void) exit(EXIT_FAILURE); } - if( setsockopt(master_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)) < 0 ) + if ( setsockopt(master_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)) < 0 ) { std::cout << std::strerror(errno) << std::endl; exit(EXIT_FAILURE); diff --git a/srcs/server.hpp b/srcs/server.hpp index 785da50..eee344e 100644 --- a/srcs/server.hpp +++ b/srcs/server.hpp @@ -1,19 +1,11 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* server.hpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: narnaud +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2022/11/02 11:16:17 by narnaud #+# #+# */ -/* Updated: 2022/11/02 12:24:25 by narnaud ### ########.fr */ -/* */ -/* ************************************************************************** */ #pragma once -#include -#include #include +#include +#include +#include +#include +#include //FD_SET, FD_ISSET, FD_ZERO macros #include #include @@ -21,5 +13,25 @@ #include #include #include +#include + +class Route { + std::string _location; + std::string _root; + std::string _index; + public: + Route(std::string location, std::string root, std::string index); + ~Route(); +}; + +class Server { + unsigned int _port; + std::string _server_name; + std::vector _routes; + public: + Server(char *filename); + ~Server(); +}; + void *ft_memset(void *b, int c, size_t len); diff --git a/srcs/tools.cpp b/srcs/tools.cpp index f29945d..602e368 100644 --- a/srcs/tools.cpp +++ b/srcs/tools.cpp @@ -1,16 +1,4 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* tools.cpp :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: narnaud +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2022/11/02 11:01:55 by narnaud #+# #+# */ -/* Updated: 2022/11/02 11:14:36 by narnaud ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include +#include "server.hpp" void *ft_memset(void *b, int c, size_t len) {