UCommon
mime.h
Go to the documentation of this file.
1 // Copyright (C) 2001-2005 Open Source Telecom Corporation.
2 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
3 // Copyright (C) 2015 Cherokees of Idaho.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free software
19 // library without restriction. Specifically, if other files instantiate
20 // templates or use macros or inline functions from this file, or you compile
21 // this file and link it with other files to produce an executable, this
22 // file does not by itself cause the resulting executable to be covered by
23 // the GNU General Public License. This exception does not however
24 // invalidate any other reasons why the executable file might be covered by
25 // the GNU General Public License.
26 //
27 // This exception applies only to the code released under the name GNU
28 // Common C++. If you copy code from other releases into a copy of GNU
29 // Common C++, as the General Public License permits, the exception does
30 // not apply to the code that you add in this way. To avoid misleading
31 // anyone as to the status of such modified files, you must delete
32 // this exception notice from them.
33 //
34 // If you write modifications of your own for GNU Common C++, it is your choice
35 // whether to permit this exception to apply to your modifications.
36 // If you do not wish that, delete this exception notice.
37 //
38 
44 #ifndef COMMONCPP_MIME_H_
45 #define COMMONCPP_MIME_H_
46 
47 #ifndef COMMONCPP_CONFIG_H_
48 #include <commoncpp/config.h>
49 #endif
50 
51 #ifndef COMMONCPP_SOCKET_H_
52 #include <commoncpp/socket.h>
53 #endif
54 
55 namespace ost {
56 
57 class MIMEMultipart;
58 class MIMEItemPart;
59 
67 class __EXPORT MIMEMultipart
68 {
69 protected:
70  friend class MIMEItemPart;
71  char boundry[8];
72  char mtype[80];
73  char *header[16];
74  MIMEItemPart *first, *last;
75 
76  virtual ~MIMEMultipart();
77 
78 public:
84  MIMEMultipart(const char *document);
85 
92  virtual void head(std::ostream *output);
93 
100  virtual void body(std::ostream *output);
101 
108  char **getHeaders(void)
109  {return header;}
110 };
111 
120 class __EXPORT MIMEMultipartForm : public MIMEMultipart
121 {
122 protected:
123  virtual ~MIMEMultipartForm();
124 
125 public:
131 };
132 
141 class __EXPORT MIMEItemPart
142 {
143 protected:
144  friend class MIMEMultipart;
145 
146  MIMEMultipart *base;
147  MIMEItemPart *next;
148  const char *ctype;
149 
155  virtual void head(std::ostream *output);
156 
162  virtual void body(std::ostream *output) = 0;
163 
170  MIMEItemPart(MIMEMultipart *top, const char *ct);
171 
172  virtual ~MIMEItemPart();
173 };
174 
182 class __EXPORT MIMEFormData : public MIMEItemPart
183 {
184 protected:
185  const char *content;
186  const char *name;
187 
188  virtual ~MIMEFormData();
189 
190 public:
196  void head(std::ostream *output);
197 
203  void body(std::ostream *output);
204 
212  MIMEFormData(MIMEMultipartForm *top, const char *name, const char *content);
213 };
214 
215 } // namespace ost
216 
217 #endif
Definition: address.h:59
A container class for multi-part MIME document objects which can be streamed to a std::ostream destin...
Definition: mime.h:67
socket operations.
The Multipart form is a MIME multipart document specific for the construction and delivery of form da...
Definition: mime.h:120
This is used to attach an item part to a MIME multipart document that is being streamed.
Definition: mime.h:141
char ** getHeaders(void)
Get a string array of the headers to use.
Definition: mime.h:108
This is a document part type for use in submitting multipart form data to a web server.
Definition: mime.h:182