update tizen source
[framework/messaging/msg-service.git] / plugin / mms_plugin / MmsPluginMIME.cpp
1 /*
2 *
3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
4 *
5 * This file is part of msg-service.
6 *
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 *          Sangkoo Kim <sangkoo.kim@samsung.com>
9 *          Seunghwan Lee <sh.cat.lee@samsung.com>
10 *          SoonMin Jung <sm0415.jung@samsung.com>
11 *          Jae-Young Lee <jy4710.lee@samsung.com>
12 *          KeeBum Kim <keebum.kim@samsung.com>
13 *
14 * PROPRIETARY/CONFIDENTIAL
15 *
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
21 *
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
28 *
29 */
30
31 #include <string>
32 #include <stdlib.h>
33 #include "MmsPluginMIME.h"
34 #include "MsgDebug.h"
35
36 #include "MmsPluginSmil.h"
37 #ifndef NULL
38 #define NULL    0
39 #endif
40
41
42 /* Header field */
43 static const char *szMsgField[MSG_FIELD_NUM] =
44 {
45         "Return-Path",
46         "Message-ID",
47         "From" ,
48         "To" ,
49         "Cc" ,
50         "Subject",
51         "Date",
52         "Mime-Version",
53         "Content-Type",
54         "Content-Transfer-Encoding",
55         "Content-Disposition", //If start param is given in multipart/related, this field will be ignored
56         "Content-ID", //for start part of multipart/related body
57         "Content-Location",
58         "Content-Name",
59         "Content-Description",
60         "Content-Vendor",
61         "Rights-Issuer",
62         "Return-Receipt-To",                    /* Delivery confirm */
63         "Disposition-Notification-To",  /* Read confirm */
64         "Content-Rep-Pos",
65         "Content-Rep-Size",
66         "Content-Rep-Index"
67 };
68
69 /*  MIME header field parameter */
70 static const char *szMsgParam[MSG_PARAM_NUM] =
71 {
72         "charset",
73         "name",
74         "filename",
75         "type",         //Only if content-type is multipart/related,
76         "start",        //Only if content-type is multipart/related
77         "start-info",   //Only if content-type is multipart/related
78         "boundary",
79         "report-type", // only used as parameter of Content-Type: multipart/report; report-type=delivery-status;
80 #ifdef FEATURE_JAVA_MMS
81         "Application-ID",                               //laconic_javaParamFix
82         "Reply-To-Application-ID",              //laconic_javaParamFix
83 #endif
84 };
85
86 /* Content-Transfer-Encoding header value */
87 static const char *szMsgEncoding[MSG_ENCODING_NUM] =
88 {
89         "7bit",
90         "8bit",
91         "binary",
92         "base64",
93         "quoted-printable"
94 };
95
96 /* Content-Disposition header value */
97 static const char *szMsgDisposition[MSG_DISPOSITION_NUM] =
98 {
99         "form-data",
100         "attachment",
101         "inline"
102 };
103
104 static const char *szMsgAddrType[MSG_ADDR_TYPE_NUM] =
105 {
106         "/TYPE=PLMN",
107         "",
108         "/TYPE=IPV4",
109         "/TYPE=IPV6",
110         ""
111 };
112
113 /* character-set value */
114 static const char *szMsgCharset [MSG_CHARSET_NUM] =
115 {
116         "us-ascii",
117         "utf-16",
118         "usc-2",
119         "utf-8",
120         /* MIME character-set value */
121
122         "iso-2022-kr",
123         "ks_c_5601-1987",
124         "euc_kr",
125         "iso-2022-jp",
126         "iso-2022-jp-2",
127         "iso-8859-1",
128         "iso-8859-2",
129         "iso-8859-3",
130         "iso-8859-4",
131         "iso-8859-5",
132         "iso-8859-6",
133         "iso-8859-6-e",
134         "iso-8859-6-i",
135         "iso-8859-7",
136         "iso-8859-8",
137         "iso-8859-8-i",
138         "iso-8859-9",
139         "iso-8859-10",
140         "iso-8859-15",
141         "Shift_jis",
142         "euc-jp",
143         "gb2312",
144         "big5",
145         "win1251",
146         "window-1251",
147         "windows-1251",
148         "koi8-r",
149         "koi8-u"
150 };
151
152
153 /**************************************************     MIME definition     ***************************************************/
154 static const MimeTable mimeTable[] = {
155         // 0
156         {"*/*",                                                                                                 "",                                     false,          MIME_ASTERISK,                                                                  MIME_ASTERISK,                                                  MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                              UNDEFINED_BINARY        },
157
158     // 1
159         {"application/xml",                                                                     "",                                     false,          MIME_APPLICATION_XML,                                                   MIME_APPLICATION_XML,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x27    },
160         {"application/wml+xml",                                                         "",                                     false,          MIME_APPLICATION_WML_XML,                                               MIME_APPLICATION_WML_XML,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x3c    },
161         {"application/xhtml+xml",                                                               "xhtml",                        false,          MIME_APPLICATION_XHTML_XML,                                             MIME_APPLICATION_XHTML_XML,                             MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x3b    },
162         {"application/java-vm",                                                         "",                                     false,          MIME_APPLICATION_JAVA_VM,                                               MIME_APPLICATION_JAVA_VM,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x11    },
163         {"application/smil",                                                                    "smil",                         true,           MIME_APPLICATION_SMIL,                                                  MIME_APPLICATION_SMIL,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
164         {"application/java-archive",                                                    "jar",                          true,           MIME_APPLICATION_JAVA_ARCHIVE,                                  MIME_APPLICATION_JAVA_ARCHIVE,                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
165         {"application/java",                                                                    "jar",                          true,           MIME_APPLICATION_JAVA,                                                  MIME_APPLICATION_JAVA,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
166         {"application/octet-stream",                                                    "",                                     false,          MIME_APPLICATION_OCTET_STREAM,                                  MIME_APPLICATION_OCTET_STREAM,                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
167         {"application/studiom",                                                         "smp",                          true,           MIME_APPLICATION_STUDIOM,                                               MIME_APPLICATION_STUDIOM,                               MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
168         {"application/funMedia",                                                                "smp",                          true,           MIME_APPLICATION_FUNMEDIA,                                              MIME_APPLICATION_FUNMEDIA,                              MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
169         {"application/msword",                                                                  "doc",                          true,           MIME_APPLICATION_MSWORD,                                                MIME_APPLICATION_MSWORD,                                MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
170         {"application/pdf",                                                                     "pdf",                          true,           MIME_APPLICATION_PDF,                                                   MIME_APPLICATION_PDF,                                   MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
171         {"application/sdp",                                                                     "sdp",                          true,           MIME_APPLICATION_SDP,                                                   MIME_APPLICATION_SDP,                                   MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,    UNDEFINED_BINARY        },
172         {"application/ram",                                                                     "ram",                          true,           MIME_APPLICATION_RAM,                                                   MIME_APPLICATION_RAM,                                   MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
173         {"application/*",                                                                               "",                                     false,          MIME_APPLICATION_ASTERIC,                                               MIME_APPLICATION_ASTERIC,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x10    },
174
175         //16
176         {"application/vnd.wap.xhtml+xml",                                               "",                                     false,          MIME_APPLICATION_VND_WAP_XHTMLXML,                              MIME_APPLICATION_VND_WAP_XHTMLXML,              MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x45    },
177         {"application/vnd.wap.wmlc",                                                    "",                                     false,          MIME_APPLICATION_VND_WAP_WMLC,                                  MIME_APPLICATION_VND_WAP_WMLC,                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x14    },
178         {"application/vnd.wap.wmlscriptc",                                              "",                                     false,          MIME_APPLICATION_VND_WAP_WMLSCRIPTC,                    MIME_APPLICATION_VND_WAP_WMLSCRIPTC,    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x15    },
179         {"application/vnd.wap.wta-eventc",                                              "",                                     false,          MIME_APPLICATION_VND_WAP_WTA_EVENTC,                    MIME_APPLICATION_VND_WAP_WTA_EVENTC,    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x16    },
180         {"application/vnd.wap.uaprof",                                                  "",                                     false,          MIME_APPLICATION_VND_WAP_UAPROF,                                MIME_APPLICATION_VND_WAP_UAPROF,                MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x17    },
181         {"application/vnd.wap.sic",                                                     "",                                     false,          MIME_APPLICATION_VND_WAP_SIC,                                   MIME_APPLICATION_VND_WAP_SIC,                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x2e    },
182         {"application/vnd.wap.slc",                                                     "",                                     false,          MIME_APPLICATION_VND_WAP_SLC,                                   MIME_APPLICATION_VND_WAP_SLC,                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x30    },
183         {"application/vnd.wap.coc",                                                     "",                                     false,          MIME_APPLICATION_VND_WAP_COC,                                   MIME_APPLICATION_VND_WAP_COC,                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x32    },
184         {"application/vnd.wap.sia",                                                     "",                                     false,          MIME_APPLICATION_VND_WAP_SIA,                                   MIME_APPLICATION_VND_WAP_SIA,                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x34    },
185         {"application/vnd.wap,connectivity-wbxml",                              "",                                     false,          MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML,    MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML,            MIME_APPLICATION_NONE,          MIME_MAINTYPE_TEXT,                     UNDEFINED_BINARY        },
186         {"application/vnd.wap.multipart.form-data",                     "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_FORM_DATA,   MIME_MULTIPART_FORM_DATA,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x24    },
187         {"application/vnd.wap.multipart.byteranges",                    "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_BYTERANGES,  MIME_MULTIPART_BYTERANGE,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x25    },
188         {"application/vnd.wap.multipart.mixed",                         "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_MIXED,               MIME_MULTIPART_MIXED,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x23    },
189         {"application/vnd.wap.multipart.related",                               "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_RELATED,             MIME_MULTIPART_RELATED,                                 MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x33    },
190         {"application/vnd.wap.multipart.alternative",                   "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE, MIME_MULTIPART_ALTERNATIVE,                                     MIME_APPLICATION_NONE,                          MIME_MAINTYPE_APPLICATION,      0x26    },
191         {"application/vnd.wap.multipart.*",                                     "",                                     false,          MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC,             MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC,             MIME_APPLICATION_NONE,                  MIME_MAINTYPE_APPLICATION,      0x22    },
192         {"application/vnd.wap.wbxml",                                                   "",                                     false,          MIME_APPLICATION_VND_WAP_WBXML,                                 MIME_APPLICATION_VND_WAP_WBXML,                 MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x29    },
193         {"application/vnd.oma.dd+xml",                                                  "dd",                           true,           MIME_APPLICATION_VND_OMA_DD_XML,                                MIME_APPLICATION_VND_OMA_DD_XML,                MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      0x47    },
194         {"application/vnd.oma.drm.message",                                     "dm",                           true,           MIME_APPLICATION_VND_OMA_DRM_MESSAGE,                   MIME_APPLICATION_VND_OMA_DRM_MESSAGE,           MIME_APPLICATION_NONE,                          MIME_MAINTYPE_ETC,                      0x48    },
195         {"application/vnd.oma.drm.content",                                     "dcf",                          true,           MIME_APPLICATION_VND_OMA_DRM_CONTENT,                   MIME_APPLICATION_VND_OMA_DRM_CONTENT,           MIME_APPLICATION_NONE,                          MIME_MAINTYPE_ETC,                      0x49    },
196         {"application/vnd.oma.drm.rights+xml",                                  "ro",                           true,           MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML,                MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML,                MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4a    },
197         {"application/vnd.oma.drm.rights+wbxml",                                "ro",                           true,           MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML,              MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML,              MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4b    },
198         {"application/vnd.oma.drm.ro+xml",                              "oro",                          true,           MIME_APPLICATION_VND_OMA_DRM_RO_XML,            MIME_APPLICATION_VND_OMA_DRM_RO_XML,            MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4b    },
199         {"application/vnd.oma.drm.dcf",                         "odf",                          true,           MIME_APPLICATION_VND_OMA_DRM_DCF,               MIME_APPLICATION_VND_OMA_DRM_DCF,               MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4b    },
200         {"application/vnd.oma.drm.roap-pdu+xml",                                "xml",                          true,           MIME_APPLICATION_VND_OMA_ROAPPDU_XML,           MIME_APPLICATION_VND_OMA_ROAPPDU_XML,           MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4b    },
201         {"application/vnd.oma.drm.roap-trigger+xml",                            "xml",                          true,           MIME_APPLICATION_VND_OMA_ROAPTRIGGER_XML,               MIME_APPLICATION_VND_OMA_ROAPTRIGGER_XML,               MIME_APPLICATION_NONE,                  MIME_MAINTYPE_ETC,                      0x4b    },
202         {"application/vnd.smaf",                                                                "mmf",                          true,           MIME_APPLICATION_VND_SMAF,                                              MIME_APPLICATION_X_SMAF,                                MIME_APPLICATION_SOUNDPLAYER,                   MIME_MAINTYPE_AUDIO,            UNDEFINED_BINARY        },
203         {"application/vnd.rn-realmedia",                                                "rm",                           true,           MIME_APPLICATION_VND_RN_REALMEDIA,                              MIME_APPLICATION_VND_RN_REALMEDIA,              MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
204         {"application/vnd.sun.j2me.java-archive",                               "jar",                          true,           MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE,             MIME_APPLICATION_JAVA_ARCHIVE,                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
205         {"application/vnd.ms-excel",                                                    "xls",                          true,           MIME_APPLICATION_VND_EXCEL,                                             MIME_APPLICATION_X_EXCEL,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
206         {"application/vnd.ms-powerpoint",                                               "ppt",                          true,           MIME_APPLICATION_VND_POWERPOINT,                                MIME_APPLICATION_VND_POWERPOINT,                MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
207         {"applcation/vnd.ms-word",                                                              "doc",                          true,           MIME_APPLICATION_VND_MSWORD,                                    MIME_APPLICATION_MSWORD,                                MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
208
209         //49
210         {"application/x-hdmlc",                                                         "",                                     false,          MIME_APPLICATION_X_HDMLC,                                               MIME_APPLICATION_X_HDMLC,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x13    },
211         {"application/x-x968-user-cert",                                                "",                                     false,          MIME_APPLICATION_X_X968_USERCERT,                               MIME_APPLICATION_X_X968_USERCERT,               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x2c    },
212         {"application/x-www-form-urlencoded",                                   "",                                     false,          MIME_APPLICATION_X_WWW_FORM_URLENCODED,                 MIME_APPLICATION_X_WWW_FORM_URLENCODED,         MIME_APPLICATION_NONE,                          MIME_MAINTYPE_APPLICATION,      0x12    },
213         {"application/x-smaf",                                                                  "mmf",                          true,           MIME_APPLICATION_X_SMAF,                                                MIME_APPLICATION_X_SMAF,                                MIME_APPLICATION_SOUNDPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
214         {"application/x-shockwave-flash",                                               "swf",                          true,           MIME_APPLICATION_X_FLASH,                                               MIME_APPLICATION_X_FLASH,                               MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            UNDEFINED_BINARY        },
215         {"application/x-msexcel",                                                               "xls",                          true,           MIME_APPLICATION_X_EXCEL,                                               MIME_APPLICATION_X_EXCEL,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
216         {"application/x-mspowerpoint",                                                  "ppt",                          true,           MIME_APPLICATION_X_POWERPOINT,                                  MIME_APPLICATION_X_POWERPOINT,                  MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
217
218
219         //56
220         {"audio/basic",                                                                         "snd"/*,au"*/,          false,          MIME_AUDIO_BASIC,                                                               MIME_AUDIO_BASIC,                                               MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
221         {"audio/mpeg",                                                                                  "mp3",                          true,           MIME_AUDIO_MPEG,                                                                MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
222         {"audio/mp3",                                                                                   "mp3",                          true,           MIME_AUDIO_MP3,                                                                 MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
223         {"audio/mpg3",                                                                                  "mp3",                          true,           MIME_AUDIO_MPG3,                                                                MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
224         {"audio/mpeg3",                                                                         "mp3",                          true,           MIME_AUDIO_MPEG3,                                                               MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
225         {"audio/mpg",                                                                                   "mp3",                          true,           MIME_AUDIO_MPG,                                                                 MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
226         {"audio/aac",                                                                                   "aac",                          true,           MIME_AUDIO_AAC,                                                                 MIME_AUDIO_AAC,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
227         {"audio/g72",                                                                                   "aac",                          true,           MIME_AUDIO_G72,                                                                 MIME_AUDIO_AAC,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
228         {"audio/amr",                                                                                   "amr",                          true,           MIME_AUDIO_AMR,                                                                 MIME_AUDIO_AMR,                                                 MIME_APPLICATION_VOICEMEMO,                             MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
229         {"audio/amr-wb",                                                                                "amr",                          true,           MIME_AUDIO_AMR_WB,                                                              MIME_AUDIO_AMR_WB,                                              MIME_APPLICATION_VOICEMEMO,                             MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
230         {"audio/mmf",                                                                                   "mmf",                          true,           MIME_AUDIO_MMF,                                                                 MIME_AUDIO_MMF,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
231         {"audio/smaf",                                                                                  "mmf",                          true,           MIME_AUDIO_SMAF,                                                                MIME_AUDIO_SMAF,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
232         {"audio/iMelody",                                                                               "imy",                          true,           MIME_AUDIO_IMELODY,                                                             MIME_AUDIO_IMELODY,                                             MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
233         {"audio/imelody",                                                                               "imy",                          true,           MIME_AUDIO_IMELODY2,                                                            MIME_AUDIO_IMELODY,                                             MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
234         {"audio/melody",                                                                                "imy",                          true,           MIME_AUDIO_MELODY,                                                              MIME_AUDIO_IMELODY,                                             MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
235         {"audio/mid",                                                                                   "mid",                          true,           MIME_AUDIO_MID,                                                                 MIME_AUDIO_MID,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
236         {"audio/midi",                                                                                  "mid"/*,midi"*/,        true,           MIME_AUDIO_MIDI,                                                                MIME_AUDIO_MID,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
237         {"audio/sp-midi",                                                                               "spm"/*,midi"*/,        true,           MIME_AUDIO_SP_MIDI,                                                             MIME_AUDIO_SP_MIDI,                                             MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
238         {"audio/wave",                                                                                  "wav",                          true,           MIME_AUDIO_WAVE,                                                                MIME_AUDIO_WAVE,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
239         {"audio/wav",                                                                                   "wav",                          true,           MIME_AUDIO_WAV,                                                         MIME_AUDIO_WAVE,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
240         {"audio/3gpp",                                                                                  "3gp",                          true,           MIME_AUDIO_3GPP,                                                                MIME_AUDIO_3GPP,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
241         {"audio/mp4",                                                                                   "mp4",                          true,           MIME_AUDIO_MP4,                                                                 MIME_AUDIO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
242         {"audio/MP4A-LATM",                                                                     "mp4",                          true,           MIME_AUDIO_MP4A_LATM,                                                   MIME_AUDIO_MP4A_LATM,                                   MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
243         {"audio/m4a",                                                                                   "m4a",                          true,           MIME_AUDIO_M4A,                                                                 MIME_AUDIO_M4A,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
244         {"audio/mpeg4",                                                                         "mp4",                          true,           MIME_AUDIO_MPEG4,                                                               MIME_AUDIO_MPEG4,                                               MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
245         {"audio/wma",                                                                                   "wma",                          true,           MIME_AUDIO_WMA,                                                                 MIME_AUDIO_WMA,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
246         {"audio/xmf",                                                                                   "xmf",                          true,           MIME_AUDIO_XMF,                                                                 MIME_AUDIO_XMF,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
247         {"audio/imy",                                                                                   "imy",                          true,           MIME_AUDIO_IMY,                                                                 MIME_AUDIO_IMY,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
248         {"audio/mobile-xmf",                                                                    "mxmf",                         true,           MIME_AUDIO_MOBILE_XMF,                                                  MIME_AUDIO_XMF,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
249
250         // 85
251         {"audio/vnd.rn-realaudio",                                                              "rm"/*,ram,ra"*/,       true,           MIME_AUDIO_VND_RN_REALAUDIO,                                    MIME_AUDIO_VND_RN_REALAUDIO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
252
253         //86
254         {"audio/x-mpeg",                                                                                "mp3",                          true,           MIME_AUDIO_X_MPEG,                                                              MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
255         {"audio/x-mp3",                                                                         "mp3",                          true,           MIME_AUDIO_X_MP3,                                                               MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
256         {"audio/x-mpeg3",                                                                               "mp3",                          true,           MIME_AUDIO_X_MPEG3,                                                             MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
257         {"audio/x-mpg",                                                                         "mp3",                          true,           MIME_AUDIO_X_MPG,                                                               MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
258         {"audio/x-amr",                                                                         "amr",                          true,           MIME_AUDIO_X_AMR,                                                               MIME_AUDIO_AMR,                                                 MIME_APPLICATION_VOICEMEMO,                             MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
259         {"audio/x-mmf",                                                                         "mmf",                          true,           MIME_AUDIO_X_MMF,                                                               MIME_AUDIO_MMF,                                                 MIME_APPLICATION_VOICEMEMO,                             MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
260         {"audio/x-smaf",                                                                                "mmf",                          true,           MIME_AUDIO_X_SMAF,                                                              MIME_AUDIO_SMAF,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
261         {"audio/x-iMelody",                                                                     "imy",                          true,           MIME_AUDIO_X_IMELODY,                                                   MIME_AUDIO_IMELODY,                                             MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
262         {"audio/x-midi",                                                                                "mid"/*,midi"*/,        true,           MIME_AUDIO_X_MIDI,                                                              MIME_AUDIO_MID,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
263         {"audio/x-mpegaudio",                                                                   "mp3",                          true,           MIME_AUDIO_X_MPEGAUDIO,                                                 MIME_AUDIO_MP3,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
264         {"audio/x-pn-realaudio",                                                                "ra"/*,ram,ra"*/,       true,           MIME_AUDIO_X_PN_REALAUDIO,                                              MIME_AUDIO_VND_RN_REALAUDIO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
265         {"audio/x-pn-multirate-realaudio",                                              "rm"/*,ram,ra"*/,       true,           MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO,                    MIME_AUDIO_VND_RN_REALAUDIO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
266         {"audio/x-pn-multirate-realaudio-live",                         "rm"/*,ram,ra"*/,       true,           MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE,               MIME_AUDIO_VND_RN_REALAUDIO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
267         {"audio/x-wave",                                                                                "wav",                          true,           MIME_AUDIO_X_WAVE,                                                              MIME_AUDIO_WAVE,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
268         {"audio/x-wav",                                                                         "wav",                          true,           MIME_AUDIO_X_WAV,                                                               MIME_AUDIO_WAVE,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
269         {"audio/x-ms-wma",                                                                              "wma",                          true,           MIME_AUDIO_X_MS_WMA,                                                    MIME_AUDIO_WAVE,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
270         {"audio/x-mid",                                                                         "mid",                          true,           MIME_AUDIO_X_MID,                                                               MIME_AUDIO_MID,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
271         {"audio/x-ms-asf",                                                                              "asf",                          true,           MIME_AUDIO_X_MS_ASF,                                                    MIME_AUDIO_X_MS_ASF,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
272         {"audio/x-xmf",                                                                         "xmf",                          true,           MIME_AUDIO_X_XMF,                                                               MIME_AUDIO_XMF,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,                    UNDEFINED_BINARY        },
273
274         //105
275         {"image/gif",                                                                                   "gif",                          false,          MIME_IMAGE_GIF,                                                                 MIME_IMAGE_GIF,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    0x1d    },
276         {"image/jpeg",                                                                                  "jpg"/*,jpeg,jpe,jpz"*/,        false,  MIME_IMAGE_JPEG,                                                        MIME_IMAGE_JPG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            0x1e    },
277         {"image/jpg",                                                                                   "jpg",                          false,          MIME_IMAGE_JPG,                                                                 MIME_IMAGE_JPG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
278         {"image/tiff",                                                                                  "tif"/*,tiff"*/,        false,          MIME_IMAGE_TIFF,                                                                MIME_IMAGE_TIF,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    0x1f    },
279         {"image/tif",                                                                                   "tif",                          false,          MIME_IMAGE_TIF,                                                                 MIME_IMAGE_TIF,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
280         {"image/png",                                                                                   "png"/*,pnz"*/,         false,          MIME_IMAGE_PNG,                                                                 MIME_IMAGE_PNG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    0x20    },
281         {"image/wbmp",                                                                                  "wbmp",                         false,          MIME_IMAGE_WBMP,                                                                MIME_IMAGE_WBMP,                                                MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
282         {"image/pjpeg",                                                                         "jpg",                          false,          MIME_IMAGE_PJPEG,                                                               MIME_IMAGE_JPG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
283         {"image/bmp",                                                                                   "bmp",                          false,          MIME_IMAGE_BMP,                                                                 MIME_IMAGE_BMP,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
284         {"image/svg+xml",                                                                               "svg",                          false,          MIME_IMAGE_SVG,                                                                 MIME_IMAGE_SVG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
285         {"image/svg-xml",                                                                               "svg",                          false,          MIME_IMAGE_SVG1,                                                                MIME_IMAGE_SVG,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,                    UNDEFINED_BINARY        },
286
287         //116
288         {"image/vnd.wap.wbmp",                                                                  "wbmp",                         false,          MIME_IMAGE_VND_WAP_WBMP,                                                MIME_IMAGE_WBMP,                                                MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            0x21    },
289
290         {"image/x-bmp",                                                                         "bmp",                          false,          MIME_IMAGE_X_BMP,                                                               MIME_IMAGE_BMP,                                                 MIME_APPLICATION_IMAGEVIEWER,                   MIME_MAINTYPE_IMAGE,            UNDEFINED_BINARY        },
291
292         {"message/rfc822",                                                                              "elm",                          false,          MIME_MESSAGE_RFC822,                                                    MIME_MESSAGE_RFC822,                                    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_MESSAGE,          UNDEFINED_BINARY        },
293
294         {"multipart/mixed",                                                                     "",                                     false,          MIME_MULTIPART_MIXED,                                                   MIME_MULTIPART_MIXED,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x0c    },
295         {"multipart/related",                                                                   "",                                     false,          MIME_MULTIPART_RELATED,                                                 MIME_MULTIPART_RELATED,                                 MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
296         {"multipart/alternative",                                                               "",                                     false,          MIME_MULTIPART_ALTERNATIVE,                                             MIME_MULTIPART_ALTERNATIVE,                             MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x0f    },
297         {"multipart/form-data",                                                         "",                                     false,          MIME_MULTIPART_FORM_DATA,                                               MIME_MULTIPART_FORM_DATA,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x0d    },
298         {"multipart/byterange",                                                         "",                                     false,          MIME_MULTIPART_BYTERANGE,                                               MIME_MULTIPART_BYTERANGE,                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      0x0e    },
299         {"multipart/report",                                                                    "",                                     false,          MIME_MULTIPART_REPORT,                                                  MIME_MULTIPART_REPORT,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
300         {"multipart/voice-message",                                                     "",                                     false,          MIME_MULTIPART_VOICE_MESSAGE,                                   MIME_MULTIPART_VOICE_MESSAGE,                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_APPLICATION,      UNDEFINED_BINARY        },
301
302         //128
303         {"text/txt",                                                                                    "txt",                          false,          MIME_TEXT_TXT,                                                                  MIME_TEXT_TXT,                                                  MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_TEXT,                     UNDEFINED_BINARY        },
304         {"text/html",                                                                                   "html"/*,htm"*/,        false,          MIME_TEXT_HTML,                                                                 MIME_TEXT_HTML,                                                 MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x02    },
305         {"text/plain",                                                                                  "txt"/*,vbm,url"*/,                             false,          MIME_TEXT_PLAIN,                                                                MIME_TEXT_PLAIN,                                                MIME_APPLICATION_PICSELVIEWER,                  MIME_MAINTYPE_TEXT,                     0x03    },
306         {"text/css",                                                                                    "",                                     false,          MIME_TEXT_CSS,                                                                  MIME_TEXT_CSS,                                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x3d    },
307         {"text/xml",                                                                                    "",                                     false,          MIME_TEXT_XML,                                                                  MIME_TEXT_XML,                                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x28    },
308         {"text/iMelody",                                                                                "imy",                          true,           MIME_TEXT_IMELODY,                                                              MIME_TEXT_IMELODY,                                              MIME_APPLICATION_SOUNDPLAYER,                   MIME_MAINTYPE_AUDIO,            UNDEFINED_BINARY        },
309
310         //134
311         {"text/vnd.wap.wmlscript",                                                              "",                                     false,          MIME_TEXT_VND_WAP_WMLSCRIPT,                                    MIME_TEXT_VND_WAP_WMLSCRIPT,                    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x09    },
312         {"text/vnd.wap.wml",                                                                    "wml",                          false,          MIME_TEXT_VND_WAP_WML,                                                  MIME_TEXT_VND_WAP_WML,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x08    },
313         {"text/vnd.wap.wta-event",                                                              "",                                     false,          MIME_TEXT_VND_WAP_WTA_EVENT,                                    MIME_TEXT_VND_WAP_WTA_EVENT,                    MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x0a    },
314         {"text/vnd.wap.connectivity-xml",                                               "",                                     false,          MIME_TEXT_VND_WAP_CONNECTIVITY_XML,                             MIME_TEXT_VND_WAP_CONNECTIVITY_XML,             MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x35    },
315         {"text/vnd.wap.si",                                                                     "",                                     false,          MIME_TEXT_VND_WAP_SI,                                                   MIME_TEXT_VND_WAP_SI,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x2d    },
316         {"text/vnd.wap.sl",                                                                     "",                                     false,          MIME_TEXT_VND_WAP_SL,                                                   MIME_TEXT_VND_WAP_SL,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x2f    },
317         {"text/vnd.wap.co",                                                                     "",                                     false,          MIME_TEXT_VND_WAP_CO,                                                   MIME_TEXT_VND_WAP_CO,                                   MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x31    },
318         {"text/vnd.sun.j2me.app-descriptor",                                    "jad",                          true,           MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR,                  MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR,  MIME_APPLICATION_NONE,                                          MIME_MAINTYPE_ETC,                      UNDEFINED_BINARY        },
319
320
321         //142
322         {"text/x-hdml",                                                                         "",                                     false,          MIME_TEXT_X_HDML,                                                               MIME_TEXT_X_HDML,                                               MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x04    },
323         {"text/x-vCalendar",                                                                    "vcs",                          true,           MIME_TEXT_X_VCALENDAR,                                                  MIME_TEXT_X_VCALENDAR,                                  MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x06    },
324         {"text/x-vCard",                                                                                "vcf",                          true,           MIME_TEXT_X_VCARD,                                                              MIME_TEXT_X_VCARD,                                              MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     0x07    },
325         {"text/x-iMelody",                                                                              "imy",                          true,           MIME_TEXT_X_IMELODY,                                                    MIME_TEXT_X_IMELODY,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,            UNDEFINED_BINARY        },
326         {"text/x-imelody",                                                                              "imy",                          true,           MIME_TEXT_X_IMELODY2,                                                   MIME_TEXT_X_IMELODY,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_AUDIO,            UNDEFINED_BINARY        },
327         {"text/x-vnote",                                                                                "vnt",                          true,           MIME_TEXT_X_VNOTE,                                                              MIME_TEXT_X_VNOTE,                                              MIME_APPLICATION_NONE,                                  MIME_MAINTYPE_TEXT,                     UNDEFINED_BINARY        },
328
329         //148
330         {"video/mpeg4",                                                                         "mp4",                          true,           MIME_VIDEO_MPEG4,                                                               MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
331         {"video/mp4",                                                                                   "mp4",                          true,           MIME_VIDEO_MP4,                                                                 MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
332         {"video/h263",                                                                                  "3gp"/*,3gpp,mp4"*/,true,               MIME_VIDEO_H263,                                                                MIME_VIDEO_H263,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
333         {"video/3gpp",                                                                                  "3gp"/*,3gpp"*/,        true,           MIME_VIDEO_3GPP,                                                                MIME_VIDEO_3GPP,                                                MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
334         {"video/3gp",                                                                                   "3gp"/*,3gpp"*/,        true,           MIME_VIDEO_3GP,                                                                 MIME_VIDEO_3GP,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
335         {"video/avi",                                                                                   "avi",                          false,          MIME_VIDEO_AVI,                                                                 MIME_VIDEO_AVI,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
336         {"video/sdp",                                                                                   "sdp",                          true,           MIME_VIDEO_SDP,                                                                 MIME_APPLICATION_SDP,                                                   MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
337         {"video/mp4v-es",                                                                                       "3gp",                          true,           MIME_VIDEO_MP4_ES,                                                                      MIME_VIDEO_3GP,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
338         {"video/mpeg",                                                                                  "3gp",                          true,           MIME_VIDEO_MPEG,                                                                        MIME_VIDEO_3GP,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,            UNDEFINED_BINARY        },
339
340         // 157
341         {"video/vnd.rn-realvideo",                                                              "rm",                           true,           MIME_VIDEO_VND_RN_REALVIDEO,                                    MIME_VIDEO_VND_RN_REALVIDEO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
342         {"video/vnd.rn-realmedia",                                                              "rm",                           true,           MIME_VIDEO_VND_RN_REALMEDIA,                                    MIME_VIDEO_VND_RN_REALMEDIA,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
343
344         //159
345         {"video/x-mp4",                                                                         "mp4",                          true,           MIME_VIDEO_X_MP4,                                                               MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
346         {"video/x-pv-mp4",                                                                              "mp4",                          true,           MIME_VIDEO_X_PV_MP4,                                                    MIME_VIDEO_MP4,                                                 MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
347         {"video/x-pn-realvideo",                                                                "rv",                           true,           MIME_VIDEO_X_PN_REALVIDEO,                                              MIME_VIDEO_VND_RN_REALVIDEO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
348         {"video/x-pn-multirate-realvideo",                                              "rm",                           true,           MIME_VIDEO_X_PN_MULTIRATE_REALVIDEO,                    MIME_VIDEO_VND_RN_REALVIDEO,                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
349         {"video/x-ms-wmv",                                                                              "wmv",                          true,           MIME_VIDEO_X_MS_WMV,                                                    MIME_VIDEO_X_MS_WMV,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
350         {"video/x-ms-asf",                                                                              "asf",                          true,           MIME_VIDEO_X_MS_ASF,                                                    MIME_VIDEO_X_MS_ASF,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        },
351         {"video/x-pv-pvx",                                                                              "pvx",                          true,           MIME_VIDEO_X_PV_PVX,                                                    MIME_VIDEO_X_PV_PVX,                                    MIME_APPLICATION_MEDIAPLAYER,                   MIME_MAINTYPE_VIDEO,                    UNDEFINED_BINARY        }
352
353 };
354
355 /**********              MIME table information     ***********/
356 static const int mimeTableIndex[] = {
357         1,                      16,                     49,
358         56,                     85,                     86,
359         105,            116,            119,
360         120,            120,            120,
361         121,            121,            121,
362         128,            134,            142,
363         148,            157,            159
364 };
365
366
367 /*****************              Extension definition      *****************/
368 static const ExtTable extTable[] = {
369
370         {"txt",                 MIME_TEXT_PLAIN},
371         {"html",                        MIME_TEXT_HTML},
372         {"htm",                 MIME_TEXT_HTML},
373         {"xhtml",                       MIME_APPLICATION_XHTML_XML},
374         {"wml",                 MIME_TEXT_VND_WAP_WML},
375         {"vcs",                 MIME_TEXT_X_VCALENDAR},
376         {"vcf",                 MIME_TEXT_X_VCARD},
377         {"vnt",                 MIME_TEXT_X_VNOTE},
378         {"smil",                        MIME_APPLICATION_SMIL},
379         {"eml",                 MIME_MESSAGE_RFC822},
380         {"gif",                 MIME_IMAGE_GIF},
381         {"jpeg",                        MIME_IMAGE_JPEG},
382         {"jpg",                 MIME_IMAGE_JPEG},
383         {"jpe",                 MIME_IMAGE_JPEG},
384         {"jpz",                 MIME_IMAGE_JPEG},
385         {"tiff",                        MIME_IMAGE_TIFF},
386         {"tif",                 MIME_IMAGE_TIFF},
387         {"png",                 MIME_IMAGE_PNG},
388         {"pnz",                 MIME_IMAGE_PNG},
389         {"wbmp",                        MIME_IMAGE_VND_WAP_WBMP},
390         {"bmp",                 MIME_IMAGE_BMP},
391         {"au",                          MIME_AUDIO_BASIC},
392         {"snd",                 MIME_AUDIO_BASIC},
393         {"mp3",                 MIME_AUDIO_MP3},
394         {"aac",                 MIME_AUDIO_AAC},
395         {"mp4",                 MIME_AUDIO_MP4},
396         {"m4a",                 MIME_AUDIO_M4A},
397         {"amr",                 MIME_AUDIO_X_AMR},
398         {"mmf",                 MIME_APPLICATION_VND_SMAF},
399         {"imy",                 MIME_AUDIO_X_IMELODY},
400         {"mid",                 MIME_AUDIO_MID},
401         {"midi",                        MIME_AUDIO_MID},
402         {"spm",                 MIME_AUDIO_SP_MIDI},
403         {"wav",                 MIME_AUDIO_WAVE},
404         {"3gp",                 MIME_AUDIO_3GPP},
405         {"3gpp",                        MIME_VIDEO_3GPP},
406         {"rm",                          MIME_VIDEO_VND_RN_REALVIDEO},
407         {"ra",                          MIME_AUDIO_VND_RN_REALAUDIO},
408         {"ram",                 MIME_AUDIO_VND_RN_REALAUDIO},
409         {"wma",                 MIME_AUDIO_X_MS_WMA},
410         {"smp",                 MIME_APPLICATION_STUDIOM},
411         {"avi",                 MIME_VIDEO_AVI},
412         {"sdp",                 MIME_APPLICATION_SDP},
413         {"vbm",                 MIME_TEXT_PLAIN},
414         {"url",                 MIME_TEXT_PLAIN},
415         {"jad",                 MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR},
416         {"jar",                 MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE},
417         {"dd",                          MIME_APPLICATION_VND_OMA_DD_XML},
418         {"dm",                          MIME_APPLICATION_VND_OMA_DRM_MESSAGE},
419         {"dcf",                 MIME_APPLICATION_VND_OMA_DRM_CONTENT},
420         {"rv",                          MIME_VIDEO_X_PN_REALVIDEO},
421         {"ro",                          MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML},
422         {"xls",                 MIME_APPLICATION_X_EXCEL},
423         {"pdf",                 MIME_APPLICATION_PDF},
424         {"ppt",                 MIME_APPLICATION_X_POWERPOINT},
425         {"swf",                 MIME_APPLICATION_X_FLASH},
426         {"svg",                 MIME_IMAGE_SVG},
427         {"doc",                 MIME_APPLICATION_MSWORD},
428         {"wmv",                 MIME_VIDEO_X_MS_WMV},
429         {"asf",                 MIME_VIDEO_X_MS_ASF},
430         {"3ga",                 MIME_AUDIO_M4A},
431         {"xmf",                 MIME_AUDIO_XMF},
432         {"mxmf",                        MIME_AUDIO_MOBILE_XMF},
433         {"pvx",                 MIME_VIDEO_X_PV_PVX},
434         {"oro",                 MIME_APPLICATION_VND_OMA_DRM_RO_XML},
435         {"odf",                 MIME_APPLICATION_VND_OMA_DRM_DCF}
436 };
437
438
439 static int mimeTableEnum[] =
440 {
441         MIME_ASTERISK   ,
442
443         MIME_APPLICATION_XML    ,
444         MIME_APPLICATION_WML_XML        ,
445         MIME_APPLICATION_XHTML_XML      ,
446         MIME_APPLICATION_JAVA_VM        ,
447         MIME_APPLICATION_SMIL   ,
448         MIME_APPLICATION_JAVA_ARCHIVE   ,
449         MIME_APPLICATION_JAVA   ,
450         MIME_APPLICATION_OCTET_STREAM   ,
451         MIME_APPLICATION_STUDIOM        ,
452         MIME_APPLICATION_FUNMEDIA       ,
453         MIME_APPLICATION_MSWORD         ,
454         MIME_APPLICATION_PDF            ,
455         MIME_APPLICATION_SDP            ,
456         MIME_APPLICATION_RAM            ,
457         MIME_APPLICATION_ASTERIC        ,
458
459
460         MIME_APPLICATION_VND_WAP_XHTMLXML       ,
461         MIME_APPLICATION_VND_WAP_WMLC   ,
462         MIME_APPLICATION_VND_WAP_WMLSCRIPTC     ,
463         MIME_APPLICATION_VND_WAP_WTA_EVENTC     ,
464         MIME_APPLICATION_VND_WAP_UAPROF ,
465         MIME_APPLICATION_VND_WAP_SIC    ,
466         MIME_APPLICATION_VND_WAP_SLC    ,
467         MIME_APPLICATION_VND_WAP_COC    ,
468         MIME_APPLICATION_VND_WAP_SIA    ,
469         MIME_APPLICATION_VND_WAP_CONNECTIVITY_WBXML     ,
470         MIME_APPLICATION_VND_WAP_MULTIPART_FORM_DATA    ,
471         MIME_APPLICATION_VND_WAP_MULTIPART_BYTERANGES   ,
472         MIME_APPLICATION_VND_WAP_MULTIPART_MIXED        ,
473         MIME_APPLICATION_VND_WAP_MULTIPART_RELATED      ,
474         MIME_APPLICATION_VND_WAP_MULTIPART_ALTERNATIVE  ,
475         MIME_APPLICATION_VND_WAP_MULTIPART_ASTERIC      ,
476         MIME_APPLICATION_VND_WAP_WBXML  ,
477         MIME_APPLICATION_VND_OMA_DD_XML ,
478         MIME_APPLICATION_VND_OMA_DRM_MESSAGE    ,
479         MIME_APPLICATION_VND_OMA_DRM_CONTENT    ,
480         MIME_APPLICATION_VND_OMA_DRM_RIGHTS_XML ,
481         MIME_APPLICATION_VND_OMA_DRM_RIGHTS_WBXML       ,
482         MIME_APPLICATION_VND_OMA_DRM_RO_XML     ,
483         MIME_APPLICATION_VND_OMA_DRM_DCF        ,
484         MIME_APPLICATION_VND_OMA_ROAPPDU_XML    ,
485         MIME_APPLICATION_VND_OMA_ROAPTRIGGER_XML,
486         MIME_APPLICATION_VND_SMAF       ,
487         MIME_APPLICATION_VND_RN_REALMEDIA       ,
488         MIME_APPLICATION_VND_SUN_J2ME_JAVA_ARCHIVE      ,
489         MIME_APPLICATION_VND_EXCEL      ,
490         MIME_APPLICATION_VND_POWERPOINT,
491         MIME_APPLICATION_VND_MSWORD,
492
493
494         MIME_APPLICATION_X_HDMLC        ,
495         MIME_APPLICATION_X_X968_USERCERT        ,
496         MIME_APPLICATION_X_WWW_FORM_URLENCODED  ,
497         MIME_APPLICATION_X_SMAF ,
498         MIME_APPLICATION_X_FLASH        ,
499         MIME_APPLICATION_X_EXCEL        ,
500         MIME_APPLICATION_X_POWERPOINT   ,
501
502
503         MIME_AUDIO_BASIC,
504         MIME_AUDIO_MPEG ,
505         MIME_AUDIO_MP3  ,
506         MIME_AUDIO_MPG3 ,
507         MIME_AUDIO_MPEG3        ,
508         MIME_AUDIO_MPG  ,
509         MIME_AUDIO_AAC  ,
510         MIME_AUDIO_G72  ,
511         MIME_AUDIO_AMR  ,
512         MIME_AUDIO_AMR_WB       ,
513         MIME_AUDIO_MMF  ,
514         MIME_AUDIO_SMAF ,
515         MIME_AUDIO_IMELODY      ,
516         MIME_AUDIO_IMELODY2 ,
517         MIME_AUDIO_MELODY       ,
518         MIME_AUDIO_MID  ,
519         MIME_AUDIO_MIDI ,
520         MIME_AUDIO_SP_MIDI      ,
521         MIME_AUDIO_WAVE ,
522         MIME_AUDIO_WAV ,
523         MIME_AUDIO_3GPP ,
524         MIME_AUDIO_MP4  ,
525         MIME_AUDIO_MP4A_LATM    ,
526         MIME_AUDIO_M4A  ,
527         MIME_AUDIO_MPEG4,
528         MIME_AUDIO_WMA,
529         MIME_AUDIO_XMF,
530         MIME_AUDIO_IMY,
531         MIME_AUDIO_MOBILE_XMF,
532
533
534         MIME_AUDIO_VND_RN_REALAUDIO     ,
535
536
537         MIME_AUDIO_X_MPEG       ,
538         MIME_AUDIO_X_MP3        ,
539         MIME_AUDIO_X_MPEG3      ,
540         MIME_AUDIO_X_MPG        ,
541         MIME_AUDIO_X_AMR        ,
542         MIME_AUDIO_X_MMF        ,
543         MIME_AUDIO_X_SMAF       ,
544         MIME_AUDIO_X_IMELODY    ,
545         MIME_AUDIO_X_MIDI       ,
546         MIME_AUDIO_X_MPEGAUDIO  ,
547         MIME_AUDIO_X_PN_REALAUDIO       ,
548         MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO     ,
549         MIME_AUDIO_X_PN_MULTIRATE_REALAUDIO_LIVE        ,
550         MIME_AUDIO_X_WAVE       ,
551         MIME_AUDIO_X_WAV        ,
552         MIME_AUDIO_X_MS_WMA     ,
553         MIME_AUDIO_X_MID ,
554         MIME_AUDIO_X_MS_ASF ,
555         MIME_AUDIO_X_XMF,
556
557
558         MIME_IMAGE_GIF  ,
559         MIME_IMAGE_JPEG ,
560         MIME_IMAGE_JPG  ,
561         MIME_IMAGE_TIFF ,
562         MIME_IMAGE_TIF  ,
563         MIME_IMAGE_PNG  ,
564         MIME_IMAGE_WBMP ,
565         MIME_IMAGE_PJPEG        ,
566         MIME_IMAGE_BMP  ,
567         MIME_IMAGE_SVG  ,
568         MIME_IMAGE_SVG1 ,
569         MIME_IMAGE_VND_WAP_WBMP ,
570         MIME_IMAGE_X_BMP        ,
571
572
573         MIME_MESSAGE_RFC822     ,
574
575
576         MIME_MULTIPART_MIXED    ,
577         MIME_MULTIPART_RELATED  ,
578         MIME_MULTIPART_ALTERNATIVE      ,
579         MIME_MULTIPART_FORM_DATA        ,
580         MIME_MULTIPART_BYTERANGE        ,
581         MIME_MULTIPART_REPORT   ,
582         MIME_MULTIPART_VOICE_MESSAGE    ,
583
584
585         MIME_TEXT_TXT   ,
586         MIME_TEXT_HTML  ,
587         MIME_TEXT_PLAIN ,
588         MIME_TEXT_CSS   ,
589         MIME_TEXT_XML   ,
590         MIME_TEXT_IMELODY       ,
591         MIME_TEXT_VND_WAP_WMLSCRIPT     ,
592         MIME_TEXT_VND_WAP_WML   ,
593         MIME_TEXT_VND_WAP_WTA_EVENT     ,
594         MIME_TEXT_VND_WAP_CONNECTIVITY_XML      ,
595         MIME_TEXT_VND_WAP_SI    ,
596         MIME_TEXT_VND_WAP_SL    ,
597         MIME_TEXT_VND_WAP_CO    ,
598         MIME_TEXT_VND_SUN_J2ME_APP_DESCRIPTOR   ,
599         MIME_TEXT_X_HDML        ,
600         MIME_TEXT_X_VCALENDAR   ,
601         MIME_TEXT_X_VCARD       ,
602         MIME_TEXT_X_IMELODY     ,
603         MIME_TEXT_X_IMELODY2 ,
604         MIME_TEXT_X_VNOTE ,
605
606
607         MIME_VIDEO_MPEG4        ,
608         MIME_VIDEO_MP4  ,
609         MIME_VIDEO_H263 ,
610         MIME_VIDEO_3GPP ,
611         MIME_VIDEO_3GP  ,
612         MIME_VIDEO_AVI  ,
613         MIME_VIDEO_SDP  ,
614         MIME_VIDEO_MP4_ES,
615         MIME_VIDEO_MPEG ,
616         MIME_VIDEO_VND_RN_REALVIDEO     ,
617         MIME_VIDEO_VND_RN_REALMEDIA     ,
618         MIME_VIDEO_X_MP4        ,
619         MIME_VIDEO_X_PV_MP4     ,
620         MIME_VIDEO_X_PN_REALVIDEO       ,
621         MIME_VIDEO_X_PN_MULTIRATE_REALVIDEO     ,
622         MIME_VIDEO_X_MS_WMV ,
623         MIME_VIDEO_X_MS_ASF,
624         MIME_VIDEO_X_PV_PVX ,
625
626         MIME_UNKNOWN    // MIME_MAX
627 };
628
629
630 #define MIME_MAX_NUM    166
631 #define EXT_MAX 67
632 #define MIME_SUB_TYPE_VND       1
633 #define MIME_SUB_TYPE_X         2
634
635 int __MimeGetTableIndexInt(MimeType mime);
636 int __MimeGetTableIndexString(const char *szMime);
637 MimeMainType __MimeGetMainTypeName(const char *szType);
638
639
640 /*
641  * This function checks whether a mime is downloadable or not.
642  *
643  * @param       mime [in] Enumeration number for a MIME type.
644  * @return      This function returns true if downloadable, or false.
645  */
646 bool MimeIsDownloadableInt(MimeType mime)
647 {
648         int index;
649
650         index = __MimeGetTableIndexInt(mime);
651         if (index == MIME_UNKNOWN)
652                 return false;
653
654         return mimeTable[index].bDownloadable;
655 }
656
657 /*
658  * This function checks whether a mime is downloadable or not.
659  *
660  * @param       mime [in] MIME string.
661  * @return      This function returns true if downloadable, or false.
662  */
663 bool MimeIsDownloadableString(const char *szMime)
664 {
665         int index;
666
667         index = __MimeGetTableIndexString(szMime);
668         if (index == MIME_UNKNOWN)
669                 return false;
670
671         return mimeTable[index].bDownloadable;
672 }
673
674 /*
675  * This function checks main type of a MIME.
676  *
677  * @param       mime [in] Enumeration number for a MIME type.
678  * @return      This function returns main type of a MIME.
679  */
680 MimeMainType MimeGetMainTypeInt(MimeType mime)
681 {
682         int index;
683
684         index = __MimeGetTableIndexInt(mime);
685         if (index == MIME_UNKNOWN)
686                 return MIME_MAINTYPE_ETC;
687
688         return mimeTable[index].mainType;
689 }
690
691 /*
692  * This function checks main type of a MIME.
693  *
694  * @param       mime [in] MIME string.
695  * @return      This function returns main type of a MIME.
696  */
697 MimeMainType MimeGetMainTypeString(const char *szMime)
698 {
699         int index;
700
701         index = __MimeGetTableIndexString(szMime);
702         if (index == MIME_UNKNOWN)
703                 return MIME_MAINTYPE_ETC;
704
705         return mimeTable[index].mainType;
706 }
707
708 /*
709  * This function returns a extension name for a specified MIME.
710  *
711  * @param       mime [in] Enumeration number for a MIME type.
712  * @return      This function returns Extension string.
713  */
714 char *MimeGetExtFromMimeInt(MimeType mime)
715 {
716         int index;
717
718         index = __MimeGetTableIndexInt(mime);
719         if (index == MIME_UNKNOWN)
720                 return NULL;
721
722         return (char *)mimeTable[index].szExt;
723 }
724
725 /*
726  * This function returns a extension name for a specified MIME.
727  *
728  * @param       mime [in] MIME string.
729  * @return      This function returns Extension string.
730  */
731 char *MimeGetExtFromMimeString(const char *szMime)
732 {
733         int index;
734
735         index = __MimeGetTableIndexString(szMime);
736         if (index == MIME_UNKNOWN)
737                 return NULL;
738
739         return (char *)mimeTable[index].szExt;
740 }
741
742
743 /*
744  * This function returns a MIME type for a specified Extension.
745  *
746  * @param       mime [in] Extension string.
747  * @return      This function returns MIME string.
748  */
749 char *MimeGetMimeFromExtString(const char *szExt)
750 {
751         int i;
752
753         for (i = 0; i < EXT_MAX; i++) {
754                 if (!strcasecmp( extTable[i].szExt, szExt)) {
755                         int index;
756
757                         index = __MimeGetTableIndexInt(extTable[i].mimeType);
758                         if (index == MIME_UNKNOWN)
759                                 return NULL;
760
761                         return (char *)mimeTable[index].szMIME;
762                 }
763         }
764
765         return NULL;
766 }
767
768 /*
769  * This function returns a MIME type for a specified Extension.
770  *
771  * @param       mime [in] Extension string.
772  * @return      This function returns MIME string.
773  */
774 MimeType MimeGetMimeFromExtInt(const char *szExt)
775 {
776         int i;
777
778         for (i = 0; i < EXT_MAX; i++) {
779                 if (!strcasecmp( extTable[i].szExt, szExt))
780                         return extTable[i].mimeType;
781         }
782
783         return MIME_UNKNOWN;
784 }
785
786 /*
787  * This function returns index number in MIME definition table with MIME enumeration.
788  * Internal function.
789  */
790 int __MimeGetTableIndexInt(MimeType mime)
791 {
792         int type;
793         int subtype;
794         int index;
795         int tableIndex;
796
797         if (mime == MIME_UNKNOWN)
798                 return MIME_UNKNOWN;
799
800         type = (mime & 0xf000) >> 12;
801         subtype = (mime & 0x0f00) >> 8;
802         index = (mime & 0x003f);
803
804         //If 'type' is zero, mimeTableIndex's array value have a minus value
805         //If 'type' is zero, mime type is '*/*'
806         if (type == 0)
807                 tableIndex = 0;
808         else
809                 tableIndex = mimeTableIndex[(type - 1) * 3 + subtype] + index;
810
811         return tableIndex;
812 }
813
814
815 #define MIME_MAX_LEN    43
816 /*
817  * This function returns index number in MIME definition table with MIME string.
818  * Internal function.
819  */
820 int __MimeGetTableIndexString(const char *szMime)
821 {
822         int type;
823         int subtype;
824         char szType[50];
825         char szSubType[50];
826         char *szTmpStart = NULL;
827         char c;
828         int i = 0;
829         int j = 0;
830         int start;
831         int end;
832         char *szMIMEType = NULL;
833         int len;
834
835         if (szMime == NULL) {
836                 MSG_DEBUG("szMime is NULL");
837                 return MIME_UNKNOWN;
838         }
839
840         szMIMEType = (char * )malloc(strlen(szMime) + 1);
841
842         if (szMIMEType == NULL) {
843                 MSG_DEBUG("szMime is NULL");
844                  return MIME_UNKNOWN;
845         }
846
847         memset(szMIMEType, 0, strlen(szMime) + 1);
848
849         if (!strcmp(szMime, "*/*")) {
850                 free(szMIMEType);
851                 return 0;
852         }
853         strcpy(szMIMEType, szMime);
854         type = 0;
855         subtype = 0;
856
857         szTmpStart = szMIMEType;
858         len = strlen(szTmpStart);
859
860         while (true) {
861                 if (i >= len) {
862                         free(szMIMEType);
863                         return MIME_UNKNOWN;
864                 }
865
866                 c = szTmpStart[i++];
867
868                 if (c == '/') {
869                         szType[j] = '\0';
870                         type = __MimeGetMainTypeName(szType);
871                         szTmpStart = &szTmpStart[i];
872                         break;
873                 } else
874                         szType[j++] = c;
875         }
876
877         i = 0;
878         j = 0;
879         len = strlen(szTmpStart);
880
881         while (true) {
882                 c = szTmpStart[i++];
883                 if (i > len) {
884                         szSubType[j] = '\0';
885                         break;
886                 }
887
888                 if (c == '.') {
889                         szSubType[j] = '\0';
890                         if (!strcasecmp(szSubType, "vnd"))
891                                 subtype = MIME_SUB_TYPE_VND;
892                         break;
893                 } else if (c == '-') {
894                         szSubType[j] = '\0';
895                         if (!strcasecmp(szSubType, "x"))
896                                 subtype = MIME_SUB_TYPE_X;
897                         break;
898                 } else
899                         szSubType[j++] = c;
900         }
901
902
903         start = mimeTableIndex[type * 3 + subtype];
904
905         if (type == MIME_MAINTYPE_VIDEO && subtype == MIME_SUB_TYPE_X)
906                 end = MIME_MAX_NUM;
907         else
908                 end = mimeTableIndex[type * 3 + subtype + 1];
909
910         if (start == end && type < MIME_MAINTYPE_VIDEO) {
911                 end = mimeTableIndex[(type + 1) * 3 + subtype + 1];
912         }
913
914
915         for (i = start; i < end; i++) {
916                 if (i >= MIME_MAX_NUM)
917                         break;
918
919                 if (!strcasecmp(mimeTable[i].szMIME, szMime)) {
920                         free(szMIMEType);
921                         return i;
922                 }
923         }
924
925         free(szMIMEType);
926         return MIME_UNKNOWN;
927 }
928
929 /*
930  * This function returns main type of MIME : Internal function.
931  */
932 MimeMainType __MimeGetMainTypeName(const char *szType)
933 {
934         if (szType == NULL )
935                 return MIME_MAINTYPE_APPLICATION;
936
937         if (!strcasecmp(szType, "application"))
938                 return MIME_MAINTYPE_APPLICATION;
939         else if (!strcasecmp(szType, "audio"))
940                 return MIME_MAINTYPE_AUDIO;
941         else if (!strcasecmp(szType, "image"))
942                 return MIME_MAINTYPE_IMAGE;
943         else if (!strcasecmp(szType, "message"))
944                 return MIME_MAINTYPE_MESSAGE;
945         else if (!strcasecmp(szType, "multipart"))
946                 return MIME_MAINTYPE_MULTIPART;
947         else if (!strcasecmp(szType, "text"))
948                 return MIME_MAINTYPE_TEXT;
949         else if (!strcasecmp(szType, "video"))
950                 return MIME_MAINTYPE_VIDEO;
951
952         return MIME_MAINTYPE_APPLICATION;
953 }
954
955
956
957 // MimeString -> MimeInt
958 MimeType MimeGetMimeIntFromMimeString(char *szMimeStr)
959 {
960         int index = __MimeGetTableIndexString(szMimeStr);
961         if (index == MIME_UNKNOWN) {
962                 return MIME_UNKNOWN;
963         } else {
964                 return (MimeType)mimeTableEnum[index];
965         }
966 }
967
968 // MimeInt -> MimeString
969 char *MimeGetMimeStringFromMimeInt(int mimeType)
970 {
971         int idx = __MimeGetTableIndexInt((MimeType)mimeType);
972
973         if (idx == MIME_UNKNOWN)
974                 return NULL;
975
976         return (char *)mimeTable[idx].szMIME;
977 }
978
979
980 // BinaryCode -> MimeInt
981 MimeType MimeGetMimeIntFromBi(int binCode)
982 {
983         int index;
984
985         if (binCode < 0x00 || binCode > 0x4b)
986                 return MIME_UNKNOWN;
987
988         for (index = 0; index < MIME_MAX_NUM; index++) {
989                 if (binCode == mimeTable[index].binary)
990                         return (MimeType)mimeTableEnum[index];
991         }
992
993         return MIME_UNKNOWN;
994 }
995
996 // BinaryCode -> MimeInt
997 char *MimeGetMimeStringFromBi(int binCode)
998 {
999         int index;
1000
1001         if (binCode < 0x00 || binCode > 0x4b)
1002                 return NULL;
1003
1004         for (index = 0; index < MIME_MAX_NUM; index++) {
1005                 if (binCode == mimeTable[index].binary)
1006                         return (char *)mimeTable[index].szMIME;
1007         }
1008
1009         return NULL;
1010 }
1011
1012 // Mimeint -> Binary Value
1013 int MimeGetBinaryValueFromMimeInt(MimeType mime)
1014 {
1015         int index;
1016
1017         index = __MimeGetTableIndexInt(mime);
1018         if (index == MIME_UNKNOWN)
1019                 return UNDEFINED_BINARY;
1020
1021         return mimeTable[index].binary;
1022 }
1023
1024 // MimeString -> Binary value
1025 int MimeGetBinaryValueFromMimeString(const char *szMime)
1026 {
1027         int index;
1028
1029         index = __MimeGetTableIndexString(szMime);
1030         if (index == MIME_UNKNOWN)
1031                 return UNDEFINED_BINARY;
1032
1033         return mimeTable[index].binary;
1034 }
1035
1036
1037 /*
1038  * This function checks main type of a MIME.
1039  *
1040  * @param       mime [in] Enumeration number for a MIME type.
1041  * @return      This function returns application type of a MIME.
1042  */
1043 MimeAppType MimeGetAppTypeFromInt(MimeType mime)
1044 {
1045         int index;
1046
1047         index = __MimeGetTableIndexInt(mime);
1048         if (index == MIME_UNKNOWN)
1049                 return MIME_APPLICATION_NONE;
1050
1051         return mimeTable[index].appType;
1052 }
1053
1054 /*
1055  * This function checks main type of a MIME.
1056  *
1057  * @param       mime [in] MIME string.
1058  * @return      This function returns application type of a MIME.
1059  */
1060 MimeAppType MimeGetAppTypeFromString(const char *szMime)
1061 {
1062         int index;
1063
1064         index = __MimeGetTableIndexString(szMime);
1065         if (index == MIME_UNKNOWN)
1066                 return MIME_APPLICATION_NONE;
1067
1068         return mimeTable[index].appType;
1069 }
1070
1071
1072 /*
1073  * This function returns a application type for a specified Extension.
1074  *
1075  * @param       mime [in] Extension string.
1076  * @return      This function returns application type.
1077  */
1078 MimeAppType MimeGetAppTypeFromExtString(const char *szExt)
1079 {
1080         int i;
1081
1082         for (i = 0; i < EXT_MAX; i++) {
1083                 if (!strcasecmp( extTable[i].szExt, szExt)) {
1084                         int index;
1085
1086                         index = __MimeGetTableIndexInt(extTable[i].mimeType);
1087                         if (index == MIME_UNKNOWN)
1088                                 return MIME_APPLICATION_NONE;
1089                         return mimeTable[index].appType;
1090                 }
1091         }
1092
1093         return MIME_APPLICATION_NONE;
1094 }
1095
1096 /*
1097  * This function gets the representative mime type from MimeType
1098  *
1099  * @param       mime [in] Enumeration number for a MIME type.
1100  * @return      representative mime type Enumeration number
1101  */
1102
1103 MimeType MimeGetContentTypeFromInt(MimeType mime)
1104 {
1105         int index;
1106
1107         for (index = 0; index < MIME_MAX_NUM; index++) {
1108                 if (mime == mimeTable[index].mime)
1109                         return mimeTable[index].contentType;
1110         }
1111
1112         return MIME_UNKNOWN;
1113 }
1114
1115 /*
1116  * This function gets the representative mime type from mime string
1117  *
1118  * @param       szMime - string name of MimeType
1119  * @return      representative mime type Enumeration number
1120  */
1121
1122 MimeType MimeGetContentTypeFromString(const char *szMime)
1123 {
1124         int index;
1125
1126         for (index = 0; index < MIME_MAX_NUM; index++) {
1127                 if (!strcasecmp(szMime, mimeTable[index].szMIME))
1128                         return mimeTable[index].contentType;
1129         }
1130
1131         return MIME_UNKNOWN;
1132 }
1133
1134 /*
1135  * This function gets the index from mime string
1136  *
1137  * @param       szMime - string name of MimeType
1138  * @return      Enumeration number for a MIME type.
1139  */
1140
1141 MimeType MimeGetMimeTypeFromString(const char *szMime)
1142 {
1143         int index;
1144
1145         for (index = 0; index < MIME_MAX_NUM; index++) {
1146                 if (!strcasecmp(szMime, mimeTable[index].szMIME))
1147                         return mimeTable[index].mime;
1148         }
1149
1150         return MIME_UNKNOWN;
1151 }
1152
1153
1154 int MsgGetCode(MsgHeaderField tableId, char *pStr)
1155 {
1156         int cCode = 0;
1157         int nNum = MSG_FIELD_UNKNOWN;
1158         char **pTable = NULL;
1159
1160         switch (tableId) {
1161         case MSG_FIELD:
1162                 nNum = MSG_FIELD_NUM;
1163                 pTable = (char **)szMsgField;
1164                 break;
1165
1166         case MSG_PARAM:
1167                 nNum = MSG_PARAM_NUM;
1168                 pTable = (char **)szMsgParam;
1169                 break;
1170
1171         case MSG_TYPE:
1172                 return MimeGetMimeIntFromMimeString(pStr);
1173
1174         case MSG_CHARSET:
1175                 nNum = MSG_CHARSET_NUM;
1176                 pTable = (char **)szMsgCharset;
1177                 break;
1178
1179         case MSG_ENCODING:
1180                 nNum = MSG_ENCODING_NUM;
1181                 pTable = (char **)szMsgEncoding;
1182                 break;
1183
1184         case MSG_DISPOSITION:
1185                 nNum = MSG_DISPOSITION_NUM;
1186                 pTable = (char **)szMsgDisposition;
1187                 break;
1188
1189         case MSG_ADDR_TYPE:
1190                 nNum = MSG_ADDR_TYPE_NUM;
1191                 pTable = (char **)szMsgAddrType;
1192                 break;
1193
1194         default:
1195                 break;
1196         }
1197
1198         for (cCode = 0; cCode < nNum; cCode++) {
1199                 if (!strcasecmp(pStr, pTable[cCode])) {
1200                         return cCode;
1201                 }
1202         }
1203
1204         return -1;
1205 }
1206
1207
1208 char *MsgGetString(MsgHeaderField tableId, int code)
1209 {
1210         int nNum = MSG_FIELD_UNKNOWN;
1211         char **pTable = NULL;
1212
1213         switch (tableId) {
1214         case MSG_FIELD:
1215                 nNum = MSG_FIELD_NUM;
1216                 pTable = (char **)szMsgField;
1217                 break;
1218
1219         case MSG_PARAM:
1220                 nNum = MSG_PARAM_NUM;
1221                 pTable = (char **)szMsgParam;
1222                 break;
1223
1224         case MSG_TYPE:
1225                 if (code != MIME_UNKNOWN && code != -1)
1226                         return MimeGetMimeStringFromMimeInt(code);
1227                 else
1228                         return (char *)MSG_UNKNOWN_TYPE_STRING;
1229
1230         case MSG_CHARSET:
1231                 nNum = MSG_CHARSET_NUM;
1232                 pTable = (char **)szMsgCharset;
1233                 break;
1234
1235         case MSG_ENCODING:
1236                 nNum = MSG_ENCODING_NUM;
1237                 pTable = (char **)szMsgEncoding;
1238                 break;
1239
1240         case MSG_DISPOSITION:
1241                 nNum = MSG_DISPOSITION_NUM;
1242                 pTable = (char **)szMsgDisposition;
1243                 break;
1244
1245         case MSG_ADDR_TYPE:
1246                 nNum = MSG_ADDR_TYPE_NUM;
1247                 pTable = (char **)szMsgAddrType;
1248                 break;
1249
1250         default:
1251                 break;
1252         }
1253
1254         if (code < 0 || code >= nNum || !pTable)
1255                 return (char *)MSG_UNKNOWN_TYPE_STRING;
1256
1257         return pTable[code];
1258 }
1259
1260 char *_MsgSkipWS3(char *s)
1261 {
1262         while (true) {
1263                 if ((*s == MSG_CH_CR) ||
1264                         (*s == MSG_CH_LF) ||
1265                         (*s == MSG_CH_SP) ||
1266                         (*s == MSG_CH_TAB))
1267                         ++s;
1268                 else
1269                         return s;
1270         }
1271 }
1272
1273
1274 int _MsgGetCode(MsgHeaderField tableId, char *pStr)
1275 {
1276         int cCode = 0;
1277         int nNum = MSG_FIELD_UNKNOWN;
1278         char **pTable = NULL;
1279
1280         switch (tableId) {
1281         case MSG_FIELD:
1282                 nNum = MSG_FIELD_NUM;
1283                 pTable = (char **)szMsgField;
1284                 break;
1285
1286         case MSG_PARAM:
1287                 nNum = MSG_PARAM_NUM;
1288                 pTable = (char **)szMsgParam;
1289                 break;
1290
1291         case MSG_TYPE:
1292                 return MimeGetMimeIntFromMimeString(pStr);
1293
1294         case MSG_CHARSET:
1295                 nNum = MSG_CHARSET_NUM;
1296                 pTable = (char **)szMsgCharset;
1297                 break;
1298
1299         case MSG_ENCODING:
1300                 nNum = MSG_ENCODING_NUM;
1301                 pTable = (char **)szMsgEncoding;
1302                 break;
1303
1304         case MSG_DISPOSITION:
1305                 nNum = MSG_DISPOSITION_NUM;
1306                 pTable = (char **)szMsgDisposition;
1307                 break;
1308
1309         case MSG_ADDR_TYPE:
1310                 nNum = MSG_ADDR_TYPE_NUM;
1311                 pTable = (char **)szMsgAddrType;
1312                 break;
1313
1314         default:
1315                 MSG_DEBUG("_MsgGetCode: Invalid tableId [%d] \n", tableId);
1316                 break;
1317         }
1318
1319         for (cCode = 0; cCode < nNum; cCode++) {
1320                 if (pTable[cCode] != NULL) {
1321                         if (!strcasecmp( pStr, pTable[cCode])) {
1322                                 return cCode;
1323                         }
1324                 }
1325         }
1326
1327         return INVALID_HOBJ;
1328 }
1329