X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/94e901e9f7b263786e227baa3c019fffc85c6b7d..46b0747592074017ff0ea4b33d4a7194235886e5:/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 deleted file mode 100644 index fbefb2d4..00000000 --- a/stglibs/srvconf.lib/parsers/server_info.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * Author : Boris Mikhailenko - * Author : Maxim Mamontov - */ - -#include "server_info.h" - -#include "stg/common.h" - -#include // sprintf - -#include - -using namespace STG; - -namespace -{ - -const size_t UNAME_LEN = 256; -const size_t SERV_VER_LEN = 64; -const size_t DIRNAME_LEN = 16; - -} - -SERVER_INFO::PARSER::PARSER(CALLBACK f, void * d) - : callback(f), - data(d), - depth(0), - parsingAnswer(false) -{ - AddParser(propertyParsers, "uname", info.uname); - AddParser(propertyParsers, "version", info.version); - AddParser(propertyParsers, "tariff", info.tariffType); - AddParser(propertyParsers, "dir_num", info.dirNum); - AddParser(propertyParsers, "users_num", info.usersNum); - AddParser(propertyParsers, "tariff_num", info.tariffNum); - - for (size_t i = 0; i < DIR_NUM; i++) - 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; -} -//----------------------------------------------------------------------------- -void SERVER_INFO::PARSER::ParseEnd(const char * /*el*/) -{ -depth--; -if (depth == 0 && parsingAnswer) - { - if (callback) - callback(error.empty(), error, info, data); - error.clear(); - parsingAnswer = false; - } -}