namespace
{
-//-----------------------------------------------------------------------------
-void ElementStart(void *data, const char *el, const char **attr)
+void ElementStart(void * data, const char * el, const char ** attr)
{
SERVCONF * sc = static_cast<SERVCONF *>(data);
sc->Start(el, attr);
}
-//-----------------------------------------------------------------------------
+
void ElementEnd(void * data, const char * el)
{
SERVCONF * sc = static_cast<SERVCONF *>(data);
bool AnsRecv(void * data, const std::string & chunk, bool final)
{
SERVCONF * sc = static_cast<SERVCONF *>(data);
-printf("Chunk: '%s', length: %d, final: %d\n", chunk.c_str(), chunk.length(), final);
if (XML_Parse(sc->parser, chunk.c_str(), chunk.length(), final) == XML_STATUS_ERROR)
{
char request[255];
snprintf(request, 255, "<GetUser login=\"%s\"/>", l);
-currParser = &parserGetUser;
-
-return Exec(request);
+return Exec(request, parserGetUser);
}
//-----------------------------------------------------------------------------
int SERVCONF::AuthBy(const char * l)
char request[255];
snprintf(request, 255, "<GetUserAuthBy login=\"%s\"/>", l);
-currParser = &parserAuthBy;
-
-return Exec(request);
+return Exec(request, parserAuthBy);
}
//-----------------------------------------------------------------------------
int SERVCONF::GetUsers()
{
char request[] = "<GetUsers/>";
-currParser = &parserGetUsers;
-
-return Exec(request);
+return Exec(request, parserGetUsers);
}
//-----------------------------------------------------------------------------
int SERVCONF::ServerInfo()
{
char request[] = "<GetServerInfo/>";
-currParser = &parserServerInfo;
-
-return Exec(request);
+return Exec(request, parserServerInfo);
}
//-----------------------------------------------------------------------------
int SERVCONF::ChgUser(const char * request)
{
-currParser = &parserChgUser;
-
-return Exec(request);
+return Exec(request, parserChgUser);
}
//-----------------------------------------------------------------------------
int SERVCONF::SendMessage(const char * request)
{
-currParser = &parserSendMessage;
-
-return Exec(request);
+return Exec(request, parserSendMessage);
}
//-----------------------------------------------------------------------------
int SERVCONF::CheckUser(const char * login, const char * password)
char request[255];
snprintf(request, 255, "<CheckUser login=\"%s\" password=\"%s\"/>", login, password);
-currParser = &parserCheckUser;
-
-return Exec(request);
+return Exec(request, parserCheckUser);
}
//-----------------------------------------------------------------------------
int SERVCONF::Start(const char * el, const char ** attr)
return errorMsg;
}
//-----------------------------------------------------------------------------
-int SERVCONF::Exec(const char * request)
+int SERVCONF::Exec(const char * request, PARSER & cp)
{
+currParser = &cp;
+
XML_ParserReset(parser, NULL);
XML_SetElementHandler(parser, ElementStart, ElementEnd);
XML_SetUserData(parser, this);