Fossil SCM
Add a much larger and more complete file-suffix to mimetype translation table to the "doc" method.
Commit
8e66784522937c6a9525dbd633ffb562d410a8db
Parent
f3ce1c9fed1931e…
1 file changed
+215
-16
+215
-16
| --- src/doc.c | ||
| +++ src/doc.c | ||
| @@ -32,37 +32,236 @@ | ||
| 32 | 32 | ** Guess the mime-type of a document based on its name. |
| 33 | 33 | */ |
| 34 | 34 | const char *mimetype_from_name(const char *zName){ |
| 35 | 35 | const char *z; |
| 36 | 36 | int i; |
| 37 | + int first, last; | |
| 38 | + int len; | |
| 37 | 39 | char zSuffix[20]; |
| 40 | + | |
| 41 | + /* A table of mimetypes based on file suffixes. | |
| 42 | + ** Suffixes must be in sorted order so that we can do a binary | |
| 43 | + ** search to find the mime-type | |
| 44 | + */ | |
| 38 | 45 | static const struct { |
| 39 | - const char *zSuffix; | |
| 40 | - const char *zMimetype; | |
| 46 | + const char *zSuffix; /* The file suffix */ | |
| 47 | + int size; /* Length of the suffix */ | |
| 48 | + const char *zMimetype; /* The corresponding mimetype */ | |
| 41 | 49 | } aMime[] = { |
| 42 | - { "html", "text/html" }, | |
| 43 | - { "htm", "text/html" }, | |
| 44 | - { "wiki", "application/x-fossil-wiki" }, | |
| 45 | - { "txt", "text/plain" }, | |
| 46 | - { "jpg", "image/jpeg" }, | |
| 47 | - { "jpeg", "image/jpeg" }, | |
| 48 | - { "gif", "image/gif" }, | |
| 49 | - { "png", "image/png" }, | |
| 50 | - { "css", "text/css" }, | |
| 50 | + { "ai", 2, "application/postscript" }, | |
| 51 | + { "aif", 3, "audio/x-aiff" }, | |
| 52 | + { "aifc", 4, "audio/x-aiff" }, | |
| 53 | + { "aiff", 4, "audio/x-aiff" }, | |
| 54 | + { "arj", 3, "application/x-arj-compressed" }, | |
| 55 | + { "asc", 3, "text/plain" }, | |
| 56 | + { "asf", 3, "video/x-ms-asf" }, | |
| 57 | + { "asx", 3, "video/x-ms-asx" }, | |
| 58 | + { "au", 2, "audio/ulaw" }, | |
| 59 | + { "avi", 3, "video/x-msvideo" }, | |
| 60 | + { "bat", 3, "application/x-msdos-program" }, | |
| 61 | + { "bcpio", 5, "application/x-bcpio" }, | |
| 62 | + { "bin", 3, "application/octet-stream" }, | |
| 63 | + { "ccad", 4, "application/clariscad" }, | |
| 64 | + { "cc", 2, "text/plain" }, | |
| 65 | + { "cdf", 3, "application/x-netcdf" }, | |
| 66 | + { "class", 5, "application/octet-stream" }, | |
| 67 | + { "cod", 3, "application/vnd.rim.cod" }, | |
| 68 | + { "com", 3, "application/x-msdos-program" }, | |
| 69 | + { "cpio", 4, "application/x-cpio" }, | |
| 70 | + { "cpt", 3, "application/mac-compactpro" }, | |
| 71 | + { "csh", 3, "application/x-csh" }, | |
| 72 | + { "css", 3, "text/css" }, | |
| 73 | + { "c", 1, "text/plain" }, | |
| 74 | + { "dcr", 3, "application/x-director" }, | |
| 75 | + { "deb", 3, "application/x-debian-package" }, | |
| 76 | + { "dir", 3, "application/x-director" }, | |
| 77 | + { "dl", 2, "video/dl" }, | |
| 78 | + { "dms", 3, "application/octet-stream" }, | |
| 79 | + { "doc", 3, "application/msword" }, | |
| 80 | + { "drw", 3, "application/drafting" }, | |
| 81 | + { "dvi", 3, "application/x-dvi" }, | |
| 82 | + { "dwg", 3, "application/acad" }, | |
| 83 | + { "dxf", 3, "application/dxf" }, | |
| 84 | + { "dxr", 3, "application/x-director" }, | |
| 85 | + { "eps", 3, "application/postscript" }, | |
| 86 | + { "etx", 3, "text/x-setext" }, | |
| 87 | + { "exe", 3, "application/octet-stream" }, | |
| 88 | + { "ez", 2, "application/andrew-inset" }, | |
| 89 | + { "f90", 3, "text/plain" }, | |
| 90 | + { "fli", 3, "video/fli" }, | |
| 91 | + { "flv", 3, "video/flv" }, | |
| 92 | + { "f", 1, "text/plain" }, | |
| 93 | + { "gif", 3, "image/gif" }, | |
| 94 | + { "gl", 2, "video/gl" }, | |
| 95 | + { "gtar", 4, "application/x-gtar" }, | |
| 96 | + { "gz", 2, "application/x-gunzip" }, | |
| 97 | + { "gz", 2, "application/x-gzip" }, | |
| 98 | + { "hdf", 3, "application/x-hdf" }, | |
| 99 | + { "hh", 2, "text/plain" }, | |
| 100 | + { "hqx", 3, "application/mac-binhex40" }, | |
| 101 | + { "h", 1, "text/plain" }, | |
| 102 | + { "html", 4, "text/html" }, | |
| 103 | + { "htm", 3, "text/html" }, | |
| 104 | + { "ice", 3, "x-conference/x-cooltalk" }, | |
| 105 | + { "ief", 3, "image/ief" }, | |
| 106 | + { "iges", 4, "model/iges" }, | |
| 107 | + { "igs", 3, "model/iges" }, | |
| 108 | + { "ips", 3, "application/x-ipscript" }, | |
| 109 | + { "ipx", 3, "application/x-ipix" }, | |
| 110 | + { "jad", 3, "text/vnd.sun.j2me.app-descriptor" }, | |
| 111 | + { "jar", 3, "application/java-archive" }, | |
| 112 | + { "jpeg", 4, "image/jpeg" }, | |
| 113 | + { "jpe", 3, "image/jpeg" }, | |
| 114 | + { "jpg", 3, "image/jpeg" }, | |
| 115 | + { "js", 2, "application/x-javascript" }, | |
| 116 | + { "kar", 3, "audio/midi" }, | |
| 117 | + { "latex", 5, "application/x-latex" }, | |
| 118 | + { "lha", 3, "application/octet-stream" }, | |
| 119 | + { "lsp", 3, "application/x-lisp" }, | |
| 120 | + { "lzh", 3, "application/octet-stream" }, | |
| 121 | + { "m3u", 3, "audio/x-mpegurl" }, | |
| 122 | + { "man", 3, "application/x-troff-man" }, | |
| 123 | + { "me", 2, "application/x-troff-me" }, | |
| 124 | + { "mesh", 4, "model/mesh" }, | |
| 125 | + { "mid", 3, "audio/midi" }, | |
| 126 | + { "midi", 4, "audio/midi" }, | |
| 127 | + { "mif", 3, "application/vnd.mif" }, | |
| 128 | + { "mif", 3, "application/x-mif" }, | |
| 129 | + { "mime", 4, "www/mime" }, | |
| 130 | + { "movie", 5, "video/x-sgi-movie" }, | |
| 131 | + { "mov", 3, "video/quicktime" }, | |
| 132 | + { "mp2", 3, "audio/mpeg" }, | |
| 133 | + { "mp2", 3, "video/mpeg" }, | |
| 134 | + { "mp3", 3, "audio/mpeg" }, | |
| 135 | + { "mpeg", 4, "video/mpeg" }, | |
| 136 | + { "mpe", 3, "video/mpeg" }, | |
| 137 | + { "mpga", 4, "audio/mpeg" }, | |
| 138 | + { "mpg", 3, "video/mpeg" }, | |
| 139 | + { "ms", 2, "application/x-troff-ms" }, | |
| 140 | + { "msh", 3, "model/mesh" }, | |
| 141 | + { "m", 1, "text/plain" }, | |
| 142 | + { "nc", 2, "application/x-netcdf" }, | |
| 143 | + { "oda", 3, "application/oda" }, | |
| 144 | + { "ogg", 3, "application/ogg" }, | |
| 145 | + { "ogm", 3, "application/ogg" }, | |
| 146 | + { "pbm", 3, "image/x-portable-bitmap" }, | |
| 147 | + { "pdb", 3, "chemical/x-pdb" }, | |
| 148 | + { "pdf", 3, "application/pdf" }, | |
| 149 | + { "pgm", 3, "image/x-portable-graymap" }, | |
| 150 | + { "pgn", 3, "application/x-chess-pgn" }, | |
| 151 | + { "pgp", 3, "application/pgp" }, | |
| 152 | + { "pl", 2, "application/x-perl" }, | |
| 153 | + { "pm", 2, "application/x-perl" }, | |
| 154 | + { "png", 3, "image/png" }, | |
| 155 | + { "pnm", 3, "image/x-portable-anymap" }, | |
| 156 | + { "pot", 3, "application/mspowerpoint" }, | |
| 157 | + { "ppm", 3, "image/x-portable-pixmap" }, | |
| 158 | + { "pps", 3, "application/mspowerpoint" }, | |
| 159 | + { "ppt", 3, "application/mspowerpoint" }, | |
| 160 | + { "ppz", 3, "application/mspowerpoint" }, | |
| 161 | + { "pre", 3, "application/x-freelance" }, | |
| 162 | + { "prt", 3, "application/pro_eng" }, | |
| 163 | + { "ps", 2, "application/postscript" }, | |
| 164 | + { "qt", 2, "video/quicktime" }, | |
| 165 | + { "ra", 2, "audio/x-realaudio" }, | |
| 166 | + { "ram", 3, "audio/x-pn-realaudio" }, | |
| 167 | + { "rar", 3, "application/x-rar-compressed" }, | |
| 168 | + { "ras", 3, "image/cmu-raster" }, | |
| 169 | + { "ras", 3, "image/x-cmu-raster" }, | |
| 170 | + { "rgb", 3, "image/x-rgb" }, | |
| 171 | + { "rm", 2, "audio/x-pn-realaudio" }, | |
| 172 | + { "roff", 4, "application/x-troff" }, | |
| 173 | + { "rpm", 3, "audio/x-pn-realaudio-plugin" }, | |
| 174 | + { "rtf", 3, "application/rtf" }, | |
| 175 | + { "rtf", 3, "text/rtf" }, | |
| 176 | + { "rtx", 3, "text/richtext" }, | |
| 177 | + { "scm", 3, "application/x-lotusscreencam" }, | |
| 178 | + { "set", 3, "application/set" }, | |
| 179 | + { "sgml", 4, "text/sgml" }, | |
| 180 | + { "sgm", 3, "text/sgml" }, | |
| 181 | + { "sh", 2, "application/x-sh" }, | |
| 182 | + { "shar", 4, "application/x-shar" }, | |
| 183 | + { "silo", 4, "model/mesh" }, | |
| 184 | + { "sit", 3, "application/x-stuffit" }, | |
| 185 | + { "skd", 3, "application/x-koan" }, | |
| 186 | + { "skm", 3, "application/x-koan" }, | |
| 187 | + { "skp", 3, "application/x-koan" }, | |
| 188 | + { "skt", 3, "application/x-koan" }, | |
| 189 | + { "smi", 3, "application/smil" }, | |
| 190 | + { "smil", 4, "application/smil" }, | |
| 191 | + { "snd", 3, "audio/basic" }, | |
| 192 | + { "sol", 3, "application/solids" }, | |
| 193 | + { "spl", 3, "application/x-futuresplash" }, | |
| 194 | + { "src", 3, "application/x-wais-source" }, | |
| 195 | + { "step", 4, "application/STEP" }, | |
| 196 | + { "stl", 3, "application/SLA" }, | |
| 197 | + { "stp", 3, "application/STEP" }, | |
| 198 | + { "sv4cpio", 7, "application/x-sv4cpio" }, | |
| 199 | + { "sv4crc", 6, "application/x-sv4crc" }, | |
| 200 | + { "swf", 3, "application/x-shockwave-flash" }, | |
| 201 | + { "t", 1, "application/x-troff" }, | |
| 202 | + { "tar", 3, "application/x-tar" }, | |
| 203 | + { "tcl", 3, "application/x-tcl" }, | |
| 204 | + { "tex", 3, "application/x-tex" }, | |
| 205 | + { "texi", 4, "application/x-texinfo" }, | |
| 206 | + { "texinfo", 7, "application/x-texinfo" }, | |
| 207 | + { "tgz", 3, "application/x-tar-gz" }, | |
| 208 | + { "tiff", 4, "image/tiff" }, | |
| 209 | + { "tif", 3, "image/tiff" }, | |
| 210 | + { "tif", 3, "image/tiff" }, | |
| 211 | + { "tr", 2, "application/x-troff" }, | |
| 212 | + { "tsi", 3, "audio/TSP-audio" }, | |
| 213 | + { "tsp", 3, "application/dsptype" }, | |
| 214 | + { "tsv", 3, "text/tab-separated-values" }, | |
| 215 | + { "txt", 3, "text/plain" }, | |
| 216 | + { "unv", 3, "application/i-deas" }, | |
| 217 | + { "ustar", 5, "application/x-ustar" }, | |
| 218 | + { "vcd", 3, "application/x-cdlink" }, | |
| 219 | + { "vda", 3, "application/vda" }, | |
| 220 | + { "vivo", 4, "video/vnd.vivo" }, | |
| 221 | + { "viv", 3, "video/vnd.vivo" }, | |
| 222 | + { "vrml", 4, "model/vrml" }, | |
| 223 | + { "wav", 3, "audio/x-wav" }, | |
| 224 | + { "wax", 3, "audio/x-ms-wax" }, | |
| 225 | + { "wiki", 4, "application/x-fossil-wiki" }, | |
| 226 | + { "wma", 3, "audio/x-ms-wma" }, | |
| 227 | + { "wmv", 3, "video/x-ms-wmv" }, | |
| 228 | + { "wmx", 3, "video/x-ms-wmx" }, | |
| 229 | + { "wrl", 3, "model/vrml" }, | |
| 230 | + { "wvx", 3, "video/x-ms-wvx" }, | |
| 231 | + { "xbm", 3, "image/x-xbitmap" }, | |
| 232 | + { "xlc", 3, "application/vnd.ms-excel" }, | |
| 233 | + { "xll", 3, "application/vnd.ms-excel" }, | |
| 234 | + { "xlm", 3, "application/vnd.ms-excel" }, | |
| 235 | + { "xls", 3, "application/vnd.ms-excel" }, | |
| 236 | + { "xlw", 3, "application/vnd.ms-excel" }, | |
| 237 | + { "xml", 3, "text/xml" }, | |
| 238 | + { "xpm", 3, "image/x-xpixmap" }, | |
| 239 | + { "xwd", 3, "image/x-xwindowdump" }, | |
| 240 | + { "xyz", 3, "chemical/x-pdb" }, | |
| 241 | + { "zip", 3, "application/zip" }, | |
| 51 | 242 | }; |
| 52 | 243 | |
| 53 | 244 | z = zName; |
| 54 | 245 | for(i=0; zName[i]; i++){ |
| 55 | 246 | if( zName[i]=='.' ) z = &zName[i+1]; |
| 56 | 247 | } |
| 57 | - i = strlen(z); | |
| 58 | - if( i<sizeof(zSuffix)-1 ){ | |
| 248 | + len = strlen(z); | |
| 249 | + if( len<sizeof(zSuffix)-1 ){ | |
| 59 | 250 | strcpy(zSuffix, z); |
| 60 | 251 | for(i=0; zSuffix[i]; i++) zSuffix[i] = tolower(zSuffix[i]); |
| 61 | - for(i=0; i<sizeof(aMime)/sizeof(aMime[0]); i++){ | |
| 62 | - if( strcmp(zSuffix, aMime[i].zSuffix)==0 ){ | |
| 63 | - return aMime[i].zMimetype; | |
| 252 | + first = 0; | |
| 253 | + last = sizeof(aMime)/sizeof(aMime[0]); | |
| 254 | + while( first<=last ){ | |
| 255 | + int c; | |
| 256 | + i = (first+last)/2; | |
| 257 | + c = strcmp(zSuffix, aMime[i].zSuffix); | |
| 258 | + if( c==0 ) return aMime[i].zMimetype; | |
| 259 | + if( c<0 ){ | |
| 260 | + last = i-1; | |
| 261 | + }else{ | |
| 262 | + first = i+1; | |
| 64 | 263 | } |
| 65 | 264 | } |
| 66 | 265 | } |
| 67 | 266 | return "application/x-fossil-artifact"; |
| 68 | 267 | } |
| 69 | 268 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -32,37 +32,236 @@ | |
| 32 | ** Guess the mime-type of a document based on its name. |
| 33 | */ |
| 34 | const char *mimetype_from_name(const char *zName){ |
| 35 | const char *z; |
| 36 | int i; |
| 37 | char zSuffix[20]; |
| 38 | static const struct { |
| 39 | const char *zSuffix; |
| 40 | const char *zMimetype; |
| 41 | } aMime[] = { |
| 42 | { "html", "text/html" }, |
| 43 | { "htm", "text/html" }, |
| 44 | { "wiki", "application/x-fossil-wiki" }, |
| 45 | { "txt", "text/plain" }, |
| 46 | { "jpg", "image/jpeg" }, |
| 47 | { "jpeg", "image/jpeg" }, |
| 48 | { "gif", "image/gif" }, |
| 49 | { "png", "image/png" }, |
| 50 | { "css", "text/css" }, |
| 51 | }; |
| 52 | |
| 53 | z = zName; |
| 54 | for(i=0; zName[i]; i++){ |
| 55 | if( zName[i]=='.' ) z = &zName[i+1]; |
| 56 | } |
| 57 | i = strlen(z); |
| 58 | if( i<sizeof(zSuffix)-1 ){ |
| 59 | strcpy(zSuffix, z); |
| 60 | for(i=0; zSuffix[i]; i++) zSuffix[i] = tolower(zSuffix[i]); |
| 61 | for(i=0; i<sizeof(aMime)/sizeof(aMime[0]); i++){ |
| 62 | if( strcmp(zSuffix, aMime[i].zSuffix)==0 ){ |
| 63 | return aMime[i].zMimetype; |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | return "application/x-fossil-artifact"; |
| 68 | } |
| 69 |
| --- src/doc.c | |
| +++ src/doc.c | |
| @@ -32,37 +32,236 @@ | |
| 32 | ** Guess the mime-type of a document based on its name. |
| 33 | */ |
| 34 | const char *mimetype_from_name(const char *zName){ |
| 35 | const char *z; |
| 36 | int i; |
| 37 | int first, last; |
| 38 | int len; |
| 39 | char zSuffix[20]; |
| 40 | |
| 41 | /* A table of mimetypes based on file suffixes. |
| 42 | ** Suffixes must be in sorted order so that we can do a binary |
| 43 | ** search to find the mime-type |
| 44 | */ |
| 45 | static const struct { |
| 46 | const char *zSuffix; /* The file suffix */ |
| 47 | int size; /* Length of the suffix */ |
| 48 | const char *zMimetype; /* The corresponding mimetype */ |
| 49 | } aMime[] = { |
| 50 | { "ai", 2, "application/postscript" }, |
| 51 | { "aif", 3, "audio/x-aiff" }, |
| 52 | { "aifc", 4, "audio/x-aiff" }, |
| 53 | { "aiff", 4, "audio/x-aiff" }, |
| 54 | { "arj", 3, "application/x-arj-compressed" }, |
| 55 | { "asc", 3, "text/plain" }, |
| 56 | { "asf", 3, "video/x-ms-asf" }, |
| 57 | { "asx", 3, "video/x-ms-asx" }, |
| 58 | { "au", 2, "audio/ulaw" }, |
| 59 | { "avi", 3, "video/x-msvideo" }, |
| 60 | { "bat", 3, "application/x-msdos-program" }, |
| 61 | { "bcpio", 5, "application/x-bcpio" }, |
| 62 | { "bin", 3, "application/octet-stream" }, |
| 63 | { "ccad", 4, "application/clariscad" }, |
| 64 | { "cc", 2, "text/plain" }, |
| 65 | { "cdf", 3, "application/x-netcdf" }, |
| 66 | { "class", 5, "application/octet-stream" }, |
| 67 | { "cod", 3, "application/vnd.rim.cod" }, |
| 68 | { "com", 3, "application/x-msdos-program" }, |
| 69 | { "cpio", 4, "application/x-cpio" }, |
| 70 | { "cpt", 3, "application/mac-compactpro" }, |
| 71 | { "csh", 3, "application/x-csh" }, |
| 72 | { "css", 3, "text/css" }, |
| 73 | { "c", 1, "text/plain" }, |
| 74 | { "dcr", 3, "application/x-director" }, |
| 75 | { "deb", 3, "application/x-debian-package" }, |
| 76 | { "dir", 3, "application/x-director" }, |
| 77 | { "dl", 2, "video/dl" }, |
| 78 | { "dms", 3, "application/octet-stream" }, |
| 79 | { "doc", 3, "application/msword" }, |
| 80 | { "drw", 3, "application/drafting" }, |
| 81 | { "dvi", 3, "application/x-dvi" }, |
| 82 | { "dwg", 3, "application/acad" }, |
| 83 | { "dxf", 3, "application/dxf" }, |
| 84 | { "dxr", 3, "application/x-director" }, |
| 85 | { "eps", 3, "application/postscript" }, |
| 86 | { "etx", 3, "text/x-setext" }, |
| 87 | { "exe", 3, "application/octet-stream" }, |
| 88 | { "ez", 2, "application/andrew-inset" }, |
| 89 | { "f90", 3, "text/plain" }, |
| 90 | { "fli", 3, "video/fli" }, |
| 91 | { "flv", 3, "video/flv" }, |
| 92 | { "f", 1, "text/plain" }, |
| 93 | { "gif", 3, "image/gif" }, |
| 94 | { "gl", 2, "video/gl" }, |
| 95 | { "gtar", 4, "application/x-gtar" }, |
| 96 | { "gz", 2, "application/x-gunzip" }, |
| 97 | { "gz", 2, "application/x-gzip" }, |
| 98 | { "hdf", 3, "application/x-hdf" }, |
| 99 | { "hh", 2, "text/plain" }, |
| 100 | { "hqx", 3, "application/mac-binhex40" }, |
| 101 | { "h", 1, "text/plain" }, |
| 102 | { "html", 4, "text/html" }, |
| 103 | { "htm", 3, "text/html" }, |
| 104 | { "ice", 3, "x-conference/x-cooltalk" }, |
| 105 | { "ief", 3, "image/ief" }, |
| 106 | { "iges", 4, "model/iges" }, |
| 107 | { "igs", 3, "model/iges" }, |
| 108 | { "ips", 3, "application/x-ipscript" }, |
| 109 | { "ipx", 3, "application/x-ipix" }, |
| 110 | { "jad", 3, "text/vnd.sun.j2me.app-descriptor" }, |
| 111 | { "jar", 3, "application/java-archive" }, |
| 112 | { "jpeg", 4, "image/jpeg" }, |
| 113 | { "jpe", 3, "image/jpeg" }, |
| 114 | { "jpg", 3, "image/jpeg" }, |
| 115 | { "js", 2, "application/x-javascript" }, |
| 116 | { "kar", 3, "audio/midi" }, |
| 117 | { "latex", 5, "application/x-latex" }, |
| 118 | { "lha", 3, "application/octet-stream" }, |
| 119 | { "lsp", 3, "application/x-lisp" }, |
| 120 | { "lzh", 3, "application/octet-stream" }, |
| 121 | { "m3u", 3, "audio/x-mpegurl" }, |
| 122 | { "man", 3, "application/x-troff-man" }, |
| 123 | { "me", 2, "application/x-troff-me" }, |
| 124 | { "mesh", 4, "model/mesh" }, |
| 125 | { "mid", 3, "audio/midi" }, |
| 126 | { "midi", 4, "audio/midi" }, |
| 127 | { "mif", 3, "application/vnd.mif" }, |
| 128 | { "mif", 3, "application/x-mif" }, |
| 129 | { "mime", 4, "www/mime" }, |
| 130 | { "movie", 5, "video/x-sgi-movie" }, |
| 131 | { "mov", 3, "video/quicktime" }, |
| 132 | { "mp2", 3, "audio/mpeg" }, |
| 133 | { "mp2", 3, "video/mpeg" }, |
| 134 | { "mp3", 3, "audio/mpeg" }, |
| 135 | { "mpeg", 4, "video/mpeg" }, |
| 136 | { "mpe", 3, "video/mpeg" }, |
| 137 | { "mpga", 4, "audio/mpeg" }, |
| 138 | { "mpg", 3, "video/mpeg" }, |
| 139 | { "ms", 2, "application/x-troff-ms" }, |
| 140 | { "msh", 3, "model/mesh" }, |
| 141 | { "m", 1, "text/plain" }, |
| 142 | { "nc", 2, "application/x-netcdf" }, |
| 143 | { "oda", 3, "application/oda" }, |
| 144 | { "ogg", 3, "application/ogg" }, |
| 145 | { "ogm", 3, "application/ogg" }, |
| 146 | { "pbm", 3, "image/x-portable-bitmap" }, |
| 147 | { "pdb", 3, "chemical/x-pdb" }, |
| 148 | { "pdf", 3, "application/pdf" }, |
| 149 | { "pgm", 3, "image/x-portable-graymap" }, |
| 150 | { "pgn", 3, "application/x-chess-pgn" }, |
| 151 | { "pgp", 3, "application/pgp" }, |
| 152 | { "pl", 2, "application/x-perl" }, |
| 153 | { "pm", 2, "application/x-perl" }, |
| 154 | { "png", 3, "image/png" }, |
| 155 | { "pnm", 3, "image/x-portable-anymap" }, |
| 156 | { "pot", 3, "application/mspowerpoint" }, |
| 157 | { "ppm", 3, "image/x-portable-pixmap" }, |
| 158 | { "pps", 3, "application/mspowerpoint" }, |
| 159 | { "ppt", 3, "application/mspowerpoint" }, |
| 160 | { "ppz", 3, "application/mspowerpoint" }, |
| 161 | { "pre", 3, "application/x-freelance" }, |
| 162 | { "prt", 3, "application/pro_eng" }, |
| 163 | { "ps", 2, "application/postscript" }, |
| 164 | { "qt", 2, "video/quicktime" }, |
| 165 | { "ra", 2, "audio/x-realaudio" }, |
| 166 | { "ram", 3, "audio/x-pn-realaudio" }, |
| 167 | { "rar", 3, "application/x-rar-compressed" }, |
| 168 | { "ras", 3, "image/cmu-raster" }, |
| 169 | { "ras", 3, "image/x-cmu-raster" }, |
| 170 | { "rgb", 3, "image/x-rgb" }, |
| 171 | { "rm", 2, "audio/x-pn-realaudio" }, |
| 172 | { "roff", 4, "application/x-troff" }, |
| 173 | { "rpm", 3, "audio/x-pn-realaudio-plugin" }, |
| 174 | { "rtf", 3, "application/rtf" }, |
| 175 | { "rtf", 3, "text/rtf" }, |
| 176 | { "rtx", 3, "text/richtext" }, |
| 177 | { "scm", 3, "application/x-lotusscreencam" }, |
| 178 | { "set", 3, "application/set" }, |
| 179 | { "sgml", 4, "text/sgml" }, |
| 180 | { "sgm", 3, "text/sgml" }, |
| 181 | { "sh", 2, "application/x-sh" }, |
| 182 | { "shar", 4, "application/x-shar" }, |
| 183 | { "silo", 4, "model/mesh" }, |
| 184 | { "sit", 3, "application/x-stuffit" }, |
| 185 | { "skd", 3, "application/x-koan" }, |
| 186 | { "skm", 3, "application/x-koan" }, |
| 187 | { "skp", 3, "application/x-koan" }, |
| 188 | { "skt", 3, "application/x-koan" }, |
| 189 | { "smi", 3, "application/smil" }, |
| 190 | { "smil", 4, "application/smil" }, |
| 191 | { "snd", 3, "audio/basic" }, |
| 192 | { "sol", 3, "application/solids" }, |
| 193 | { "spl", 3, "application/x-futuresplash" }, |
| 194 | { "src", 3, "application/x-wais-source" }, |
| 195 | { "step", 4, "application/STEP" }, |
| 196 | { "stl", 3, "application/SLA" }, |
| 197 | { "stp", 3, "application/STEP" }, |
| 198 | { "sv4cpio", 7, "application/x-sv4cpio" }, |
| 199 | { "sv4crc", 6, "application/x-sv4crc" }, |
| 200 | { "swf", 3, "application/x-shockwave-flash" }, |
| 201 | { "t", 1, "application/x-troff" }, |
| 202 | { "tar", 3, "application/x-tar" }, |
| 203 | { "tcl", 3, "application/x-tcl" }, |
| 204 | { "tex", 3, "application/x-tex" }, |
| 205 | { "texi", 4, "application/x-texinfo" }, |
| 206 | { "texinfo", 7, "application/x-texinfo" }, |
| 207 | { "tgz", 3, "application/x-tar-gz" }, |
| 208 | { "tiff", 4, "image/tiff" }, |
| 209 | { "tif", 3, "image/tiff" }, |
| 210 | { "tif", 3, "image/tiff" }, |
| 211 | { "tr", 2, "application/x-troff" }, |
| 212 | { "tsi", 3, "audio/TSP-audio" }, |
| 213 | { "tsp", 3, "application/dsptype" }, |
| 214 | { "tsv", 3, "text/tab-separated-values" }, |
| 215 | { "txt", 3, "text/plain" }, |
| 216 | { "unv", 3, "application/i-deas" }, |
| 217 | { "ustar", 5, "application/x-ustar" }, |
| 218 | { "vcd", 3, "application/x-cdlink" }, |
| 219 | { "vda", 3, "application/vda" }, |
| 220 | { "vivo", 4, "video/vnd.vivo" }, |
| 221 | { "viv", 3, "video/vnd.vivo" }, |
| 222 | { "vrml", 4, "model/vrml" }, |
| 223 | { "wav", 3, "audio/x-wav" }, |
| 224 | { "wax", 3, "audio/x-ms-wax" }, |
| 225 | { "wiki", 4, "application/x-fossil-wiki" }, |
| 226 | { "wma", 3, "audio/x-ms-wma" }, |
| 227 | { "wmv", 3, "video/x-ms-wmv" }, |
| 228 | { "wmx", 3, "video/x-ms-wmx" }, |
| 229 | { "wrl", 3, "model/vrml" }, |
| 230 | { "wvx", 3, "video/x-ms-wvx" }, |
| 231 | { "xbm", 3, "image/x-xbitmap" }, |
| 232 | { "xlc", 3, "application/vnd.ms-excel" }, |
| 233 | { "xll", 3, "application/vnd.ms-excel" }, |
| 234 | { "xlm", 3, "application/vnd.ms-excel" }, |
| 235 | { "xls", 3, "application/vnd.ms-excel" }, |
| 236 | { "xlw", 3, "application/vnd.ms-excel" }, |
| 237 | { "xml", 3, "text/xml" }, |
| 238 | { "xpm", 3, "image/x-xpixmap" }, |
| 239 | { "xwd", 3, "image/x-xwindowdump" }, |
| 240 | { "xyz", 3, "chemical/x-pdb" }, |
| 241 | { "zip", 3, "application/zip" }, |
| 242 | }; |
| 243 | |
| 244 | z = zName; |
| 245 | for(i=0; zName[i]; i++){ |
| 246 | if( zName[i]=='.' ) z = &zName[i+1]; |
| 247 | } |
| 248 | len = strlen(z); |
| 249 | if( len<sizeof(zSuffix)-1 ){ |
| 250 | strcpy(zSuffix, z); |
| 251 | for(i=0; zSuffix[i]; i++) zSuffix[i] = tolower(zSuffix[i]); |
| 252 | first = 0; |
| 253 | last = sizeof(aMime)/sizeof(aMime[0]); |
| 254 | while( first<=last ){ |
| 255 | int c; |
| 256 | i = (first+last)/2; |
| 257 | c = strcmp(zSuffix, aMime[i].zSuffix); |
| 258 | if( c==0 ) return aMime[i].zMimetype; |
| 259 | if( c<0 ){ |
| 260 | last = i-1; |
| 261 | }else{ |
| 262 | first = i+1; |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | return "application/x-fossil-artifact"; |
| 267 | } |
| 268 |