🔨」 fix: change a few thing in main and help to prevent leak

This commit is contained in:
2025-05-06 19:20:44 +02:00
parent 5ea07dd436
commit ec1299ccfa
3 changed files with 21 additions and 7 deletions

9
sample.toml Normal file
View File

@ -0,0 +1,9 @@
[server]
host = "0.0.0.0"
port = 80
[server.location./]
methods = { "GET" }
root = "/var/www/html"
dirlist = true
client_max_body_size = "10M"

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/10 13:08:36 by adjoly #+# #+# */
/* Updated: 2025/05/06 16:19:36 by adjoly ### ########.fr */
/* Updated: 2025/05/06 19:19:43 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -18,6 +18,8 @@
#include <unistd.h>
#include <webserv.hpp>
using namespace webserv;
void _printHelp(void) {
std::cout << "-------------- WEBSERV --------------" << std::endl;
std::cout << "- --help : Print this message" << std::endl;
@ -50,7 +52,10 @@ void _generateConf(void) {
}
void _printVersion(void) {
std::cout << "You are running : Webserv " << WEBSRV_VERSION << std::endl;
Logger log;
std::stringstream str;
str << "you are running webserv " << WEBSRV_VERSION;
log.info(str.str());
}
bool help(int ac, char **av) {

View File

@ -6,7 +6,7 @@
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/03 15:45:07 by mmoussou #+# #+# */
/* Updated: 2025/05/06 11:51:01 by adjoly ### ########.fr */
/* Updated: 2025/05/06 19:19:33 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -40,20 +40,20 @@ void ft_sig(int sig) {
}
int main(int ac, char **av) {
_log = new Logger;
Logger log;
if (help(ac, av)) {
return EXIT_SUCCESS;
}
_log->info("Starting server...");
log.info("Starting server...");
if (access(av[1], F_OK) < 0) {
std::stringstream str;
str << "File : " << av[1] << " could not be opened";
_log->error(str.str());
log.error(str.str());
return EXIT_FAILURE;
}
delete _log;
_log = not_nullptr;
config::Config *conf;
try {
std::string str = av[1];