summaryrefslogtreecommitdiff
path: root/src/mime/mime.h
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2011-10-08 20:30:28 +0200
committerHenrik Rydberg <rydberg@euromail.se>2011-10-08 20:30:28 +0200
commit5df79c53745fde5d6c3340a2979b1429cd5892c1 (patch)
tree1a81af141708b826e9c61e8a04019994fcca8298 /src/mime/mime.h
Initial import of htcd system 1.0
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/mime/mime.h')
-rw-r--r--src/mime/mime.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/mime/mime.h b/src/mime/mime.h
new file mode 100644
index 0000000..fb2ae0f
--- /dev/null
+++ b/src/mime/mime.h
@@ -0,0 +1,99 @@
1/*************************************************************************
2 *
3 * HTCd - Copyright (C) 1998-2006 Henrik Rydberg
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 General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef MIMEH
21#define MIMEH
22
23#include <mime/enc.h>
24
25// MIME Headers
26const mstring mime_version_tag="MIME-Version";
27const mstring cont_type_tag="Content-Type";
28const mstring cont_trans_enc_tag="Content-Transfer-Encoding";
29const mstring cont_id_tag="Content-ID";
30const mstring cont_desc_tag="Content-Description";
31const mstring cont_disp_tag="Content-Disposition";
32const mstring cont_length_tag="Content-Length";
33// Option headers
34const mstring name_tag="name";
35const mstring file_tag="filename";
36const mstring charset_tag="charset";
37const mstring boundary_tag="boundary";
38const mstring path_tag="path";
39// Some Content types
40const mstring mime_textplain="text/plain";
41const mstring mime_texthtml="text/html";
42const mstring mime_texthtc="text/x-htc";
43const mstring mime_multialt="multipart/alternative";
44
45/////////////////////////////////////////////////////////////////
46
47const sref* file2mime(const sref& file);
48
49/////////////////////////////////////////////////////////////////
50
51class Mime {
52public:
53 sref head,body;
54
55 mstring mime_version;
56 mstring cont_type,cont_type_charset,cont_type_name,cont_type_boundary;
57 mstring cont_id;
58 mstring cont_desc;
59 mstring cont_disp,cont_disp_name,cont_disp_file;
60 mstring cont_trans_enc;
61 mstring cont_length;
62
63 virtual void putHead(mstream& out) const;
64
65 void Init(const sref& in);
66
67 int Multipart(rpile& list) const;
68 void Pick(const sref& mime);
69
70 Mime();
71 Mime(const sref& msg) { Init(msg); }
72
73protected:
74 virtual int Special(sref line);
75 virtual int Handle(const sref& name,
76 const sref& rawval,
77 const sref& val,
78 const rrpile& opts);
79};
80
81//////////////////////////////////////////////////////////////////
82
83inline int putval(mstream& out,const sref& tag,const sref& val) {
84 if(val.nempty()) { out<<tag<<": "<<val; return 1; } else return 0;
85}
86inline void putopt(mstream& out,const sref& tag,const sref& val) {
87 if(val.nempty()) out<<"; "<<tag<<"=\""<<val<<"\"";
88}
89inline int putopt1(mstream& out,const sref& tag,const sref& val) {
90 if(val.nempty()) { out<<tag<<"=\""<<val<<"\""; return 1; } else return 0;
91}
92inline int putopt2(mstream& out,const sref& tag,const sref& val) {
93 if(val.nempty()) { out<<tag<<"="<<val; return 1; } else return 0;
94}
95inline void putend(mstream& out) { out<<CRLF; }
96
97//////////////////////////////////////////////////////////////////
98
99#endif