Fossil SCM

Add the test-mimetype command and use it to verify the correct order of entries in the mimetype table. Fix the errors found.

drh 2011-05-27 12:16 trunk
Commit ea2698e9c7de2222f285034e0c4ceb2f307568eb
1 file changed +40 -10
+40 -10
--- src/doc.c
+++ src/doc.c
@@ -139,14 +139,14 @@
139139
{ "flv", 3, "video/flv" },
140140
{ "gif", 3, "image/gif" },
141141
{ "gl", 2, "video/gl" },
142142
{ "gtar", 4, "application/x-gtar" },
143143
{ "gz", 2, "application/x-gzip" },
144
+ { "h", 1, "text/plain" },
144145
{ "hdf", 3, "application/x-hdf" },
145146
{ "hh", 2, "text/plain" },
146147
{ "hqx", 3, "application/mac-binhex40" },
147
- { "h", 1, "text/plain" },
148148
{ "htm", 3, "text/html" },
149149
{ "html", 4, "text/html" },
150150
{ "ice", 3, "x-conference/x-cooltalk" },
151151
{ "ief", 3, "image/ief" },
152152
{ "iges", 4, "model/iges" },
@@ -153,12 +153,12 @@
153153
{ "igs", 3, "model/iges" },
154154
{ "ips", 3, "application/x-ipscript" },
155155
{ "ipx", 3, "application/x-ipix" },
156156
{ "jad", 3, "text/vnd.sun.j2me.app-descriptor" },
157157
{ "jar", 3, "application/java-archive" },
158
- { "jpeg", 4, "image/jpeg" },
159158
{ "jpe", 3, "image/jpeg" },
159
+ { "jpeg", 4, "image/jpeg" },
160160
{ "jpg", 3, "image/jpeg" },
161161
{ "js", 2, "application/x-javascript" },
162162
{ "kar", 3, "audio/midi" },
163163
{ "latex", 5, "application/x-latex" },
164164
{ "lha", 3, "application/octet-stream" },
@@ -171,19 +171,18 @@
171171
{ "mesh", 4, "model/mesh" },
172172
{ "mid", 3, "audio/midi" },
173173
{ "midi", 4, "audio/midi" },
174174
{ "mif", 3, "application/x-mif" },
175175
{ "mime", 4, "www/mime" },
176
- { "movie", 5, "video/x-sgi-movie" },
177176
{ "mov", 3, "video/quicktime" },
177
+ { "movie", 5, "video/x-sgi-movie" },
178178
{ "mp2", 3, "audio/mpeg" },
179
- { "mp2", 3, "video/mpeg" },
180179
{ "mp3", 3, "audio/mpeg" },
181
- { "mpeg", 4, "video/mpeg" },
182180
{ "mpe", 3, "video/mpeg" },
183
- { "mpga", 4, "audio/mpeg" },
181
+ { "mpeg", 4, "video/mpeg" },
184182
{ "mpg", 3, "video/mpeg" },
183
+ { "mpga", 4, "audio/mpeg" },
185184
{ "ms", 2, "application/x-troff-ms" },
186185
{ "msh", 3, "model/mesh" },
187186
{ "nc", 2, "application/x-netcdf" },
188187
{ "oda", 3, "application/oda" },
189188
{ "ogg", 3, "application/ogg" },
@@ -209,22 +208,20 @@
209208
{ "qt", 2, "video/quicktime" },
210209
{ "ra", 2, "audio/x-realaudio" },
211210
{ "ram", 3, "audio/x-pn-realaudio" },
212211
{ "rar", 3, "application/x-rar-compressed" },
213212
{ "ras", 3, "image/cmu-raster" },
214
- { "ras", 3, "image/x-cmu-raster" },
215213
{ "rgb", 3, "image/x-rgb" },
216214
{ "rm", 2, "audio/x-pn-realaudio" },
217215
{ "roff", 4, "application/x-troff" },
218216
{ "rpm", 3, "audio/x-pn-realaudio-plugin" },
219
- { "rtf", 3, "application/rtf" },
220217
{ "rtf", 3, "text/rtf" },
221218
{ "rtx", 3, "text/richtext" },
222219
{ "scm", 3, "application/x-lotusscreencam" },
223220
{ "set", 3, "application/set" },
224
- { "sgml", 4, "text/sgml" },
225221
{ "sgm", 3, "text/sgml" },
222
+ { "sgml", 4, "text/sgml" },
226223
{ "sh", 2, "application/x-sh" },
227224
{ "shar", 4, "application/x-shar" },
228225
{ "silo", 4, "model/mesh" },
229226
{ "sit", 3, "application/x-stuffit" },
230227
{ "skd", 3, "application/x-koan" },
@@ -249,12 +246,12 @@
249246
{ "tcl", 3, "application/x-tcl" },
250247
{ "tex", 3, "application/x-tex" },
251248
{ "texi", 4, "application/x-texinfo" },
252249
{ "texinfo", 7, "application/x-texinfo" },
253250
{ "tgz", 3, "application/x-tar-gz" },
254
- { "tiff", 4, "image/tiff" },
255251
{ "tif", 3, "image/tiff" },
252
+ { "tiff", 4, "image/tiff" },
256253
{ "tr", 2, "application/x-troff" },
257254
{ "tsi", 3, "audio/TSP-audio" },
258255
{ "tsp", 3, "application/dsptype" },
259256
{ "tsv", 3, "text/tab-separated-values" },
260257
{ "txt", 3, "text/plain" },
@@ -283,10 +280,25 @@
283280
{ "xpm", 3, "image/x-xpixmap" },
284281
{ "xwd", 3, "image/x-xwindowdump" },
285282
{ "xyz", 3, "chemical/x-pdb" },
286283
{ "zip", 3, "application/zip" },
287284
};
285
+
286
+#ifdef FOSSIL_DEBUG
287
+ /* This is test code to make sure the table above is in the correct
288
+ ** order
289
+ */
290
+ if( fossil_strcmp(zName, "mimetype-test")==0 ){
291
+ for(i=1; i<sizeof(aMime)/sizeof(aMime[0]); i++){
292
+ if( fossil_strcmp(aMime[i-1].zSuffix,aMime[i].zSuffix)>=0 ){
293
+ fossil_fatal("mimetypes out of sequence: %s before %s",
294
+ aMime[i-1].zSuffix, aMime[i].zSuffix);
295
+ }
296
+ }
297
+ return "ok";
298
+ }
299
+#endif
288300
289301
z = zName;
290302
for(i=0; zName[i]; i++){
291303
if( zName[i]=='.' ) z = &zName[i+1];
292304
}
@@ -308,10 +320,28 @@
308320
}
309321
}
310322
}
311323
return "application/x-fossil-artifact";
312324
}
325
+
326
+/*
327
+** COMMAND: test-mimetype
328
+**
329
+** Usage: %fossil test-mimetype FILENAME...
330
+**
331
+** Return the deduced mimetype for each file listed.
332
+**
333
+** If Fossil is compiled with -DFOSSIL_DEBUG then the "mimetype-test"
334
+** filename is special and verifies the integrity of the mimetype table.
335
+** It should return "ok".
336
+*/
337
+void mimetype_test_cmd(void){
338
+ int i;
339
+ for(i=2; i<g.argc; i++){
340
+ fossil_print("%-20s -> %s\n", g.argv[i], mimetype_from_name(g.argv[i]));
341
+ }
342
+}
313343
314344
/*
315345
** WEBPAGE: doc
316346
** URL: /doc?name=BASELINE/PATH
317347
** URL: /doc/BASELINE/PATH
318348
--- src/doc.c
+++ src/doc.c
@@ -139,14 +139,14 @@
139 { "flv", 3, "video/flv" },
140 { "gif", 3, "image/gif" },
141 { "gl", 2, "video/gl" },
142 { "gtar", 4, "application/x-gtar" },
143 { "gz", 2, "application/x-gzip" },
 
144 { "hdf", 3, "application/x-hdf" },
145 { "hh", 2, "text/plain" },
146 { "hqx", 3, "application/mac-binhex40" },
147 { "h", 1, "text/plain" },
148 { "htm", 3, "text/html" },
149 { "html", 4, "text/html" },
150 { "ice", 3, "x-conference/x-cooltalk" },
151 { "ief", 3, "image/ief" },
152 { "iges", 4, "model/iges" },
@@ -153,12 +153,12 @@
153 { "igs", 3, "model/iges" },
154 { "ips", 3, "application/x-ipscript" },
155 { "ipx", 3, "application/x-ipix" },
156 { "jad", 3, "text/vnd.sun.j2me.app-descriptor" },
157 { "jar", 3, "application/java-archive" },
158 { "jpeg", 4, "image/jpeg" },
159 { "jpe", 3, "image/jpeg" },
 
160 { "jpg", 3, "image/jpeg" },
161 { "js", 2, "application/x-javascript" },
162 { "kar", 3, "audio/midi" },
163 { "latex", 5, "application/x-latex" },
164 { "lha", 3, "application/octet-stream" },
@@ -171,19 +171,18 @@
171 { "mesh", 4, "model/mesh" },
172 { "mid", 3, "audio/midi" },
173 { "midi", 4, "audio/midi" },
174 { "mif", 3, "application/x-mif" },
175 { "mime", 4, "www/mime" },
176 { "movie", 5, "video/x-sgi-movie" },
177 { "mov", 3, "video/quicktime" },
 
178 { "mp2", 3, "audio/mpeg" },
179 { "mp2", 3, "video/mpeg" },
180 { "mp3", 3, "audio/mpeg" },
181 { "mpeg", 4, "video/mpeg" },
182 { "mpe", 3, "video/mpeg" },
183 { "mpga", 4, "audio/mpeg" },
184 { "mpg", 3, "video/mpeg" },
 
185 { "ms", 2, "application/x-troff-ms" },
186 { "msh", 3, "model/mesh" },
187 { "nc", 2, "application/x-netcdf" },
188 { "oda", 3, "application/oda" },
189 { "ogg", 3, "application/ogg" },
@@ -209,22 +208,20 @@
209 { "qt", 2, "video/quicktime" },
210 { "ra", 2, "audio/x-realaudio" },
211 { "ram", 3, "audio/x-pn-realaudio" },
212 { "rar", 3, "application/x-rar-compressed" },
213 { "ras", 3, "image/cmu-raster" },
214 { "ras", 3, "image/x-cmu-raster" },
215 { "rgb", 3, "image/x-rgb" },
216 { "rm", 2, "audio/x-pn-realaudio" },
217 { "roff", 4, "application/x-troff" },
218 { "rpm", 3, "audio/x-pn-realaudio-plugin" },
219 { "rtf", 3, "application/rtf" },
220 { "rtf", 3, "text/rtf" },
221 { "rtx", 3, "text/richtext" },
222 { "scm", 3, "application/x-lotusscreencam" },
223 { "set", 3, "application/set" },
224 { "sgml", 4, "text/sgml" },
225 { "sgm", 3, "text/sgml" },
 
226 { "sh", 2, "application/x-sh" },
227 { "shar", 4, "application/x-shar" },
228 { "silo", 4, "model/mesh" },
229 { "sit", 3, "application/x-stuffit" },
230 { "skd", 3, "application/x-koan" },
@@ -249,12 +246,12 @@
249 { "tcl", 3, "application/x-tcl" },
250 { "tex", 3, "application/x-tex" },
251 { "texi", 4, "application/x-texinfo" },
252 { "texinfo", 7, "application/x-texinfo" },
253 { "tgz", 3, "application/x-tar-gz" },
254 { "tiff", 4, "image/tiff" },
255 { "tif", 3, "image/tiff" },
 
256 { "tr", 2, "application/x-troff" },
257 { "tsi", 3, "audio/TSP-audio" },
258 { "tsp", 3, "application/dsptype" },
259 { "tsv", 3, "text/tab-separated-values" },
260 { "txt", 3, "text/plain" },
@@ -283,10 +280,25 @@
283 { "xpm", 3, "image/x-xpixmap" },
284 { "xwd", 3, "image/x-xwindowdump" },
285 { "xyz", 3, "chemical/x-pdb" },
286 { "zip", 3, "application/zip" },
287 };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
289 z = zName;
290 for(i=0; zName[i]; i++){
291 if( zName[i]=='.' ) z = &zName[i+1];
292 }
@@ -308,10 +320,28 @@
308 }
309 }
310 }
311 return "application/x-fossil-artifact";
312 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
314 /*
315 ** WEBPAGE: doc
316 ** URL: /doc?name=BASELINE/PATH
317 ** URL: /doc/BASELINE/PATH
318
--- src/doc.c
+++ src/doc.c
@@ -139,14 +139,14 @@
139 { "flv", 3, "video/flv" },
140 { "gif", 3, "image/gif" },
141 { "gl", 2, "video/gl" },
142 { "gtar", 4, "application/x-gtar" },
143 { "gz", 2, "application/x-gzip" },
144 { "h", 1, "text/plain" },
145 { "hdf", 3, "application/x-hdf" },
146 { "hh", 2, "text/plain" },
147 { "hqx", 3, "application/mac-binhex40" },
 
148 { "htm", 3, "text/html" },
149 { "html", 4, "text/html" },
150 { "ice", 3, "x-conference/x-cooltalk" },
151 { "ief", 3, "image/ief" },
152 { "iges", 4, "model/iges" },
@@ -153,12 +153,12 @@
153 { "igs", 3, "model/iges" },
154 { "ips", 3, "application/x-ipscript" },
155 { "ipx", 3, "application/x-ipix" },
156 { "jad", 3, "text/vnd.sun.j2me.app-descriptor" },
157 { "jar", 3, "application/java-archive" },
 
158 { "jpe", 3, "image/jpeg" },
159 { "jpeg", 4, "image/jpeg" },
160 { "jpg", 3, "image/jpeg" },
161 { "js", 2, "application/x-javascript" },
162 { "kar", 3, "audio/midi" },
163 { "latex", 5, "application/x-latex" },
164 { "lha", 3, "application/octet-stream" },
@@ -171,19 +171,18 @@
171 { "mesh", 4, "model/mesh" },
172 { "mid", 3, "audio/midi" },
173 { "midi", 4, "audio/midi" },
174 { "mif", 3, "application/x-mif" },
175 { "mime", 4, "www/mime" },
 
176 { "mov", 3, "video/quicktime" },
177 { "movie", 5, "video/x-sgi-movie" },
178 { "mp2", 3, "audio/mpeg" },
 
179 { "mp3", 3, "audio/mpeg" },
 
180 { "mpe", 3, "video/mpeg" },
181 { "mpeg", 4, "video/mpeg" },
182 { "mpg", 3, "video/mpeg" },
183 { "mpga", 4, "audio/mpeg" },
184 { "ms", 2, "application/x-troff-ms" },
185 { "msh", 3, "model/mesh" },
186 { "nc", 2, "application/x-netcdf" },
187 { "oda", 3, "application/oda" },
188 { "ogg", 3, "application/ogg" },
@@ -209,22 +208,20 @@
208 { "qt", 2, "video/quicktime" },
209 { "ra", 2, "audio/x-realaudio" },
210 { "ram", 3, "audio/x-pn-realaudio" },
211 { "rar", 3, "application/x-rar-compressed" },
212 { "ras", 3, "image/cmu-raster" },
 
213 { "rgb", 3, "image/x-rgb" },
214 { "rm", 2, "audio/x-pn-realaudio" },
215 { "roff", 4, "application/x-troff" },
216 { "rpm", 3, "audio/x-pn-realaudio-plugin" },
 
217 { "rtf", 3, "text/rtf" },
218 { "rtx", 3, "text/richtext" },
219 { "scm", 3, "application/x-lotusscreencam" },
220 { "set", 3, "application/set" },
 
221 { "sgm", 3, "text/sgml" },
222 { "sgml", 4, "text/sgml" },
223 { "sh", 2, "application/x-sh" },
224 { "shar", 4, "application/x-shar" },
225 { "silo", 4, "model/mesh" },
226 { "sit", 3, "application/x-stuffit" },
227 { "skd", 3, "application/x-koan" },
@@ -249,12 +246,12 @@
246 { "tcl", 3, "application/x-tcl" },
247 { "tex", 3, "application/x-tex" },
248 { "texi", 4, "application/x-texinfo" },
249 { "texinfo", 7, "application/x-texinfo" },
250 { "tgz", 3, "application/x-tar-gz" },
 
251 { "tif", 3, "image/tiff" },
252 { "tiff", 4, "image/tiff" },
253 { "tr", 2, "application/x-troff" },
254 { "tsi", 3, "audio/TSP-audio" },
255 { "tsp", 3, "application/dsptype" },
256 { "tsv", 3, "text/tab-separated-values" },
257 { "txt", 3, "text/plain" },
@@ -283,10 +280,25 @@
280 { "xpm", 3, "image/x-xpixmap" },
281 { "xwd", 3, "image/x-xwindowdump" },
282 { "xyz", 3, "chemical/x-pdb" },
283 { "zip", 3, "application/zip" },
284 };
285
286 #ifdef FOSSIL_DEBUG
287 /* This is test code to make sure the table above is in the correct
288 ** order
289 */
290 if( fossil_strcmp(zName, "mimetype-test")==0 ){
291 for(i=1; i<sizeof(aMime)/sizeof(aMime[0]); i++){
292 if( fossil_strcmp(aMime[i-1].zSuffix,aMime[i].zSuffix)>=0 ){
293 fossil_fatal("mimetypes out of sequence: %s before %s",
294 aMime[i-1].zSuffix, aMime[i].zSuffix);
295 }
296 }
297 return "ok";
298 }
299 #endif
300
301 z = zName;
302 for(i=0; zName[i]; i++){
303 if( zName[i]=='.' ) z = &zName[i+1];
304 }
@@ -308,10 +320,28 @@
320 }
321 }
322 }
323 return "application/x-fossil-artifact";
324 }
325
326 /*
327 ** COMMAND: test-mimetype
328 **
329 ** Usage: %fossil test-mimetype FILENAME...
330 **
331 ** Return the deduced mimetype for each file listed.
332 **
333 ** If Fossil is compiled with -DFOSSIL_DEBUG then the "mimetype-test"
334 ** filename is special and verifies the integrity of the mimetype table.
335 ** It should return "ok".
336 */
337 void mimetype_test_cmd(void){
338 int i;
339 for(i=2; i<g.argc; i++){
340 fossil_print("%-20s -> %s\n", g.argv[i], mimetype_from_name(g.argv[i]));
341 }
342 }
343
344 /*
345 ** WEBPAGE: doc
346 ** URL: /doc?name=BASELINE/PATH
347 ** URL: /doc/BASELINE/PATH
348

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button