diff options
| author | Vincent Richard <[email protected]> | 2013-06-24 13:32:40 +0000 |
|---|---|---|
| committer | Vincent Richard <[email protected]> | 2013-06-24 13:32:40 +0000 |
| commit | 895b07cae9741f44a1272b2f3875f8dd94763222 (patch) | |
| tree | 6532de59e01676c78b423b5de5ebc1411c7da111 /src/utility/encoder/b64Encoder.cpp | |
| parent | Return after sending message when sending is supported. (diff) | |
| download | vmime-895b07cae9741f44a1272b2f3875f8dd94763222.tar.gz vmime-895b07cae9741f44a1272b2f3875f8dd94763222.zip | |
Added support for SIZE SMTP extension (RFC-1870).
Diffstat (limited to 'src/utility/encoder/b64Encoder.cpp')
| -rw-r--r-- | src/utility/encoder/b64Encoder.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/utility/encoder/b64Encoder.cpp b/src/utility/encoder/b64Encoder.cpp index d67a91ac..20e16b98 100644 --- a/src/utility/encoder/b64Encoder.cpp +++ b/src/utility/encoder/b64Encoder.cpp @@ -304,6 +304,27 @@ utility::stream::size_type b64Encoder::decode(utility::inputStream& in, } +utility::stream::size_type b64Encoder::getEncodedSize(const utility::stream::size_type n) const +{ + const string::size_type propMaxLineLength = + getProperties().getProperty <string::size_type>("maxlinelength", static_cast <string::size_type>(-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)); + + return (n * 4) / 3 // 3 bytes of input provide 4 bytes of output + + (cutLines ? (n / maxLineLength) * 2 : 0) // CRLF (2 bytes) for each line. + + 4; // padding +} + + +utility::stream::size_type b64Encoder::getDecodedSize(const utility::stream::size_type n) const +{ + // 4 bytes of input provide 3 bytes of output + return (n * 3) / 4; +} + + } // encoder } // utility } // vmime |
