still working on telnet tester

This commit is contained in:
Eric LAZO
2022-08-15 01:47:37 +02:00
parent 21efbef86a
commit aa03880601
12 changed files with 228 additions and 50 deletions

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/23 16:08:00 by me #+# #+# */
/* Updated: 2022/08/12 18:12:23 by lperrey ### ########.fr */
/* Updated: 2022/08/14 22:14:06 by erlazo ### ########.fr */
/* */
/* ************************************************************************** */
@@ -59,7 +59,7 @@ public:
}
// works a lot better than using a compare function...
bool operator<(const LocationConfig& rhs) const
bool operator<(const LocationConfig& rhs) const
{
int comp_lhs = 0;
int comp_rhs = 0;
@@ -84,6 +84,12 @@ public:
return (comp_lhs < comp_rhs); // right comparison ? not <= ?
};
bool operator==(const LocationConfig& rhs) const
{
if (path.compare(rhs.path) == 0)
return true;
return false;
}
};

View File

@@ -46,6 +46,18 @@ void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
while (it_l != it->locations.end())
{
if (it_l->path[it_l->path.size() - 1] == '/'
&& it_l->path.size() > 1)
it_l->path.erase(it_l->path.size() - 1);
std::vector<LocationConfig>::const_iterator tmp = it_l + 1;
while (tmp != it->locations.end())
{
if (it_l->path == tmp->path)
throw std::invalid_argument("Duplicate locations in config file");
++tmp;
}
if (it_l->root == "")
it_l->root = it->root;
@@ -57,13 +69,6 @@ void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
// nothing to be done for cgi_ext, error_pages, redirect
// if (eval_file_type(it_l->root) == IS_DIR
// && it_l->path[it_l->path.size() - 1] != '/')
// it_l->path.push_back('/');
if (it_l->path[it_l->path.size() - 1] == '/'
&& it_l->path.size() > 1)
it_l->path.erase(it_l->path.size() - 1);
++it_l;
}
std::sort(it->locations.begin(), it->locations.end());

View File

@@ -19,7 +19,7 @@ int main(int ac, char **av)
ConfigParser configParser(config.c_str());
// configParser._print_content();
configParser._print_content();
// i don't love that servers has to be a pointer...
std::vector<ServerConfig>* servers = configParser.parse();
@@ -28,8 +28,8 @@ int main(int ac, char **av)
for (std::vector<ServerConfig>::iterator it = servers->begin(); it < servers->end(); it++)
{
(void)0;
// std::cout << it->server_name << " ";
// it->print_all();
// std::cout << it->server_name << " ";
it->print_all();
}