From d3a440fa0a067b7dc79d96b2787041cbb50edb0a Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Mon, 22 Aug 2022 16:03:07 +0200 Subject: [PATCH] add Request::AddPostVar(pt::Space & space, const wchar_t * name) --- winixd/core/request.cpp | 39 +++++++++++++++++++++++++------------- winixd/core/request.h | 1 + winixd/core/requesttypes.h | 2 +- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/winixd/core/request.cpp b/winixd/core/request.cpp index 0a734e3..9b7d951 100644 --- a/winixd/core/request.cpp +++ b/winixd/core/request.cpp @@ -418,45 +418,44 @@ void Request::PrepareFrameNames() } } + + // add such a method to Space -bool Request::AddPostVar(const wchar_t * name, const wchar_t * value) +pt::Space * Request::AddPostVar(pt::Space & space, const wchar_t * name) { - bool status = false; - pt::Space * space_value = post_in.get_space(name); + pt::Space * space_value = space.get_space(name); + pt::Space * new_space = nullptr; Log * log = get_logger(); if( space_value ) { if( space_value->is_table() ) { - if( space_value->table_size() < WINIX_POSTTABLE_VALUT_TABLE_MAXSIZE ) + if( space_value->table_size() < WINIX_POSTTABLE_VALUE_TABLE_MAXSIZE ) { - status = true; - space_value->add(value); + new_space = &space_value->add_empty_space(); } else { if( log ) { - (*log) << log1 << "Request: more than " << WINIX_POSTTABLE_VALUT_TABLE_MAXSIZE << " post variables in a table " << name << " (skipping)" << logend; + (*log) << log1 << "Request: more than " << WINIX_POSTTABLE_VALUE_TABLE_MAXSIZE << " post variables in a table " << name << " (skipping)" << logend; } } } else { - status = true; pt::Space new_table; new_table.add(std::move(*space_value)); - new_table.add(value); + new_space = &new_table.add_empty_space(); space_value->set(std::move(new_table)); } } else { - if( post_in.object_size() < WINIX_POSTTABLE_MAXSIZE ) + if( space.object_size() < WINIX_POSTTABLE_MAXSIZE ) { - post_in.add(name, value); - status = true; + new_space = &space.add_empty_space(name); } else { @@ -467,7 +466,21 @@ bool Request::AddPostVar(const wchar_t * name, const wchar_t * value) } } - return status; + return new_space; +} + + + +bool Request::AddPostVar(const wchar_t * name, const wchar_t * value) +{ + pt::Space * new_space = AddPostVar(post_in, name); + + if( new_space ) + { + new_space->set(value); + } + + return new_space != nullptr; } diff --git a/winixd/core/request.h b/winixd/core/request.h index fccd543..f872b55 100644 --- a/winixd/core/request.h +++ b/winixd/core/request.h @@ -481,6 +481,7 @@ public: void RemoveParam(const wchar_t * param_name); void RemoveParam(const std::wstring & param_name); + pt::Space * AddPostVar(pt::Space & space, const wchar_t * name); bool AddPostVar(const wchar_t * name, const wchar_t * value); bool AddPostVar(const std::wstring & name, const std::wstring & value); diff --git a/winixd/core/requesttypes.h b/winixd/core/requesttypes.h index eec1333..cf9ad61 100644 --- a/winixd/core/requesttypes.h +++ b/winixd/core/requesttypes.h @@ -47,7 +47,7 @@ namespace Winix // may move to config? #define WINIX_POSTTABLE_MAXSIZE 1024 -#define WINIX_POSTTABLE_VALUT_TABLE_MAXSIZE 1024 +#define WINIX_POSTTABLE_VALUE_TABLE_MAXSIZE 1024 struct PostFile