mod_mime_magic.xml revision 6aada32e978e09cc60d52cb05ae4cee91b676da1
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy<?xml-stylesheet type="text/xsl" href="/style/manual.xsl"?>
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy<modulesynopsis>
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy<description>Determines the MIME type of a file
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy by looking at a few bytes of its contents</description>
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy <p>This module determines the MIME type of files in the same
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy way the Unix file(1) command works: it looks at the first few
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy bytes of the file. It is intended as a "second line of defense"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy for cases that <module>mod_mime</module> can't
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy resolve. To assure that mod_mime gets first try at determining
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy a file's MIME type, be sure to list mod_mime_magic
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy <strong>before</strong> mod_mime in the configuration.</p>
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy <p>This module is derived from a free version of the
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy <code>file(1)</code> command for Unix, which uses "magic
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy numbers" and other hints from a file's contents to figure out
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy what the contents are. This module is active only if the magic
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy file is specified by the <directive module="mod_mime_magic"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy<section><title>Format of the Magic File</title>
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy <p>The contents of the file are plain ASCII text in 4-5
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy columns. Blank lines are allowed but ignored. Commented lines
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy use a hash mark "#". The remaining lines are parsed for the
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy following columns:</p>
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy <td>byte number to begin checking from<br />
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy ">" indicates a dependency upon the previous non-">"
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy type of data to match
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy <td>long integer date (seconds since Unix
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy <td>little-endian 32-bit integer date</td>
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy <td>MIME encoding if matched (optional)</td>
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy <p>For example, the following magic file lines would recognize
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy some audio formats.</p>
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy <p>Or these would recognize the difference between "*.doc" files
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy containing Microsoft Word or FrameMaker documents. (These are
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy incompatible file formats which use the same file suffix.)</p>
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy0 string \<MakerFile application/x-frame
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy0 string \<MakerDictionary application/x-frame
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy0 string \<MakerScreenFon application/x-frame
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy0 string \320\317\021\340\241\261 application/msword
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy0 string \333\245-\0\0\0 application/msword
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy <p>An optional MIME encoding can be included as a fifth column.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy For example, this can recognize gzipped files and set the
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy encoding for them.</p>
file name allows ...even if just to reduce the "why doesn't my
* originally posted to comp.sources.unix. Copyright info for that program