mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
intermediate changes
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
[[server]]
|
[[server]]
|
||||||
name = "jopaserver"
|
name = "serv1"
|
||||||
host = "127.0.0.1"
|
host = "127.0.0.1"
|
||||||
port = 8080
|
port = 8080
|
||||||
error_page = "error.html"
|
error_page = "error.html"
|
||||||
@@ -20,3 +20,26 @@
|
|||||||
methods = ["GET"]
|
methods = ["GET"]
|
||||||
directory_list = false
|
directory_list = false
|
||||||
directory_fallback = "oops.html"
|
directory_fallback = "oops.html"
|
||||||
|
|
||||||
|
[[server]]
|
||||||
|
name = "2222"
|
||||||
|
host = "10.0.0.1"
|
||||||
|
port = 8081
|
||||||
|
error_page = "error2.html"
|
||||||
|
body_size_limit = 10
|
||||||
|
[[server.location]]
|
||||||
|
location = "/root2/"
|
||||||
|
# redirection ???
|
||||||
|
root = "/var/www/html/jopa.html"
|
||||||
|
methods = ["GET", "POST"]
|
||||||
|
directory_list = true
|
||||||
|
directory_fallback = "its_a_directory.html"
|
||||||
|
upload_accept = false
|
||||||
|
upload_dir = "/var/www/html/upload"
|
||||||
|
|
||||||
|
[[server.location]]
|
||||||
|
location = "/secret2/"
|
||||||
|
root = "/var/www/html/secret.html"
|
||||||
|
methods = ["GET"]
|
||||||
|
directory_list = false
|
||||||
|
directory_fallback = "oops.html"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class toml_node;
|
|||||||
/* typedef std::vector<TOMLMap *> TOMLArray; */
|
/* typedef std::vector<TOMLMap *> TOMLArray; */
|
||||||
/* typedef std::vector<TOMLArray *> TOMLArrayOfMap; */
|
/* typedef std::vector<TOMLArray *> TOMLArrayOfMap; */
|
||||||
typedef std::map<std::string, toml_node *> TOMLMap; // = JSONObject
|
typedef std::map<std::string, toml_node *> TOMLMap; // = JSONObject
|
||||||
typedef std::pair<std::string, std::vector<TOMLMap *> *> TOMLMapArray;
|
typedef std::vector<TOMLMap *> TOMLMapArray;
|
||||||
typedef std::vector<toml_node *> TOMLArray;
|
typedef std::vector<toml_node *> TOMLArray;
|
||||||
|
|
||||||
void display(TOMLMap *config);
|
void display(TOMLMap *config);
|
||||||
|
|||||||
@@ -88,6 +88,25 @@ class toml_node
|
|||||||
value.map_array = map_array;
|
value.map_array = map_array;
|
||||||
type = MAPARRAY;
|
type = MAPARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string *TOMLMap_to_string(TOMLMap *map)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
std::string *result = new std::string();
|
||||||
|
TOMLMap::iterator it;
|
||||||
|
|
||||||
|
for (it = map->begin(); it != map->end(); ++it)
|
||||||
|
{
|
||||||
|
ss << it->first
|
||||||
|
<< ": "
|
||||||
|
<< *(it->second->toString())
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
ss >> *result;
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
|
|
||||||
std::string *toString(void) const
|
std::string *toString(void) const
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
@@ -116,6 +135,28 @@ class toml_node
|
|||||||
*result += " ]";
|
*result += " ]";
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
case MAP:
|
||||||
|
{
|
||||||
|
return (TOMLMap_to_string(value.map));
|
||||||
|
}
|
||||||
|
case MAPARRAY:
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
std::string *result = new std::string();
|
||||||
|
TOMLMapArray::iterator it;
|
||||||
|
TOMLMapArray *map_array = value.map_array;
|
||||||
|
|
||||||
|
ss << std::endl;
|
||||||
|
for (it = map_array->begin(); it != map_array->end(); ++it)
|
||||||
|
{
|
||||||
|
ss << (TOMLMap_to_string(*it));
|
||||||
|
}
|
||||||
|
|
||||||
|
ss << "-------" << std::endl;
|
||||||
|
|
||||||
|
ss >> *result;
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
case BOOL:
|
case BOOL:
|
||||||
{
|
{
|
||||||
std::string *result;
|
std::string *result;
|
||||||
|
|||||||
@@ -36,6 +36,15 @@ namespace config
|
|||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (nextToken.type == MAPARRAY_DECL)
|
||||||
|
{
|
||||||
|
parseMapArray();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* take key make decision */
|
||||||
|
}
|
||||||
std::string key = nextToken.value;
|
std::string key = nextToken.value;
|
||||||
std::cerr << key << std::endl;
|
std::cerr << key << std::endl;
|
||||||
if (tokenizer.getToken().type != ASSIGN)
|
if (tokenizer.getToken().type != ASSIGN)
|
||||||
@@ -257,8 +266,8 @@ namespace config
|
|||||||
std::string key;
|
std::string key;
|
||||||
key = "";
|
key = "";
|
||||||
|
|
||||||
/* root = parseMap(); */
|
root = parseMap();
|
||||||
root = parseMapArray();
|
/* root = parseMapArray(); */
|
||||||
return (root);
|
return (root);
|
||||||
|
|
||||||
/* while (tokenizer.hasMoreTokens()) */
|
/* while (tokenizer.hasMoreTokens()) */
|
||||||
|
|||||||
@@ -23,7 +23,8 @@
|
|||||||
/* } */
|
/* } */
|
||||||
namespace config
|
namespace config
|
||||||
{
|
{
|
||||||
void display(toml_node *config)
|
|
||||||
|
void display(toml_node *root_node)
|
||||||
{
|
{
|
||||||
std::cout << ">>> printing config: <<<" << std::endl;
|
std::cout << ">>> printing config: <<<" << std::endl;
|
||||||
if (config->get_type() != toml_node::MAPARRAY)
|
if (config->get_type() != toml_node::MAPARRAY)
|
||||||
|
|||||||
Reference in New Issue
Block a user