Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

dsMime.h

Go to the documentation of this file.
00001 /*
00002  * $Id: dsMime.h,v 1.9 2004/10/05 07:38:24 dsamersoff Exp $
00003  *
00004  */
00005 
00006 #ifndef dsMime_h
00007 #define dsMime_h
00008 
00009 #ifdef HAVE_CONFIG_H
00010 # include <config.h>
00011 #endif
00012 
00013 
00014 #include <stdio.h>
00015 #include <stdlib.h>
00016 #include <string.h>
00017 
00018 #include <dsSmartException.h>
00019 #include <dsBoyer.h>
00020 #include <dsutil.h>
00021 #include <xlat.h>
00022 
00023 #include <iostream>
00024 #include <vector>
00025                        
00026 DECLARE_EXCEPTION(dsMime);
00027 
00028 //private:
00029 /* out-of-class functions */
00030 
00031 char *rfc822ndup(char *ptr, int len);
00032 
00033 void _hdr_decode(char *ptr, int len, char *out, int *outlen);
00034 void _hdr_decode2(char *ptr, int len, std::ostream& os);
00035 
00036 
00037 //public:
00039 void _b_decode(const char *ptr, int len, std::ostream& os);
00040 void _b_decode(const char *ptr, int len, char *out, int *outlen);
00041 
00042 /* encode base64 */
00043 void _b_encode(std::ostream& dest, const char *src);
00044 void _b_encode(std::ostream& dest, std::istream& src);
00045 
00046 /* decode hex ascii */
00047 void _hex_decode(const char *ptr, int len, std::ostream& os);
00048 void _hex_decode(const char *ptr, int len, char *out);
00049 
00053 void _hex_encode(const char *ptr, int len, std::ostream& os);
00054 
00058 void _hex_dbg_encode(const char *ptr, int len, std::ostream& os);
00059 
00060 
00062 void _q_decode(char *ptr, int len, std::ostream& os);
00063 void _q_decode(char *ptr, int len, char *out, int *outlen);
00064 
00065 
00066 class dsMime 
00067 {
00068   char * _c_type;    //dynamic string
00069   char * _encoding;  //dynamic string
00070   
00071   char * _body_ptr;  //pointer to original message
00072   int    _body_len; 
00073 
00074   char * _hd_ptr;    //pointer to original message
00075   int    _hd_len;
00076 
00077 public:
00078  
00079   dsMime();
00080   dsMime(char *type);
00081  ~dsMime();
00082 
00083   char * type(){ return _c_type; }
00084   char *encoding(){ return _encoding; }
00085 
00086   char *body(){ return _body_ptr; }
00087   void body(std::ostream& os);
00088   int body_len(){ return _body_len; }
00089 
00090   char *header(){ return _hd_ptr; }
00091   void header(std::ostream& os);
00092 
00093   int header_len(){ return _hd_len; }
00094 
00095   friend class dsMimeHandler;
00096 };
00097 
00103 class dsMimeHandler
00104 {
00105   void __handle_message(dsMime *mtmp);
00106   dsMime * __parse_mime_header(char *ptr, int len );
00107 
00108 public: 
00109 
00110   std::vector<dsMime *> _mt;
00111 
00112   dsMimeHandler();
00113   dsMimeHandler(char *ptr, int len);
00114 
00115   ~dsMimeHandler();
00116 
00117   void handleMessage( char *ptr, int len);
00118 
00119   std::vector<dsMime *>::iterator begin(){ return _mt.begin(); }
00120   std::vector<dsMime *>::iterator end()  { return _mt.end();   }
00121 
00122 };
00123 
00124 #endif
00125   
00126     

Generated on Mon May 16 18:26:57 2005 for libdms4 by doxygen1.3-rc2