Skip to content

Commit

Permalink
Merge pull request #51 from ilovenoah/create-pull-request/patch
Browse files Browse the repository at this point in the history
feature/formatting-by-clang-format-on-github-actions
  • Loading branch information
ilovenoah authored Feb 9, 2024
2 parents c80e54e + b766f70 commit f302bf2
Show file tree
Hide file tree
Showing 13 changed files with 404 additions and 220 deletions.
22 changes: 11 additions & 11 deletions inc/AConfigurable.hpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
#ifndef CONFIGURABLE_HPP
#define CONFIGURABLE_HPP

#include <vector>
#include <string>
#include <map>
#include <limits.h>

#include <fstream>
#include <map>
#include <sstream>
#include <limits.h>
#include "utils.hpp"
#include <string>
#include <vector>

#include "errormsg.hpp"
#include "utils.hpp"

#define ONEMEGA 1000000

class AConfigurable {
public:
enum IsAutoIndexed {
FALSE = 0,
TRUE = 1,
UNDEFINED = 2
};
enum IsAutoIndexed { FALSE = 0, TRUE = 1, UNDEFINED = 2 };

private:
protected:
std::vector<std::string> _allowMethods;
Expand All @@ -38,7 +37,8 @@ class AConfigurable {
const IsAutoIndexed &getAutoindex() const;
bool setIndex(std::string const &attribute, std::fstream &file);
const std::vector<std::string> &getIndex() const;
bool setClientMaxBodySize(std::string const &attribute, std::fstream &file);
bool setClientMaxBodySize(std::string const &attribute,
std::fstream &file);
const ssize_t &getClientMaxBodySize() const;
bool setCgiExtensions(std::string const &attribute, std::fstream &file);
const std::vector<std::string> &getCgiExtensions() const;
Expand Down
19 changes: 12 additions & 7 deletions inc/Config.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#ifndef CONFIG_HPP
#define CONFIG_HPP

#include <iostream>
#include <string>
#include <sys/stat.h>

#include <fstream>
#include <iostream>
#include <map>
#include <sys/stat.h>
#include <string>

#include "Server.hpp"
#include "utils.hpp"
#include "errormsg.hpp"
#include "utils.hpp"

class Server;

Expand All @@ -17,8 +19,12 @@ class Config {
std::fstream _file;
std::map<std::string, Server> _servers;
Server _createServerInstance(std::fstream &file);
static std::map<std::string, bool (Server::*)(const std::string&, std::fstream&)> _setterMap;
static std::map<std::string, bool (Server::*)(const std::string&, std::fstream&)> initSetterMap();
static std::map<std::string,
bool (Server::*)(const std::string &, std::fstream &)>
_setterMap;
static std::map<std::string,
bool (Server::*)(const std::string &, std::fstream &)>
initSetterMap();

public:
static std::size_t lineCount;
Expand All @@ -28,5 +34,4 @@ class Config {
void printServers() const;
};


#endif
5 changes: 3 additions & 2 deletions inc/Location.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#ifndef LOCATION_HPP
#define LOCATION_HPP

#include <string>
#include <fstream>
#include <sstream>
#include "Server.hpp"
#include <string>

#include "AConfigurable.hpp"
#include "Server.hpp"

class Server;

Expand Down
2 changes: 1 addition & 1 deletion inc/Response.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <string>

#include "ClientSocket.hpp"
#include "Request.hpp"
#include "Config.hpp"
#include "Request.hpp"

class Response {
// public:
Expand Down
15 changes: 10 additions & 5 deletions inc/Server.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#ifndef SERVER_HPP
#define SERVER_HPP

#include <vector>
#include <string>
#include <map>
#include <string>
#include <vector>

#include "AConfigurable.hpp"
#include "Config.hpp"
#include "Location.hpp"
#include "utils.hpp"
#include "Config.hpp"

#define MIN_USERPORT 1024
#define MAX_USERPORT 49151
Expand All @@ -21,8 +22,12 @@ class Server : public AConfigurable {
std::string _port;
std::string _root;
std::map<std::string, Location> _locations;
static std::map<std::string, bool (Location::*)(const std::string&, std::fstream&)> _setterMap;
static std::map<std::string, bool (Location::*)(const std::string&, std::fstream&)> initSetterMap();
static std::map<std::string,
bool (Location::*)(const std::string &, std::fstream &)>
_setterMap;
static std::map<std::string,
bool (Location::*)(const std::string &, std::fstream &)>
initSetterMap();

public:
Server();
Expand Down
4 changes: 2 additions & 2 deletions inc/main.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef MAIN_HPP
#define MAIN_HPP

#include "Error.hpp"
#include "Config.hpp"
#include "Error.hpp"
#include "Location.hpp"
#include "env.hpp"
#include "ServerSocket.hpp"
#include "env.hpp"
#include "loop.hpp"

#endif
14 changes: 7 additions & 7 deletions inc/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
#include "env.hpp"

namespace utils {
void putSysError(char const *msg);
std::size_t decStrToSizeT(std::string &str);
std::size_t hexStrToSizeT(std::string &str);
bool findCRLF(std::stringstream &stream);
bool shouldIgnoreLine(std::string const &line);
bool rmCR(std::string &line);
bool isNumber(std::string const &str);
void putSysError(char const *msg);
std::size_t decStrToSizeT(std::string &str);
std::size_t hexStrToSizeT(std::string &str);
bool findCRLF(std::stringstream &stream);
bool shouldIgnoreLine(std::string const &line);
bool rmCR(std::string &line);
bool isNumber(std::string const &str);
} // namespace utils

#endif
Loading

0 comments on commit f302bf2

Please sign in to comment.