s = "<AuthorizedBy>";
std::vector<std::string> list(u->GetAuthorizers());
for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it)
- s += "<Auth name=\"" + *it + "\">";
+ s += "<Auth name=\"" + *it + "\"/>";
s += "</AuthorizedBy>";
answerList->push_back(s);
template <typename varT>
const std::string & x2str(varT x, std::string & s);
template <typename varT>
-const std::string & x2str(varT x) { std::string s; return x2str(x, s); }
+std::string x2str(varT x) { std::string s; return x2str(x, s); }
template <typename varT>
const std::string & unsigned2str(varT x, std::string & s);
template <typename varT>
-const std::string & unsigned2str(varT x) { std::string s; return unsigned2str(x, s); }
+std::string unsigned2str(varT x) { std::string s; return unsigned2str(x, s); }
//-----------------------------------------------------------------------------
template <typename varT>
*/
//---------------------------------------------------------------------------
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <unistd.h>
+
+#include "stg/netunit.h"
+#include "stg/common.h"
#include <cstdio>
+#include <cerrno>
#include <cstring>
-#include "stg/netunit.h"
-#include "stg/common.h"
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <unistd.h>
//---------------------------------------------------------------------------
ret = recv(outerSocket, buffer, strlen(OK_HEADER), 0);
if (ret <= 0)
{
+ printf("Receive header answer error: '%s'\n", strerror(errno));
errorMsg = RECV_HEADER_ANSWER_ERROR;
return st_recv_fail;
}
ret = recv(outerSocket, buffer, strlen(OK_LOGIN), 0);
if (ret <= 0)
{
+ printf("Receive login answer error: '%s'\n", strerror(errno));
errorMsg = RECV_LOGIN_ANSWER_ERROR;
return st_recv_fail;
}
ret = recv(outerSocket, buffer, strlen(OK_LOGINS), 0);
if (ret <= 0)
{
+ printf("Receive secret login answer error: '%s'\n", strerror(errno));
errorMsg = RECV_LOGIN_ANSWER_ERROR;
return st_recv_fail;
}
ret = recv(outerSocket, &bufferS[n++], 1, 0);
if (ret <= 0)
{
+ printf("Receive data error: '%s'\n", strerror(errno));
close(outerSocket);
errorMsg = RECV_DATA_ANSWER_ERROR;
return st_recv_fail;
{
if (RxCallBack)
if (st_ok != RxCallBack(dataRxCallBack, &answerList))
- {
return st_xml_parse_error;
- }
return st_ok;
}
}
PARSER_GET_USER::STAT value;
if (!attr)
return value;
-std::map<std::string, long long &> props;
+std::map<std::string, long long *> props;
for (size_t i = 0; i < DIR_NUM; ++i)
{
- props.insert(std::pair<std::string, long long &>("su" + x2str(i), value.su[i]));
- props.insert(std::pair<std::string, long long &>("sd" + x2str(i), value.sd[i]));
- props.insert(std::pair<std::string, long long &>("mu" + x2str(i), value.mu[i]));
- props.insert(std::pair<std::string, long long &>("md" + x2str(i), value.md[i]));
+ props.insert(std::pair<std::string, long long *>("su" + x2str(i), &value.su[i]));
+ props.insert(std::pair<std::string, long long *>("sd" + x2str(i), &value.sd[i]));
+ props.insert(std::pair<std::string, long long *>("mu" + x2str(i), &value.mu[i]));
+ props.insert(std::pair<std::string, long long *>("md" + x2str(i), &value.md[i]));
}
size_t pos = 0;
while (attr[pos])
{
std::string name(ToLower(attr[pos++]));
- std::map<std::string, long long &>::iterator it(props.find(name));
+ std::map<std::string, long long *>::iterator it(props.find(name));
if (it != props.end())
- str2x(attr[pos++], it->second);
+ str2x(attr[pos++], *it->second);
}
return value;
}
//-----------------------------------------------------------------------------
int AnsRecv(void * data, list<string> * list1)
{
-//NODE * node;
-SERVCONF * sc;
-char ans[ENC_MSG_LEN + 1];
-int len, done = 0;
-
-sc = (SERVCONF*)data;
+SERVCONF * sc = static_cast<SERVCONF *>(data);
XML_ParserReset(sc->parser, NULL);
XML_SetElementHandler(sc->parser, Start, End);
XML_SetUserData(sc->parser, data);
+char ans[ENC_MSG_LEN + 1];
+int len, done = 0;
+
//loop parsing
list<string>::iterator node;
node = list1->begin();
-if (node == list1->end())
- {
- return st_ok;
- }
-
while (node != list1->end())
{
strncpy(ans, node->c_str(), ENC_MSG_LEN);
ans[ENC_MSG_LEN] = 0;
- //printf("---> %s\n", ans);
len = strlen(ans);
if (XML_Parse(sc->parser, ans, len, done) == XML_STATUS_ERROR)
strprintf(&sc->errorMsg, "XML parse error at line %d: %s",
static_cast<int>(XML_GetCurrentLineNumber(sc->parser)),
XML_ErrorString(XML_GetErrorCode(sc->parser)));
+ printf("%s\n", sc->errorMsg.c_str());
return st_xml_parse_error;
}
++node;
}
-return 0;
+return st_ok;
}
//-----------------------------------------------------------------------------
void Start(void *data, const char *el, const char **attr)