3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
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>
14 * PROPRIETARY/CONFIDENTIAL
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.
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.
33 #include "MmsPluginMIME.h"
36 #include "MmsPluginSmil.h"
43 static const char *szMsgField[MSG_FIELD_NUM] =
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
59 "Content-Description",
62 "Return-Receipt-To", /* Delivery confirm */
63 "Disposition-Notification-To", /* Read confirm */
69 /* MIME header field parameter */
70 static const char *szMsgParam[MSG_PARAM_NUM] =
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
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
86 /* Content-Transfer-Encoding header value */
87 static const char *szMsgEncoding[MSG_ENCODING_NUM] =
96 /* Content-Disposition header value */
97 static const char *szMsgDisposition[MSG_DISPOSITION_NUM] =
104 static const char *szMsgAddrType[MSG_ADDR_TYPE_NUM] =
113 /* character-set value */
114 static const char *szMsgCharset [MSG_CHARSET_NUM] =
120 /* MIME character-set value */
153 /************************************************** MIME definition ***************************************************/
154 static const MimeTable mimeTable[] = {
156 {"*/*", "", false, MIME_ASTERISK, MIME_ASTERISK, MIME_APPLICATION_NONE, MIME_MAINTYPE_ETC, UNDEFINED_BINARY },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
288 {"image/vnd.wap.wbmp", "wbmp", false, MIME_IMAGE_VND_WAP_WBMP, MIME_IMAGE_WBMP, MIME_APPLICATION_IMAGEVIEWER, MIME_MAINTYPE_IMAGE, 0x21 },
290 {"image/x-bmp", "bmp", false, MIME_IMAGE_X_BMP, MIME_IMAGE_BMP, MIME_APPLICATION_IMAGEVIEWER, MIME_MAINTYPE_IMAGE, UNDEFINED_BINARY },
292 {"message/rfc822", "elm", false, MIME_MESSAGE_RFC822, MIME_MESSAGE_RFC822, MIME_APPLICATION_NONE, MIME_MAINTYPE_MESSAGE, UNDEFINED_BINARY },
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 },
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 },
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 },
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 },
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 },
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 },
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 }
355 /********** MIME table information ***********/
356 static const int mimeTableIndex[] = {
367 /***************** Extension definition *****************/
368 static const ExtTable extTable[] = {
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}
439 static int mimeTableEnum[] =
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 ,
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,
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 ,
516 MIME_AUDIO_IMELODY2 ,
525 MIME_AUDIO_MP4A_LATM ,
531 MIME_AUDIO_MOBILE_XMF,
534 MIME_AUDIO_VND_RN_REALAUDIO ,
544 MIME_AUDIO_X_IMELODY ,
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 ,
552 MIME_AUDIO_X_MS_WMA ,
554 MIME_AUDIO_X_MS_ASF ,
569 MIME_IMAGE_VND_WAP_WBMP ,
573 MIME_MESSAGE_RFC822 ,
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 ,
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 ,
600 MIME_TEXT_X_VCALENDAR ,
602 MIME_TEXT_X_IMELODY ,
603 MIME_TEXT_X_IMELODY2 ,
616 MIME_VIDEO_VND_RN_REALVIDEO ,
617 MIME_VIDEO_VND_RN_REALMEDIA ,
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 ,
624 MIME_VIDEO_X_PV_PVX ,
626 MIME_UNKNOWN // MIME_MAX
630 #define MIME_MAX_NUM 166
632 #define MIME_SUB_TYPE_VND 1
633 #define MIME_SUB_TYPE_X 2
635 int __MimeGetTableIndexInt(MimeType mime);
636 int __MimeGetTableIndexString(const char *szMime);
637 MimeMainType __MimeGetMainTypeName(const char *szType);
641 * This function checks whether a mime is downloadable or not.
643 * @param mime [in] Enumeration number for a MIME type.
644 * @return This function returns true if downloadable, or false.
646 bool MimeIsDownloadableInt(MimeType mime)
650 index = __MimeGetTableIndexInt(mime);
651 if (index == MIME_UNKNOWN)
654 return mimeTable[index].bDownloadable;
658 * This function checks whether a mime is downloadable or not.
660 * @param mime [in] MIME string.
661 * @return This function returns true if downloadable, or false.
663 bool MimeIsDownloadableString(const char *szMime)
667 index = __MimeGetTableIndexString(szMime);
668 if (index == MIME_UNKNOWN)
671 return mimeTable[index].bDownloadable;
675 * This function checks main type of a MIME.
677 * @param mime [in] Enumeration number for a MIME type.
678 * @return This function returns main type of a MIME.
680 MimeMainType MimeGetMainTypeInt(MimeType mime)
684 index = __MimeGetTableIndexInt(mime);
685 if (index == MIME_UNKNOWN)
686 return MIME_MAINTYPE_ETC;
688 return mimeTable[index].mainType;
692 * This function checks main type of a MIME.
694 * @param mime [in] MIME string.
695 * @return This function returns main type of a MIME.
697 MimeMainType MimeGetMainTypeString(const char *szMime)
701 index = __MimeGetTableIndexString(szMime);
702 if (index == MIME_UNKNOWN)
703 return MIME_MAINTYPE_ETC;
705 return mimeTable[index].mainType;
709 * This function returns a extension name for a specified MIME.
711 * @param mime [in] Enumeration number for a MIME type.
712 * @return This function returns Extension string.
714 char *MimeGetExtFromMimeInt(MimeType mime)
718 index = __MimeGetTableIndexInt(mime);
719 if (index == MIME_UNKNOWN)
722 return (char *)mimeTable[index].szExt;
726 * This function returns a extension name for a specified MIME.
728 * @param mime [in] MIME string.
729 * @return This function returns Extension string.
731 char *MimeGetExtFromMimeString(const char *szMime)
735 index = __MimeGetTableIndexString(szMime);
736 if (index == MIME_UNKNOWN)
739 return (char *)mimeTable[index].szExt;
744 * This function returns a MIME type for a specified Extension.
746 * @param mime [in] Extension string.
747 * @return This function returns MIME string.
749 char *MimeGetMimeFromExtString(const char *szExt)
753 for (i = 0; i < EXT_MAX; i++) {
754 if (!strcasecmp( extTable[i].szExt, szExt)) {
757 index = __MimeGetTableIndexInt(extTable[i].mimeType);
758 if (index == MIME_UNKNOWN)
761 return (char *)mimeTable[index].szMIME;
769 * This function returns a MIME type for a specified Extension.
771 * @param mime [in] Extension string.
772 * @return This function returns MIME string.
774 MimeType MimeGetMimeFromExtInt(const char *szExt)
778 for (i = 0; i < EXT_MAX; i++) {
779 if (!strcasecmp( extTable[i].szExt, szExt))
780 return extTable[i].mimeType;
787 * This function returns index number in MIME definition table with MIME enumeration.
790 int __MimeGetTableIndexInt(MimeType mime)
797 if (mime == MIME_UNKNOWN)
800 type = (mime & 0xf000) >> 12;
801 subtype = (mime & 0x0f00) >> 8;
802 index = (mime & 0x003f);
804 //If 'type' is zero, mimeTableIndex's array value have a minus value
805 //If 'type' is zero, mime type is '*/*'
809 tableIndex = mimeTableIndex[(type - 1) * 3 + subtype] + index;
815 #define MIME_MAX_LEN 43
817 * This function returns index number in MIME definition table with MIME string.
820 int __MimeGetTableIndexString(const char *szMime)
826 char *szTmpStart = NULL;
832 char *szMIMEType = NULL;
835 if (szMime == NULL) {
836 MSG_DEBUG("szMime is NULL");
840 szMIMEType = (char * )malloc(strlen(szMime) + 1);
842 if (szMIMEType == NULL) {
843 MSG_DEBUG("szMime is NULL");
847 memset(szMIMEType, 0, strlen(szMime) + 1);
849 if (!strcmp(szMime, "*/*")) {
853 strcpy(szMIMEType, szMime);
857 szTmpStart = szMIMEType;
858 len = strlen(szTmpStart);
870 type = __MimeGetMainTypeName(szType);
871 szTmpStart = &szTmpStart[i];
879 len = strlen(szTmpStart);
890 if (!strcasecmp(szSubType, "vnd"))
891 subtype = MIME_SUB_TYPE_VND;
893 } else if (c == '-') {
895 if (!strcasecmp(szSubType, "x"))
896 subtype = MIME_SUB_TYPE_X;
903 start = mimeTableIndex[type * 3 + subtype];
905 if (type == MIME_MAINTYPE_VIDEO && subtype == MIME_SUB_TYPE_X)
908 end = mimeTableIndex[type * 3 + subtype + 1];
910 if (start == end && type < MIME_MAINTYPE_VIDEO) {
911 end = mimeTableIndex[(type + 1) * 3 + subtype + 1];
915 for (i = start; i < end; i++) {
916 if (i >= MIME_MAX_NUM)
919 if (!strcasecmp(mimeTable[i].szMIME, szMime)) {
930 * This function returns main type of MIME : Internal function.
932 MimeMainType __MimeGetMainTypeName(const char *szType)
935 return MIME_MAINTYPE_APPLICATION;
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;
952 return MIME_MAINTYPE_APPLICATION;
957 // MimeString -> MimeInt
958 MimeType MimeGetMimeIntFromMimeString(char *szMimeStr)
960 int index = __MimeGetTableIndexString(szMimeStr);
961 if (index == MIME_UNKNOWN) {
964 return (MimeType)mimeTableEnum[index];
968 // MimeInt -> MimeString
969 char *MimeGetMimeStringFromMimeInt(int mimeType)
971 int idx = __MimeGetTableIndexInt((MimeType)mimeType);
973 if (idx == MIME_UNKNOWN)
976 return (char *)mimeTable[idx].szMIME;
980 // BinaryCode -> MimeInt
981 MimeType MimeGetMimeIntFromBi(int binCode)
985 if (binCode < 0x00 || binCode > 0x4b)
988 for (index = 0; index < MIME_MAX_NUM; index++) {
989 if (binCode == mimeTable[index].binary)
990 return (MimeType)mimeTableEnum[index];
996 // BinaryCode -> MimeInt
997 char *MimeGetMimeStringFromBi(int binCode)
1001 if (binCode < 0x00 || binCode > 0x4b)
1004 for (index = 0; index < MIME_MAX_NUM; index++) {
1005 if (binCode == mimeTable[index].binary)
1006 return (char *)mimeTable[index].szMIME;
1012 // Mimeint -> Binary Value
1013 int MimeGetBinaryValueFromMimeInt(MimeType mime)
1017 index = __MimeGetTableIndexInt(mime);
1018 if (index == MIME_UNKNOWN)
1019 return UNDEFINED_BINARY;
1021 return mimeTable[index].binary;
1024 // MimeString -> Binary value
1025 int MimeGetBinaryValueFromMimeString(const char *szMime)
1029 index = __MimeGetTableIndexString(szMime);
1030 if (index == MIME_UNKNOWN)
1031 return UNDEFINED_BINARY;
1033 return mimeTable[index].binary;
1038 * This function checks main type of a MIME.
1040 * @param mime [in] Enumeration number for a MIME type.
1041 * @return This function returns application type of a MIME.
1043 MimeAppType MimeGetAppTypeFromInt(MimeType mime)
1047 index = __MimeGetTableIndexInt(mime);
1048 if (index == MIME_UNKNOWN)
1049 return MIME_APPLICATION_NONE;
1051 return mimeTable[index].appType;
1055 * This function checks main type of a MIME.
1057 * @param mime [in] MIME string.
1058 * @return This function returns application type of a MIME.
1060 MimeAppType MimeGetAppTypeFromString(const char *szMime)
1064 index = __MimeGetTableIndexString(szMime);
1065 if (index == MIME_UNKNOWN)
1066 return MIME_APPLICATION_NONE;
1068 return mimeTable[index].appType;
1073 * This function returns a application type for a specified Extension.
1075 * @param mime [in] Extension string.
1076 * @return This function returns application type.
1078 MimeAppType MimeGetAppTypeFromExtString(const char *szExt)
1082 for (i = 0; i < EXT_MAX; i++) {
1083 if (!strcasecmp( extTable[i].szExt, szExt)) {
1086 index = __MimeGetTableIndexInt(extTable[i].mimeType);
1087 if (index == MIME_UNKNOWN)
1088 return MIME_APPLICATION_NONE;
1089 return mimeTable[index].appType;
1093 return MIME_APPLICATION_NONE;
1097 * This function gets the representative mime type from MimeType
1099 * @param mime [in] Enumeration number for a MIME type.
1100 * @return representative mime type Enumeration number
1103 MimeType MimeGetContentTypeFromInt(MimeType mime)
1107 for (index = 0; index < MIME_MAX_NUM; index++) {
1108 if (mime == mimeTable[index].mime)
1109 return mimeTable[index].contentType;
1112 return MIME_UNKNOWN;
1116 * This function gets the representative mime type from mime string
1118 * @param szMime - string name of MimeType
1119 * @return representative mime type Enumeration number
1122 MimeType MimeGetContentTypeFromString(const char *szMime)
1126 for (index = 0; index < MIME_MAX_NUM; index++) {
1127 if (!strcasecmp(szMime, mimeTable[index].szMIME))
1128 return mimeTable[index].contentType;
1131 return MIME_UNKNOWN;
1135 * This function gets the index from mime string
1137 * @param szMime - string name of MimeType
1138 * @return Enumeration number for a MIME type.
1141 MimeType MimeGetMimeTypeFromString(const char *szMime)
1145 for (index = 0; index < MIME_MAX_NUM; index++) {
1146 if (!strcasecmp(szMime, mimeTable[index].szMIME))
1147 return mimeTable[index].mime;
1150 return MIME_UNKNOWN;
1154 int MsgGetCode(MsgHeaderField tableId, char *pStr)
1157 int nNum = MSG_FIELD_UNKNOWN;
1158 char **pTable = NULL;
1162 nNum = MSG_FIELD_NUM;
1163 pTable = (char **)szMsgField;
1167 nNum = MSG_PARAM_NUM;
1168 pTable = (char **)szMsgParam;
1172 return MimeGetMimeIntFromMimeString(pStr);
1175 nNum = MSG_CHARSET_NUM;
1176 pTable = (char **)szMsgCharset;
1180 nNum = MSG_ENCODING_NUM;
1181 pTable = (char **)szMsgEncoding;
1184 case MSG_DISPOSITION:
1185 nNum = MSG_DISPOSITION_NUM;
1186 pTable = (char **)szMsgDisposition;
1190 nNum = MSG_ADDR_TYPE_NUM;
1191 pTable = (char **)szMsgAddrType;
1198 for (cCode = 0; cCode < nNum; cCode++) {
1199 if (!strcasecmp(pStr, pTable[cCode])) {
1208 char *MsgGetString(MsgHeaderField tableId, int code)
1210 int nNum = MSG_FIELD_UNKNOWN;
1211 char **pTable = NULL;
1215 nNum = MSG_FIELD_NUM;
1216 pTable = (char **)szMsgField;
1220 nNum = MSG_PARAM_NUM;
1221 pTable = (char **)szMsgParam;
1225 if (code != MIME_UNKNOWN && code != -1)
1226 return MimeGetMimeStringFromMimeInt(code);
1228 return (char *)MSG_UNKNOWN_TYPE_STRING;
1231 nNum = MSG_CHARSET_NUM;
1232 pTable = (char **)szMsgCharset;
1236 nNum = MSG_ENCODING_NUM;
1237 pTable = (char **)szMsgEncoding;
1240 case MSG_DISPOSITION:
1241 nNum = MSG_DISPOSITION_NUM;
1242 pTable = (char **)szMsgDisposition;
1246 nNum = MSG_ADDR_TYPE_NUM;
1247 pTable = (char **)szMsgAddrType;
1254 if (code < 0 || code >= nNum || !pTable)
1255 return (char *)MSG_UNKNOWN_TYPE_STRING;
1257 return pTable[code];
1260 char *_MsgSkipWS3(char *s)
1263 if ((*s == MSG_CH_CR) ||
1264 (*s == MSG_CH_LF) ||
1265 (*s == MSG_CH_SP) ||
1274 int _MsgGetCode(MsgHeaderField tableId, char *pStr)
1277 int nNum = MSG_FIELD_UNKNOWN;
1278 char **pTable = NULL;
1282 nNum = MSG_FIELD_NUM;
1283 pTable = (char **)szMsgField;
1287 nNum = MSG_PARAM_NUM;
1288 pTable = (char **)szMsgParam;
1292 return MimeGetMimeIntFromMimeString(pStr);
1295 nNum = MSG_CHARSET_NUM;
1296 pTable = (char **)szMsgCharset;
1300 nNum = MSG_ENCODING_NUM;
1301 pTable = (char **)szMsgEncoding;
1304 case MSG_DISPOSITION:
1305 nNum = MSG_DISPOSITION_NUM;
1306 pTable = (char **)szMsgDisposition;
1310 nNum = MSG_ADDR_TYPE_NUM;
1311 pTable = (char **)szMsgAddrType;
1315 MSG_DEBUG("_MsgGetCode: Invalid tableId [%d] \n", tableId);
1319 for (cCode = 0; cCode < nNum; cCode++) {
1320 if (pTable[cCode] != NULL) {
1321 if (!strcasecmp( pStr, pTable[cCode])) {
1327 return INVALID_HOBJ;