]> granicus.if.org Git - file/commitdiff
magic merge from rrt@
authorChristos Zoulas <christos@zoulas.com>
Mon, 4 Feb 2008 16:33:44 +0000 (16:33 +0000)
committerChristos Zoulas <christos@zoulas.com>
Mon, 4 Feb 2008 16:33:44 +0000 (16:33 +0000)
45 files changed:
ChangeLog
Makefile.am
magic/Magdir/adventure
magic/Magdir/animation
magic/Magdir/archive
magic/Magdir/audio
magic/Magdir/c-lang
magic/Magdir/cafebabe
magic/Magdir/commands
magic/Magdir/compress
magic/Magdir/database
magic/Magdir/elf
magic/Magdir/filesystems
magic/Magdir/flash
magic/Magdir/fortran
magic/Magdir/frame
magic/Magdir/gnu
magic/Magdir/iff
magic/Magdir/images
magic/Magdir/java
magic/Magdir/jpeg
magic/Magdir/lisp
magic/Magdir/macintosh
magic/Magdir/mail.news
magic/Magdir/misctools
magic/Magdir/msdos
magic/Magdir/pdf
magic/Magdir/perl
magic/Magdir/pgp
magic/Magdir/pkgadd
magic/Magdir/printer
magic/Magdir/riff
magic/Magdir/rpm
magic/Magdir/rtf
magic/Magdir/sc
magic/Magdir/sgml
magic/Magdir/tex
magic/Magdir/vorbis
magic/Magdir/wordprocessors
magic/Makefile.am
magic/magic.mime
src/apprentice.c
src/file.h
src/funcs.c
src/softmagic.c

index ed4575073ccc812dc360dfd764d962cfe4e94ecc..f9cc7bc497699deacab4d72ee9573a7da1d06b77 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-02-04 11:31 Christos Zoulas <christos@zoulas.com>
+
+       * !mine: annotations in magic files (Reuben Thomas)
+
 2007-01-29 15:35 Christos Zoulas <christos@zoulas.com>
 
        * zero out utime/utimes structs (Gavin Atkinson)
index 59dac9bc1d91e7300a5fca31d5b5d58444979a74..b560c1d9f90cadce532b72fc67f3c97818af64f2 100644 (file)
@@ -1,5 +1,5 @@
 # don't enforce GNU packaging standards
-AUTOMAKE_OPTIONS = foreign no-dependencies
+AUTOMAKE_OPTIONS = foreign
 
 EXTRA_DIST = LEGAL.NOTICE MAINT PORTING
 
index 405d3cc41ed71cee9d2fe80e26b83e51512c23db..7b30c496144e4bd2f612a319d9e530150b7aa58e 100644 (file)
 >10    belong   0x0A0D1A00
 >>14   string  >\0             %s saved game data
 
+# Danny Milosavljevic <danny.milo@gmx.net>
+# this are adrift (adventure game standard) game files, extension .taf
+# depending on version magic continues with 0x93453E6139FA (V 4.0)
+# 0x9445376139FA (V 3.90)
+# 0x9445366139FA (V 3.80)
+# this is from source (http://www.adrift.org.uk/) and I have some taf
+# files, and checked them.
+#0     belong  0x3C423FC9
+#>4    belong  0x6A87C2CF      Adrift game file
+#!:mime        application/x-adrift
index 6392f850887e8eb8648481c098a21837d60dce76..b2e687cf756a8e35d1b9cbd25b895970069bb9ea 100644 (file)
@@ -8,37 +8,56 @@
 
 # SGI and Apple formats
 0      string          MOVI            Silicon Graphics movie file
+!:mime video/x-sgi-movie
 4       string          moov            Apple QuickTime
+!:mime video/quicktime
 >12     string          mvhd            \b movie (fast start)
 >12     string          mdra            \b URL
 >12     string          cmov            \b movie (fast start, compressed header)
 >12     string          rmra            \b multiple URLs
 4       string          mdat            Apple QuickTime movie (unoptimized)
+!:mime video/quicktime
 4       string          wide            Apple QuickTime movie (unoptimized)
+!:mime video/quicktime
 4       string          skip            Apple QuickTime movie (modified)
+!:mime video/quicktime
 4       string          free            Apple QuickTime movie (modified)
+!:mime video/quicktime
 4       string          idsc            Apple QuickTime image (fast start)
+!:mime image/x-quicktime
 4       string          idat            Apple QuickTime image (unoptimized)
+!:mime image/x-quicktime
 4       string          pckg            Apple QuickTime compressed archive
+!:mime application/x-quicktime-player
 4      string/B        jP              JPEG 2000 image
+!:mime image/jp2
 4      string          ftyp            ISO Media
 >8     string          isom            \b, MPEG v4 system, version 1
+!:mime video/mp4
 >8     string          iso2            \b, MPEG v4 system, part 12 revision
 >8     string          mp41            \b, MPEG v4 system, version 1
+!:mime video/mp4
 >8     string          mp42            \b, MPEG v4 system, version 2
+!:mime video/mp4
 >8     string          mp7t            \b, MPEG v4 system, MPEG v7 XML
 >8     string          mp7b            \b, MPEG v4 system, MPEG v7 binary XML
 >8     string/B        jp2             \b, JPEG 2000
+!:mime image/jp2
 >8     string          3gp             \b, MPEG v4 system, 3GPP
+!:mime video/3gpp
 >>11   byte            4               \b v4 (H.263/AMR GSM 6.10)
 >>11   byte            5               \b v5 (H.263/AMR GSM 6.10)
 >>11   byte            6               \b v6 (ITU H.264/AMR GSM 6.10)
 >8     string          mmp4            \b, MPEG v4 system, 3GPP Mobile
+!:mime video/mp4
 >8     string          avc1            \b, MPEG v4 system, 3GPP JVT AVC
+!:mime video/3gpp
 >8     string/B        M4A             \b, MPEG v4 system, iTunes AAC-LC
+!:mime video/mp4
 >8     string/B        M4P             \b, MPEG v4 system, iTunes AES encrypted
 >8     string/B        M4B             \b, MPEG v4 system, iTunes bookmarked
 >8     string/B        qt              \b, Apple QuickTime movie
+!:mime video/quicktime
 
 # MPEG sequences
 # Scans for all common MPEG header start codes
 # modified to fully support MPEG ADTS
 
 # MP3, M1A
-0       beshort&0xFFFE  0xFFFA         MPEG ADTS, layer III, v1
+# modified by Joerg Jenderek
+# GRR the original test are too common for many DOS files
+# so don't accept as MP3 until we've tested the rate
+0       beshort&0xFFFE
 # rates
->2      byte&0xF0       0x10           \b,  32 kBits
->2      byte&0xF0       0x20           \b,  40 kBits
->2      byte&0xF0       0x30           \b,  48 kBits
->2      byte&0xF0       0x40           \b,  56 kBits
->2      byte&0xF0       0x50           \b,  64 kBits
->2      byte&0xF0       0x60           \b,  80 kBits
->2      byte&0xF0       0x70           \b,  96 kBits
->2      byte&0xF0       0x80           \b, 112 kBits
->2      byte&0xF0       0x90           \b, 128 kBits
->2      byte&0xF0       0xA0           \b, 160 kBits
->2      byte&0xF0       0xB0           \b, 192 kBits
->2      byte&0xF0       0xC0           \b, 224 kBits
->2      byte&0xF0       0xD0           \b, 256 kBits
->2      byte&0xF0       0xE0           \b, 320 kBits
+>2      byte&0xF0       0x10           MPEG ADTS, layer III, v1,  32 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0x20           MPEG ADTS, layer III, v1,  40 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0x30           MPEG ADTS, layer III, v1,  48 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0x40           MPEG ADTS, layer III, v1,  56 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0x50           MPEG ADTS, layer III, v1,  64 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0x60           MPEG ADTS, layer III, v1,  80 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0x70           MPEG ADTS, layer III, v1,  96 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0x80           MPEG ADTS, layer III, v1, 112 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0x90           MPEG ADTS, layer III, v1, 128 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0xA0           MPEG ADTS, layer III, v1, 160 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0xB0           MPEG ADTS, layer III, v1, 192 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0xC0           MPEG ADTS, layer III, v1, 224 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0xD0           MPEG ADTS, layer III, v1, 256 kBits
+!:mime audio/mpeg
+>2      byte&0xF0       0xE0           MPEG ADTS, layer III, v1, 320 kBits
+!:mime audio/mpeg
 # timing
 >2      byte&0x0C       0x00           \b, 44.1 kHz
 >2      byte&0x0C       0x04           \b, 48 kHz
 
 # Stored AAC streams (instead of the MP4 format)
 0       string          ADIF           MPEG ADIF, AAC
+!:mime audio/x-hx-aac-adif
 >4      byte            &0x80
 >>13    byte            &0x10          \b, VBR
 >>13    byte            ^0x10          \b, CBR
 
 # Live or stored single AAC stream (used with MPEG-2 systems)
 0       beshort&0xFFF6  0xFFF0         MPEG ADTS, AAC
+!:mime audio/x-hx-aac-adts
 >1      byte            &0x08          \b, v2
 >1      byte            ^0x08          \b, v4
 # profile
 
 # Live MPEG-4 audio streams (instead of RTP FlexMux)
 0       beshort&0xFFE0  0x56E0         MPEG-4 LOAS
+!:mime audio/x-mp4a-latm
 #>1     beshort&0x1FFF  x              \b, %u byte packet
 >3      byte&0xE0       0x40
 >>4     byte&0x3C       0x04           \b, single stream
 >>4     byte            &0x20          \b, 4 or more streams
 >>4     byte            &0x40          \b, 8 or more streams
 0       beshort         0x4DE1         MPEG-4 LO-EP audio stream
+!:mime audio/x-mp4a-latm
 
 # FLI animation format
 4      leshort         0xAF11                  FLI file
+!:mime video/x-fli
 >6     leshort         x                       - %d frames,
 >8     leshort         x                       width=%d pixels,
 >10    leshort         x                       height=%d pixels,
 >16    leshort         x                       ticks/frame=%d
 # FLC animation format
 4      leshort         0xAF12                  FLC file
+!:mime video/x-flc
 >6     leshort         x                       - %d frames
 >8     leshort         x                       width=%d pixels,
 >10    leshort         x                       height=%d pixels,
 # 255 (hex FF)!  The DL format is really bad.
 #
 #0     byte    1       DL version 1, medium format (160x100, 4 images/screen)
+#!:mime        video/x-unknown
 #>42   byte    x       - %d screens,
 #>43   byte    x       %d commands
 #0     byte    2       DL version 2
+#!:mime        video/x-unknown
 #>1    byte    1       - large format (320x200,1 image/screen),
 #>1    byte    2       - medium format (160x100,4 images/screen),
 #>1    byte    >2      - unknown format,
 
 # MNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
 0      string                  \x8aMNG         MNG video data,
+!:mime video/x-mng
 >4     belong                  !0x0d0a1a0a     CORRUPTED,
 >4     belong                  0x0d0a1a0a
 >>16    belong x                               %ld x
 
 # JNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
 0      string                  \x8bJNG         JNG video data,
+!:mime video/x-jng
 >4     belong                  !0x0d0a1a0a     CORRUPTED,
 >4     belong                  0x0d0a1a0a
 >>16    belong x                               %ld x
 
 # VRML (Virtual Reality Modelling Language)
 0       string/b        #VRML\ V1.0\ ascii     VRML 1 file
+!:mime model/vrml
 0      string/b        #VRML\ V2.0\ utf8       ISO/IEC 14772 VRML 97 file
+!:mime model/vrml
 
 #---------------------------------------------------------------------------
 # HVQM4: compressed movie format designed by Hudson for Nintendo GameCube
 >36    string          I               \binterlaced,
 >40    ledouble        x               \baspect:%.2f,
 >48    ledouble        x               \bfps:%.2f
+
+#                                              MPEG file
+# MPEG sequences
+# FIXME: This section is from the old magic.mime file and needs integrating with the rest
+0       belong             0x000001BA
+>4      byte               &0x40
+!:mime video/mp2p
+>4      byte               ^0x40
+!:mime video/mpeg
+0       belong             0x000001BB
+!:mime video/mpeg
+0       belong             0x000001B0
+!:mime video/mp4v-es
+0       belong             0x000001B5
+!:mime video/mp4v-es
+0       belong             0x000001B3
+!:mime video/mpv
+0       belong&0xFF5FFF1F  0x47400010
+!:mime video/mp2t
+0       belong             0x00000001
+>4      byte&0x1F         0x07
+!:mime video/h264
index 55a591f6ec606ee8d44546ad650d9a393573a834..a6eeaffa0e8432c3e90f48a6c4743b30034f4441 100644 (file)
@@ -8,7 +8,9 @@
 
 # POSIX tar archives
 257    string          ustar\0         POSIX tar archive
+!:mime application/x-tar # encoding: posix
 257    string          ustar\040\040\0 GNU tar archive
+!:mime application/x-tar # encoding: gnu
 
 # cpio archives
 #
@@ -22,7 +24,9 @@
 # are defined as "short"s; I think all the new formats are
 # character-header formats and thus are strings, not numbers.
 0      short           070707          cpio archive
+!:mime application/x-cpio
 0      short           0143561         byte-swapped cpio archive
+!:mime application/x-cpio # encoding: swapped
 0      string          070707          ASCII cpio archive (pre-SVR4 or odc)
 0      string          070701          ASCII cpio archive (SVR4 with no CRC)
 0      string          070702          ASCII cpio archive (SVR4 with CRC)
 # Debian package (needs to go before regular portable archives)
 #
 0      string          =!<arch>\ndebian
+!:mime application/x-debian-package
 >8     string          debian-split    part of multipart Debian package
 >8     string          debian-binary   Debian binary package
+>8     string          !debian
 >68    string          >\0             (format %s)
 # These next two lines do not work, because a bzip2 Debian archive
 # still uses gzip for the control.tar (first in the archive).  Only
@@ -49,6 +55,7 @@
 0      short           0177545         old PDP-11 archive
 0      long            0100554         apl workspace
 0      string          =<ar>           archive
+!:mime application/x-archive
 
 # MIPS archive (needs to go before regular portable archives)
 #
@@ -79,6 +86,7 @@
 # "ar" archives?
 #
 0      string          =!<arch>                current ar archive
+!:mime application/x-archive
 >8     string          __.SYMDEF       random library
 >0     belong          =65538          - pre SR9.5
 >0     belong          =65539          - post SR9.5
 # we only test some types on basis of frequency: 0x08 (83%), 0x09 (5%),
 # 0x02 (5%), 0x03 (3%), 0x04 (2%), 0x06 (2%).  0x01 collides with terminfo.
 0      lelong&0x8080ffff       0x0000081a      ARC archive data, dynamic LZW
+!:mime application/x-arc
 0      lelong&0x8080ffff       0x0000091a      ARC archive data, squashed
+!:mime application/x-arc
 0      lelong&0x8080ffff       0x0000021a      ARC archive data, uncompressed
+!:mime application/x-arc
 0      lelong&0x8080ffff       0x0000031a      ARC archive data, packed
+!:mime application/x-arc
 0      lelong&0x8080ffff       0x0000041a      ARC archive data, squeezed
+!:mime application/x-arc
 0      lelong&0x8080ffff       0x0000061a      ARC archive data, crunched
+!:mime application/x-arc
 # [JW] stuff taken from idarc, obviously ARC successors:
 0      lelong&0x8080ffff       0x00000a1a      PAK archive data
+!:mime application/x-arc
 0      lelong&0x8080ffff       0x0000141a      ARC+ archive data
+!:mime application/x-arc
 0      lelong&0x8080ffff       0x0000481a      HYP archive data
+!:mime application/x-arc
 
 # Acorn archive formats (Disaster prone simpleton, m91dps@ecs.ox.ac.uk)
 # I can't create either SPARK or ArcFS archives so I have not tested this stuff
 
 # ARJ archiver (jason@jarthur.Claremont.EDU)
 0      leshort         0xea60          ARJ archive data
+!:mime application/x-arj
 >5     byte            x               \b, v%d,
 >8     byte            &0x04           multi-volume,
 >8     byte            &0x10           slash-switched,
 
 # LHARC/LHA archiver (Greg Roelofs, newt@uchicago.edu)
 2      string          -lh0-           LHarc 1.x/ARX archive data [lh0]
+!:mime application/x-lharc
 2      string          -lh1-           LHarc 1.x/ARX archive data [lh1]
+!:mime application/x-lharc
 2      string          -lz4-           LHarc 1.x archive data [lz4]
+!:mime application/x-lharc
 2      string          -lz5-           LHarc 1.x archive data [lz5]
+!:mime application/x-lharc
 #      [never seen any but the last; -lh4- reported in comp.compression:]
 2      string          -lzs-           LHa/LZS archive data [lzs]
+!:mime application/x-lha
 2      string          -lh\40-         LHa 2.x? archive data [lh ]
+!:mime application/x-lha
 2      string          -lhd-           LHa 2.x? archive data [lhd]
+!:mime application/x-lha
 2      string          -lh2-           LHa 2.x? archive data [lh2]
+!:mime application/x-lha
 2      string          -lh3-           LHa 2.x? archive data [lh3]
+!:mime application/x-lha
 2      string          -lh4-           LHa (2.x) archive data [lh4]
+!:mime application/x-lha
 2      string          -lh5-           LHa (2.x) archive data [lh5]
+!:mime application/x-lha
 2      string          -lh6-           LHa (2.x) archive data [lh6]
+!:mime application/x-lha
 2      string          -lh7-           LHa (2.x)/LHark archive data [lh7]
