X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/abe068d00ecc304c855886f5e511b563b352dd0a..6c05b2e63b58b19df2f35707fa12f238a18458e7:/stglibs/srvconf.lib/parsers/get_user.cpp diff --git a/stglibs/srvconf.lib/parsers/get_user.cpp b/stglibs/srvconf.lib/parsers/get_user.cpp index 71e6cba6..54cfc0f9 100644 --- a/stglibs/srvconf.lib/parsers/get_user.cpp +++ b/stglibs/srvconf.lib/parsers/get_user.cpp @@ -25,7 +25,6 @@ #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; -}