diff --git a/webserv/config/ConfigManager.cpp b/webserv/config/ConfigManager.cpp index 16011b4..bb7ccce 100644 --- a/webserv/config/ConfigManager.cpp +++ b/webserv/config/ConfigManager.cpp @@ -115,9 +115,9 @@ void ConfigManager::parseConfigFile(const std::string &filePath) file.close(); } -void ConfigManager::parseGlobalDeclarations(const std::string &declarations) -{ - // Placeholder for actual global declarations parsing logic - std::cout << "Parsing global declarations:\n" << declarations << '\n'; - // Implement the parsing logic here -} +// void ConfigManager::parseGlobalDeclarations(const std::string &declarations) +// { +// // Placeholder for actual global declarations parsing logic +// std::cout << "Parsing global declarations:\n" << declarations << '\n'; +// // Implement the parsing logic here +// } diff --git a/webserv/config/ConfigManager.hpp b/webserv/config/ConfigManager.hpp index 64a20ba..0014f88 100644 --- a/webserv/config/ConfigManager.hpp +++ b/webserv/config/ConfigManager.hpp @@ -23,6 +23,5 @@ class ConfigManager std::vector serverConfigs; void parseConfigFile(const std::string &filePath); - void parseGlobalDeclarations(const std::string &declarations); - + // void parseGlobalDeclarations(const std::string &declarations); }; \ No newline at end of file diff --git a/webserv/config/LocationConfig.cpp b/webserv/config/LocationConfig.cpp index 336dc57..7751c73 100644 --- a/webserv/config/LocationConfig.cpp +++ b/webserv/config/LocationConfig.cpp @@ -1,13 +1,11 @@ #include #include - #include -#include #include +#include -LocationConfig::LocationConfig(const std::string &locationBlock) - : path(""), autoIndex(false), indexFile("") +LocationConfig::LocationConfig(const std::string &locationBlock) : autoIndex(false) { parseLocationBlock(locationBlock); } @@ -18,7 +16,6 @@ void LocationConfig::parseLocationBlock(const std::string &block) std::cout << "Parsing location block:\n" << block << '\n'; // Implement the parsing logic here parseDirectives(block); - } void LocationConfig::parseDirectives(const std::string &declarations) { @@ -30,14 +27,14 @@ void LocationConfig::parseDirectives(const std::string &declarations) while (std::getline(stream, line)) { std::string directive; - std::istringstream ss{trim(line)}; - ss >> directive; + std::istringstream lineStream{trim(line)}; + lineStream >> directive; if (!directive.empty()) { std::cout << "Directive: " << directive << '\n'; // Implement the parsing logic here std::string value; - ss >> value; + lineStream >> value; if (directive == "autoindex") { autoIndex = (value == "on"); diff --git a/webserv/config/ServerConfig.cpp b/webserv/config/ServerConfig.cpp index 31f6fe5..25e3410 100644 --- a/webserv/config/ServerConfig.cpp +++ b/webserv/config/ServerConfig.cpp @@ -1,26 +1,23 @@ -#include #include +#include #include #include -#include #include +#include -ServerConfig::ServerConfig(std::string const &serverBlock) - : host(""), port(80), root("") +ServerConfig::ServerConfig(std::string const &serverBlock) : port(80) { parseServerBlock(serverBlock); } - - void ServerConfig::parseServerBlock(const std::string &block) { // Placeholder for actual server block parsing logic std::cout << "Parsing server block:\n"; - // Placeholder for actual file parsing logic - + // Placeholder for actual file parsing logic + std::string serverDeclarations; size_t pos = 0; @@ -35,7 +32,7 @@ void ServerConfig::parseServerBlock(const std::string &block) serverDeclarations += block.substr(pos); break; } - std::string locationPath = trim(block.substr(locationPos, bracePos - (locationPos ))); + std::string locationPath = trim(block.substr(locationPos, bracePos - (locationPos))); // Add global declarations before this server block serverDeclarations += block.substr(pos, locationPos - pos); size_t closeBrace = findCorrespondingClosingBrace(block, bracePos); @@ -62,14 +59,14 @@ void ServerConfig::parseDirectives(const std::string &declarations) while (std::getline(stream, line)) { std::string directive; - std::istringstream ss{trim(line)}; - ss >> directive; + std::istringstream lineStream{trim(line)}; + lineStream >> directive; if (!directive.empty()) { std::cout << "Directive: " << directive << '\n'; // Implement the parsing logic here std::string value; - ss >> value; + lineStream >> value; if (directive == "listen") { @@ -95,16 +92,16 @@ void ServerConfig::parseDirectives(const std::string &declarations) cgi_pass = value; std::cout << "Set cgi_pass to " << cgi_pass << '\n'; } - else if(directive =="cgi_ext") + else if (directive == "cgi_ext") { cgi_ext = value; std::cout << "Set cgi_ext to " << cgi_ext << '\n'; } - else if(directive == "index") + else if (directive == "index") { index_files.clear(); std::string indexFile; - while (ss >> indexFile) + while (lineStream >> indexFile) { index_files.push_back(indexFile); std::cout << "Added index file: " << indexFile << '\n'; @@ -114,7 +111,7 @@ void ServerConfig::parseDirectives(const std::string &declarations) { int statusCode = std::stoi(value); std::string errorPagePath; - ss >> errorPagePath; + lineStream >> errorPagePath; error_page[statusCode] = errorPagePath; std::cout << "Set error_page for status " << statusCode << " to " << errorPagePath << '\n'; } diff --git a/webserv/config/utils.cpp b/webserv/config/utils.cpp index f27b32d..d845e19 100644 --- a/webserv/config/utils.cpp +++ b/webserv/config/utils.cpp @@ -2,7 +2,6 @@ #include - std::string trim(const std::string &str) { size_t first = str.find_first_not_of(" \t\n\r"); diff --git a/webserv/main.cpp b/webserv/main.cpp index c6fe2b6..0410462 100644 --- a/webserv/main.cpp +++ b/webserv/main.cpp @@ -8,10 +8,10 @@ int main(int argc, char **argv) if (argc < 2) { - std::cerr << "Usage: " << argv[0] << " \n"; + std::cerr << "Usage: " << argv[0] << " \n"; //NOLINT return 1; } - ConfigManager::getInstance().init(argv[1]); + ConfigManager::getInstance().init(argv[1]); //NOLINT return 0; } \ No newline at end of file