ucommon
commoncpp/mime.h
Go to the documentation of this file.
00001 // Copyright (C) 2001-2005 Open Source Telecom Corporation.
00002 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
00003 //
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 2 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free software
00018 // library without restriction.  Specifically, if other files instantiate
00019 // templates or use macros or inline functions from this file, or you compile
00020 // this file and link it with other files to produce an executable, this
00021 // file does not by itself cause the resulting executable to be covered by
00022 // the GNU General Public License.  This exception does not however
00023 // invalidate any other reasons why the executable file might be covered by
00024 // the GNU General Public License.
00025 //
00026 // This exception applies only to the code released under the name GNU
00027 // Common C++.  If you copy code from other releases into a copy of GNU
00028 // Common C++, as the General Public License permits, the exception does
00029 // not apply to the code that you add in this way.  To avoid misleading
00030 // anyone as to the status of such modified files, you must delete
00031 // this exception notice from them.
00032 //
00033 // If you write modifications of your own for GNU Common C++, it is your choice
00034 // whether to permit this exception to apply to your modifications.
00035 // If you do not wish that, delete this exception notice.
00036 //
00037 
00043 #ifndef COMMONCPP_MIME_H_
00044 #define COMMONCPP_MIME_H_
00045 
00046 #ifndef COMMONCPP_CONFIG_H_
00047 #include <commoncpp/config.h>
00048 #endif
00049 
00050 #ifndef COMMONCPP_SOCKET_H_
00051 #include <commoncpp/socket.h>
00052 #endif
00053 
00054 namespace ost {
00055 
00056 class MIMEMultipart;
00057 class MIMEItemPart;
00058 
00066 class __EXPORT MIMEMultipart
00067 {
00068 protected:
00069     friend class MIMEItemPart;
00070     char boundry[8];
00071     char mtype[80];
00072     char *header[16];
00073     MIMEItemPart *first, *last;
00074 
00075     virtual ~MIMEMultipart();
00076 
00077 public:
00083     MIMEMultipart(const char *document);
00084 
00091     virtual void head(std::ostream *output);
00092 
00099     virtual void body(std::ostream *output);
00100 
00107     char **getHeaders(void)
00108         {return header;}
00109 };
00110 
00119 class __EXPORT MIMEMultipartForm : public MIMEMultipart
00120 {
00121 protected:
00122     virtual ~MIMEMultipartForm();
00123 
00124 public:
00129     MIMEMultipartForm();
00130 };
00131 
00140 class __EXPORT MIMEItemPart
00141 {
00142 protected:
00143     friend class MIMEMultipart;
00144 
00145     MIMEMultipart *base;
00146     MIMEItemPart *next;
00147     const char *ctype;
00148 
00154     virtual void head(std::ostream *output);
00155 
00161     virtual void body(std::ostream *output) = 0;
00162 
00169     MIMEItemPart(MIMEMultipart *top, const char *ct);
00170 
00171     virtual ~MIMEItemPart();
00172 };
00173 
00181 class __EXPORT MIMEFormData : public MIMEItemPart
00182 {
00183 protected:
00184     const char *content;
00185     const char *name;
00186 
00187     virtual ~MIMEFormData();
00188 
00189 public:
00195     void head(std::ostream *output);
00196 
00202     void body(std::ostream *output);
00203 
00211     MIMEFormData(MIMEMultipartForm *top, const char *name, const char *content);
00212 };
00213 
00214 } // namespace ost
00215 
00216 #endif