From 0edaa87860dbfd4871c597a9f2fbec07fca67ed6 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sat, 17 Sep 2005 09:08:45 +0000 Subject: SASL authentication. --- src/utility/stream.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'src/utility') diff --git a/src/utility/stream.cpp b/src/utility/stream.cpp index 49ebcf66..c13e8df7 100644 --- a/src/utility/stream.cpp +++ b/src/utility/stream.cpp @@ -326,6 +326,67 @@ const stream::size_type inputStreamPointerAdapter::skip(const size_type count) } + +// inputStreamByteBufferAdapter + +inputStreamByteBufferAdapter::inputStreamByteBufferAdapter(const byte* buffer, const size_type length) + : m_buffer(buffer), m_length(length), m_pos(0) +{ +} + + +const bool inputStreamByteBufferAdapter::eof() const +{ + return m_pos >= m_length; +} + + +void inputStreamByteBufferAdapter::reset() +{ + m_pos = 0; +} + + +const stream::size_type inputStreamByteBufferAdapter::read + (value_type* const data, const size_type count) +{ + const size_type remaining = m_length - m_pos; + + if (remaining < count) + { + std::copy(m_buffer + m_pos, m_buffer + m_pos + remaining, data); + m_pos += remaining; + + return remaining; + } + else + { + std::copy(m_buffer + m_pos, m_buffer + m_pos + count, data); + m_pos += count; + + return count; + } +} + + +const stream::size_type inputStreamByteBufferAdapter::skip(const size_type count) +{ + const size_type remaining = m_length - m_pos; + + if (remaining < count) + { + m_pos += remaining; + return remaining; + } + else + { + m_pos += count; + return count; + } +} + + + #ifdef VMIME_HAVE_MESSAGING_FEATURES -- cgit