Simplified types for better readability. Use appropriate types (size_t, byte_t...). Minor warning fixes.

This commit is contained in:
Vincent Richard 2013-12-10 08:52:51 +01:00
parent 92fc0b34b0
commit 7e265b05f4
223 changed files with 2245 additions and 1969 deletions

View File

@ -67,8 +67,8 @@ address-list = (address *("," address)) / obs-addr-list
*/
shared_ptr <address> address::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition, bool *isLastAddressOfGroup)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition, bool *isLastAddressOfGroup)
{
bool escaped = false;
bool quoted = false;
@ -81,12 +81,12 @@ shared_ptr <address> address::parseNext
if (isLastAddressOfGroup)
*isLastAddressOfGroup = false;
string::size_type pos = position;
size_t pos = position;
while (pos < end && parserHelpers::isSpace(buffer[pos]))
++pos;
const string::size_type start = pos;
const size_t start = pos;
while (!stop && pos < end)
{

View File

@ -51,12 +51,12 @@ addressList::~addressList()
void addressList::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
removeAllAddresses();
string::size_type pos = position;
size_t pos = position;
while (pos < end)
{
@ -75,9 +75,9 @@ void addressList::parseImpl
void addressList::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
string::size_type pos = curLinePos;
size_t pos = curLinePos;
generationContext tmpCtx(ctx);
tmpCtx.setMaxLineLength(tmpCtx.getMaxLineLength() - 2);

View File

@ -86,7 +86,7 @@ const string libapi() { return (VMIME_API); }
// New line sequence to be used when folding header fields.
const string NEW_LINE_SEQUENCE = "\r\n ";
const string::size_type NEW_LINE_SEQUENCE_LENGTH = 1; // space
const size_t NEW_LINE_SEQUENCE_LENGTH = 1; // space
/** The CR-LF sequence.
*/
@ -110,10 +110,13 @@ nullPtrType null;
// Line length limits
namespace lineLengthLimits
{
const string::size_type infinite = std::numeric_limits <string::size_type>::max();
const size_t infinite = std::numeric_limits <size_t>::max();
}
const size_t npos = std::numeric_limits <size_t>::max();
#ifndef VMIME_BUILDING_DOC

View File

@ -55,30 +55,30 @@ body::~body()
// static
utility::stream::size_type body::findNextBoundaryPosition
size_t body::findNextBoundaryPosition
(shared_ptr <utility::parserInputStreamAdapter> parser, const string& boundary,
const utility::stream::size_type position, const utility::stream::size_type end,
utility::stream::size_type* boundaryStart, utility::stream::size_type* boundaryEnd)
const size_t position, const size_t end,
size_t* boundaryStart, size_t* boundaryEnd)
{
utility::stream::size_type pos = position;
size_t pos = position;
while (pos != utility::stream::npos && pos < end)
while (pos != npos && pos < end)
{
pos = parser->findNext(boundary, pos);
if (pos == utility::stream::npos)
if (pos == npos)
break; // not found
if (pos != 0)
{
// Skip transport padding bytes (SPACE or HTAB), if any
utility::stream::size_type advance = 0;
size_t advance = 0;
while (pos != 0)
{
parser->seek(pos - advance - 1);
const utility::stream::value_type c = parser->peekByte();
const byte_t c = parser->peekByte();
if (c == ' ' || c == '\t')
++advance;
@ -96,7 +96,7 @@ utility::stream::size_type body::findNextBoundaryPosition
{
parser->seek(pos + boundary.length());
const utility::stream::value_type next = parser->peekByte();
const byte_t next = parser->peekByte();
// Boundary should be followed by a new line or a dash
if (next == '\r' || next == '\n' || next == '-')
@ -130,9 +130,7 @@ utility::stream::size_type body::findNextBoundaryPosition
void body::parseImpl
(const parsingContext& /* ctx */,
shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end,
utility::stream::size_type* newPosition)
const size_t position, const size_t end, size_t* newPosition)
{
removeAllParts();
@ -174,7 +172,7 @@ void body::parseImpl
{
// No "boundary" parameter specified: we can try to
// guess it by scanning the body contents...
utility::stream::size_type pos = position;
size_t pos = position;
parser->seek(pos);
@ -186,23 +184,23 @@ void body::parseImpl
{
pos = parser->findNext("\n--", position);
if ((pos != utility::stream::npos) && (pos + 3 < end))
if ((pos != npos) && (pos + 3 < end))
pos += 3; // skip \n--
}
if ((pos != utility::stream::npos) && (pos < end))
if ((pos != npos) && (pos < end))
{
parser->seek(pos);
// Read some bytes after boundary separator
utility::stream::value_type buffer[256];
const utility::stream::size_type bufferLen =
byte_t buffer[256];
const size_t bufferLen =
parser->read(buffer, std::min(end - pos, sizeof(buffer) / sizeof(buffer[0])));
buffer[sizeof(buffer) / sizeof(buffer[0]) - 1] = '\0';
// Skip transport padding bytes (SPACE or HTAB), if any
utility::stream::size_type boundarySkip = 0;
size_t boundarySkip = 0;
while (boundarySkip < bufferLen && parserHelpers::isSpace(buffer[boundarySkip]))
++boundarySkip;
@ -210,10 +208,10 @@ void body::parseImpl
// Extract boundary from buffer (stop at first CR or LF).
// We have to stop after a reasonnably long boundary length (100)
// not to take the whole body contents for a boundary...
string::value_type boundaryBytes[100];
string::size_type boundaryLen = 0;
byte_t boundaryBytes[100];
size_t boundaryLen = 0;
for (string::value_type c = buffer[boundarySkip] ;
for (byte_t c = buffer[boundarySkip] ;
boundaryLen < bufferLen && boundaryLen < 100 && !(c == '\r' || c == '\n') ;
++boundaryLen, c = buffer[boundarySkip + boundaryLen])
{
@ -244,18 +242,18 @@ void body::parseImpl
// This is a multi-part body
if (isMultipart && !boundary.empty())
{
utility::stream::size_type partStart = position;
utility::stream::size_type pos = position;
size_t partStart = position;
size_t pos = position;
bool lastPart = false;
// Find the first boundary
utility::stream::size_type boundaryStart, boundaryEnd;
size_t boundaryStart, boundaryEnd;
pos = findNextBoundaryPosition(parser, boundary, pos, end, &boundaryStart, &boundaryEnd);
for (int index = 0 ; !lastPart && (pos != utility::stream::npos) && (pos < end) ; ++index)
for (int index = 0 ; !lastPart && (pos != npos) && (pos < end) ; ++index)
{
utility::stream::size_type partEnd = boundaryStart;
size_t partEnd = boundaryStart;
// Check whether it is the last part (boundary terminated by "--")
parser->seek(boundaryEnd);
@ -321,7 +319,7 @@ void body::parseImpl
m_contents = make_shared <emptyContentHandler>();
// Last part was not found: recover from missing boundary
if (!lastPart && pos == utility::stream::npos)
if (!lastPart && pos == npos)
{
shared_ptr <bodyPart> part = m_part->createChildPart();
@ -364,7 +362,7 @@ void body::parseImpl
}
// Extract the (encoded) contents
const utility::stream::size_type length = end - position;
const size_t length = end - position;
shared_ptr <utility::inputStream> contentStream =
make_shared <utility::seekableInputStreamRegionAdapter>
@ -416,7 +414,7 @@ text body::getActualEpilogText(const generationContext& ctx) const
void body::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type /* curLinePos */, string::size_type* newLinePos) const
const size_t /* curLinePos */, size_t* newLinePos) const
{
// MIME-Multipart
if (getPartCount() != 0)
@ -500,12 +498,12 @@ void body::generateImpl
}
utility::stream::size_type body::getGeneratedSize(const generationContext& ctx)
size_t body::getGeneratedSize(const generationContext& ctx)
{
// MIME-Multipart
if (getPartCount() != 0)
{
utility::stream::size_type size = 0;
size_t size = 0;
// Size of parts and boundaries
for (size_t p = 0 ; p < getPartCount() ; ++p)
@ -588,7 +586,7 @@ const string body::generateRandomBoundaryString()
this document.)
*/
string::value_type boundary[2 + 48 + 1] = { 0 };
char boundary[2 + 48 + 1] = { 0 };
boundary[0] = '=';
boundary[1] = '_';
@ -622,7 +620,7 @@ bool body::isValidBoundary(const string& boundary)
if (boundary.length() > 0 && boundary.length() < 70)
{
const string::value_type last = *(end - 1);
const char last = *(end - 1);
if (!(last == ' ' || last == '\t' || last == '\n'))
{

View File

@ -38,14 +38,11 @@ bodyPart::bodyPart()
void bodyPart::parseImpl
(const parsingContext& ctx,
shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end,
utility::stream::size_type* newPosition)
(const parsingContext& ctx, shared_ptr <utility::parserInputStreamAdapter> parser,
const size_t position, const size_t end, size_t* newPosition)
{
// Parse the headers
string::size_type pos = position;
size_t pos = position;
m_header->parse(ctx, parser, pos, end, &pos);
// Parse the body contents
@ -60,7 +57,7 @@ void bodyPart::parseImpl
void bodyPart::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type /* curLinePos */, string::size_type* newLinePos) const
const size_t /* curLinePos */, size_t* newLinePos) const
{
m_header->generate(ctx, os);
@ -73,7 +70,7 @@ void bodyPart::generateImpl
}
utility::stream::size_type bodyPart::getGeneratedSize(const generationContext& ctx)
size_t bodyPart::getGeneratedSize(const generationContext& ctx)
{
return m_header->getGeneratedSize(ctx) + 2 /* CRLF */ + m_body->getGeneratedSize(ctx);
}

View File

@ -58,8 +58,8 @@ charset::charset(const char* name)
void charset::parseImpl
(const parsingContext& /* ctx */, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& /* ctx */, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
m_name = utility::stringUtils::trim
(string(buffer.begin() + position, buffer.begin() + end));
@ -77,7 +77,7 @@ void charset::parseImpl
void charset::generateImpl
(const generationContext& /* ctx */, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
os << m_name;

View File

@ -44,11 +44,15 @@ extern "C"
// HACK: prototypes may differ depending on the compiler and/or system (the
// second parameter may or may not be 'const'). This relies on the compiler
// for choosing the right type.
class ICONV_HACK
class ICONV_IN_TYPE
{
public:
ICONV_HACK(const char** ptr) : m_ptr(ptr) { }
ICONV_IN_TYPE(const char** ptr) : m_ptr(ptr) { }
ICONV_IN_TYPE(const vmime::byte_t** ptr)
: m_ptr(reinterpret_cast <const char**>(ptr)) { }
operator const char**() { return m_ptr; }
operator char**() { return const_cast <char**>(m_ptr); }
@ -58,6 +62,22 @@ extern "C"
const char** m_ptr;
};
class ICONV_OUT_TYPE
{
public:
ICONV_OUT_TYPE(char** ptr) : m_ptr(ptr) { }
ICONV_OUT_TYPE(vmime::byte_t** ptr)
: m_ptr(reinterpret_cast <char**>(ptr)) { }
operator char**() { return m_ptr; }
private:
char** m_ptr;
};
#endif // VMIME_BUILDING_DOC
}
@ -69,14 +89,14 @@ void outputInvalidChar(OUTPUT_CLASS& out, ICONV_DESC cd,
const vmime::charsetConverterOptions& opts = vmime::charsetConverterOptions())
{
const char* invalidCharIn = opts.invalidSequence.c_str();
size_t invalidCharInLen = opts.invalidSequence.length();
vmime::size_t invalidCharInLen = opts.invalidSequence.length();
char invalidCharOutBuffer[16];
char* invalidCharOutPtr = invalidCharOutBuffer;
size_t invalidCharOutLen = 16;
vmime::byte_t invalidCharOutBuffer[16];
vmime::byte_t* invalidCharOutPtr = invalidCharOutBuffer;
vmime::size_t invalidCharOutLen = 16;
if (iconv(cd, ICONV_HACK(&invalidCharIn), &invalidCharInLen,
&invalidCharOutPtr, &invalidCharOutLen) != static_cast <size_t>(-1))
if (iconv(cd, ICONV_IN_TYPE(&invalidCharIn), &invalidCharInLen,
ICONV_OUT_TYPE(&invalidCharOutPtr), &invalidCharOutLen) != static_cast <size_t>(-1))
{
out.write(invalidCharOutBuffer, 16 - invalidCharOutLen);
}
@ -134,8 +154,8 @@ void charsetConverter_iconv::convert(utility::inputStream& in, utility::outputSt
const iconv_t cd = *static_cast <iconv_t*>(m_desc);
char inBuffer[32768];
char outBuffer[32768];
byte_t inBuffer[32768];
byte_t outBuffer[32768];
size_t inPos = 0;
bool prevIsInvalid = false;
@ -147,13 +167,13 @@ void charsetConverter_iconv::convert(utility::inputStream& in, utility::outputSt
size_t inLength = static_cast <size_t>(in.read(inBuffer + inPos, sizeof(inBuffer) - inPos) + inPos);
size_t outLength = sizeof(outBuffer);
const char* inPtr = breakAfterNext ? NULL : inBuffer;
const byte_t* inPtr = breakAfterNext ? NULL : inBuffer;
size_t *ptrLength = breakAfterNext ? NULL : &inLength;
char* outPtr = outBuffer;
byte_t* outPtr = outBuffer;
// Convert input bytes
if (iconv(cd, ICONV_HACK(&inPtr), ptrLength,
&outPtr, &outLength) == static_cast <size_t>(-1))
if (iconv(cd, ICONV_IN_TYPE(&inPtr), ptrLength,
ICONV_OUT_TYPE(&outPtr), &outLength) == static_cast <size_t>(-1))
{
// Illegal input sequence or input sequence has no equivalent
// sequence in the destination charset.
@ -167,7 +187,7 @@ void charsetConverter_iconv::convert(utility::inputStream& in, utility::outputSt
outputInvalidChar(out, cd, m_options);
// Skip a byte and leave unconverted bytes in the input buffer
std::copy(const_cast <char*>(inPtr + 1), inBuffer + sizeof(inBuffer), inBuffer);
std::copy(const_cast <byte_t*>(inPtr + 1), inBuffer + sizeof(inBuffer), inBuffer);
inPos = inLength - 1;
}
else
@ -176,7 +196,7 @@ void charsetConverter_iconv::convert(utility::inputStream& in, utility::outputSt
out.write(outBuffer, sizeof(outBuffer) - outLength);
// Leave unconverted bytes in the input buffer
std::copy(const_cast <char*>(inPtr), inBuffer + sizeof(inBuffer), inBuffer);
std::copy(const_cast <byte_t*>(inPtr), inBuffer + sizeof(inBuffer), inBuffer);
inPos = inLength;
if (errno != E2BIG)
@ -271,16 +291,16 @@ outputStream& charsetFilteredOutputStream_iconv::getNextOutputStream()
}
void charsetFilteredOutputStream_iconv::write
(const value_type* const data, const size_type count)
void charsetFilteredOutputStream_iconv::writeImpl
(const byte_t* const data, const size_t count)
{
if (m_desc == NULL)
throw exceptions::charset_conv_error("Cannot initialize converter.");
const iconv_t cd = *static_cast <iconv_t*>(m_desc);
const value_type* curData = data;
size_type curDataLen = count;
const byte_t* curData = data;
size_t curDataLen = count;
// If there is some unconverted bytes left, add more data from this
// chunk to see if it can now be converted.
@ -303,7 +323,7 @@ void charsetFilteredOutputStream_iconv::write
}
// Get more data
const size_type remaining =
const size_t remaining =
std::min(curDataLen, sizeof(m_unconvBuffer) - m_unconvCount);
std::copy(curData, curData + remaining, m_unconvBuffer + m_unconvCount);
@ -316,14 +336,15 @@ void charsetFilteredOutputStream_iconv::write
return; // no more data
// Try a conversion
const char* inPtr = m_unconvBuffer;
const byte_t* inPtr = m_unconvBuffer;
size_t inLength = m_unconvCount;
char* outPtr = m_outputBuffer;
byte_t* outPtr = m_outputBuffer;
size_t outLength = sizeof(m_outputBuffer);
const size_t inLength0 = inLength;
if (iconv(cd, ICONV_HACK(&inPtr), &inLength, &outPtr, &outLength) == static_cast <size_t>(-1))
if (iconv(cd, ICONV_IN_TYPE(&inPtr), &inLength,
ICONV_OUT_TYPE(&outPtr), &outLength) == static_cast <size_t>(-1))
{
const size_t inputConverted = inLength0 - inLength;
@ -350,14 +371,15 @@ void charsetFilteredOutputStream_iconv::write
return; // no more data
// Now, convert the current data buffer
const char* inPtr = curData;
const byte_t* inPtr = curData;
size_t inLength = std::min(curDataLen, sizeof(m_outputBuffer) / MAX_CHARACTER_WIDTH);
char* outPtr = m_outputBuffer;
byte_t* outPtr = m_outputBuffer;
size_t outLength = sizeof(m_outputBuffer);
const size_t inLength0 = inLength;
if (iconv(cd, ICONV_HACK(&inPtr), &inLength, &outPtr, &outLength) == static_cast <size_t>(-1))
if (iconv(cd, ICONV_IN_TYPE(&inPtr), &inLength,
ICONV_OUT_TYPE(&outPtr), &outLength) == static_cast <size_t>(-1))
{
// Write successfully converted bytes
m_stream.write(m_outputBuffer, sizeof(m_outputBuffer) - outLength);
@ -403,14 +425,14 @@ void charsetFilteredOutputStream_iconv::flush()
while (m_unconvCount != 0)
{
// Try a conversion
const char* inPtr = m_unconvBuffer + offset;
const byte_t* inPtr = m_unconvBuffer + offset;
size_t inLength = m_unconvCount;
char* outPtr = m_outputBuffer;
byte_t* outPtr = m_outputBuffer;
size_t outLength = sizeof(m_outputBuffer);
const size_t inLength0 = inLength;
if (iconv(cd, ICONV_HACK(&inPtr), &inLength, &outPtr, &outLength) == static_cast <size_t>(-1))
if (iconv(cd, ICONV_IN_TYPE(&inPtr), &inLength, ICONV_OUT_TYPE(&outPtr), &outLength) == static_cast <size_t>(-1))
{
const size_t inputConverted = inLength0 - inLength;

View File

@ -96,7 +96,7 @@ void charsetConverter_icu::convert(utility::inputStream& in, utility::outputStre
UErrorCode err = U_ZERO_ERROR;
// From buffers
char cpInBuffer[16]; // stream data put here
byte_t cpInBuffer[16]; // stream data put here
size_t outSize = ucnv_getMinCharSize(m_from) * sizeof(cpInBuffer) * sizeof(UChar);
UChar* uOutBuffer = new UChar[outSize]; // Unicode chars end up here
@ -120,10 +120,10 @@ void charsetConverter_icu::convert(utility::inputStream& in, utility::outputStre
while (!in.eof())
{
// Read input data into buffer
size_t inLength = static_cast<size_t>(in.read(cpInBuffer, sizeof(cpInBuffer)));
size_t inLength = in.read(cpInBuffer, sizeof(cpInBuffer));
// Beginning of read data
const char* source = &cpInBuffer[0];
const char* source = reinterpret_cast <const char*>(&cpInBuffer[0]);
const char* sourceLimit = source + inLength; // end + 1
UBool flush = in.eof(); // is this last run?
@ -250,8 +250,8 @@ outputStream& charsetFilteredOutputStream_icu::getNextOutputStream()
}
void charsetFilteredOutputStream_icu::write
(const value_type* const data, const size_type count)
void charsetFilteredOutputStream_icu::writeImpl
(const byte_t* const data, const size_t count)
{
if (m_from == NULL || m_to == NULL)
throw exceptions::charset_conv_error("Cannot initialize converters.");
@ -264,8 +264,8 @@ void charsetFilteredOutputStream_icu::write
// Conversion loop
UErrorCode toErr = U_ZERO_ERROR;
const char* uniSource = data;
const char* uniSourceLimit = data + count;
const char* uniSource = reinterpret_cast <const char*>(data);
const char* uniSourceLimit = uniSource + count;
do
{

View File

@ -95,8 +95,8 @@ void charsetConverter_idna::convert(const string& in, string& out)
string inUTF8;
charset::convert(in, inUTF8, m_source, vmime::charsets::UTF_8);
const string::value_type* ch = inUTF8.c_str();
const string::value_type* end = inUTF8.c_str() + inUTF8.length();
const char* ch = inUTF8.c_str();
const char* end = inUTF8.c_str() + inUTF8.length();
std::vector <punycode_uint> unichars;
unichars.reserve(inUTF8.length());
@ -139,8 +139,8 @@ void charsetConverter_idna::convert(const string& in, string& out)
if (status == punycode_success)
{
std::vector <string::value_type> outUTF8Bytes(outputLen * 4);
string::value_type* p = &outUTF8Bytes[0];
std::vector <char> outUTF8Bytes(outputLen * 4);
char* p = &outUTF8Bytes[0];
for (std::vector <punycode_uint>::const_iterator it = output.begin() ;
it != output.begin() + outputLen ; ++it)

View File

@ -47,15 +47,15 @@ component::~component()
void component::parse
(shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type length)
(shared_ptr <utility::inputStream> inputStream, const size_t length)
{
parse(inputStream, 0, length, NULL);
}
void component::parse
(shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type position,
const utility::stream::size_type end, utility::stream::size_type* newPosition)
(shared_ptr <utility::inputStream> inputStream, const size_t position,
const size_t end, size_t* newPosition)
{
parse(parsingContext::getDefaultContext(), inputStream, position, end, newPosition);
}
@ -63,8 +63,8 @@ void component::parse
void component::parse
(const parsingContext& ctx,
shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type position,
const utility::stream::size_type end, utility::stream::size_type* newPosition)
shared_ptr <utility::inputStream> inputStream, const size_t position,
const size_t end, size_t* newPosition)
{
m_parsedOffset = m_parsedLength = 0;
@ -109,8 +109,8 @@ void component::parse(const parsingContext& ctx, const string& buffer)
void component::parse
(const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
m_parsedOffset = m_parsedLength = 0;
@ -120,8 +120,8 @@ void component::parse
void component::parse
(const parsingContext& ctx,
const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
m_parsedOffset = m_parsedLength = 0;
@ -129,7 +129,7 @@ void component::parse
}
void component::offsetParsedBounds(const utility::stream::size_type offset)
void component::offsetParsedBounds(const size_t offset)
{
// Offset parsed bounds of this component
if (m_parsedLength != 0)
@ -145,8 +145,7 @@ void component::offsetParsedBounds(const utility::stream::size_type offset)
void component::parseImpl
(const parsingContext& ctx, shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end, utility::stream::size_type* newPosition)
const size_t position, const size_t end, size_t* newPosition)
{
// This is the default implementation for parsing from an input stream:
// actually, we extract the substring and use the "parse from string" implementation
@ -163,8 +162,8 @@ void component::parseImpl
void component::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
// This is the default implementation for parsing from a string:
// actually, we encapsulate the string buffer in an input stream, then use
@ -179,8 +178,8 @@ void component::parseImpl
}
const string component::generate(const string::size_type maxLineLength,
const string::size_type curLinePos) const
const string component::generate
(const size_t maxLineLength, const size_t curLinePos) const
{
std::ostringstream oss;
utility::outputStreamAdapter adapter(oss);
@ -195,9 +194,7 @@ const string component::generate(const string::size_type maxLineLength,
void component::generate
(utility::outputStream& os,
const string::size_type curLinePos,
string::size_type* newLinePos) const
(utility::outputStream& os, const size_t curLinePos, size_t* newLinePos) const
{
generateImpl(generationContext::getDefaultContext(),
os, curLinePos, newLinePos);
@ -205,38 +202,36 @@ void component::generate
void component::generate
(const generationContext& ctx,
utility::outputStream& outputStream,
const string::size_type curLinePos,
string::size_type* newLinePos) const
(const generationContext& ctx, utility::outputStream& outputStream,
const size_t curLinePos, size_t* newLinePos) const
{
generateImpl(ctx, outputStream, curLinePos, newLinePos);
}
string::size_type component::getParsedOffset() const
size_t component::getParsedOffset() const
{
return (m_parsedOffset);
}
string::size_type component::getParsedLength() const
size_t component::getParsedLength() const
{
return (m_parsedLength);
}
void component::setParsedBounds(const string::size_type start, const string::size_type end)
void component::setParsedBounds(const size_t start, const size_t end)
{
m_parsedOffset = start;
m_parsedLength = end - start;
}
utility::stream::size_type component::getGeneratedSize(const generationContext& ctx)
size_t component::getGeneratedSize(const generationContext& ctx)
{
std::vector <shared_ptr <component> > children = getChildComponents();
utility::stream::size_type totalSize = 0;
size_t totalSize = 0;
for (std::vector <shared_ptr <component> >::iterator it = children.begin() ; it != children.end() ; ++it)
totalSize += (*it)->getGeneratedSize(ctx);

View File

@ -32,205 +32,205 @@ namespace vmime
namespace mediaTypes
{
// Types
const string::value_type* const TEXT = "text";
const string::value_type* const MULTIPART = "multipart";
const string::value_type* const MESSAGE = "message";
const string::value_type* const APPLICATION = "application";
const string::value_type* const IMAGE = "image";
const string::value_type* const AUDIO = "audio";
const string::value_type* const VIDEO = "video";
const char* const TEXT = "text";
const char* const MULTIPART = "multipart";
const char* const MESSAGE = "message";
const char* const APPLICATION = "application";
const char* const IMAGE = "image";
const char* const AUDIO = "audio";
const char* const VIDEO = "video";
// Sub-types
const string::value_type* const TEXT_PLAIN = "plain";
const string::value_type* const TEXT_HTML = "html";
const string::value_type* const TEXT_RICHTEXT = "richtext";
const string::value_type* const TEXT_ENRICHED = "enriched";
const string::value_type* const TEXT_RFC822_HEADERS = "rfc822-headers"; // RFC-1892
const string::value_type* const TEXT_DIRECTORY = "directory"; // RFC-2426
const char* const TEXT_PLAIN = "plain";
const char* const TEXT_HTML = "html";
const char* const TEXT_RICHTEXT = "richtext";
const char* const TEXT_ENRICHED = "enriched";
const char* const TEXT_RFC822_HEADERS = "rfc822-headers"; // RFC-1892
const char* const TEXT_DIRECTORY = "directory"; // RFC-2426
const string::value_type* const MULTIPART_MIXED = "mixed";
const string::value_type* const MULTIPART_RELATED = "related";
const string::value_type* const MULTIPART_ALTERNATIVE = "alternative";
const string::value_type* const MULTIPART_PARALLEL = "parallel";
const string::value_type* const MULTIPART_DIGEST = "digest";
const string::value_type* const MULTIPART_REPORT = "report"; // RFC-1892
const char* const MULTIPART_MIXED = "mixed";
const char* const MULTIPART_RELATED = "related";
const char* const MULTIPART_ALTERNATIVE = "alternative";
const char* const MULTIPART_PARALLEL = "parallel";
const char* const MULTIPART_DIGEST = "digest";
const char* const MULTIPART_REPORT = "report"; // RFC-1892
const string::value_type* const MESSAGE_RFC822 = "rfc822";
const string::value_type* const MESSAGE_PARTIAL = "partial";
const string::value_type* const MESSAGE_EXTERNAL_BODY = "external-body";
const string::value_type* const MESSAGE_DISPOSITION_NOTIFICATION = "disposition-notification";
const char* const MESSAGE_RFC822 = "rfc822";
const char* const MESSAGE_PARTIAL = "partial";
const char* const MESSAGE_EXTERNAL_BODY = "external-body";
const char* const MESSAGE_DISPOSITION_NOTIFICATION = "disposition-notification";
const string::value_type* const APPLICATION_OCTET_STREAM = "octet-stream";
const char* const APPLICATION_OCTET_STREAM = "octet-stream";
const string::value_type* const IMAGE_JPEG = "jpeg";
const string::value_type* const IMAGE_GIF = "gif";
const char* const IMAGE_JPEG = "jpeg";
const char* const IMAGE_GIF = "gif";
const string::value_type* const AUDIO_BASIC = "basic";
const char* const AUDIO_BASIC = "basic";
const string::value_type* const VIDEO_MPEG = "mpeg";
const char* const VIDEO_MPEG = "mpeg";
}
// Encoding types
namespace encodingTypes
{
const string::value_type* const SEVEN_BIT = "7bit";
const string::value_type* const EIGHT_BIT = "8bit";
const string::value_type* const BASE64 = "base64";
const string::value_type* const QUOTED_PRINTABLE = "quoted-printable";
const string::value_type* const BINARY = "binary";
const string::value_type* const UUENCODE = "uuencode";
const char* const SEVEN_BIT = "7bit";
const char* const EIGHT_BIT = "8bit";
const char* const BASE64 = "base64";
const char* const QUOTED_PRINTABLE = "quoted-printable";
const char* const BINARY = "binary";
const char* const UUENCODE = "uuencode";
}
// Content disposition types
namespace contentDispositionTypes
{
const string::value_type* const INLINE = "inline";
const string::value_type* const ATTACHMENT = "attachment";
const char* const INLINE = "inline";
const char* const ATTACHMENT = "attachment";
}
// Charsets
namespace charsets
{
const string::value_type* const ISO8859_1 = "iso-8859-1";
const string::value_type* const ISO8859_2 = "iso-8859-2";
const string::value_type* const ISO8859_3 = "iso-8859-3";
const string::value_type* const ISO8859_4 = "iso-8859-4";
const string::value_type* const ISO8859_5 = "iso-8859-5";
const string::value_type* const ISO8859_6 = "iso-8859-6";
const string::value_type* const ISO8859_7 = "iso-8859-7";
const string::value_type* const ISO8859_8 = "iso-8859-8";
const string::value_type* const ISO8859_9 = "iso-8859-9";
const string::value_type* const ISO8859_10 = "iso-8859-10";
const string::value_type* const ISO8859_13 = "iso-8859-13";
const string::value_type* const ISO8859_14 = "iso-8859-14";
const string::value_type* const ISO8859_15 = "iso-8859-15";
const string::value_type* const ISO8859_16 = "iso-8859-16";
const char* const ISO8859_1 = "iso-8859-1";
const char* const ISO8859_2 = "iso-8859-2";
const char* const ISO8859_3 = "iso-8859-3";
const char* const ISO8859_4 = "iso-8859-4";
const char* const ISO8859_5 = "iso-8859-5";
const char* const ISO8859_6 = "iso-8859-6";
const char* const ISO8859_7 = "iso-8859-7";
const char* const ISO8859_8 = "iso-8859-8";
const char* const ISO8859_9 = "iso-8859-9";
const char* const ISO8859_10 = "iso-8859-10";
const char* const ISO8859_13 = "iso-8859-13";
const char* const ISO8859_14 = "iso-8859-14";
const char* const ISO8859_15 = "iso-8859-15";
const char* const ISO8859_16 = "iso-8859-16";
const string::value_type* const CP_437 = "cp437";
const string::value_type* const CP_737 = "cp737";
const string::value_type* const CP_775 = "cp775";
const string::value_type* const CP_850 = "cp850";
const string::value_type* const CP_852 = "cp852";
const string::value_type* const CP_853 = "cp853";
const string::value_type* const CP_855 = "cp855";
const string::value_type* const CP_857 = "cp857";
const string::value_type* const CP_858 = "cp858";
const string::value_type* const CP_860 = "cp860";
const string::value_type* const CP_861 = "cp861";
const string::value_type* const CP_862 = "cp862";
const string::value_type* const CP_863 = "cp863";
const string::value_type* const CP_864 = "cp864";
const string::value_type* const CP_865 = "cp865";
const string::value_type* const CP_866 = "cp866";
const string::value_type* const CP_869 = "cp869";
const string::value_type* const CP_874 = "cp874";
const string::value_type* const CP_1125 = "cp1125";
const string::value_type* const CP_1250 = "cp1250";
const string::value_type* const CP_1251 = "cp1251";
const string::value_type* const CP_1252 = "cp1252";
const string::value_type* const CP_1253 = "cp1253";
const string::value_type* const CP_1254 = "cp1254";
const string::value_type* const CP_1255 = "cp1255";
const string::value_type* const CP_1256 = "cp1256";
const string::value_type* const CP_1257 = "cp1257";
const char* const CP_437 = "cp437";
const char* const CP_737 = "cp737";
const char* const CP_775 = "cp775";
const char* const CP_850 = "cp850";
const char* const CP_852 = "cp852";
const char* const CP_853 = "cp853";
const char* const CP_855 = "cp855";
const char* const CP_857 = "cp857";
const char* const CP_858 = "cp858";
const char* const CP_860 = "cp860";
const char* const CP_861 = "cp861";
const char* const CP_862 = "cp862";
const char* const CP_863 = "cp863";
const char* const CP_864 = "cp864";
const char* const CP_865 = "cp865";
const char* const CP_866 = "cp866";
const char* const CP_869 = "cp869";
const char* const CP_874 = "cp874";
const char* const CP_1125 = "cp1125";
const char* const CP_1250 = "cp1250";
const char* const CP_1251 = "cp1251";
const char* const CP_1252 = "cp1252";
const char* const CP_1253 = "cp1253";
const char* const CP_1254 = "cp1254";
const char* const CP_1255 = "cp1255";
const char* const CP_1256 = "cp1256";
const char* const CP_1257 = "cp1257";
const string::value_type* const US_ASCII = "us-ascii";
const char* const US_ASCII = "us-ascii";
const string::value_type* const UTF_7 = "utf-7";
const string::value_type* const UTF_8 = "utf-8";
const string::value_type* const UTF_16 = "utf-16";
const string::value_type* const UTF_32 = "utf-32";
const char* const UTF_7 = "utf-7";
const char* const UTF_8 = "utf-8";
const char* const UTF_16 = "utf-16";
const char* const UTF_32 = "utf-32";
const string::value_type* const WINDOWS_1250 = "windows-1250";
const string::value_type* const WINDOWS_1251 = "windows-1251";
const string::value_type* const WINDOWS_1252 = "windows-1252";
const string::value_type* const WINDOWS_1253 = "windows-1253";
const string::value_type* const WINDOWS_1254 = "windows-1254";
const string::value_type* const WINDOWS_1255 = "windows-1255";
const string::value_type* const WINDOWS_1256 = "windows-1256";
const string::value_type* const WINDOWS_1257 = "windows-1257";
const string::value_type* const WINDOWS_1258 = "windows-1258";
const char* const WINDOWS_1250 = "windows-1250";
const char* const WINDOWS_1251 = "windows-1251";
const char* const WINDOWS_1252 = "windows-1252";
const char* const WINDOWS_1253 = "windows-1253";
const char* const WINDOWS_1254 = "windows-1254";
const char* const WINDOWS_1255 = "windows-1255";
const char* const WINDOWS_1256 = "windows-1256";
const char* const WINDOWS_1257 = "windows-1257";
const char* const WINDOWS_1258 = "windows-1258";
const string::value_type* const IDNA = "idna";
const char* const IDNA = "idna";
}
// Fields
namespace fields
{
const string::value_type* const RECEIVED = "Received";
const string::value_type* const FROM = "From";
const string::value_type* const SENDER = "Sender";
const string::value_type* const REPLY_TO = "Reply-To";
const string::value_type* const TO = "To";
const string::value_type* const CC = "Cc";
const string::value_type* const BCC = "Bcc";
const string::value_type* const DATE = "Date";
const string::value_type* const SUBJECT = "Subject";
const string::value_type* const ORGANIZATION = "Organization";
const string::value_type* const USER_AGENT = "User-Agent";
const string::value_type* const DELIVERED_TO = "Delivered-To";
const string::value_type* const RETURN_PATH = "Return-Path";
const string::value_type* const MIME_VERSION = "Mime-Version";
const string::value_type* const MESSAGE_ID = "Message-Id";
const string::value_type* const CONTENT_TYPE = "Content-Type";
const string::value_type* const CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
const string::value_type* const CONTENT_DESCRIPTION = "Content-Description";
const string::value_type* const CONTENT_DISPOSITION = "Content-Disposition";
const string::value_type* const CONTENT_ID = "Content-Id";
const string::value_type* const CONTENT_LOCATION = "Content-Location";
const string::value_type* const IN_REPLY_TO = "In-Reply-To";
const string::value_type* const REFERENCES = "References";
const char* const RECEIVED = "Received";
const char* const FROM = "From";
const char* const SENDER = "Sender";
const char* const REPLY_TO = "Reply-To";
const char* const TO = "To";
const char* const CC = "Cc";
const char* const BCC = "Bcc";
const char* const DATE = "Date";
const char* const SUBJECT = "Subject";
const char* const ORGANIZATION = "Organization";
const char* const USER_AGENT = "User-Agent";
const char* const DELIVERED_TO = "Delivered-To";
const char* const RETURN_PATH = "Return-Path";
const char* const MIME_VERSION = "Mime-Version";
const char* const MESSAGE_ID = "Message-Id";
const char* const CONTENT_TYPE = "Content-Type";
const char* const CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
const char* const CONTENT_DESCRIPTION = "Content-Description";
const char* const CONTENT_DISPOSITION = "Content-Disposition";
const char* const CONTENT_ID = "Content-Id";
const char* const CONTENT_LOCATION = "Content-Location";
const char* const IN_REPLY_TO = "In-Reply-To";
const char* const REFERENCES = "References";
const string::value_type* const X_MAILER = "X-Mailer";
const string::value_type* const X_PRIORITY = "X-Priority";
const char* const X_MAILER = "X-Mailer";
const char* const X_PRIORITY = "X-Priority";
// RFC-3798: Message Disposition
const string::value_type* const ORIGINAL_MESSAGE_ID = "Original-Message-ID";
const string::value_type* const DISPOSITION_NOTIFICATION_TO = "Disposition-Notification-To";
const string::value_type* const DISPOSITION_NOTIFICATION_OPTIONS = "Disposition-Notification-Options";
const string::value_type* const DISPOSITION = "Disposition";
const string::value_type* const FAILURE = "Failure";
const string::value_type* const ERROR = "Error";
const string::value_type* const WARNING = "Warning";
const string::value_type* const ORIGINAL_RECIPIENT = "Original-Recipient";
const string::value_type* const FINAL_RECIPIENT = "Final-Recipient";
const string::value_type* const REPORTING_UA = "Reporting-UA";
const string::value_type* const MDN_GATEWAY = "MDN-Gateway";
const char* const ORIGINAL_MESSAGE_ID = "Original-Message-ID";
const char* const DISPOSITION_NOTIFICATION_TO = "Disposition-Notification-To";
const char* const DISPOSITION_NOTIFICATION_OPTIONS = "Disposition-Notification-Options";
const char* const DISPOSITION = "Disposition";
const char* const FAILURE = "Failure";
const char* const ERROR = "Error";
const char* const WARNING = "Warning";
const char* const ORIGINAL_RECIPIENT = "Original-Recipient";
const char* const FINAL_RECIPIENT = "Final-Recipient";
const char* const REPORTING_UA = "Reporting-UA";
const char* const MDN_GATEWAY = "MDN-Gateway";
}
// Constants for disposition action modes (RFC-3978).
namespace dispositionActionModes
{
const string::value_type* const MANUAL = "manual";
const string::value_type* const AUTOMATIC = "automatic";
const char* const MANUAL = "manual";
const char* const AUTOMATIC = "automatic";
}
// Constants for disposition sending modes (RFC-3798).
namespace dispositionSendingModes
{
const string::value_type* const SENT_MANUALLY = "MDN-sent-manually";
const string::value_type* const SENT_AUTOMATICALLY ="MDN-sent-automatically";
const char* const SENT_MANUALLY = "MDN-sent-manually";
const char* const SENT_AUTOMATICALLY ="MDN-sent-automatically";
}
// Constants for disposition types (RFC-3798).
namespace dispositionTypes
{
const string::value_type* const DISPLAYED = "displayed";
const string::value_type* const DELETED = "deleted";
const char* const DISPLAYED = "displayed";
const char* const DELETED = "deleted";
}
// Constants for disposition modifiers (RFC-3798).
namespace dispositionModifiers
{
const string::value_type* const ERROR = "error";
const char* const ERROR = "error";
}

View File

@ -48,8 +48,8 @@ contentDisposition::contentDisposition(const contentDisposition& type)
void contentDisposition::parseImpl
(const parsingContext& /* ctx */, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& /* ctx */, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
m_name = utility::stringUtils::trim(utility::stringUtils::toLower
(string(buffer.begin() + position, buffer.begin() + end)));
@ -63,7 +63,7 @@ void contentDisposition::parseImpl
void contentDisposition::generateImpl
(const generationContext& /* ctx */, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
os << m_name;

View File

@ -69,11 +69,11 @@ zone = "UT" / "GMT" ; Universal Time
void datetime::parseImpl
(const parsingContext& /* ctx */, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& /* ctx */, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
const string::value_type* const pend = buffer.data() + end;
const string::value_type* p = buffer.data() + position;
const char* const pend = buffer.data() + end;
const char* p = buffer.data() + position;
// Parse the date and time value
while (p < pend && parserHelpers::isSpace(*p)) ++p;
@ -592,11 +592,11 @@ void datetime::parseImpl
void datetime::generateImpl
(const generationContext& /* ctx */, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
static const string::value_type* dayNames[] =
static const char* dayNames[] =
{ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
static const string::value_type* monthNames[] =
static const char* monthNames[] =
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

View File

@ -172,22 +172,22 @@ const std::vector <string> disposition::getModifierList() const
void disposition::parseImpl
(const parsingContext& /* ctx */, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& /* ctx */, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
// disposition-mode ";" disposition-type
// [ "/" disposition-modifier *( "," disposition-modifier ) ]
//
// disposition-mode = action-mode "/" sending-mode
string::size_type pos = position;
size_t pos = position;
while (pos < end && parserHelpers::isSpace(buffer[pos]))
++pos;
// -- disposition-mode
const string::size_type modeStart = pos;
string::size_type modeEnd = pos;
const size_t modeStart = pos;
size_t modeEnd = pos;
while (pos < end && buffer[pos] != ';')
{
@ -199,7 +199,7 @@ void disposition::parseImpl
--modeEnd;
const string mode = string(buffer.begin() + modeStart, buffer.begin() + modeEnd);
const string::size_type slash = mode.find('/');
const size_t slash = mode.find('/');
if (slash != string::npos)
{
@ -222,8 +222,8 @@ void disposition::parseImpl
++pos;
// -- disposition-type
const string::size_type typeStart = pos;
string::size_type typeEnd = pos;
const size_t typeStart = pos;
size_t typeEnd = pos;
while (pos < end && buffer[pos] != '/')
{
@ -248,8 +248,8 @@ void disposition::parseImpl
while (pos < end && parserHelpers::isSpace(buffer[pos]))
++pos;
const string::size_type modifierStart = pos;
string::size_type modifierEnd = pos;
const size_t modifierStart = pos;
size_t modifierEnd = pos;
while (pos < end && buffer[pos] != ',')
{
@ -279,9 +279,9 @@ void disposition::parseImpl
void disposition::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
string::size_type pos = curLinePos;
size_t pos = curLinePos;
const string actionMode = (m_actionMode.empty() ? "automatic-action" : m_actionMode);
const string sendingMode = (m_sendingMode.empty() ? "MDN-sent-automatically" : m_sendingMode);

View File

@ -72,12 +72,12 @@ emailAddress::emailAddress(const word& localName, const word& domainName)
void emailAddress::parseImpl
(const parsingContext& /* ctx */, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& /* ctx */, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
const string::value_type* const pend = buffer.data() + end;
const string::value_type* const pstart = buffer.data() + position;
const string::value_type* p = pstart;
const char* const pend = buffer.data() + end;
const char* const pstart = buffer.data() + position;
const char* p = pstart;
enum ParserStates
{
@ -104,7 +104,7 @@ void emailAddress::parseImpl
while (p < pend && !stop)
{
const string::value_type c = *p;
const char c = *p;
if ((localPart.str().length() + domainPart.str().length()) >= 256)
{
@ -371,9 +371,9 @@ void emailAddress::parseImpl
static const string domainNameToIDNA(const string& domainName)
{
std::ostringstream idnaDomain;
string::size_type p = 0;
size_t p = 0;
for (string::size_type n = domainName.find('.', p) ;
for (size_t n = domainName.find('.', p) ;
(n = domainName.find('.', p)) != string::npos ; p = n + 1)
{
string idnaPart;
@ -398,7 +398,7 @@ static const string domainNameToIDNA(const string& domainName)
void emailAddress::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
string localPart, domainPart;

View File

@ -40,7 +40,7 @@ shared_ptr <contentHandler> emptyContentHandler::clone() const
void emptyContentHandler::generate(utility::outputStream& /* os */, const vmime::encoding& /* enc */,
const string::size_type /* maxLineLength */) const
const size_t /* maxLineLength */) const
{
// Nothing to do.
}
@ -72,7 +72,7 @@ void emptyContentHandler::extractRaw(utility::outputStream& /* os */,
}
string::size_type emptyContentHandler::getLength() const
size_t emptyContentHandler::getLength() const
{
return (0);
}

View File

@ -62,8 +62,8 @@ encoding::encoding(const encoding& enc)
void encoding::parseImpl
(const parsingContext& /* ctx */, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& /* ctx */, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
m_usage = USAGE_UNKNOWN;
@ -83,7 +83,7 @@ void encoding::parseImpl
void encoding::generateImpl
(const generationContext& /* ctx */, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
os << m_name;
@ -146,8 +146,8 @@ const encoding encoding::decideImpl
// "lineLengthLimits::convenient" characters (7-bit requires that)
string::const_iterator p = begin;
const string::size_type maxLen = lineLengthLimits::convenient;
string::size_type len = 0;
const size_t maxLen = lineLengthLimits::convenient;
size_t len = 0;
for ( ; p != end && len <= maxLen ; )
{

View File

@ -212,8 +212,8 @@ const datetime& fileAttachment::fileInfo::getReadDate() const { return (*m_readD
void fileAttachment::fileInfo::setReadDate(const datetime& date) { if (m_readDate) { *m_readDate = date; } else { m_readDate = new datetime(date); } }
bool fileAttachment::fileInfo::hasSize() const { return (m_size != NULL); }
utility::stream::size_type fileAttachment::fileInfo::getSize() const { return (*m_size); }
void fileAttachment::fileInfo::setSize(const utility::stream::size_type size) { if (m_size) { *m_size = size; } else { m_size = new utility::stream::size_type(size); } }
size_t fileAttachment::fileInfo::getSize() const { return (*m_size); }
void fileAttachment::fileInfo::setSize(const size_t size) { if (m_size) { *m_size = size; } else { m_size = new size_t(size); } }
} // vmime

View File

@ -53,13 +53,13 @@ generationContext& generationContext::getDefaultContext()
}
string::size_type generationContext::getMaxLineLength() const
size_t generationContext::getMaxLineLength() const
{
return m_maxLineLength;
}
void generationContext::setMaxLineLength(const string::size_type maxLineLength)
void generationContext::setMaxLineLength(const size_t maxLineLength)
{
m_maxLineLength = maxLineLength;
}

View File

@ -63,10 +63,10 @@ field-body-contents =
*/
void header::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
string::size_type pos = position;
size_t pos = position;
removeAllFields();
@ -87,7 +87,7 @@ void header::parseImpl
void header::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type /* curLinePos */, string::size_type* newLinePos) const
const size_t /* curLinePos */, size_t* newLinePos) const
{
// Generate the fields
for (std::vector <shared_ptr <headerField> >::const_iterator it = m_fields.begin() ;
@ -102,7 +102,7 @@ void header::generateImpl
}
utility::stream::size_type header::getGeneratedSize(const generationContext& ctx)
size_t header::getGeneratedSize(const generationContext& ctx)
{
return component::getGeneratedSize(ctx) + 2 * m_fields.size() /* CRLF */;
}

View File

@ -76,10 +76,10 @@ headerField& headerField::operator=(const headerField& other)
shared_ptr <headerField> headerField::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
string::size_type pos = position;
size_t pos = position;
while (pos < end)
{
@ -106,12 +106,12 @@ shared_ptr <headerField> headerField::parseNext
// This line may be a field description
if (!parserHelpers::isSpace(c))
{
const string::size_type nameStart = pos; // remember the start position of the line
const size_t nameStart = pos; // remember the start position of the line
while (pos < end && (buffer[pos] != ':' && !parserHelpers::isSpace(buffer[pos])))
++pos;
const string::size_type nameEnd = pos;
const size_t nameEnd = pos;
while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t'))
++pos;
@ -141,8 +141,8 @@ shared_ptr <headerField> headerField::parseNext
while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t'))
++pos;
const string::size_type contentsStart = pos;
string::size_type contentsEnd = 0;
const size_t contentsStart = pos;
size_t contentsEnd = 0;
// Extract the field value
while (pos < end)
@ -280,8 +280,8 @@ shared_ptr <headerField> headerField::parseNext
void headerField::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
m_value->parse(ctx, buffer, position, end, newPosition);
}
@ -289,7 +289,7 @@ void headerField::parseImpl
void headerField::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
os << m_name + ": ";
@ -297,7 +297,7 @@ void headerField::generateImpl
}
utility::stream::size_type headerField::getGeneratedSize(const generationContext& ctx)
size_t headerField::getGeneratedSize(const generationContext& ctx)
{
return m_name.length() + 2 /* ": " */ + m_value->getGeneratedSize(ctx);
}

View File

@ -30,7 +30,7 @@ namespace vmime
{
utility::stream::size_type headerFieldValue::getGeneratedSize(const generationContext& ctx)
size_t headerFieldValue::getGeneratedSize(const generationContext& ctx)
{
std::ostringstream oss;
utility::outputStreamAdapter osa(oss);

View File

@ -67,12 +67,12 @@ angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr
*/
void mailbox::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
const string::value_type* const pend = buffer.data() + end;
const string::value_type* const pstart = buffer.data() + position;
const string::value_type* p = pstart;
const char* const pend = buffer.data() + end;
const char* const pstart = buffer.data() + position;
const char* p = pstart;
// Ignore blank spaces at the beginning
while (p < pend && parserHelpers::isSpace(*p)) ++p;
@ -333,7 +333,7 @@ void mailbox::parseImpl
void mailbox::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
string generatedEmail;
utility::outputStreamStringAdapter generatedEmailStream(generatedEmail);
@ -341,7 +341,7 @@ void mailbox::generateImpl
if (m_name.isEmpty())
{
string::size_type pos = curLinePos;
size_t pos = curLinePos;
// No display name is specified, only email address.
if (curLinePos + generatedEmail.length() > ctx.getMaxLineLength())
@ -404,7 +404,7 @@ void mailbox::generateImpl
}
}
string::size_type pos = curLinePos;
size_t pos = curLinePos;
m_name.encodeAndFold(ctx, os, pos, &pos,
text::QUOTE_IF_POSSIBLE | (forceEncode ? text::FORCE_ENCODING : 0));

View File

@ -44,8 +44,8 @@ mailboxField::mailboxField(const mailboxField&)
void mailboxField::parse
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
shared_ptr <mailbox> mbox = make_shared <mailbox>();

View File

@ -55,12 +55,12 @@ mailboxGroup::~mailboxGroup()
void mailboxGroup::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
const string::value_type* const pend = buffer.data() + end;
const string::value_type* const pstart = buffer.data() + position;
const string::value_type* p = pstart;
const char* const pend = buffer.data() + end;
const char* const pstart = buffer.data() + position;
const char* p = pstart;
while (p < pend && parserHelpers::isSpace(*p))
++p;
@ -77,7 +77,7 @@ void mailboxGroup::parseImpl
++p;
string::size_type pos = position + (p - pstart);
size_t pos = position + (p - pstart);
bool isLastAddressOfGroup = false;
while (pos < end && !isLastAddressOfGroup)
@ -115,7 +115,7 @@ void mailboxGroup::parseImpl
void mailboxGroup::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
// We have to encode the name:
// - if it contains characters in a charset different from "US-ASCII",
@ -157,7 +157,7 @@ void mailboxGroup::generateImpl
}
}
string::size_type pos = curLinePos;
size_t pos = curLinePos;
generationContext tmpCtx(ctx);
tmpCtx.setMaxLineLength(ctx.getMaxLineLength() - 2);

View File

@ -177,12 +177,12 @@ const std::vector <shared_ptr <component> > mailboxList::getChildComponents()
void mailboxList::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
m_list.removeAllAddresses();
string::size_type pos = position;
size_t pos = position;
while (pos < end)
{
@ -214,7 +214,7 @@ void mailboxList::parseImpl
void mailboxList::generateImpl(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
m_list.generate(ctx, os, curLinePos, newLinePos);
}

View File

@ -49,15 +49,15 @@ mediaType::mediaType(const string& type, const string& subType)
void mediaType::parseImpl
(const parsingContext& /* ctx */, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& /* ctx */, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
const string::value_type* const pend = buffer.data() + end;
const string::value_type* const pstart = buffer.data() + position;
const string::value_type* p = pstart;
const char* const pend = buffer.data() + end;
const char* const pstart = buffer.data() + position;
const char* p = pstart;
// Extract the type
const string::size_type typeStart = position;
const size_t typeStart = position;
while (p < pend && *p != '/') ++p;
@ -85,7 +85,7 @@ void mediaType::parseImpl
void mediaType::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
const string value = m_type + "/" + m_subType;

View File

@ -37,8 +37,8 @@ message::message()
}
const string message::generate(const string::size_type maxLineLength,
const string::size_type curLinePos) const
const string message::generate
(const size_t maxLineLength, const size_t curLinePos) const
{
return bodyPart::generate(maxLineLength, curLinePos);
}

View File

@ -62,12 +62,12 @@ messageId::messageId(const string& left, const string& right)
*/
void messageId::parseImpl
(const parsingContext& /* ctx */, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& /* ctx */, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
const string::value_type* const pend = buffer.data() + end;
const string::value_type* const pstart = buffer.data() + position;
const string::value_type* p = pstart;
const char* const pend = buffer.data() + end;
const char* const pstart = buffer.data() + position;
const char* p = pstart;
m_left.clear();
m_right.clear();
@ -117,7 +117,7 @@ void messageId::parseImpl
if (p < pend)
{
// Extract left part
const string::size_type leftStart = position + (p - pstart);
const size_t leftStart = position + (p - pstart);
while (p < pend && *p != '@' && *p != '>') ++p;
@ -130,7 +130,7 @@ void messageId::parseImpl
++p;
// Extract right part
const string::size_type rightStart = position + (p - pstart);
const size_t rightStart = position + (p - pstart);
while (p < pend && *p != '>' && (hasBrackets || !parserHelpers::isSpace(*p))) ++p;
@ -147,17 +147,17 @@ void messageId::parseImpl
shared_ptr <messageId> messageId::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
string::size_type pos = position;
size_t pos = position;
while (pos < end && parserHelpers::isSpace(buffer[pos]))
++pos;
if (pos != end)
{
const string::size_type begin = pos;
const size_t begin = pos;
while (pos < end && !parserHelpers::isSpace(buffer[pos]))
++pos;
@ -189,9 +189,9 @@ const string messageId::getId() const
void messageId::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
string::size_type pos = curLinePos;
size_t pos = curLinePos;
if (curLinePos + m_left.length() + m_right.length() + 3 > ctx.getMaxLineLength())
{

View File

@ -85,12 +85,12 @@ const std::vector <shared_ptr <component> > messageIdSequence::getChildComponent
void messageIdSequence::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
removeAllMessageIds();
string::size_type pos = position;
size_t pos = position;
while (pos < end)
{
@ -109,9 +109,9 @@ void messageIdSequence::parseImpl
void messageIdSequence::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
string::size_type pos = curLinePos;
size_t pos = curLinePos;
if (!m_list.empty())
{

View File

@ -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;

View File

@ -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);
}

View File

@ -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

View File

@ -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)
{

View File

@ -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:

View File

@ -104,7 +104,7 @@ const mediaType& IMAPMessagePart::getType() const
}
int IMAPMessagePart::getSize() const
size_t IMAPMessagePart::getSize() const
{
return m_size;
}

View File

@ -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();
}

View File

@ -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 += '-';

View File

@ -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);

View File

@ -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]);

View File

@ -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);

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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] == '.'))

View File

@ -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])
{

View File

@ -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);
}

View File

@ -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 (...)
{

View File

@ -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,14 +601,16 @@ void POP3Folder::rename(const folder::path& /* newPath */)
}
void POP3Folder::addMessage(shared_ptr <vmime::message> /* msg */, const int /* flags */,
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 */,
void POP3Folder::addMessage
(utility::inputStream& /* is */, const size_t /* size */, const int /* flags */,
vmime::datetime* /* date */, utility::progressListener* /* progress */)
{
throw exceptions::operation_not_supported();

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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());

View File

@ -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 (...)
{

View File

@ -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--;

View File

@ -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;

View File

@ -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;

View File

@ -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());
}
TLSSocket::size_type TLSSocket_OpenSSL::receiveRaw(char* buffer, const size_type count)
void TLSSocket_OpenSSL::send(const char* str)
{
sendRaw(reinterpret_cast <const byte_t*>(str), ::strlen(str));
}
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);

View File

@ -114,8 +114,8 @@ void parameter::setValue(const word& value)
void parameter::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
m_value->setBuffer(string(buffer.begin() + position, buffer.begin() + end));
@ -145,15 +145,15 @@ void parameter::parse(const parsingContext& ctx, const std::vector <valueChunk>&
// Decode following data
if (chunk.encoded)
{
const string::size_type len = chunk.data.length();
string::size_type pos = 0;
const size_t len = chunk.data.length();
size_t pos = 0;
// If this is the first encoded chunk, extract charset
// and language information
if (!foundCharsetChunk)
{
// Eg. "us-ascii'en'This%20is%20even%20more%20"
string::size_type q = chunk.data.find_first_of('\'');
size_t q = chunk.data.find_first_of('\'');
if (q != string::npos)
{
@ -178,9 +178,9 @@ void parameter::parse(const parsingContext& ctx, const std::vector <valueChunk>&
foundCharsetChunk = true;
}
for (string::size_type i = pos ; i < len ; ++i)
for (size_t i = pos ; i < len ; ++i)
{
const string::value_type c = chunk.data[i];
const char c = chunk.data[i];
if (c == '%' && i + 2 < len)
{
@ -218,7 +218,7 @@ void parameter::parse(const parsingContext& ctx, const std::vector <valueChunk>&
break;
}
value << static_cast <string::value_type>(v);
value << static_cast <char>(v);
i += 2; // skip next 2 chars
}
@ -273,7 +273,7 @@ void parameter::parse(const parsingContext& ctx, const std::vector <valueChunk>&
void parameter::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
const string& name = m_name;
const string& value = m_value->getBuffer();
@ -293,7 +293,7 @@ void parameter::generateImpl
string sevenBitBuffer;
utility::outputStreamStringAdapter sevenBitStream(sevenBitBuffer);
string::size_type pos = curLinePos;
size_t pos = curLinePos;
if (pos + name.length() + 10 + value.length() > ctx.getMaxLineLength())
{
@ -303,10 +303,10 @@ void parameter::generateImpl
bool needQuoting = false;
bool needQuotedPrintable = false;
string::size_type valueLength = 0;
size_t valueLength = 0;
// Use worst-case length name.length()+2 for 'name=' part of line
for (string::size_type i = 0 ; (i < value.length()) && (pos + name.length() + 2 + valueLength < ctx.getMaxLineLength() - 4) ; ++i, ++valueLength)
for (size_t i = 0 ; (i < value.length()) && (pos + name.length() + 2 + valueLength < ctx.getMaxLineLength() - 4) ; ++i, ++valueLength)
{
switch (value[i])
{
@ -378,7 +378,7 @@ void parameter::generateImpl
else
{
// Do not chop off this value, but just add the complete name as one header line.
for (string::size_type i = 0 ; i < value.length() ; ++i)
for (size_t i = 0 ; i < value.length() ; ++i)
{
const char_t c = value[i];
@ -446,7 +446,7 @@ void parameter::generateImpl
// Check whether there is enough space for the first section:
// parameter name, section identifier, charset and separators
// + at least 5 characters for the value
const string::size_type firstSectionLength =
const size_t firstSectionLength =
name.length() + 4 /* *0*= */ + 2 /* '' */
+ m_value->getCharset().getName().length();
@ -461,9 +461,9 @@ void parameter::generateImpl
std::vector <string> sectionText;
string currentSection;
string::size_type currentSectionLength = firstSectionLength;
size_t currentSectionLength = firstSectionLength;
for (string::size_type i = 0 ; i < value.length() ; ++i)
for (size_t i = 0 ; i < value.length() ; ++i)
{
// Check whether we should start a new line (taking into
// account the next character will be encoded = worst case)

View File

@ -71,23 +71,23 @@ struct paramInfo
{
bool extended;
std::vector <parameter::valueChunk> value;
string::size_type start;
string::size_type end;
size_t start;
size_t end;
};
#endif // VMIME_BUILDING_DOC
void parameterizedHeaderField::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
const string::value_type* const pend = buffer.data() + end;
const string::value_type* const pstart = buffer.data() + position;
const string::value_type* p = pstart;
const char* const pend = buffer.data() + end;
const char* const pstart = buffer.data() + position;
const char* p = pstart;
// Skip non-significant whitespaces
string::size_type valueStart = position;
size_t valueStart = position;
while (p < pend && parserHelpers::isSpace(*p))
{
@ -96,7 +96,7 @@ void parameterizedHeaderField::parseImpl
}
// Advance up to ';', if any
string::size_type valueLength = 0;
size_t valueLength = 0;
while (p < pend && *p != ';' && (!parserHelpers::isSpace(*p))) // FIXME: support ";" inside quoted or RFC-2047-encoded text
{
@ -132,7 +132,7 @@ void parameterizedHeaderField::parseImpl
while (p < pend && parserHelpers::isSpace(*p)) ++p;
const string::size_type attrStart = position + (p - pstart);
const size_t attrStart = position + (p - pstart);
while (p < pend && !(*p == ';' || *p == '='))
++p;
@ -148,7 +148,7 @@ void parameterizedHeaderField::parseImpl
else
{
// Extract the attribute name
string::size_type attrEnd = position + (p - pstart);
size_t attrEnd = position + (p - pstart);
while (attrEnd != attrStart && parserHelpers::isSpace(buffer[attrEnd - 1]))
--attrEnd;
@ -173,7 +173,7 @@ void parameterizedHeaderField::parseImpl
bool stop = false;
std::ostringstream ss;
string::size_type start = position + (p - pstart);
size_t start = position + (p - pstart);
for ( ; p < pend && !stop ; ++p)
{
@ -218,12 +218,12 @@ void parameterizedHeaderField::parseImpl
// -- the value is a simple token
else
{
const string::size_type valStart = position + (p - pstart);
const size_t valStart = position + (p - pstart);
while (p < pend && *p != ';')
++p;
string::size_type valEnd = position + (p - pstart);
size_t valEnd = position + (p - pstart);
while (valEnd != valStart && parserHelpers::isSpace(buffer[valEnd - 1]))
--valEnd;
@ -250,13 +250,13 @@ void parameterizedHeaderField::parseImpl
}
// Check for RFC-2231 multi-section parameters
const string::size_type star = name.find_last_of('*');
const size_t star = name.find_last_of('*');
if (star != string::npos)
{
bool allDigits = true;
for (string::size_type i = star + 1 ; allDigits && (i < name.length()) ; ++i)
for (size_t i = star + 1 ; allDigits && (i < name.length()) ; ++i)
allDigits = parserHelpers::isDigit(name[i]);
if (allDigits)
@ -337,9 +337,9 @@ void parameterizedHeaderField::parseImpl
void parameterizedHeaderField::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
string::size_type pos = curLinePos;
size_t pos = curLinePos;
// Parent header field
headerField::generateImpl(ctx, os, pos, &pos);

View File

@ -113,10 +113,10 @@ const std::vector <shared_ptr <component> > path::getChildComponents()
void path::parseImpl
(const parsingContext& /* ctx */, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& /* ctx */, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
string::size_type pos = position;
size_t pos = position;
while (pos < end && parserHelpers::isSpace(buffer[pos]))
++pos;
@ -131,12 +131,12 @@ void path::parseImpl
while (pos < end && parserHelpers::isSpace(buffer[pos]))
++pos;
const string::size_type addrStart = pos;
const size_t addrStart = pos;
while (pos < end && buffer[pos] != '>')
++pos;
string::size_type addrEnd = pos;
size_t addrEnd = pos;
while (addrEnd > addrStart && parserHelpers::isSpace(buffer[addrEnd - 1]))
addrEnd--;
@ -148,7 +148,7 @@ void path::parseImpl
addrSpec = string(buffer.begin() + position, buffer.begin() + end);
}
const string::size_type at = addrSpec.find_first_of('@');
const size_t at = addrSpec.find_first_of('@');
if (at != string::npos)
{
@ -168,7 +168,7 @@ void path::parseImpl
void path::generateImpl
(const generationContext& /* ctx */, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
if (m_localPart.empty() && m_domain.empty())
{

View File

@ -118,7 +118,14 @@ public:
{
}
void write(const value_type* const data, const size_type count)
void flush()
{
::fsync(m_desc);
}
protected:
void writeImpl(const byte_t* const data, const size_t count)
{
if (::write(m_desc, data, count) == -1)
{
@ -127,11 +134,6 @@ public:
}
}
void flush()
{
::fsync(m_desc);
}
private:
const int m_desc;
@ -159,13 +161,13 @@ public:
// Do nothing: unsupported
}
size_type skip(const size_type count)
size_t skip(const size_t count)
{
// TODO: not tested
value_type buffer[4096];
byte_t buffer[4096];
int bytesSkipped = 0;
int bytesRead = 0;
ssize_t bytesSkipped = 0;
ssize_t bytesRead = 0;
while ((bytesRead = ::read(m_desc, buffer,
std::min(sizeof(buffer), count - bytesSkipped))) != 0)
@ -179,12 +181,12 @@ public:
bytesSkipped += bytesRead;
}
return static_cast <size_type>(bytesSkipped);
return static_cast <size_t>(bytesSkipped);
}
size_type read(value_type* const data, const size_type count)
size_t read(byte_t* const data, const size_t count)
{
int bytesRead = 0;
ssize_t bytesRead = 0;
if ((bytesRead = ::read(m_desc, data, count)) == -1)
{
@ -194,7 +196,7 @@ public:
m_eof = (bytesRead == 0);
return static_cast <size_type>(bytesRead);
return static_cast <size_t>(bytesRead);
}
private:

View File

@ -97,7 +97,7 @@ void posixFileIterator::getNextElement()
while ((m_dirEntry = ::readdir(m_dir)) != NULL)
{
const char* name = m_dirEntry->d_name;
const int len = ::strlen(name);
const size_t len = ::strlen(name);
if (!(len == 1 && name[0] == '.') &&
!(len == 2 && name[0] == '.' && name[1] == '.'))
@ -128,9 +128,10 @@ posixFileWriterOutputStream::~posixFileWriterOutputStream()
}
void posixFileWriterOutputStream::write(const value_type* const data, const size_type count)
void posixFileWriterOutputStream::writeImpl
(const byte_t* const data, const size_t count)
{
const value_type* array = data;
const byte_t* array = data;
size_t size = count;
while (1)
@ -196,8 +197,8 @@ void posixFileReaderInputStream::reset()
}
vmime::utility::stream::size_type posixFileReaderInputStream::read
(value_type* const data, const size_type count)
size_t posixFileReaderInputStream::read
(byte_t* const data, const size_t count)
{
ssize_t c = 0;
@ -207,11 +208,11 @@ vmime::utility::stream::size_type posixFileReaderInputStream::read
if (c == 0 && count != 0)
m_eof = true;
return static_cast <size_type>(c);
return static_cast <size_t>(c);
}
vmime::utility::stream::size_type posixFileReaderInputStream::skip(const size_type count)
size_t posixFileReaderInputStream::skip(const size_t count)
{
const off_t curPos = ::lseek(m_fd, 0, SEEK_CUR);
@ -223,22 +224,22 @@ vmime::utility::stream::size_type posixFileReaderInputStream::skip(const size_ty
if (newPos == off_t(-1))
posixFileSystemFactory::reportError(m_path, errno);
return static_cast <size_type>(newPos - curPos);
return static_cast <size_t>(newPos - curPos);
}
vmime::utility::stream::size_type posixFileReaderInputStream::getPosition() const
size_t posixFileReaderInputStream::getPosition() const
{
const off_t curPos = ::lseek(m_fd, 0, SEEK_CUR);
if (curPos == off_t(-1))
posixFileSystemFactory::reportError(m_path, errno);
return static_cast <size_type>(curPos);
return static_cast <size_t>(curPos);
}
void posixFileReaderInputStream::seek(const size_type pos)
void posixFileReaderInputStream::seek(const size_t pos)
{
const off_t newPos = ::lseek(m_fd, pos, SEEK_SET);
@ -528,8 +529,8 @@ const vmime::string posixFileSystemFactory::pathToString(const vmime::utility::f
const vmime::utility::file::path posixFileSystemFactory::stringToPathImpl(const vmime::string& str)
{
vmime::string::size_type offset = 0;
vmime::string::size_type prev = 0;
vmime::size_t offset = 0;
vmime::size_t prev = 0;
vmime::utility::file::path path;

View File

@ -181,7 +181,7 @@ static inline bool isFQDN(const vmime::string& str)
if (utility::stringUtils::isStringEqualNoCase(str, "localhost", 9))
return false;
const vmime::string::size_type p = str.find_first_of(".");
const vmime::size_t p = str.find_first_of(".");
return p != vmime::string::npos && p > 0 && p != str.length() - 1;
}

View File

@ -40,6 +40,8 @@
#include <errno.h>
#include <string.h>
#include "vmime/utility/stringUtils.hpp"
#include "vmime/exception.hpp"
@ -426,7 +428,7 @@ const string posixSocket::getPeerName() const
}
posixSocket::size_type posixSocket::getBlockSize() const
size_t posixSocket::getBlockSize() const
{
return 16384; // 16 KB
}
@ -434,12 +436,12 @@ posixSocket::size_type posixSocket::getBlockSize() const
void posixSocket::receive(vmime::string& buffer)
{
const size_type 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);
}
posixSocket::size_type posixSocket::receiveRaw(char* buffer, const size_type count)
size_t posixSocket::receiveRaw(byte_t* buffer, const size_t count)
{
m_status &= ~STATUS_WOULDBLOCK;
@ -529,15 +531,21 @@ posixSocket::size_type posixSocket::receiveRaw(char* buffer, const size_type cou
void posixSocket::send(const vmime::string& buffer)
{
sendRaw(buffer.data(), buffer.length());
sendRaw(reinterpret_cast <const byte_t*>(buffer.data()), buffer.length());
}
void posixSocket::sendRaw(const char* buffer, const size_type count)
void posixSocket::send(const char* str)
{
sendRaw(reinterpret_cast <const byte_t*>(str), ::strlen(str));
}
void posixSocket::sendRaw(const byte_t* buffer, const size_t count)
{
m_status &= ~STATUS_WOULDBLOCK;
size_type size = count;
size_t size = count;
while (size > 0)
{
@ -563,7 +571,7 @@ void posixSocket::sendRaw(const char* buffer, const size_type count)
}
posixSocket::size_type posixSocket::sendRawNonBlocking(const char* buffer, const size_type count)
size_t posixSocket::sendRawNonBlocking(const byte_t* buffer, const size_t count)
{
m_status &= ~STATUS_WOULDBLOCK;

View File

@ -61,8 +61,8 @@ const vmime::string windowsFileSystemFactory::pathToString(const vmime::utility:
const vmime::utility::file::path windowsFileSystemFactory::stringToPathImpl(const vmime::string& str)
{
vmime::string::size_type offset = 0;
vmime::string::size_type prev = 0;
vmime::size_t offset = 0;
vmime::size_t prev = 0;
vmime::utility::file::path path;
@ -117,7 +117,7 @@ bool windowsFileSystemFactory::isValidPathComponent(
}
// Check for invalid characters
for (string::size_type i = 0 ; i < buffer.length() ; ++i)
for (size_t i = 0 ; i < buffer.length() ; ++i)
{
const unsigned char c = buffer[i];
@ -467,7 +467,7 @@ void windowsFileReaderInputStream::reset()
SetFilePointer(m_hFile, 0, NULL, FILE_BEGIN);
}
vmime::utility::stream::size_type windowsFileReaderInputStream::read(value_type* const data, const size_type count)
size_t windowsFileReaderInputStream::read(byte_t* const data, const size_t count)
{
DWORD dwBytesRead;
if (!ReadFile(m_hFile, (LPVOID)data, (DWORD)count, &dwBytesRead, NULL))
@ -475,24 +475,24 @@ vmime::utility::stream::size_type windowsFileReaderInputStream::read(value_type*
return dwBytesRead;
}
vmime::utility::stream::size_type windowsFileReaderInputStream::skip(const size_type count)
size_t windowsFileReaderInputStream::skip(const size_t count)
{
DWORD dwCurPos = SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT);
DWORD dwNewPos = SetFilePointer(m_hFile, (LONG)count, NULL, FILE_CURRENT);
return (dwNewPos - dwCurPos);
}
vmime::utility::stream::size_type windowsFileReaderInputStream::getPosition() const
size_t windowsFileReaderInputStream::getPosition() const
{
DWORD dwCurPos = SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT);
if (dwCurPos == INVALID_SET_FILE_POINTER)
windowsFileSystemFactory::reportError(m_path, GetLastError());
return static_cast <size_type>(dwCurPos);
return static_cast <size_t>(dwCurPos);
}
void windowsFileReaderInputStream::seek(const size_type pos)
void windowsFileReaderInputStream::seek(const size_t pos)
{
DWORD dwNewPos = SetFilePointer(m_hFile, (LONG)pos, NULL, FILE_BEGIN);
@ -530,7 +530,7 @@ windowsFileWriterOutputStream::~windowsFileWriterOutputStream()
CloseHandle(m_hFile);
}
void windowsFileWriterOutputStream::write(const value_type* const data, const size_type count)
void windowsFileWriterOutputStream::writeImpl(const byte_t* const data, const size_t count)
{
DWORD dwBytesWritten;
if (!WriteFile(m_hFile, data, (DWORD)count, &dwBytesWritten, NULL))

View File

@ -206,7 +206,7 @@ static inline bool isFQDN(const vmime::string& str)
if (utility::stringUtils::isStringEqualNoCase(str, "localhost", 9))
return false;
const vmime::string::size_type p = str.find_first_of(".");
const vmime::size_t p = str.find_first_of(".");
return p != vmime::string::npos && p > 0 && p != str.length() - 1;
}

View File

@ -230,7 +230,7 @@ const string windowsSocket::getPeerName() const
}
windowsSocket::size_type windowsSocket::getBlockSize() const
size_t windowsSocket::getBlockSize() const
{
return 16384; // 16 KB
}
@ -238,12 +238,12 @@ windowsSocket::size_type windowsSocket::getBlockSize() const
void windowsSocket::receive(vmime::string& buffer)
{
const size_type size = receiveRaw(m_buffer, sizeof(m_buffer));
const size_t size = receiveRaw(m_buffer, sizeof(m_buffer));
buffer = vmime::string(m_buffer, size);
}
windowsSocket::size_type windowsSocket::receiveRaw(char* buffer, const size_type count)
size_t windowsSocket::receiveRaw(char* buffer, const size_t count)
{
m_status &= ~STATUS_WOULDBLOCK;
@ -307,15 +307,21 @@ windowsSocket::size_type windowsSocket::receiveRaw(char* buffer, const size_type
void windowsSocket::send(const vmime::string& buffer)
{
sendRaw(buffer.data(), buffer.length());
sendRaw(reinterpret_cast <const byte_t*>(buffer.data()), buffer.length());
}
void windowsSocket::sendRaw(const char* buffer, const size_type count)
void windowsSocket::send(const char* str)
{
sendRaw(reinterpret_cast <const byte_t*>(str), strlen(str));
}
void windowsSocket::sendRaw(const char* buffer, const size_t count)
{
m_status &= ~STATUS_WOULDBLOCK;
size_type size = count;
size_t size = count;
while (size > 0)
{
@ -344,7 +350,7 @@ void windowsSocket::sendRaw(const char* buffer, const size_type count)
}
windowsSocket::size_type windowsSocket::sendRawNonBlocking(const char* buffer, const size_type count)
size_t windowsSocket::sendRawNonBlocking(const char* buffer, const size_t count)
{
m_status &= ~STATUS_WOULDBLOCK;

View File

@ -131,7 +131,7 @@ void propertySet::parse(const string& props)
{
value.reserve(50);
const string::value_type quoteChar = *pos;
const char quoteChar = *pos;
bool theEnd = false;
bool escape = false;

View File

@ -59,12 +59,12 @@ relay::relay(const relay& r)
*/
void relay::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
const string::value_type* const pend = buffer.data() + end;
const string::value_type* const pstart = buffer.data() + position;
const string::value_type* p = pend - 1;
const char* const pend = buffer.data() + end;
const char* const pstart = buffer.data() + position;
const char* p = pend - 1;
// Find the beginning of the date part
while (p >= pstart && *p != ';')
@ -107,7 +107,7 @@ void relay::parseImpl
// A little hack for handling comments
if (inComment)
{
string::size_type par = word.find(')');
size_t par = word.find(')');
if (par != string::npos)
{
@ -202,7 +202,7 @@ void relay::parseImpl
void relay::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
std::ostringstream oss;
int count = 0;

View File

@ -92,11 +92,11 @@ void* X509Certificate_GnuTLS::getInternalData()
shared_ptr <X509Certificate> X509Certificate::import(utility::inputStream& is)
{
byteArray bytes;
utility::stream::value_type chunk[4096];
byte_t chunk[4096];
while (!is.eof())
{
const utility::stream::size_type len = is.read(chunk, sizeof(chunk));
const size_t len = is.read(chunk, sizeof(chunk));
bytes.insert(bytes.end(), chunk, chunk + len);
}
@ -146,7 +146,7 @@ void X509Certificate_GnuTLS::write
gnutls_x509_crt_export(m_data->cert, fmt, &data[0], &dataSize);
os.write(reinterpret_cast <utility::stream::value_type*>(&data[0]), dataSize);
os.write(reinterpret_cast <byte_t*>(&data[0]), dataSize);
}

View File

@ -171,11 +171,11 @@ shared_ptr <X509Certificate> X509Certificate_OpenSSL::importInternal(X509* cert)
shared_ptr <X509Certificate> X509Certificate::import(utility::inputStream& is)
{
byteArray bytes;
utility::stream::value_type chunk[4096];
byte_t chunk[4096];
while (!is.eof())
{
const int len = is.read(chunk, sizeof(chunk));
const size_t len = is.read(chunk, sizeof(chunk));
bytes.insert(bytes.end(), chunk, chunk + len);
}
@ -189,7 +189,7 @@ shared_ptr <X509Certificate> X509Certificate::import
{
shared_ptr <X509Certificate_OpenSSL> cert = make_shared <X509Certificate_OpenSSL>();
BIO* membio = BIO_new_mem_buf(const_cast <byte_t*>(data), length);
BIO* membio = BIO_new_mem_buf(const_cast <byte_t*>(data), static_cast <int>(length));
if (!PEM_read_bio_X509(membio, &(cert->m_data->cert), 0, 0))
{
@ -207,7 +207,7 @@ void X509Certificate_OpenSSL::write
(utility::outputStream& os, const Format format) const
{
BIO* membio = 0;
int dataSize = 0;
long dataSize = 0;
unsigned char* out = 0;
if (format == FORMAT_DER)
@ -215,7 +215,7 @@ void X509Certificate_OpenSSL::write
if ((dataSize = i2d_X509(m_data->cert, &out)) < 0)
goto err;
os.write(reinterpret_cast <utility::stream::value_type*>(out), dataSize);
os.write(reinterpret_cast <byte_t*>(out), dataSize);
os.flush();
OPENSSL_free(out);
}
@ -228,7 +228,7 @@ void X509Certificate_OpenSSL::write
goto pem_err;
dataSize = BIO_get_mem_data(membio, &out);
os.write(reinterpret_cast <utility::stream::value_type*>(out), dataSize);
os.write(reinterpret_cast <byte_t*>(out), dataSize);
os.flush();
BIO_vfree(membio);
}
@ -281,7 +281,7 @@ bool X509Certificate_OpenSSL::checkIssuer(shared_ptr <const X509Certificate> cer
out = BIO_new(BIO_s_mem());
X509_NAME_print_ex(out, X509_get_issuer_name(m_data->cert), 0, XN_FLAG_RFC2253);
int n = BIO_get_mem_data(out, &issuer);
long n = BIO_get_mem_data(out, &issuer);
vmime::string thisIssuerName((char*)issuer, n);
BIO_free(out);

View File

@ -83,7 +83,7 @@ void md5MessageDigest::init()
}
static void copyUint8Array(vmime_uint8* dest, const vmime_uint8* src, unsigned long count)
static void copyUint8Array(vmime_uint8* dest, const vmime_uint8* src, size_t count)
{
for ( ; count >= 4 ; count -= 4, dest += 4, src += 4)
{
@ -104,7 +104,7 @@ static inline vmime_uint32 swapUint32(const vmime_uint32 D)
}
static inline void swapUint32Array(vmime_uint32* buf, unsigned long words)
static inline void swapUint32Array(vmime_uint32* buf, size_t words)
{
for ( ; words >= 4 ; words -= 4, buf += 4)
{
@ -131,17 +131,16 @@ void md5MessageDigest::update(const string& s)
}
void md5MessageDigest::update(const byte_t* data, const unsigned long offset,
const unsigned long len)
void md5MessageDigest::update(const byte_t* data, const size_t offset, const size_t len)
{
update(data + offset, len);
}
void md5MessageDigest::update(const byte_t* data, const unsigned long length)
void md5MessageDigest::update(const byte_t* data, const size_t length)
{
const unsigned long avail = 64 - (m_byteCount & 0x3f);
unsigned long len = length;
const size_t avail = 64 - (m_byteCount & 0x3f);
size_t len = length;
m_byteCount += len;
@ -177,7 +176,7 @@ void md5MessageDigest::finalize(const string& s)
}
void md5MessageDigest::finalize(const byte_t* buffer, const unsigned long len)
void md5MessageDigest::finalize(const byte_t* buffer, const size_t len)
{
update(buffer, len);
finalize();
@ -185,7 +184,7 @@ void md5MessageDigest::finalize(const byte_t* buffer, const unsigned long len)
void md5MessageDigest::finalize(const byte_t* buffer,
const unsigned long offset, const unsigned long len)
const size_t offset, const size_t len)
{
update(buffer, offset, len);
finalize();
@ -329,7 +328,7 @@ void md5MessageDigest::transform()
}
int md5MessageDigest::getDigestLength() const
size_t md5MessageDigest::getDigestLength() const
{
return 16;
}

View File

@ -34,14 +34,14 @@ namespace digest {
const string messageDigest::getHexDigest() const
{
const byte_t* hash = getDigest();
const int len = getDigestLength();
const size_t len = getDigestLength();
static const unsigned char hex[] = "0123456789abcdef";
std::ostringstream oss;
oss.imbue(std::locale::classic());
for (int i = 0 ; i < len ; ++i)
for (size_t i = 0 ; i < len ; ++i)
{
oss << hex[(hash[i] & 0xf0) >> 4];
oss << hex[(hash[i] & 0x0f)];

View File

@ -95,14 +95,14 @@ void sha1MessageDigest::update(const string& s)
}
void sha1MessageDigest::update(const byte_t* buffer, const unsigned long offset,
void sha1MessageDigest::update(const byte_t* buffer, const size_t offset,
const unsigned long len)
{
update(buffer + offset, len);
}
void sha1MessageDigest::update(const byte_t* buffer, const unsigned long len)
void sha1MessageDigest::update(const byte_t* buffer, const size_t len)
{
unsigned int i, j;
@ -174,7 +174,7 @@ void sha1MessageDigest::finalize(const string& s)
}
void sha1MessageDigest::finalize(const byte_t* buffer, const unsigned long len)
void sha1MessageDigest::finalize(const byte_t* buffer, const size_t len)
{
update(buffer, len);
finalize();
@ -182,7 +182,7 @@ void sha1MessageDigest::finalize(const byte_t* buffer, const unsigned long len)
void sha1MessageDigest::finalize(const byte_t* buffer,
const unsigned long offset, const unsigned long len)
const size_t offset, const size_t len)
{
finalize(buffer + offset, len);
}
@ -251,7 +251,7 @@ void sha1MessageDigest::transform
}
int sha1MessageDigest::getDigestLength() const
size_t sha1MessageDigest::getDigestLength() const
{
return 20;
}

View File

@ -106,7 +106,7 @@ shared_ptr <SASLMechanism> SASLContext::suggestMechanism
}
void SASLContext::decodeB64(const string& input, byte_t** output, long* outputLen)
void SASLContext::decodeB64(const string& input, byte_t** output, size_t* outputLen)
{
string res;
@ -127,7 +127,7 @@ void SASLContext::decodeB64(const string& input, byte_t** output, long* outputLe
}
const string SASLContext::encodeB64(const byte_t* input, const long inputLen)
const string SASLContext::encodeB64(const byte_t* input, const size_t inputLen)
{
string res;

View File

@ -99,8 +99,8 @@ shared_ptr <SASLContext> SASLSession::getContext()
bool SASLSession::evaluateChallenge
(const byte_t* challenge, const long challengeLen,
byte_t** response, long* responseLen)
(const byte_t* challenge, const size_t challengeLen,
byte_t** response, size_t* responseLen)
{
return m_mech->step(dynamicCast <SASLSession>(shared_from_this()),
challenge, challengeLen, response, responseLen);

View File

@ -30,9 +30,12 @@
#include "vmime/security/sasl/SASLSocket.hpp"
#include "vmime/security/sasl/SASLSession.hpp"
#include "vmime/utility/stringUtils.hpp"
#include "vmime/exception.hpp"
#include <algorithm>
#include <cstring>
#include <gsasl.h>
@ -75,7 +78,7 @@ bool SASLSocket::isConnected() const
}
SASLSocket::size_type SASLSocket::getBlockSize() const
size_t SASLSocket::getBlockSize() const
{
return m_wrapped->getBlockSize();
}
@ -95,17 +98,17 @@ const string SASLSocket::getPeerAddress() const
void SASLSocket::receive(string& buffer)
{
const size_type n = receiveRaw(m_recvBuffer, sizeof(m_recvBuffer));
const size_t n = receiveRaw(m_recvBuffer, sizeof(m_recvBuffer));
buffer = string(m_recvBuffer, n);
buffer = utility::stringUtils::makeStringFromBytes(m_recvBuffer, n);
}
SASLSocket::size_type SASLSocket::receiveRaw(char* buffer, const size_type count)
size_t SASLSocket::receiveRaw(byte_t* buffer, const size_t count)
{
if (m_pendingLen != 0)
{
const size_type copyLen =
const size_t copyLen =
(count >= m_pendingLen ? m_pendingLen : count);
std::copy(m_pendingBuffer + m_pendingPos,
@ -127,14 +130,13 @@ SASLSocket::size_type SASLSocket::receiveRaw(char* buffer, const size_type count
return copyLen;
}
const size_type n = m_wrapped->receiveRaw(buffer, count);
const size_t n = m_wrapped->receiveRaw(buffer, count);
byte_t* output = 0;
long outputLen = 0;
size_t outputLen = 0;
m_session->getMechanism()->decode
(m_session, reinterpret_cast <const byte_t*>(buffer), n,
&output, &outputLen);
(m_session, buffer, n, &output, &outputLen);
// If we can not copy all decoded data into the output buffer, put
// remaining data into a pending buffer for next calls to receive()
@ -161,23 +163,27 @@ SASLSocket::size_type SASLSocket::receiveRaw(char* buffer, const size_type count
void SASLSocket::send(const string& buffer)
{
sendRaw(buffer.data(), buffer.length());
sendRaw(reinterpret_cast <const byte_t*>(buffer.data()), buffer.length());
}
void SASLSocket::sendRaw(const char* buffer, const size_type count)
void SASLSocket::send(const char* str)
{
sendRaw(reinterpret_cast <const byte_t*>(str), strlen(str));
}
void SASLSocket::sendRaw(const byte_t* buffer, const size_t count)
{
byte_t* output = 0;
long outputLen = 0;
size_t outputLen = 0;
m_session->getMechanism()->encode
(m_session, reinterpret_cast <const byte_t*>(buffer), count,
&output, &outputLen);
(m_session, buffer, count, &output, &outputLen);
try
{
m_wrapped->sendRaw
(reinterpret_cast <const char*>(output), outputLen);
m_wrapped->sendRaw(output, outputLen);
}
catch (...)
{
@ -189,21 +195,19 @@ void SASLSocket::sendRaw(const char* buffer, const size_type count)
}
SASLSocket::size_type SASLSocket::sendRawNonBlocking(const char* buffer, const size_type count)
size_t SASLSocket::sendRawNonBlocking(const byte_t* buffer, const size_t count)
{
byte_t* output = 0;
long outputLen = 0;
size_t outputLen = 0;
m_session->getMechanism()->encode
(m_session, reinterpret_cast <const byte_t*>(buffer), count,
&output, &outputLen);
(m_session, buffer, count, &output, &outputLen);
size_type bytesSent = 0;
size_t bytesSent = 0;
try
{
bytesSent = m_wrapped->sendRawNonBlocking
(reinterpret_cast <const char*>(output), outputLen);
bytesSent = m_wrapped->sendRawNonBlocking(output, outputLen);
}
catch (...)
{

View File

@ -63,8 +63,8 @@ const string builtinSASLMechanism::getName() const
bool builtinSASLMechanism::step
(shared_ptr <SASLSession> sess, const byte_t* challenge, const long challengeLen,
byte_t** response, long* responseLen)
(shared_ptr <SASLSession> sess, const byte_t* challenge, const size_t challengeLen,
byte_t** response, size_t* responseLen)
{
char* output = 0;
size_t outputLen = 0;
@ -121,8 +121,8 @@ bool builtinSASLMechanism::isComplete() const
void builtinSASLMechanism::encode
(shared_ptr <SASLSession> sess, const byte_t* input, const long inputLen,
byte_t** output, long* outputLen)
(shared_ptr <SASLSession> sess, const byte_t* input, const size_t inputLen,
byte_t** output, size_t* outputLen)
{
char* coutput = 0;
size_t coutputLen = 0;
@ -154,8 +154,8 @@ void builtinSASLMechanism::encode
void builtinSASLMechanism::decode
(shared_ptr <SASLSession> sess, const byte_t* input, const long inputLen,
byte_t** output, long* outputLen)
(shared_ptr <SASLSession> sess, const byte_t* input, const size_t inputLen,
byte_t** output, size_t* outputLen)
{
char* coutput = 0;
size_t coutputLen = 0;

View File

@ -40,7 +40,7 @@ streamContentHandler::streamContentHandler()
streamContentHandler::streamContentHandler(shared_ptr <utility::inputStream> is,
const utility::stream::size_type length, const vmime::encoding& enc)
const size_t length, const vmime::encoding& enc)
{
setData(is, length, enc);
}
@ -52,7 +52,7 @@ streamContentHandler::~streamContentHandler()
streamContentHandler::streamContentHandler(const streamContentHandler& cts)
: contentHandler(), m_encoding(cts.m_encoding), m_contentType(cts.m_contentType),
: contentHandler(), m_contentType(cts.m_contentType), m_encoding(cts.m_encoding),
m_stream(cts.m_stream), m_length(cts.m_length)
{
}
@ -77,7 +77,7 @@ streamContentHandler& streamContentHandler::operator=(const streamContentHandler
void streamContentHandler::setData(shared_ptr <utility::inputStream> is,
const utility::stream::size_type length, const vmime::encoding& enc)
const size_t length, const vmime::encoding& enc)
{
m_encoding = enc;
m_length = length;
@ -86,7 +86,7 @@ void streamContentHandler::setData(shared_ptr <utility::inputStream> is,
void streamContentHandler::generate(utility::outputStream& os, const vmime::encoding& enc,
const string::size_type maxLineLength) const
const size_t maxLineLength) const
{
if (!m_stream)
return;
@ -185,7 +185,7 @@ void streamContentHandler::extractRaw(utility::outputStream& os,
}
string::size_type streamContentHandler::getLength() const
size_t streamContentHandler::getLength() const
{
return (m_length);
}

View File

@ -56,8 +56,8 @@ stringContentHandler::stringContentHandler(const utility::stringProxy& str, cons
}
stringContentHandler::stringContentHandler(const string& buffer, const string::size_type start,
const string::size_type end, const vmime::encoding& enc)
stringContentHandler::stringContentHandler(const string& buffer, const size_t start,
const size_t end, const vmime::encoding& enc)
: m_encoding(enc), m_string(buffer, start, end)
{
}
@ -98,8 +98,8 @@ void stringContentHandler::setData(const string& buffer, const vmime::encoding&
}
void stringContentHandler::setData(const string& buffer, const string::size_type start,
const string::size_type end, const vmime::encoding& enc)
void stringContentHandler::setData(const string& buffer, const size_t start,
const size_t end, const vmime::encoding& enc)
{
m_encoding = enc;
m_string.set(buffer, start, end);
@ -114,7 +114,7 @@ stringContentHandler& stringContentHandler::operator=(const string& buffer)
void stringContentHandler::generate(utility::outputStream& os,
const vmime::encoding& enc, const string::size_type maxLineLength) const
const vmime::encoding& enc, const size_t maxLineLength) const
{
// Managed data is already encoded
if (isEncoded())
@ -191,7 +191,7 @@ void stringContentHandler::extractRaw(utility::outputStream& os,
}
string::size_type stringContentHandler::getLength() const
size_t stringContentHandler::getLength() const
{
return (m_string.length());
}

View File

@ -68,12 +68,12 @@ text::~text()
void text::parseImpl
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
(const parsingContext& ctx, const string& buffer, const size_t position,
const size_t end, size_t* newPosition)
{
removeAllWords();
string::size_type newPos;
size_t newPos;
const std::vector <shared_ptr <word> > words = word::parseMultiple(ctx, buffer, position, end, &newPos);
@ -88,7 +88,7 @@ void text::parseImpl
void text::generateImpl
(const generationContext& ctx, utility::outputStream& os,
const string::size_type curLinePos, string::size_type* newLinePos) const
const size_t curLinePos, size_t* newLinePos) const
{
encodeAndFold(ctx, os, curLinePos, newLinePos, 0);
}
@ -251,8 +251,8 @@ shared_ptr <text> text::newFromString(const string& in, const charset& ch)
void text::createFromString(const string& in, const charset& ch)
{
string::size_type asciiCount = 0;
string::size_type asciiPercent = 0;
size_t asciiCount = 0;
size_t asciiPercent = 0;
removeAllWords();
@ -281,7 +281,7 @@ void text::createFromString(const string& in, const charset& ch)
bool prevIs8bit = false; // is previous word 8-bit?
unsigned int count = 0; // total number of words
for (string::size_type end = in.size(), pos = 0, start = 0 ; ; )
for (size_t end = in.size(), pos = 0, start = 0 ; ; )
{
if (pos == end || parserHelpers::isSpace(in[pos]))
{
@ -352,9 +352,9 @@ void text::createFromString(const string& in, const charset& ch)
void text::encodeAndFold
(const generationContext& ctx, utility::outputStream& os,
const string::size_type firstLineOffset, string::size_type* lastLineLength, const int flags) const
const size_t firstLineOffset, size_t* lastLineLength, const int flags) const
{
string::size_type curLineLength = firstLineOffset;
size_t curLineLength = firstLineOffset;
word::generatorState state;
for (size_t wi = 0 ; wi < getWordCount() ; ++wi)

View File

@ -70,34 +70,34 @@ const unsigned char b64Encoder::sm_decodeMap[256] =
};
#ifndef VMIME_BUILDING_DOC
#define B64_WRITE(s, x, l) s.write(reinterpret_cast <utility::stream::value_type*>(x), l)
#define B64_WRITE(s, x, l) s.write(reinterpret_cast <byte_t*>(x), l)
#endif // VMIME_BUILDING_DOC
utility::stream::size_type b64Encoder::encode(utility::inputStream& in,
size_t b64Encoder::encode(utility::inputStream& in,
utility::outputStream& out, utility::progressListener* progress)
{
in.reset(); // may not work...
const string::size_type propMaxLineLength =
getProperties().getProperty <string::size_type>("maxlinelength", static_cast <string::size_type>(-1));
const size_t propMaxLineLength =
getProperties().getProperty <size_t>("maxlinelength", static_cast <size_t>(-1));
const bool cutLines = (propMaxLineLength != static_cast <string::size_type>(-1));
const string::size_type maxLineLength = std::min(propMaxLineLength, static_cast <string::size_type>(76));
const bool cutLines = (propMaxLineLength != static_cast <size_t>(-1));
const size_t maxLineLength = std::min(propMaxLineLength, static_cast <size_t>(76));
// Process data
utility::stream::value_type buffer[65536];
utility::stream::size_type bufferLength = 0;
utility::stream::size_type bufferPos = 0;
byte_t buffer[65536];
size_t bufferLength = 0;
size_t bufferPos = 0;
unsigned char bytes[3];
unsigned char output[4];
byte_t bytes[3];
byte_t output[4];
utility::stream::size_type total = 0;
utility::stream::size_type inTotal = 0;
size_t total = 0;
size_t inTotal = 0;
string::size_type curCol = 0;
size_t curCol = 0;
if (progress)
progress->start(0);
@ -191,21 +191,21 @@ utility::stream::size_type b64Encoder::encode(utility::inputStream& in,
}
utility::stream::size_type b64Encoder::decode(utility::inputStream& in,
size_t b64Encoder::decode(utility::inputStream& in,
utility::outputStream& out, utility::progressListener* progress)
{
in.reset(); // may not work...
// Process the data
char buffer[16384];
utility::stream::size_type bufferLength = 0;
utility::stream::size_type bufferPos = 0;
byte_t buffer[16384];
size_t bufferLength = 0;
size_t bufferPos = 0;
utility::stream::size_type total = 0;
utility::stream::size_type inTotal = 0;
size_t total = 0;
size_t inTotal = 0;
unsigned char bytes[4];
unsigned char output[3];
byte_t bytes[4];
byte_t output[3];
if (progress)
progress->start(0);
@ -234,7 +234,7 @@ utility::stream::size_type b64Encoder::decode(utility::inputStream& in,
while (count < 4 && bufferPos < bufferLength)
{
const unsigned char c = buffer[bufferPos++];
const byte_t c = buffer[bufferPos++];
if (!parserHelpers::isSpace(c))
bytes[count++] = c;
@ -250,7 +250,7 @@ utility::stream::size_type b64Encoder::decode(utility::inputStream& in,
while (count < 4 && bufferPos < bufferLength)
{
const unsigned char c = buffer[bufferPos++];
const byte_t c = buffer[bufferPos++];
if (!parserHelpers::isSpace(c))
bytes[count++] = c;
@ -259,13 +259,13 @@ utility::stream::size_type b64Encoder::decode(utility::inputStream& in,
}
// Decode the bytes
unsigned char c1 = bytes[0];
unsigned char c2 = bytes[1];
byte_t c1 = bytes[0];
byte_t c2 = bytes[1];
if (c1 == '=' || c2 == '=') // end
break;
output[0] = static_cast <unsigned char>((sm_decodeMap[c1] << 2) | ((sm_decodeMap[c2] & 0x30) >> 4));
output[0] = static_cast <byte_t>((sm_decodeMap[c1] << 2) | ((sm_decodeMap[c2] & 0x30) >> 4));
c1 = bytes[2];
@ -276,7 +276,7 @@ utility::stream::size_type b64Encoder::decode(utility::inputStream& in,
break;
}
output[1] = static_cast <unsigned char>(((sm_decodeMap[c2] & 0xf) << 4) | ((sm_decodeMap[c1] & 0x3c) >> 2));
output[1] = static_cast <byte_t>(((sm_decodeMap[c2] & 0xf) << 4) | ((sm_decodeMap[c1] & 0x3c) >> 2));
c2 = bytes[3];
@ -287,7 +287,7 @@ utility::stream::size_type b64Encoder::decode(utility::inputStream& in,
break;
}
output[2] = static_cast <unsigned char>(((sm_decodeMap[c1] & 0x03) << 6) | sm_decodeMap[c2]);
output[2] = static_cast <byte_t>(((sm_decodeMap[c1] & 0x03) << 6) | sm_decodeMap[c2]);
B64_WRITE(out, output, 3);
total += 3;
@ -304,13 +304,13 @@ utility::stream::size_type b64Encoder::decode(utility::inputStream& in,
}
utility::stream::size_type b64Encoder::getEncodedSize(const utility::stream::size_type n) const
size_t b64Encoder::getEncodedSize(const size_t n) const
{
const string::size_type propMaxLineLength =
getProperties().getProperty <string::size_type>("maxlinelength", static_cast <string::size_type>(-1));
const size_t propMaxLineLength =
getProperties().getProperty <size_t>("maxlinelength", static_cast <size_t>(-1));
const bool cutLines = (propMaxLineLength != static_cast <string::size_type>(-1));
const string::size_type maxLineLength = std::min(propMaxLineLength, static_cast <string::size_type>(76));
const bool cutLines = (propMaxLineLength != static_cast <size_t>(-1));
const size_t maxLineLength = std::min(propMaxLineLength, static_cast <size_t>(76));
return (n * 4) / 3 // 3 bytes of input provide 4 bytes of output
+ (cutLines ? (n / maxLineLength) * 2 : 0) // CRLF (2 bytes) for each line.
@ -318,7 +318,7 @@ utility::stream::size_type b64Encoder::getEncodedSize(const utility::stream::siz
}
utility::stream::size_type b64Encoder::getDecodedSize(const utility::stream::size_type n) const
size_t b64Encoder::getDecodedSize(const size_t n) const
{
// 4 bytes of input provide 3 bytes of output
return (n * 3) / 4;

View File

@ -36,13 +36,13 @@ noopEncoder::noopEncoder()
}
utility::stream::size_type noopEncoder::encode(utility::inputStream& in,
size_t noopEncoder::encode(utility::inputStream& in,
utility::outputStream& out, utility::progressListener* progress)
{
in.reset(); // may not work...
// No encoding performed
utility::stream::size_type res = 0;
size_t res = 0;
if (progress)
res = utility::bufferedStreamCopy(in, out, 0, progress);
@ -53,13 +53,13 @@ utility::stream::size_type noopEncoder::encode(utility::inputStream& in,
}
utility::stream::size_type noopEncoder::decode(utility::inputStream& in,
size_t noopEncoder::decode(utility::inputStream& in,
utility::outputStream& out, utility::progressListener* progress)
{
in.reset(); // may not work...
// No decoding performed
utility::stream::size_type res = 0;
size_t res = 0;
if (progress)
res = utility::bufferedStreamCopy(in, out, 0, progress);
@ -70,13 +70,13 @@ utility::stream::size_type noopEncoder::decode(utility::inputStream& in,
}
utility::stream::size_type noopEncoder::getEncodedSize(const utility::stream::size_type n) const
size_t noopEncoder::getEncodedSize(const size_t n) const
{
return n;
}
utility::stream::size_type noopEncoder::getDecodedSize(const utility::stream::size_type n) const
size_t noopEncoder::getDecodedSize(const size_t n) const
{
return n;
}

View File

@ -69,7 +69,7 @@ const unsigned char qpEncoder::sm_hexDigits[] = "0123456789ABCDEF";
// This is a quick lookup table:
// '1' means "encode", '0' means "no encoding"
//
const unsigned char qpEncoder::sm_RFC2047EncodeTable[] =
const vmime_uint8 qpEncoder::sm_RFC2047EncodeTable[] =
{
/* 0 NUL */ 1, /* 1 SOH */ 1, /* 2 STX */ 1, /* 3 ETX */ 1, /* 4 EOT */ 1, /* 5 ENQ */ 1,
/* 6 ACK */ 1, /* 7 BEL */ 1, /* 8 BS */ 1, /* 9 TAB */ 1, /* 10 LF */ 1, /* 11 VT */ 1,
@ -97,7 +97,7 @@ const unsigned char qpEncoder::sm_RFC2047EncodeTable[] =
// Hex-decoding table
const unsigned char qpEncoder::sm_hexDecodeTable[256] =
const vmime_uint8 qpEncoder::sm_hexDecodeTable[256] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -119,14 +119,14 @@ const unsigned char qpEncoder::sm_hexDecodeTable[256] =
// static
bool qpEncoder::RFC2047_isEncodingNeededForChar(const unsigned char c)
bool qpEncoder::RFC2047_isEncodingNeededForChar(const byte_t c)
{
return (c >= 128 || sm_RFC2047EncodeTable[c] != 0);
}
// static
int qpEncoder::RFC2047_getEncodedLength(const unsigned char c)
int qpEncoder::RFC2047_getEncodedLength(const byte_t c)
{
if (c >= 128 || sm_RFC2047EncodeTable[c] != 0)
{
@ -157,37 +157,37 @@ int qpEncoder::RFC2047_getEncodedLength(const unsigned char c)
outBufferPos += 3; \
curCol += 3
#define QP_WRITE(s, x, l) s.write(reinterpret_cast <utility::stream::value_type*>(x), l)
#define QP_WRITE(s, x, l) s.write(reinterpret_cast <byte_t*>(x), l)
#endif // VMIME_BUILDING_DOC
utility::stream::size_type qpEncoder::encode(utility::inputStream& in,
size_t qpEncoder::encode(utility::inputStream& in,
utility::outputStream& out, utility::progressListener* progress)
{
in.reset(); // may not work...
const string::size_type propMaxLineLength =
getProperties().getProperty <string::size_type>("maxlinelength", static_cast <string::size_type>(-1));
const size_t propMaxLineLength =
getProperties().getProperty <size_t>("maxlinelength", static_cast <size_t>(-1));
const bool rfc2047 = getProperties().getProperty <bool>("rfc2047", false);
const bool text = getProperties().getProperty <bool>("text", false); // binary mode by default
const bool cutLines = (propMaxLineLength != static_cast <string::size_type>(-1));
const string::size_type maxLineLength = std::min(propMaxLineLength, static_cast <string::size_type>(74));
const bool cutLines = (propMaxLineLength != static_cast <size_t>(-1));
const size_t maxLineLength = std::min(propMaxLineLength, static_cast <size_t>(74));
// Process the data
char buffer[16384];
utility::stream::size_type bufferLength = 0;
utility::stream::size_type bufferPos = 0;
byte_t buffer[16384];
size_t bufferLength = 0;
size_t bufferPos = 0;
string::size_type curCol = 0;
size_t curCol = 0;
unsigned char outBuffer[16384];
int outBufferPos = 0;
byte_t outBuffer[16384];
size_t outBufferPos = 0;
utility::stream::size_type total = 0;
utility::stream::size_type inTotal = 0;
size_t total = 0;
size_t inTotal = 0;
if (progress)
progress->start(0);
@ -215,7 +215,7 @@ utility::stream::size_type qpEncoder::encode(utility::inputStream& in,
}
// Get the next char and encode it
const unsigned char c = static_cast <unsigned char>(buffer[bufferPos++]);
const byte_t c = buffer[bufferPos++];
if (rfc2047)
{
@ -371,7 +371,7 @@ utility::stream::size_type qpEncoder::encode(utility::inputStream& in,
}
utility::stream::size_type qpEncoder::decode(utility::inputStream& in,
size_t qpEncoder::decode(utility::inputStream& in,
utility::outputStream& out, utility::progressListener* progress)
{
in.reset(); // may not work...
@ -379,20 +379,20 @@ utility::stream::size_type qpEncoder::decode(utility::inputStream& in,
// Process the data
const bool rfc2047 = getProperties().getProperty <bool>("rfc2047", false);
char buffer[16384];
utility::stream::size_type bufferLength = 0;
utility::stream::size_type bufferPos = 0;
byte_t buffer[16384];
size_t bufferLength = 0;
size_t bufferPos = 0;
unsigned char outBuffer[16384];
int outBufferPos = 0;
byte_t outBuffer[16384];
size_t outBufferPos = 0;
utility::stream::size_type total = 0;
utility::stream::size_type inTotal = 0;
size_t total = 0;
size_t inTotal = 0;
while (bufferPos < bufferLength || !in.eof())
{
// Flush current output buffer
if (outBufferPos >= static_cast <int>(sizeof(outBuffer)))
if (outBufferPos >= sizeof(outBuffer))
{
QP_WRITE(out, outBuffer, outBufferPos);
@ -412,7 +412,7 @@ utility::stream::size_type qpEncoder::decode(utility::inputStream& in,
}
// Decode the next sequence (hex-encoded byte or printable character)
unsigned char c = static_cast <unsigned char>(buffer[bufferPos++]);
byte_t c = buffer[bufferPos++];
++inTotal;
@ -428,7 +428,7 @@ utility::stream::size_type qpEncoder::decode(utility::inputStream& in,
if (bufferPos < bufferLength)
{
c = static_cast <unsigned char>(buffer[bufferPos++]);
c = buffer[bufferPos++];
++inTotal;
@ -468,11 +468,11 @@ utility::stream::size_type qpEncoder::decode(utility::inputStream& in,
if (bufferPos < bufferLength)
{
const unsigned char next = static_cast <unsigned char>(buffer[bufferPos++]);
const byte_t next = buffer[bufferPos++];
++inTotal;
const unsigned char value = static_cast <unsigned char>
const byte_t value = static_cast <byte_t>
(sm_hexDecodeTable[c] * 16 + sm_hexDecodeTable[next]);
outBuffer[outBufferPos++] = value;
@ -532,13 +532,13 @@ utility::stream::size_type qpEncoder::decode(utility::inputStream& in,
}
utility::stream::size_type qpEncoder::getEncodedSize(const utility::stream::size_type n) const
size_t qpEncoder::getEncodedSize(const size_t n) const
{
const string::size_type propMaxLineLength =
getProperties().getProperty <string::size_type>("maxlinelength", static_cast <string::size_type>(-1));
const size_t propMaxLineLength =
getProperties().getProperty <size_t>("maxlinelength", static_cast <size_t>(-1));
const bool cutLines = (propMaxLineLength != static_cast <string::size_type>(-1));
const string::size_type maxLineLength = std::min(propMaxLineLength, static_cast <string::size_type>(74));
const bool cutLines = (propMaxLineLength != static_cast <size_t>(-1));
const size_t maxLineLength = std::min(propMaxLineLength, static_cast <size_t>(74));
// Worst cast: 1 byte of input provide 3 bytes of output
// Count CRLF (2 bytes) for each line.
@ -546,7 +546,7 @@ utility::stream::size_type qpEncoder::getEncodedSize(const utility::stream::size
}
utility::stream::size_type qpEncoder::getDecodedSize(const utility::stream::size_type n) const
size_t qpEncoder::getDecodedSize(const size_t n) const
{
// Worst case: 1 byte of input equals 1 byte of output
return n;

View File

@ -52,19 +52,19 @@ const std::vector <string> uuEncoder::getAvailableProperties() const
// This is the character encoding function to make a character printable
static inline unsigned char UUENCODE(const unsigned long c)
static inline byte_t UUENCODE(const unsigned int c)
{
return static_cast <unsigned char>((c & 077) + ' ');
return static_cast <byte_t>((c & 077) + ' ');
}
// Single character decoding
static inline unsigned char UUDECODE(const unsigned long c)
static inline unsigned int UUDECODE(const unsigned int c)
{
return static_cast <unsigned char>((c - ' ') & 077);
return (c - ' ') & 077;
}
utility::stream::size_type uuEncoder::encode(utility::inputStream& in,
size_t uuEncoder::encode(utility::inputStream& in,
utility::outputStream& out, utility::progressListener* progress)
{
in.reset(); // may not work...
@ -72,12 +72,11 @@ utility::stream::size_type uuEncoder::encode(utility::inputStream& in,
const string propFilename = getProperties().getProperty <string>("filename", "");
const string propMode = getProperties().getProperty <string>("mode", "644");
const string::size_type maxLineLength =
std::min(getProperties().getProperty <string::size_type>("maxlinelength", 46),
static_cast <string::size_type>(46));
const size_t maxLineLength =
std::min(getProperties().getProperty <size_t>("maxlinelength", 46), static_cast <size_t>(46));
utility::stream::size_type total = 0;
utility::stream::size_type inTotal = 0;
size_t total = 0;
size_t inTotal = 0;
// Output the prelude text ("begin [mode] [filename]")
out << "begin";
@ -92,8 +91,8 @@ utility::stream::size_type uuEncoder::encode(utility::inputStream& in,
total += 7;
// Process the data
utility::stream::value_type inBuffer[64];
utility::stream::value_type outBuffer[64];
byte_t inBuffer[64];
byte_t outBuffer[64];
if (progress)
progress->start(0);
@ -103,17 +102,17 @@ utility::stream::size_type uuEncoder::encode(utility::inputStream& in,
// Process up to 45 characters per line
std::fill(inBuffer, inBuffer + sizeof(inBuffer), 0);
const utility::stream::size_type inLength = in.read(inBuffer, maxLineLength - 1);
const size_t inLength = in.read(inBuffer, maxLineLength - 1);
outBuffer[0] = UUENCODE(inLength); // Line length
outBuffer[0] = UUENCODE(static_cast <unsigned int>(inLength)); // Line length
utility::stream::size_type j = 1;
size_t j = 1;
for (utility::stream::size_type i = 0 ; i < inLength ; i += 3, j += 4)
for (size_t i = 0 ; i < inLength ; i += 3, j += 4)
{
const unsigned char c1 = static_cast <unsigned char>(inBuffer[i]);
const unsigned char c2 = static_cast <unsigned char>(inBuffer[i + 1]);
const unsigned char c3 = static_cast <unsigned char>(inBuffer[i + 2]);
const byte_t c1 = inBuffer[i];
const byte_t c2 = inBuffer[i + 1];
const byte_t c3 = inBuffer[i + 2];
outBuffer[j] = UUENCODE(c1 >> 2);
outBuffer[j + 1] = UUENCODE(((c1 << 4) & 060) | ((c2 >> 4) & 017));
@ -143,17 +142,17 @@ utility::stream::size_type uuEncoder::encode(utility::inputStream& in,
}
utility::stream::size_type uuEncoder::decode(utility::inputStream& in,
size_t uuEncoder::decode(utility::inputStream& in,
utility::outputStream& out, utility::progressListener* progress)
{
in.reset(); // may not work...
// Process the data
utility::stream::value_type inBuffer[64];
utility::stream::value_type outBuffer[64];
byte_t inBuffer[64];
byte_t outBuffer[64];
utility::stream::size_type total = 0;
utility::stream::size_type inTotal = 0;
size_t total = 0;
size_t inTotal = 0;
bool stop = false;
@ -165,15 +164,14 @@ utility::stream::size_type uuEncoder::decode(utility::inputStream& in,
while (!stop && !in.eof())
{
// Get the line length
utility::stream::value_type lengthChar;
byte_t lengthChar;
if (in.read(&lengthChar, 1) == 0)
break;
const utility::stream::size_type outLength = UUDECODE(lengthChar);
const utility::stream::size_type inLength =
std::min((outLength * 4) / 3, static_cast <utility::stream::size_type>(64));
utility::stream::size_type inPos = 0;
const size_t outLength = UUDECODE(lengthChar);
const size_t inLength = std::min((outLength * 4) / 3, static_cast <size_t>(64));
size_t inPos = 0;
switch (lengthChar)
{
@ -199,10 +197,10 @@ utility::stream::size_type uuEncoder::decode(utility::inputStream& in,
{
inTotal += 5;
utility::stream::value_type c = 0;
byte_t c = 0;
utility::stream::size_type count = 0;
utility::stream::value_type buffer[512];
size_t count = 0;
byte_t buffer[512];
while (count < sizeof(buffer) - 1 && in.read(&c, 1) == 1)
{
@ -229,11 +227,11 @@ utility::stream::size_type uuEncoder::decode(utility::inputStream& in,
{
buffer[count] = '\0';
utility::stream::value_type* p = buffer;
byte_t* p = buffer;
while (*p && parserHelpers::isSpace(*p)) ++p;
utility::stream::value_type* modeStart = buffer;
byte_t* modeStart = buffer;
while (*p && !parserHelpers::isSpace(*p)) ++p;
@ -241,7 +239,7 @@ utility::stream::size_type uuEncoder::decode(utility::inputStream& in,
while (*p && parserHelpers::isSpace(*p)) ++p;
utility::stream::value_type* filenameStart = buffer;
byte_t* filenameStart = buffer;
while (*p && !(*p == '\r' || *p == '\n')) ++p;
@ -289,22 +287,21 @@ utility::stream::size_type uuEncoder::decode(utility::inputStream& in,
inTotal += (inLength - inPos);
// Decode data
for (utility::stream::size_type i = 0, j = 0 ; i < inLength ; i += 4, j += 3)
for (size_t i = 0, j = 0 ; i < inLength ; i += 4, j += 3)
{
const unsigned char c1 = static_cast <unsigned char>(inBuffer[i]);
const unsigned char c2 = static_cast <unsigned char>(inBuffer[i + 1]);
const unsigned char c3 = static_cast <unsigned char>(inBuffer[i + 2]);
const unsigned char c4 = static_cast <unsigned char>(inBuffer[i + 3]);
const byte_t c1 = inBuffer[i];
const byte_t c2 = inBuffer[i + 1];
const byte_t c3 = inBuffer[i + 2];
const byte_t c4 = inBuffer[i + 3];
const utility::stream::size_type n =
std::min(inLength - i, static_cast <utility::stream::size_type>(3));
const size_t n = std::min(inLength - i, static_cast <size_t>(3));
switch (n)
{
default:
case 3: outBuffer[j + 2] = static_cast <unsigned char>(UUDECODE(c3) << 6 | UUDECODE(c4));
case 2: outBuffer[j + 1] = static_cast <unsigned char>(UUDECODE(c2) << 4 | UUDECODE(c3) >> 2);
case 1: outBuffer[j] = static_cast <unsigned char>(UUDECODE(c1) << 2 | UUDECODE(c2) >> 4);
case 3: outBuffer[j + 2] = static_cast <byte_t>(UUDECODE(c3) << 6 | UUDECODE(c4));
case 2: outBuffer[j + 1] = static_cast <byte_t>(UUDECODE(c2) << 4 | UUDECODE(c3) >> 2);
case 1: outBuffer[j] = static_cast <byte_t>(UUDECODE(c1) << 2 | UUDECODE(c2) >> 4);
case 0: break;
}
@ -326,7 +323,7 @@ utility::stream::size_type uuEncoder::decode(utility::inputStream& in,
}
utility::stream::size_type uuEncoder::getEncodedSize(const utility::stream::size_type n) const
size_t uuEncoder::getEncodedSize(const size_t n) const
{
// 3 bytes of input provide 4 bytes of output.
// Count CRLF (2 bytes) for each line of 45 characters.
@ -335,7 +332,7 @@ utility::stream::size_type uuEncoder::getEncodedSize(const utility::stream::size
}
utility::stream::size_type uuEncoder::getDecodedSize(const utility::stream::size_type n) const
size_t uuEncoder::getDecodedSize(const size_t n) const
{
// 4 bytes of input provide 3 bytes of output
return (n * 3) / 4;

View File

@ -32,7 +32,7 @@ namespace utility {
// filteredInputStream
stream::size_type filteredInputStream::getBlockSize()
size_t filteredInputStream::getBlockSize()
{
return std::min(inputStream::getBlockSize(), getPreviousInputStream().getBlockSize());
}
@ -40,7 +40,7 @@ stream::size_type filteredInputStream::getBlockSize()
// filteredOutputStream
stream::size_type filteredOutputStream::getBlockSize()
size_t filteredOutputStream::getBlockSize()
{
return std::min(outputStream::getBlockSize(), getNextOutputStream().getBlockSize());
}
@ -75,26 +75,26 @@ void dotFilteredInputStream::reset()
}
stream::size_type dotFilteredInputStream::read(value_type* const data, const size_type count)
size_t dotFilteredInputStream::read(byte_t* const data, const size_t count)
{
const stream::size_type read = m_stream.read(data, count);
const size_t read = m_stream.read(data, count);
const value_type* readPtr = data;
value_type* writePtr = data;
const byte_t* readPtr = data;
byte_t* writePtr = data;
const value_type* end = data + read;
const byte_t* end = data + read;
stream::size_type written = 0;
size_t written = 0;
// Replace "\n.." with "\n."
while (readPtr < end)
{
if (*readPtr == '.')
{
const value_type prevChar2 =
const byte_t prevChar2 =
(readPtr == data + 1 ? m_previousChar1 :
readPtr == data ? m_previousChar2 : *(readPtr - 2));
const value_type prevChar1 =
const byte_t prevChar1 =
(readPtr == data ? m_previousChar1 : *(readPtr - 1));
if (prevChar2 == '\n' && prevChar1 == '.')
@ -127,7 +127,7 @@ stream::size_type dotFilteredInputStream::read(value_type* const data, const siz
}
stream::size_type dotFilteredInputStream::skip(const size_type /* count */)
size_t dotFilteredInputStream::skip(const size_t /* count */)
{
// Skipping bytes is not supported
return 0;
@ -148,15 +148,15 @@ outputStream& dotFilteredOutputStream::getNextOutputStream()
}
void dotFilteredOutputStream::write
(const value_type* const data, const size_type count)
void dotFilteredOutputStream::writeImpl
(const byte_t* const data, const size_t count)
{
if (count == 0)
return;
const value_type* pos = data;
const value_type* end = data + count;
const value_type* start = data;
const byte_t* pos = data;
const byte_t* end = data + count;
const byte_t* start = data;
if (m_previousChar == '.')
{
@ -172,7 +172,7 @@ void dotFilteredOutputStream::write
// Replace "\n." with "\n.."
while ((pos = std::find(pos, end, '.')) != end)
{
const value_type previousChar =
const byte_t previousChar =
(pos == data ? m_previousChar : *(pos - 1));
if (previousChar == '\n')
@ -224,15 +224,15 @@ outputStream& CRLFToLFFilteredOutputStream::getNextOutputStream()
}
void CRLFToLFFilteredOutputStream::write
(const value_type* const data, const size_type count)
void CRLFToLFFilteredOutputStream::writeImpl
(const byte_t* const data, const size_t count)
{
if (count == 0)
return;
const value_type* pos = data;
const value_type* end = data + count;
const value_type* start = data;
const byte_t* pos = data;
const byte_t* end = data + count;
const byte_t* start = data;
// Warning: if the whole buffer finishes with '\r', this
// last character will not be written back if flush() is
@ -249,7 +249,7 @@ void CRLFToLFFilteredOutputStream::write
// Replace "\r\n" (CRLF) with "\n" (LF)
while ((pos = std::find(pos, end, '\n')) != end)
{
const value_type previousChar =
const byte_t previousChar =
(pos == data ? m_previousChar : *(pos - 1));
if (previousChar == '\r')
@ -300,8 +300,8 @@ outputStream& LFToCRLFFilteredOutputStream::getNextOutputStream()
}
void LFToCRLFFilteredOutputStream::write
(const value_type* const data, const size_type count)
void LFToCRLFFilteredOutputStream::writeImpl
(const byte_t* const data, const size_t count)
{
if (count == 0)
return;
@ -309,10 +309,10 @@ void LFToCRLFFilteredOutputStream::write
string buffer;
buffer.reserve(count);
const value_type* pos = data;
const value_type* end = data + count;
const byte_t* pos = data;
const byte_t* end = data + count;
value_type previousChar = m_previousChar;
byte_t previousChar = m_previousChar;
while (pos < end)
{
@ -360,8 +360,8 @@ void LFToCRLFFilteredOutputStream::flush()
// stopSequenceFilteredInputStream <1>
template <>
stream::size_type stopSequenceFilteredInputStream <1>::read
(value_type* const data, const size_type count)
size_t stopSequenceFilteredInputStream <1>::read
(byte_t* const data, const size_t count)
{
if (eof() || m_stream.eof())
{
@ -369,10 +369,10 @@ stream::size_type stopSequenceFilteredInputStream <1>::read
return 0;
}
const size_type read = m_stream.read(data, count);
value_type* end = data + read;
const size_t read = m_stream.read(data, count);
byte_t* end = data + read;
value_type* pos = std::find(data, end, m_sequence[0]);
byte_t* pos = std::find(data, end, m_sequence[0]);
if (pos == end)
{

View File

@ -48,16 +48,16 @@ void inputStreamAdapter::reset()
}
stream::size_type inputStreamAdapter::read
(value_type* const data, const size_type count)
size_t inputStreamAdapter::read
(byte_t* const data, const size_t count)
{
m_stream.exceptions(std::ios_base::badbit);
m_stream.read(data, count);
m_stream.read(reinterpret_cast <char*>(data), count);
return (m_stream.gcount());
}
stream::size_type inputStreamAdapter::skip(const size_type count)
size_t inputStreamAdapter::skip(const size_t count)
{
m_stream.exceptions(std::ios_base::badbit);
m_stream.ignore(count);
@ -65,13 +65,13 @@ stream::size_type inputStreamAdapter::skip(const size_type count)
}
stream::size_type inputStreamAdapter::getPosition() const
size_t inputStreamAdapter::getPosition() const
{
return m_stream.tellg();
}
void inputStreamAdapter::seek(const size_type pos)
void inputStreamAdapter::seek(const size_t pos)
{
m_stream.clear();
m_stream.seekg(pos, std::ios_base::beg);

View File

@ -28,7 +28,7 @@ namespace vmime {
namespace utility {
inputStreamByteBufferAdapter::inputStreamByteBufferAdapter(const byte_t* buffer, const size_type length)
inputStreamByteBufferAdapter::inputStreamByteBufferAdapter(const byte_t* buffer, const size_t length)
: m_buffer(buffer), m_length(length), m_pos(0)
{
}
@ -46,10 +46,10 @@ void inputStreamByteBufferAdapter::reset()
}
stream::size_type inputStreamByteBufferAdapter::read
(value_type* const data, const size_type count)
size_t inputStreamByteBufferAdapter::read
(byte_t* const data, const size_t count)
{
const size_type remaining = m_length - m_pos;
const size_t remaining = m_length - m_pos;
if (remaining < count)
{
@ -68,9 +68,9 @@ stream::size_type inputStreamByteBufferAdapter::read
}
stream::size_type inputStreamByteBufferAdapter::skip(const size_type count)
size_t inputStreamByteBufferAdapter::skip(const size_t count)
{
const size_type remaining = m_length - m_pos;
const size_t remaining = m_length - m_pos;
if (remaining < count)
{
@ -85,13 +85,13 @@ stream::size_type inputStreamByteBufferAdapter::skip(const size_type count)
}
stream::size_type inputStreamByteBufferAdapter::getPosition() const
size_t inputStreamByteBufferAdapter::getPosition() const
{
return m_pos;
}
void inputStreamByteBufferAdapter::seek(const size_type pos)
void inputStreamByteBufferAdapter::seek(const size_t pos)
{
if (pos <= m_length)
m_pos = pos;

View File

@ -53,22 +53,22 @@ void inputStreamSocketAdapter::reset()
}
stream::size_type inputStreamSocketAdapter::read
(value_type* const data, const size_type count)
size_t inputStreamSocketAdapter::read
(byte_t* const data, const size_t count)
{
return m_socket.receiveRaw(data, count);
}
stream::size_type inputStreamSocketAdapter::skip
(const size_type /* count */)
size_t inputStreamSocketAdapter::skip
(const size_t /* count */)
{
// Not supported
return 0;
}
stream::size_type inputStreamSocketAdapter::getBlockSize()
size_t inputStreamSocketAdapter::getBlockSize()
{
return m_socket.getBlockSize();
}

View File

@ -35,7 +35,7 @@ inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer)
inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer,
const string::size_type begin, const string::size_type end)
const size_t begin, const size_t end)
: m_buffer(buffer), m_begin(begin), m_end(end), m_pos(begin)
{
}
@ -53,12 +53,12 @@ void inputStreamStringAdapter::reset()
}
stream::size_type inputStreamStringAdapter::read
(value_type* const data, const size_type count)
size_t inputStreamStringAdapter::read
(byte_t* const data, const size_t count)
{
if (m_pos + count >= m_end)
{
const size_type remaining = m_end - m_pos;
const size_t remaining = m_end - m_pos;
std::copy(m_buffer.begin() + m_pos, m_buffer.end(), data);
m_pos = m_end;
@ -73,11 +73,11 @@ stream::size_type inputStreamStringAdapter::read
}
stream::size_type inputStreamStringAdapter::skip(const size_type count)
size_t inputStreamStringAdapter::skip(const size_t count)
{
if (m_pos + count >= m_end)
{
const size_type remaining = m_end - m_pos;
const size_t remaining = m_end - m_pos;
m_pos = m_end;
return (remaining);
}
@ -89,13 +89,13 @@ stream::size_type inputStreamStringAdapter::skip(const size_type count)
}
stream::size_type inputStreamStringAdapter::getPosition() const
size_t inputStreamStringAdapter::getPosition() const
{
return m_pos - m_begin;
}
void inputStreamStringAdapter::seek(const size_type pos)
void inputStreamStringAdapter::seek(const size_t pos)
{
if (m_begin + pos <= m_end)
m_pos = m_begin + pos;

View File

@ -47,10 +47,10 @@ void inputStreamStringProxyAdapter::reset()
}
stream::size_type inputStreamStringProxyAdapter::read
(value_type* const data, const size_type count)
size_t inputStreamStringProxyAdapter::read
(byte_t* const data, const size_t count)
{
const size_type remaining = m_buffer.length() - m_pos;
const size_t remaining = m_buffer.length() - m_pos;
if (count > remaining)
{
@ -67,9 +67,9 @@ stream::size_type inputStreamStringProxyAdapter::read
}
stream::size_type inputStreamStringProxyAdapter::skip(const size_type count)
size_t inputStreamStringProxyAdapter::skip(const size_t count)
{
const size_type remaining = m_buffer.length() - m_pos;
const size_t remaining = m_buffer.length() - m_pos;
if (count > remaining)
{
@ -84,13 +84,13 @@ stream::size_type inputStreamStringProxyAdapter::skip(const size_type count)
}
stream::size_type inputStreamStringProxyAdapter::getPosition() const
size_t inputStreamStringProxyAdapter::getPosition() const
{
return m_pos;
}
void inputStreamStringProxyAdapter::seek(const size_type pos)
void inputStreamStringProxyAdapter::seek(const size_t pos)
{
if (pos <= m_buffer.length())
m_pos = pos;

View File

@ -28,6 +28,18 @@ namespace vmime {
namespace utility {
void outputStream::write(const byte_t* const data, const size_t count)
{
writeImpl(data, count);
}
void outputStream::write(const char* const data, const size_t count)
{
writeImpl(reinterpret_cast <const byte_t*>(data), count);
}
} // utility
} // vmime

View File

@ -34,11 +34,11 @@ outputStreamAdapter::outputStreamAdapter(std::ostream& os)
}
void outputStreamAdapter::write
(const value_type* const data, const size_type count)
void outputStreamAdapter::writeImpl
(const byte_t* const data, const size_t count)
{
m_stream.exceptions(std::ios_base::badbit);
m_stream.write(data, count);
m_stream.write(reinterpret_cast <const char*>(data), count);
}

View File

@ -34,7 +34,8 @@ outputStreamByteArrayAdapter::outputStreamByteArrayAdapter(byteArray& array)
}
void outputStreamByteArrayAdapter::write(const value_type* const data, const size_type count)
void outputStreamByteArrayAdapter::writeImpl
(const byte_t* const data, const size_t count)
{
m_array.insert(m_array.end(), data, data + count);
}

View File

@ -40,8 +40,8 @@ outputStreamSocketAdapter::outputStreamSocketAdapter(net::socket& sok)
}
void outputStreamSocketAdapter::write
(const value_type* const data, const size_type count)
void outputStreamSocketAdapter::writeImpl
(const byte_t* const data, const size_t count)
{
m_socket.sendRaw(data, count);
}
@ -53,7 +53,7 @@ void outputStreamSocketAdapter::flush()
}
stream::size_type outputStreamSocketAdapter::getBlockSize()
size_t outputStreamSocketAdapter::getBlockSize()
{
return m_socket.getBlockSize();
}

View File

@ -23,6 +23,8 @@
#include "vmime/utility/outputStreamStringAdapter.hpp"
#include "vmime/utility/stringUtils.hpp"
namespace vmime {
namespace utility {
@ -34,9 +36,10 @@ outputStreamStringAdapter::outputStreamStringAdapter(string& buffer)
}
void outputStreamStringAdapter::write(const value_type* const data, const size_type count)
void outputStreamStringAdapter::writeImpl
(const byte_t* const data, const size_t count)
{
m_buffer.append(data, count);
vmime::utility::stringUtils::appendBytesToString(m_buffer, data, count);
}

View File

@ -46,8 +46,8 @@ void parserInputStreamAdapter::reset()
}
stream::size_type parserInputStreamAdapter::read
(value_type* const data, const size_type count)
size_t parserInputStreamAdapter::read
(byte_t* const data, const size_t count)
{
return m_stream->read(data, count);
}
@ -59,17 +59,19 @@ shared_ptr <seekableInputStream> parserInputStreamAdapter::getUnderlyingStream()
}
const string parserInputStreamAdapter::extract(const size_type begin, const size_type end) const
const string parserInputStreamAdapter::extract(const size_t begin, const size_t end) const
{
const size_type initialPos = m_stream->getPosition();
const size_t initialPos = m_stream->getPosition();
byte_t *buffer = NULL;
try
{
value_type *buffer = new value_type[end - begin + 1];
buffer = new byte_t[end - begin + 1];
m_stream->seek(begin);
const size_type readBytes = m_stream->read(buffer, end - begin);
const size_t readBytes = m_stream->read(buffer, end - begin);
buffer[readBytes] = '\0';
m_stream->seek(initialPos);
@ -81,14 +83,16 @@ const string parserInputStreamAdapter::extract(const size_type begin, const size
}
catch (...)
{
delete [] buffer;
m_stream->seek(initialPos);
throw;
}
}
stream::size_type parserInputStreamAdapter::findNext
(const string& token, const size_type startPosition)
size_t parserInputStreamAdapter::findNext
(const string& token, const size_t startPosition)
{
static const unsigned int BUFFER_SIZE = 4096;
@ -96,28 +100,28 @@ stream::size_type parserInputStreamAdapter::findNext
if (token.empty() || token.length() > BUFFER_SIZE / 2)
return npos;
const size_type initialPos = getPosition();
const size_t initialPos = getPosition();
seek(startPosition);
try
{
value_type findBuffer[BUFFER_SIZE];
value_type* findBuffer1 = findBuffer;
value_type* findBuffer2 = findBuffer + (BUFFER_SIZE / 2) * sizeof(value_type);
byte_t findBuffer[BUFFER_SIZE];
byte_t* findBuffer1 = findBuffer;
byte_t* findBuffer2 = findBuffer + (BUFFER_SIZE / 2);
size_type findBufferLen = 0;
size_type findBufferOffset = 0;
size_t findBufferLen = 0;
size_t findBufferOffset = 0;
bool isEOF = false;
// Fill in initial buffer
findBufferLen = read(findBuffer, BUFFER_SIZE * sizeof(value_type));
findBufferLen = read(findBuffer, BUFFER_SIZE);
while (findBufferLen != 0)
{
// Find token
for (value_type *begin = findBuffer, *end = findBuffer + findBufferLen - token.length() ;
for (byte_t *begin = findBuffer, *end = findBuffer + findBufferLen - token.length() ;
begin <= end ; ++begin)
{
if (begin[0] == token[0] &&
@ -132,7 +136,7 @@ stream::size_type parserInputStreamAdapter::findNext
}
// Rotate buffer
memcpy(findBuffer1, findBuffer2, (BUFFER_SIZE / 2) * sizeof(value_type));
memcpy(findBuffer1, findBuffer2, (BUFFER_SIZE / 2));
// Read more bytes
if (findBufferLen < BUFFER_SIZE && (eof() || isEOF))
@ -141,7 +145,7 @@ stream::size_type parserInputStreamAdapter::findNext
}
else
{
const size_type bytesRead = read(findBuffer2, (BUFFER_SIZE / 2) * sizeof(value_type));
const size_t bytesRead = read(findBuffer2, BUFFER_SIZE / 2);
if (bytesRead == 0)
{

View File

@ -31,7 +31,7 @@ namespace utility {
// progressListenerSizeAdapter
progressListenerSizeAdapter::progressListenerSizeAdapter
(progressListener* list, const long total)
(progressListener* list, const size_t total)
: m_wrapped(list), m_total(total)
{
}
@ -43,14 +43,14 @@ bool progressListenerSizeAdapter::cancel() const
}
void progressListenerSizeAdapter::start(const long predictedTotal)
void progressListenerSizeAdapter::start(const size_t predictedTotal)
{
if (m_wrapped)
m_wrapped->start(predictedTotal);
}
void progressListenerSizeAdapter::progress(const long current, const long currentTotal)
void progressListenerSizeAdapter::progress(const size_t current, const size_t currentTotal)
{
if (m_wrapped)
{
@ -62,7 +62,7 @@ void progressListenerSizeAdapter::progress(const long current, const long curren
}
void progressListenerSizeAdapter::stop(const long total)
void progressListenerSizeAdapter::stop(const size_t total)
{
if (m_wrapped)
{

View File

@ -66,13 +66,13 @@ unsigned int random::getProcess()
}
const string random::getString(const string::size_type length, const string& randomChars)
const string random::getString(const size_t length, const string& randomChars)
{
string res;
res.resize(length);
const unsigned int x = static_cast <unsigned int>(randomChars.length());
string::size_type c = 0;
size_t c = 0;
while (c < length)
{

Some files were not shown because too many files have changed in this diff Show More