diff options
| author | Sam Varshavchik | 2013-08-19 16:39:41 -0400 |
|---|---|---|
| committer | Sam Varshavchik | 2013-08-25 14:43:51 -0400 |
| commit | 9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch) | |
| tree | 7a81a04cb51efb078ee350859a64be2ebc6b8813 /libmail/base64.H | |
| parent | a9520698b770168d1f33d6301463bb70a19655ec (diff) | |
| download | courier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2 | |
Initial checkin
Imported from subversion report, converted to git. Updated all paths in
scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'libmail/base64.H')
| -rw-r--r-- | libmail/base64.H | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/libmail/base64.H b/libmail/base64.H new file mode 100644 index 0000000..102ec23 --- /dev/null +++ b/libmail/base64.H @@ -0,0 +1,91 @@ +/* +** Copyright 2002, Double Precision Inc. +** +** See COPYING for distribution information. +*/ +#ifndef libmail_base64_h +#define libmail_base64_h + +#include "libmail_config.h" +#include "decoder.H" + +#include <string> + +#include "rfc822/encode.h" + +LIBMAIL_START + +// +// MIME base64 decoder. +// + +class decodebase64 : public decoder { + + std::string decodeBuffer; + +public: + decodebase64(); + virtual ~decodebase64(); + void decode(std::string text); // text - base64 text + +private: + virtual void decoded(std::string buffer)=0; + // decoded contents +}; + +// MIME base64 encoder + +class encodebase64 { + + struct libmail_encode_info encodeInfo; + + static int callback_func(const char *, size_t, void *); + +public: + encodebase64(); + virtual ~encodebase64(); + + void encode(std::string text); // text - binary data to encode + void flush(); // Flush any buffered encoded data. +private: + virtual void encoded(std::string buffer)=0; +}; + +// +// A helper object that collects the output of mail::decodebase64 into a +// single string +// + +class decodebase64str : public decodebase64 { + +public: + std::string challengeStr; + decodebase64str(); + decodebase64str(std::string); + ~decodebase64str(); + void decoded(std::string s); + + operator std::string() const { return (challengeStr); } +}; + +// +// A helper object that base64-encodes a single chunk of data, and returns it. +// + +class encodebase64str : public encodebase64 { + +public: + std::string responseStr; + + encodebase64str(); + encodebase64str(std::string); + ~encodebase64str(); + + void encoded(std::string s); + + operator std::string() const { return (responseStr); } +}; + +LIBMAIL_END + +#endif |
