summaryrefslogtreecommitdiff
path: root/src/mime/def.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/mime/def.cc')
-rw-r--r--src/mime/def.cc149
1 files changed, 149 insertions, 0 deletions
diff --git a/src/mime/def.cc b/src/mime/def.cc
new file mode 100644
index 0000000..0a692cd
--- /dev/null
+++ b/src/mime/def.cc
@@ -0,0 +1,149 @@
1/*************************************************************************
2 *
3 * HTCd - Copyright (C) 1998-2006 Henrik Rydberg
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <mime/mime.h>
21#include <mt/msmap.h>
22
23struct table_t { char ext[16],name[64]; };
24
25static table_t table[]={
26 {"ai","application/postscript"},
27 {"aif","audio/x-aiff"},
28 {"aifc","audio/x-aiff"},
29 {"aiff","audio/x-aiff"},
30 {"au","audio/basic"},
31 {"avi","video/x-msvideo"},
32 {"bcpio","application/x-bcpio"},
33 {"bin","application/octet-stream"},
34 {"cdf","application/x-netcdf"},
35 {"class","application/octet-stream"},
36 {"cpio","application/x-cpio"},
37 {"cpt","application/mac-compactpro"},
38 {"csh","application/x-csh"},
39 {"css","text/css"},
40 {"dcr","application/x-director"},
41 {"dir","application/x-director"},
42 {"dms","application/octet-stream"},
43 {"doc","application/msword"},
44 {"dvi","application/x-dvi"},
45 {"dxr","application/x-director"},
46 {"eps","application/postscript"},
47 {"etx","text/x-setext"},
48 {"exe","application/octet-stream"},
49 {"gif","image/gif"},
50 {"gtar","application/x-gtar"},
51 {"gz","application/x-gzip"},
52 {"hdf","application/x-hdf"},
53 {"hqx","application/mac-binhex40"},
54 {"htc","text/x-htc"},
55 {"hts","text/plain"},
56 {"htx","text/x-htx"},
57 {"htm","text/html"},
58 {"html","text/html"},
59 {"ice","x-conference/x-cooltalk"},
60 {"ief","image/ief"},
61 {"jpe","image/jpeg"},
62 {"jpeg","image/jpeg"},
63 {"jpg","image/jpeg"},
64 {"kar","audio/midi"},
65 {"latex","application/x-latex"},
66 {"lha","application/octet-stream"},
67 {"lzh","application/octet-stream"},
68 {"man","application/x-troff-man"},
69 {"me","application/x-troff-me"},
70 {"mid","audio/midi"},
71 {"midi","audio/midi"},
72 {"mif","application/x-mif"},
73 {"mov","video/quicktime"},
74 {"movie","video/x-sgi-movie"},
75 {"mp2","audio/mpeg"},
76 {"mp3","audio/mpeg"},
77 {"mpe","video/mpeg"},
78 {"mpeg","video/mpeg"},
79 {"mpg","video/mpeg"},
80 {"mpga","audio/mpeg"},
81 {"ms","application/x-troff-ms"},
82 {"nc","application/x-netcdf"},
83 {"oda","application/oda"},
84 {"pbm","image/x-portable-bitmap"},
85 {"pdb","chemical/x-pdb"},
86 {"pdf","application/pdf"},
87 {"pgm","image/x-portable-graymap"},
88 {"png","image/png"},
89 {"pnm","image/x-portable-anymap"},
90 {"ppm","image/x-portable-pixmap"},
91 {"ppt","application/powerpoint"},
92 {"ps","application/postscript"},
93 {"qt","video/quicktime"},
94 {"ra","audio/x-realaudio"},
95 {"ram","audio/x-pn-realaudio"},
96 {"ras","image/x-cmu-raster"},
97 {"rgb","image/x-rgb"},
98 {"roff","application/x-troff"},
99 {"rpm","audio/x-pn-realaudio-plugin"},
100 {"rtf","application/rtf"},
101 {"rtx","text/richtext"},
102 {"sgm","text/x-sgml"},
103 {"sgml","text/x-sgml"},
104 {"sh","application/x-sh"},
105 {"shar","application/x-shar"},
106 {"sit","application/x-stuffit"},
107 {"skd","application/x-koan"},
108 {"skm","application/x-koan"},
109 {"skp","application/x-koan"},
110 {"skt","application/x-koan"},
111 {"snd","audio/basic"},
112 {"src","application/x-wais-source"},
113 {"sv4cpio","application/x-sv4cpio"},
114 {"sv4crc","application/x-sv4crc"},
115 {"t","application/x-troff"},
116 {"tar","application/x-tar"},
117 {"tcl","application/x-tcl"},
118 {"tex","application/x-tex"},
119 {"texi","application/x-texinfo"},
120 {"texinfo","application/x-texinfo"},
121 {"tif","image/tiff"},
122 {"tiff","image/tiff"},
123 {"tr","application/x-troff"},
124 {"tsv","text/tab-separated-values"},
125 {"txt","text/plain"},
126 {"ustar","application/x-ustar"},
127 {"vcd","application/x-cdlink"},
128 {"vrml","x-world/x-vrml"},
129 {"wav","audio/x-wav"},
130 {"wrl","x-world/x-vrml"},
131 {"xbm","image/x-xbitmap"},
132 {"xpm","image/x-xpixmap"},
133 {"xwd","image/x-xwindowdump"},
134 {"xyz","chemical/x-pdb"},
135 {"zip","application/zip"},
136 {"",""}
137};
138
139const sref* file2mime(const sref& file)
140{
141 static rrmap mime;
142 if(mime.empty()) {
143 for(table_t* p=table;*p->ext;p++) mime.add(sref(p->ext),sref(p->name));
144 }
145 mstring path=file.past_last('.');
146 path.tolower();
147 if(path.nempty()) return mime.get(path);
148 return 0;
149}