+#include "stg/common.h"
+#include "stg/netunit.h"
+#include "request.h"
+
#include <stdlib.h>
#include <stdio.h>
#include <expat.h>
#include <string.h>
-#include "common.h"
-#include "netunit.h"
-#include "request.h"
-
int parse_depth = 0;
XML_Parser parser;
//---------------------------------------------------------------------------
if (strcasecmp(el, "traff") == 0)
{
-// printf ("<traff>\n");
int j = 0;
- uint64_t t;
while (attr[j])
{
+ uint64_t t;
str2x(attr[j+1], t);
printf ("<%s>%lld</%s>\n", attr[j], t, attr[j]);
j+=2;
}
-// printf ("</traff>\n");
return;
}
else
printf ("<%s>%s</%s>\n", el, attr[1], el);
return;
}
-// }
parse_depth++;
if (parse_depth == 1)
{
void EndElement(void *, const char *el)
{
parse_depth--;
-if (strcasecmp(el, "ServerInfo") == 0 || strcasecmp(el, "Tariffs") == 0 || strcasecmp(el, "Admins") == 0 || strcasecmp(el, "Users") == 0 || strcasecmp(el, "tariff") == 0 || strcasecmp(el, "user") == 0)
- {
+if (strcasecmp(el, "ServerInfo") == 0 ||
+ strcasecmp(el, "Tariffs") == 0 ||
+ strcasecmp(el, "Admins") == 0 ||
+ strcasecmp(el, "Users") == 0 ||
+ strcasecmp(el, "tariff") == 0 ||
+ strcasecmp(el, "user") == 0)
printf ("</%s>\n", el);
- }
}
//---------------------------------------------------------------------------
int ParseReply(void *, list<string> * ans)
-//int ParseReply(void * data, SLIST * ans)
{
-//char answ[ENC_MSG_LEN + 1];
-int len;
int done = 0;
parse_depth = 0;
list<string>::iterator n = ans->begin();
while (n != ans->end())
{
- len = strlen(n->c_str());
+ int len = strlen(n->c_str());
if (++n == ans->end())
done = 1;
if (XML_Parse(parser, n->c_str(), len, done) == XML_STATUS_ERROR)
{
- char s[128];
- printf(s, "Parse error at line %d: %s",
+ printf("Parse error at line %d: %s",
XML_GetCurrentLineNumber(parser),
XML_ErrorString(XML_GetErrorCode(parser)));
return st_xml_parse_error;