+!:mime application/x-lha
 >20    byte            x               - header level %d
 # taken from idarc [JW]
 2   string      -lZ         PUT archive data
 
 # RAR archiver (Greg Roelofs, newt@uchicago.edu)
 0      string          Rar!            RAR archive data,
+!:mime application/x-rar
 >44    byte            x               v%0x,
 >10    byte            >0              flags:
 >>10   byte            &0x01           Archive volume,
 
 # ZIP archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu)
 0      string          PK\003\004
+!:mime application/zip
 >4     byte            0x00            Zip archive data
 >4     byte            0x09            Zip archive data, at least v0.9 to extract
 >4     byte            0x0a            Zip archive data, at least v1.0 to extract
 
 # Zoo archiver
 20     lelong          0xfdc4a7dc      Zoo archive data
+!:mime application/x-zoo
 >4     byte            >48             \b, v%c.
 >>6    byte            >47             \b%c
 >>>7   byte            >47             \b%c
 
 # Shell archives
 10     string          #\ This\ is\ a\ shell\ archive  shell archive text
+!:mime application/octet-stream
 
 #
 # LBR. NB: May conflict with the questionable 
 
 # Felix von Leitner <felix-file@fefe.de>
 0      string  d8:announce     BitTorrent file
+!:mime application/x-bittorrent
 
 # Atari MSA archive - Teemu Hukkanen <tjhukkan@iki.fi>
 0       beshort 0x0e0f          Atari MSA archive data
 # EET archive
 # From: Tilman Sauerbeck <tilman@code-monkey.de>
 0      belong  0x1ee7ff00      EET archive
+!:mime application/x-eet
 
 # rzip archives
 0      string  RZIP            rzip compressed data
 #  http://www.thouky.co.uk/software/psifs/sis.html
 #  http://developer.symbian.com/main/downloads/papers/SymbianOSv91/softwareinstallsis.pdf
 8      lelong  0x10000419      Symbian installation file
+!:mime application/vnd.symbian.install
 >4     lelong  0x1000006D      (EPOC release 3/4/5)
 >4     lelong  0x10003A12      (EPOC release 6)
 0      lelong  0x10201A7A      Symbian installation file (Symbian OS 9.x)
+!:mime x-epoc/x-sisx-app
 
 # Pack200 Java archives, http://jcp.org/en/jsr/detail?id=200
 0      belong  0xcafed00d      Pack200 Java archive
index 18b47a6254ba8a8ee00bdc8b4694cb077281a31d..c235e8aef58b5013afdfddf0f2f3965ef0274e08 100644 (file)
@@ -9,12 +9,19 @@
 # Sun/NeXT audio data
 0      string          .snd            Sun/NeXT audio data:
 >12    belong          1               8-bit ISDN mu-law,
+!:mime audio/basic
 >12    belong          2               8-bit linear PCM [REF-PCM],
+!:mime audio/basic
 >12    belong          3               16-bit linear PCM,
+!:mime audio/basic
 >12    belong          4               24-bit linear PCM,
+!:mime audio/basic
 >12    belong          5               32-bit linear PCM,
+!:mime audio/basic
 >12    belong          6               32-bit IEEE floating point,
+!:mime audio/basic
 >12    belong          7               64-bit IEEE floating point,
+!:mime audio/basic
 >12    belong          8               Fragmented sample data,
 >12    belong          10              DSP program,
 >12    belong          11              8-bit fixed point,
@@ -26,6 +33,7 @@
 >12    belong          20              16-bit linear with emphasis and compression,
 >12    belong          21              Music kit DSP commands,
 >12    belong          23              8-bit ISDN mu-law compressed (CCITT G.721 ADPCM voice enc.),
+!:mime  audio/x-adpcm
 >12    belong          24              compressed (8-bit CCITT G.722 ADPCM)
 >12    belong          25              compressed (3-bit CCITT G.723.3 ADPCM),
 >12    belong          26              compressed (5-bit CCITT G.723.5 ADPCM),
 # that uses little-endian encoding and has a different magic number
 0      lelong          0x0064732E      DEC audio data:
 >12    lelong          1               8-bit ISDN mu-law,
+!:mime audio/x-dec-basic
 >12    lelong          2               8-bit linear PCM [REF-PCM],
+!:mime audio/x-dec-basic
 >12    lelong          3               16-bit linear PCM,
+!:mime audio/x-dec-basic
 >12    lelong          4               24-bit linear PCM,
+!:mime audio/x-dec-basic
 >12    lelong          5               32-bit linear PCM,
+!:mime audio/x-dec-basic
 >12    lelong          6               32-bit IEEE floating point,
+!:mime audio/x-dec-basic
 >12    lelong          7               64-bit IEEE floating point,
+!:mime audio/x-dec-basic
 >12    belong          8               Fragmented sample data,
 >12    belong          10              DSP program,
 >12    belong          11              8-bit fixed point,
@@ -56,6 +71,7 @@
 >12    belong          20              16-bit linear with emphasis and compression,
 >12    belong          21              Music kit DSP commands,
 >12    lelong          23              8-bit ISDN mu-law compressed (CCITT G.721 ADPCM voice enc.),
+!:mime audio/x-dec-basic
 >12    belong          24              compressed (8-bit CCITT G.722 ADPCM)
 >12    belong          25              compressed (3-bit CCITT G.723.3 ADPCM),
 >12    belong          26              compressed (5-bit CCITT G.723.5 ADPCM),
@@ -67,6 +83,7 @@
 
 # Creative Labs AUDIO stuff
 0      string  MThd                    Standard MIDI data
+!:mime audio/x-midi
 >8     beshort x                       (format %d)
 >10    beshort x                       using %d track
 >10    beshort         >1              \bs
 >12    beshort&0x8000  >0              SMPTE
 
 0      string  CTMF                    Creative Music (CMF) data
+!:mime audio/x-unknown
 0      string  SBI                     SoundBlaster instrument data
+!:mime audio/x-unknown
 0      string  Creative\ Voice\ File   Creative Labs voice data
+!:mime audio/x-unknown
 # is this next line right?  it came this way...
 >19    byte    0x1A
 >23    byte    >0                      - version %d
 
 # Real Audio (Magic .ra\0375)
 0      belong          0x2e7261fd      RealAudio sound file
+!:mime audio/x-pn-realaudio
 0      string          .RMF            RealMedia file
+!:mime application/vnd.rn-realmedia
+#video/x-pn-realvideo
+#video/vnd.rn-realvideo
+#application/vnd.rn-realmedia
+#      sigh, there are many mimes for that but the above are the most common.
 
 # MTM/669/FAR/S3M/ULT/XM format checking [Aaron Eppert, aeppert@dialin.ind.net]
 # Oct 31, 1995
 0      string          GF1PATCH110\0ID#000002\0        GUS patch
 0      string          GF1PATCH100\0ID#000002\0        Old GUS patch
 
+# mime types according to http://www.geocities.com/nevilo/mod.htm:
+#      audio/it        .it
+#      audio/x-zipped-it       .itz
+#      audio/xm        fasttracker modules
+#      audio/x-s3m     screamtracker modules
+#      audio/s3m       screamtracker modules
+#      audio/x-zipped-mod      mdz
+#      audio/mod       mod
+#      audio/x-mod     All modules (mod, s3m, 669, mtm, med, xm, it, mdz, stm, itz, xmz, s3z)
+
 #
 # Taken from loader code from mikmod version 2.14
 # by Steve McIntyre (stevem@chiark.greenend.org.uk)
 # <doj@cubic.org> added title printing on 2003-06-24
 0      string  MAS_UTrack_V00
 >14    string  >/0             ultratracker V1.%.1s module sound data
+!:mime audio/x-mod
+#audio/x-tracker-module
 
 0      string  UN05            MikMod UNI format module sound data
 
 0      string  Extended\ Module: Fasttracker II module sound data
+!:mime audio/x-mod
+#audio/x-tracker-module
 >17    string  >\0             Title: "%s"
 
 21     string/c        =!SCREAM!       Screamtracker 2 module sound data
+!:mime audio/x-mod
+#audio/x-screamtracker-module
 21     string  BMOD2STM        Screamtracker 2 module sound data
+!:mime audio/x-mod
+#audio/x-screamtracker-module
 1080   string  M.K.            4-channel Protracker module sound data
+!:mime audio/x-mod
+#audio/x-protracker-module
 >0     string  >\0             Title: "%s"
 1080   string  M!K!            4-channel Protracker module sound data
+!:mime audio/x-mod
+#audio/x-protracker-module
 >0     string  >\0             Title: "%s"
 1080   string  FLT4            4-channel Startracker module sound data
+!:mime audio/x-mod
+#audio/x-startracker-module
 >0     string  >\0             Title: "%s"
 1080   string  FLT8            8-channel Startracker module sound data
+!:mime audio/x-mod
+#audio/x-startracker-module
 >0     string  >\0             Title: "%s"
 1080   string  4CHN            4-channel Fasttracker module sound data
+!:mime audio/x-mod
+#audio/x-fasttracker-module
 >0     string  >\0             Title: "%s"
 1080   string  6CHN            6-channel Fasttracker module sound data
+!:mime audio/x-mod
+#audio/x-fasttracker-module
 >0     string  >\0             Title: "%s"
 1080   string  8CHN            8-channel Fasttracker module sound data
+!:mime audio/x-mod
+#audio/x-fasttracker-module
 >0     string  >\0             Title: "%s"
 1080   string  CD81            8-channel Octalyser module sound data
+!:mime audio/x-mod
+#audio/x-octalysertracker-module
 >0     string  >\0             Title: "%s"
-1080   string  OKTA            8-channel Oktalyzer module sound data
+1080   string  OKTA            8-channel Octalyzer module sound data
+!:mime audio/x-mod
+#audio/x-octalysertracker-module
 >0     string  >\0             Title: "%s"
 # Not good enough.
 #1082  string  CH
 #>1080 string  >/0             %.2s-channel Fasttracker "oktalyzer" module sound data
 1080   string  16CN            16-channel Taketracker module sound data
+!:mime audio/x-mod
+#audio/x-taketracker-module
 >0     string  >\0             Title: "%s"
 1080   string  32CN            32-channel Taketracker module sound data
+!:mime audio/x-mod
+#audio/x-taketracker-module
 >0     string  >\0             Title: "%s"
 
 # TOC sound files -Trevor Johnson <trevor@jpj.net>
 0      string          _SGI_SoundTrack         SGI SoundTrack project file
 # ID3 version 2 tags <waschk@informatik.uni-rostock.de>
 0      string          ID3     Audio file with ID3 version 2.
+# ??? Normally such a file is an MP3 file, but this will give false positives
+!:mime audio/mpeg
 >3     ubyte   <0xff   \b%d
 #>4    ubyte   <0xff   \b%d tag
 >2584  string  fLaC            \b, FLAC encoding
 
 # Impulse tracker module (audio/x-it)
 0      string          IMPM            Impulse Tracker module sound data -
+!:mime audio/x-mod
 >4     string          >\0             "%s"
 >40    leshort         !0              compatible w/ITv%x
 >42    leshort         !0              created w/ITv%x
 # Free lossless audio codec <http://flac.sourceforge.net>
 # From: Przemyslaw Augustyniak <silvathraec@rpg.pl>
 0      string                  fLaC            FLAC audio bitstream data
+!:mime audio/x-flac
 >4     byte&0x7f               >0              \b, unknown version
 >4     byte&0x7f               0               \b
 # some common bits/sample values
index fd3f9aa2491f06881b4166e88dae2e5488687bda..343ef7f151bf07e1ab40c55afe3b575d7847751a 100644 (file)
@@ -6,6 +6,10 @@
 # XPM icons (Greg Roelofs, newt@uchicago.edu)
 # if you uncomment "/*" for C/REXX below, also uncomment this entry
 #0     string          /*\ XPM\ */     X pixmap image data
+#!:mime        image/x-xpmi
+
+# 3DS (3d Studio files) Conflicts with diff output 0x3d '='
+#16    beshort         0x3d3d          image/x-3ds
 
 # this first will upset you if you're a PL/1 shop...
 # in which case rm it; ascmagic will catch real C programs
index 233411c80439b2f4cbb45fc35f48a3ab910782b2..40cf5850436a67f47f68f489a42859c5f04bf4cd 100644 (file)
 # (and use as a hack). Let's not use 18, because the Mach-O people
 # might add another one or two as time goes by...
 #
-0      belong          0xcafebabe
->4     belong          >30             compiled Java class data,
->>6     beshort                x               version %d.
->>4     beshort                x               \b%d
->4     belong          1               Mach-O fat file with 1 architecture
->4     belong          >1
->>4    belong          <20             Mach-O fat file with %ld architectures
+0      beshort         0xcafe
+>2     beshort         0xbabe
+!:mime application/x-java-applet
+>>2    belong          >30             compiled Java class data,
+>>>6   beshort         x               version %d.
+>>>4   beshort         x               \b%d
+>>4    belong          1               Mach-O fat file with 1 architecture
+>>4    belong          >1
+>>>4   belong          <20             Mach-O fat file with %ld architectures
+>2     beshort         0xd00d          JAR compressed with pack200
+!:mime application/x-java-pack200
index 599c190a45ec45a64bab04d99792a285c7a45bde..d1a33ebad96f01c0143befb1b0d37fb7d3a5bba5 100644 (file)
@@ -2,31 +2,50 @@
 #------------------------------------------------------------------------------
 # commands:  file(1) magic for various shells and interpreters
 #
-     string          :                       shell archive or script for antique kernel text
+#0     string          :                       shell archive or script for antique kernel text
 0      string/b        #!\ /bin/sh             Bourne shell script text executable
+!:mime application/x-shellscript
 0      string/b        #!\ /bin/csh            C shell script text executable
+!:mime application/x-shellscript
 # korn shell magic, sent by George Wu, gwu@clyde.att.com
 0      string/b        #!\ /bin/ksh            Korn shell script text executable
+!:mime application/x-shellscript
 0      string/b        #!\ /bin/tcsh           Tenex C shell script text executable
+!:mime application/x-shellscript
 0      string/b        #!\ /usr/local/tcsh     Tenex C shell script text executable
+!:mime application/x-shellscript
 0      string/b        #!\ /usr/local/bin/tcsh Tenex C shell script text executable
+!:mime application/x-shellscript
 
 #
 # zsh/ash/ae/nawk/gawk magic from cameron@cs.unsw.oz.au (Cameron Simpson)
 0      string/b        #!\ /bin/zsh            Paul Falstad's zsh script text executable
+!:mime application/x-shellscript
 0      string/b        #!\ /usr/bin/zsh        Paul Falstad's zsh script text executable
+!:mime application/x-shellscript
 0      string/b        #!\ /usr/local/bin/zsh  Paul Falstad's zsh script text executable
+!:mime application/x-shellscript
 0      string/b        #!\ /usr/local/bin/ash  Neil Brown's ash script text executable
+!:mime application/x-shellscript
 0      string/b        #!\ /usr/local/bin/ae   Neil Brown's ae script text executable
+!:mime application/x-shellscript
 0      string/b        #!\ /bin/nawk           new awk script text executable
+!:mime application/x-nawk
 0      string/b        #!\ /usr/bin/nawk       new awk script text executable
+!:mime application/x-nawk
 0      string/b        #!\ /usr/local/bin/nawk new awk script text executable
+!:mime application/x-nawk
 0      string/b        #!\ /bin/gawk           GNU awk script text executable
+!:mime application/x-gawk
 0      string/b        #!\ /usr/bin/gawk       GNU awk script text executable
+!:mime application/x-gawk
 0      string/b        #!\ /usr/local/bin/gawk GNU awk script text executable
+!:mime application/x-gawk
 #
 0      string/b        #!\ /bin/awk            awk script text executable
+!:mime application/x-awk
 0      string/b        #!\ /usr/bin/awk        awk script text executable
+!:mime application/x-awk
 # update to distinguish from *.vcf files
 # this is broken because postscript has /EBEGIN{ for example.
 #0     regex           BEGIN[[:space:]]*[{]    awk script text
@@ -36,7 +55,9 @@
 
 # bash shell magic, from Peter Tobias (tobias@server.et-inf.fho-emden.de)
 0      string/b        #!\ /bin/bash   Bourne-Again shell script text executable
+!:mime application/x-shellscript
 0      string/b        #!\ /usr/local/bin/bash Bourne-Again shell script text executable
+!:mime application/x-shellscript
 
 # using env
 0      string          #!/usr/bin/env          a
index e9be46b76c40d1fcb08acdf00faa6244427d7f0d..1d8cbd114a006277963dac258b28134b0323501d 100644 (file)
@@ -10,6 +10,7 @@
 
 # standard unix compress
 0      string          \037\235        compress'd data
+!:mime application/x-compress
 >2     byte&0x80       >0              block compressed
 >2     byte&0x1f       x               %d bits
 
@@ -19,6 +20,7 @@
 #      * Produce shorter output - notably, only report compression methods
 #        other than 8 ("deflate", the only method defined in RFC 1952).
 0       string          \037\213        gzip compressed data
+!:mime application/x-gzip
 >2     byte            <8              \b, reserved method
 >2     byte            >8              \b, unknown method
 >3     byte            &0x01           \b, ASCII
 
 # packed data, Huffman (minimum redundancy) codes on a byte-by-byte basis
 0      string          \037\036        packed data
+!:mime application/octet-stream
 >2     belong          >1              \b, %d characters originally
 >2     belong          =1              \b, %d character originally
 #
 # This magic number is byte-order-independent.
 0      short           0x1f1f          old packed data
+!:mime application/octet-stream
 
 # XXX - why *two* entries for "compacted data", one of which is
 # byte-order independent, and one of which is byte-order dependent?
 #
 0      short           0x1fff          compacted data
