1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr"><head><!--
4        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5              This file is generated from xml source: DO NOT EDIT
6        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7      -->
8<title>mod_mime_magic - Serveur Apache HTTP</title>
9<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
10<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
11<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" />
12<script src="/style/scripts/prettify.min.js" type="text/javascript">
13</script>
14
15<link href="/images/favicon.ico" rel="shortcut icon" /></head>
16<body>
17<div id="page-header">
18<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossaire</a> | <a href="/sitemap.html">Plan du site</a></p>
19<p class="apache">Serveur Apache HTTP Version 2.4</p>
20<img alt="" src="/images/feather.gif" /></div>
21<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
22<div id="path">
23<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">Serveur HTTP</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.4</a> &gt; <a href="./">Modules</a></div>
24<div id="page-content">
25<div id="preamble"><h1>Module Apache mod_mime_magic</h1>
26<div class="toplang">
27<p><span>Langues Disponibles: </span><a href="/en/mod/mod_mime_magic.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
28<a href="/fr/mod/mod_mime_magic.html" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
29</div>
30<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>D�termine le type MIME d'un fichier � partir de quelques
31octets de son contenu</td></tr>
32<tr><th><a href="module-dict.html#Status">Statut:</a></th><td>Extension</td></tr>
33<tr><th><a href="module-dict.html#ModuleIdentifier">Identificateur�de�Module:</a></th><td>mime_magic_module</td></tr>
34<tr><th><a href="module-dict.html#SourceFile">Fichier�Source:</a></th><td>mod_mime_magic.c</td></tr></table>
35<h3>Sommaire</h3>
36
37    <p>Ce module permet de d�terminer le <a class="glossarylink" href="/glossary.html#mime-type" title="voir glossaire">type
38    MIME</a> des fichiers de la m�me mani�re que la commande Unix
39    <code>file(1)</code>, � savoir en se basant sur les premiers octets
40    du fichier. Il est con�u comme une "seconde ligne de d�fense" pour
41    les cas o� <code class="module"><a href="/mod/mod_mime.html">mod_mime</a></code> ne parvient pas � d�terminer le
42    type du fichier.</p>
43
44    <p>Ce module est d�riv� d'une version libre de la commande Unix
45    <code>file(1)</code> qui utilise des "nombres magiques" et autres
46    marques distinctives issus du contenu du fichier pour essayer de
47    d�terminer le type de contenu. Ce module n'est activ� que si le
48    fichier magique est sp�cifi� par la directive <code class="directive"><a href="#mimemagicfile">MimeMagicFile</a></code>.</p>
49</div>
50<div id="quickview"><h3 class="directives">Directives</h3>
51<ul id="toc">
52<li><img alt="" src="/images/down.gif" /> <a href="#mimemagicfile">MimeMagicFile</a></li>
53</ul>
54<h3>Sujets</h3>
55<ul id="topics">
56<li><img alt="" src="/images/down.gif" /> <a href="#format">Format du fichier magique</a></li>
57<li><img alt="" src="/images/down.gif" /> <a href="#performance">Probl�mes li�s aux performances</a></li>
58<li><img alt="" src="/images/down.gif" /> <a href="#notes">Notes</a></li>
59</ul><ul class="seealso"><li><a href="#comments_section">Commentaires</a></li></ul></div>
60<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
61<div class="section">
62<h2><a name="format" id="format">Format du fichier magique</a></h2>
63
64    <p>Le fichier contient du texte ASCII sur 4 � 5 colonnes. Les lignes
65    vides sont autoris�es mais ignor�es. Toute ligne commen�ant par un
66    di�se (<code>#</code>) est un commentaire. Les autres lignes sont
67    interpr�t�es en colonnes comme suit :</p>
68
69    <table class="bordered"><tr class="header"><th>Colonne</th><th>Description</th></tr>
70<tr><td>1</td>
71        <td>num�ro de l'octet � partir duquel la v�rification d�bute<br />
72         "<code>&gt;</code>" indique une d�pendance par rapport � la
73	 derni�re ligne non-"<code>&gt;</code>"</td></tr>
74<tr class="odd"><td>2</td>
75        <td><p>type de donn�e � rechercher</p>
76        <table class="bordered">
77        
78        <tr><td><code>byte</code></td>
79            <td>caract�re unique</td></tr>
80        <tr><td><code>short</code></td>
81            <td>entier sur 16 bits selon l'ordre de la machine</td></tr>
82        <tr><td><code>long</code></td>
83            <td>entier sur 32 bits selon l'ordre de la machine</td></tr>
84        <tr><td><code>string</code></td>
85            <td>cha�ne de taille choisie</td></tr>
86        <tr><td><code>date</code></td>
87            <td>date au format entier long (secondes depuis le temps Unix epoch/1970)</td></tr>
88        <tr><td><code>beshort</code></td>
89            <td>entier 16 bits big-endian</td></tr>
90        <tr><td><code>belong</code></td>
91            <td>entier 32 bits big-endian</td></tr>
92        <tr><td><code>bedate</code></td>
93            <td>date au format entier 32 bits big-endian</td></tr>
94        <tr><td><code>leshort</code></td>
95            <td>entier 16 bits little-endian</td></tr>
96        <tr><td><code>lelong</code></td>
97            <td>entier 32 bits little-endian</td></tr>
98        <tr><td><code>ledate</code></td>
99            <td>date au format entier 32 bits little-endian</td></tr>
100        </table></td></tr>
101<tr><td>3</td>
102        <td>contenu des donn�es � rechercher</td></tr>
103<tr class="odd"><td>4</td>
104        <td>type MIME si correspondance</td></tr>
105<tr><td>5</td>
106        <td>codage MIME si correspondance (optionnel)</td></tr>
107</table>
108
109    <p>Par exemple, les lignes du fichier magique suivantes
110    permettraient de reconna�tre certains formats audio :</p>
111
112    <div class="example"><pre># Sun/NeXT audio data
1130      string      .snd
114&gt;12    belong      1       audio/basic
115&gt;12    belong      2       audio/basic
116&gt;12    belong      3       audio/basic
117&gt;12    belong      4       audio/basic
118&gt;12    belong      5       audio/basic
119&gt;12    belong      6       audio/basic
120&gt;12    belong      7       audio/basic
121&gt;12    belong     23       audio/x-adpcm</pre></div>
122
123    <p>Et celles-ci permettraient de reconna�tre la diff�rence entre les
124    fichiers <code>*.doc</code> qui contiennent des documents Microsoft
125    Word et les documents FrameMaker (ce sont des formats de fichiers
126    incompatibles qui poss�dent le m�me suffixe).</p>
127
128    <div class="example"><pre># Frame
1290  string  \&lt;MakerFile        application/x-frame
1300  string  \&lt;MIFFile          application/x-frame
1310  string  \&lt;MakerDictionary  application/x-frame
1320  string  \&lt;MakerScreenFon   application/x-frame
1330  string  \&lt;MML              application/x-frame
1340  string  \&lt;Book             application/x-frame
1350  string  \&lt;Maker            application/x-frame
136
137# MS-Word
1380  string  \376\067\0\043            application/msword
1390  string  \320\317\021\340\241\261  application/msword
1400  string  \333\245-\0\0\0           application/msword</pre></div>
141
142    <p>Un champ optionnel codage MIME peut �tre ajout� dans la cinqui�me
143    colonne. Par exemple, cette ligne permet de reconna�tre les fichiers
144    compress�s par gzip et d�finissent le type de codage.</p>
145
146    <div class="example"><pre># gzip (GNU zip, � ne pas confondre avec
147#       l'archiveur zip [Info-ZIP/PKWARE])
148
1490  string  \037\213  application/octet-stream  x-gzip</pre></div>
150</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
151<div class="section">
152<h2><a name="performance" id="performance">Probl�mes li�s aux performances</a></h2>
153    <p>Ce module n'est pas fait pour tous les syst�mes. Si votre syst�me
154    parvient � peine � supporter sa charge, ou si vous testez les
155    performances d'un serveur web, il est d�conseill� d'utiliser ce
156    module car son fonctionnement a un prix en mati�re de ressources
157    consomm�es.</p>
158
159    <p>Des efforts ont cependant �t� fournis pour am�liorer les
160    performances du code original de la commande <code>file(1)</code> en
161    l'adaptant pour fonctionner sur un serveur web � forte charge. Il a
162    �t� con�u pour un serveur sur lequel des milliers d'utilisateurs
163    publient leurs propres documents, ce qui est probablement tr�s
164    courant sur un intranet. Il s'av�re souvent b�n�fique qu'un serveur
165    puisse prendre des d�cisions plus pertinentes � propos du contenu
166    d'un fichier que celles se basant sur le nom du fichier seul, ne
167    serait-ce que pour diminuer le nombre d'appels du type "pourquoi ma
168    page ne s'affiche-t-elle pas ?" survenant lorsque les utilisateurs
169    nomment leurs fichiers incorrectement. Vous devez d�terminer si la
170    charge suppl�mentaire convient � votre environnement.</p>
171</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
172<div class="section">
173<h2><a name="notes" id="notes">Notes</a></h2>
174    <p>Les notes suivantes s'appliquent au module
175    <code class="module"><a href="/mod/mod_mime_magic.html">mod_mime_magic</a></code> et sont incluses ici pour
176    conformit� avec les restrictions de copyright des contributeurs
177    qui requi�rent de les accepter.</p>
178    <p>Note de traduction : ces informations de type l�gal ne sont pas traductibles</p>
179
180    <div class="note">
181      <p>mod_mime_magic: MIME type lookup via file magic numbers<br />
182      Copyright (c) 1996-1997 Cisco Systems, Inc.</p>
183
184      <p>This software was submitted by Cisco Systems to the Apache Group
185      in July 1997. Future revisions and derivatives of this source code
186      must acknowledge Cisco Systems as the original contributor of this
187      module. All other licensing and usage conditions are those of the
188      Apache Group.</p>
189
190      <p>Some of this code is derived from the free version of the file
191      command originally posted to comp.sources.unix. Copyright info for
192      that program is included below as required.</p>
193    </div>
194
195    <div class="note">
196      <p> - Copyright (c) Ian F. Darwin, 1987. Written by Ian F. Darwin.</p>
197
198      <p>This software is not subject to any license of the American
199      Telephone and Telegraph Company or of the Regents of the University
200      of California.</p>
201
202      <p>Permission is granted to anyone to use this software for any
203      purpose on any computer system, and to alter it and redistribute it
204      freely, subject to the following restrictions:</p>
205
206      <ol>
207        <li>The author is not responsible for the consequences of use of
208        this software, no matter how awful, even if they arise from flaws
209        in it.</li>
210
211        <li>The origin of this software must not be misrepresented, either
212        by explicit claim or by omission. Since few users ever read
213        sources, credits must appear in the documentation.</li>
214
215        <li>Altered versions must be plainly marked as such, and must not
216        be misrepresented as being the original software. Since few users
217        ever read sources, credits must appear in the documentation.</li>
218
219        <li>This notice may not be removed or altered.</li>
220      </ol>
221    </div>
222
223    <div class="note">
224      <p>For compliance with Mr Darwin's terms: this has been very
225      significantly modified from the free "file" command.</p>
226
227      <ul>
228        <li>all-in-one file for compilation convenience when moving from
229        one version of Apache to the next.</li>
230
231        <li>Memory allocation is done through the Apache API's pool
232        structure.</li>
233
234        <li>All functions have had necessary Apache API request or server
235        structures passed to them where necessary to call other Apache API
236        routines. (<em>i.e.</em>, usually for logging, files, or memory
237        allocation in itself or a called function.)</li>
238
239        <li>struct magic has been converted from an array to a single-ended
240        linked list because it only grows one record at a time, it's only
241        accessed sequentially, and the Apache API has no equivalent of
242        <code>realloc()</code>.</li>
243
244        <li>Functions have been changed to get their parameters from the
245        server configuration instead of globals.  (It should be reentrant
246        now but has not been tested in a threaded environment.)</li>
247
248        <li>Places where it used to print results to stdout now saves them
249        in a list where they're used to set the MIME type in the Apache
250        request record.</li>
251
252        <li>Command-line flags have been removed since they will never be
253        used here.</li>
254      </ul>
255    </div>
256</div>
257<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
258<div class="directive-section"><h2><a name="MimeMagicFile" id="MimeMagicFile">MimeMagicFile</a> <a name="mimemagicfile" id="mimemagicfile">Directive</a></h2>
259<table class="directive">
260<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Active la d�termination du type MIME en se basant sur le
261contenu du fichier et en utilisant le fichier magique
262sp�cifi�</td></tr>
263<tr><th><a href="directive-dict.html#Syntax">Syntaxe:</a></th><td><code>MimeMagicFile <var>chemin-fichier</var></code></td></tr>
264<tr><th><a href="directive-dict.html#Context">Contexte:</a></th><td>configuration du serveur, serveur virtuel</td></tr>
265<tr><th><a href="directive-dict.html#Status">Statut:</a></th><td>Extension</td></tr>
266<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_mime_magic</td></tr>
267</table>
268    <p>La directive <code class="directive">MimeMagicFile</code> permet
269    d'activer ce module, le fichier par d�faut fourni �tant
270    <code>conf/magic</code>. Les chemins sans slash '/' de d�but sont
271    relatifs au r�pertoire d�fini par la directive <code class="directive"><a href="/mod/core.html#serverroot">ServerRoot</a></code>. Les serveurs virtuels
272    utilisent le m�me fichier que le serveur principal sauf si un
273    fichier sp�cifique a �t� d�fini pour ce serveur virtuel, auquel cas
274    c'est ce dernier fichier qui sera utilis�.</p>
275
276    <div class="example"><h3>Exemple</h3><pre class="prettyprint lang-config">MimeMagicFile conf/magic</pre>
277</div>
278
279</div>
280</div>
281<div class="bottomlang">
282<p><span>Langues Disponibles: </span><a href="/en/mod/mod_mime_magic.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
283<a href="/fr/mod/mod_mime_magic.html" title="Fran�ais">&nbsp;fr&nbsp;</a></p>
284</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Commentaires</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
285<script type="text/javascript"><!--//--><![CDATA[//><!--
286var comments_shortname = 'httpd';
287var comments_identifier = 'http://httpd.apache.org/docs/2.4/mod/mod_mime_magic.html';
288(function(w, d) {
289    if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
290        d.write('<div id="comments_thread"><\/div>');
291        var s = d.createElement('script');
292        s.type = 'text/javascript';
293        s.async = true;
294        s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
295        (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
296    }
297    else { 
298        d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
299    }
300})(window, document);
301//--><!]]></script></div><div id="footer">
302<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autoris� sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
303<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossaire</a> | <a href="/sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
304if (typeof(prettyPrint) !== 'undefined') {
305    prettyPrint();
306}
307//--><!]]></script>
308</body></html>