aboutsummaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/fetchAttributes.cpp1
-rw-r--r--src/net/imap/IMAPConnection.cpp10
-rw-r--r--src/net/imap/IMAPFolder.cpp18
-rw-r--r--src/net/imap/IMAPFolderStatus.cpp36
-rw-r--r--src/net/imap/IMAPMessage.cpp39
-rw-r--r--src/net/imap/IMAPMessagePart.cpp2
-rw-r--r--src/net/imap/IMAPMessagePartContentHandler.cpp4
-rw-r--r--src/net/imap/IMAPUtils.cpp10
-rw-r--r--src/net/maildir/format/courierMaildirFormat.cpp2
-rw-r--r--src/net/maildir/format/kmailMaildirFormat.cpp7
-rw-r--r--src/net/maildir/maildirFolder.cpp14
-rw-r--r--src/net/maildir/maildirMessage.cpp53
-rw-r--r--src/net/maildir/maildirMessagePart.cpp10
-rw-r--r--src/net/maildir/maildirStore.cpp2
-rw-r--r--src/net/maildir/maildirUtils.cpp8
-rw-r--r--src/net/messageSet.cpp12
-rw-r--r--src/net/pop3/POP3Connection.cpp6
-rw-r--r--src/net/pop3/POP3Folder.cpp18
-rw-r--r--src/net/pop3/POP3Message.cpp19
-rw-r--r--src/net/pop3/POP3Response.cpp22
-rw-r--r--src/net/sendmail/sendmailTransport.cpp6
-rw-r--r--src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp16
-rw-r--r--src/net/smtp/SMTPCommand.cpp4
-rw-r--r--src/net/smtp/SMTPConnection.cpp6
-rw-r--r--src/net/smtp/SMTPResponse.cpp4
-rw-r--r--src/net/smtp/SMTPTransport.cpp6
-rw-r--r--src/net/tls/gnutls/TLSSocket_GnuTLS.cpp40
-rw-r--r--src/net/tls/openssl/TLSSocket_OpenSSL.cpp36
28 files changed, 231 insertions, 180 deletions
diff --git a/src/net/fetchAttributes.cpp b/src/net/fetchAttributes.cpp
index b98e573f..85a41b8c 100644
--- a/src/net/fetchAttributes.cpp
+++ b/src/net/fetchAttributes.cpp
@@ -51,6 +51,7 @@ fetchAttributes::fetchAttributes(const int attribs)
fetchAttributes::fetchAttributes(const fetchAttributes& attribs)
+ : object()
{
m_predefinedAttribs = attribs.m_predefinedAttribs;
m_headers = attribs.m_headers;
diff --git a/src/net/imap/IMAPConnection.cpp b/src/net/imap/IMAPConnection.cpp
index 0dba1ecc..234c2b6a 100644
--- a/src/net/imap/IMAPConnection.cpp
+++ b/src/net/imap/IMAPConnection.cpp
@@ -394,10 +394,10 @@ void IMAPConnection::authenticateSASL()
}
byte_t* challenge = 0;
- long challengeLen = 0;
+ size_t challengeLen = 0;
byte_t* resp = 0;
- long respLen = 0;
+ size_t respLen = 0;
try
{
@@ -530,7 +530,7 @@ bool IMAPConnection::hasCapability(const string& capa)
const string normCapa = utility::stringUtils::toUpper(capa);
- for (unsigned int i = 0, n = m_capabilities.size() ; i < n ; ++i)
+ for (size_t i = 0, n = m_capabilities.size() ; i < n ; ++i)
{
if (m_capabilities[i] == normCapa)
return true;
@@ -566,7 +566,7 @@ bool IMAPConnection::processCapabilityResponseData(const IMAPParser::response* r
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
resp->continue_req_or_response_data();
- for (unsigned int i = 0 ; i < respDataList.size() ; ++i)
+ for (size_t i = 0 ; i < respDataList.size() ; ++i)
{
if (respDataList[i]->response_data() == NULL)
continue;
@@ -739,7 +739,7 @@ void IMAPConnection::send(bool tag, const string& what, bool end)
}
-void IMAPConnection::sendRaw(const char* buffer, const int count)
+void IMAPConnection::sendRaw(const byte_t* buffer, const size_t count)
{
m_socket->sendRaw(buffer, count);
}
diff --git a/src/net/imap/IMAPFolder.cpp b/src/net/imap/IMAPFolder.cpp
index 06d331df..fb98887c 100644
--- a/src/net/imap/IMAPFolder.cpp
+++ b/src/net/imap/IMAPFolder.cpp
@@ -791,8 +791,8 @@ void IMAPFolder::fetchMessages(std::vector <shared_ptr <message> >& msg, const f
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
resp->continue_req_or_response_data();
- const int total = msg.size();
- int current = 0;
+ const size_t total = msg.size();
+ size_t current = 0;
if (progress)
progress->start(total);
@@ -1005,7 +1005,7 @@ void IMAPFolder::addMessage(shared_ptr <vmime::message> msg, const int flags,
}
-void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int flags,
+void IMAPFolder::addMessage(utility::inputStream& is, const size_t size, const int flags,
vmime::datetime* date, utility::progressListener* progress)
{
shared_ptr <IMAPStore> store = m_store.lock();
@@ -1064,22 +1064,22 @@ void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int
}
// Send message data
- const int total = size;
- int current = 0;
+ const size_t total = size;
+ size_t current = 0;
if (progress)
progress->start(total);
- const socket::size_type blockSize = std::min(is.getBlockSize(),
+ const size_t blockSize = std::min(is.getBlockSize(),
static_cast <size_t>(m_connection->getSocket()->getBlockSize()));
- std::vector <char> vbuffer(blockSize);
- char* buffer = &vbuffer.front();
+ std::vector <byte_t> vbuffer(blockSize);
+ byte_t* buffer = &vbuffer.front();
while (!is.eof())
{
// Read some data from the input stream
- const int read = is.read(buffer, sizeof(buffer));
+ const size_t read = is.read(buffer, sizeof(buffer));
current += read;
// Put read data into socket output stream
diff --git a/src/net/imap/IMAPFolderStatus.cpp b/src/net/imap/IMAPFolderStatus.cpp
index 25c88b02..c78a40f3 100644
--- a/src/net/imap/IMAPFolderStatus.cpp
+++ b/src/net/imap/IMAPFolderStatus.cpp
@@ -115,7 +115,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
{
case IMAPParser::status_att_val::MESSAGES:
{
- const unsigned int count = (*jt)->value_as_number()->value();
+ const unsigned int count =
+ static_cast <unsigned int>((*jt)->value_as_number()->value());
if (m_count != count)
{
@@ -127,7 +128,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
}
case IMAPParser::status_att_val::UNSEEN:
{
- const unsigned int unseen = (*jt)->value_as_number()->value();
+ const unsigned int unseen =
+ static_cast <unsigned int>((*jt)->value_as_number()->value());
if (m_unseen != unseen)
{
@@ -139,7 +141,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
}
case IMAPParser::status_att_val::RECENT:
{
- const unsigned int recent = (*jt)->value_as_number()->value();
+ const unsigned int recent =
+ static_cast <unsigned int>((*jt)->value_as_number()->value());
if (m_recent != recent)
{
@@ -151,7 +154,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
}
case IMAPParser::status_att_val::UIDNEXT:
{
- const vmime_uint32 uidNext = (*jt)->value_as_number()->value();
+ const vmime_uint32 uidNext =
+ static_cast <vmime_uint32>((*jt)->value_as_number()->value());
if (m_uidNext != uidNext)
{
@@ -163,7 +167,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
}
case IMAPParser::status_att_val::UIDVALIDITY:
{
- const vmime_uint32 uidValidity = (*jt)->value_as_number()->value();
+ const vmime_uint32 uidValidity =
+ static_cast <vmime_uint32>((*jt)->value_as_number()->value());
if (m_uidValidity != uidValidity)
{
@@ -175,7 +180,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
}
case IMAPParser::status_att_val::HIGHESTMODSEQ:
{
- const vmime_uint64 highestModSeq = (*jt)->value_as_mod_sequence_value()->value();
+ const vmime_uint64 highestModSeq =
+ static_cast <vmime_uint64>((*jt)->value_as_mod_sequence_value()->value());
if (m_highestModSeq != highestModSeq)
{
@@ -191,7 +197,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
}
else if (resp->type() == IMAPParser::mailbox_data::EXISTS)
{
- const unsigned int count = resp->number()->value();
+ const unsigned int count =
+ static_cast <unsigned int>(resp->number()->value());
if (m_count != count)
{
@@ -201,7 +208,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
}
else if (resp->type() == IMAPParser::mailbox_data::RECENT)
{
- const unsigned int recent = resp->number()->value();
+ const unsigned int recent =
+ static_cast <unsigned int>(resp->number()->value());
if (m_recent != recent)
{
@@ -222,7 +230,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::resp_text_code* resp
{
case IMAPParser::resp_text_code::UIDVALIDITY:
{
- const vmime_uint32 uidValidity = resp->nz_number()->value();
+ const vmime_uint32 uidValidity =
+ static_cast <vmime_uint32>(resp->nz_number()->value());
if (m_uidValidity != uidValidity)
{
@@ -234,7 +243,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::resp_text_code* resp
}
case IMAPParser::resp_text_code::UIDNEXT:
{
- const vmime_uint32 uidNext = resp->nz_number()->value();
+ const vmime_uint32 uidNext =
+ static_cast <vmime_uint32>(resp->nz_number()->value());
if (m_uidNext != uidNext)
{
@@ -246,7 +256,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::resp_text_code* resp
}
case IMAPParser::resp_text_code::UNSEEN:
{
- const unsigned int unseen = resp->nz_number()->value();
+ const unsigned int unseen =
+ static_cast <unsigned int>(resp->nz_number()->value());
if (m_unseen != unseen)
{
@@ -258,7 +269,8 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::resp_text_code* resp
}
case IMAPParser::resp_text_code::HIGHESTMODSEQ:
{
- const vmime_uint64 highestModSeq = resp->mod_sequence_value()->value();
+ const vmime_uint64 highestModSeq =
+ static_cast <vmime_uint64>(resp->mod_sequence_value()->value());
if (m_highestModSeq != highestModSeq)
{
diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp
index ae51bfe8..c11aafc2 100644
--- a/src/net/imap/IMAPMessage.cpp
+++ b/src/net/imap/IMAPMessage.cpp
@@ -98,7 +98,7 @@ private:
IMAPMessage::IMAPMessage(shared_ptr <IMAPFolder> folder, const int num)
- : m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
+ : m_folder(folder), m_num(num), m_size(-1U), m_flags(FLAG_UNDEFINED),
m_expunged(false), m_modseq(0), m_structure(null)
{
folder->registerMessage(this);
@@ -146,9 +146,9 @@ vmime_uint64 IMAPMessage::getModSequence() const
}
-int IMAPMessage::getSize() const
+size_t IMAPMessage::getSize() const
{
- if (m_size == -1)
+ if (m_size == -1U)
throw exceptions::unfetched_object();
return (m_size);
@@ -197,28 +197,36 @@ shared_ptr <const header> IMAPMessage::getHeader() const
}
-void IMAPMessage::extract(utility::outputStream& os, utility::progressListener* progress,
- const int start, const int length, const bool peek) const
+void IMAPMessage::extract
+ (utility::outputStream& os,
+ utility::progressListener* progress,
+ const size_t start, const size_t length,
+ const bool peek) const
{
shared_ptr <const IMAPFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
- extractImpl(null, os, progress, start, length, EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0));
+ extractImpl(null, os, progress, start, length,
+ EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0));
}
void IMAPMessage::extractPart
- (shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress,
- const int start, const int length, const bool peek) const
+ (shared_ptr <const messagePart> p,
+ utility::outputStream& os,
+ utility::progressListener* progress,
+ const size_t start, const size_t length,
+ const bool peek) const
{
shared_ptr <const IMAPFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
- extractImpl(p, os, progress, start, length, EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0));
+ extractImpl(p, os, progress, start, length,
+ EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0));
}
@@ -253,9 +261,12 @@ void IMAPMessage::fetchPartHeaderForStructure(shared_ptr <messageStructure> str)
}
-void IMAPMessage::extractImpl(shared_ptr <const messagePart> p, utility::outputStream& os,
- utility::progressListener* progress, const int start,
- const int length, const int extractFlags) const
+void IMAPMessage::extractImpl
+ (shared_ptr <const messagePart> p,
+ utility::outputStream& os,
+ utility::progressListener* progress,
+ const size_t start, const size_t length,
+ const int extractFlags) const
{
shared_ptr <const IMAPFolder> folder = m_folder.lock();
@@ -340,7 +351,7 @@ void IMAPMessage::extractImpl(shared_ptr <const messagePart> p, utility::outputS
command << "]";
- if (start != 0 || length != -1)
+ if (start != 0 || length != static_cast <size_t>(-1))
command << "<" << start << "." << length << ">";
// Send the request
@@ -473,7 +484,7 @@ int IMAPMessage::processFetchResponse
}
case IMAPParser::msg_att_item::RFC822_SIZE:
{
- m_size = (*it)->number()->value();
+ m_size = static_cast <size_t>((*it)->number()->value());
break;
}
case IMAPParser::msg_att_item::BODY_SECTION:
diff --git a/src/net/imap/IMAPMessagePart.cpp b/src/net/imap/IMAPMessagePart.cpp
index 153470cf..eed885dc 100644
--- a/src/net/imap/IMAPMessagePart.cpp
+++ b/src/net/imap/IMAPMessagePart.cpp
@@ -104,7 +104,7 @@ const mediaType& IMAPMessagePart::getType() const
}
-int IMAPMessagePart::getSize() const
+size_t IMAPMessagePart::getSize() const
{
return m_size;
}
diff --git a/src/net/imap/IMAPMessagePartContentHandler.cpp b/src/net/imap/IMAPMessagePartContentHandler.cpp
index 7112e3d2..1f53f082 100644
--- a/src/net/imap/IMAPMessagePartContentHandler.cpp
+++ b/src/net/imap/IMAPMessagePartContentHandler.cpp
@@ -59,7 +59,7 @@ shared_ptr <contentHandler> IMAPMessagePartContentHandler::clone() const
void IMAPMessagePartContentHandler::generate
- (utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength) const
+ (utility::outputStream& os, const vmime::encoding& enc, const size_t maxLineLength) const
{
shared_ptr <IMAPMessage> msg = constCast <IMAPMessage>(m_message.lock());
shared_ptr <messagePart> part = constCast <messagePart>(m_part.lock());
@@ -165,7 +165,7 @@ void IMAPMessagePartContentHandler::extractRaw
}
-string::size_type IMAPMessagePartContentHandler::getLength() const
+size_t IMAPMessagePartContentHandler::getLength() const
{
return m_part.lock()->getSize();
}
diff --git a/src/net/imap/IMAPUtils.cpp b/src/net/imap/IMAPUtils.cpp
index bf310414..ff81ce71 100644
--- a/src/net/imap/IMAPUtils.cpp
+++ b/src/net/imap/IMAPUtils.cpp
@@ -190,9 +190,9 @@ const string IMAPUtils::toModifiedUTF7
int b = 0, k = 0;
bool base64 = false;
- string::size_type remaining = cvt.length();
+ size_t remaining = cvt.length();
- for (string::size_type i = 0, len = cvt.length() ; i < len ; )
+ for (size_t i = 0, len = cvt.length() ; i < len ; )
{
const unsigned char c = cvt[i];
@@ -206,7 +206,7 @@ const string IMAPUtils::toModifiedUTF7
continue;
}
- string::size_type n = 0;
+ size_t n = 0;
int ch = 0;
if (c < 0x80)
@@ -232,7 +232,7 @@ const string IMAPUtils::toModifiedUTF7
++i;
--remaining;
- for (string::size_type j = 0 ; j < n ; j++)
+ for (size_t j = 0 ; j < n ; j++)
{
if ((cvt[i + j] & 0xc0) != 0x80)
return ""; // error
@@ -280,7 +280,7 @@ const string IMAPUtils::toModifiedUTF7
base64 = false;
}
- out += static_cast <string::value_type>(ch);
+ out += static_cast <char>(ch);
if (ch == '&')
out += '-';
diff --git a/src/net/maildir/format/courierMaildirFormat.cpp b/src/net/maildir/format/courierMaildirFormat.cpp
index a948de3e..6d460d5e 100644
--- a/src/net/maildir/format/courierMaildirFormat.cpp
+++ b/src/net/maildir/format/courierMaildirFormat.cpp
@@ -242,7 +242,7 @@ const std::vector <folder::path> courierMaildirFormat::listFolders
const string dir = dirs[i].substr(1) + ".";
folder::path path;
- for (string::size_type pos = dir.find("."), prev = 0 ;
+ for (size_t pos = dir.find("."), prev = 0 ;
pos != string::npos ; prev = pos + 1, pos = dir.find(".", pos + 1))
{
const string comp = dir.substr(prev, pos - prev);
diff --git a/src/net/maildir/format/kmailMaildirFormat.cpp b/src/net/maildir/format/kmailMaildirFormat.cpp
index 70c9b909..975752a5 100644
--- a/src/net/maildir/format/kmailMaildirFormat.cpp
+++ b/src/net/maildir/format/kmailMaildirFormat.cpp
@@ -118,11 +118,12 @@ const utility::file::path kmailMaildirFormat::folderPathToFileSystemPath
// Root path
utility::file::path fsPath = getContext()->getStore()->getFileSystemPath();
- const int count = (type == CONTAINER_DIRECTORY
- ? path.getSize() : path.getSize() - 1);
+ const size_t pathSize = path.getSize();
+ const size_t count = (type == CONTAINER_DIRECTORY
+ ? pathSize : (pathSize >= 1 ? pathSize - 1 : 0));
// Parent folders
- for (int i = 0 ; i < count ; ++i)
+ for (size_t i = 0 ; i < count ; ++i)
{
utility::file::path::component comp(path[i]);
diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp
index f476d98a..660178ff 100644
--- a/src/net/maildir/maildirFolder.cpp
+++ b/src/net/maildir/maildirFolder.cpp
@@ -719,7 +719,7 @@ void maildirFolder::addMessage(shared_ptr <vmime::message> msg, const int flags,
}
-void maildirFolder::addMessage(utility::inputStream& is, const int size,
+void maildirFolder::addMessage(utility::inputStream& is, const size_t size,
const int flags, vmime::datetime* /* date */, utility::progressListener* progress)
{
shared_ptr <maildirStore> store = m_store.lock();
@@ -816,7 +816,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
const utility::file::path& dstDirPath,
const utility::file::path::component& filename,
- utility::inputStream& is, const utility::stream::size_type size,
+ utility::inputStream& is, const size_t size,
utility::progressListener* progress)
{
shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
@@ -834,12 +834,12 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
shared_ptr <utility::fileWriter> fw = file->getFileWriter();
shared_ptr <utility::outputStream> os = fw->getOutputStream();
- utility::stream::value_type buffer[65536];
- utility::stream::size_type total = 0;
+ byte_t buffer[65536];
+ size_t total = 0;
while (!is.eof())
{
- const utility::stream::size_type read = is.read(buffer, sizeof(buffer));
+ const size_t read = is.read(buffer, sizeof(buffer));
if (read != 0)
{
@@ -1185,8 +1185,8 @@ void maildirFolder::fetchMessages(std::vector <shared_ptr <message> >& msg,
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
- const int total = msg.size();
- int current = 0;
+ const size_t total = msg.size();
+ size_t current = 0;
if (progress)
progress->start(total);
diff --git a/src/net/maildir/maildirMessage.cpp b/src/net/maildir/maildirMessage.cpp
index 88d743b2..a14f067e 100644
--- a/src/net/maildir/maildirMessage.cpp
+++ b/src/net/maildir/maildirMessage.cpp
@@ -40,6 +40,7 @@
#include "vmime/platform.hpp"
#include "vmime/utility/outputStreamAdapter.hpp"
+#include "vmime/utility/stringUtils.hpp"
namespace vmime {
@@ -82,9 +83,9 @@ const message::uid maildirMessage::getUID() const
}
-int maildirMessage::getSize() const
+size_t maildirMessage::getSize() const
{
- if (m_size == -1)
+ if (m_size == static_cast <size_t>(-1))
throw exceptions::unfetched_object();
return (m_size);
@@ -145,16 +146,16 @@ void maildirMessage::setFlags(const int flags, const int mode)
void maildirMessage::extract(utility::outputStream& os,
- utility::progressListener* progress, const int start,
- const int length, const bool peek) const
+ utility::progressListener* progress, const size_t start,
+ const size_t length, const bool peek) const
{
extractImpl(os, progress, 0, m_size, start, length, peek);
}
void maildirMessage::extractPart(shared_ptr <const messagePart> p, utility::outputStream& os,
- utility::progressListener* progress, const int start,
- const int length, const bool peek) const
+ utility::progressListener* progress, const size_t start,
+ const size_t length, const bool peek) const
{
shared_ptr <const maildirMessagePart> mp = dynamicCast <const maildirMessagePart>(p);
@@ -164,7 +165,7 @@ void maildirMessage::extractPart(shared_ptr <const messagePart> p, utility::outp
void maildirMessage::extractImpl(utility::outputStream& os, utility::progressListener* progress,
- const int start, const int length, const int partialStart, const int partialLength,
+ const size_t start, const size_t length, const size_t partialStart, const size_t partialLength,
const bool /* peek */) const
{
shared_ptr <const maildirFolder> folder = m_folder.lock();
@@ -179,20 +180,19 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis
is->skip(start + partialStart);
- utility::stream::value_type buffer[8192];
- utility::stream::size_type remaining = (partialLength == -1 ? length
- : std::min(partialLength, length));
+ byte_t buffer[8192];
+ size_t remaining = (partialLength == static_cast <size_t>(-1)
+ ? length : std::min(partialLength, length));
- const int total = remaining;
- int current = 0;
+ const size_t total = remaining;
+ size_t current = 0;
if (progress)
progress->start(total);
while (!is->eof() && remaining > 0)
{
- const utility::stream::size_type read =
- is->read(buffer, std::min(remaining, sizeof(buffer)));
+ const size_t read = is->read(buffer, std::min(remaining, sizeof(buffer)));
remaining -= read;
current += read;
@@ -226,20 +226,19 @@ void maildirMessage::fetchPartHeader(shared_ptr <messagePart> p)
is->skip(mp->getHeaderParsedOffset());
- utility::stream::value_type buffer[1024];
- utility::stream::size_type remaining = mp->getHeaderParsedLength();
+ byte_t buffer[1024];
+ size_t remaining = mp->getHeaderParsedLength();
string contents;
contents.reserve(remaining);
while (!is->eof() && remaining > 0)
{
- const utility::stream::size_type read =
- is->read(buffer, std::min(remaining, sizeof(buffer)));
+ const size_t read = is->read(buffer, std::min(remaining, sizeof(buffer)));
remaining -= read;
- contents.append(buffer, read);
+ vmime::utility::stringUtils::appendBytesToString(contents, buffer, read);
}
mp->getOrCreateHeader().parse(contents);
@@ -279,30 +278,30 @@ void maildirMessage::fetch(shared_ptr <maildirFolder> msgFolder, const fetchAttr
// Need whole message contents for structure
if (options.has(fetchAttributes::STRUCTURE))
{
- utility::stream::value_type buffer[16384];
+ byte_t buffer[16384];
contents.reserve(file->getLength());
while (!is->eof())
{
- const utility::stream::size_type read = is->read(buffer, sizeof(buffer));
- contents.append(buffer, read);
+ const size_t read = is->read(buffer, sizeof(buffer));
+ vmime::utility::stringUtils::appendBytesToString(contents, buffer, read);
}
}
// Need only header
else
{
- utility::stream::value_type buffer[1024];
+ byte_t buffer[1024];
contents.reserve(4096);
while (!is->eof())
{
- const utility::stream::size_type read = is->read(buffer, sizeof(buffer));
- contents.append(buffer, read);
+ const size_t read = is->read(buffer, sizeof(buffer));
+ vmime::utility::stringUtils::appendBytesToString(contents, buffer, read);
- const string::size_type sep1 = contents.rfind("\r\n\r\n");
- const string::size_type sep2 = contents.rfind("\n\n");
+ const size_t sep1 = contents.rfind("\r\n\r\n");
+ const size_t sep2 = contents.rfind("\n\n");
if (sep1 != string::npos)
{
diff --git a/src/net/maildir/maildirMessagePart.cpp b/src/net/maildir/maildirMessagePart.cpp
index 683e259e..6ae085c9 100644
--- a/src/net/maildir/maildirMessagePart.cpp
+++ b/src/net/maildir/maildirMessagePart.cpp
@@ -93,7 +93,7 @@ const mediaType& maildirMessagePart::getType() const
}
-int maildirMessagePart::getSize() const
+size_t maildirMessagePart::getSize() const
{
return m_size;
}
@@ -123,25 +123,25 @@ header& maildirMessagePart::getOrCreateHeader()
}
-int maildirMessagePart::getHeaderParsedOffset() const
+size_t maildirMessagePart::getHeaderParsedOffset() const
{
return m_headerParsedOffset;
}
-int maildirMessagePart::getHeaderParsedLength() const
+size_t maildirMessagePart::getHeaderParsedLength() const
{
return m_headerParsedLength;
}
-int maildirMessagePart::getBodyParsedOffset() const
+size_t maildirMessagePart::getBodyParsedOffset() const
{
return m_bodyParsedOffset;
}
-int maildirMessagePart::getBodyParsedLength() const
+size_t maildirMessagePart::getBodyParsedLength() const
{
return m_bodyParsedLength;
}
diff --git a/src/net/maildir/maildirStore.cpp b/src/net/maildir/maildirStore.cpp
index c7ceb6fa..87e733e2 100644
--- a/src/net/maildir/maildirStore.cpp
+++ b/src/net/maildir/maildirStore.cpp
@@ -122,7 +122,7 @@ bool maildirStore::isValidFolderName(const folder::path::component& name) const
return false;
// Name cannot start with '.'
- const int length = buf.length();
+ const size_t length = buf.length();
int pos = 0;
while ((pos < length) && (buf[pos] == '.'))
diff --git a/src/net/maildir/maildirUtils.cpp b/src/net/maildir/maildirUtils.cpp
index 5a5ac90f..77aac715 100644
--- a/src/net/maildir/maildirUtils.cpp
+++ b/src/net/maildir/maildirUtils.cpp
@@ -71,7 +71,7 @@ bool maildirUtils::isMessageFile(const utility::file& file)
const utility::file::path::component maildirUtils::extractId
(const utility::file::path::component& filename)
{
- string::size_type sep = filename.getBuffer().rfind(':'); // try colon
+ size_t sep = filename.getBuffer().rfind(':'); // try colon
if (sep == string::npos)
{
@@ -86,7 +86,7 @@ const utility::file::path::component maildirUtils::extractId
int maildirUtils::extractFlags(const utility::file::path::component& comp)
{
- string::size_type sep = comp.getBuffer().rfind(':'); // try colon
+ size_t sep = comp.getBuffer().rfind(':'); // try colon
if (sep == string::npos)
{
@@ -95,11 +95,11 @@ int maildirUtils::extractFlags(const utility::file::path::component& comp)
}
const string flagsString(comp.getBuffer().begin() + sep + 1, comp.getBuffer().end());
- const string::size_type count = flagsString.length();
+ const size_t count = flagsString.length();
int flags = 0;
- for (string::size_type i = 0 ; i < count ; ++i)
+ for (size_t i = 0 ; i < count ; ++i)
{
switch (flagsString[i])
{
diff --git a/src/net/messageSet.cpp b/src/net/messageSet.cpp
index 71a8a788..2939042e 100644
--- a/src/net/messageSet.cpp
+++ b/src/net/messageSet.cpp
@@ -151,14 +151,14 @@ messageSet::messageSet(const messageSet& other)
{
m_ranges.resize(other.m_ranges.size());
- for (unsigned int i = 0, n = other.m_ranges.size() ; i < n ; ++i)
+ for (size_t i = 0, n = other.m_ranges.size() ; i < n ; ++i)
m_ranges[i] = other.m_ranges[i]->clone();
}
messageSet::~messageSet()
{
- for (unsigned int i = 0, n = m_ranges.size() ; i < n ; ++i)
+ for (size_t i = 0, n = m_ranges.size() ; i < n ; ++i)
delete m_ranges[i];
}
@@ -256,12 +256,12 @@ messageSet messageSet::byUID(const std::vector <message::uid>& uids)
{
std::vector <vmime_uint32> numericUIDs;
- for (unsigned int i = 0, n = uids.size() ; i < n ; ++i)
+ for (size_t i = 0, n = uids.size() ; i < n ; ++i)
{
const string uid = uids[i];
int numericUID = 0;
- const string::value_type* p = uid.c_str();
+ const char* p = uid.c_str();
for ( ; *p >= '0' && *p <= '9' ; ++p)
numericUID = (numericUID * 10) + (*p - '0');
@@ -271,7 +271,7 @@ messageSet messageSet::byUID(const std::vector <message::uid>& uids)
messageSet set;
// Non-numeric UID, fall back to plain UID list (single-UID ranges)
- for (unsigned int i = 0, n = uids.size() ; i < n ; ++i)
+ for (size_t i = 0, n = uids.size() ; i < n ; ++i)
set.m_ranges.push_back(new UIDMessageRange(uids[i]));
return set;
@@ -342,7 +342,7 @@ void messageSet::addRange(const messageRange& range)
void messageSet::enumerate(messageSetEnumerator& en) const
{
- for (unsigned int i = 0, n = m_ranges.size() ; i < n ; ++i)
+ for (size_t i = 0, n = m_ranges.size() ; i < n ; ++i)
m_ranges[i]->enumerate(en);
}
diff --git a/src/net/pop3/POP3Connection.cpp b/src/net/pop3/POP3Connection.cpp
index 547ef5ef..5fa923f4 100644
--- a/src/net/pop3/POP3Connection.cpp
+++ b/src/net/pop3/POP3Connection.cpp
@@ -463,10 +463,10 @@ void POP3Connection::authenticateSASL()
case POP3Response::CODE_READY:
{
byte_t* challenge = 0;
- long challengeLen = 0;
+ size_t challengeLen = 0;
byte_t* resp = 0;
- long respLen = 0;
+ size_t respLen = 0;
try
{
@@ -495,7 +495,7 @@ void POP3Connection::authenticateSASL()
}
// Cancel SASL exchange
- m_socket->sendRaw("*\r\n", 3);
+ m_socket->send("*\r\n");
}
catch (...)
{
diff --git a/src/net/pop3/POP3Folder.cpp b/src/net/pop3/POP3Folder.cpp
index 66ace31c..096de8af 100644
--- a/src/net/pop3/POP3Folder.cpp
+++ b/src/net/pop3/POP3Folder.cpp
@@ -318,8 +318,8 @@ void POP3Folder::fetchMessages(std::vector <shared_ptr <message> >& msg, const f
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
- const int total = msg.size();
- int current = 0;
+ const size_t total = msg.size();
+ size_t current = 0;
if (progress)
progress->start(total);
@@ -362,7 +362,7 @@ void POP3Folder::fetchMessages(std::vector <shared_ptr <message> >& msg, const f
if (x != result.end())
{
- int size = 0;
+ size_t size = 0;
std::istringstream iss((*x).second);
iss >> size;
@@ -446,7 +446,7 @@ void POP3Folder::fetchMessage(shared_ptr <message> msg, const fetchAttributes& o
if (it != responseText.end())
{
- int size = 0;
+ size_t size = 0;
std::istringstream iss(string(it, responseText.end()));
iss >> size;
@@ -601,15 +601,17 @@ void POP3Folder::rename(const folder::path& /* newPath */)
}
-void POP3Folder::addMessage(shared_ptr <vmime::message> /* msg */, const int /* flags */,
- vmime::datetime* /* date */, utility::progressListener* /* progress */)
+void POP3Folder::addMessage
+ (shared_ptr <vmime::message> /* msg */, const int /* flags */,
+ vmime::datetime* /* date */, utility::progressListener* /* progress */)
{
throw exceptions::operation_not_supported();
}
-void POP3Folder::addMessage(utility::inputStream& /* is */, const int /* size */, const int /* flags */,
- vmime::datetime* /* date */, utility::progressListener* /* progress */)
+void POP3Folder::addMessage
+ (utility::inputStream& /* is */, const size_t /* size */, const int /* flags */,
+ vmime::datetime* /* date */, utility::progressListener* /* progress */)
{
throw exceptions::operation_not_supported();
}
diff --git a/src/net/pop3/POP3Message.cpp b/src/net/pop3/POP3Message.cpp
index 5f0fb725..08523611 100644
--- a/src/net/pop3/POP3Message.cpp
+++ b/src/net/pop3/POP3Message.cpp
@@ -78,9 +78,9 @@ const message::uid POP3Message::getUID() const
}
-int POP3Message::getSize() const
+size_t POP3Message::getSize() const
{
- if (m_size == -1)
+ if (m_size == static_cast <size_t>(-1))
throw exceptions::unfetched_object();
return (m_size);
@@ -125,9 +125,11 @@ shared_ptr <const header> POP3Message::getHeader() const
}
-void POP3Message::extract(utility::outputStream& os,
- utility::progressListener* progress, const int start,
- const int length, const bool /* peek */) const
+void POP3Message::extract
+ (utility::outputStream& os,
+ utility::progressListener* progress,
+ const size_t start, const size_t length,
+ const bool /* peek */) const
{
shared_ptr <const POP3Folder> folder = m_folder.lock();
@@ -136,7 +138,7 @@ void POP3Message::extract(utility::outputStream& os,
else if (!folder->getStore())
throw exceptions::illegal_state("Store disconnected");
- if (start != 0 && length != -1)
+ if (start != 0 && length != static_cast <size_t>(-1))
throw exceptions::partial_fetch_not_supported();
// Emit the "RETR" command
@@ -157,9 +159,10 @@ void POP3Message::extract(utility::outputStream& os,
void POP3Message::extractPart
- (shared_ptr <const messagePart> /* p */, utility::outputStream& /* os */,
+ (shared_ptr <const messagePart> /* p */,
+ utility::outputStream& /* os */,
utility::progressListener* /* progress */,
- const int /* start */, const int /* length */,
+ const size_t /* start */, const size_t /* length */,
const bool /* peek */) const
{
throw exceptions::operation_not_supported();
diff --git a/src/net/pop3/POP3Response.cpp b/src/net/pop3/POP3Response.cpp
index e24634c6..1dc5ee76 100644
--- a/src/net/pop3/POP3Response.cpp
+++ b/src/net/pop3/POP3Response.cpp
@@ -98,7 +98,7 @@ shared_ptr <POP3Response> POP3Response::readMultilineResponse(shared_ptr <POP3Co
// static
shared_ptr <POP3Response> POP3Response::readLargeResponse
(shared_ptr <POP3Connection> conn, utility::outputStream& os,
- utility::progressListener* progress, const long predictedSize)
+ utility::progressListener* progress, const size_t predictedSize)
{
shared_ptr <POP3Response> resp = shared_ptr <POP3Response>
(new POP3Response(conn->getSocket(), conn->getTimeoutHandler()));
@@ -159,7 +159,7 @@ void POP3Response::readResponseImpl(string& buffer, const bool multiLine)
buffer.clear();
- string::value_type last1 = '\0', last2 = '\0';
+ char last1 = '\0', last2 = '\0';
for ( ; !foundTerminator ; )
{
@@ -187,7 +187,7 @@ void POP3Response::readResponseImpl(string& buffer, const bool multiLine)
m_timeoutHandler->resetTimeOut();
// Check for transparent characters: '\n..' becomes '\n.'
- const string::value_type first = receiveBuffer[0];
+ const char first = receiveBuffer[0];
if (first == '.' && last2 == '\n' && last1 == '.')
{
@@ -199,7 +199,7 @@ void POP3Response::readResponseImpl(string& buffer, const bool multiLine)
receiveBuffer.erase(receiveBuffer.begin());
}
- for (string::size_type trans ;
+ for (size_t trans ;
string::npos != (trans = receiveBuffer.find("\n..")) ; )
{
receiveBuffer.replace(trans, 3, "\n.");
@@ -228,9 +228,9 @@ void POP3Response::readResponseImpl(string& buffer, const bool multiLine)
void POP3Response::readResponseImpl
(string& firstLine, utility::outputStream& os,
- utility::progressListener* progress, const long predictedSize)
+ utility::progressListener* progress, const size_t predictedSize)
{
- long current = 0, total = predictedSize;
+ size_t current = 0, total = predictedSize;
string temp;
bool codeDone = false;
@@ -264,8 +264,8 @@ void POP3Response::readResponseImpl
}
// Receive data from the socket
- utility::stream::value_type buffer[65536];
- const utility::stream::size_type read = is.read(buffer, sizeof(buffer));
+ byte_t buffer[65536];
+ const size_t read = is.read(buffer, sizeof(buffer));
if (read == 0) // buffer is empty
{
@@ -289,7 +289,7 @@ void POP3Response::readResponseImpl
// If we don't have extracted the response code yet
if (!codeDone)
{
- temp.append(buffer, read);
+ vmime::utility::stringUtils::appendBytesToString(temp, buffer, read);
string responseData;
@@ -322,7 +322,7 @@ void POP3Response::readResponseImpl
bool POP3Response::stripFirstLine
(const string& buffer, string& result, string* firstLine)
{
- const string::size_type end = buffer.find('\n');
+ const size_t end = buffer.find('\n');
if (end != string::npos)
{
@@ -371,7 +371,7 @@ POP3Response::ResponseCode POP3Response::getResponseCode(const string& buffer)
// static
void POP3Response::stripResponseCode(const string& buffer, string& result)
{
- const string::size_type pos = buffer.find_first_of(" \t");
+ const size_t pos = buffer.find_first_of(" \t");
if (pos != string::npos)
result = buffer.substr(pos + 1);
diff --git a/src/net/sendmail/sendmailTransport.cpp b/src/net/sendmail/sendmailTransport.cpp
index 68c96e51..8ef18e3b 100644
--- a/src/net/sendmail/sendmailTransport.cpp
+++ b/src/net/sendmail/sendmailTransport.cpp
@@ -137,7 +137,7 @@ void sendmailTransport::noop()
void sendmailTransport::send
(const mailbox& expeditor, const mailboxList& recipients,
- utility::inputStream& is, const utility::stream::size_type size,
+ utility::inputStream& is, const size_t size,
utility::progressListener* progress, const mailbox& sender)
{
// If no recipient/expeditor was found, throw an exception
@@ -159,7 +159,7 @@ void sendmailTransport::send
args.push_back("--");
- for (int i = 0 ; i < recipients.getMailboxCount() ; ++i)
+ for (size_t i = 0 ; i < recipients.getMailboxCount() ; ++i)
args.push_back(recipients.getMailboxAt(i)->getEmail().generate());
// Call sendmail
@@ -176,7 +176,7 @@ void sendmailTransport::send
void sendmailTransport::internalSend
(const std::vector <string> args, utility::inputStream& is,
- const utility::stream::size_type size, utility::progressListener* progress)
+ const size_t size, utility::progressListener* progress)
{
const utility::file::path path = vmime::platform::getHandler()->
getFileSystemFactory()->stringToPath(m_sendmailPath);
diff --git a/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp b/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp
index 0584f7e6..69f63bc9 100644
--- a/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp
+++ b/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp
@@ -47,7 +47,7 @@ SMTPChunkingOutputStreamAdapter::SMTPChunkingOutputStreamAdapter(shared_ptr <SMT
void SMTPChunkingOutputStreamAdapter::sendChunk
- (const value_type* const data, const size_type count, const bool last)
+ (const byte_t* const data, const size_t count, const bool last)
{
if (count == 0 && !last)
{
@@ -96,17 +96,17 @@ void SMTPChunkingOutputStreamAdapter::sendChunk
}
-void SMTPChunkingOutputStreamAdapter::write
- (const value_type* const data, const size_type count)
+void SMTPChunkingOutputStreamAdapter::writeImpl
+ (const byte_t* const data, const size_t count)
{
- const value_type* curData = data;
- size_type curCount = count;
+ const byte_t* curData = data;
+ size_t curCount = count;
while (curCount != 0)
{
// Fill the buffer
- const size_type remaining = sizeof(m_buffer) - m_bufferSize;
- const size_type bytesToCopy = std::min(remaining, curCount);
+ const size_t remaining = sizeof(m_buffer) - m_bufferSize;
+ const size_t bytesToCopy = std::min(remaining, curCount);
std::copy(data, data + bytesToCopy, m_buffer + m_bufferSize);
@@ -131,7 +131,7 @@ void SMTPChunkingOutputStreamAdapter::flush()
}
-utility::stream::size_type SMTPChunkingOutputStreamAdapter::getBlockSize()
+size_t SMTPChunkingOutputStreamAdapter::getBlockSize()
{
return sizeof(m_buffer);
}
diff --git a/src/net/smtp/SMTPCommand.cpp b/src/net/smtp/SMTPCommand.cpp
index 6b3d1d79..949ab0c1 100644
--- a/src/net/smtp/SMTPCommand.cpp
+++ b/src/net/smtp/SMTPCommand.cpp
@@ -94,7 +94,7 @@ shared_ptr <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8)
// static
-shared_ptr <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const unsigned long size)
+shared_ptr <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const size_t size)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -160,7 +160,7 @@ shared_ptr <SMTPCommand> SMTPCommand::DATA()
// static
-shared_ptr <SMTPCommand> SMTPCommand::BDAT(const unsigned long chunkSize, const bool last)
+shared_ptr <SMTPCommand> SMTPCommand::BDAT(const size_t chunkSize, const bool last)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
diff --git a/src/net/smtp/SMTPConnection.cpp b/src/net/smtp/SMTPConnection.cpp
index 9fcacbc1..26be25db 100644
--- a/src/net/smtp/SMTPConnection.cpp
+++ b/src/net/smtp/SMTPConnection.cpp
@@ -396,10 +396,10 @@ void SMTPConnection::authenticateSASL()
case 334:
{
byte_t* challenge = 0;
- long challengeLen = 0;
+ size_t challengeLen = 0;
byte_t* resp = 0;
- long respLen = 0;
+ size_t respLen = 0;
try
{
@@ -428,7 +428,7 @@ void SMTPConnection::authenticateSASL()
}
// Cancel SASL exchange
- m_socket->sendRaw("*\r\n", 3);
+ m_socket->send("*\r\n");
}
catch (...)
{
diff --git a/src/net/smtp/SMTPResponse.cpp b/src/net/smtp/SMTPResponse.cpp
index baefc38d..f7980351 100644
--- a/src/net/smtp/SMTPResponse.cpp
+++ b/src/net/smtp/SMTPResponse.cpp
@@ -128,11 +128,11 @@ const string SMTPResponse::readResponseLine()
while (true)
{
// Get a line from the response buffer
- const string::size_type lineEnd = currentBuffer.find_first_of('\n');
+ const size_t lineEnd = currentBuffer.find_first_of('\n');
if (lineEnd != string::npos)
{
- string::size_type actualLineEnd = lineEnd;
+ size_t actualLineEnd = lineEnd;
if (actualLineEnd != 0 && currentBuffer[actualLineEnd - 1] == '\r') // CRLF case
actualLineEnd--;
diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp
index 4f409a03..0020d010 100644
--- a/src/net/smtp/SMTPTransport.cpp
+++ b/src/net/smtp/SMTPTransport.cpp
@@ -163,7 +163,7 @@ void SMTPTransport::noop()
void SMTPTransport::sendEnvelope
(const mailbox& expeditor, const mailboxList& recipients,
const mailbox& sender, bool sendDATACommand,
- const utility::stream::size_type size)
+ const size_t size)
{
// If no recipient/expeditor was found, throw an exception
if (recipients.isEmpty())
@@ -315,7 +315,7 @@ void SMTPTransport::sendEnvelope
void SMTPTransport::send
(const mailbox& expeditor, const mailboxList& recipients,
- utility::inputStream& is, const utility::stream::size_type size,
+ utility::inputStream& is, const size_t size,
utility::progressListener* progress, const mailbox& sender)
{
if (!isConnected())
@@ -334,7 +334,7 @@ void SMTPTransport::send
fos.flush();
// Send end-of-data delimiter
- m_connection->getSocket()->sendRaw("\r\n.\r\n", 5);
+ m_connection->getSocket()->send("\r\n.\r\n");
shared_ptr <SMTPResponse> resp;
diff --git a/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp b/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp
index bb21cb9d..5a90565b 100644
--- a/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp
+++ b/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp
@@ -37,6 +37,10 @@
#include "vmime/security/cert/X509Certificate.hpp"
+#include "vmime/utility/stringUtils.hpp"
+
+#include <cstring>
+
namespace vmime {
namespace net {
@@ -110,7 +114,7 @@ bool TLSSocket_GnuTLS::isConnected() const
}
-TLSSocket::size_type TLSSocket_GnuTLS::getBlockSize() const
+size_t TLSSocket_GnuTLS::getBlockSize() const
{
return 16384; // 16 KB
}
@@ -130,18 +134,24 @@ const string TLSSocket_GnuTLS::getPeerAddress() const
void TLSSocket_GnuTLS::receive(string& buffer)
{
- const int size = receiveRaw(m_buffer, sizeof(m_buffer));
- buffer = vmime::string(m_buffer, size);
+ const size_t size = receiveRaw(m_buffer, sizeof(m_buffer));
+ buffer = utility::stringUtils::makeStringFromBytes(m_buffer, size);
}
void TLSSocket_GnuTLS::send(const string& buffer)
{
- sendRaw(buffer.data(), buffer.length());
+ sendRaw(reinterpret_cast <const byte_t*>(buffer.data()), buffer.length());
}
-TLSSocket::size_type TLSSocket_GnuTLS::receiveRaw(char* buffer, const size_type count)
+void TLSSocket_GnuTLS::send(const char* str)
+{
+ sendRaw(reinterpret_cast <const byte_t*>(str), ::strlen(str));
+}
+
+
+size_t TLSSocket_GnuTLS::receiveRaw(byte_t* buffer, const size_t count)
{
m_status &= ~STATUS_WOULDBLOCK;
@@ -160,14 +170,14 @@ TLSSocket::size_type TLSSocket_GnuTLS::receiveRaw(char* buffer, const size_type
return 0;
}
- TLSSession_GnuTLS::throwTLSException("gnutls_record_recv", ret);
+ TLSSession_GnuTLS::throwTLSException("gnutls_record_recv", static_cast <int>(ret));
}
- return static_cast <size_type>(ret);
+ return static_cast <size_t>(ret);
}
-void TLSSocket_GnuTLS::sendRaw(const char* buffer, const size_type count)
+void TLSSocket_GnuTLS::sendRaw(const byte_t* buffer, const size_t count)
{
ssize_t ret = gnutls_record_send
(*m_session->m_gnutlsSession,
@@ -184,12 +194,12 @@ void TLSSocket_GnuTLS::sendRaw(const char* buffer, const size_type count)
return;
}
- TLSSession_GnuTLS::throwTLSException("gnutls_record_send", ret);
+ TLSSession_GnuTLS::throwTLSException("gnutls_record_send", static_cast <int>(ret));
}
}
-TLSSocket::size_type TLSSocket_GnuTLS::sendRawNonBlocking(const char* buffer, const size_type count)
+size_t TLSSocket_GnuTLS::sendRawNonBlocking(const byte_t* buffer, const size_t count)
{
ssize_t ret = gnutls_record_send
(*m_session->m_gnutlsSession,
@@ -209,7 +219,7 @@ TLSSocket::size_type TLSSocket_GnuTLS::sendRawNonBlocking(const char* buffer, co
TLSSession_GnuTLS::throwTLSException("gnutls_record_send", static_cast <int>(ret));
}
- return static_cast <size_type>(ret);
+ return static_cast <size_t>(ret);
}
@@ -288,7 +298,7 @@ ssize_t TLSSocket_GnuTLS::gnutlsPushFunc
try
{
sok->m_wrapped->sendRaw
- (reinterpret_cast <const char*>(data), static_cast <int>(len));
+ (reinterpret_cast <const byte_t*>(data), len);
}
catch (exception& e)
{
@@ -318,8 +328,7 @@ ssize_t TLSSocket_GnuTLS::gnutlsPullFunc
{
const ssize_t ret = static_cast <ssize_t>
(sok->m_wrapped->receiveRaw
- (reinterpret_cast <char*>(data),
- static_cast <int>(len)));
+ (reinterpret_cast <byte_t*>(data), len));
if (ret == 0)
{
@@ -345,8 +354,7 @@ ssize_t TLSSocket_GnuTLS::gnutlsPullFunc
{
const ssize_t n = static_cast <ssize_t>
(sok->m_wrapped->receiveRaw
- (reinterpret_cast <char*>(data),
- static_cast <int>(len)));
+ (reinterpret_cast <byte_t*>(data), len));
if (n == 0 && sok->m_wrapped->getStatus() & socket::STATUS_WOULDBLOCK)
return GNUTLS_E_AGAIN;
diff --git a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
index 9aec43e5..8f304c78 100644
--- a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
+++ b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
@@ -38,7 +38,10 @@
#include "vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp"
+#include "vmime/utility/stringUtils.hpp"
+
#include <vector>
+#include <cstring>
namespace vmime {
@@ -60,7 +63,8 @@ BIO_METHOD TLSSocket_OpenSSL::sm_customBIOMethod =
TLSSocket_OpenSSL::bio_gets,
TLSSocket_OpenSSL::bio_ctrl,
TLSSocket_OpenSSL::bio_create,
- TLSSocket_OpenSSL::bio_destroy
+ TLSSocket_OpenSSL::bio_destroy,
+ 0
};
@@ -160,7 +164,7 @@ bool TLSSocket_OpenSSL::isConnected() const
}
-TLSSocket::size_type TLSSocket_OpenSSL::getBlockSize() const
+size_t TLSSocket_OpenSSL::getBlockSize() const
{
return 16384; // 16 KB
}
@@ -180,20 +184,28 @@ const string TLSSocket_OpenSSL::getPeerAddress() const
void TLSSocket_OpenSSL::receive(string& buffer)
{
- const size_type size = receiveRaw(m_buffer, sizeof(m_buffer));
+ const size_t size = receiveRaw(m_buffer, sizeof(m_buffer));
- if (size >= 0)
- buffer = vmime::string(m_buffer, size);
+ if (size != 0)
+ buffer = utility::stringUtils::makeStringFromBytes(m_buffer, size);
+ else
+ buffer.clear();
}
void TLSSocket_OpenSSL::send(const string& buffer)
{
- sendRaw(buffer.data(), buffer.length());
+ sendRaw(reinterpret_cast <const byte_t*>(buffer.data()), buffer.length());
+}
+
+
+void TLSSocket_OpenSSL::send(const char* str)
+{
+ sendRaw(reinterpret_cast <const byte_t*>(str), ::strlen(str));
}
-TLSSocket::size_type TLSSocket_OpenSSL::receiveRaw(char* buffer, const size_type count)
+size_t TLSSocket_OpenSSL::receiveRaw(byte_t* buffer, const size_t count)
{
int rc = SSL_read(m_ssl, buffer, static_cast <int>(count));
handleError(rc);
@@ -205,14 +217,14 @@ TLSSocket::size_type TLSSocket_OpenSSL::receiveRaw(char* buffer, const size_type
}
-void TLSSocket_OpenSSL::sendRaw(const char* buffer, const size_type count)
+void TLSSocket_OpenSSL::sendRaw(const byte_t* buffer, const size_t count)
{
int rc = SSL_write(m_ssl, buffer, static_cast <int>(count));
handleError(rc);
}
-TLSSocket_OpenSSL::size_type TLSSocket_OpenSSL::sendRawNonBlocking(const char* buffer, const size_type count)
+size_t TLSSocket_OpenSSL::sendRawNonBlocking(const byte_t* buffer, const size_t count)
{
int rc = SSL_write(m_ssl, buffer, static_cast <int>(count));
handleError(rc);
@@ -391,7 +403,8 @@ int TLSSocket_OpenSSL::bio_write(BIO* bio, const char* buf, int len)
{
BIO_clear_retry_flags(bio);
- const size_type n = sok->m_wrapped->sendRawNonBlocking(buf, len);
+ const size_t n = sok->m_wrapped->sendRawNonBlocking
+ (reinterpret_cast <const byte_t*>(buf), len);
BIO_clear_retry_flags(bio);
@@ -422,7 +435,8 @@ int TLSSocket_OpenSSL::bio_read(BIO* bio, char* buf, int len)
try
{
- const size_type n = sok->m_wrapped->receiveRaw(buf, len);
+ const size_t n = sok->m_wrapped->receiveRaw
+ (reinterpret_cast <byte_t*>(buf), len);
BIO_clear_retry_flags(bio);