aboutsummaryrefslogtreecommitdiffstats
path: root/src/utility
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2005-06-16 21:26:26 +0200
committerVincent Richard <[email protected]>2005-06-16 21:26:26 +0200
commit4661d7b735c4c188a68df151ec03835e298c5dfe (patch)
tree1d3beba52385427dbbe99b9f947fc97735d372f5 /src/utility
parentAdded dotFilteredInputStream + fixed CRLFToLFFilteredOutputStream + added uni... (diff)
downloadvmime-4661d7b735c4c188a68df151ec03835e298c5dfe.tar.gz
vmime-4661d7b735c4c188a68df151ec03835e298c5dfe.zip
Added 'inputStreamSocketAdapter' and 'stopSequenceFilteredInputStream'.
Diffstat (limited to 'src/utility')
-rw-r--r--src/utility/filteredStream.cpp29
-rw-r--r--src/utility/stream.cpp40
2 files changed, 67 insertions, 2 deletions
diff --git a/src/utility/filteredStream.cpp b/src/utility/filteredStream.cpp
index c198c230..57e17634 100644
--- a/src/utility/filteredStream.cpp
+++ b/src/utility/filteredStream.cpp
@@ -228,6 +228,35 @@ void CRLFToLFFilteredOutputStream::write
}
+// stopSequenceFilteredInputStream <1>
+
+template <>
+const stream::size_type stopSequenceFilteredInputStream <1>::read
+ (value_type* const data, const size_type count)
+{
+ if (eof() || m_stream.eof())
+ {
+ m_eof = true;
+ return 0;
+ }
+
+ const size_type read = m_stream.read(data, count);
+ value_type* end = data + read;
+
+ value_type* pos = std::find(data, end, m_sequence[0]);
+
+ if (pos == end)
+ {
+ return (read);
+ }
+ else
+ {
+ m_found = 1;
+ return (pos - data);
+ }
+}
+
+
} // utility
} // vmime
diff --git a/src/utility/stream.cpp b/src/utility/stream.cpp
index 3899eb52..94be1447 100644
--- a/src/utility/stream.cpp
+++ b/src/utility/stream.cpp
@@ -319,11 +319,11 @@ const stream::size_type inputStreamPointerAdapter::skip(const size_type count)
}
-// outputStreamSocketAdapter
-
#ifdef VMIME_HAVE_MESSAGING_FEATURES
+// outputStreamSocketAdapter
+
outputStreamSocketAdapter::outputStreamSocketAdapter(messaging::socket& sok)
: m_socket(sok)
{
@@ -337,6 +337,42 @@ void outputStreamSocketAdapter::write
}
+// inputStreamSocketAdapter
+
+inputStreamSocketAdapter::inputStreamSocketAdapter(messaging::socket& sok)
+ : m_socket(sok)
+{
+}
+
+
+const bool inputStreamSocketAdapter::eof() const
+{
+ // Can't know...
+ return false;
+}
+
+
+void inputStreamSocketAdapter::reset()
+{
+ // Not supported
+}
+
+
+const stream::size_type inputStreamSocketAdapter::read
+ (value_type* const data, const size_type count)
+{
+ return m_socket.receiveRaw(data, count);
+}
+
+
+const stream::size_type inputStreamSocketAdapter::skip
+ (const size_type /* count */)
+{
+ // Not supported
+ return 0;
+}
+
+
#endif // VMIME_HAVE_MESSAGING_FEATURES