2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19 * Author : Maxim Mamontov <faust@stargazer.dp.ua>
22 #include "server_info.h"
24 #include "stg/common.h"
26 #include <cstdio> // sprintf
32 SERVER_INFO::PARSER::PARSER(CALLBACK f, void * d, const std::string & e)
39 AddParser(propertyParsers, "uname", info.uname);
40 AddParser(propertyParsers, "version", info.version);
41 AddParser(propertyParsers, "tariff", info.tariffType);
42 AddParser(propertyParsers, "dir_num", info.dirNum);
43 AddParser(propertyParsers, "user_num", info.usersNum);
44 AddParser(propertyParsers, "tariff_num", info.tariffNum);
46 for (size_t i = 0; i < DIR_NUM; i++)
47 AddParser(propertyParsers, "dir_name_" + unsigned2str(i), info.dirName[i], GetEncodedValue);
49 //-----------------------------------------------------------------------------
50 int SERVER_INFO::PARSER::ParseStart(const char *el, const char **attr)
55 if (strcasecmp(el, "GetServerInfo") == 0)
60 if (depth == 2 && parsingAnswer)
61 if (!TryParse(propertyParsers, ToLower(el), attr, encoding))
62 error = "Invalid parameter.";
66 //-----------------------------------------------------------------------------
67 void SERVER_INFO::PARSER::ParseEnd(const char * /*el*/)
70 if (depth == 0 && parsingAnswer)
73 callback(error.empty(), error, info, data);
75 parsingAnswer = false;