Mime.h

Go to the documentation of this file.
00001 #ifndef __MIME_H__
00002 #define __MIME_H__
00003 
00004 /*
00005 
00006 $Id$
00007 
00008 */
00009 
00010 #include "String.h"
00011 
00012 // Messages.
00013 
00014 static const char *const MSG_BZIP2_COMPRESSION = "bzip2 compression error.";
00015 
00016 // MIME encodings.
00017 
00018 typedef enum
00019 {
00020   MIME_ENC_UNKNOWN,
00021   MIME_ENC_NONE,
00022   MIME_ENC_BASE64,
00023   MIME_ENC_ZBASE64,
00024   MIME_ENC_BZ2BASE64
00025 } MimeEncoding;
00026 
00027 static const char *const MIME_ENC_NAME_NONE      = "none";
00028 static const char *const MIME_ENC_NAME_BASE64    = "base64";
00029 static const char *const MIME_ENC_NAME_ZBASE64   = "zbase64";
00030 static const char *const MIME_ENC_NAME_BZ2BASE64 = "bz2base64";
00031 
00032 static const unsigned int MIME_BASE64_LINE_WIDTH_DEFAULT = 72;
00033 
00034 class Mime
00035 {
00036 
00037 public:
00038 
00039   static MimeEncoding encoding(const String &name);
00040 
00041   static int encodeBase64(const String &source, String &destination, unsigned int lineSize = MIME_BASE64_LINE_WIDTH_DEFAULT);
00042   static int decodeBase64(const String &source, String &destination);
00043   static int encodeData(const String &source, String &destination, const MimeEncoding encoding = MIME_ENC_BASE64);
00044 
00045 private:
00046 
00047   static void encodeBlock(unsigned char in[3], unsigned char out[4], int len);
00048   static void decodeBlock(unsigned char in[4], unsigned char out[3]);
00049 
00050   // Translation Table as described in RFC1113.
00051   static const char *const cb64;
00052 
00053   // Translation Table to decode (created by author).
00054   static const char *const cd64;
00055 
00056 };
00057 
00058 #endif

Generated on Thu Sep 6 20:11:25 2007 for Pylon Application Platform by  doxygen 1.5.1