//-----------------------------------------------------------------------------
bool ProcessSetUser(const std::string & server,
int port,
- const std::string & admLogin,
- const std::string & admPasswd,
+ const std::string & login,
+ const std::string & password,
const std::string & str)
{
-SERVCONF sc;
-
-sc.SetServer(server.c_str());
-sc.SetPort(port);
-sc.SetAdmLogin(admLogin.c_str());
-sc.SetAdmPassword(admPasswd.c_str());
+SERVCONF sc(server, port, login, password);
ResultData data;
sc.SetChgUserCallback(RecvSetUserAnswer, &data);
const std::string & login, const std::string & password,
const std::string & requestString)
{
-SERVCONF sc;
-
-sc.SetServer(server.c_str());
-sc.SetPort(port);
-sc.SetAdmLogin(login.c_str());
-sc.SetAdmPassword(password.c_str());
+SERVCONF sc(server, port, login, password);
ResultData data;
sc.SetSendMessageCallback(SendMessageCallback, &data);
const std::string &login,
REQUEST & request)
{
-SERVCONF sc;
-
-sc.SetServer(server.c_str());
-sc.SetPort(port);
-sc.SetAdmLogin(admLogin.c_str());
-sc.SetAdmPassword(admPasswd.c_str());
+SERVCONF sc(server, port, admLogin, admPasswd);
GetUserData data(request, false);
const std::string &admPasswd,
const std::string &login)
{
-SERVCONF sc;
-
-sc.SetServer(server.c_str());
-sc.SetPort(port);
-sc.SetAdmLogin(admLogin.c_str());
-sc.SetAdmPassword(admPasswd.c_str());
+SERVCONF sc(server, port, admLogin, admPasswd);
ResultData data;
sc.SetAuthByCallback(RecvAuthByData, &data);
class NETTRANSACT
{
public:
- NETTRANSACT();
+ NETTRANSACT(const std::string & server, uint16_t port,
+ const std::string & login, const std::string & password);
int Transact(const char * data);
const std::string & GetError() const;
void SetRxCallback(void * data, RxCallback_t);
- void SetServer(const char * serverName);
- void SetServerPort(short unsigned p);
-
- void SetLogin(const char * l);
- void SetPassword(const char * p);
- ////////////////////////////////////////////
int Connect();
int Disconnect();
void Reset();
void Decrypt(char * d, const char * s, BLOWFISH_CTX *ctx);
std::string server;
- short unsigned port;
+ uint16_t port;
std::string login;
std::string password;
int outerSocket;
#include <expat.h>
-void Start(void * data, const char * el, const char ** attr);
-void End(void * data, const char * el);
-
#define MAX_ERR_STR_LEN (64)
#define IP_STRING_LEN (255)
class SERVCONF
{
public:
- SERVCONF();
- void SetServer(const char * server);
- void SetPort(uint16_t port);
-
- void SetAdmLogin(const char * login);
- void SetAdmPassword(const char * password);
+ SERVCONF(const std::string & server, uint16_t port,
+ const std::string & login, const std::string & password);
void SetGetUsersCallback(PARSER_GET_USERS::CALLBACK f, void * data);
void SetAuthByCallback(PARSER_AUTH_BY::CALLBACK f, void * data);
#define RECV_HEADER_ANSWER_ERROR "Recv header answer error!"
//---------------------------------------------------------------------------
-NETTRANSACT::NETTRANSACT()
- : port(0),
+NETTRANSACT::NETTRANSACT(const std::string & s, uint16_t p,
+ const std::string & l, const std::string & pwd)
+ : server(s),
+ port(p),
+ login(l),
+ password(pwd),
outerSocket(-1),
RxCallBack(NULL),
dataRxCallBack(NULL)
}
}
//---------------------------------------------------------------------------
-void NETTRANSACT::SetLogin(const char * l)
-{
-login = l;
-}
-//---------------------------------------------------------------------------
-void NETTRANSACT::SetPassword(const char * p)
-{
-password = p;
-}
-//---------------------------------------------------------------------------
-void NETTRANSACT::SetServer(const char * serverName)
-{
-server = serverName;
-}
-//---------------------------------------------------------------------------
-void NETTRANSACT::SetServerPort(short unsigned p)
-{
-port = p;
-}
-//---------------------------------------------------------------------------
void NETTRANSACT::SetRxCallback(void * data, RxCallback_t cb)
{
RxCallBack = cb;
#include <cstdio>
#include <cstring>
+namespace
+{
+
+//-----------------------------------------------------------------------------
+void Start(void *data, const char *el, const char **attr)
+{
+SERVCONF * sc = static_cast<SERVCONF *>(data);
+sc->Start(el, attr);
+}
//-----------------------------------------------------------------------------
+void End(void * data, const char * el)
+{
+SERVCONF * sc = static_cast<SERVCONF *>(data);
+sc->End(el);
+}
+
+} // namespace anonymous
+
int AnsRecv(void * data, std::list<std::string> * list1)
{
SERVCONF * sc = static_cast<SERVCONF *>(data);
return st_ok;
}
+
//-----------------------------------------------------------------------------
-void Start(void *data, const char *el, const char **attr)
-{
-SERVCONF * sc = static_cast<SERVCONF *>(data);
-sc->Start(el, attr);
-}
-//-----------------------------------------------------------------------------
-void End(void * data, const char * el)
-{
-SERVCONF * sc = static_cast<SERVCONF *>(data);
-sc->End(el);
-}
-//-----------------------------------------------------------------------------
-SERVCONF::SERVCONF()
- : currParser(NULL)
+SERVCONF::SERVCONF(const std::string & server, uint16_t port,
+ const std::string & login, const std::string & password)
+ : currParser(NULL),
+ nt( server, port, login, password )
{
parser = XML_ParserCreate(NULL);
nt.SetRxCallback(this, AnsRecv);
}
//-----------------------------------------------------------------------------
-void SERVCONF::SetServer(const char * server)
-{
-nt.SetServer(server);
-}
-//-----------------------------------------------------------------------------
-void SERVCONF::SetPort(uint16_t port)
-{
-nt.SetServerPort(port);
-}
-//-----------------------------------------------------------------------------
-void SERVCONF::SetAdmLogin(const char * login)
-{
-nt.SetLogin(login);
-}
-//-----------------------------------------------------------------------------
-void SERVCONF::SetAdmPassword(const char * password)
-{
-nt.SetPassword(password);
-}
-//-----------------------------------------------------------------------------
int SERVCONF::GetUser(const char * l)
{
char request[255];