+!:mime application/octet-stream
 # This string is valid for SunOS (BE) and a matching "short" is listed
 # in the Ultrix (LE) magic file.
 0      string          \377\037        compacted data
+!:mime application/octet-stream
 0      short           0145405         huf output
+!:mime application/octet-stream
 
 # bzip2
 0      string          BZh             bzip2 compressed data
+!:mime application/x-bzip2
 >3     byte            >47             \b, block size = %c00k
 
 # squeeze and crunch
index 8f2fc0a76d334a4b15fc57f6212f92b6a8abfd8b..d1f374d5ee029af9a4fda35a182ee89c30134b19 100644 (file)
@@ -9,8 +9,11 @@
 #  Will be maintained as part of the GDBM distribution in the future.
 #  <downsj@teeny.org>
 0      belong  0x13579ace      GNU dbm 1.x or ndbm database, big endian
+!:mime application/x-gdbm
 0      lelong  0x13579ace      GNU dbm 1.x or ndbm database, little endian
+!:mime application/x-gdbm
 0      string  GDBM            GNU dbm 2.x database
+!:mime application/x-gdbm
 #
 # Berkeley DB
 #
@@ -21,6 +24,7 @@
 # Hash and Btree 2.X and later databases store the metadata in host byte order.
 
 0      long    0x00061561      Berkeley DB
+!:mime application/x-dbm
 >8     belong  4321
 >>4    belong  >2              1.86
 >>4    belong  <3              1.85
 #>>0x04          byte          6       non-incrementing secondary index .XGn file 
 #>>0x04          byte          7       secondary index .YGn file 
 #>>>0x04         byte          8       incrementing secondary index .XGn file 
+
 ## XBase database files
 #0      byte       0x02        
 #>8     leshort          >0
 #>>12   leshort    0   FoxBase 
+#!:mime        application/x-dbf
 #>>>0x04       lelong          0               (no records)
 #>>>0x04       lelong          >0              (%ld records)
 #
 #0      byte       0x03        
+#!:mime        application/x-dbf
 #>8     leshort          >0
 #>>12   leshort    0   FoxBase+, FoxPro, dBaseIII+, dBaseIV, no memo 
 #>>>0x04       lelong          0               (no records)
 #>>>0x04       lelong          >0              (%ld records)
 #
 #0      byte       0x04        
+#!:mime        application/x-dbf
 #>8     leshort          >0
 #>>12   leshort    0   dBASE IV no memo file 
 #>>>0x04       lelong          0               (no records)
 #>>>0x04       lelong          >0              (%ld records)
 #
 #0      byte       0x05        
+#!:mime        application/x-dbf
 #>8     leshort          >0
 #>>12   leshort    0   dBASE V no memo file 
 #>>>0x04       lelong          0               (no records)
 #>>>0x04       lelong          >0              (%ld records)
 #
 #0      byte       0x30
+#!:mime        application/x-dbf
 #>8     leshort          >0
 #>>12   leshort    0   Visual FoxPro 
 #>>>0x04       lelong          0               (no records)
 #>>>0x04       lelong          >0              (%ld records)
 #
 #0      byte       0x43
+#!:mime        application/x-dbf
 #>8     leshort          >0
 #>>12   leshort    0   FlagShip with memo var size 
 #>>>0x04       lelong          0               (no records)
 #>>>0x04       lelong          >0              (%ld records)
 #
 #0      byte       0x7b
+#!:mime        application/x-dbf
 #>8     leshort          >0
 #>>12   leshort    0   dBASEIV with memo 
 #>>>0x04       lelong          0               (no records)
 #>>>0x04       lelong          >0              (%ld records)
 #
 #0      byte       0x83        
+#!:mime        application/x-dbf
 #>8     leshort          >0
 #>>12   leshort    0   FoxBase+, dBaseIII+ with memo 
 #>>>0x04       lelong          0               (no records)
 #>>>0x04       lelong          >0              (%ld records)
 #
 #0      byte       0x8b
+#!:mime        application/x-dbf
 #>8     leshort          >0
 #>>12   leshort    0   dBaseIV with memo 
 #>>>0x04       lelong          0               (no records)
 #>>>0x04       lelong          >0              (%ld records)
 #
 #0      byte       0x8e        
+#!:mime        application/x-dbf
 #>8     leshort          >0
 #>>12   leshort    0   dBaseIV with SQL Table 
 #>>>0x04       lelong          0               (no records)
 #>>>0x04       lelong          >0              (%ld records)
 #
 #0      byte       0xb3
+#!:mime        application/x-dbf
 #>8     leshort          >0
 #>>12   leshort    0   FlagShip with .dbt memo 
 #>>>0x04       lelong          0               (no records)
 #>>>0x04       lelong          >0              (%ld records)
 #
 #0      byte       0xf5
+#!:mime        application/x-dbf
 #>8     leshort          >0
 #>>12   leshort    0   FoxPro with memo 
 #>>>0x04       lelong          0               (no records)
 #0     leshort         0x0006          DBase 3 index file
 
 # MS Access database
-4        string        Standard\ Jet\ DB       Microsoft Access Database
+4      string  Standard\ Jet\ DB       Microsoft Access Database
+!:mime application/x-msaccess
 
 # TDB database from Samba et al - Martin Pool <mbp@samba.org>
 0      string  TDB\ file               TDB database
index 464b436aca1d882880eacbce0d638ee16b89f2e0..dadfda779d31b723832555e52c6f43604a634afc 100644 (file)
 >5     byte            0               invalid byte order
 >5     byte            1               LSB
 >>16   leshort         0               no file type,
+!:mime application/octet-stream
 >>16   leshort         1               relocatable,
+!:mime application/x-object
 >>16   leshort         2               executable,
+!:mime application/x-executable
 >>16   leshort         3               shared object,
+!:mime application/x-sharedlib
 # Core handling from Peter Tobias <tobias@server.et-inf.fho-emden.de>
 # corrections by Christian 'Dr. Disk' Hechelmann <drdisk@ds9.au.s.shuttle.de>
 >>16   leshort         4               core file
+!:mime application/x-coredump
 # Core file detection is not reliable.
 #>>>(0x38+0xcc) string >\0             of '%s'
 #>>>(0x38+0x10) lelong >0              (signal %d),
 >>36   lelong          1               MathCoPro/FPU/MAU Required
 >5     byte            2               MSB
 >>16   beshort         0               no file type,
+!:mime application/octet-stream
 >>16   beshort         1               relocatable,
+!:mime application/x-object
 >>16   beshort         2               executable,
+!:mime application/x-executable
 >>16   beshort         3               shared object,
+!:mime application/x-sharedlib
 >>16   beshort         4               core file,
+!:mime application/x-coredump
 #>>>(0x38+0xcc) string >\0             of '%s'
 #>>>(0x38+0x10) belong >0              (signal %d),
 >>16   beshort         &0xff00         processor-specific,
index 20b257bc3a4c39292ccf8672d3de64d52334b26a..d78b52d54f8c5b047f6df511e9c42f542e23929f 100644 (file)
 
 # CDROM Filesystems
 # Modified for UDF by gerardo.cacciari@gmail.com
-32769    string    CD001
->38913   string   !NSR0      ISO 9660 CD-ROM filesystem data
->38913   string    NSR0      UDF filesystem data
->>38917  string    1         (version 1.0)
->>38917  string    2         (version 1.5)
->>38917  string    3         (version 2.0)
->>38917  byte     >0x33      (unknown version, ID 0x%X)
->>38917  byte     <0x31      (unknown version, ID 0x%X)
+32769  string    CD001
+!:mime application/x-iso9660-image
+>38913 string   !NSR0      ISO 9660 CD-ROM filesystem data
+>38913 string    NSR0      UDF filesystem data
+>>38917        string    1         (version 1.0)
+>>38917        string    2         (version 1.5)
+>>38917        string    3         (version 2.0)
+>>38917        byte     >0x33      (unknown version, ID 0x%X)
+>>38917        byte     <0x31      (unknown version, ID 0x%X)
 # "application id" which appears to be used as a volume label
->32808  string    >\0       '%s'
->34816  string    \000CD001\001EL\ TORITO\ SPECIFICATION    (bootable)
-37633    string    CD001     ISO 9660 CD-ROM filesystem data (raw 2352 byte sectors)
-32776    string    CDROM     High Sierra CD-ROM filesystem data
+>32808 string    >\0       '%s'
+>34816 string    \000CD001\001EL\ TORITO\ SPECIFICATION    (bootable)
+37633  string    CD001     ISO 9660 CD-ROM filesystem data (raw 2352 byte sectors)
+!:mime application/x-iso9660-image
+32776  string    CDROM     High Sierra CD-ROM filesystem data
 
 # cramfs filesystem - russell@coker.com.au
 0       lelong    0x28cd3d45      Linux Compressed ROM File System data, little endian
index f14b460c702ec851f0655126edca006c1ba9bec8..0b985f22b7c8f085e8e9a57a12332869ee920c01 100644 (file)
@@ -8,10 +8,13 @@
 #
 0      string          FWS             Macromedia Flash data,
 >3     byte            x               version %d
+!:mime application/x-shockwave-flash
 0      string          CWS             Macromedia Flash data (compressed),
+!:mime application/x-shockwave-flash
 >3     byte            x               version %d
 # From: Cal Peake <cp@absolutedigital.net>
 0      string          FLV             Macromedia Flash Video
+!:mime video/x-flv
 
 #
 # From Dave Wilson
index ce004adb361b5abe572132960eca23431bc2a339..3e490333e1804cd95738aa89486b19dc54f7ddee 100644 (file)
@@ -1,2 +1,3 @@
 # FORTRAN source
 0      string/c        c\              FORTRAN program
+!:mime text/x-fortran
index 1b397df05799aa7cb0e891edab623e86f6fdf9a4..643ba99e0965fe59709de15ee1ecf578328b4df3 100644 (file)
@@ -5,7 +5,11 @@
 # This stuff came on a FrameMaker demo tape, most of which is
 # copyright, but this file is "published" as witness the following:
 #
+# Note that this is the Framemaker Maker Interchange Format, not the
+# Normal format which would be application/vnd.framemaker.
+#
 0      string          \<MakerFile     FrameMaker document
