🔨」 fix: fixed some things.

This commit is contained in:
2025-05-06 19:29:36 +02:00
parent ec1299ccfa
commit 8ef2803075
2 changed files with 16 additions and 22 deletions

View File

@ -6,13 +6,13 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/10 13:08:36 by adjoly #+# #+# */ /* Created: 2025/04/10 13:08:36 by adjoly #+# #+# */
/* Updated: 2025/05/06 19:19:43 by adjoly ### ########.fr */ /* Updated: 2025/05/06 19:20:57 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include <log.hpp>
#include <fstream> #include <fstream>
#include <help.hpp> #include <help.hpp>
#include <log.hpp>
#include <sstream> #include <sstream>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
@ -40,9 +40,9 @@ void _generateConf(void) {
std::ofstream file(SAMPLE_CONF_PATH); std::ofstream file(SAMPLE_CONF_PATH);
if (file.is_open()) { if (file.is_open()) {
file << "[server]\nhost = \"0.0.0.0\"\nport = " file << "[server]\nhost = \"0.0.0.0\"\nport = "
"80\n\n[server.location./]\nmethods = { \"GET\" }\nroot " "80\n\n[server.location./]\nmethods = { \"GET\" }\nroot "
"= \"/var/www/html\"\ndirlist = true\nclient_max_body_size " "= \"/var/www/html\"\ndirlist = true\nclient_max_body_size "
"= \"10M\"\n"; "= \"10M\"\n";
file.close(); file.close();
_log.info("config file successfully generated"); _log.info("config file successfully generated");
} else { } else {
@ -52,7 +52,7 @@ void _generateConf(void) {
} }
void _printVersion(void) { void _printVersion(void) {
Logger log; Logger log;
std::stringstream str; std::stringstream str;
str << "you are running webserv " << WEBSRV_VERSION; str << "you are running webserv " << WEBSRV_VERSION;
log.info(str.str()); log.info(str.str());
@ -67,15 +67,12 @@ bool help(int ac, char **av) {
if (option == "--help" || option == "-v") { if (option == "--help" || option == "-v") {
_printHelp(); _printHelp();
return true; return true;
} } else if (option == "--generate" || option == "-g") {
else if (option == "--generate" || option == "-g") {
_generateConf(); _generateConf();
return true; return true;
} } else if (option == "--version" || option == "-v") {
else if (option == "--version" || option == "-v") {
_printVersion(); _printVersion();
return true; return true;
} } else
else
return false; return false;
} }

View File

@ -6,32 +6,32 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */ /* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 15:45:07 by mmoussou #+# #+# */ /* Created: 2025/02/03 15:45:07 by mmoussou #+# #+# */
/* Updated: 2025/05/06 19:19:33 by adjoly ### ########.fr */ /* Updated: 2025/05/06 19:20:55 by adjoly ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "cppeleven.hpp" #include "cppeleven.hpp"
#include <config/Config.hpp>
#include <config/default.hpp> #include <config/default.hpp>
#include <csignal> #include <csignal>
#include <server/default.hpp>
#include <config/Config.hpp>
#include <cstdlib> #include <cstdlib>
#include <exception> #include <exception>
#include <help.hpp> #include <help.hpp>
#include <log.hpp>
#include <requests/default.hpp> #include <requests/default.hpp>
#include <server/default.hpp>
#include <sstream> #include <sstream>
#include <tomlpp.hpp> #include <tomlpp.hpp>
#include <unistd.h> #include <unistd.h>
#include <log.hpp>
#include <webserv.hpp> #include <webserv.hpp>
namespace webserv { namespace webserv {
Logger *_log = not_nullptr; Logger *_log = not_nullptr;
} }
int _sig = 0; int _sig = 0;
void ft_sig(int sig) { void ft_sig(int sig) {
_sig = sig; _sig = sig;
std::stringstream str; std::stringstream str;
str << "sig hitted = "; str << "sig hitted = ";
@ -52,15 +52,12 @@ int main(int ac, char **av) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
_log = not_nullptr; _log = not_nullptr;
config::Config *conf; config::Config *conf;
try { try {
std::string str = av[1]; std::string str = av[1];
conf = new config::Config(str); conf = new config::Config(str);
} catch (std::exception &) { } catch (std::exception &) {
//std::cout << e.what() << std::endl;
//delete conf;
if (_log != not_nullptr) if (_log != not_nullptr)
delete _log; delete _log;
return 1; return 1;