/************************************************************************* * * HTCd - Copyright (C) 1998-2006 Henrik Rydberg * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include struct table_t { char ext[16],name[64]; }; static table_t table[]={ {"ai","application/postscript"}, {"aif","audio/x-aiff"}, {"aifc","audio/x-aiff"}, {"aiff","audio/x-aiff"}, {"au","audio/basic"}, {"avi","video/x-msvideo"}, {"bcpio","application/x-bcpio"}, {"bin","application/octet-stream"}, {"cdf","application/x-netcdf"}, {"class","application/octet-stream"}, {"cpio","application/x-cpio"}, {"cpt","application/mac-compactpro"}, {"csh","application/x-csh"}, {"css","text/css"}, {"dcr","application/x-director"}, {"dir","application/x-director"}, {"dms","application/octet-stream"}, {"doc","application/msword"}, {"dvi","application/x-dvi"}, {"dxr","application/x-director"}, {"eps","application/postscript"}, {"etx","text/x-setext"}, {"exe","application/octet-stream"}, {"gif","image/gif"}, {"gtar","application/x-gtar"}, {"gz","application/x-gzip"}, {"hdf","application/x-hdf"}, {"hqx","application/mac-binhex40"}, {"htc","text/x-htc"}, {"hts","text/plain"}, {"htx","text/x-htx"}, {"htm","text/html"}, {"html","text/html"}, {"ice","x-conference/x-cooltalk"}, {"ief","image/ief"}, {"jpe","image/jpeg"}, {"jpeg","image/jpeg"}, {"jpg","image/jpeg"}, {"kar","audio/midi"}, {"latex","application/x-latex"}, {"lha","application/octet-stream"}, {"lzh","application/octet-stream"}, {"man","application/x-troff-man"}, {"me","application/x-troff-me"}, {"mid","audio/midi"}, {"midi","audio/midi"}, {"mif","application/x-mif"}, {"mov","video/quicktime"}, {"movie","video/x-sgi-movie"}, {"mp2","audio/mpeg"}, {"mp3","audio/mpeg"}, {"mpe","video/mpeg"}, {"mpeg","video/mpeg"}, {"mpg","video/mpeg"}, {"mpga","audio/mpeg"}, {"ms","application/x-troff-ms"}, {"nc","application/x-netcdf"}, {"oda","application/oda"}, {"pbm","image/x-portable-bitmap"}, {"pdb","chemical/x-pdb"}, {"pdf","application/pdf"}, {"pgm","image/x-portable-graymap"}, {"png","image/png"}, {"pnm","image/x-portable-anymap"}, {"ppm","image/x-portable-pixmap"}, {"ppt","application/powerpoint"}, {"ps","application/postscript"}, {"qt","video/quicktime"}, {"ra","audio/x-realaudio"}, {"ram","audio/x-pn-realaudio"}, {"ras","image/x-cmu-raster"}, {"rgb","image/x-rgb"}, {"roff","application/x-troff"}, {"rpm","audio/x-pn-realaudio-plugin"}, {"rtf","application/rtf"}, {"rtx","text/richtext"}, {"sgm","text/x-sgml"}, {"sgml","text/x-sgml"}, {"sh","application/x-sh"}, {"shar","application/x-shar"}, {"sit","application/x-stuffit"}, {"skd","application/x-koan"}, {"skm","application/x-koan"}, {"skp","application/x-koan"}, {"skt","application/x-koan"}, {"snd","audio/basic"}, {"src","application/x-wais-source"}, {"sv4cpio","application/x-sv4cpio"}, {"sv4crc","application/x-sv4crc"}, {"t","application/x-troff"}, {"tar","application/x-tar"}, {"tcl","application/x-tcl"}, {"tex","application/x-tex"}, {"texi","application/x-texinfo"}, {"texinfo","application/x-texinfo"}, {"tif","image/tiff"}, {"tiff","image/tiff"}, {"tr","application/x-troff"}, {"tsv","text/tab-separated-values"}, {"txt","text/plain"}, {"ustar","application/x-ustar"}, {"vcd","application/x-cdlink"}, {"vrml","x-world/x-vrml"}, {"wav","audio/x-wav"}, {"wrl","x-world/x-vrml"}, {"xbm","image/x-xbitmap"}, {"xpm","image/x-xpixmap"}, {"xwd","image/x-xwindowdump"}, {"xyz","chemical/x-pdb"}, {"zip","application/zip"}, {"",""} }; const sref* file2mime(const sref& file) { static rrmap mime; if(mime.empty()) { for(table_t* p=table;*p->ext;p++) mime.add(sref(p->ext),sref(p->name)); } mstring path=file.past_last('.'); path.tolower(); if(path.nempty()) return mime.get(path); return 0; }