Browse Source

starting conf classes implementation

test
nicolas-arnaud 2 years ago
parent
commit
03a59acf17
  1. 2
      Makefile
  2. 3
      srcs/read_conf.cpp
  3. 19
      srcs/server.cpp
  4. 38
      srcs/server.hpp
  5. 14
      srcs/tools.cpp

2
Makefile

@ -1,5 +1,5 @@
NAME= server NAME= server
SRCS= srcs/server.cpp srcs/tools.cpp SRCS= srcs/server.cpp srcs/tools.cpp srcs/read_conf.cpp
OBJS= $(SRCS:.cpp=.o) OBJS= $(SRCS:.cpp=.o)
CXX=c++ CXX=c++
CXXFLAGS= -Wextra -Wall -std=c++98 CXXFLAGS= -Wextra -Wall -std=c++98

3
srcs/read_conf.cpp

@ -0,0 +1,3 @@
#include "server.hpp"

19
srcs/server.cpp

@ -1,21 +1,4 @@
/** #include "server.hpp"
Handle multiple socket connections with select and fd_set on Linux
*/
#include <iostream>
#include <fcntl.h>
#include <stdio.h>
#include <string.h> //strlen
#include <stdlib.h>
#include <errno.h>
#include <unistd.h> //close
#include <arpa/inet.h> //close
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/time.h> //FD_SET, FD_ISSET, FD_ZERO macros
#define PORT 80 #define PORT 80
int main(void) int main(void)

38
srcs/server.hpp

@ -1,19 +1,11 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* server.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/02 11:16:17 by narnaud #+# #+# */
/* Updated: 2022/11/02 12:24:25 by narnaud ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once #pragma once
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/time.h> //FD_SET, FD_ISSET, FD_ZERO macros
#include <unistd.h> #include <unistd.h>
#include <cerrno> #include <cerrno>
@ -21,5 +13,25 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <vector>
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<Route> _routes;
public:
Server(char *filename);
~Server();
};
void *ft_memset(void *b, int c, size_t len); void *ft_memset(void *b, int c, size_t len);

14
srcs/tools.cpp

@ -1,16 +1,4 @@
/* ************************************************************************** */ #include "server.hpp"
/* */
/* ::: :::::::: */
/* tools.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/02 11:01:55 by narnaud #+# #+# */
/* Updated: 2022/11/02 11:14:36 by narnaud ### ########.fr */
/* */
/* ************************************************************************** */
#include <stddef.h>
void *ft_memset(void *b, int c, size_t len) void *ft_memset(void *b, int c, size_t len)
{ {

Loading…
Cancel
Save