+PARSER_GET_SERVER_INFO::PARSER_GET_SERVER_INFO()
+ : RecvServerInfoDataCb(NULL),
+ serverInfoDataCb(NULL),
+ depth(0)
+{
+}
+//-----------------------------------------------------------------------------
+int PARSER_GET_SERVER_INFO::ParseStart(const char *el, const char **attr)
+{
+depth++;
+if (depth == 1)
+ {
+ if (strcasecmp(el, "ServerInfo") != 0)
+ {
+ //printf("%s\n", el);
+ }
+ }
+else
+ {
+ if (depth == 2)
+ {
+ if (strcasecmp(el, "uname") == 0)
+ {
+ ParseUname(attr);
+ return 0;
+ }
+ if (strcasecmp(el, "version") == 0)
+ {
+ ParseServerVersion(attr);
+ return 0;
+ }
+ if (strcasecmp(el, "tariff") == 0)
+ {
+ ParseTariffType(attr);
+ return 0;
+ }
+ if (strcasecmp(el, "dir_num") == 0)
+ {
+ ParseDirNum(attr);
+ return 0;
+ }
+ if (strcasecmp(el, "users_num") == 0)
+ {
+ ParseUsersNum(attr);
+ return 0;
+ }
+ if (strcasecmp(el, "tariff_num") == 0)
+ {
+ ParseTariffsNum(attr);
+ return 0;
+ }
+
+ for (int j = 0; j < DIR_NUM; j++)
+ {
+ char str[16];
+ sprintf(str, "dir_name_%d", j);
+ if (strcasecmp(el, str) == 0)
+ {
+ ParseDirName(attr, j);
+ }
+ }
+
+ }
+ }
+return 0;
+}
+//-----------------------------------------------------------------------------
+void PARSER_GET_SERVER_INFO::ParseEnd(const char *)
+{
+depth--;
+if (depth == 0)
+ {
+ RecvServerInfoDataCb(&serverInfo, serverInfoDataCb);
+ }
+}
+//-----------------------------------------------------------------------------
+/*void PARSER_GET_SERVER_INFO::ParseServerInfo(const char * el, const char ** attr)
+ {
+ }*/
+//-----------------------------------------------------------------------------
+void PARSER_GET_SERVER_INFO::SetServerInfoRecvCb(RecvServerInfoDataCb_t f, void * data)
+{
+RecvServerInfoDataCb = f;
+serverInfoDataCb = data;
+}
+//-----------------------------------------------------------------------------
+void PARSER_GET_SERVER_INFO::ParseUname(const char ** attr)
+{
+if (strcmp(*attr, "value") == 0)
+ serverInfo.uname = attr[1];
+}
+//-----------------------------------------------------------------------------
+void PARSER_GET_SERVER_INFO::ParseServerVersion(const char ** attr)
+{
+if (strcmp(*attr, "value") == 0)
+ serverInfo.version = attr[1];
+}
+//-----------------------------------------------------------------------------
+void PARSER_GET_SERVER_INFO::ParseUsersNum(const char ** attr)
+{
+if (strcmp(*attr, "value") == 0)
+ {
+ if (str2x(attr[1], serverInfo.usersNum) < 0)
+ {
+ serverInfo.usersNum = -1;
+ return;
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+void PARSER_GET_SERVER_INFO::ParseTariffsNum(const char ** attr)
+{
+if (strcmp(*attr, "value") == 0)
+ {
+ if (str2x(attr[1], serverInfo.tariffNum) < 0)
+ {
+ serverInfo.tariffNum = -1;
+ return;
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+void PARSER_GET_SERVER_INFO::ParseTariffType(const char ** attr)
+{
+if (strcmp(*attr, "value") == 0)
+ {
+ if (str2x(attr[1], serverInfo.tariffType) < 0)
+ {
+ serverInfo.tariffType = -1;
+ return;
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+void PARSER_GET_SERVER_INFO::ParseDirNum(const char **attr)
+{
+if (strcasecmp(*attr, "value") == 0)
+ {
+ if (str2x(attr[1], serverInfo.dirNum) < 0)
+ {
+ serverInfo.dirNum = -1;
+ return;
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+void PARSER_GET_SERVER_INFO::ParseDirName(const char **attr, int d)
+{
+if (strcmp(attr[0], "value") == 0)
+ {
+ char str[2*DIRNAME_LEN + 1];
+ Decode21(str, attr[1]);
+ serverInfo.dirName[d] = str;
+ }
+}
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+PARSER_AUTH_BY::PARSER_AUTH_BY()
+ : RecvAuthByDataCb(NULL),
+ authByDataCb(NULL),
+ depth(0)
+{
+}
+//-----------------------------------------------------------------------------
+int PARSER_AUTH_BY::ParseStart(const char *el, const char **attr)
+{
+depth++;
+if (depth == 1)
+ {
+ if (strcasecmp(el, "AuthorizedBy") != 0)
+ {
+ list.erase(list.begin(), list.end());
+ //printf("%s\n", el);
+ }
+ }
+else
+ {
+ if (depth == 2)
+ {
+ if (strcasecmp(el, "Auth") == 0)
+ {
+ if (attr && attr[0] && attr[1])
+ list.push_back(attr[1]);
+ return 0;
+ }
+ }
+ }
+return 0;
+}
+//-----------------------------------------------------------------------------
+void PARSER_AUTH_BY::ParseEnd(const char *)
+{
+depth--;
+if (depth == 0)
+ {
+ RecvAuthByDataCb(list, authByDataCb);
+ }
+}
+//-----------------------------------------------------------------------------
+void PARSER_AUTH_BY::SetRecvCb(RecvAuthByDataCb_t f, void * data)
+{
+RecvAuthByDataCb = f;
+authByDataCb = data;
+}
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------