#include "ContentType.h" StringMapCI ContentType::m_contentTypes; StringMapCI ContentType::m_extensions; //file extension lookup unsigned int ContentType::m_count = 1; ContentType::ContentType(const char *_MIMETypeText, const char *_extension, const bool _process, unsigned int extraMIMETypes, unsigned int extraExtensions, ...): m_id(m_count++), m_MIMETypeText(_MIMETypeText), m_extension(_extension), m_process(_process) { //add official MIMEType text and extension addMIMETypeText(m_MIMETypeText); if (m_extension) addExtension(m_extension); //some MIMETypes have no associated extensions va_list ap; va_start(ap, extraExtensions); //add other variable MIMEType texts const char *MIMETypeText; for (unsigned int i = 0; i < extraMIMETypes; i++) if (MIMETypeText = va_arg(ap, const char*)) addMIMETypeText(MIMETypeText); //add other extensions const char *extension; for (unsigned int i = 0; i < extraExtensions; i++) if (extension = va_arg(ap, const char*)) addExtension(extension); va_end(ap); } void ContentType::addExtension(const char *extension) { pair::iterator, bool> pr = m_extensions.insert(make_pair(extension, this)); if (!pr.second || !extension || !*extension) { //pr->second == true if an insertion was made DEBUGERROR("[ContentType]: extension already exists [%s]", extension); throw ExtensionExists(extension); } } void ContentType::addMIMETypeText(const char *MIMETypeText) { pair::iterator, bool> pr = m_contentTypes.insert(make_pair(MIMETypeText, this)); if (!pr.second || !MIMETypeText || !*MIMETypeText) { //pr->second == true if an insertion was made DEBUGERROR("[ContentType]: MIMEType already exists [%s]", MIMETypeText); throw MIMETypeExists(MIMETypeText); } } ContentType *ContentType::contentType(const char *textstart) { StringMapCI::const_iterator i; i = m_contentTypes.find(textstart); return (i == m_contentTypes.end() ? 0 : i->second); } ContentType *ContentType::fromextension(const char *textstart) { StringMapCI::const_iterator i; i = m_extensions.find(textstart); return (i == m_extensions.end() ? 0 : i->second); } //special ContentType ContentType::unknownContentType("unknownContentType", 0, true); ContentType ContentType::notStatedContentType("notStatedContentType", 0, true); //extra ContentType ContentType::application_xml("application/xml", "xml", false, 1, 0, "text/xml"); ContentType ContentType::unknown_script("unknown_script", "php", true, 0, 7, "php3", "asp", "aspx", "cfm", "jsp", "cgi", "pl"); ContentType ContentType::image_png("image/png", "png"); ContentType ContentType::video_x_ms_wmv("video/x-ms-wmv", "wmv"); ContentType ContentType::application_rss_xml("application/rss+xml", "rss"); //from IIS 5 (http://www.w3schools.com/media/media_mimeref.asp) ContentType ContentType::application_envoy("application/envoy", "evy"); ContentType ContentType::application_fractals("application/fractals", "fif"); ContentType ContentType::application_futuresplash("application/futuresplash", "spl"); ContentType ContentType::application_hta("application/hta", "hta"); ContentType ContentType::application_internet_property_stream("application/internet-property-stream", "acx"); ContentType ContentType::application_mac_binhex40("application/mac-binhex40", "hqx"); ContentType ContentType::application_msword("application/msword", "doc", false, 0, 1, "dot"); ContentType ContentType::application_octet_stream("application/octet-stream", "bin", false, 0, 5, "lzh", "class", "dms", "exe", "lha"); ContentType ContentType::application_oda("application/oda", "oda"); ContentType ContentType::application_olescript("application/olescript", "axs"); ContentType ContentType::application_pdf("application/pdf", "pdf"); ContentType ContentType::application_pics_rules("application/pics-rules", "prf"); ContentType ContentType::application_pkcs10("application/pkcs10", "p10"); ContentType ContentType::application_pkix_crl("application/pkix-crl", "crl"); ContentType ContentType::application_postscript("application/postscript", "ps", false, 0, 2, "eps", "ai"); ContentType ContentType::application_rtf("application/rtf", "rtf", true); ContentType ContentType::application_set_payment_initiation("application/set-payment-initiation", "setpay"); ContentType ContentType::application_set_registration_initiation("application/set-registration-initiation", "setreg"); ContentType ContentType::application_vnd_ms_excel("application/vnd.ms-excel", "xls", false, 0, 5, "xla", "xlc", "xlm", "xlt", "xlw"); ContentType ContentType::application_vnd_ms_outlook("application/vnd.ms-outlook"); ContentType ContentType::application_vnd_ms_pkicertstore("application/vnd.ms-pkicertstore", "sst"); ContentType ContentType::application_vnd_ms_pkiseccat("application/vnd.ms-pkiseccat", "cat"); ContentType ContentType::application_vnd_ms_pkistl("application/vnd.ms-pkistl", "stl"); ContentType ContentType::application_vnd_ms_powerpoint("application/vnd.ms-powerpoint", "ppt", false, 0, 2, "pps", "pot"); ContentType ContentType::application_vnd_ms_project("application/vnd.ms-project", "mpp"); ContentType ContentType::application_vnd_ms_works("application/vnd.ms-works", "wks", false, 0, 3, "wps", "wdb", "wcm"); ContentType ContentType::application_winhlp("application/winhlp", "hlp"); ContentType ContentType::application_x_bcpio("application/x-bcpio", "bcpio"); ContentType ContentType::application_x_cdf("application/x-cdf", "cdf"); ContentType ContentType::application_x_compress("application/x-compress", "z"); ContentType ContentType::application_x_compressed("application/x-compressed", "tgz"); ContentType ContentType::application_x_cpio("application/x-cpio", "cpio"); ContentType ContentType::application_x_csh("application/x-csh", "csh"); ContentType ContentType::application_x_director("application/x-director", "dcr", false, 0, 2, "dir", "dxr"); ContentType ContentType::application_x_dvi("application/x-dvi", "dvi"); ContentType ContentType::application_x_gtar("application/x-gtar", "gtar"); ContentType ContentType::application_x_gzip("application/x-gzip", "gz"); ContentType ContentType::application_x_hdf("application/x-hdf", "hdf"); ContentType ContentType::application_x_internet_signup("application/x-internet-signup", "ins", false, 0, 1, "isp"); ContentType ContentType::application_x_iphone("application/x-iphone", "iii"); ContentType ContentType::application_x_javascript("text/javascript", "js", true, 1, 0, "application/x-javascript"); ContentType ContentType::application_x_latex("application/x-latex", "latex"); ContentType ContentType::application_x_msaccess("application/x-msaccess", "mdb"); ContentType ContentType::application_x_mscardfile("application/x-mscardfile", "crd"); ContentType ContentType::application_x_msclip("application/x-msclip", "clp"); ContentType ContentType::application_x_msdownload("application/x-msdownload", "dll"); ContentType ContentType::application_x_msmediaview("application/x-msmediaview", "m13", false, 0, 2, "m14", "mvb"); ContentType ContentType::application_x_msmetafile("application/x-msmetafile", "wmf"); ContentType ContentType::application_x_msmoney("application/x-msmoney", "mny"); ContentType ContentType::application_x_mspublisher("application/x-mspublisher", "pub"); ContentType ContentType::application_x_msschedule("application/x-msschedule", "scd"); ContentType ContentType::application_x_msterminal("application/x-msterminal", "trm"); ContentType ContentType::application_x_mswrite("application/x-mswrite", "wri"); ContentType ContentType::application_x_netcdf("application/x-netcdf"); ContentType ContentType::application_x_perfmon("application/x-perfmon", "pma", false, 0, 4, "pmc", "pml", "pmr", "pmw"); ContentType ContentType::application_x_pkcs12("application/x-pkcs12", "p12", false, 0, 1, "pfx"); ContentType ContentType::application_x_pkcs7_certificates("application/x-pkcs7-certificates", "p7b", false, 0, 1, "spc"); ContentType ContentType::application_x_pkcs7_certreqresp("application/x-pkcs7-certreqresp", "p7r"); ContentType ContentType::application_x_pkcs7_mime("application/x-pkcs7-mime", "p7c", false, 0, 1, "p7m"); ContentType ContentType::application_x_pkcs7_signature("application/x-pkcs7-signature", "p7s"); ContentType ContentType::application_x_sh("application/x-sh", "sh"); ContentType ContentType::application_x_shar("application/x-shar", "shar"); ContentType ContentType::application_x_shockwave_flash("application/x-shockwave-flash", "swf"); ContentType ContentType::application_x_stuffit("application/x-stuffit", "sit"); ContentType ContentType::application_x_sv4cpio("application/x-sv4cpio", "sv4cpio"); ContentType ContentType::application_x_sv4crc("application/x-sv4crc", "sv4crc"); ContentType ContentType::application_x_tar("application/x-tar", "tar"); ContentType ContentType::application_x_tcl("application/x-tcl", "tcl"); ContentType ContentType::application_x_tex("application/x-tex", "tex"); ContentType ContentType::application_x_texinfo("application/x-texinfo", "texi", false, 0, 1, "texinfo"); ContentType ContentType::application_x_troff("application/x-troff", "roff", false, 0, 2, "t", "tr"); ContentType ContentType::application_x_troff_man("application/x-troff-man", "man"); ContentType ContentType::application_x_troff_me("application/x-troff-me", "me"); ContentType ContentType::application_x_troff_ms("application/x-troff-ms", "ms"); ContentType ContentType::application_x_ustar("application/x-ustar", "ustar"); ContentType ContentType::application_x_wais_source("application/x-wais-source", "src"); ContentType ContentType::application_x_x509_ca_cert("application/x-x509-ca-cert", "cer", false, 0, 2, "crt", "der"); ContentType ContentType::application_ynd_ms_pkipko("application/ynd.ms-pkipko", "pko"); ContentType ContentType::application_zip("application/zip", "zip"); ContentType ContentType::audio_basic("audio/basic", "au", false, 0, 1, "snd"); ContentType ContentType::audio_mid("audio/mid", "mid", false, 0, 1, "rmi"); ContentType ContentType::audio_mpeg("audio/mpeg", "mp3"); ContentType ContentType::audio_x_aiff("audio/x-aiff", "aif", false, 0, 2, "aifc", "aiff"); ContentType ContentType::audio_x_mpegurl("audio/x-mpegurl", "m3u"); ContentType ContentType::audio_x_pn_realaudio("audio/x-pn-realaudio", "ra", false, 0, 1, "ram"); ContentType ContentType::audio_x_wav("audio/x-wav", "wav"); ContentType ContentType::image_bmp("image/bmp", "bmp"); ContentType ContentType::image_cis_cod("image/cis-cod", "cod"); ContentType ContentType::image_gif("image/gif", "gif"); ContentType ContentType::image_ief("image/ief", "ief"); ContentType ContentType::image_jpeg("image/jpeg", "jpg", false, 0, 2, "jpe", "jpeg"); ContentType ContentType::image_pipeg("image/pipeg", "jfif"); ContentType ContentType::image_svg_xml("image/svg+xml", "svg"); ContentType ContentType::image_tiff("image/tiff", "tif", false, 0, 1, "tiff"); ContentType ContentType::image_x_cmu_raster("image/x-cmu-raster", "ras"); ContentType ContentType::image_x_cmx("image/x-cmx", "cmx"); ContentType ContentType::image_x_icon("image/x-icon", "ico"); ContentType ContentType::image_x_portable_anymap("image/x-portable-anymap", "pnm"); ContentType ContentType::image_x_portable_bitmap("image/x-portable-bitmap", "pbm"); ContentType ContentType::image_x_portable_graymap("image/x-portable-graymap", "pgm"); ContentType ContentType::image_x_portable_pixmap("image/x-portable-pixmap", "ppm"); ContentType ContentType::image_x_rgb("image/x-rgb", "rgb"); ContentType ContentType::image_x_xbitmap("image/x-xbitmap", "xbm"); ContentType ContentType::image_x_xpixmap("image/x-xpixmap", "xpm"); ContentType ContentType::image_x_xwindowdump("image/x-xwindowdump", "xwd"); ContentType ContentType::message_rfc822("message/rfc822", "mht", false, 0, 2, "mhtml", "nws"); ContentType ContentType::text_css("text/css", "css"); ContentType ContentType::text_h323("text/h323", "323"); ContentType ContentType::text_html("text/html", "html", true, 0, 3, "shtml", "htm", "stm"); ContentType ContentType::text_iuls("text/iuls", "uls"); ContentType ContentType::text_plain("text/plain", "txt", true, 0, 3, "bas", "c", "h"); ContentType ContentType::text_richtext("text/richtext", "rtx", true); ContentType ContentType::text_scriptlet("text/scriptlet", "sct"); ContentType ContentType::text_tab_separated_values("text/tab-separated-values", "tsv", true); ContentType ContentType::text_webviewhtml("text/webviewhtml", "htt"); ContentType ContentType::text_x_component("text/x-component", "htc"); ContentType ContentType::text_x_setext("text/x-setext", "etx"); ContentType ContentType::text_x_vcard("text/x-vcard", "vcf"); ContentType ContentType::video_mpeg("video/mpeg", "mp2", false, 0, 5, "mpa", "mpe", "mpeg", "mpg", "mpv2"); ContentType ContentType::video_quicktime("video/quicktime", "mov", false, 0, 1, "qt"); ContentType ContentType::video_x_la_asf("video/x-la-asf", "lsf", false, 0, 1, "lsx"); ContentType ContentType::video_x_ms_asf("video/x-ms-asf", "asf", false, 0, 2, "asr", "asx"); ContentType ContentType::video_x_msvideo("video/x-msvideo", "avi"); ContentType ContentType::video_x_sgi_movie("video/x-sgi-movie", "movie"); ContentType ContentType::x_world_x_vrml("x-world/x-vrml", "vrml", false, 0, 5, "xof", "flr", "wrl", "wrz", "xaf");