* Author : Maxim Mamontov <faust@stargazer.dp.ua>
*/
-#include "parser_server_info.h"
+#include "server_info.h"
#include "stg/common.h"
#include <cstdio> // sprintf
-#include <cstddef>
#include <strings.h>
}
-SERVER_INFO::PARSER::PARSER()
- : callback(NULL),
- data(NULL),
+SERVER_INFO::PARSER::PARSER(CALLBACK f, void * d)
+ : callback(f),
+ data(d),
depth(0),
parsingAnswer(false)
{
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;
}
//-----------------------------------------------------------------------------
parsingAnswer = false;
}
}
-//-----------------------------------------------------------------------------
-void SERVER_INFO::PARSER::SetCallback(CALLBACK f, void * d)
-{
-callback = f;
-data = d;
-}