X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/76fb825a64343da7a8aa9b16c5dbcab709504832..476796d9b898e096079fee2dc76b37daaca13fc8:/stglibs/srvconf.lib/parsers/get_user.cpp?ds=sidebyside diff --git a/stglibs/srvconf.lib/parsers/get_user.cpp b/stglibs/srvconf.lib/parsers/get_user.cpp index 2c398914..54cfc0f9 100644 --- a/stglibs/srvconf.lib/parsers/get_user.cpp +++ b/stglibs/srvconf.lib/parsers/get_user.cpp @@ -19,13 +19,12 @@ * Author : Maxim Mamontov */ -#include "parser_get_user.h" +#include "get_user.h" #include "stg/common.h" #include #include -#include #include @@ -42,10 +41,10 @@ if (!attr) std::map props; for (size_t i = 0; i < DIR_NUM; ++i) { - props.insert(std::pair("su" + x2str(i), &value.su[i])); - props.insert(std::pair("sd" + x2str(i), &value.sd[i])); - props.insert(std::pair("mu" + x2str(i), &value.mu[i])); - props.insert(std::pair("md" + x2str(i), &value.md[i])); + props.insert(std::pair("su" + unsigned2str(i), &value.su[i])); + props.insert(std::pair("sd" + unsigned2str(i), &value.sd[i])); + props.insert(std::pair("mu" + unsigned2str(i), &value.mu[i])); + props.insert(std::pair("md" + unsigned2str(i), &value.md[i])); } size_t pos = 0; while (attr[pos]) @@ -61,9 +60,9 @@ return true; } -GET_USER::PARSER::PARSER() - : callback(NULL), - data(NULL), +GET_USER::PARSER::PARSER(CALLBACK f, void * d) + : callback(f), + data(d), depth(0), parsingAnswer(false) { @@ -91,7 +90,7 @@ GET_USER::PARSER::PARSER() AddParser(propertyParsers, "traff", info.stat); for (size_t i = 0; i < USERDATA_NUM; ++i) - AddParser(propertyParsers, "userData" + x2str(i), info.userData[i], GetEncodedValue); + AddParser(propertyParsers, "userData" + unsigned2str(i), info.userData[i], GetEncodedValue); } //----------------------------------------------------------------------------- GET_USER::PARSER::~PARSER() @@ -128,6 +127,7 @@ if (depth == 0 && parsingAnswer) void GET_USER::PARSER::ParseUser(const char * el, const char ** attr) { if (strcasecmp(el, "user") == 0) + { if (attr && attr[0] && attr[1]) { if (strcasecmp(attr[1], "error") == 0) @@ -142,6 +142,7 @@ if (strcasecmp(el, "user") == 0) } else parsingAnswer = true; + } } //----------------------------------------------------------------------------- void GET_USER::PARSER::ParseUserParams(const char * el, const char ** attr) @@ -149,9 +150,3 @@ void GET_USER::PARSER::ParseUserParams(const char * el, const char ** attr) if (!TryParse(propertyParsers, ToLower(el), attr)) error = "Invalid parameter."; } -//----------------------------------------------------------------------------- -void GET_USER::PARSER::SetCallback(CALLBACK f, void * d) -{ -callback = f; -data = d; -}