+!:mime application/x-mif
 >11    string          5.5              (5.5
 >11    string          5.0              (5.0
 >11    string          4.0              (4.0
 >11    string          1.0              (1.0
 >14    byte            x                 %c)
 0      string          \<MIFFile       FrameMaker MIF (ASCII) file
+!:mime application/x-mif
 >9     string          4.0              (4.0)
 >9     string          3.0              (3.0)
 >9     string          2.0              (2.0)
 >9     string          1.0              (1.x)
 0      string          \<MakerDictionary       FrameMaker Dictionary text
+!:mime application/x-mif
 >17    string          3.0              (3.0)
 >17    string          2.0              (2.0)
 >17    string          1.0              (1.x)
 0      string          \<MakerScreenFont       FrameMaker Font file
+!:mime application/x-mif
 >17    string          1.01             (%s)
 0      string          \<MML           FrameMaker MML file
+!:mime application/x-mif
 0      string          \<BookFile      FrameMaker Book file
+!:mime application/x-mif
 >10    string          3.0              (3.0
 >10    string          2.0              (2.0
 >10    string          1.0              (1.0
 >13    byte            x                 %c)
 # XXX - this book entry should be verified, if you find one, uncomment this
 #0     string          \<Book\         FrameMaker Book (ASCII) file
+#!:mime        application/x-mif
 #>6    string          3.0              (3.0)
 #>6    string          2.0              (2.0)
 #>6    string          1.0              (1.0)
 0      string          \<Maker Intermediate Print File FrameMaker IPL file
+!:mime application/x-mif
index 42d9c7bc68e4c8b50651b1ae780278e8785db23f..a237f530cf98cfae5ca206b6447954e2cbfca39d 100644 (file)
 # The format is very similar to pgp
 0      string          \001gpg                 GPG key trust database
 >4     byte            x                       version %d
+# Note: magic.mime had 0x8501 for the next line instead of 0x8502
 0      beshort         0x8502                  GPG encrypted data
+!:mime text/PGP # encoding: data
+
 # This magic is not particularly good, as the keyrings don't have true
 # magic. Nevertheless, it covers many keyrings.
 0       beshort         0x9901                  GPG key public ring
+!:mime application/x-gnupg-keyring
 
 # Gnumeric spreadsheet
 # This entry is only semi-helpful, as Gnumeric compresses its files, so
index 3c88f9039c1f54a6bd595abde5ce7a7aabeb0b98..4d2a832c6e95b957e8d07c2d4c70548d07a94245 100644 (file)
 #>4    belong          x               \b, FORM is %d bytes long
 # audio formats
 >8     string          AIFF            \b, AIFF audio
+!:mime audio/x-aiff
 >8     string          AIFC            \b, AIFF-C compressed audio
+!:mime audio/x-aiff
 >8     string          8SVX            \b, 8SVX 8-bit sampled sound voice
+!:mime audio/x-aiff
 >8     string          16SV            \b, 16SV 16-bit sampled sound voice
 >8     string          SAMP            \b, SAMP sampled audio
 >8     string          MAUD            \b, MAUD MacroSystem audio
index fd9e14f9fd2bfeca2d7fe7841dd2399df0f8835b..57ef7a968ef4c18424860d8fc014c185c49e4303 100644 (file)
@@ -1,6 +1,7 @@
 
 #------------------------------------------------------------------------------
-# images:  file(1) magic for image formats (see also "iff")
+# images:  file(1) magic for image formats (see also "iff", and "c-lang" for
+# XPM bitmaps)
 #
 # originally from jef@helios.ee.lbl.gov (Jef Poskanzer),
 # additions by janl@ifi.uio.no as well as others. Jan also suggested
 # PBMPLUS images
 # The next byte following the magic is always whitespace.
 0      string          P1              Netpbm PBM image text
+!:mime image/x-portable-bitmap
 0      string          P2              Netpbm PGM image text
+!:mime image/x-portable-greymap
 0      string          P3              Netpbm PPM image text
+!:mime image/x-portable-pixmap
 0      string          P4              Netpbm PBM "rawbits" image data
+!:mime image/x-portable-bitmap
 0      string          P5              Netpbm PGM "rawbits" image data
+!:mime image/x-portable-greymap
 0      string          P6              Netpbm PPM "rawbits" image data
+!:mime image/x-portable-pixmap
 0      string          P7              Netpbm PAM image file
+!:mime image/x-portable-pixmap
 
 # From: bryanh@giraffe-data.com (Bryan Henderson)
 0      string          \117\072        Solitaire Image Recorder format
 >21    byte            51              version 3
 
 # NIFF (Navy Interchange File Format, a modification of TIFF) images
+# [GRR:  this *must* go before TIFF]
 0      string          IIN1            NIFF image data
+!:mime image/x-niff
 
 # Tag Image File Format, from Daniel Quinlan (quinlan@yggdrasil.com)
 # The second word of TIFF files is the TIFF version number, 42, which has
 # never changed.  The TIFF specification recommends testing for it.
 0      string          MM\x00\x2a      TIFF image data, big-endian
+!:mime image/tiff
 0      string          II\x2a\x00      TIFF image data, little-endian
+!:mime image/tiff
 
 # PNG [Portable Network Graphics, or "PNG's Not GIF"] images
 # (Greg Roelofs, newt@uchicago.edu)
@@ -65,6 +77,7 @@
 # 137 P N G \r \n ^Z \n [4-byte length] H E A D [HEAD data] [HEAD crc] ...
 #
 0      string          \x89PNG         PNG image data,
+!:mime image/png
 >4     belong          !0x0d0a1a0a     CORRUPTED,
 >4     belong          0x0d0a1a0a
 >>16   belong          x               %ld x
 >>28   byte            1               interlaced
 1      string          PNG             PNG image data, CORRUPTED
 
+# possible GIF replacements; none yet released!
+# (Greg Roelofs, newt@uchicago.edu)
+#
+# GRR 950115:  this was mine ("Zip GIF"):
+0      string          GIF94z          ZIF image (GIF+deflate alpha)
+!:mime image/x-unknown
+#
+# GRR 950115:  this is Jeremy Wohl's Free Graphics Format (better):
+#                                      
+0      string          FGF95a          FGF image (GIF+deflate beta)
+!:mime image/x-unknown
+#
+# GRR 950115:  this is Thomas Boutell's Portable Bitmap Format proposal
+# (best; not yet implemented):
+#                                      
+0      string          PBF             PBF image (deflate compression)
+!:mime image/x-unknown
+
 # GIF
 0      string          GIF8            GIF image data
+!:mime image/gif
 >4     string          7a              \b, version 8%s,
 >4     string          9a              \b, version 8%s,
 >6     leshort         >0              %hd x
 0      string          Sfff            structured fax file
 
 
-# PC bitmaps (OS/2, Windoze BMP files)  (Greg Roelofs, newt@uchicago.edu)
+# PC bitmaps (OS/2, Windows BMP files)  (Greg Roelofs, newt@uchicago.edu)
 0      string          BM              PC bitmap data
+!:mime image/bmp
 >14    leshort         12              \b, OS/2 1.x format
 >>18   leshort         x               \b, %d x
 >>20   leshort         x               %d
 
 # DICOM medical imaging data
 128    string  DICM                    DICOM medical imaging data
+!:mime application/dicom
 
 # XWD - X Window Dump file.
 #   As described in /usr/X11R6/include/X11/XWDFile.h
 
 # Adobe Photoshop
 0      string          8BPS Adobe Photoshop Image
+!:mime image/vnd.adobe.photoshop
 
 # XV thumbnail indicator (ThMO)
 0      string          P7\ 332         XV thumbnail image data
 # From: stephane.loeuillet@tiscali.f
 # http://www.djvuzone.org/
 0      string  AT&TFORM                DjVu Image file
+!:mime image/vnd.djvu
 
 # From: Jason Bacon <bacon@smithers.neuro.mcw.edu>
 0      beshort 0x3020                  character Computer Graphics Metafile
 
 # From: Tobias Burnus <burnus@net-b.de>
 # Xara (for a while: Corel Xara) is a graphic package, see
-# http://www.xara.com/ for Windows and as GPL application for
+# http://www.xara.com/ for Windows and as GPL application for Linux
 0      string  XARA\243\243    Xara graphics file
+
+# http://www.cartesianinc.com/Tech/
+0      string  CPC\262         Cartesian Perceptual Compression image
+!:mime image/x-cpi
index 971b72ceb3a4d95e72e60d21592355ed9eeceee5..cca5542c1f69d91964708ffb0eebad7fe968b0bf 100644 (file)
@@ -9,8 +9,9 @@
 >2     beshort         >0x0004         \b, version %d
 
 0      belong          0xfeedfeed      Java KeyStore
-
+!:mime application/x-java-keystore
 0      belong          0xcececece      Java JCE KeyStore
+!:mime application/x-java-jce-keystore
 
 # Dalvik .dex format. http://retrodev.com/android/dexformat.html
 # From <mkf@google.com> "Mike Fleming"
index af646d6fb92010b1271ca4ce8091367c58814190..b3e6646fe21af7126aecbc80338ead6bef71db09 100644 (file)
@@ -9,6 +9,7 @@
 # both of which turn into "JPEG image data" here.
 #
 0      beshort         0xffd8          JPEG image data
+!:mime image/jpeg
 >6     string          JFIF            \b, JFIF standard
 # The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06
 # in a vain attempt to add image size reporting for JFIF.  Note that these
index e9c8ba8ec4e6df5cf0ae41dadca80c7e7a3e5e36..d468c47110aaf763c796ce4e6b89df5cf087a322 100644 (file)
@@ -6,6 +6,8 @@
 
 # updated by Joerg Jenderek
 0      string  ;;                      
+!:mime text/plain
+# FIXME: Is the above MIME type pointless?
 # windows INF files often begin with semicolon and use CRLF as line end
 # lisp files are mainly created on unix system with LF as line end
 >2     search/2048     !\r             Lisp/Scheme program text
 
 # Emacs 18 - this is always correct, but not very magical.
 0      string  \012(                   Emacs v18 byte-compiled Lisp data
+!:mime application/x-elc
 # Emacs 19+ - ver. recognition added by Ian Springer
 # Also applies to XEmacs 19+ .elc files; could tell them apart if we had regexp
 # support or similar - Chris Chittleborough <cchittleborough@yahoo.com.au>
-0      string  ;ELC                    
->4     byte    >19                     
+0      string  ;ELC    
+>4     byte    >18                     
 >4     byte    <32                     Emacs/XEmacs v%d byte-compiled Lisp data
+!:mime application/x-elc               
 
 # Files produced by CLISP Common Lisp From: Bruno Haible <haible@ilog.fr>
 0      string  (SYSTEM::VERSION\040'   CLISP byte-compiled Lisp program text
index 4acd5c88e17030aaf10ed246913b71929077211d..6a903f8c16e0c06c408cd3cd10e36e21e8a03b85 100644 (file)
@@ -5,6 +5,7 @@
 # BinHex is the Macintosh ASCII-encoded file format (see also "apple")
 # Daniel Quinlan, quinlan@yggdrasil.com
 11     string  must\ be\ converted\ with\ BinHex       BinHex binary text
+!:mime application/mac-binhex40
 >41    string  x                                       \b, version %.3s
 
 # Stuffit archives are the de facto standard of compression for Macintosh
@@ -18,6 +19,7 @@
 
 # Newer StuffIt archives (grant@netbsd.org)
 0      string          StuffIt                 StuffIt Archive
+!:mime application/x-stuffit
 #>162  string          >0                      : %s
 
 # Macintosh Applications and Installation binaries (franklsm@tuns.ca)
index f08261ca3a6e1c158c92ec14f68b41ae87302a36..f402599676e0c6bb1e3ffb43f359f56fedbedf4a 100644 (file)
@@ -6,17 +6,28 @@
 #0     string          From            mail text
 # There are tests to ascmagic.c to cope with mail and news.
 0      string          Relay-Version:  old news text
+!:mime message/rfc822
 0      string          #!\ rnews       batched news text
+!:mime message/rfc822
 0      string          N#!\ rnews      mailed, batched news text
+!:mime message/rfc822
 0      string          Forward\ to     mail forwarding text
+!:mime message/rfc822
 0      string          Pipe\ to        mail piping text
+!:mime message/rfc822
 0      string          Return-Path:    smtp mail text
+!:mime message/rfc822
 0      string          Path:           news text
+!:mime message/news
 0      string          Xref:           news text
+!:mime message/news
 0      string          From:           news or mail text
+!:mime message/rfc822
 0      string          Article         saved news text
+!:mime message/news
 0      string          BABYL           Emacs RMAIL text
 0      string          Received:       RFC 822 mail text
+!:mime message/rfc822
 0      string          MIME-Version:   MIME entity text
 #0     string          Content-        MIME entity text
 
@@ -39,3 +50,5 @@
 # XXX: Weak magic
 #256   leshort 0xAFAE4453              Squish message area data file
 #>4    leshort >0                      (%d messages)
+
+#0     string          \<!--\ MHonArc          text/html; x-type=mhonarc
index bb995bad65c93d3559c2f0fec773dc832821c9ea..c5c2e252794898d1aa8f1888bcdf65629549ea13 100644 (file)
@@ -4,6 +4,7 @@
 0      string  %%!!                    X-Post-It-Note text
 0      string/c        BEGIN:VCALENDAR         vCalendar calendar file
 0      string/c        BEGIN:VCARD             vCard visiting card
+!:mime text/x-vcard
 
 # From: Alex Beregszaszi <alex@fsn.hu>
 4      string  gtktalog                GNOME Catalogue (gtktalog)
index 10ce8aefc04552ba377432a61dc17948e5a06caf..aaa99466c432b4c734552ff54e28fcfc4020f446 100644 (file)
@@ -46,6 +46,7 @@
 # many of the compressed formats were extraced from IDARC 1.23 source code
 #
 0      string  MZ              MS-DOS executable
+!:mime application/x-dosexec
 >0 string MZ\0\0\0\0\0\0\0\0\0\0PE\0\0 \b, PE for MS Windows
 >>&18  leshort&0x2000  >0      (DLL)
 >>&88  leshort         0       (unknown subsystem)
 >>&18  leshort&0x1000  >0      system file
 >>&0xf4 search/0x140 \x0\x40\x1\x0
 >>>(&0.l+(4)) string MSCF \b, WinHKI CAB self-extracting archive
+>30            string  Copyright\ 1989-1990\ PKWARE\ Inc.      Self-extracting PKZIP archive
+!:mime application/zip
+# Is next line correct? One might expect "Corp." not "Copr." If it is right, add a note to that effect.
+>30            string  PKLITE\ Copr.   Self-extracting PKZIP archive
+!:mime application/zip
 
 >0x18  leshort >0x3f
 >>(0x3c.l) string PE\0\0 PE 
 >0x1e  string  PKLITE \b, %s compressed
 >0x64   string  W\ Collis\0\0 \b, Compack compressed
 >0x24  string  LHa's\ SFX \b, LHa self-extracting archive
+!:mime application/x-lha
 >0x24  string  LHA's\ SFX \b, LHa self-extracting archive
+!:mime application/x-lha
 >0x24   string  \ $ARX \b, ARX self-extracting archive
 >0x24   string  \ $LHarc \b, LHarc self-extracting archive
 >0x20   string  SFX\ by\ LARC \b, LARC self-extracting archive
 
 # Popular applications
 2080   string  Microsoft\ Word\ 6.0\ Document  %s
+!:mime application/msword
 2080   string  Documento\ Microsoft\ Word\ 6 Spanish Microsoft Word 6 document data
+!:mime application/msword
 # Pawel Wiecek <coven@i17linuxb.ists.pwr.wroc.pl> (for polish Word)
 2112   string  MSWordDoc                       Microsoft Word document data
+!:mime application/msword
 #
 0      belong  0x31be0000                      Microsoft Word Document
+!:mime application/msword
 #
 0       string  PO^Q`                          Microsoft Word 6.0 Document
+!:mime application/msword
 #
 0      string  \376\067\0\043                  Microsoft Office Document
+!:mime application/msword
 0      string  \333\245-\0\0\0                 Microsoft Office Document
+!:mime application/msword
+512    string          \354\245\301            Microsoft Word Document
+!:mime application/msword
 #
 2080   string  Microsoft\ Excel\ 5.0\ Worksheet        %s
+!:mime application/vnd.ms-excel
+
 2080   string  Foglio\ di\ lavoro\ Microsoft\ Exce     %s
+!:mime application/vnd.ms-excel
 #
 # Pawel Wiecek <coven@i17linuxb.ists.pwr.wroc.pl> (for polish Excel)
 2114   string  Biff5           Microsoft Excel 5.0 Worksheet
+!:mime application/vnd.ms-excel
 # Italian MS-Excel
 2121   string  Biff5           Microsoft Excel 5.0 Worksheet
+!:mime application/vnd.ms-excel
 0      string  \x09\x04\x06\x00\x00\x00\x10\x00        Microsoft Excel Worksheet
+!:mime application/vnd.ms-excel
 #
 0      belong  0x00001a00      Lotus 1-2-3
+!:mime application/x-123
 >4     belong  0x00100400      wk3 document data
 >4     belong  0x02100400      wk4 document data
 >4     belong  0x07800100      fm3 or fmb document data
 >4     belong  0x07800000      fm3 or fmb document data
 #
 0      belong  0x00000200      Lotus 1-2-3
+!:mime application/x-123
 >4     belong  0x06040600      wk1 document data
 >4     belong  0x06800200      fmt document data
+0      string          WordPro\0       Lotus WordPro
+!:mime application/vnd.lotus-wordpro
+0      string          WordPro\r\373   Lotus WordPro
+!:mime application/vnd.lotus-wordpro
+
 
 # Help files
 0      string  ?_\3\0          MS Windows Help Data
 
 # Windows icons (Ian Springer <ips@fpk.hp.com>)
 0      string  \000\000\001\000        MS Windows icon resource
+!:mime image/x-ico
 >4     byte    1                       - 1 icon
 >4     byte    >1                      - %d icons
 >>6    byte    >0                      \b, %dx
 >>>>24 long            >0              length %d
 
 # TNEF magic From "Joomy" <joomy@se-ed.net> 
+# Microsoft Outlook's Transport Neutral Encapsulation Format (TNEF)
 0      leshort         0x223e9f78      TNEF
+!:mime application/vnd.ms-tnef
 
 # HtmlHelp files (.chm)
 0      string  ITSF\003\000\000\000\x60\000\000\000\001\000\000\000    MS Windows HtmlHelp Data
 # False positive with PPT
 #0     string  \xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E\x00\x03\x00\xFE\xFF        Microsoft Installer
 0      string  \320\317\021\340\241\261\032\341        Microsoft Office Document
+#>48   byte    0x1B                                    Excel Document
+#!:mime        application/vnd.ms-excel
+>546   string  bjbj                    Microsoft Word Document
+!:mime application/msword
+>546   string  jbjb                    Microsoft Word Document
+!:mime application/msword
+
+0       string \224\246\056            Microsoft Word Document
+!:mime application/msword
+
+512    string  R\0o\0o\0t\0\ \0E\0n\0t\0r\0y   Microsoft Word Document
+!:mime application/msword
 
 # From: "Nelson A. de Oliveira" <naoliv@gmail.com>
 # Magic type for Dell's BIOS .hdr files
 0      string $RBU
 >23    string Dell                     %s system BIOS
 >48    string x                        version %.3s
-
index e90214efb9a6a5f6e781e6a2467e5efd782f5ffe..b3d6d1ac2c97e84630fd540ad0060b4560d32f80 100644 (file)
@@ -3,6 +3,7 @@
 #
 
 0      string          %PDF-           PDF document
+!:mime application/pdf
 >5     byte            x               \b, version %c
 >7     byte            x               \b.%c
 
index a8daee4c647c785413a498957bcd9cf0e340bbd6..89fca64ff3a85d272f34bc49224b4f9596e7ffbc 100644 (file)
@@ -6,12 +6,19 @@
 # Keith Waclena <keith@cerberus.uchicago.edu>
 # Send additions to <perl5-porters@perl.org>
 0      string/b        #!\ /bin/perl                   perl script text executable
+!:mime application/x-perl
 0      string          eval\ "exec\ /bin/perl          perl script text
+!:mime application/x-perl
 0      string/b        #!\ /usr/bin/perl               perl script text executable
+!:mime application/x-perl
 0      string          eval\ "exec\ /usr/bin/perl      perl script text
+!:mime application/x-perl
 0      string/b        #!\ /usr/local/bin/perl         perl script text
+!:mime application/x-perl
 0      string          eval\ "exec\ /usr/local/bin/perl        perl script text executable
+!:mime application/x-perl
 0      string          eval\ '(exit\ $?0)'\ &&\ eval\ 'exec    perl script text
+!:mime application/x-perl
 
 
 # by Dmitry V. Levin and Alexey Tourbin
index 038d098ee4acd41c0b090e06b2d908d6de017d9c..88519b77726916b11a555a97ae02ae9767b252a0 100644 (file)
@@ -1,12 +1,18 @@
 
 #------------------------------------------------------------------------------
 # pgp:  file(1) magic for Pretty Good Privacy
+# see http://lists.gnupg.org/pipermail/gnupg-devel/1999-September/016052.html
 #
 0       beshort         0x9900                  PGP key public ring
+!:mime application/x-pgp-keyring
 0       beshort         0x9501                  PGP key security ring
+!:mime application/x-pgp-keyring
 0       beshort         0x9500                  PGP key security ring
+!:mime application/x-pgp-keyring
 0      beshort         0xa600                  PGP encrypted data
+!:mime application/pgp-encrypted
 0       string          -----BEGIN\040PGP       PGP armored data
+!:mime text/PGP # encoding: armored data
 >15     string          PUBLIC\040KEY\040BLOCK- public key block
 >15     string          MESSAGE-                message
 >15     string          SIGNED\040MESSAGE-      signed message
index dc8ef5d93ab4dd99c39afd49303e5da8887a9a8d..876dacd79cd41b02b28e482d544ac1d458ca4a74 100644 (file)
@@ -3,3 +3,4 @@
 # pkgadd:  file(1) magic for SysV R4 PKG Datastreams
 #
 0       string          #\ PaCkAgE\ DaTaStReAm  pkg Datastream (SVR4)
+!:mime application/x-svr4-package
index 77ba7809748b05f3ddcd68fc15170efa11b9fb0b..552808facd1e77af62871b5ccc6aa368d19df614 100644 (file)
@@ -5,6 +5,7 @@
 
 # PostScript, updated by Daniel Quinlan (quinlan@yggdrasil.com)
 0      string          %!              PostScript document text
+!:mime application/postscript
 >2     string          PS-Adobe-       conforming
 >>11   string          >\0             at level %.3s
 >>>15  string          EPS             - type %s
@@ -12,6 +13,7 @@
 >>>15  string          ExitServer      - type %s
 # Some PCs have the annoying habit of adding a ^D as a document separator
 0      string          \004%!          PostScript document text
+!:mime application/postscript
 >3     string          PS-Adobe-       conforming
 >>12   string          >\0             at level %.3s
 >>>16  string          EPS             - type %s
index 5aa9d109388d25c92aabf26d51c2a677f20270d9..6d246458fada86d5d6f01874c19caeb1b889f5e1 100644 (file)
@@ -33,6 +33,7 @@
 >8     string          RMP3            \b, MPEG Layer 3 audio
 # Microsoft WAVE format (*.wav)
 >8     string          WAVE            \b, WAVE audio
+!:mime audio/x-wav
 >>20   leshort         1               \b, Microsoft PCM
 >>>34  leshort         >0              \b, %d bit
 >>20   leshort         2               \b, Microsoft ADPCM
 >>24   lelong          >0              %d Hz
 # Corel Draw Picture
 >8     string          CDRA            \b, Corel Draw Picture
+!:mime image/x-coreldraw
 # AVI == Audio Video Interleave
 >8     string          AVI\040         \b, AVI
+!:mime video/x-msvideo
 >>12    string          LIST
 >>>20   string          hdrlavih
 >>>>&36 lelong          x               \b, %lu x
index 09ee51b4f026f6660f14d3957f37f78a583fe062..6d7e850bb7dfe5c9ce23cfde3f6741ea02e09404 100644 (file)
@@ -4,6 +4,7 @@
 #
 0      beshort         0xedab
 >2     beshort         0xeedb          RPM
+!:mime application/x-rpm
 >>4    byte            x               v%d
 >>6    beshort         0               bin
 >>6    beshort         1               src
@@ -13,7 +14,7 @@
 >>8    beshort         4               MIPS
 >>8    beshort         5               PowerPC
 >>8    beshort         6               68000
->>8    beshort         7       SGI
+>>8    beshort         7               SGI
 >>8    beshort         8               RS6000
 >>8    beshort         9               IA64
 >>8    beshort         10              Sparc64
index 8e2d4166fa58dc56e40dd2dd07aae81ce07843dc..19465ff7a1b8914d3e8fbfac5a34b7a773b1bc42 100644 (file)
@@ -5,6 +5,7 @@
 # Duncan P. Simpson, D.P.Simpson@dcs.warwick.ac.uk
 #
 0      string          {\\rtf          Rich Text Format data,
+!:mime text/rtf
 >5     byte            x               version %c,
 >6     string          \\ansi          ANSI
 >6     string          \\mac           Apple Macintosh
index 98599f264781f65a75e673d63dc57a1803104e3e..72027d69ebfff823e076587d2d37180aba004eee 100644 (file)
@@ -3,3 +3,4 @@
 # sc:  file(1) magic for "sc" spreadsheet
 #
 38     string          Spreadsheet     sc spreadsheet file
+!:mime application/x-sc
index ba6c3ef8971b2a8e0ecf59fd5db2af2ed94d09d1..b9cf07a6f4d3ecd0ef4bdca9793acd56e9c17fab 100644 (file)
@@ -1,13 +1,23 @@
+# Type:        SVG Vectorial Graphics
+# From:        Noel Torres <tecnico@ejerciciosresueltos.com>
+0      string  \<?xml\ version="
+>15    string  >\0
+>>23   regex   .*\<svg                 SVG Scalable Vector Graphics image
+!:mime image/svg+xml
 
 #------------------------------------------------------------------------------
 # sgml:  file(1) magic for Standard Generalized Markup Language
 # HyperText Markup Language (HTML) is an SGML document type,
 # from Daniel Quinlan (quinlan@yggdrasil.com)
 # adapted to string extenstions by Anthon van der Neut <anthon@mnt.org)
-0   string/cB  \<!DOCTYPE\ html        HTML document text
-0   string/cb  \<head                  HTML document text
-0   string/cb  \<title                 HTML document text
-0   string/cb  \<html                  HTML document text
+0      string/cB       \<!DOCTYPE\ html        HTML document text
+!:mime text/html
+0      string/cb       \<head                  HTML document text
+!:mime text/html
+0      string/cb       \<title                 HTML document text
+!:mime text/html
+0      string/cb       \<html                  HTML document text
+!:mime text/html
 
 # Extensible markup language (XML), a subset of SGML
 # from Marc Prud'hommeaux (marc@apocalypse.org)
index 52adb8704a2f7eac6d973e63e9dd61c5dd03e09e..6228e7ed2d56c1e455475baf48f92b3af71c7c05 100644 (file)
@@ -2,12 +2,15 @@
 #------------------------------------------------------------------------------
 # tex:  file(1) magic for TeX files
 #
+# XXX - needs byte-endian stuff (big-endian and little-endian DVI?)
+#
 # From <conklin@talisman.kaleida.com>
 
 # Although we may know the offset of certain text fields in TeX DVI
 # and font files, we can't use them reliably because they are not
 # zero terminated. [but we do anyway, christos]
 0      string          \367\002        TeX DVI file
+!:mime application/x-dvi
 >16    string          >\0             (%s)
 0      string          \367\203        TeX generic font data
 0      string          \367\131        TeX packed font data
 # breaking them apart and reading the data.  The following patterns
 # match most *.tfm files generated by METAFONT or afm2tfm.
 2      string          \000\021        TeX font metric data
+!:mime application/x-tex-tfm
 >33    string          >\0             (%s)
 2      string          \000\022        TeX font metric data
+!:mime application/x-tex-tfm
 >33    string          >\0             (%s)
 
 # Texinfo and GNU Info, from Daniel Quinlan (quinlan@yggdrasil.com)
 0      string          \\input\ texinfo        Texinfo source text
+!:mime text/x-texinfo
 0      string          This\ is\ Info\ file    GNU Info text
+!:mime text/x-info
 
 # TeX documents, from Daniel Quinlan (quinlan@yggdrasil.com)
 0      search/400      \\input         TeX document text
+!:mime text/x-tex
 0      search/400      \\section       LaTeX document text
+!:mime text/x-tex
 0      search/400      \\setlength     LaTeX document text
+!:mime text/x-tex
 0      search/400      \\documentstyle LaTeX document text
+!:mime text/x-tex
 0      search/400      \\chapter       LaTeX document text
+!:mime text/x-tex
 0      search/400      \\documentclass LaTeX 2e document text
+!:mime text/x-tex
 0      search/400      \\relax         LaTeX auxiliary file
+!:mime text/x-tex
 0      search/400      \\contentsline  LaTeX table of contents
+!:mime text/x-tex
 0      search/400      %\ -*-latex-*-  LaTeX document text
+!:mime text/x-tex
 
 # Tex document, from Hendrik Scholz <hendrik@scholz.net>
 0   string      \\ifx       TeX document text
index 5957ea0d2782edf15467c9662f995341649aaf13..23c5e402e96257665fc27a5217ae6c9d25bc2b0b 100644 (file)
@@ -13,6 +13,7 @@
 #
 # --- Ogg Framing ---
 0              string          OggS            Ogg data
+!:mime         application/ogg
 >4             byte            !0              UNKNOWN REVISION %u
 ##>4           byte            0               revision 0
 >4             byte            0
index 546d2616d9651bdfdd803e9c276d2ec269e14a98..c55f7c9585362c76144b6ae147f19cff759c74b6 100644 (file)
 0      string  HWP\ Document\ File     Hangul (Korean) Word Processor File 3.0
 # From: Won-Kyu Park <wkpark@kldp.org>
 512    string          R\0o\0o\0t\0    Hangul (Korean) Word Processor File 2000
+!:mime application/x-hwp
 
 # CosmicBook, from Benoît Rouits
 0       string  CSBK    Ted Neslson's CosmicBook hypertext file
 2      string  IIXPR3                  Intel Quark Express Document (English)
 2      string  IIXPRa                  Intel Quark Express Document (Korean)
 2      string  MMXPR3                  Motorola Quark Express Document (English)
+!:mime application/x-quark-xpress-3
 2      string  MMXPRa                  Motorola Quark Express Document (Korean)
 
 # adobe indesign (document, whatever...) from querkan
 0      string          X\ hp           SoftQuad troff Context intermediate for HP LaserJet
 0      string          X\ impr         SoftQuad troff Context intermediate for IMAGEN imPRESS
 0      string          X\ ps           SoftQuad troff Context intermediate for PostScript
+
+#------------------------------------------------------------------------------
+# ichitaro456: file(1) magic for Just System Word Processor Ichitaro
+#
+# Contributor kenzo-:
+# Reversed-engineered JS Ichitaro magic numbers
+#
+
+0      string          DOC
+>43    byte            0x14    Just System Word Processor Ichitaro v4
+!:mime application/x-ichitaro4
+>144   string  JDASH           application/x-ichitaro4
+
+0      string          DOC
+>43    byte            0x15    Just System Word Processor Ichitaro v5
+!:mime application/x-ichitaro5
+
+0      string          DOC
+>43    byte            0x16    Just System Word Processor Ichitaro v6
+!:mime application/x-ichitaro6
index f7bd3383205a8542d79b8a3909fa0ccc93ea6db5..5413522744546d464e009c6cd9a867ea90fb2d77 100644 (file)
@@ -1,10 +1,10 @@
-pkgdata_DATA = magic magic.mime magic.mgc magic.mime.mgc
+pkgdata_DATA = magic magic.mgc
 
-EXTRA_DIST = magic2mime Localstuff Header magic.mime $(magic_FRAGMENTS)
+EXTRA_DIST = Localstuff Header $(magic_FRAGMENTS)
 
-CLEANFILES =  magic magic.mgc magic.mime.mgc
+CLEANFILES =  magic magic.mgc
 
-magic: Header Localstuff $(magic_FRAGMENTS)
+magic: Header Localstuff $(magic_FRAGMENTS) $(top_builddir)/src/file
        cat $(srcdir)/Header $(srcdir)/Localstuff > $@
        for frag in $(magic_FRAGMENTS); do \
          if test -f $(srcdir)/$$frag; then \
@@ -15,6 +15,8 @@ magic: Header Localstuff $(magic_FRAGMENTS)
           cat $$f; \
        done >> $@
 
+# FIXME: Build file natively as well so that it can be used to compile
+# the target's magic file
 if IS_CROSS_COMPILE
 FILE_COMPILE = file
 else
@@ -24,9 +26,6 @@ endif
 magic.mgc: magic
        $(FILE_COMPILE) -C -m magic
 
-magic.mime.mgc: magic.mime
-       $(FILE_COMPILE) -C -m $(srcdir)/magic.mime
-
 magic_FRAGMENTS = \
 Magdir/acorn \
 Magdir/adi \
@@ -51,23 +50,22 @@ Magdir/blit \
 Magdir/bout \
 Magdir/bsdi \
 Magdir/btsnoop \
+Magdir/c64 \
 Magdir/cad \
 Magdir/cafebabe \
-Magdir/c-lang \
-Magdir/c64 \
 Magdir/cddb \
 Magdir/chord \
 Magdir/cisco \
 Magdir/citrus \
+Magdir/c-lang \
 Magdir/claris \
 Magdir/clipper \
-Magdir/cracklib \
-Magdir/spec \
 Magdir/commands \
 Magdir/communications \
 Magdir/compress \
 Magdir/console \
 Magdir/convex \
+Magdir/cracklib \
 Magdir/ctags \
 Magdir/dact \
 Magdir/database \
@@ -76,6 +74,7 @@ Magdir/diff \
 Magdir/digital \
 Magdir/dolby \
 Magdir/dump \
+Magdir/dyadic \
 Magdir/editors \
 Magdir/efi \
 Magdir/elf \
@@ -91,8 +90,8 @@ Magdir/frame \
 Magdir/freebsd \
 Magdir/fsav \
 Magdir/games \
-Magdir/geos \
 Magdir/gcc \
+Magdir/geos \
 Magdir/gimp \
 Magdir/gnu \
 Magdir/grace \
@@ -173,6 +172,7 @@ Magdir/rpm \
 Magdir/rtf \
 Magdir/sc \
 Magdir/sccs \
+Magdir/scientific \
 Magdir/sendmail \
 Magdir/sequent \
 Magdir/sgi \
@@ -182,9 +182,8 @@ Magdir/sinclair \
 Magdir/sketch \
 Magdir/smalltalk \
 Magdir/sniffer \
-Magdir/dyadic \
-Magdir/scientific \
 Magdir/softquad \
+Magdir/spec \
 Magdir/spectrum \
 Magdir/sql \
 Magdir/sun \
@@ -198,8 +197,8 @@ Magdir/timezone \
 Magdir/troff \
 Magdir/tuxedo \
 Magdir/typeset \
-Magdir/unknown \
 Magdir/unicode \
+Magdir/unknown \
 Magdir/uuencode \
 Magdir/varied.out \
 Magdir/varied.script \
index dfa62de4b8d81cae0d0bc49cbbf767f0b0059db3..2c81e99690a8e858fae22782ba4e32c2725e790c 100644 (file)
 # Localstuff:  file(1) magic for locally observed files
 # Add any locally observed files here.
 
-# Real Audio (Magic .ra\0375)
-0      belong          0x2e7261fd      audio/x-pn-realaudio
-0      string          .RMF            application/vnd.rn-realmedia
-
-#video/x-pn-realvideo
-#video/vnd.rn-realvideo
-#application/vnd.rn-realmedia
-#      sigh, there are many mimes for that but the above are the most common.
-
-# Taken from magic, converted to magic.mime
-# mime types according to http://www.geocities.com/nevilo/mod.htm:
-#      audio/it        .it
-#      audio/x-zipped-it       .itz
-#      audio/xm        fasttracker modules
-#      audio/x-s3m     screamtracker modules
-#      audio/s3m       screamtracker modules
-#      audio/x-zipped-mod      mdz
-#      audio/mod       mod
-#      audio/x-mod     All modules (mod, s3m, 669, mtm, med, xm, it, mdz, stm, itz, xmz, s3z)
-
-# Taken from loader code from mikmod version 2.14
-# by Steve McIntyre (stevem@chiark.greenend.org.uk)
-# <doj@cubic.org> added title printing on 2003-06-24
-0      string  MAS_UTrack_V00
->14    string  >/0             audio/x-mod
-#audio/x-tracker-module
-
-#0     string  UN05            MikMod UNI format module sound data
-
-0      string  Extended\ Module: audio/x-mod
-#audio/x-tracker-module
-##>17  string  >\0             Title: "%s"
-
-21     string/c        \!SCREAM!       audio/x-mod
-#audio/x-screamtracker-module
-21     string  BMOD2STM        audio/x-mod
-#audio/x-screamtracker-module
-1080   string  M.K.            audio/x-mod
-#audio/x-protracker-module
-#>0    string  >\0             Title: "%s"
-1080   string  M!K!            audio/x-mod
-#audio/x-protracker-module
-#>0    string  >\0             Title: "%s"
-1080   string  FLT4            audio/x-mod
-#audio/x-startracker-module
-#>0    string  >\0             Title: "%s"
-1080   string  FLT8            audio/x-mod
-#audio/x-startracker-module
-#>0    string  >\0             Title: "%s"
-1080   string  4CHN            audio/x-mod
-#audio/x-fasttracker-module
-#>0    string  >\0             Title: "%s"
-1080   string  6CHN            audio/x-mod
-#audio/x-fasttracker-module
-#>0    string  >\0             Title: "%s"
-1080   string  8CHN            audio/x-mod
-#audio/x-fasttracker-module
-#>0    string  >\0             Title: "%s"
-1080   string  CD81            audio/x-mod
-#audio/x-oktalyzer-tracker-module
-#>0    string  >\0             Title: "%s"
-1080   string  OKTA            audio/x-mod
-#audio/x-oktalyzer-tracker-module
-#>0    string  >\0             Title: "%s"
-# Not good enough.
-#1082  string  CH
-#>1080 string  >/0             %.2s-channel Fasttracker "oktalyzer" module sound data
-1080   string  16CN            audio/x-mod
-#audio/x-taketracker-module
-#>0    string  >\0             Title: "%s"
-1080   string  32CN            audio/x-mod
-#audio/x-taketracker-module
-#>0    string  >\0             Title: "%s"
-
-# Impuse tracker module (it)
-0      string          IMPM            audio/x-mod
-#>4    string          >\0             "%s"
-#>40   leshort         !0              compatible w/ITv%x
-#>42   leshort         !0              created w/ITv%x
-
 #------------------------------------------------------------------------------
 # end local stuff
 #------------------------------------------------------------------------------
-
-# xml based formats!
-
-# svg
-
-38     string          \<\!DOCTYPE\040svg      image/svg+xml
-
-0      belong          0xfeedfeed      application/x-java-keystore
-
-0      belong          0xcececece      application/x-java-jce-keystore
-
-
-# xml
-0      string          \<?xml                  text/xml
-
-
-#------------------------------------------------------------------------------
-# Java
-
-0      beshort         0xcafe
->2     beshort         0xbabe          application/x-java-applet
->2     beshort         0xd00d          application/x-java-pack200
-
-#------------------------------------------------------------------------------
-# audio:  file(1) magic for sound formats
-#
-# from Jan Nicolai Langfeldt <janl@ifi.uio.no>,
-#
-
-# Sun/NeXT audio data
-0      string          .snd
->12    belong          1               audio/basic
->12    belong          2               audio/basic
->12    belong          3               audio/basic
->12    belong          4               audio/basic
->12    belong          5               audio/basic
->12    belong          6               audio/basic
->12    belong          7               audio/basic
-
->12    belong          23              audio/x-adpcm
-
-# DEC systems (e.g. DECstation 5000) use a variant of the Sun/NeXT format
-# that uses little-endian encoding and has a different magic number
-# (0x0064732E in little-endian encoding).
-0      lelong          0x0064732E
->12    lelong          1               audio/x-dec-basic
->12    lelong          2               audio/x-dec-basic
->12    lelong          3               audio/x-dec-basic
->12    lelong          4               audio/x-dec-basic
->12    lelong          5               audio/x-dec-basic
->12    lelong          6               audio/x-dec-basic
->12    lelong          7               audio/x-dec-basic
-#                                       compressed (G.721 ADPCM)
->12    lelong          23              audio/x-dec-adpcm
-
-# Bytes 0-3 of AIFF, AIFF-C, & 8SVX audio files are "FORM"
-#                                      AIFF audio data
-8      string          AIFF            audio/x-aiff
-#                                      AIFF-C audio data
-8      string          AIFC            audio/x-aiff
-#                                      IFF/8SVX audio data
-8      string          8SVX            audio/x-aiff
-
-
-
-# Creative Labs AUDIO stuff
-#                                      Standard MIDI data
-0      string  MThd                    audio/x-midi
-#>9    byte    >0                      (format %d)
-#>11   byte    >1                      using %d channels
-#                                      Creative Music (CMF) data
-0      string  CTMF                    audio/x-unknown
-#                                      SoundBlaster instrument data
-0      string  SBI                     audio/x-unknown
-#                                      Creative Labs voice data
-0      string  Creative\ Voice\ File   audio/x-unknown
-## is this next line right?  it came this way...
-#>19   byte    0x1A
-#>23   byte    >0                      - version %d
-#>22   byte    >0                      \b.%d
-
-# [GRR 950115:  is this also Creative Labs?  Guessing that first line
-#  should be string instead of unknown-endian long...]
-#0     long            0x4e54524b      MultiTrack sound data
-#0     string          NTRK            MultiTrack sound data
-#>4    long            x               - version %ld
-
-# Microsoft WAVE format (*.wav)
-# [GRR 950115:  probably all of the shorts and longs should be leshort/lelong]
-#                                      Microsoft RIFF
-0      string          RIFF
-#                                      - WAVE format
->8     string          WAVE            audio/x-wav
->8     string/B        AVI             video/x-msvideo
-#
->8     string          CDRA            image/x-coreldraw
-
-# AAC (aka MPEG-2 NBC)
-0       beshort&0xfff6    0xfff0          audio/X-HX-AAC-ADTS
-0       string          ADIF            audio/X-HX-AAC-ADIF
-0       beshort&0xffe0  0x56e0          audio/MP4A-LATM
-0       beshort         0x4De1          audio/MP4A-LATM
-
-# MPEG Layer 3 sound files
-# modified by Joerg Jenderek
-# GRR the original test are too common for many DOS files
-# so test 1 <= kbits nibble <= E
-0       beshort                &0xffe0         
->2     ubyte&0xF0      >0x0F           
->>2    ubyte&0xF0      <0xE1           audio/mpeg
-#MP3 with ID3 tag
-0      string          ID3             audio/mpeg
-# Ogg/Vorbis
-0      string          OggS            application/ogg
-
-#------------------------------------------------------------------------------
-# c-lang:  file(1) magic for C programs or various scripts
-#
-
-# XPM icons (Greg Roelofs, newt@uchicago.edu)
-# ideally should go into "images", but entries below would tag XPM as C source
-0      string          /*\ XPM         image/x-xpmi
-
-# 3DS (3d Studio files) Conflicts with diff output 0x3d '='
-#16    beshort         0x3d3d          image/x-3ds
-
-# this first will upset you if you're a PL/1 shop... (are there any left?)
-# in which case rm it; ascmagic will catch real C programs
-#                                      C or REXX program text
-#0     string          /*              text/x-c
-#                                      C++ program text
-#0     string          //              text/x-c++
-
-#------------------------------------------------------------------------------
-# commands:  file(1) magic for various shells and interpreters
-#
-#0       string          :\ shell archive or commands for antique kernel text
-0       string          #!/bin/sh               application/x-shellscript
-0       string          #!\ /bin/sh             application/x-shellscript
-0       string          #!/bin/csh              application/x-shellscript
-0       string          #!\ /bin/csh            application/x-shellscript
-# korn shell magic, sent by George Wu, gwu@clyde.att.com
-0       string          #!/bin/ksh              application/x-shellscript
-0       string          #!\ /bin/ksh            application/x-shellscript
-0       string          #!/bin/tcsh             application/x-shellscript
-0       string          #!\ /bin/tcsh           application/x-shellscript
-0       string          #!/usr/local/tcsh       application/x-shellscript
-0       string          #!\ /usr/local/tcsh     application/x-shellscript
-0       string          #!/usr/local/bin/tcsh   application/x-shellscript
-0       string          #!\ /usr/local/bin/tcsh application/x-shellscript
-# bash shell magic, from Peter Tobias (tobias@server.et-inf.fho-emden.de)
-0       string          #!/bin/bash                    application/x-shellscript
-0       string          #!\ /bin/bash           application/x-shellscript
-0       string          #!/usr/local/bin/bash   application/x-shellscript
-0       string          #!\ /usr/local/bin/bash application/x-shellscript
-
-#
-# zsh/ash/ae/nawk/gawk magic from cameron@cs.unsw.oz.au (Cameron Simpson)
-0       string          #!/bin/zsh             application/x-shellscript
-0       string          #!/usr/bin/zsh         application/x-shellscript
-0       string          #!/usr/local/bin/zsh    application/x-shellscript
-0       string          #!\ /usr/local/bin/zsh  application/x-shellscript
-0       string          #!/usr/local/bin/ash    application/x-shellscript
-0       string          #!\ /usr/local/bin/ash  application/x-shellscript
-#0       string          #!/usr/local/bin/ae     Neil Brown's ae
-#0       string          #!\ /usr/local/bin/ae   Neil Brown's ae
-0       string          #!/bin/nawk             application/x-nawk
-0       string          #!\ /bin/nawk           application/x-nawk
-0       string          #!/usr/bin/nawk         application/x-nawk
-0       string          #!\ /usr/bin/nawk       application/x-nawk
-0       string          #!/usr/local/bin/nawk   application/x-nawk
-0       string          #!\ /usr/local/bin/nawk application/x-nawk
-0       string          #!/bin/gawk             application/x-gawk
-0       string          #!\ /bin/gawk           application/x-gawk
-0       string          #!/usr/bin/gawk         application/x-gawk
-0       string          #!\ /usr/bin/gawk       application/x-gawk
-0       string          #!/usr/local/bin/gawk   application/x-gawk
-0       string          #!\ /usr/local/bin/gawk application/x-gawk
-#
-0       string          #!/bin/awk              application/x-awk
-0       string          #!\ /bin/awk            application/x-awk
-0       string          #!/usr/bin/awk          application/x-awk
-0       string          #!\ /usr/bin/awk        application/x-awk
-# update to distinguish from *.vcf files by Joerg Jenderek: joerg dot jenderek at web dot de
-# Too general, \EBEGIN matches in postscript
-#0     regex           BEGIN[[:space:]]*[{]    application/x-awk
-
-# For Larry Wall's perl language.  The ``eval'' line recognizes an
-# outrageously clever hack for USG systems.
-#                               Keith Waclena <keith@cerberus.uchicago.edu>
-0       string          #!/bin/perl                     application/x-perl
-0       string          #!\ /bin/perl                   application/x-perl
-0       string          eval\ "exec\ /bin/perl          application/x-perl
-0       string          #!/usr/bin/perl                 application/x-perl
-0       string          #!\ /usr/bin/perl               application/x-perl
-0       string          eval\ "exec\ /usr/bin/perl      application/x-perl
-0       string          #!/usr/local/bin/perl           application/x-perl
-0       string          #!\ /usr/local/bin/perl         application/x-perl
-0       string          eval\ "exec\ /usr/local/bin/perl application/x-perl
-
-#------------------------------------------------------------------------------
-# compress:  file(1) magic for pure-compression formats (no archives)
-#
-# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, whap, etc.
-#
-# Formats for various forms of compressed data
-# Formats for "compress" proper have been moved into "compress.c",
-# because it tries to uncompress it to figure out what's inside.
-
-# standard unix compress
-0      string          \037\235        application/x-compress
-
-# gzip (GNU zip, not to be confused with [Info-ZIP/PKWARE] zip archiver)
-0       string          \037\213        application/x-gzip
-
-0              string                  PK\003\004              application/zip
-
-# RAR archiver (Greg Roelofs, newt@uchicago.edu)
-0      string          Rar!            application/x-rar
-
-# According to gzip.h, this is the correct byte order for packed data.
-0      string          \037\036        application/octet-stream
-#
-# This magic number is byte-order-independent.
-#
-0      short           017437          application/octet-stream
-
-# XXX - why *two* entries for "compacted data", one of which is
-# byte-order independent, and one of which is byte-order dependent?
-#
-# compacted data
-0      short           0x1fff          application/octet-stream
-0      string          \377\037        application/octet-stream
-# huf output
-0      short           0145405         application/octet-stream
-
-# Squeeze and Crunch...
-# These numbers were gleaned from the Unix versions of the programs to
-# handle these formats.  Note that I can only uncrunch, not crunch, and
-# I didn't have a crunched file handy, so the crunch number is untested.
-#                              Keith Waclena <keith@cerberus.uchicago.edu>
-#0     leshort         0x76FF          squeezed data (CP/M, DOS)
-#0     leshort         0x76FE          crunched data (CP/M, DOS)
-
-# Freeze
-#0     string          \037\237        Frozen file 2.1
-#0     string          \037\236        Frozen file 1.0 (or gzip 0.5)
-
-# lzh?
-#0     string          \037\240        LZH compressed data
-
-257    string          ustar\0         application/x-tar       posix
-257    string          ustar\040\040\0         application/x-tar       gnu
-
-0      short           070707          application/x-cpio
-0      short           0143561         application/x-cpio      swapped
-
-0      string          =<ar>           application/x-archive
-0      string          \!<arch>        application/x-archive
->8     string          debian          application/x-debian-package
-
-#------------------------------------------------------------------------------
-#
-# RPM: file(1) magic for Red Hat Packages   Erik Troan (ewt@redhat.com)
-#
-0       beshort         0xedab
->2      beshort         0xeedb          application/x-rpm
-
-0      lelong&0x8080ffff       0x0000081a      application/x-arc       lzw
-0      lelong&0x8080ffff       0x0000091a      application/x-arc       squashed
-0      lelong&0x8080ffff       0x0000021a      application/x-arc       uncompressed
-0      lelong&0x8080ffff       0x0000031a      application/x-arc       packed
-0      lelong&0x8080ffff       0x0000041a      application/x-arc       squeezed
-0      lelong&0x8080ffff       0x0000061a      application/x-arc       crunched
-
-0      leshort 0xea60  application/x-arj
-
-# LHARC/LHA archiver (Greg Roelofs, newt@uchicago.edu)
-2      string  -lh0-   application/x-lharc     lh0
-2      string  -lh1-   application/x-lharc     lh1
-2      string  -lz4-   application/x-lharc     lz4
-2      string  -lz5-   application/x-lharc     lz5
-#      [never seen any but the last; -lh4- reported in comp.compression:]
-2      string  -lzs-   application/x-lha       lzs
-2      string  -lh\ -  application/x-lha       lh
-2      string  -lhd-   application/x-lha       lhd
-2      string  -lh2-   application/x-lha       lh2
-2      string  -lh3-   application/x-lha       lh3
-2      string  -lh4-   application/x-lha       lh4
-2      string  -lh5-   application/x-lha       lh5
-2      string  -lh6-   application/x-lha       lh6
-2      string  -lh7-   application/x-lha       lh7
-# Shell archives
-10     string  #\ This\ is\ a\ shell\ archive  application/octet-stream        x-shell
-
-#------------------------------------------------------------------------------
-# frame:  file(1) magic for FrameMaker files
-#
-# This stuff came on a FrameMaker demo tape, most of which is
-# copyright, but this file is "published" as witness the following:
-#
-# Note that this is the Framemaker Maker Interchange Format, not the
-# Normal format which would be application/vnd.framemaker.
-#
-0      string          \<MakerFile     application/x-mif
-0      string          \<MIFFile       application/x-mif
-0      string          \<MakerDictionary       application/x-mif
-0      string          \<MakerScreenFon        application/x-mif
-0      string          \<MML           application/x-mif
-0      string          \<Book          application/x-mif
-0      string          \<Maker         application/x-mif
-
-#------------------------------------------------------------------------------
-# html:  file(1) magic for HTML (HyperText Markup Language) docs
-#
-# from Daniel Quinlan <quinlan@yggdrasil.com>
-#
-0      string          \<HEAD  text/html
-0      string          \<head  text/html
-0      string          \<TITLE text/html
-0      string          \<title text/html
-0       string          \<html text/html
-0       string          \<HTML text/html
-0      string          \<!--   text/html
-0      string          \<h1    text/html
-0      string          \<H1    text/html
-0      string/c        \<!doctype\ html        text/html
-
-#------------------------------------------------------------------------------
-# images:  file(1) magic for image formats (see also "c-lang" for XPM bitmaps)
-#
-# originally from jef@helios.ee.lbl.gov (Jef Poskanzer),
-# additions by janl@ifi.uio.no as well as others. Jan also suggested
-# merging several one- and two-line files into here.
-#
-# XXX - byte order for GIF and TIFF fields?
-# [GRR:  TIFF allows both byte orders; GIF is probably little-endian]
-#
-
-# [GRR:  what the hell is this doing in here?]
-#0     string          xbtoa           btoa'd file
-
-# PBMPLUS
-#                                      PBM file
-0      string          P1              image/x-portable-bitmap
-#                                      PGM file
-0      string          P2              image/x-portable-greymap
-#                                      PPM file
-0      string          P3              image/x-portable-pixmap
-#                                      PBM "rawbits" file
-0      string          P4              image/x-portable-bitmap
-#                                      PGM "rawbits" file
-0      string          P5              image/x-portable-greymap
-#                                      PPM "rawbits" file
-0      string          P6              image/x-portable-pixmap
-
-# NIFF (Navy Interchange File Format, a modification of TIFF)
-# [GRR:  this *must* go before TIFF]
-0      string          IIN1            image/x-niff
-
-# TIFF and friends
-#                                      TIFF file, big-endian
-0      string          MM              image/tiff
-#                                      TIFF file, little-endian
-0      string          II              image/tiff
-
-# possible GIF replacements; none yet released!
-# (Greg Roelofs, newt@uchicago.edu)
-#
-# GRR 950115:  this was mine ("Zip GIF"):
-#                                      ZIF image (GIF+deflate alpha)
-0      string          GIF94z          image/x-unknown
-#
-# GRR 950115:  this is Jeremy Wohl's Free Graphics Format (better):
-#                                      FGF image (GIF+deflate beta)
-0      string          FGF95a          image/x-unknown
-#
-# GRR 950115:  this is Thomas Boutell's Portable Bitmap Format proposal
-# (best; not yet implemented):
-#                                      PBF image (deflate compression)
-0      string          PBF             image/x-unknown
-
-# GIF
-0      string          GIF             image/gif
-
-# JPEG images
-0      beshort         0xffd8          image/jpeg
-
-# PC bitmaps (OS/2, Windoze BMP files)  (Greg Roelofs, newt@uchicago.edu)
-0      string          BM              image/bmp
-#>14   byte            12              (OS/2 1.x format)
-#>14   byte            64              (OS/2 2.x format)
-#>14   byte            40              (Windows 3.x format)
-#0     string          IC              icon
-#0     string          PI              pointer
-#0     string          CI              color icon
-#0     string          CP              color pointer
-#0     string          BA              bitmap array
-
-# CDROM Filesystems
-32769    string    CD001     application/x-iso9660-image
-
-# Newer StuffIt archives (grant@netbsd.org)
-0      string          StuffIt                 application/x-stuffit
-#>162  string          >0                      : %s
-
-# BinHex is the Macintosh ASCII-encoded file format (see also "apple")
-# Daniel Quinlan, quinlan@yggdrasil.com
-11     string  must\ be\ converted\ with\ BinHex\ 4    application/mac-binhex40
-##>41  string  x                                       \b, version %.3s
-
-
-#------------------------------------------------------------------------------
-# lisp:  file(1) magic for lisp programs
-#
-# various lisp types, from Daniel Quinlan (quinlan@yggdrasil.com)
-0      string  ;;                      text/plain
-# Emacs 18 - this is always correct, but not very magical.
-0      string  \012(                   application/x-elc
-# Emacs 19
-0      string  ;ELC\023\000\000\000    application/x-elc
-
-#------------------------------------------------------------------------------
-# mail.news:  file(1) magic for mail and news
-#
-# There are tests to ascmagic.c to cope with mail and news.
-0      string          Relay-Version:  message/rfc822
-0      string          #!\ rnews       message/rfc822
-0      string          N#!\ rnews      message/rfc822
-0      string          Forward\ to     message/rfc822
-0      string          Pipe\ to        message/rfc822
-0      string          Return-Path:    message/rfc822
-0      string          Received:       message/rfc822
-0      string          Path:           message/news
-0      string          Xref:           message/news
-0      string          From:           message/rfc822
-0      string          Article         message/news
-#------------------------------------------------------------------------------
-# msword: file(1) magic for MS Word files
-#
-# Contributor claims:
-# Reversed-engineered MS Word magic numbers
-#
-
-0      string          \376\067\0\043                  application/msword
-# disable this one because it applies also to other
-# Office/OLE documents for which msword is not correct. See PR#2608.
-# from magic file of the apache
-#0     string          \320\317\021\340\241\261        application/msword
-512    string          \354\245\301                    application/msword
-0      string          \333\245-\0\0\0                 application/msword
-
-
-
-#------------------------------------------------------------------------------
-# printer:  file(1) magic for printer-formatted files
-#
-
-# PostScript
-0      string          %!              application/postscript
-0      string          \004%!          application/postscript
-
-# Acrobat
-# (due to clamen@cs.cmu.edu)
-0      string          %PDF-           application/pdf
-
-#------------------------------------------------------------------------------
-# sc:  file(1) magic for "sc" spreadsheet
-#
-38     string          Spreadsheet     application/x-sc
-
-#------------------------------------------------------------------------------
-# tex:  file(1) magic for TeX files
-#
-# XXX - needs byte-endian stuff (big-endian and little-endian DVI?)
-#
-# From <conklin@talisman.kaleida.com>
-
-# Although we may know the offset of certain text fields in TeX DVI
-# and font files, we can't use them reliably because they are not
-# zero terminated. [but we do anyway, christos]
-0      string          \367\002        application/x-dvi
-#0     string          \367\203        TeX generic font data
-#0     string          \367\131        TeX packed font data
-#0     string          \367\312        TeX virtual font data
-#0     string          This\ is\ TeX,  TeX transcript text
-#0     string          This\ is\ METAFONT,     METAFONT transcript text
-
-# There is no way to detect TeX Font Metric (*.tfm) files without
-# breaking them apart and reading the data.  The following patterns
-# match most *.tfm files generated by METAFONT or afm2tfm.
-2      string          \000\021        application/x-tex-tfm
-2      string          \000\022        application/x-tex-tfm
-#>34   string          >\0             (%s)
-
-# Texinfo and GNU Info, from Daniel Quinlan (quinlan@yggdrasil.com)
-0      string          \\input\ texinfo                text/x-texinfo
-0      string          This\ is\ Info\ file    text/x-info
-
-# correct TeX magic for Linux (and maybe more)
-# from Peter Tobias (tobias@server.et-inf.fho-emden.de)
-#
-0      leshort         0x02f7          application/x-dvi
-
-# RTF - Rich Text Format
-0      string          {\\rtf          text/rtf
-
-# TeX documents, from Daniel Quinlan (quinlan@yggdrasil.com)
-0      search/400      \\input         text/x-tex
-0      search/400      \\section       text/x-tex
-0      search/400      \\setlength     text/x-tex
-0      search/400      \\documentstyle text/x-tex
-0      search/400      \\chapter       text/x-tex
-0      search/400      \\documentclass text/x-tex
-
-#------------------------------------------------------------------------------
-# animation:  file(1) magic for animation/movie formats
-#
-# animation formats, originally from vax@ccwf.cc.utexas.edu (VaX#n8)
-#                                              MPEG file
-# MPEG sequences
-0       belong             0x000001BA
->4      byte               &0x40          video/mp2p
->4      byte               ^0x40          video/mpeg
-0       belong             0x000001BB     video/mpeg
-0       belong             0x000001B0     video/mp4v-es
-0       belong             0x000001B5     video/mp4v-es
-0       belong             0x000001B3     video/mpv
-0       belong&0xFF5FFF1F  0x47400010     video/mp2t
-0       belong             0x00000001
->4      byte&0x1F         0x07           video/h264
-
-# FLI animation format
-0      leshort         0xAF11                          video/x-fli
-# FLC animation format
-0      leshort         0xAF12                          video/x-flc
-#
-# SGI and Apple formats
-# Added ISO mimes
-0      string          MOVI          video/x-sgi-movie
-4      string          moov          video/quicktime
-4      string          mdat          video/quicktime
-4      string          wide          video/quicktime
-4      string          skip          video/quicktime
-4      string          free          video/quicktime
-4      string          idsc          image/x-quicktime
-4      string          idat          image/x-quicktime
-4      string          pckg          application/x-quicktime-player
-4      string/B        jP            image/jp2
-4      string          ftyp
->8     string          isom          video/mp4
->8     string          mp41          video/mp4
->8     string          mp42          video/mp4
->8     string/B        jp2           image/jp2
->8     string          3gp           video/3gpp
->8      string          avc1          video/3gpp
->8     string          mmp4          video/mp4
->8     string/B        M4A           audio/mp4
->8     string/B        qt            video/quicktime
-# The contributor claims:
-#   I couldn't find a real magic number for these, however, this
-#   -appears- to work.  Note that it might catch other files, too,
-#   so BE CAREFUL!
-#
-# Note that title and author appear in the two 20-byte chunks
-# at decimal offsets 2 and 22, respectively, but they are XOR'ed with
-# 255 (hex FF)! DL format SUCKS BIG ROCKS.
-#
-#                                              DL file version 1 , medium format (160x100, 4 images/screen)
-0      byte            1                       video/x-unknown
-0      byte            2                       video/x-unknown
-#
-# Databases
-#
-# GDBM magic numbers
-#  Will be maintained as part of the GDBM distribution in the future.
-#  <downsj@teeny.org>
-0       belong  0x13579ace      application/x-gdbm
-0       lelong  0x13579ace      application/x-gdbm
-0       string  GDBM            application/x-gdbm
-#
-0       belong  0x061561        application/x-dbm
-#
-# Executables
-#
-0      string          \177ELF
->16    leshort         0               application/octet-stream
->16    leshort         1               application/x-object
->16    leshort         2               application/x-executable
->16    leshort         3               application/x-sharedlib
->16    leshort         4               application/x-coredump
->16    beshort         0               application/octet-stream
->16    beshort         1               application/x-object
->16    beshort         2               application/x-executable
->16    beshort         3               application/x-sharedlib
->16    beshort         4               application/x-coredump
-#
-# DOS
-0              string                  MZ                              application/x-dosexec
-#
-# KDE
-0              string  [KDE\ Desktop\ Entry]   application/x-kdelnk
-0              string  #\ KDE\ Config\ File    application/x-kdelnk
-# xmcd database file for kscd
-0              string  #\ xmcd                text/x-xmcd
-
-#------------------------------------------------------------------------------
-# pkgadd:  file(1) magic for SysV R4 PKG Datastreams
-#
-0       string          #\ PaCkAgE\ DaTaStReAm  application/x-svr4-package
-
-#PNG Image Format
-0      string          \x89PNG                 image/png
-
-# MNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
-0      string          \x8aMNG                 video/x-mng
-0      string          \x8aJNG                 video/x-jng
-
-#------------------------------------------------------------------------------
-# Hierarchical Data Format, used to facilitate scientific data exchange
-# specifications at http://hdf.ncsa.uiuc.edu/
-0      belong          0x0e031301      Hierarchical Data Format (version 4) data
-0      string          \211HDF\r\n\032 Hierarchical Data Format (version 5) data
-
-# Adobe Photoshop
-0      string          8BPS                    image/vnd.adobe.photoshop
-
-# Felix von Leitner <felix-file@fefe.de>
-0      string          d8:announce             application/x-bittorrent
-
-
-# lotus 1-2-3 document
-0      belong  0x00001a00      application/x-123
-0      belong  0x00000200      application/x-123
-
-# MS Access database
-4      string  Standard\ Jet\ DB       application/x-msaccess
-
-## magic for XBase files
-#0      byte       0x02
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0      byte       0x03
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0      byte       0x04
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0      byte       0x05
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0      byte       0x30
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0      byte       0x43
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0      byte       0x7b
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0      byte       0x83
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0      byte       0x8b
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0      byte       0x8e
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0      byte       0xb3
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0      byte       0xf5
-#>8     leshort          >0
-#>>12   leshort    0   application/x-dbf
-#
-#0     leshort         0x0006          application/x-dbt
-
-# Debian has entries for the old PGP formats:
-# pgp:  file(1) magic for Pretty Good Privacy
-# see http://lists.gnupg.org/pipermail/gnupg-devel/1999-September/016052.html
-0       beshort         0x9900                  application/x-pgp-keyring
-0       beshort         0x9501                  application/x-pgp-keyring
-0       beshort         0x9500                  application/x-pgp-keyring
-0       beshort         0xa600                  application/pgp-encrypted
-0       string          -----BEGIN\040PGP       text/PGP armored data
->15     string          PUBLIC\040KEY\040BLOCK- public key block
->15     string          MESSAGE-                message
->15     string          SIGNED\040MESSAGE-      signed message
->15     string          PGP\040SIGNATURE-       signature
-0       beshort         0x8501                  data
-#
-# GnuPG Magic:
-#
-0       beshort         0x9901                  application/x-gnupg-keyring
-0       beshort         0x8501                  text/OpenPGP data
-
-# flash:        file(1) magic for Macromedia Flash file format
-#
-# See
-#
-#       http://www.macromedia.com/software/flash/open/
-#
-0      string          FWS
->3     byte            x                       application/x-shockwave-flash
-# Flash Video
-0      string          FLV                     video/x-flv
-
-
-# The following paramaters are created for Namazu.
-# <http://www.namazu.org/>
-#
-# 1999/08/13
-#0     string          \<!--\ MHonArc          text/html; x-type=mhonarc
-0      string          BZh                     application/x-bzip2
-
-# 1999/09/09
-# VRML (suggested by Masao Takaku)
-0      string          #VRML\ V1.0\ ascii      model/vrml
-0      string          #VRML\ V2.0\ utf8       model/vrml
-
-#------------------------------------------------------------------------------
-# ichitaro456: file(1) magic for Just System Word Processor Ichitaro
-#
-# Contributor kenzo-:
-# Reversed-engineered JS Ichitaro magic numbers
-#
-
-0      string          DOC
->43    byte            0x14            application/x-ichitaro4
->144   string  JDASH           application/x-ichitaro4
-
-0      string          DOC
->43    byte            0x15            application/x-ichitaro5
-
-0      string          DOC
->43    byte            0x16            application/x-ichitaro6
-
-#------------------------------------------------------------------------------
-# office97: file(1) magic for MicroSoft Office files
-#
-# Contributor kenzo-:
-# Reversed-engineered MS Office magic numbers
-#
-
-#0       string          \320\317\021\340\241\261\032\341
-#>48     byte            0x1B            application/excel
-
-2080   string  Microsoft\ Excel\ 5.0\ Worksheet        application/vnd.ms-excel
-2114   string  Biff5                                   application/vnd.ms-excel
-
-0       string \224\246\056            application/msword
-
-0      belong  0x31be0000              application/msword
-
-0      string  PO^Q`                   application/msword
-
-0      string  \320\317\021\340\241\261\032\341
->546   string  bjbj                    application/msword
->546   string  jbjb                    application/msword
-
-512    string  R\0o\0o\0t\0\ \0E\0n\0t\0r\0y   application/msword
-
-2080   string  Microsoft\ Word\ 6.0\ Document  application/msword
-2080   string  Documento\ Microsoft\ Word\ 6   application/msword
-2112   string  MSWordDoc                       application/msword
-
-#0     string  \320\317\021\340\241\261\032\341        application/powerpoint
-0      string  \320\317\021\340\241\261\032\341        application/msword
-
-0       string  #\ PaCkAgE\ DaTaStReAm  application/x-svr4-package
-
-
-# WinNT/WinCE PE files (Warner Losh, imp@village.org)
-#
-128            string  PE\000\000      application/octet-stream
-0              string  PE\000\000      application/octet-stream
-
-# miscellaneous formats
-0              string  LZ              application/octet-stream
-
-# DOS device drivers by Joerg Jenderek
-0      belong          0xffffffff      application/octet-stream
-
-# .EXE formats (Greg Roelofs, newt@uchicago.edu)
-#
-0              string  MZ
->24            string  @               application/octet-stream
-
-0              string  MZ
->30            string  Copyright\ 1989-1990\ PKWARE\ Inc.      application/zip
-
-0              string  MZ
->30            string  PKLITE\ Copr.   application/zip
-
-0              string  MZ
->36            string  LHa's\ SFX      application/x-lha
-
-0              string  MZ              application/octet-stream
-
-# LHA archiver
-2              string  -lh
->6             string  -               application/x-lha
-
-
-# Zoo archiver
-20             lelong  0xfdc4a7dc      application/x-zoo
-
-# ARC archiver
-0              lelong&0x8080ffff       0x0000081a      application/x-arc
-0              lelong&0x8080ffff       0x0000091a      application/x-arc
-0              lelong&0x8080ffff       0x0000021a      application/x-arc
-0              lelong&0x8080ffff       0x0000031a      application/x-arc
-0              lelong&0x8080ffff       0x0000041a      application/x-arc
-0              lelong&0x8080ffff       0x0000061a      application/x-arc
-
-# Microsoft Outlook's Transport Neutral Encapsulation Format (TNEF)
-0              lelong  0x223e9f78      application/vnd.ms-tnef
-
-# From: stephane.loeuillet@tiscali.f
-# http://www.djvuzone.org/
-0      string          AT&TFORM        image/vnd.djvu
-
-# Danny Milosavljevic <danny.milo@gmx.net>
-# this are adrift (adventure game standard) game files, extension .taf
-# depending on version magic continues with 0x93453E6139FA (V 4.0)
-# 0x9445376139FA (V 3.90)
-# 0x9445366139FA (V 3.80)
-# this is from source (http://www.adrift.org.uk/) and I have some taf
-# files, and checked them.
-#0     belong  0x3C423FC9
-#>4    belong  0x6A87C2CF      application/x-adrift
-#0     string  \000\000\001\000        image/x-ico
-
-# Quark Xpress 3 Files:
-# (made the mimetype up)
-0      string  \0\0MMXPR3\0    application/x-quark-xpress-3
-
-# EET archive
-# From: Tilman Sauerbeck <tilman@code-monkey.de>
-0      belong  0x1ee7ff00      application/x-eet
-
-# From: Denis Knauf, via gentoo.
-0      string  fLaC            audio/x-flac
-0      string  CWS             application/x-shockwave-flash
-
-# Hangul Document Files:
-# Reversed-engineered HWP magic numbers
-# From: Won-Kyu Park <wkpark@kldp.org>
-512    string          R\0o\0o\0t\0    application/x-hwp
-
-0      string/c        BEGIN:VCARD     text/x-vcard
-0      string          WordPro\0       application/vnd.lotus-wordpro
-0      string          WordPro\r\373   application/vnd.lotus-wordpro
-0      string          CPC\262         image/x-cpi
-
-# 
-128    string          DICM            application/dicom
-
-# Symbian installation files
-8      lelong  0x10000419      application/vnd.symbian.install
-0      lelong  0x10201A7A      x-epoc/x-sisx-app
-# FORTRAN source
-0      string/c        c\              text/x-fortran
index 329db63fcaaae65420eafc3c1c9871471b936fff..abcacfee5873334567ae823f3c356f3f3de18296 100644 (file)
@@ -47,7 +47,7 @@
 #endif
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.110 2008/01/26 18:45:16 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.111 2008/01/28 00:14:38 christos Exp $")
 #endif /* lint */
 
 #define        EATAB {while (isascii((unsigned char) *l) && \
@@ -93,6 +93,8 @@ private const char *getstr(struct magic_set *, const char *, char *, int,
     int *, int);
 private int parse(struct magic_set *, struct magic_entry **, uint32_t *,
     const char *, size_t, int);
+private int parse_mime(struct magic_set *, struct magic_entry **, uint32_t *,
+    const char *);
 private void eatsize(const char **);
 private int apprentice_1(struct magic_set *, const char *, int, struct mlist *);
 private size_t apprentice_magic_strength(const struct magic *);
@@ -116,6 +118,9 @@ private int get_op(char);
 private size_t maxmagic = 0;
 private size_t magicsize = sizeof(struct magic);
 
+private const char usg_hdr[] = "cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
+private const char mime_marker[] = "!:mime";
+private const size_t mime_marker_len = sizeof(mime_marker) - 1;
 
 #ifdef COMPILE_ONLY
 
@@ -327,7 +332,6 @@ file_apprentice(struct magic_set *ms, const char *fn, int action)
        char *p, *mfn, *afn = NULL;
        int file_err, errs = -1;
        struct mlist *mlist;
-       static const char mime[] = ".mime";
 
        init_file_tables();
 
@@ -355,18 +359,6 @@ file_apprentice(struct magic_set *ms, const char *fn, int action)
                        *p++ = '\0';
                if (*fn == '\0')
                        break;
-               if (ms->flags & MAGIC_MIME) {
-                       size_t len = strlen(fn) + sizeof(mime);
-                       if ((afn = malloc(len)) == NULL) {
-                               free(mfn);
-                               free(mlist);
-                               file_oomem(ms, len);
-                               return NULL;
-                       }
-                       (void)strcpy(afn, fn);
-                       (void)strcat(afn, mime);
-                       fn = afn;
-               }
                file_err = apprentice_1(ms, fn, action, mlist);
                if (file_err > errs)
                        errs = file_err;
@@ -524,8 +516,6 @@ private int
 apprentice_file(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
     const char *fn, int action)
 {
-       private const char hdr[] =
-               "cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
        FILE *f;
        char line[BUFSIZ];
        int errs = 0;
@@ -553,7 +543,7 @@ apprentice_file(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
 
        /* print silly verbose header for USG compat. */
        if (action == FILE_CHECK)
-               (void)fprintf(stderr, "%s\n", hdr);
+               (void)fprintf(stderr, "%s\n", usg_hdr);
 
        /* read and parse this file */
        for (ms->line = 1; fgets(line, sizeof(line), f) != NULL; ms->line++) {
@@ -569,6 +559,14 @@ apprentice_file(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
                        continue;
                if (line[0] == '#')     /* comment, do not parse */
                        continue;
+               if (len > mime_marker_len &&
+                   memcmp(line, mime_marker, mime_marker_len) == 0) {
+                       /* MIME type */
+                       if (parse_mime(ms, &marray, &marraycount,
+                           line + mime_marker_len) != 0)
+                               errs++;
+                       continue;
+               }
                if (parse(ms, &marray, &marraycount, line, lineno, action) != 0)
                        errs++;
        }
@@ -708,14 +706,16 @@ string_modifier_check(struct magic_set *ms, struct magic const *m)
        case FILE_BESTRING16:
        case FILE_LESTRING16:
                if (m->str_flags != 0) {
-                       file_magwarn(ms, "no modifiers allowed for 16-bit strings\n");
+                       file_magwarn(ms,
+                           "no modifiers allowed for 16-bit strings\n");
                        return -1;
                }
                break;
        case FILE_STRING:
        case FILE_PSTRING:
                if ((m->str_flags & REGEX_OFFSET_START) != 0) {
-                       file_magwarn(ms, "'/%c' only allowed on regex and search\n",
+                       file_magwarn(ms,
+                           "'/%c' only allowed on regex and search\n",
                            CHAR_REGEX_OFFSET_START);
                        return -1;
                }
@@ -1082,7 +1082,8 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
                                case '3':  case '4':  case '5':
                                case '6':  case '7':  case '8':
                                case '9': {
-                                       if (have_count && ms->flags & MAGIC_CHECK)
+                                       if (have_count &&
+                                           (ms->flags & MAGIC_CHECK))
                                                file_magwarn(ms,
                                                    "multiple counts");
                                        have_count = 1;
@@ -1114,7 +1115,8 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
                                        return -1;
                                }
                                /* allow multiple '/' for readability */
-                               if (l[1] == '/' && !isspace((unsigned char)l[2]))
+                               if (l[1] == '/' &&
+                                   !isspace((unsigned char)l[2]))
                                        l++;
                        }
                        if (string_modifier_check(ms, m) == -1)
@@ -1205,11 +1207,62 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
                file_mdump(m);
        }
 #endif
+       m->mimetype[0] = '\0';          /* initialise MIME type to none */
        if (m->cont_level == 0)
                ++(*nmentryp);          /* make room for next */
        return 0;
 }
 
+/*
+ * parse a MIME annotation line from magic file, put into magic[index - 1]
+ * if valid
+ */
+private int
+parse_mime(struct magic_set *ms, struct magic_entry **mentryp,
+    uint32_t *nmentryp, const char *line)
+{
+       size_t i;
+       const char *l = line;
+       struct magic *m;
+       struct magic_entry *me;
+
+       if (*nmentryp == 0) {
+               file_error(ms, 0, "No current entry for MIME type");
+               return -1;
+       }
+
+       me = &(*mentryp)[*nmentryp - 1];
+       m = &me->mp[me->cont_count == 0 ? 0 : me->cont_count - 1];
+
+       if (m->mimetype[0] != '\0') {
+               file_error(ms, 0, "Current entry already has a MIME type: %s\n"
+                   "Description: %s\nNew type: %s", m->mimetype, m->desc, l);
+               return -1;
+       }       
+
+       EATAB;
+#if 0
+        file_magwarn(ms, "Description: %s\nNew type: %s", m->desc, l);
+#endif
+       for (i = 0;
+            *l && ((isascii((unsigned char)*l) && isalnum((unsigned char)*l))
+            || strchr("-+/", *l)) && i < sizeof(m->mimetype);
+            m->mimetype[i++] = *l++)
+               continue;
+       if (i == sizeof(m->mimetype)) {
+               m->desc[sizeof(m->mimetype) - 1] = '\0';
+               if (ms->flags & MAGIC_CHECK)
+                       file_magwarn(ms, "MIME type `%s' truncated %zu",
+                           m->mimetype, i);
+       } else
+               m->mimetype[i] = '\0';
+
+       if (i > 0)
+               return 0;
+       else
+               return -1;
+}
+
 private int
 check_format_type(const char *ptr, int type)
 {
index a5616a718ad712adfa004b09623178b3ba1d4700..cb4f7f78325f460902d8e490ca57c83170ef386d 100644 (file)
@@ -27,7 +27,7 @@
  */
 /*
  * file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.91 2007/03/25 03:13:47 christos Exp $
+ * @(#)$File: file.h,v 1.92 2007/11/08 00:31:37 christos Exp $
  */
 
 #ifndef __file_h__
@@ -91,8 +91,8 @@
 #define MAXstring 32           /* max leng of "string" types */
 
 #define MAGICNO                0xF11E041C
-#define VERSIONNO      4
-#define FILE_MAGICSIZE (32 * 4)
+#define VERSIONNO      5
+#define FILE_MAGICSIZE (32 * 6)
 
 #define        FILE_LOAD       0
 #define FILE_CHECK     1
@@ -237,6 +237,8 @@ struct magic {
        } value;                /* either number or string */
        /* Words 17..31 */
        char desc[MAXDESC];     /* description */
+       /* Words 32..47 */
+       char mimetype[MAXDESC]; /* MIME type */
 };
 
 #define BIT(A)   (1 << (A))
index 54e3dc18984a52415e08a1291f0c4f01f1d87d1d..3731d9eff2af3e966fb13d495136ebabc6d766a1 100644 (file)
@@ -48,7 +48,7 @@
 #endif
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.34 2007/10/17 19:33:31 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.35 2007/12/27 16:35:59 christos Exp $")
 #endif /* lint */
 
 #ifndef HAVE_VSNPRINTF
@@ -184,7 +184,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
                return 1;
        } else if (nb == 1) {
                if ((!mime || (mime & MAGIC_MIME_TYPE)) &&
-                   file_printf(ms, mime ?  "application/octet-stream" :
+                   file_printf(ms, mime ? "application/octet-stream" :
                    "very short file (no magic)") == -1)
                        return -1;
                return 1;
@@ -217,7 +217,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
                        (m = file_ascmagic(ms, buf, nb)) == 0) {
                        /* abandon hope, all ye who remain here */
                        if ((!mime || (mime & MAGIC_MIME_TYPE)) &&
-                           file_printf(ms, mime ?  "application/octet-stream" :
+                           file_printf(ms, mime ? "application/octet-stream" :
                                "data") == -1)
                                return -1;
                        m = 1;
index 5bdb457c6f21cdcb8671f74740c0412a7d5b00da..3d1a07ddb85f8dddabb64cc363e83677a7964f8f 100644 (file)
@@ -38,7 +38,7 @@
 
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.102 2007/11/08 00:31:37 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.103 2007/12/27 16:35:59 christos Exp $")
 #endif /* lint */
 
 private int match(struct magic_set *, struct magic *, uint32_t,
@@ -57,6 +57,12 @@ private void cvt_16(union VALUETYPE *, const struct magic *);
 private void cvt_32(union VALUETYPE *, const struct magic *);
 private void cvt_64(union VALUETYPE *, const struct magic *);
 
+/*
+ * Macro to give description string according to whether we want plain
+ * text or MIME type
+ */
+#define MAGIC_DESC ((ms->flags & MAGIC_MIME) ? m->mimetype : m->desc)
+
 /*
  * softmagic - lookup one file in parsed, in-memory copy of database
  * Passed the name and FILE * of one file to be typed.
@@ -117,17 +123,18 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 
        for (magindex = 0; magindex < nmagic; magindex++) {
                int flush;
+               struct magic *m = &magic[magindex];
 
-               ms->offset = magic[magindex].offset;
-               ms->line = magic[magindex].lineno;
+               ms->offset = m->offset;
+               ms->line = m->lineno;
 
                /* if main entry matches, print it... */
-               flush = !mget(ms, s, &magic[magindex], nbytes, cont_level);
+               flush = !mget(ms, s, m, nbytes, cont_level);
                if (flush) {
-                       if (magic[magindex].reln == '!')
+                       if (m->reln == '!')
                                flush = 0;
                } else {        
-                       switch (magiccheck(ms, &magic[magindex])) {
+                       switch (magiccheck(ms, m)) {
                        case -1:
                                return -1;
                        case 0:
@@ -152,15 +159,14 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
                 * If we are going to print something, we'll need to print
                 * a blank before we print something else.
                 */
-               if (magic[magindex].desc[0]) {
+               if (*MAGIC_DESC) {
                        need_separator = 1;
                        printed_something = 1;
                        if (print_sep(ms, firstline) == -1)
                                return -1;
                }
 
-               if ((ms->c.li[cont_level].off = mprint(ms, &magic[magindex]))
-                   == -1)
+               if ((ms->c.li[cont_level].off = mprint(ms, m)) == -1)
                        return -1;
 
                /* and any continuations that match */
@@ -169,36 +175,36 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 
                while (magic[magindex+1].cont_level != 0 &&
                    ++magindex < nmagic) {
-                       ms->line = magic[magindex].lineno; /* for messages */
+                       m = &magic[magindex];
+                       ms->line = m->lineno; /* for messages */
 
-                       if (cont_level < magic[magindex].cont_level)
+                       if (cont_level < m->cont_level)
                                continue;
-                       if (cont_level > magic[magindex].cont_level) {
+                       if (cont_level > m->cont_level) {
                                /*
                                 * We're at the end of the level
                                 * "cont_level" continuations.
                                 */
-                               cont_level = magic[magindex].cont_level;
+                               cont_level = m->cont_level;
                        }
-                       ms->offset = magic[magindex].offset;
-                       if (magic[magindex].flag & OFFADD) {
+                       ms->offset = m->offset;
+                       if (m->flag & OFFADD) {
                                ms->offset +=
                                    ms->c.li[cont_level - 1].off;
                        }
 
 #ifdef ENABLE_CONDITIONALS
-                       if (magic[magindex].cond == COND_ELSE ||
-                           magic[magindex].cond == COND_ELIF) {
+                       if (m->cond == COND_ELSE ||
+                           m->cond == COND_ELIF) {
                                if (ms->c.li[cont_level].last_match == 1)
                                        continue;
                        }
 #endif
-                       flush = !mget(ms, s, &magic[magindex], nbytes,
-                           cont_level);
-                       if (flush && magic[magindex].reln != '!')
+                       flush = !mget(ms, s, m, nbytes, cont_level);
+                       if (flush && m->reln != '!')
                                continue;
                                
-                       switch (flush ? 1 : magiccheck(ms, &magic[magindex])) {
+                       switch (flush ? 1 : magiccheck(ms, m)) {
                        case -1:
                                return -1;
                        case 0:
@@ -210,7 +216,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 #ifdef ENABLE_CONDITIONALS
                                ms->c.li[cont_level].last_match = 1;
 #endif
-                               if (magic[magindex].type != FILE_DEFAULT)
+                               if (m->type != FILE_DEFAULT)
                                        ms->c.li[cont_level].got_match = 1;
                                else if (ms->c.li[cont_level].got_match) {
                                        ms->c.li[cont_level].got_match = 0;
@@ -220,7 +226,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
                                 * If we are going to print something,
                                 * make sure that we have a separator first.
                                 */
-                               if (magic[magindex].desc[0]) {
+                               if (*MAGIC_DESC) {
                                        printed_something = 1;
                                        if (print_sep(ms, firstline) == -1)
                                                return -1;
@@ -233,15 +239,15 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
                                 */
                                /* space if previous printed */
                                if (need_separator
-                                   && (magic[magindex].nospflag == 0)
-                                   && (magic[magindex].desc[0] != '\0')) {
+                                   && (m->nospflag == 0)
+                                   && *MAGIC_DESC) {
                                        if (file_printf(ms, " ") == -1)
                                                return -1;
                                        need_separator = 0;
                                }
-                               if ((ms->c.li[cont_level].off = mprint(ms, &magic[magindex])) == -1)
+                               if ((ms->c.li[cont_level].off = mprint(ms, m)) == -1)
                                        return -1;
-                               if (magic[magindex].desc[0])
+                               if (*MAGIC_DESC)
                                        need_separator = 1;
 
                                /*
@@ -259,6 +265,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
                        returnval = 1;
                }
                if ((ms->flags & MAGIC_CONTINUE) == 0 && printed_something) {
+                       fprintf(stderr, "printed something or not continuing %d\n", printed_something);
                        return 1; /* don't keep searching */
                }                       
        }
@@ -271,7 +278,7 @@ check_fmt(struct magic_set *ms, struct magic *m)
        regex_t rx;
        int rc;
 
-       if (strchr(m->desc, '%') == NULL)
+       if (strchr(MAGIC_DESC, '%') == NULL)
                return 0;
 
        rc = regcomp(&rx, "%[-0-9\\.]*s", REG_EXTENDED|REG_NOSUB);
@@ -281,7 +288,7 @@ check_fmt(struct magic_set *ms, struct magic *m)
                file_magerror(ms, "regex error %d, (%s)", rc, errmsg);
                return -1;
        } else {
-               rc = regexec(&rx, m->desc, 0, 0, 0);
+               rc = regexec(&rx, MAGIC_DESC, 0, 0, 0);
                regfree(&rx);
                return !rc;
        }
@@ -327,11 +334,11 @@ mprint(struct magic_set *ms, struct magic *m)
                        if (snprintf(buf, sizeof(buf), "%c",
                            (unsigned char)v) < 0)
                                return -1;
-                       if (file_printf(ms, m->desc, buf) == -1)
+                       if (file_printf(ms, MAGIC_DESC, buf) == -1)
                                return -1;
                        break;
                default:
-                       if (file_printf(ms, m->desc, (unsigned char) v) == -1)
+                       if (file_printf(ms, MAGIC_DESC, (unsigned char) v) == -1)
                                return -1;
                        break;
                }
@@ -349,11 +356,11 @@ mprint(struct magic_set *ms, struct magic *m)
                        if (snprintf(buf, sizeof(buf), "%hu",
                            (unsigned short)v) < 0)
                                return -1;
-                       if (file_printf(ms, m->desc, buf) == -1)
+                       if (file_printf(ms, MAGIC_DESC, buf) == -1)
                                return -1;
                        break;
                default:
-                       if (file_printf(ms, m->desc, (unsigned short) v) == -1)
+                       if (file_printf(ms, MAGIC_DESC, (unsigned short) v) == -1)
                                return -1;
                        break;
                }
@@ -371,11 +378,11 @@ mprint(struct magic_set *ms, struct magic *m)
                case 1:
                        if (snprintf(buf, sizeof(buf), "%u", (uint32_t)v) < 0)
                                return -1;
-                       if (file_printf(ms, m->desc, buf) == -1)
+                       if (file_printf(ms, MAGIC_DESC, buf) == -1)
                                return -1;
                        break;
                default:
-                       if (file_printf(ms, m->desc, (uint32_t) v) == -1)
+                       if (file_printf(ms, MAGIC_DESC, (uint32_t) v) == -1)
                                return -1;
                        break;
                }
@@ -386,7 +393,7 @@ mprint(struct magic_set *ms, struct magic *m)
        case FILE_BEQUAD:
        case FILE_LEQUAD:
                v = file_signextend(ms, m, p->q);
-               if (file_printf(ms, m->desc, (uint64_t) v) == -1)
+               if (file_printf(ms, MAGIC_DESC, (uint64_t) v) == -1)
                        return -1;
                t = ms->offset + sizeof(int64_t);
                break;
@@ -396,14 +403,14 @@ mprint(struct magic_set *ms, struct magic *m)
        case FILE_BESTRING16:
        case FILE_LESTRING16:
                if (m->reln == '=' || m->reln == '!') {
-                       if (file_printf(ms, m->desc, m->value.s) == -1)
+                       if (file_printf(ms, MAGIC_DESC, m->value.s) == -1)
                                return -1;
                        t = ms->offset + m->vallen;
                }
                else {
                        if (*m->value.s == '\0')
                                p->s[strcspn(p->s, "\n")] = '\0';
-                       if (file_printf(ms, m->desc, p->s) == -1)
+                       if (file_printf(ms, MAGIC_DESC, p->s) == -1)
                                return -1;
                        t = ms->offset + strlen(p->s);
                }
@@ -413,7 +420,7 @@ mprint(struct magic_set *ms, struct magic *m)
        case FILE_BEDATE:
        case FILE_LEDATE:
        case FILE_MEDATE:
-               if (file_printf(ms, m->desc, file_fmttime(p->l, 1)) == -1)
+               if (file_printf(ms, MAGIC_DESC, file_fmttime(p->l, 1)) == -1)
                        return -1;
                t = ms->offset + sizeof(time_t);
                break;
@@ -422,7 +429,7 @@ mprint(struct magic_set *ms, struct magic *m)
        case FILE_BELDATE:
        case FILE_LELDATE:
        case FILE_MELDATE:
-               if (file_printf(ms, m->desc, file_fmttime(p->l, 0)) == -1)
+               if (file_printf(ms, MAGIC_DESC, file_fmttime(p->l, 0)) == -1)
                        return -1;
                t = ms->offset + sizeof(time_t);
                break;
@@ -430,7 +437,7 @@ mprint(struct magic_set *ms, struct magic *m)
        case FILE_QDATE:
        case FILE_BEQDATE:
        case FILE_LEQDATE:
-               if (file_printf(ms, m->desc, file_fmttime((uint32_t)p->q, 1))
+               if (file_printf(ms, MAGIC_DESC, file_fmttime((uint32_t)p->q, 1))
                    == -1)
                        return -1;
                t = ms->offset + sizeof(uint64_t);
@@ -439,7 +446,7 @@ mprint(struct magic_set *ms, struct magic *m)
        case FILE_QLDATE:
        case FILE_BEQLDATE:
        case FILE_LEQLDATE:
-               if (file_printf(ms, m->desc, file_fmttime((uint32_t)p->q, 0))
+               if (file_printf(ms, MAGIC_DESC, file_fmttime((uint32_t)p->q, 0))
                    == -1)
                        return -1;
                t = ms->offset + sizeof(uint64_t);
@@ -455,11 +462,11 @@ mprint(struct magic_set *ms, struct magic *m)
                case 1:
                        if (snprintf(buf, sizeof(buf), "%g", vf) < 0)
                                return -1;
-                       if (file_printf(ms, m->desc, buf) == -1)
+                       if (file_printf(ms, MAGIC_DESC, buf) == -1)
                                return -1;
                        break;
                default:
-                       if (file_printf(ms, m->desc, vf) == -1)
+                       if (file_printf(ms, MAGIC_DESC, vf) == -1)
                                return -1;
                        break;
                }
@@ -476,11 +483,11 @@ mprint(struct magic_set *ms, struct magic *m)
                case 1:
                        if (snprintf(buf, sizeof(buf), "%g", vd) < 0)
                                return -1;
-                       if (file_printf(ms, m->desc, buf) == -1)
+                       if (file_printf(ms, MAGIC_DESC, buf) == -1)
                                return -1;
                        break;
                default:
-                       if (file_printf(ms, m->desc, vd) == -1)
+                       if (file_printf(ms, MAGIC_DESC, vd) == -1)
                                return -1;
                        break;
                }
@@ -496,7 +503,7 @@ mprint(struct magic_set *ms, struct magic *m)
                        file_oomem(ms, ms->search.rm_len);
                        return -1;
                }
-               rval = file_printf(ms, m->desc, cp);
+               rval = file_printf(ms, MAGIC_DESC, cp);
                free(cp);
 
                if (rval == -1)
@@ -510,7 +517,7 @@ mprint(struct magic_set *ms, struct magic *m)
        }
 
        case FILE_SEARCH:
-               if (file_printf(ms, m->desc, m->value.s) == -1)
+               if (file_printf(ms, MAGIC_DESC, m->value.s) == -1)
                        return -1;
                if ((m->str_flags & REGEX_OFFSET_START))
                        t = ms->search.offset;
@@ -519,7 +526,7 @@ mprint(struct magic_set *ms, struct magic *m)
                break;
 
        case FILE_DEFAULT:
-               if (file_printf(ms, m->desc, m->value.s) == -1)
+               if (file_printf(ms, MAGIC_DESC, m->value.s) == -1)
                        return -1;
                t = ms->offset;
                break;