10139N/A<!
DOCTYPE REFENTRY PUBLIC "-//Sun Microsystems//DTD DocBook V3.0-Based SolBook Subset V2.0//EN" [
10139N/A<!--ArborText, Inc., 1988-1999, v.4002-->
10139N/A<!
ENTITY cmd "gnome-vfs-mime-magic">
13061N/A<!
ENTITY suncopy "Copyright (c) 2003,2008 Sun Microsystems, Inc. All Rights Reserved.">
10139N/A<?
Pub EntList brvbar bull cross dash diam diams frac12 frac13 frac14 hellip 10139N/A laquo lArr loz mdash nabla ndash para pound rArr raquo sect yen bsol>
10139N/A<
refentry id="gnome-vfs-mime-magic-4">
10139N/A<
refmeta><
refentrytitle>gnome-vfs-mime-magic.4</
refentrytitle><
manvolnum>4</
manvolnum>
13061N/A<
refmiscinfo class="date">14 May 2008</
refmiscinfo>
10139N/A<
refmiscinfo class="sectdesc">&man4;</
refmiscinfo>
10139N/A<
refmiscinfo class="software">&release;</
refmiscinfo>
10139N/A<
refmiscinfo class="arch">generic</
refmiscinfo>
10139N/A<
refmiscinfo class="copyright">&suncopy;</
refmiscinfo>
10139N/A<
indexterm><
primary>gnome-vfs-mime-magic</
primary></
indexterm><
indexterm>
10139N/A<
primary>gnome-mime-info</
primary></
indexterm><
indexterm><
primary>gnome-mime-keys
10139N/A</
primary></
indexterm><
indexterm><
primary>GNOME VFS MIME detection</
primary>
10139N/A</
indexterm><
refnamediv id="gnome-vfs-mime-magic-4-name"><
refname>gnome-vfs-mime-magic</
refname>
10139N/AGNOME VFS MIME detection</
refpurpose></
refnamediv>
10139N/A<
refsect1 id="gnome-vfs-mime-magic-4-desc"><
title>&desc-tt;</
title>
13061N/AGnomeVFS is obsolete. Refer to the GNOME Desktop System Administration
13061N/AGuide for information about how to register MIME type information with
13061N/Athe GNOME desktop. The GNOME Desktop System Administration Guide can
13061N/A<
citerefentry><
refentrytitle>yelp</
refentrytitle><
manvolnum>1</
manvolnum></
citerefentry>.
10139N/A<
para>On any modern desktop system, each document type or file type must be
10139N/Agiven a unique identification name and icon. In GNOME, this information is
10139N/Aused extensively by the file manager, <
citerefentry><
refentrytitle>nautilus
10139N/A</
refentrytitle><
manvolnum>1</
manvolnum></
citerefentry>. The primary underlying
10139N/Amechanism for providing such definitions is achieved via <
command>&cmd;</
command>. <
command>&cmd;</
command>
10139N/Acontains the default file content sniffers for identifying MIME types. The
10139N/Aconcept of MIME magic is similar to that of Solaris <
citerefentry><
refentrytitle>
10139N/Amagic</
refentrytitle><
manvolnum>4</
manvolnum></
citerefentry>.</
para>
10139N/A<
refsect1 id="gnome-vfs-mime-magic-4-exde"><
title>&exde-tt;</
title>
10139N/A<
refsect2 id="gnome-vfs-mime-magic-4-exde-cmd"><
title>&cmd;</
title>
10139N/Afile describes a MIME type. The format of each line is as follows:<
screen><
computeroutput><
replaceable>
10139N/Aoffset_start</
replaceable>[:<
replaceable>offset_end</
replaceable>] <
replaceable>
10139N/Apattern_type</
replaceable> <
replaceable>pattern</
replaceable> [&<
replaceable>
10139N/Apattern_mask</
replaceable>] <
replaceable>mime-type</
replaceable></
computeroutput></
screen></
para>
10139N/A<
para>Each line contains the following fields:</
para>
10139N/A<
variablelist><
varlistentry><
term><
replaceable>offset_start</
replaceable></
term>
10139N/A<
listitem><
para>Decimal number that, with <
replaceable>offset_end</
replaceable>,
10139N/Aspecifies the bytes offset within the file.</
para>
10139N/A<
varlistentry><
term><
replaceable>offset_end</
replaceable></
term><
listitem>
10139N/A<
para>Decimal number that, with <
replaceable>offset_start</
replaceable>, specifies
10139N/Athe bytes offset within the file.</
para>
10139N/A<
varlistentry><
term><
replaceable>pattern_type</
replaceable></
term><
listitem>
10139N/A<
para>Can be one of the following types:</
para>
10139N/A<
para><
literal>byte | short | long | string | date | beshort | belong | bedate
10139N/A| leshort | lelong | ledate</
literal></
para>
10139N/A<
para>where <
literal>be</
literal> stands for Big Endian and <
literal>le</
literal>
10139N/Astands for Little Endian.</
para>
10139N/A<
varlistentry><
term><
replaceable>pattern</
replaceable></
term><
listitem><
para>
10139N/AAn ASCII string with non-printable characters escaped as hex or octal escape
10139N/Asequences, and spaces and other important whitespace escaped with a backslash
10139N/A<
varlistentry><
term><
replaceable>pattern_mask</
replaceable></
term><
listitem>
10139N/A<
para>A string of hex digits. The mask must be the same specification as the
10139N/A<
varlistentry><
term><
replaceable>mime-type</
replaceable></
term><
listitem>
10139N/A</
variablelist><
para>The magic patterns are matched sequentially from the
11925N/Afirst entry to the last entry of the list. Therefore, you should put the non-ambiguous
10139N/Apatterns at the start of the list. Any pattern that requires a deep seek into
10139N/Athe file should be placed at the end of the list to reduce performance overhead.
10139N/AWhen designing new document formats, include an easily recognizable unique
10139N/Amagic pattern near the start of the file. A good pattern is is at least four
10139N/Abytes long and contains one or two non-printable characters so that text files
10139N/A<
para>Apart from file sniffing, GNOME also provide a secondary mechanism to
10139N/Adetermine MIME types. If a file has been sniffed and its type does not match
10139N/A</
filename> and processes these. The format of these files is different to
10139N/Athat of pattern magic. Instead of determining the MIME type by reading the
10139N/Acontent of the file, the MIME type of the file is determined by its extension.
10139N/AThe mime info file has the following format: <
screen><
computeroutput><
replaceable>
10139N/A ext[,<
replaceable>prio</
replaceable>]: <
replaceable>list of extensions for this mime-type
10139N/A regex[,<
replaceable>prio</
replaceable>]: <
replaceable>regular expression that matches the filename
10139N/A</
replaceable></
computeroutput></
screen></
para>
10139N/A<
para>More than one <
literal>ext:</
literal> and <
literal>regex:</
literal>
10139N/Afield can be present for a given MIME type. You can also associate a priority
10139N/Afor each field. The default priority (<
replaceable>prio</
replaceable>) is
10139N/A1, a higher numerical value indicates a higher priority. The indentation before <
literal>
10139N/Aext:</
literal> and <
literal>regex:</
literal> must be a tab character (<
literal>
10139N/A<
para>The searching sequence implies that the magic pattern file has a higher
10139N/Aprecedence over the mime info files. As the mime info files are read alphabetically,
10139N/Athis also determines matching orders for the file extension. </
para>
10139N/A ext: foo</
computeroutput></
screen></
para>
10139N/A ext: foo</
computeroutput></
screen></
para>
10139N/A<
para>For each MIME info file there must be an associated keys file in the
10139N/Asame directory. The key file provides human readable text which can be localized
10139N/Ainto various languages. The data in these keys files is used by the GNOME
10139N/Afile manager, <
citerefentry><
refentrytitle>nautilus</
refentrytitle><
manvolnum>
10139N/A1</
manvolnum></
citerefentry>.</
para>
10139N/A<
refsect1 id="gnome-vfs-mime-magic-4-exam"><
title>&exam-tt;</
title>
10139N/A<
example role="example"><
title>Magic pattern definition for PDF file</
title>
10139N/A</
filename> file describes the MIME type of <
literal>
application/
pdf</
literal>:<
screen><
computeroutput>
10139N/A<
para>The first 5 characters of a PDF file are <
literal>%PDF-</
literal>. The
10139N/Asymbols % and - differentiate the PDF file from a text file.</
para>
10139N/A<
example role="example"><
title>Magic pattern definition for BMP file</
title>
10139N/A</
filename> file describes the MIME type of <
literal>
application/
bmp</
literal>:<
screen><
computeroutput>
10139N/A0 string BMxxxx\000\000 &0xffff00000000ffff
image/
bmp</
computeroutput>
10139N/A<
para>The interpretation of this line is as follows: <
itemizedlist>
10139N/A<
listitem><
para>The first two characters are <
literal>BM</
literal> and the
10139N/Aseventh and eighth characters are NULL.</
para></
listitem>
10139N/A<
listitem><
para>The mask <
literal>0xffff00000000ffff</
literal> allows the
10139N/Aselction of the first, second, seventh, and eighth characters to be selected
10139N/Afor comparison.</
para></
listitem>
10139N/A ext: Z</
computeroutput> </
screen></
para>
10139N/A<
para>This line indicates that the <
literal>x-compress</
literal> application
10139N/Asearches for files with a <
literal>.Z</
literal> extension.</
para>
10139N/A</
filename> file is as follows (excluding all localized text): <
screen><
computeroutput>
10139N/A description=compress-compressed file
10139N/A default_action_type=application
10139N/A use_category_default=yes</
computeroutput></
screen></
para>
10139N/A ext: tgz</
computeroutput> </
screen></
para>
10139N/A<
para>This example uses the priority flag to give <
literal>regex</
literal>
10139N/Aa higher priority than <
literal>ext</
literal>, which means that a file with
10139N/Aan extension of <
literal>
tar.gz</
literal> should be matched first (to have
10139N/A<
refsect1 id="gnome-vfs-mime-magic-4-file"><
title>&file-tt;</
title>
10139N/A<
para>The following files are used by this application:</
para>
10139N/A<
variablelist termlength="medium"><
varlistentry><
term><
filename>/
etc/
gnome/&cmd;</
filename>
10139N/A</
filename> </
term><
listitem><
para></
para>
10139N/A</
filename> </
term><
listitem><
para></
para>
10139N/A<
refsect1 id="gnome-vfs-mime-magic-4-attr"><
title>&attr-tt;</
title>
10139N/A<
para>See <
olink targetdocent="REFMAN5" localinfo="attributes-5"><
citerefentry>
10139N/A<
refentrytitle>attributes</
refentrytitle><
manvolnum>5</
manvolnum></
citerefentry></
olink>
10139N/Afor descriptions of the following attributes:</
para>
10139N/A<
tgroup cols="2" colsep="1" rowsep="1"><
colspec colname="COLSPEC0" colwidth="1*">
10139N/A<
colspec colname="COLSPEC1" colwidth="1*">
10139N/A<
row><
entry align="center" valign="middle">ATTRIBUTE TYPE</
entry><
entry align="center" 10139N/Avalign="middle">ATTRIBUTE VALUE</
entry></
row>
10139N/A<
row><
entry colname="COLSPEC0"><
para>Interface stability</
para></
entry><
entry 13061N/Acolname="COLSPEC1"><
para>Obsolete Volatile</
para></
entry></
row>
10139N/A<
refsect1 id="gnome-vfs-mime-magic-4-also"><
title>&also-tt;</
title>
10139N/A<!--Reference to another man page--> 10139N/A<!--Reference to a Help manual--> 11925N/A<
citerefentry><
refentrytitle>nautilus</
refentrytitle><
manvolnum>1</
manvolnum></
citerefentry>,
11925N/A<
citerefentry><
refentrytitle>libgnomevfs-2</
refentrytitle><
manvolnum>3</
manvolnum></
citerefentry>,
11925N/A<
citerefentry><
refentrytitle>gnome-interfaces</
refentrytitle><
manvolnum>5</
manvolnum></
citerefentry>
13061N/A<
citetitle>GNOME Desktop System Administration Guide</
citetitle>
10139N/A<
refsect1 id="gnome-vfs-mime-magic-4-note"><
title></
title>
11933N/A<
para>Written by Ghee Teo, Sun Microsystems Inc., 2003.</
para>