X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/641204dfbdb9fc870cdd2e7f9e3169a44693e7bf..c2d2b5b171463c34e92b84290109a43f44823101:/stglibs/srvconf.lib/servconf.cpp?ds=inline diff --git a/stglibs/srvconf.lib/servconf.cpp b/stglibs/srvconf.lib/servconf.cpp index be6fa279..a7cac13c 100644 --- a/stglibs/srvconf.lib/servconf.cpp +++ b/stglibs/srvconf.lib/servconf.cpp @@ -24,8 +24,8 @@ $Author: faust $ */ -#include -#include +#include +#include #include "servconf.h" @@ -63,12 +63,9 @@ while (node != list1->end()) if (XML_Parse(sc->parser, ans, len, done) == XML_STATUS_ERROR) { - snprintf(sc->errorMsg, MAX_ERR_STR_LEN, "XML parse error at line %d: %s", - static_cast(XML_GetCurrentLineNumber(sc->parser)), - XML_ErrorString(XML_GetErrorCode(sc->parser))); - printf(sc->errorMsg, "XML parse error at line %d: %s", - XML_GetCurrentLineNumber(sc->parser), - XML_ErrorString(XML_GetErrorCode(sc->parser))); + strprintf(&sc->errorMsg, "XML parse error at line %d: %s", + static_cast(XML_GetCurrentLineNumber(sc->parser)), + XML_ErrorString(XML_GetErrorCode(sc->parser))); return st_xml_parse_error; } ++node; @@ -93,9 +90,23 @@ sc->End(el); } //----------------------------------------------------------------------------- SERVCONF::SERVCONF() + : currParser(NULL), + parseDepth(0), + error(0), + RecvUserDataCb(NULL), + RecvGetUserDataCb(NULL), + RecvServerInfoDataCb(NULL), + RecvChgUserCb(NULL), + RecvCheckUserCb(NULL), + RecvSendMessageCb(NULL), + getUserDataDataCb(NULL), + getUsersDataDataCb(NULL), + getServerInfoDataCb(NULL), + chgUserDataCb(NULL), + checkUserDataCb(NULL), + sendMessageDataCb(NULL) { parser = XML_ParserCreate(NULL); -parseDepth = 0; } //----------------------------------------------------------------------------- void SERVCONF::SetServer(const char * server) @@ -132,17 +143,17 @@ nt.SetRxCallback(this, AnsRecv); if ((ret = nt.Connect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Transact(request)) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Disconnect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } @@ -162,17 +173,17 @@ nt.SetRxCallback(this, AnsRecv); if ((ret = nt.Connect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Transact(request)) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Disconnect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } @@ -195,17 +206,17 @@ nt.SetRxCallback(this, AnsRecv); if ((ret = nt.Connect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Transact(request)) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Disconnect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } @@ -225,17 +236,17 @@ nt.SetRxCallback(this, AnsRecv); if ((ret = nt.Connect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Transact(request)) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Disconnect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } @@ -254,20 +265,17 @@ nt.SetRxCallback(this, AnsRecv); if ((ret = nt.Connect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); - printfd(__FILE__, "Error on connect: '%s'\n", errorMsg); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Transact(request)) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); - printfd(__FILE__, "Error on transact: '%s'\n", errorMsg); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Disconnect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); - printfd(__FILE__, "Error on disconnect: '%s'\n", errorMsg); + errorMsg = nt.GetError(); return ret; } @@ -288,17 +296,17 @@ nt.SetRxCallback(this, AnsRecv); if ((ret = nt.Connect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Transact(request)) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Disconnect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } @@ -319,17 +327,17 @@ nt.SetRxCallback(this, AnsRecv); if ((ret = nt.Connect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Transact(request)) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } if ((ret = nt.Disconnect()) != st_ok) { - strncpy(errorMsg, nt.GetError(), MAX_ERR_STR_LEN); + errorMsg = nt.GetError(); return ret; } @@ -383,7 +391,7 @@ RecvSendMessageCb = f; sendMessageDataCb = data; } //----------------------------------------------------------------------------- -char * SERVCONF::GetStrError() +const std::string & SERVCONF::GetStrError() const { return errorMsg; } @@ -395,4 +403,3 @@ error = 0; return e; } //----------------------------------------------------------------------------- -