* Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
*/
- /*
- $Revision: 1.8 $
- $Date: 2010/08/04 00:40:38 $
- $Author: faust $
- */
-
#include "stg/servconf.h"
#include "stg/common.h"
#include <cstdio>
#include <cstring>
-using namespace std;
-
//-----------------------------------------------------------------------------
-int AnsRecv(void * data, list<string> * list1)
+int AnsRecv(void * data, std::list<std::string> * list1)
{
SERVCONF * sc = static_cast<SERVCONF *>(data);
int len, done = 0;
//loop parsing
-list<string>::iterator node;
+std::list<std::string>::iterator node;
node = list1->begin();
while (node != list1->end())
return st_xml_parse_error;
}
++node;
-
}
return st_ok;
//-----------------------------------------------------------------------------
void Start(void *data, const char *el, const char **attr)
{
-SERVCONF * sc;
-sc = (SERVCONF*)data;
+SERVCONF * sc = static_cast<SERVCONF *>(data);
sc->Start(el, attr);
}
//-----------------------------------------------------------------------------
-void End(void *data, const char *el)
+void End(void * data, const char * el)
{
-SERVCONF * sc;
-sc = (SERVCONF*)data;
+SERVCONF * sc = static_cast<SERVCONF *>(data);
sc->End(el);
}
//-----------------------------------------------------------------------------
SERVCONF::SERVCONF()
- : currParser(NULL),
- RecvSendMessageCb(NULL),
- sendMessageDataCb(NULL)
+ : currParser(NULL)
{
parser = XML_ParserCreate(NULL);
nt.SetRxCallback(this, AnsRecv);
currParser = &parserGetUsers;
-return Exec(request);
-}
-//-----------------------------------------------------------------------------
-int SERVCONF::SendMessage(const char * login, const char * message, int prio)
-{
-char request[1000];
-char msg[500];
-Encode12(msg, message, strlen(message));
-snprintf(request, 1000, "<Message login=\"%s\" priority=\"%d\" text=\"%s\"/>", login, prio, msg);
-
-currParser = &parserSendMessage;
-parserSendMessage.SetSendMessageRecvCb(RecvSendMessageCb, sendMessageDataCb);
-
return Exec(request);
}
//-----------------------------------------------------------------------------
return Exec(request);
}
//-----------------------------------------------------------------------------
-// TODO: remove this shit!
-//-----------------------------------------------------------------------------
-int SERVCONF::MsgUser(const char * request)
+int SERVCONF::SendMessage(const char * request)
{
currParser = &parserSendMessage;
-parserSendMessage.SetSendMessageRecvCb(RecvSendMessageCb, sendMessageDataCb);
return Exec(request);
}
return Exec(request);
}
//-----------------------------------------------------------------------------
-int SERVCONF::Start(const char *el, const char **attr)
+int SERVCONF::Start(const char * el, const char ** attr)
{
currParser->ParseStart(el, attr);
return 0;
}
//-----------------------------------------------------------------------------
-void SERVCONF::End(const char *el)
+void SERVCONF::End(const char * el)
{
currParser->ParseEnd(el);
}
parserCheckUser.SetCallback(f, data);
}
//-----------------------------------------------------------------------------
-void SERVCONF::SetSendMessageCb(RecvSendMessageCb_t f, void * data)
+void SERVCONF::SetSendMessageCallback(PARSER_SEND_MESSAGE::CALLBACK f, void * data)
{
-RecvSendMessageCb = f;
-sendMessageDataCb = data;
+parserSendMessage.SetCallback(f, data);
}
//-----------------------------------------------------------------------------
const std::string & SERVCONF::GetStrError() const