X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/abe068d00ecc304c855886f5e511b563b352dd0a..e8755e448558202feb64092ef8b1d91569ecc7db:/stglibs/srvconf.lib/parsers/server_info.cpp diff --git a/stglibs/srvconf.lib/parsers/server_info.cpp b/stglibs/srvconf.lib/parsers/server_info.cpp index 1b637858..fbefb2d4 100644 --- a/stglibs/srvconf.lib/parsers/server_info.cpp +++ b/stglibs/srvconf.lib/parsers/server_info.cpp @@ -24,7 +24,6 @@ #include "stg/common.h" #include // sprintf -#include #include @@ -39,9 +38,9 @@ const size_t DIRNAME_LEN = 16; } -SERVER_INFO::PARSER::PARSER() - : callback(NULL), - data(NULL), +SERVER_INFO::PARSER::PARSER(CALLBACK f, void * d) + : callback(f), + data(d), depth(0), parsingAnswer(false) { @@ -53,19 +52,23 @@ SERVER_INFO::PARSER::PARSER() AddParser(propertyParsers, "tariff_num", info.tariffNum); for (size_t i = 0; i < DIR_NUM; i++) - AddParser(propertyParsers, "dir_name_" + x2str(i), info.dirName[i], GetEncodedValue); + AddParser(propertyParsers, "dir_name_" + unsigned2str(i), info.dirName[i], GetEncodedValue); } //----------------------------------------------------------------------------- int SERVER_INFO::PARSER::ParseStart(const char *el, const char **attr) { depth++; if (depth == 1) + { if (strcasecmp(el, "ServerInfo") == 0) parsingAnswer = true; + } else + { if (depth == 2 && parsingAnswer) if (!TryParse(propertyParsers, ToLower(el), attr)) error = "Invalid parameter."; + } return 0; } //----------------------------------------------------------------------------- @@ -80,9 +83,3 @@ if (depth == 0 && parsingAnswer) parsingAnswer = false; } } -//----------------------------------------------------------------------------- -void SERVER_INFO::PARSER::SetCallback(CALLBACK f, void * d) -{ -callback = f; -data = d; -}