#include <algorithm> // std::min
-#include <cstdio>
#include <cerrno>
#include <cstring>
#include <cassert>
namespace
{
-const std::string::size_type MAX_XML_CHUNK_LENGTH = 2048;
-
struct ReadState
{
bool final;
struct hostent * phe = gethostbyname(localAddress.c_str());
if (phe == NULL)
{
- errorMsg = "DNS error.\nCan not reslove " + localAddress;
+ errorMsg = "Can not reslove '" + localAddress + "'";
return st_dns_err;
}
struct hostent * phe = gethostbyname(server.c_str());
if (phe == NULL)
{
- errorMsg = "DNS error.\nCan not reslove " + server;
+ errorMsg = "Can not reslove '" + server + "'";
return st_dns_err;
}
if (!ReadAll(sock, buffer, strlen(OK_HEADER)))
{
- printf("Receive header answer error: '%s'\n", strerror(errno));
errorMsg = RECV_HEADER_ANSWER_ERROR;
return st_recv_fail;
}
if (!ReadAll(sock, buffer, strlen(OK_LOGIN)))
{
- printf("Receive login answer error: '%s'\n", strerror(errno));
errorMsg = RECV_LOGIN_ANSWER_ERROR;
return st_recv_fail;
}
if (!ReadAll(sock, buffer, strlen(OK_LOGINS)))
{
- printf("Receive secret login answer error: '%s'\n", strerror(errno));
errorMsg = RECV_LOGIN_ANSWER_ERROR;
return st_recv_fail;
}
{
STG::ENCRYPT_STREAM stream(password, TxCrypto, this);
stream.Put(text.c_str(), text.length() + 1, true);
-if (!stream.isOk())
+if (!stream.IsOk())
{
errorMsg = SEND_DATA_ERROR;
return st_send_fail;
ssize_t res = read(sock, buffer, sizeof(buffer));
if (res < 0)
{
- printf("Receive data error: '%s'\n", strerror(errno));
errorMsg = RECV_DATA_ANSWER_ERROR;
return st_recv_fail;
}
stream.Put(buffer, res, res == 0);
- if (!stream.isOk())
+ if (!stream.IsOk())
return st_xml_parse_error;
}