inet/zz_mime_body.h

Go to the documentation of this file.
00001 /* libzzinet
00002  *
00003  * This program is distributed under the GNU General Public License, version 2.
00004  * A copy of this license is included with this source.
00005  *
00006  * Copyright 2000-2006, Toni Thomsson <toni@tonjac.org> 
00007 */
00008 
00009 #ifdef _WIN32
00010 #pragma warning(disable: 4786)
00011 #endif
00012 
00013 #ifndef zz_mime_body_h
00014 #define zz_mime_body_h
00015 
00016 #include <zz_buffer.h>
00017 #include <zz_string.h>
00018 #include <map>
00019 #include <zz_export.h>
00020 
00021 // Block storlek för MIME buffert
00022 #define ZZ_MIME_WBLOCK_SIZE 10240
00023 
00024 // Vagnretur + radbrytning
00025 #define CRLF char(13), char(10)
00026 
00027 /*
00028         Description:
00029         MIME body, parsning/skrivning
00030 
00031         Author: 
00032         Toni Thomsson, toni@tonjac.org
00033 
00034         Library:
00035         libzzinet.a (HPUX) libzzinet.lib (win32)
00036 
00037         Platform:
00038         HPUX, win32
00039 */
00040 class ZZ_API CzzMIMEBody
00041 {
00042 public:
00043 
00044         /*
00045                 Description: Skapar ett MIME-body objekt
00046 
00047                 Remarks:
00048                 Skapa MIME body för skrivning
00049         */
00050         CzzMIMEBody();
00051 
00052         /*
00053                 Description: Skapar ett MIME-body objekt
00054 
00055                 Remarks:
00056                 Skapa MIME body för parsning
00057         */
00058         CzzMIMEBody( char* body,                        // IN, bodybuffert
00059                                         long size,                      // IN, storlek på body
00060                                         const char* type        // IN, innehålls typ
00061                                         );
00062 
00063         // Description: Destruktor
00064         virtual ~CzzMIMEBody();
00065 
00066         // Description: Läs boundary från typen
00067         static CzzString parseBoundary( const char* type // IN, typ
00068                                                                         );
00069 
00070         /*
00071                 Description: 
00072                 Sökväg till uppladdad fil
00073                 
00074                 See Also:
00075                 CzzCGI::getFile
00076 
00077                 Throws:
00078                 CzzException
00079         */
00080         CzzString getFile( const CzzString& name // IN, variabel namn
00081                                                 );
00082 
00083         /*
00084                 Description: 
00085                 Läs variabel
00086                 
00087                 See Also:
00088                 CzzCGI::operator[]
00089 
00090                 Throws:
00091                 CzzException
00092         */
00093         CzzString operator[]( const CzzString& var // IN, variabel namn
00094                                                         );
00095 
00096         // Description: Lägg till header till body-buffert
00097         void addHeader( const char* name, // IN, variabelnamn
00098                                         const char* value // IN, värde
00099                                         );
00100 
00101         // Description: Lägg till fil-header till body-buffert
00102         void addFileHeader( const char* name,   // IN, variabelnamn
00103                                                 const char* file        // IN, sökväg
00104                                                 );
00105 
00106         // Description: Lägg till slutmarkering till body-buffert
00107         void addEndMarker( void );
00108 
00109         // Description: Läs boundary
00110         CzzString& getBoundary( void ) { return m_Boundary; }
00111 
00112         // Description: Pekare till skrivbuffert
00113         const char* getData( void ) { return m_Buffer.getData(); };
00114 
00115         // Description: Storlek på skrivbuffert
00116         long getSize( void ) { return m_Buffer.getSize(); };
00117 
00118 protected:
00119         
00120         // Description: Parsar MIME body
00121         void parseMe( void );
00122         
00123         // Description: Genererar en unik boundary nyckel
00124         void genBoundary( void );
00125 
00126         CzzString m_Boundary;
00127         CzzString m_LastFileElement;
00128         char* m_RawBody;
00129         long m_RawSize;
00130         map<CzzString, CzzString > m_ElementMap;
00131         map<CzzString, CzzString > m_FileMap;
00132         CzzBuffer m_Buffer;
00133         
00134 private:
00135 
00136         CzzString copyReadFromStart( long from, long to );
00137         long parseElementName( long pos, const CzzString& elem );
00138         long writeToFile( long pos );
00139 };
00140 
00141 #endif // zz_mime_body_h
00142 

Generated on Thu Sep 21 21:45:42 2006 for tonjac.org MINI/C++ library by  doxygen 1.4.6-NO