diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2011-10-08 20:30:28 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2011-10-08 20:30:28 +0200 |
| commit | 5df79c53745fde5d6c3340a2979b1429cd5892c1 (patch) | |
| tree | 1a81af141708b826e9c61e8a04019994fcca8298 /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.h | 99 |
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 | ||
| 26 | const mstring mime_version_tag="MIME-Version"; | ||
| 27 | const mstring cont_type_tag="Content-Type"; | ||
| 28 | const mstring cont_trans_enc_tag="Content-Transfer-Encoding"; | ||
| 29 | const mstring cont_id_tag="Content-ID"; | ||
| 30 | const mstring cont_desc_tag="Content-Description"; | ||
| 31 | const mstring cont_disp_tag="Content-Disposition"; | ||
| 32 | const mstring cont_length_tag="Content-Length"; | ||
| 33 | // Option headers | ||
| 34 | const mstring name_tag="name"; | ||
| 35 | const mstring file_tag="filename"; | ||
| 36 | const mstring charset_tag="charset"; | ||
| 37 | const mstring boundary_tag="boundary"; | ||
| 38 | const mstring path_tag="path"; | ||
| 39 | // Some Content types | ||
| 40 | const mstring mime_textplain="text/plain"; | ||
| 41 | const mstring mime_texthtml="text/html"; | ||
| 42 | const mstring mime_texthtc="text/x-htc"; | ||
| 43 | const mstring mime_multialt="multipart/alternative"; | ||
| 44 | |||
| 45 | ///////////////////////////////////////////////////////////////// | ||
| 46 | |||
| 47 | const sref* file2mime(const sref& file); | ||
| 48 | |||
| 49 | ///////////////////////////////////////////////////////////////// | ||
| 50 | |||
| 51 | class Mime { | ||
| 52 | public: | ||
| 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 | |||
| 73 | protected: | ||
| 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 | |||
| 83 | inline int putval(mstream& out,const sref& tag,const sref& val) { | ||
| 84 | if(val.nempty()) { out<<tag<<": "<<val; return 1; } else return 0; | ||
| 85 | } | ||
| 86 | inline void putopt(mstream& out,const sref& tag,const sref& val) { | ||
| 87 | if(val.nempty()) out<<"; "<<tag<<"=\""<<val<<"\""; | ||
| 88 | } | ||
| 89 | inline int putopt1(mstream& out,const sref& tag,const sref& val) { | ||
| 90 | if(val.nempty()) { out<<tag<<"=\""<<val<<"\""; return 1; } else return 0; | ||
| 91 | } | ||
| 92 | inline int putopt2(mstream& out,const sref& tag,const sref& val) { | ||
| 93 | if(val.nempty()) { out<<tag<<"="<<val; return 1; } else return 0; | ||
| 94 | } | ||
| 95 | inline void putend(mstream& out) { out<<CRLF; } | ||
| 96 | |||
| 97 | ////////////////////////////////////////////////////////////////// | ||
| 98 | |||
| 99 | #endif | ||
