Virgin import of Christos Zoulas's FILE 4.10.

*- file is now broken into a library containing and processing the magic
   and a consumer binary.
This commit is contained in:
obrien 2004-08-09 08:45:41 +00:00
parent 76588875a9
commit 9137be5ffd
111 changed files with 17290 additions and 5274 deletions

View File

@ -1,12 +1 @@
Makefile
config.cache
config.h
config.log
config.status
stamp-h
file
file.1
magic.4
magic
magic.mgc
magic.mime.mgc
autom4te.cache

166
contrib/file/ChangeLog Normal file
View File

@ -0,0 +1,166 @@
2004-07-24 16:33 Christos Zoulas <christos@zoulas.com>
* magic.mime update Danny Milosavljevic <danny.milo@gmx.net>
* FreeBSD version update Oliver Eikemeier <eikemeier@fillmore-labs.com>
* utime/utimes detection Ian Lance Taylor <ian@wasabisystems.com>
* errors reading elf magic Jakub Bogusz <qboosh@pld-linux.org>
2004-04-12 10:55 Christos Zoulas <christos@zoulas.com>
* make sure that magic formats match magic types during compilation
* fix broken sgi magic file
2004-04-06 20:36 Christos Zoulas <christos@zoulas.com>
* detect present of mbstate_t Petter Reinholdtsen <pere@hungry.com>
* magic fixes
2004-03-22 15:25 Christos Zoulas <christos@zoulas.com>
* Lots of mime fixes
(Joerg Ostertag) <ostertag@rechengilde.de>
* FreeBSD ELF version handling
(Edwin Groothuis) <edwin@mavetju.org>
* correct cleanup in all cases; don't just close the file.
(Christos Zoulas) <christos@zoulas.com>
* add gettext message catalogue support
(Michael Piefel) <piefel@debian.org>
* better printout for unreadable files
(Michael Piefel) <piefel@debian.org>
* compensate for missing MAXPATHLEN
(Michael Piefel) <piefel@debian.org>
* add wide character string length computation
(Michael Piefel) <piefel@debian.org>
* Avoid infinite loops caused by bad elf alignments
or name and description note sizes. Reported by
(Mikael Magnusson) <mmikael@comhem.se>
2004-03-09 13:55 Christos Zoulas <christos@zoulas.com>
* Fix possible memory leak on error and add missing regfree
(Dmitry V. Levin) <ldv@altlinux.org>
2003-12-23 12:12 Christos Zoulas <christos@zoulas.com>
* fix -k flag (Maciej W. Rozycki)
2003-11-18 14:10 Christos Zoulas <christos@zoulas.com>
* Try to give us much info as possible on corrupt elf files.
(Willy Tarreau) <willy@w.ods.org>
* Updated python bindings (Brett Funderburg)
<brettf@deepfile.com>
2003-11-11 15:03 Christos Zoulas <christos@zoulas.com>
* Include file.h first, because it includes config.h
breaks largefile test macros otherwise.
(Paul Eggert <eggert@CS.UCLA.EDU> via
Lars Hecking <lhecking@nmrc.ie>)
2003-10-14 21:39 Christos Zoulas <christos@zoulas.com>
* Python bindings (Brett Funderburg) <brettf@deepfile.com>
* Don't lookup past the end of the buffer
(Chad Hanson) <chanson@tcs-sec.com>
* Add MAGIC_ERROR and api on magic_errno()
2003-10-08 12:40 Christos Zoulas <christos@zoulas.com>
* handle error conditions from compile as fatal
(Antti Kantee) <pooka@netbsd.org>
* handle magic filename parsing sanely
* more magic fixes.
* fix a memory leak (Illes Marton) <illes.marton@balabit.hu>
* describe magic file handling
(Bryan Henderson) <bryanh@giraffe-data.com>
2003-09-12 15:09 Christos Zoulas <christos@zoulas.com>
* update magic files.
* remove largefile support from file.h; it breaks things on most OS's
2003-08-10 10:25 Christos Zoulas <christos@zoulas.com>
* fix unmapping'ing of mmaped files.
2003-07-10 12:03 Christos Zoulas <christos@zoulas.com>
* don't exit with -1 on error; always exit 1 (Marty Leisner)
* restore utimes code.
2003-06-10 17:03 Christos Zoulas <christos@zoulas.com>
* make sure we don't access uninitialized memory.
* pass lint
* #ifdef __cplusplus in magic.h
2003-05-25 19:23 Christos Zoulas <christos@zoulas.com>
* rename cvs magic file to revision to deal with
case insensitive filesystems.
2003-05-23 17:03 Christos Zoulas <christos@zoulas.com>
* documentation fixes from Michael Piefel <piefel@debian.org>
* magic fixes (various)
* revert basename magic in .mgc name determination
* buffer protection in uncompress,
signness issues,
close files
Maciej W. Rozycki <macro@ds2.pg.gda.pl
2003-04-21 20:12 Christos Zoulas <christos@zoulas.com>
* fix zsh magic
2003-04-04 16:59 Christos Zoulas <christos@zoulas.com>
* fix operand sort order in string.
2003-04-02 17:30 Christos Zoulas <christos@zoulas.com>
* cleanup namespace in magic.h
2003-04-02 13:50 Christos Zoulas <christos@zoulas.com>
* Magic additions (Alex Ott)
* Fix bug that broke VPATH compilation (Peter Breitenlohner)
2003-03-28 16:03 Christos Zoulas <christos@zoulas.com>
* remove packed attribute from magic struct.
* make the magic struct properly aligned.
* bump version number of compiled files to 2.
2003-03-27 13:10 Christos Zoulas <christos@zoulas.com>
* separate tar detection and run it before softmagic.
* fix reversed symlink test.
* fix version printing.
* make separator a string instead of a char.
* update manual page and sort options.
2003-03-26 11:00 Christos Zoulas <christos@zoulas.com>
* Pass lint
* make NULL in magic_file mean stdin
* Fix "-" argument to file to pass NULL to magic_file
* avoid pointer casts by using memcpy
* rename magic_buf -> magic_buffer
* keep only the first error
* manual page: new sentence, new line
* fix typo in api function (magic_buf -> magic_buffer)

View File

@ -1,7 +1,7 @@
$Id: LEGAL.NOTICE,v 1.11 1999/01/14 16:30:12 christos Exp $
$Id: LEGAL.NOTICE,v 1.13 2003/03/23 22:23:30 christos Exp $
Copyright (c) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992, 1994, 1995.
Software written by Ian F. Darwin and others;
maintained 1994-1999 Christos Zoulas.
maintained 1994-2003 Christos Zoulas.
This software is not subject to any export provision of the United States
Department of Commerce, and may be exported to any country or planet.

View File

@ -2,6 +2,6 @@
#------------------------------------------------------------------------------
# Localstuff: file(1) magic for locally observed files
#
# $Id: Localstuff,v 1.3 1995/01/21 21:09:00 christos Exp $
# $Id: Localstuff,v 1.4 2003/03/23 04:17:27 christos Exp $
# Add any locally observed files here. Remember:
# text if readable, executable if runnable binary, data if unreadable.

View File

@ -1,4 +1,4 @@
$Id: MAINT,v 1.4 2000/04/11 02:43:51 christos Exp $
$Id: MAINT,v 1.5 2003/03/23 04:36:37 christos Exp $
Maintenance notes:

View File

@ -16,7 +16,7 @@
# Infocom
# (Note: to avoid false matches Z-machine version 1 and 2 are not
# recognized since only the oldest Zork I and II used them. Similarly
# there are 4 Infocom games that use verion 4 that are not recognized.)
# there are 4 Infocom games that use version 4 that are not recognized.)
#0 byte 3 Infocom game data (Z-machine 3,
#>2 beshort <0x7fff Release %3d,
#>26 beshort >0 Size %d*2

View File

@ -3,9 +3,8 @@
#
# From ignatios@cs.uni-bonn.de (Ignatios Souvatzis)
# Some formats are still missing: AmigaOS special IFF's, e.g.: FORM....CTLG
# (the others should be separate, anyway)
#
0 belong 0x000003fa AmigaOS shared library
0 belong 0x000003f3 AmigaOS loadseg()ble executable/binary
0 belong 0x000003e7 AmigaOS object/library data
#
@ -33,7 +32,25 @@
0 string ARP. The Holy Noise Module sound file
0 string BeEp\0 JamCracker Module sound file
0 string COSO\0 Hippel-COSO Module sound file
26 string V.3 Brian Postma's Soundmon Module sound file v3
26 string BPSM Brian Postma's Soundmon Module sound file v3
26 string V.2 Brian Postma's Soundmon Module sound file v2
# Too simple (short, pure ASCII, deep), MPi
#26 string V.3 Brian Postma's Soundmon Module sound file v3
#26 string BPSM Brian Postma's Soundmon Module sound file v3
#26 string V.2 Brian Postma's Soundmon Module sound file v2
# The following are from: "Stefan A. Haubenthal" <polluks@web.de>
0 beshort 0x0f00 AmigaOS bitmap font
0 beshort 0x0f03 AmigaOS outline font
0 belong 0x80001001 AmigaOS outline tag
0 string ##\ version catalog translation
# Amiga disk types
#
0 string RDSK Rigid Disk Block
>160 string x on %.24s
0 string DOS\0 Amiga DOS disk
0 string DOS\1 Amiga FFS disk
0 string DOS\2 Amiga Inter DOS disk
0 string DOS\3 Amiga Inter FFS disk
0 string DOS\4 Amiga Fastdir DOS disk
0 string DOS\5 Amiga Fastdir FFS disk
0 string KICK Kickstart disk

View File

@ -118,6 +118,12 @@
#>3 byte&0x03 1 \b, Emphasis 5
#>3 byte&0x03 3 \b, Emphasis c
#From: Johan Gade <jgade@diku.dk>
# MPEG-4 Advanced Audio Coding (AAC) file (perhaps also MPEG-2 ACC?)
16 string M4A MPEG-4 Advanced Audio Coding file (AAC)
# FLI animation format
4 leshort 0xAF11 FLI file
>6 leshort x - %d frames,
@ -157,10 +163,19 @@
# \003. Most of them start with non-null values at hex offset 0x34 or so.
#0 string \3\0\0\0\0\0\0\0\0\0\0\0 DL version 3
# SGI and Apple formats
# SGI formats
0 string MOVI Silicon Graphics movie file
# Apple Quicktime: Scan for all known top-level QT atom markers
4 string moov Apple QuickTime movie file (moov)
4 string mdat Apple QuickTime movie file (mdat)
4 string ftyp Apple QuickTime movie file (ftyp)
4 string free Apple QuickTime movie file (free)
4 string junk Apple QuickTime movie file (junk)
4 string pnot Apple QuickTime movie file (pnot)
4 string skip Apple QuickTime movie file (skip)
4 string wide Apple QuickTime movie file (wide)
4 string pict Apple QuickTime movie file (pict)
# iso 13818 transport stream
#
@ -194,3 +209,32 @@
0 string \x8aMNG MNG video data,
>4 belong !0x0d0a1a0a CORRUPTED,
>4 belong 0x0d0a1a0a
>>16 belong x %ld x
>>20 belong x %ld
# JNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
0 string \x8bJNG JNG video data,
>4 belong !0x0d0a1a0a CORRUPTED,
>4 belong 0x0d0a1a0a
>>16 belong x %ld x
>>20 belong x %ld
# Vivo video (Wolfram Kleff)
3 string \x0D\x0AVersion:Vivo Vivo video data
# VRML (Virtual Reality Modelling Language)
0 string/b #VRML\ V1.0\ ascii VRML 1 file
0 string/b #VRML\ V2.0\ utf8 ISO/IEC 14772 VRML 97 file
#---------------------------------------------------------------------------
# HVQM4: compressed movie format designed by Hudson for Nintendo GameCube
# From Mark Sheppard <msheppard@climax.co.uk>, 2002-10-03
#
0 string HVQM4 %s
>6 string >\0 v%s
>0 byte x GameCube movie,
>0x34 ubeshort x %d x
>0x36 ubeshort x %d,
>0x26 ubeshort x %dµs,
>0x42 ubeshort 0 no audio
>0x42 ubeshort >0 %dHz audio

View File

@ -28,6 +28,13 @@
>12 belong &0x02000000 UseFasterCompression,
>16 belong x version %d
0 string package4 Newton package,
>8 byte 8 NOS 1.x,
>8 byte 9 NOS 2.x,
>12 belong &0x80000000 AutoRemove,
>12 belong &0x40000000 CopyProtect,
>12 belong &0x10000000 NoCompression,
# The following entries for the Apple II are for files that have
# been transferred as raw binary data from an Apple, without having
# been encapsulated by any of the above archivers.
@ -120,3 +127,24 @@
# Beagle Bros. Apple Mechanic fonts
0 belong&0xFF00FFFF 0x6400D000 Apple Mechanic font
# Apple Universal Disk Image Format (UDIF) - dmg files.
# From Johan Gade.
# These entries are disabled for now until we fix the following issues.
#
# Note there might be some problems with the "VAX COFF executable"
# entry. Note this entry should be placed before the mac filesystem section,
# particularly the "Apple Partition data" entry.
#
# The intended meaning of these tests is, that the file is only of the
# specified type if both of the lines are correct - i.e. if the first
# line matches and the second doesn't then it is not of that type.
#
#0 long 0x7801730d
#>4 long 0x62626060 UDIF read-only zlib-compressed image (UDZO)
#
# Note that this entry is recognized correctly by the "Apple Partition
# data" entry - however since this entry is more specific - this
# information seems to be more useful.
#0 long 0x45520200
#>0x410 string disk\ image UDIF read/write image (UDRW)

View File

@ -32,8 +32,10 @@
0 string !<arch>\ndebian
>8 string debian-split part of multipart Debian package
>8 string debian-binary Debian binary package
>68 string >\n (format %s)
>136 ledate x created: %s
>68 string >\0 (format %s)
>81 string bz2 \b, uses bzip2 compression
>84 string gz \b, uses gzip compression
#>136 ledate x created: %s
# other archives
0 long 0177555 very old archive
@ -187,7 +189,12 @@
>20 byte x - header level %d
# RAR archiver (Greg Roelofs, newt@uchicago.edu)
0 string Rar! RAR archive data
0 string Rar! RAR archive data,
>44 byte x v%0x,
>35 byte 0 os: MS-DOS
>35 byte 1 os: OS/2
>35 byte 2 os: Win32
>35 byte 3 os: Unix
# SQUISH archiver (Greg Roelofs, newt@uchicago.edu)
0 string SQSH squished archive data (Acorn RISCOS)
@ -239,9 +246,11 @@
# Microsoft cabinets
# by David Necas (Yeti) <yeti@physics.muni.cz>
0 string MSCF\0\0\0\0 Microsoft cabinet file data,
>25 byte x v%d
>24 byte x \b.%d
#0 string MSCF\0\0\0\0 Microsoft cabinet file data,
#>25 byte x v%d
#>24 byte x \b.%d
# MPi: All CABs have version 1.3, so this is pointless.
# Better magic in debian-additions.
# GTKtalog catalogs
# by David Necas (Yeti) <yeti@physics.muni.cz>
@ -256,3 +265,56 @@
0 string PAR\0 PARity archive data
>48 leshort =0 - Index file
>48 leshort >0 - file number %d
# Felix von Leitner <felix-file@fefe.de>
0 string d8:announce BitTorrent file
# Atari MSA archive - Teemu Hukkanen <tjhukkan@iki.fi>
0 beshort 0x0e0f Atari MSA archive data
>2 beshort x \b, %d sectors per track
>4 beshort 0 \b, 1 sided
>4 beshort 1 \b, 2 sided
>6 beshort x \b, starting track: %d
>8 beshort x \b, ending track: %d
# Alternate ZIP string (amc@arwen.cs.berkeley.edu)
0 string PK00PK\003\004 Zip archive data
# ACE archive (from http://www.wotsit.org/download.asp?f=ace)
# by Stefan `Sec` Zehl <sec@42.org>
7 string **ACE** ACE compressed archive
>15 byte >0 version %d
>16 byte =0x00 \b, from MS-DOS
>16 byte =0x01 \b, from OS/2
>16 byte =0x02 \b, from Win/32
>16 byte =0x03 \b, from Unix
>16 byte =0x04 \b, from MacOS
>16 byte =0x05 \b, from WinNT
>16 byte =0x06 \b, from Primos
>16 byte =0x07 \b, from AppleGS
>16 byte =0x08 \b, from Atari
>16 byte =0x09 \b, from Vax/VMS
>16 byte =0x0A \b, from Amiga
>16 byte =0x0B \b, from Next
>14 byte x \b, version %d to extract
>5 leshort &0x0080 \b, multiple volumes,
>>17 byte x \b (part %d),
>5 leshort &0x0002 \b, contains comment
>5 leshort &0x0200 \b, sfx
>5 leshort &0x0400 \b, small dictionary
>5 leshort &0x0800 \b, multi-volume
>5 leshort &0x1000 \b, contains AV-String
>>30 string\x16*UNREGISTERED\x20VERSION* (unregistered)
>5 leshort &0x2000 \b, with recovery record
>5 leshort &0x4000 \b, locked
>5 leshort &0x8000 \b, solid
# Date in MS-DOS format (whatever that is)
#>18 lelong x Created on
# sfArk : compression program for Soundfonts (sf2) by Dirk Jagdmann
# <doj@cubic.org>
0x1A string sfArk sfArk compressed Soundfont
>0x15 string 2
>>0x1 string >\0 Version %s
>>0x2A string >\0 : %s

View File

@ -8,18 +8,28 @@
# Sun/NeXT audio data
0 string .snd Sun/NeXT audio data:
>12 belong 1 8-bit ISDN u-law,
>12 belong 1 8-bit ISDN mu-law,
>12 belong 2 8-bit linear PCM [REF-PCM],
>12 belong 3 16-bit linear PCM,
>12 belong 4 24-bit linear PCM,
>12 belong 5 32-bit linear PCM,
>12 belong 6 32-bit IEEE floating point,
>12 belong 7 64-bit IEEE floating point,
>12 belong 23 8-bit ISDN u-law compressed (CCITT G.721 ADPCM voice data encoding),
>12 belong 24 compressed (8-bit G.722 ADPCM)
>12 belong 25 compressed (3-bit G.723 ADPCM),
>12 belong 26 compressed (5-bit G.723 ADPCM),
>12 belong 27 8-bit A-law,
>12 belong 8 Fragmented sample data,
>12 belong 10 DSP program,
>12 belong 11 8-bit fixed point,
>12 belong 12 16-bit fixed point,
>12 belong 13 24-bit fixed point,
>12 belong 14 32-bit fixed point,
>12 belong 18 16-bit linear with emphasis,
>12 belong 19 16-bit linear compressed,
>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 data encoding),
>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),
>12 belong 27 8-bit A-law (CCITT G.711),
>20 belong 1 mono,
>20 belong 2 stereo,
>20 belong 4 quad,
@ -28,14 +38,28 @@
# 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
0 lelong 0x0064732E DEC audio data:
>12 lelong 1 8-bit ISDN u-law,
>12 lelong 1 8-bit ISDN mu-law,
>12 lelong 2 8-bit linear PCM [REF-PCM],
>12 lelong 3 16-bit linear PCM,
>12 lelong 4 24-bit linear PCM,
>12 lelong 5 32-bit linear PCM,
>12 lelong 6 32-bit IEEE floating point,
>12 lelong 7 64-bit IEEE floating point,
>12 lelong 23 8-bit ISDN u-law compressed (CCITT G.721 ADPCM voice data encoding),
>12 belong 8 Fragmented sample data,
>12 belong 10 DSP program,
>12 belong 11 8-bit fixed point,
>12 belong 12 16-bit fixed point,
>12 belong 13 24-bit fixed point,
>12 belong 14 32-bit fixed point,
>12 belong 18 16-bit linear with emphasis,
>12 belong 19 16-bit linear compressed,
>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 data encoding),
>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),
>12 belong 27 8-bit A-law (CCITT G.711),
>20 lelong 1 mono,
>20 lelong 2 stereo,
>20 lelong 4 quad,
@ -43,8 +67,12 @@
# Creative Labs AUDIO stuff
0 string MThd Standard MIDI data
>9 byte >0 (format %d)
>11 byte >1 using %d tracks
>8 beshort x (format %d)
>10 beshort x using %d track
>10 beshort >1 \bs
>12 beshort&0x7fff x at 1/%d
>12 beshort&0x8000 >0 SMPTE
0 string CTMF Creative Music (CMF) data
0 string SBI SoundBlaster instrument data
0 string Creative\ Voice\ File Creative Labs voice data
@ -72,12 +100,18 @@
# MTM/669/FAR/S3M/ULT/XM format checking [Aaron Eppert, aeppert@dialin.ind.net]
# Oct 31, 1995
0 string MTM MultiTracker Module sound file
# fixed by <doj@cubic.org> 2003-06-24
# Too short...
#0 string MTM MultiTracker Module sound file
#0 string if Composer 669 Module sound data
0 string FAR Module sound data
#0 string JN Composer 669 Module sound data (extended format)
0 string MAS_U ULT(imate) Module sound data
#0 string FAR Module sound data
#>4 string >\15 Title: "%s"
0x2c string SCRM ScreamTracker III Module sound data
0 string Extended Module Extended Module sound data
>0 string >\0 Title: "%s"
# Gravis UltraSound patches
# From <ache@nagual.ru>
@ -88,37 +122,68 @@
#
# Taken from loader code from mikmod version 2.14
# by Steve McIntyre (stevem@chiark.greenend.org.uk)
0 string JN extended 669 module data
# <doj@cubic.org> added title printing on 2003-06-24
0 string MAS_UTrack_V00
>14 string >/0 ultratracker V1.%.1s module sound data
0 string UN05 MikMod UNI format module sound data
0 string Extended\ Module: Fasttracker II module sound data
21 string !SCREAM! Screamtracker 2 module sound data
>17 string >\0 Title: "%s"
21 string/c !SCREAM! Screamtracker 2 module sound data
21 string BMOD2STM Screamtracker 2 module sound data
1080 string M.K. 4-channel Protracker module sound data
>0 string >\0 Title: "%s"
1080 string M!K! 4-channel Protracker module sound data
>0 string >\0 Title: "%s"
1080 string FLT4 4-channel Startracker module sound data
>0 string >\0 Title: "%s"
1080 string FLT8 8-channel Startracker module sound data
>0 string >\0 Title: "%s"
1080 string 4CHN 4-channel Fasttracker module sound data
>0 string >\0 Title: "%s"
1080 string 6CHN 6-channel Fasttracker module sound data
>0 string >\0 Title: "%s"
1080 string 8CHN 8-channel Fasttracker module sound data
1080 string CD81 8-channel Oktalyzer module sound data
>0 string >\0 Title: "%s"
1080 string CD81 8-channel Octalyser module sound data
>0 string >\0 Title: "%s"
1080 string OKTA 8-channel Oktalyzer module sound data
>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
>0 string >\0 Title: "%s"
1080 string 32CN 32-channel Taketracker module sound data
>0 string >\0 Title: "%s"
# TOC sound files -Trevor Johnson <trevor@jpj.net>
#
0 string TOC TOC sound file
# sidfiles <pooka@iki.fi>
# added name,author,(c) and new RSID type by <doj@cubic.org> 2003-06-24
0 string SIDPLAY\ INFOFILE Sidplay info file
0 string PSID PlaySID v2.2+ (AMIGA) sidtune
>4 beshort >0 w/ header v%d,
>14 beshort =1 single song,
>14 beshort >1 %d songs,
>16 beshort >0 default song: %d
>0x16 string >\0 name: "%s"
>0x36 string >\0 author: "%s"
>0x56 string >\0 copyright: "%s"
0 string RSID RSID sidtune PlaySID compatible
>4 beshort >0 w/ header v%d,
>14 beshort =1 single song,
>14 beshort >1 %d songs,
>16 beshort >0 default song: %d
>0x16 string >\0 name: "%s"
>0x36 string >\0 author: "%s"
>0x56 string >\0 copyright: "%s"
# IRCAM <mpruett@sgi.com>
# VAX and MIPS files are little-endian; Sun and NeXT are big-endian
@ -133,8 +198,25 @@
# Sample Vision <mpruett@sgi.com>
0 string SOUND\ SAMPLE\ DATA\ Sample Vision file
# Audio Visual Research <mpruett@sgi.com>
0 string 2BIT Audio Visual Research file
# Audio Visual Research <tonigonenstein@users.sourceforge.net>
0 string 2BIT Audio Visual Research file,
>12 beshort =0 mono,
>12 beshort =-1 stereo,
>14 beshort x %d bits
>16 beshort =0 unsigned,
>16 beshort =-1 signed,
>22 belong&0x00ffffff x %d Hz,
>18 beshort =0 no loop,
>18 beshort =-1 loop,
>21 ubyte <=127 note %d,
>22 byte =0 replay 5.485 KHz
>22 byte =1 replay 8.084 KHz
>22 byte =2 replay 10.971 Khz
>22 byte =3 replay 16.168 Khz
>22 byte =4 replay 21.942 KHz
>22 byte =5 replay 32.336 KHz
>22 byte =6 replay 43.885 KHz
>22 byte =7 replay 47.261 KHz
# SGI SoundTrack <mpruett@sgi.com>
0 string _SGI_SoundTrack SGI SoundTrack project file
@ -230,6 +312,29 @@
0 string FTMN FaceTheMusic module
>16 string >\0d \b, "%s"
# From: <doj@cubic.org> 2003-06-24
0 string AMShdr\32 Velvet Studio AMS Module v2.2
0 string Extreme Extreme Tracker AMS Module v1.3
0 string DDMF Xtracker DMF Module
>4 byte x v%i
>0xD string >\0 Title: "%s"
>0x2B string >\0 Composer: "%s"
0 string DSM\32 Dynamic Studio Module DSM
0 string SONG DigiTrekker DTM Module
0 string DMDL DigiTrakker MDL Module
0 string PSM\32 Protracker Studio PSM Module
44 string PTMF Poly Tracker PTM Module
>0 string >\32 Title: "%s"
0 string MT20 MadTracker 2.0 Module MT2
0 string RAD\40by\40REALiTY!! RAD Adlib Tracker Module RAD
0 string RTMM RTM Module
0x426 string MaDoKaN96 XMS Adlib Module
>0 string >\0 Composer: "%s"
0 string AMF AMF Module
>4 string >\0 Title: "%s"
0 string MODINFO1 Open Cubic Player Module Inforation MDZ
0 string Extended\40Instrument: Fast Tracker II Instrument
# From: Takeshi Hamasaki <hma@syd.odn.ne.jp>
# NOA Nancy Codec file
0 string \210NOA\015\012\032 NOA Nancy Codec Movie file
@ -240,7 +345,56 @@
>20 string Ver01.00 Ver. 1.00
>>32 byte x , %d tracks
# FLAC audio stream <URL:http://flac.sourceforge.net/>
# From: Dan Fandrich <dan@coneharvesters.com>
0 string fLaC FLAC audio stream data
# Free lossless audio codec <http://flac.sourceforge.net>
# From: Przemyslaw Augustyniak <silvathraec@rpg.pl>
0 string fLaC FLAC audio bitstream data
>4 byte&0x7f >0 \b, unknown version
>4 byte&0x7f 0 \b
# some common bits/sample values
>>20 beshort&0x1f0 0x030 \b, 4 bit
>>20 beshort&0x1f0 0x050 \b, 6 bit
>>20 beshort&0x1f0 0x070 \b, 8 bit
>>20 beshort&0x1f0 0x0b0 \b, 12 bit
>>20 beshort&0x1f0 0x0f0 \b, 16 bit
>>20 beshort&0x1f0 0x170 \b, 24 bit
>>20 byte&0xe 0x0 \b, mono
>>20 byte&0xe 0x2 \b, stereo
>>20 byte&0xe 0x4 \b, 3 channels
>>20 byte&0xe 0x6 \b, 4 channels
>>20 byte&0xe 0x8 \b, 5 channels
>>20 byte&0xe 0xa \b, 6 channels
>>20 byte&0xe 0xc \b, 7 channels
>>20 byte&0xe 0xe \b, 8 channels
# some common sample rates
>>17 belong&0xfffff0 0x0ac440 \b, 44.1 kHz
>>17 belong&0xfffff0 0x0bb800 \b, 48 kHz
>>17 belong&0xfffff0 0x07d000 \b, 32 kHz
>>17 belong&0xfffff0 0x056220 \b, 22.05 kHz
>>17 belong&0xfffff0 0x05dc00 \b, 24 kHz
>>17 belong&0xfffff0 0x03e800 \b, 16 kHz
>>17 belong&0xfffff0 0x02b110 \b, 11.025 kHz
>>17 belong&0xfffff0 0x02ee00 \b, 12 kHz
>>17 belong&0xfffff0 0x01f400 \b, 8 kHz
>>17 belong&0xfffff0 0x177000 \b, 96 kHz
>>17 belong&0xfffff0 0x0fa000 \b, 64 kHz
>>21 byte&0xf >0 \b, >4G samples
>>21 byte&0xf 0 \b
>>>22 belong >0 \b, %u samples
>>>22 belong 0 \b, length unknown
# (ISDN) VBOX voice message file (Wolfram Kleff)
0 string VBOX VBOX voice message data
# ReBorn Song Files (.rbs)
# David J. Singer <doc@deadvirgins.org.uk>
8 string RB40 RBS Song file
>29 string ReBorn created by ReBorn
>37 string Propellerhead created by ReBirth
# Synthesizer Generator and Kimwitu share their file format
0 string A#S#C#S#S#L#V#3 Synthesizer Generator or Kimwitu data
# Kimwitu++ uses a slightly different magic
0 string A#S#C#S#S#L#HUB Kimwitu++ data
# From "Simon Hosie
0 string TFMX-SONG TFMX module sound data

12
contrib/file/Magdir/bFLT Normal file
View File

@ -0,0 +1,12 @@
#------------------------------------------------------------------------------
# bFLT: file(1) magic for BFLT uclinux binary files
#
# From Philippe De Muyter <phdm@macqel.be>
#
0 string bFLT BFLT executable
>4 belong x - version %ld
>4 belong 4
>>36 belong&0x1 0x1 ram
>>36 belong&0x2 0x2 gotpic
>>36 belong&0x4 0x4 gzip
>>36 belong&0x8 0x8 gzdata

9
contrib/file/Magdir/bout Normal file
View File

@ -0,0 +1,9 @@
#
# i80960 b.out objects and archives
#
0 long 0x10d i960 b.out relocatable object
>16 long >0 not stripped
#
# b.out archive (hp-rt on i960)
0 string !<bout> b.out archive
>8 string __.SYMDEF random library

View File

@ -10,4 +10,15 @@
# this first will upset you if you're a PL/1 shop...
# in which case rm it; ascmagic will catch real C programs
#0 string /* C or REXX program text
0 string // C++ program text
#0 string // C++ program text
# From: Mikhail Teterin <mi@aldan.algebra.com>
0 string cscope cscope reference data
>7 string x version %.2s
# We skip the path here, because it is often long (so file will
# truncate it) and mostly redundant.
# The inverted index functionality was added some time betwen
# versions 11 and 15, so look for -q if version is above 14:
>7 string >14
>>10 regex .+\ -q\ with inverted index
>10 regex .+\ -c\ text (non-compressed)

27
contrib/file/Magdir/c64 Normal file
View File

@ -0,0 +1,27 @@
#------------------------------------------------------------------------------
# c64: file(1) magic for various commodore 64 related files
#
# From <doj@cubic.org>
0x16500 belong 0x12014100 D64 Image
0x16500 belong 0x12014180 D71 Image
0x61800 belong 0x28034400 D81 Image
0 string C64\40CARTRIDGE CCS C64 Emultar Cartridge Image
0 belong 0x43154164 X64 Image
0 string GCR-1541 GCR Image
>8 byte x version: $i
>9 byte x tracks: %i
9 string PSUR ARC archive (c64)
2 string -LH1- LHA archive (c64)
0 string C64File PC64 Emulator file
>8 string >\0 "%s"
0 string C64Image PC64 Freezer Image
0 beshort 0x38CD C64 PCLink Image
0 string CBM\144\0\0 Power 64 C64 Emulator Snapshot
0 belong 0xFF424CFF WRAptor packer (c64)

36
contrib/file/Magdir/cad Normal file
View File

@ -0,0 +1,36 @@
#------------------------------------------------------------------------------
# autocad: file(1) magic for cad files
#
# AutoCAD DWG versions R13/R14 (www.autodesk.com)
# Written December 01, 2003 by Lester Hightower
# Based on the DWG File Format Specifications at http://www.opendwg.org/
0 string \101\103\061\060\061 AutoCAD
>5 string \062\000\000\000\000 DWG ver. R13
>5 string \064\000\000\000\000 DWG ver. R14
# Microstation DGN/CIT Files (www.bentley.com)
# Written October 30, 2003 by Lester Hightower
# DGN is the default file extension of Microstation/Intergraph CAD files.
# CIT is the proprietary raster format (similar to TIFF) used to attach
# raster underlays to Microstation DGN (vector) drawings.
#
# http://www.wotsit.org/search.asp
# http://filext.com/detaillist.php?extdetail=DGN
# http://filext.com/detaillist.php?extdetail=CIT
#
# http://www.bentley.com/products/default.cfm?objectid=97F351F5-9C35-4E5E-89C2
# 3F86C928&method=display&p_objectid=97F351F5-9C35-4E5E-89C280A93F86C928
# http://www.bentley.com/products/default.cfm?objectid=A5C2FD43-3AC9-4C71-B682
# 721C479F&method=display&p_objectid=A5C2FD43-3AC9-4C71-B682C7BE721C479F
0 string \010\011\376 Microstation
>3 string \002
>>30 string \372\104 DGN File
>>30 string \172\104 DGN File
>>30 string \026\105 DGN File
>4 string \030\000\000 CIT File
# AutoCad, from Nahuel Greco
0 string AC1012 AutoCad (release 12)
0 string AC1014 AutoCad (release 14)

View File

@ -0,0 +1,9 @@
#------------------------------------------------------------------------------
# chord: file(1) magic for Chord music sheet typesetting utility input files
#
# From Philippe De Muyter <phdm@macqel.be>
# File format is actually free, but many distributed files begin with `{title'
#
0 string {title Chord text file

View File

@ -32,7 +32,7 @@
# a t r i s t sp ^ S cr nl d i v sp #
# .mth Thesaurus
# statrts with \0 but no magic header
# starts with \0 but no magic header
# .chy Hyphenation file
# I am not sure: 000 210 034 000 000

View File

@ -13,6 +13,8 @@
#
# 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
0 string/b #!\ /usr/bin/zsh Paul Falstad's zsh script text executable
0 string/b #!\ /usr/local/bin/zsh Paul Falstad's zsh script text executable
0 string/b #!\ /usr/local/bin/ash Neil Brown's ash script text executable
0 string/b #!\ /usr/local/bin/ae Neil Brown's ae script text executable
@ -40,17 +42,6 @@
0 string #!\ /usr/bin/env a
>16 string >\0 %s script text executable
# generic shell magic
0 string #!\ / a
>3 string >\0 %s script text executable
0 string #!\ / a
>3 string >\0 %s script text executable
0 string #!/ a
>2 string >\0 %s script text executable
0 string #!\ script text executable
>3 string >\0 for %s
# PHP scripts
# Ulf Harnhammar <ulfh@update.uu.se>
0 string/c =<?php PHP script text

View File

@ -0,0 +1,21 @@
#----------------------------------------------------------------------------
# communication
# TTCN is the Tree and Tabular Combined Notation described in ISO 9646-3.
# It is used for conformance testing of communication protocols.
# Added by W. Borgert <debacle@debian.org>.
0 string $Suite TTCN Abstract Test Suite
>&1 string $SuiteId
>>&1 string >\n %s
>&2 string $SuiteId
>>&1 string >\n %s
>&3 string $SuiteId
>>&1 string >\n %s
# MSC (message sequence charts) are a formal description technique,
# described in ITU-T Z.120, mainly used for communication protocols.
# Added by W. Borgert <debacle@debian.org>.
0 string mscdocument Message Sequence Chart (document)
0 string msc Message Sequence Chart (chart)
0 string submsc Message Sequence Chart (subchart)

View File

@ -46,10 +46,8 @@
>2 belong >1 \b, %d characters originally
>2 belong =1 \b, %d character originally
#
# This magic number is byte-order-independent. XXX - Does that mean this
# is big-endian, little-endian, either, or that you can't tell?
# this short is valid for SunOS
0 short 017437 old packed data
# This magic number is byte-order-independent.
0 short 0x1f1f old packed data
# XXX - why *two* entries for "compacted data", one of which is
# byte-order independent, and one of which is byte-order dependent?
@ -169,3 +167,6 @@
0 string 7z\274\257\047\034 7z archive data,
>6 byte x version %d
>7 byte x \b.%d
# AFX compressed files (Wolfram Kleff)
2 string -afx- AFX compressed file data

View File

@ -119,4 +119,37 @@
#------------------------------------------------------------------------------
# msx: file(1) magic for MSX game cartridge dumps
0 beshort 0x4142 MSX game cartridge dump
# Too simple - MPi
#0 beshort 0x4142 MSX game cartridge dump
#------------------------------------------------------------------------------
# Sony Playstation executables (Adam Sjoegren <asjo@diku.dk>) :
0 string PS-X\ EXE Sony Playstation executable
# Area:
>113 string x (%s)
#------------------------------------------------------------------------------
# Microsoft Xbox executables .xbe (Esa Hyytiä <ehyytia@cc.hut.fi>)
0 string XBEH XBE, Microsoft Xbox executable
# probabilistic checks whether signed or not
>0x0004 ulelong =0x0
>>&2 ulelong =0x0
>>>&2 ulelong =0x0 \b, not signed
>0x0004 ulelong >0
>>&2 ulelong >0
>>>&2 ulelong >0 \b, signed
# expect base address of 0x10000
>0x0104 ulelong =0x10000
>>(0x0118-0x0FF60) ulelong&0x80000007 0x80000007 \b, all regions
>>(0x0118-0x0FF60) ulelong&0x80000007 !0x80000007
>>>(0x0118-0x0FF60) ulelong >0 (regions:
>>>>(0x0118-0x0FF60) ulelong &0x00000001 NA
>>>>(0x0118-0x0FF60) ulelong &0x00000002 Japan
>>>>(0x0118-0x0FF60) ulelong &0x00000004 Rest_of_World
>>>>(0x0118-0x0FF60) ulelong &0x80000000 Manufacturer
>>>(0x0118-0x0FF60) ulelong >0 \b)
# --------------------------------
# Microsoft Xbox data file formats
0 string XIP0 XIP, Microsoft Xbox data
0 string XTF0 XTF, Microsoft Xbox data

10
contrib/file/Magdir/dact Normal file
View File

@ -0,0 +1,10 @@
#------------------------------------------------------------------------------
# dact: file(1) magic for DACT compressed files
#
0 long 0x444354C3 DACT compressed data
>4 byte >-1 (version %i.
>5 byte >-1 $BS%i.
>6 byte >-1 $BS%i)
>7 long >0 $BS, original size: %i bytes
>15 long >30 $BS, block size: %i bytes

View File

@ -78,3 +78,126 @@
0 string root\0 ROOT file
>4 belong x Version %d
>33 belong x (Compression: %d)
# XXX: Weak magic.
# Alex Ott <ott@jet.msk.su>
## Paradox file formats
#2 leshort 0x0800 Paradox
#>0x39 byte 3 v. 3.0
#>0x39 byte 4 v. 3.5
#>0x39 byte 9 v. 4.x
#>0x39 byte 10 v. 5.x
#>0x39 byte 11 v. 5.x
#>0x39 byte 12 v. 7.x
#>>0x04 byte 0 indexed .DB data file
#>>0x04 byte 1 primary index .PX file
#>>0x04 byte 2 non-indexed .DB data file
#>>0x04 byte 3 non-incrementing secondary index .Xnn file
#>>0x04 byte 4 secondary index .Ynn file
#>>0x04 byte 5 incrementing secondary index .Xnn file
#>>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
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x03
#>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
#>8 leshort >0
#>>12 leshort 0 dBASE IV no memo file
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x05
#>8 leshort >0
#>>12 leshort 0 dBASE V no memo file
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x30
#>8 leshort >0
#>>12 leshort 0 Visual FoxPro
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x43
#>8 leshort >0
#>>12 leshort 0 FlagShip with memo var size
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x7b
#>8 leshort >0
#>>12 leshort 0 dBASEIV with memo
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x83
#>8 leshort >0
#>>12 leshort 0 FoxBase+, dBaseIII+ with memo
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x8b
#>8 leshort >0
#>>12 leshort 0 dBaseIV with memo
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x8e
#>8 leshort >0
#>>12 leshort 0 dBaseIV with SQL Table
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0xb3
#>8 leshort >0
#>>12 leshort 0 FlagShip with .dbt memo
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0xf5
#>8 leshort >0
#>>12 leshort 0 FoxPro with memo
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 leshort 0x0006 DBase 3 index file
# MS Access database
4 string Standard\ Jet\ DB Microsoft Access Database
# TDB database from Samba et al - Martin Pool <mbp@samba.org>
0 string TDB\ file TDB database
>32 lelong 0x2601196D version 6, little-endian
>>36 lelong x hash size %d bytes
# SE Linux policy database
0 lelong 0xf97cff8c SE Linux policy
>16 lelong x v%d
>20 lelong 1 MLS
>24 lelong x %d symbols
>28 lelong x %d ocons
# ICE authority file data (Wolfram Kleff)
2 string ICE ICE authority data
# X11 Xauthority file (Wolfram Kleff)
10 string MIT-MAGIC-COOKIE-1 X11 Xauthority data
11 string MIT-MAGIC-COOKIE-1 X11 Xauthority data
12 string MIT-MAGIC-COOKIE-1 X11 Xauthority data
13 string MIT-MAGIC-COOKIE-1 X11 Xauthority data
14 string MIT-MAGIC-COOKIE-1 X11 Xauthority data
15 string MIT-MAGIC-COOKIE-1 X11 Xauthority data
16 string MIT-MAGIC-COOKIE-1 X11 Xauthority data
17 string MIT-MAGIC-COOKIE-1 X11 Xauthority data
18 string MIT-MAGIC-COOKIE-1 X11 Xauthority data

View File

@ -6,8 +6,3 @@
0 string ***\ 'diff' output text
0 string Only\ in\ 'diff' output text
0 string Common\ subdirectories:\ 'diff' output text
# xdelta is like diff(1) for binary files (works for text, too).
# Available from: ftp://ftp.xcf.berkeley.edu/pub/xdelta/
0 string %XDZ xdelta diff file
>4 string >% version %.3s

View File

@ -12,9 +12,14 @@
>4 byte 0 invalid class
>4 byte 1 32-bit
# only for MIPS - in the future, the ABI field of e_flags should be used.
>>18 leshort 8
>>>36 lelong &0x20 N32
>>18 leshort 10
>>>36 lelong &0x20 N32
>>18 beshort 8
>>>36 belong &0x20 N32
>>18 beshort 10
>>>36 belong &0x20 N32
>>>36 belong &0x20 N32
>4 byte 2 64-bit
>5 byte 0 invalid byte order
>5 byte 1 LSB
@ -77,12 +82,14 @@
>>18 leshort 17 Fujitsu VPP500,
>>18 leshort 18 SPARC32PLUS,
>>18 leshort 20 PowerPC,
>>18 leshort 22 IBM S/390,
>>18 leshort 36 NEC V800,
>>18 leshort 37 Fujitsu FR20,
>>18 leshort 38 TRW RH-32,
>>18 leshort 39 Motorola RCE,
>>18 leshort 40 ARM,
>>18 leshort 41 Alpha,
>>18 leshort 0xa390 IBM S/390 (obsolete),
>>18 leshort 42 Hitachi SH,
>>18 leshort 43 SPARC V9 - invalid byte order,
>>18 leshort 44 Siemens Tricore Embedded Processor,
@ -162,6 +169,7 @@
>>>36 belong&0xffff00 &0x000800 Sun UltraSPARC3 Extensions Required,
>>18 beshort 20 PowerPC or cisco 4500,
>>18 beshort 21 cisco 7500,
>>18 beshort 22 IBM S/390,
>>18 beshort 24 cisco SVIP,
>>18 beshort 25 cisco 7200,
>>18 beshort 36 NEC V800 or cisco 12000,
@ -186,10 +194,14 @@
>>18 beshort 75 Digital VAX,
>>18 beshort 97 NatSemi 32k,
>>18 beshort 0x9026 Alpha (unofficial),
>>18 beshort 0xa390 IBM S/390 (obsolete),
>>20 belong 0 invalid version
>>20 belong 1 version 1
>>36 belong 1 MathCoPro/FPU/MAU Required
>8 string >\0 (%s)
# Up to now only 0, 1 and 2 are defined; I've seen a file with 0x83, it seemed
# like proper ELF, but extracting the string had bad results.
>4 byte <0x80
>>8 string >\0 (%s)
>8 string \0
>>7 byte 0 (SYSV)
>>7 byte 1 (HP-UX)

8
contrib/file/Magdir/fcs Normal file
View File

@ -0,0 +1,8 @@
#------------------------------------------------------------------------------
# fcs: file(1) magic for FCS (Flow Cytometry Standard) data files
# From Roger Leigh <roger@whinlatter.uklinux.net>
0 string FCS1.0 Flow Cytometry Standard (FCS) data, version 1.0
0 string FCS2.0 Flow Cytometry Standard (FCS) data, version 2.0
0 string FCS3.0 Flow Cytometry Standard (FCS) data, version 3.0

View File

@ -205,8 +205,8 @@
# SGI XFS filesystem - Nathan Scott <nathans@debian.org>
0 belong 0x58465342 SGI XFS filesystem data
>0x4 belong x (blksz=3D%d,
>0x68 beshort x inosz=3D%d,
>0x4 belong x (blksz %d,
>0x68 beshort x inosz %d,
>0x64 beshort ^0x2004 v1 dirs)
>0x64 beshort &0x2004 v2 dirs)
@ -276,5 +276,62 @@
# CDROM Filesystems
32769 string CD001 ISO 9660 CD-ROM filesystem data
# "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
# cramfs filesystem - russell@coker.com.au
0 lelong 0x28cd3d45 Linux Compressed ROM File System data, little endian
>4 lelong x size %d
>8 lelong &1 version #2
>8 lelong &2 sorted_dirs
>8 lelong &4 hole_support
>32 lelong x CRC 0x%x,
>36 lelong x edition %d,
>40 lelong x %d blocks,
>44 lelong x %d files
0 belong 0x28cd3d45 Linux Compressed ROM File System data, big endian
>4 belong x size %d
>8 belong &1 version #2
>8 belong &2 sorted_dirs
>8 belong &4 hole_support
>32 belong x CRC 0x%x,
>36 belong x edition %d,
>40 belong x %d blocks,
>44 belong x %d files
# reiserfs - russell@coker.com.au
0x10034 string ReIsErFs ReiserFS V3.5
0x10034 string ReIsEr2Fs ReiserFS V3.6
>0x1002c leshort x block size %d
>0x10032 leshort &2 (mounted or unclean)
>0x10000 lelong x num blocks %d
>0x10040 lelong 1 tea hash
>0x10040 lelong 2 yura hash
>0x10040 lelong 3 r5 hash
# JFFS - russell@coker.com.au
0 lelong 0x34383931 Linux Journalled Flash File system, little endian
0 belong 0x34383931 Linux Journalled Flash File system, big endian
# EST flat binary format (which isn't, but anyway)
# From: Mark Brown <broonie@sirena.org.uk>
0 string ESTFBINR EST flat binary
# Aculab VoIP firmware
# From: Mark Brown <broonie@sirena.org.uk>
0 string VoIP\ Startup\ and Aculab VoIP firmware
>35 string x format %s
# PPCBoot image file
# From: Mark Brown <broonie@sirena.org.uk>
0 belong 0x27051956 PPCBoot image
>4 string PPCBoot
>>12 string x version %s
# JFFS2 file system
0 leshort 0x1984 Linux old jffs2 filesystem data little endian
0 lelong 0xe0011985 Linux jffs2 filesystem data little endian

View File

@ -8,6 +8,8 @@
#
0 string FWS Macromedia Flash data,
>3 byte x version %d
0 string CWS Macromedia Flash data (compressed),
>3 byte x version %d
#
# From Dave Wilson
0 string AGD4\xbe\xb8\xbb\xcb\x00 Macromedia Freehand 9 Document

View File

@ -7,9 +7,9 @@
0 short 017001 byte-swapped Berkeley vfont data
# PostScript fonts (must precede "printer" entries), quinlan@yggdrasil.com
0 string %!PS-AdobeFont-1.0 PostScript Type 1 font text
0 string %!PS-AdobeFont-1. PostScript Type 1 font text
>20 string >\0 (%s)
6 string %!PS-AdobeFont-1.0 PostScript Type 1 font program data
6 string %!PS-AdobeFont-1. PostScript Type 1 font program data
# X11 font files in SNF (Server Natural Format) format
0 belong 00000004 X11 SNF font data, MSB first
@ -49,3 +49,13 @@
# downloadable fonts for browser (prints type) anthon@mnt.org
0 string PFR1 PFR1 font
>102 string >0 \b: %s
# True Type fonts
0 string \000\001\000\000\000 TrueType font data
0 string \007\001\001\000Copyright\ (c)\ 199 Adobe Multiple Master font
0 string \012\001\001\000Copyright\ (c)\ 199 Adobe Multiple Master font
# Opentype font data from Avi Bercovich
0 string OTTO OpenType font data

157
contrib/file/Magdir/games Normal file
View File

@ -0,0 +1,157 @@
#------------------------------------------------------------------------------
# games: file(1) for games
# Thomas M. Ott (ThMO)
1 string =WAD DOOM data,
>0 string =I main wad
>0 string =P patch wad
>0 byte x unknown junk
# Fabio Bonelli <fabiobonelli@libero.it>
# Quake II - III data files
0 string IDP2 Quake II 3D Model file,
>20 long x %lu skin(s),
>8 long x (%lu x
>12 long x %lu),
>40 long x %lu frame(s),
>16 long x Frame size %lu bytes,
>24 long x %lu vertices/frame,
>28 long x %lu texture coordinates,
>32 long x %lu triangles/frame
0 string IBSP Quake
>4 long 0x26 II Map file (BSP)
>4 long 0x2E III Map file (BSP)
0 string IDS2 Quake II SP2 sprite file
#---------------------------------------------------------------------------
# Doom and Quake
# submitted by Nicolas Patrois
# DOOM
0 string IWAD DOOM or DOOM ][ world
0 string PWAD DOOM or DOOM ][ extension world
0 string \xcb\x1dBoom\xe6\xff\x03\x01 Boom or linuxdoom demo
# some doom lmp files don't match, I've got one beginning with \x6d\x02\x01\x01
24 string LxD\ 203 Linuxdoom save
>0 string x , name=%s
>44 string x , world=%s
# Quake
0 string PACK Quake I or II world or extension
#0 string -1\x0a Quake I demo
#>30 string x version %.4s
#>61 string x level %s
#0 string 5\x0a Quake I save
# The levels
# Quake 1
0 string 5\x0aIntroduction Quake I save: start Introduction
0 string 5\x0athe_Slipgate_Complex Quake I save: e1m1 The slipgate complex
0 string 5\x0aCastle_of_the_Damned Quake I save: e1m2 Castle of the damned
0 string 5\x0athe_Necropolis Quake I save: e1m3 The necropolis
0 string 5\x0athe_Grisly_Grotto Quake I save: e1m4 The grisly grotto
0 string 5\x0aZiggurat_Vertigo Quake I save: e1m8 Ziggurat vertigo (secret)
0 string 5\x0aGloom_Keep Quake I save: e1m5 Gloom keep
0 string 5\x0aThe_Door_To_Chthon Quake I save: e1m6 The door to Chthon
0 string 5\x0aThe_House_of_Chthon Quake I save: e1m7 The house of Chthon
0 string 5\x0athe_Installation Quake I save: e2m1 The installation
0 string 5\x0athe_Ogre_Citadel Quake I save: e2m2 The ogre citadel
0 string 5\x0athe_Crypt_of_Decay Quake I save: e2m3 The crypt of decay (dopefish lives!)
0 string 5\x0aUnderearth Quake I save: e2m7 Underearth (secret)
0 string 5\x0athe_Ebon_Fortress Quake I save: e2m4 The ebon fortress
0 string 5\x0athe_Wizard's_Manse Quake I save: e2m5 The wizard's manse
0 string 5\x0athe_Dismal_Oubliette Quake I save: e2m6 The dismal oubliette
0 string 5\x0aTermination_Central Quake I save: e3m1 Termination central
0 string 5\x0aVaults_of_Zin Quake I save: e3m2 Vaults of Zin
0 string 5\x0athe_Tomb_of_Terror Quake I save: e3m3 The tomb of terror
0 string 5\x0aSatan's_Dark_Delight Quake I save: e3m4 Satan's dark delight
0 string 5\x0athe_Haunted_Halls Quake I save: e3m7 The haunted halls (secret)
0 string 5\x0aWind_Tunnels Quake I save: e3m5 Wind tunnels
0 string 5\x0aChambers_of_Torment Quake I save: e3m6 Chambers of torment
0 string 5\x0athe_Sewage_System Quake I save: e4m1 The sewage system
0 string 5\x0aThe_Tower_of_Despair Quake I save: e4m2 The tower of despair
0 string 5\x0aThe_Elder_God_Shrine Quake I save: e4m3 The elder god shrine
0 string 5\x0athe_Palace_of_Hate Quake I save: e4m4 The palace of hate
0 string 5\x0aHell's_Atrium Quake I save: e4m5 Hell's atrium
0 string 5\x0athe_Nameless_City Quake I save: e4m8 The nameless city (secret)
0 string 5\x0aThe_Pain_Maze Quake I save: e4m6 The pain maze
0 string 5\x0aAzure_Agony Quake I save: e4m7 Azure agony
0 string 5\x0aShub-Niggurath's_Pit Quake I save: end Shub-Niggurath's pit
# Quake DeathMatch levels
0 string 5\x0aPlace_of_Two_Deaths Quake I save: dm1 Place of two deaths
0 string 5\x0aClaustrophobopolis Quake I save: dm2 Claustrophobopolis
0 string 5\x0aThe_Abandoned_Base Quake I save: dm3 The abandoned base
0 string 5\x0aThe_Bad_Place Quake I save: dm4 The bad place
0 string 5\x0aThe_Cistern Quake I save: dm5 The cistern
0 string 5\x0aThe_Dark_Zone Quake I save: dm6 The dark zone
# Scourge of Armagon
0 string 5\x0aCommand_HQ Quake I save: start Command HQ
0 string 5\x0aThe_Pumping_Station Quake I save: hip1m1 The pumping station
0 string 5\x0aStorage_Facility Quake I save: hip1m2 Storage facility
0 string 5\x0aMilitary_Complex Quake I save: hip1m5 Military complex (secret)
0 string 5\x0athe_Lost_Mine Quake I save: hip1m3 The lost mine
0 string 5\x0aResearch_Facility Quake I save: hip1m4 Research facility
0 string 5\x0aAncient_Realms Quake I save: hip2m1 Ancient realms
0 string 5\x0aThe_Gremlin's_Domain Quake I save: hip2m6 The gremlin's domain (secret)
0 string 5\x0aThe_Black_Cathedral Quake I save: hip2m2 The black cathedral
0 string 5\x0aThe_Catacombs Quake I save: hip2m3 The catacombs
0 string 5\x0athe_Crypt__ Quake I save: hip2m4 The crypt
0 string 5\x0aMortum's_Keep Quake I save: hip2m5 Mortum's keep
0 string 5\x0aTur_Torment Quake I save: hip3m1 Tur torment
0 string 5\x0aPandemonium Quake I save: hip3m2 Pandemonium
0 string 5\x0aLimbo Quake I save: hip3m3 Limbo
0 string 5\x0athe_Edge_of_Oblivion Quake I save: hipdm1 The edge of oblivion (secret)
0 string 5\x0aThe_Gauntlet Quake I save: hip3m4 The gauntlet
0 string 5\x0aArmagon's_Lair Quake I save: hipend Armagon's lair
# Malice
0 string 5\x0aThe_Academy Quake I save: start The academy
0 string 5\x0aThe_Lab Quake I save: d1 The lab
0 string 5\x0aArea_33 Quake I save: d1b Area 33
0 string 5\x0aSECRET_MISSIONS Quake I save: d3b Secret missions
0 string 5\x0aThe_Hospital Quake I save: d10 The hospital (secret)
0 string 5\x0aThe_Genetics_Lab Quake I save: d11 The genetics lab (secret)
0 string 5\x0aBACK_2_MALICE Quake I save: d4b Back to Malice
0 string 5\x0aArea44 Quake I save: d1c Area 44
0 string 5\x0aTakahiro_Towers Quake I save: d2 Takahiro towers
0 string 5\x0aA_Rat's_Life Quake I save: d3 A rat's life
0 string 5\x0aInto_The_Flood Quake I save: d4 Into the flood
0 string 5\x0aThe_Flood Quake I save: d5 The flood
0 string 5\x0aNuclear_Plant Quake I save: d6 Nuclear plant
0 string 5\x0aThe_Incinerator_Plant Quake I save: d7 The incinerator plant
0 string 5\x0aThe_Foundry Quake I save: d7b The foundry
0 string 5\x0aThe_Underwater_Base Quake I save: d8 The underwater base
0 string 5\x0aTakahiro_Base Quake I save: d9 Takahiro base
0 string 5\x0aTakahiro_Laboratories Quake I save: d12 Takahiro laboratories
0 string 5\x0aStayin'_Alive Quake I save: d13 Stayin' alive
0 string 5\x0aB.O.S.S._HQ Quake I save: d14 B.O.S.S. HQ
0 string 5\x0aSHOWDOWN! Quake I save: d15 Showdown!
# Malice DeathMatch levels
0 string 5\x0aThe_Seventh_Precinct Quake I save: ddm1 The seventh precinct
0 string 5\x0aSub_Station Quake I save: ddm2 Sub station
0 string 5\x0aCrazy_Eights! Quake I save: ddm3 Crazy eights!
0 string 5\x0aEast_Side_Invertationa Quake I save: ddm4 East side invertationa
0 string 5\x0aSlaughterhouse Quake I save: ddm5 Slaughterhouse
0 string 5\x0aDOMINO Quake I save: ddm6 Domino
0 string 5\x0aSANDRA'S_LADDER Quake I save: ddm7 Sandra's ladder
0 string MComprHD MAME CHD compressed hard disk image,
>12 belong x version %lu

16
contrib/file/Magdir/gcc Normal file
View File

@ -0,0 +1,16 @@
#------------------------------------------------------------------------------
# gcc: file(1) magic for GCC special files
#
0 string gpch GCC precompiled header
# The version field is annoying. It's 3 characters, not zero-terminated.
>5 byte x (version %c
>6 byte x \b%c
>7 byte x \b%c)
# 67 = 'C', 111 = 'o', 43 = '+', 79 = 'O'
>4 byte 67 for C
>4 byte 111 for Objective C
>4 byte 43 for C++
>4 byte 79 for Objective C++

19
contrib/file/Magdir/geos Normal file
View File

@ -0,0 +1,19 @@
#------------------------------------------------------------------------------
# GEOS files (Vidar Madsen, vidar@gimp.org)
# semi-commonly used in embedded and handheld systems.
0 belong 0xc745c153 GEOS
>40 byte 1 executable
>40 byte 2 VMFile
>40 byte 3 binary
>40 byte 4 directory label
>40 byte <1 unknown
>40 byte >4 unknown
>4 string >\0 \b, name "%s"
#>44 short x \b, version %d
#>46 short x \b.%d
#>48 short x \b, rev %d
#>50 short x \b.%d
#>52 short x \b, proto %d
#>54 short x \br%d
#>168 string >\0 \b, copyright "%s"

View File

@ -10,3 +10,15 @@
# message catalogs, from Mitchum DSouza <m.dsouza@mrc-apu.cam.ac.uk>
0 string *nazgul* Nazgul style compiled message catalog
>8 lelong >0 \b, version %ld
# GnuPG
# The format is very similar to pgp
0 string \001gpg GPG key trust database
>4 byte x version %d
0 beshort 0x9901 GPG key public ring
# This magic is not particularly good, as the keyrings don't have true
# magic. Nevertheless, it covers many keyrings.
# Gnumeric spreadsheet
# This entry is only semi-helpful, as Gnumeric compresses its files, so
# they will ordinarily reported as "compressed", but at least -z helps
39 string =<gmr:Workbook Gnumeric spreadsheet

View File

@ -1,25 +1,25 @@
#------------------------------------------------------------------------------
# human68k: file(1) magic for Human68k (X680x0 DOS) binary formats
0 string HU Human68k
>68 string LZX LZX compressed
>>72 string >\0 (version %s)
>(8.L+74) string LZX LZX compressed
>>(8.L+78) string >\0 (version %s)
>60 belong >0 binded
>(8.L+66) string #HUPAIR hupair
>0 string HU X executable
>(8.L+74) string #LIBCV1 - linked PD LIBC ver 1
>4 belong >0 - base address 0x%x
>28 belong >0 not stripped
>32 belong >0 with debug information
0 beshort 0x601a Human68k Z executable
0 beshort 0x6000 Human68k object file
0 belong 0xd1000000 Human68k ar binary archive
0 belong 0xd1010000 Human68k ar ascii archive
0 beshort 0x0068 Human68k lib archive
4 string LZX Human68k LZX compressed
>8 string >\0 (version %s)
>4 string LZX R executable
2 string #HUPAIR Human68k hupair R executable
# Magic too short!
#0 string HU Human68k
#>68 string LZX LZX compressed
#>>72 string >\0 (version %s)
#>(8.L+74) string LZX LZX compressed
#>>(8.L+78) string >\0 (version %s)
#>60 belong >0 binded
#>(8.L+66) string #HUPAIR hupair
#>0 string HU X executable
#>(8.L+74) string #LIBCV1 - linked PD LIBC ver 1
#>4 belong >0 - base address 0x%x
#>28 belong >0 not stripped
#>32 belong >0 with debug information
#0 beshort 0x601a Human68k Z executable
#0 beshort 0x6000 Human68k object file
#0 belong 0xd1000000 Human68k ar binary archive
#0 belong 0xd1010000 Human68k ar ascii archive
#0 beshort 0x0068 Human68k lib archive
#4 string LZX Human68k LZX compressed
#>8 string >\0 (version %s)
#>4 string LZX R executable
#2 string #HUPAIR Human68k hupair R executable

View File

@ -15,3 +15,5 @@
0 string 0xabcdef AIX message catalog
0 belong 0x000001f9 AIX compiled message catalog
0 string \<aiaff> archive
0 string \<bigaf> archive (big format)

View File

@ -16,6 +16,8 @@
>8 string AIFC \b, AIFF-C compressed audio
>8 string 8SVX \b, 8SVX 8-bit sampled sound voice
>8 string SAMP \b, SAMP sampled audio
>8 string DTYP \b, DTYP datatype description
>8 string PTCH \b, PTCH binary patch
# image formats
>8 string ILBMBMHD \b, ILBM interleaved image
>>20 beshort x \b, %d x
@ -26,3 +28,5 @@
>8 string TDDD \b, TDDD 3-D rendering
# other formats
>8 string FTXT \b, FTXT formatted text
>8 string CTLG \b, CTLG message catalog
>8 string PREF \b, PREF preferences

View File

@ -17,10 +17,16 @@
# `tgatoppm' recognizes a superset (Index may be anything)
1 belong&0xfff7ffff 0x01010000 Targa image data - Map
>2 byte&8 8 - RLE
>12 leshort >0 %hd x
>14 leshort >0 %hd
1 belong&0xfff7ffff 0x00020000 Targa image data - RGB
>2 byte&8 8 - RLE
>12 leshort >0 %hd x
>14 leshort >0 %hd
1 belong&0xfff7ffff 0x00030000 Targa image data - Mono
>2 byte&8 8 - RLE
>12 leshort >0 %hd x
>14 leshort >0 %hd
# PBMPLUS images
# The next byte following the magic is always whitespace.
@ -158,10 +164,11 @@
>>18 lelong x \b, %d x
>>22 lelong x %d x
>>28 leshort x %d
0 string IC PC icon data
0 string PI PC pointer image data
0 string CI PC color icon data
0 string CP PC color pointer image data
# Too simple - MPi
#0 string IC PC icon data
#0 string PI PC pointer image data
#0 string CI PC color icon data
#0 string CP PC color pointer image data
# Conflicts with other entries [BABYL]
#0 string BA PC bitmap array data
@ -269,11 +276,11 @@
# DICOM medical imaging data
128 string DICM DICOM medical imaging data
# XWD - X-Windows Dump file.
# XWD - X Window Dump file.
# As described in /usr/X11R6/include/X11/XWDFile.h
# used by the xwd program.
# Bradford Castalia, idaeim, 1/01
4 belong 7 XWD X-Windows Dump image data
4 belong 7 XWD X Window Dump image data
>100 string >\0 \b, "%s"
>16 belong x \b, %dx
>20 belong x \b%dx
@ -359,3 +366,156 @@
>>14 leshort x %hd dpi,
>2 byte 0 uncompressed
>2 byte 1 RLE compressed
# Adobe Photoshop
0 string 8BPS Adobe Photoshop Image
# XV thumbnail indicator (ThMO)
0 string P7\ 332 XV thumbnail image data
# NITF is defined by United States MIL-STD-2500A
0 string NITF National Imagery Transmission Format
>25 string >\0 dated %.14s
# GEM Image: Version 1, Headerlen 8 (Wolfram Kleff)
0 belong 0x00010008 GEM Image data
>12 beshort x %d x
>14 beshort x %d,
>4 beshort x %d planes,
>8 beshort x %d x
>10 beshort x %d pixelsize
# GEM Metafile (Wolfram Kleff)
0 lelong 0x0018FFFF GEM Metafile data
>4 leshort x version %d
#
# SMJPEG. A custom Motion JPEG format used by Loki Entertainment
# Software Torbjorn Andersson <d91tan@Update.UU.SE>.
#
0 string \0\nSMJPEG SMJPEG
>8 belong x %d.x data
# According to the specification you could find any number of _TXT
# headers here, but I can't think of any way of handling that. None of
# the SMJPEG files I tried it on used this feature. Even if such a
# file is encountered the output should still be reasonable.
>16 string _SND \b,
>>24 beshort >0 %d Hz
>>26 byte 8 8-bit
>>26 byte 16 16-bit
>>28 string NONE uncompressed
# >>28 string APCM ADPCM compressed
>>27 byte 1 mono
>>28 byte 2 stereo
# Help! Isn't there any way to avoid writing this part twice?
>>32 string _VID \b,
# >>>48 string JFIF JPEG
>>>40 belong >0 %d frames
>>>44 beshort >0 (%d x
>>>46 beshort >0 %d)
>16 string _VID \b,
# >>32 string JFIF JPEG
>>24 belong >0 %d frames
>>28 beshort >0 (%d x
>>30 beshort >0 %d)
0 string Paint\ Shop\ Pro\ Image\ File Paint Shop Pro Image File
# "thumbnail file" (icon)
# descended from "xv", but in use by other applications as well (Wolfram Kleff)
0 string P7\ 332 XV "thumbnail file" (icon) data
# taken from fkiss: (<yav@mte.biglobe.ne.jp> ?)
0 string KiSS KISS/GS
>4 byte 16 color
>>5 byte x %d bit
>>8 leshort x %d colors
>>10 leshort x %d groups
>4 byte 32 cell
>>5 byte x %d bit
>>8 leshort x %d x
>>10 leshort x %d
>>12 leshort x +%d
>>14 leshort x +%d
# Webshots (www.webshots.com), by John Harrison
0 string C\253\221g\230\0\0\0 Webshots Desktop .wbz file
# Hercules DASD image files
# From Jan Jaeger <jj@septa.nl>
0 string CKD_P370 Hercules CKD DASD image file
>8 long x \b, %d heads per cylinder
>12 long x \b, track size %d bytes
>16 byte x \b, device type 33%2.2X
0 string CKD_C370 Hercules compressed CKD DASD image file
>8 long x \b, %d heads per cylinder
>12 long x \b, track size %d bytes
>16 byte x \b, device type 33%2.2X
0 string CKD_S370 Hercules CKD DASD shadow file
>8 long x \b, %d heads per cylinder
>12 long x \b, track size %d bytes
>16 byte x \b, device type 33%2.2X
# Squeak images and - etoffi@softhome.net
0 string \146\031\0\0 Squeak image data
0 string 'From\040Squeak Squeak program text
# partimage: file(1) magic for PartImage files (experimental, incomplete)
# Author: Hans-Joachim Baader <hjb@pro-linux.de>
0 string PaRtImAgE-VoLuMe PartImage
>0x0020 string 0.6.1 file version %s
>>0x0060 lelong >-1 volume %ld
#>>0x0064 8 byte identifier
#>>0x007c reserved
>>0x0200 string >\0 type %s
>>0x1400 string >\0 device %s,
>>0x1600 string >\0 original filename %s,
# Some fields omitted
>>0x2744 lelong 0 not compressed
>>0x2744 lelong 1 gzip compressed
>>0x2744 lelong 2 bzip2 compressed
>>0x2744 lelong >2 compressed with unknown algorithm
>0x0020 string >0.6.1 file version %s
>0x0020 string <0.6.1 file version %s
# DCX is multi-page PCX, using a simple header of up to 1024
# offsets for the respective PCX components.
# From: Joerg Wunsch <joerg_wunsch@uriah.heep.sax.de>
0 lelong 987654321 DCX multi-page PCX image data
# Simon Walton <simonw@matteworld.com>
# Kodak Cineon format for scanned negatives
# http://www.kodak.com/US/en/motion/support/dlad/
0 lelong 0xd75f2a80 Cineon image data
>200 belong >0 \b, %ld x
>204 belong >0 %ld
# Bio-Rad .PIC is an image format used by microscope control systems
# and related image processing software used by biologists.
# From: Vebjorn Ljosa <vebjorn@ljosa.com>
54 leshort 12345 Bio-Rad .PIC Image File
>0 leshort >0 %hd x
>2 leshort >0 %hd,
>4 leshort =1 1 image in file
>4 leshort >1 %hd images in file
# From Jan "Yenya" Kasprzak <kas@fi.muni.cz>
# The description of *.mrw format can be found at
# http://www.dalibor.cz/minolta/raw_file_format.htm
0 string \000MRM Minolta Dimage camera raw image data
# From: stephane.loeuillet@tiscali.f
# http://www.djvuzone.org/
0 string AT&TFORM DjVu Image file
# From: Jason Bacon <bacon@smithers.neuro.mcw.edu>
0 beshort 0x3020 character Computer Graphics Metafile
# From: Tom Hilinski <tom.hilinski@comcast.net>
# http://www.unidata.ucar.edu/packages/netcdf/
0 string CDF\001 netcdf file

View File

@ -33,3 +33,15 @@
0 leshort =0514 80386 COFF executable
>12 lelong >0 not stripped
>22 leshort >0 - version %ld
# rom: file(1) magic for BIOS ROM Extensions found in intel machines
# mapped into memory between 0xC0000 and 0xFFFFF
# From Gürkan Sengün <gurkan@linuks.mine.nu>, www.linuks.mine.nu
0 beshort 0x55AA BIOS (ia32) ROM Ext.
>5 string USB USB
>7 string LDR UNDI image
>30 string IBM IBM comp. Video
>26 string Adaptec Adaptec
>28 string Adaptec Adaptec
>42 string PROMISE Promise
>2 byte x (%d*512)

View File

@ -10,22 +10,113 @@
#
0 beshort 0xffd8 JPEG image data
>6 string JFIF \b, JFIF standard
>6 string Exif \b, EXIF 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
# tests are not fool-proof since some perfectly valid JPEGs are currently
# impossible to specify in magic(4) format.
# First, a little JFIF version info:
>11 byte x \b %d.
>12 byte x \b%02d
>>11 byte x \b %d.
>>12 byte x \b%02d
# Next, the resolution or aspect ratio of the image:
>13 byte 0 \b, aspect ratio
>13 byte 1 \b, resolution (DPI)
>13 byte 2 \b, resolution (DPCM)
#>4 beshort x \b, segment length %d
#>>13 byte 0 \b, aspect ratio
#>>13 byte 1 \b, resolution (DPI)
#>>13 byte 2 \b, resolution (DPCM)
#>>4 beshort x \b, segment length %d
# Next, show thumbnail info, if it exists:
>18 byte !0 \b, thumbnail %dx
>>19 byte x \b%d
>>18 byte !0 \b, thumbnail %dx
>>>19 byte x \b%d
# EXIF moved down here to avoid reporting a bogus version number,
# and EXIF version number printing added.
# - Patrik R=E5dman <patrik+file-magic@iki.fi>
>6 string Exif \b, EXIF standard
# Look for EXIF IFD offset in IFD 0, and then look for EXIF version tag in EXIF IFD.
# All possible combinations of entries have to be enumerated, since no looping
# is possible. And both endians are possible...
# The combinations included below are from real-world JPEGs.
# Little-endian
>>12 string II
# IFD 0 Entry #5:
>>>70 leshort 0x8769
# EXIF IFD Entry #1:
>>>>(78.l+14) leshort 0x9000
>>>>>(78.l+23) byte x %c
>>>>>(78.l+24) byte x \b.%c
>>>>>(78.l+25) byte !0x30 \b%c
# IFD 0 Entry #9:
>>>118 leshort 0x8769
# EXIF IFD Entry #3:
>>>>(126.l+38) leshort 0x9000
>>>>>(126.l+47) byte x %c
>>>>>(126.l+48) byte x \b.%c
>>>>>(126.l+49) byte !0x30 \b%c
# IFD 0 Entry #10
>>>130 leshort 0x8769
# EXIF IFD Entry #3:
>>>>(138.l+38) leshort 0x9000
>>>>>(138.l+47) byte x %c
>>>>>(138.l+48) byte x \b.%c
>>>>>(138.l+49) byte !0x30 \b%c
# EXIF IFD Entry #4:
>>>>(138.l+50) leshort 0x9000
>>>>>(138.l+59) byte x %c
>>>>>(138.l+60) byte x \b.%c
>>>>>(138.l+61) byte !0x30 \b%c
# EXIF IFD Entry #5:
>>>>(138.l+62) leshort 0x9000
>>>>>(138.l+71) byte x %c
>>>>>(138.l+72) byte x \b.%c
>>>>>(138.l+73) byte !0x30 \b%c
# IFD 0 Entry #11
>>>142 leshort 0x8769
# EXIF IFD Entry #3:
>>>>(150.l+38) leshort 0x9000
>>>>>(150.l+47) byte x %c
>>>>>(150.l+48) byte x \b.%c
>>>>>(150.l+49) byte !0x30 \b%c
# EXIF IFD Entry #4:
>>>>(150.l+50) leshort 0x9000
>>>>>(150.l+59) byte x %c
>>>>>(150.l+60) byte x \b.%c
>>>>>(150.l+61) byte !0x30 \b%c
# EXIF IFD Entry #5:
>>>>(150.l+62) leshort 0x9000
>>>>>(150.l+71) byte x %c
>>>>>(150.l+72) byte x \b.%c
>>>>>(150.l+73) byte !0x30 \b%c
# Big-endian
>>12 string MM
# IFD 0 Entry #9:
>>>118 beshort 0x8769
# EXIF IFD Entry #1:
>>>>(126.L+14) beshort 0x9000
>>>>>(126.L+23) byte x %c
>>>>>(126.L+24) byte x \b.%c
>>>>>(126.L+25) byte !0x30 \b%c
# EXIF IFD Entry #3:
>>>>(126.L+38) beshort 0x9000
>>>>>(126.L+47) byte x %c
>>>>>(126.L+48) byte x \b.%c
>>>>>(126.L+49) byte !0x30 \b%c
# IFD 0 Entry #10
>>>130 beshort 0x8769
# EXIF IFD Entry #3:
>>>>(138.L+38) beshort 0x9000
>>>>>(138.L+47) byte x %c
>>>>>(138.L+48) byte x \b.%c
>>>>>(138.L+49) byte !0x30 \b%c
# EXIF IFD Entry #5:
>>>>(138.L+62) beshort 0x9000
>>>>>(138.L+71) byte x %c
>>>>>(138.L+72) byte x \b.%c
>>>>>(138.L+73) byte !0x30 \b%c
# IFD 0 Entry #11
>>>142 beshort 0x8769
# EXIF IFD Entry #4:
>>>>(150.L+50) beshort 0x9000
>>>>>(150.L+59) byte x %c
>>>>>(150.L+60) byte x \b.%c
>>>>>(150.L+61) byte !0x30 \b%c
# Here things get sticky. We can do ONE MORE marker segment with
# indirect addressing, and that's all. It would be great if we could
# do pointer arithemetic like in an assembler language. Christos?
@ -33,7 +124,7 @@
# named accumulators, it would be even more effective...
# At least we can show a comment if no other segments got inserted before:
>(4.S+5) byte 0xFE
>>(4.S+8) string >\0 \b, "%s"
>>(4.S+8) string >\0 \b, comment: "%s"
#>(4.S+5) byte 0xFE \b, comment
#>>(4.S+6) beshort x \b length=%d
#>>(4.S+8) string >\0 \b, "%s"
@ -54,8 +145,8 @@
# I've commented-out quantisation table reporting. I doubt anyone cares yet.
#>(4.S+5) byte 0xDB \b, quantisation table
#>>(4.S+6) beshort x \b length=%d
>14 beshort x \b, %d x
>16 beshort x \b %d
#>14 beshort x \b, %d x
#>16 beshort x \b %d
# HSI is Handmade Software's proprietary JPEG encoding scheme
0 string hsi1 JPEG image data, HSI proprietary

View File

@ -44,11 +44,6 @@
# this can be overridden by the DOS executable (COM) entry
2 string LILO Linux/i386 LILO boot/chain loader
#
# Debian Packages, from Peter Tobias <tobias@server.et-inf.fho-emden.de>
0 string 0.9
>8 byte 0x0a old Debian Binary Package
>>3 byte >0 \b, created by dpkg 0.9%c
>>4 byte >0 pl%c
# PSF fonts, from H. Peter Anvin <hpa@yggdrasil.com>
0 leshort 0x0436 Linux/i386 PC Screen Font data,
>2 byte 0 256 characters, no directory,
@ -60,6 +55,8 @@
4086 string SWAP-SPACE Linux/i386 swap file
# according to man page of mkswap (8) March 1999
4086 string SWAPSPACE2 Linux/i386 swap file (new style)
>0x400 long x %d (4K pages)
>0x404 long x size %d pages
# ECOFF magic for OSF/1 and Linux (only tested under Linux though)
#
# from Erik Troan (ewt@redhat.com) examining od dumps, so this
@ -79,28 +76,38 @@
# and others such as Axel Kohlmeyer <akohlmey@rincewind.chemie.uni-ulm.de>
# and Nicolás Lichtmaier <nick@debian.org>
# All known start with: b8 c0 07 8e d8 b8 00 90 8e c0 b9 00 01 29 f6 29
514 string HdrS Linux kernel
>518 leshort >0
>>529 byte 0 zImage data,
>>529 byte 1 bzImage data,
>0x048c byte 0x31
>>0x048c string x version %s
>0x0493 byte 0x31
>>0x0493 string x version %s
>0x048c byte 0x32
>>0x048c string x version %s
>0x0493 byte 0x32
>>0x0493 string x version %s
>0x04df byte 0x32
>>0x04df string x version %s
>0x04fb byte 0x32
>>0x04fb string x version %s
# Linux kernel boot images (i386 arch) (Wolfram Kleff)
514 string HdrS Linux kernel
>510 leshort 0xAA55 x86 boot executable
>>518 leshort >=3D0x200
>>529 byte 0 zImage,
>>>529 byte 1 bzImage,
>>>(526.s+0x200) string >\0 version %s,
>>498 leshort 1 RO-rootFS,
>>498 leshort 0 RW-rootFS,
>>508 leshort >0 root_dev 0x%X,
>>502 leshort >0 swap_dev 0x%X,
>>504 leshort >0 RAMdisksize %u KB,
>>506 leshort 0xFFFF Normal VGA
>>506 leshort 0xFFFE Extended VGA
>>506 leshort 0xFFFD Prompt for Videomode
>>506 leshort >0 Video mode %d
# This also matches new kernels, which were caught above by "HdrS".
0 belong 0xb8c0078e Linux kernel
>0x1e3 string Loading version 1.3.79 or older
>0x1e9 string Loading from prehistoric times
# LSM entries - Nicolás Lichtmaier <nick@feedback.net.ar>
# System.map files - Nicolás Lichtmaier <nick@debian.org>
8 string \ A\ _text Linux kernel symbol map text
# LSM entries - Nicolás Lichtmaier <nick@debian.org>
0 string Begin3 Linux Software Map entry text
0 string Begin4 Linux Software Map entry text (new format)
# From Matt Zimmerman
0 belong 0x4f4f4f4d User-mode Linux COW file
>4 belong x \b, version %d
>8 string >\0 \b, backing file %s
############################################################################
# Linux kernel versions

View File

@ -12,7 +12,10 @@
>12 belong 3 shared library
>12 belong 4 core
>12 belong 5 preload executable
>12 belong >5
>12 belong 6 dynamically linked shared library
>12 belong 7 dynamic linker
>12 belong 8 bundle
>12 belong >8
>>12 belong x filetype=%ld
>4 belong <0
>>4 belong x architecture=%ld
@ -38,6 +41,6 @@
>4 belong 15 i860-big
>4 belong 16 i860
>4 belong 17 rs6000
>4 belong 18 powerPC
>4 belong 18 ppc
>4 belong >18
>>4 belong x architecture=%ld

View File

@ -88,7 +88,8 @@
# that the first one be 0x80, 0x81, 0x82, or 0x83, and that the second
# be 0x81. This works for the files I have, but maybe not for everyone's.
122 beshort&0xFCFF 0x8081 Macintosh MacBinary data
# Unfortunately, this magic is quite weak - MPi
#122 beshort&0xFCFF 0x8081 Macintosh MacBinary data
# MacBinary I doesn't have the version number field at all, but MacBinary II
# has been in use since 1987 so I hope there aren't many really old files
@ -111,117 +112,117 @@
# >73 byte&0x10 0x40 \b, invisible
# >73 byte&0x10 0x80 \b, locked
>65 string x \b, type "%4.4s"
#>65 string x \b, type "%4.4s"
>65 string 8BIM (PhotoShop)
>65 string ALB3 (PageMaker 3)
>65 string ALB4 (PageMaker 4)
>65 string ALT3 (PageMaker 3)
>65 string APPL (application)
>65 string AWWP (AppleWorks word processor)
>65 string CIRC (simulated circuit)
>65 string DRWG (MacDraw)
>65 string EPSF (Encapsulated PostScript)
>65 string FFIL (font suitcase)
>65 string FKEY (function key)
>65 string FNDR (Macintosh Finder)
>65 string GIFf (GIF image)
>65 string Gzip (GNU gzip)
>65 string INIT (system extension)
>65 string LIB\ (library)
>65 string LWFN (PostScript font)
>65 string MSBC (Microsoft BASIC)
>65 string PACT (Compact Pro archive)
>65 string PDF\ (Portable Document Format)
>65 string PICT (picture)
>65 string PNTG (MacPaint picture)
>65 string PREF (preferences)
>65 string PROJ (Think C project)
>65 string QPRJ (Think Pascal project)
>65 string SCFL (Defender scores)
>65 string SCRN (startup screen)
>65 string SITD (StuffIt Deluxe)
>65 string SPn3 (SuperPaint)
>65 string STAK (HyperCard stack)
>65 string Seg\ (StuffIt segment)
>65 string TARF (Unix tar archive)
>65 string TEXT (ASCII)
>65 string TIFF (TIFF image)
>65 string TOVF (Eudora table of contents)
>65 string WDBN (Microsoft Word word processor)
>65 string WORD (MacWrite word processor)
>65 string XLS\ (Microsoft Excel)
>65 string ZIVM (compress (.Z))
>65 string ZSYS (Pre-System 7 system file)
>65 string acf3 (Aldus FreeHand)
>65 string cdev (control panel)
>65 string dfil (Desk Acessory suitcase)
>65 string libr (library)
>65 string nX^d (WriteNow word processor)
>65 string nX^w (WriteNow dictionary)
>65 string rsrc (resource)
>65 string scbk (Scrapbook)
>65 string shlb (shared library)
>65 string ttro (SimpleText read-only)
>65 string zsys (system file)
#>65 string 8BIM (PhotoShop)
#>65 string ALB3 (PageMaker 3)
#>65 string ALB4 (PageMaker 4)
#>65 string ALT3 (PageMaker 3)
#>65 string APPL (application)
#>65 string AWWP (AppleWorks word processor)
#>65 string CIRC (simulated circuit)
#>65 string DRWG (MacDraw)
#>65 string EPSF (Encapsulated PostScript)
#>65 string FFIL (font suitcase)
#>65 string FKEY (function key)
#>65 string FNDR (Macintosh Finder)
#>65 string GIFf (GIF image)
#>65 string Gzip (GNU gzip)
#>65 string INIT (system extension)
#>65 string LIB\ (library)
#>65 string LWFN (PostScript font)
#>65 string MSBC (Microsoft BASIC)
#>65 string PACT (Compact Pro archive)
#>65 string PDF\ (Portable Document Format)
#>65 string PICT (picture)
#>65 string PNTG (MacPaint picture)
#>65 string PREF (preferences)
#>65 string PROJ (Think C project)
#>65 string QPRJ (Think Pascal project)
#>65 string SCFL (Defender scores)
#>65 string SCRN (startup screen)
#>65 string SITD (StuffIt Deluxe)
#>65 string SPn3 (SuperPaint)
#>65 string STAK (HyperCard stack)
#>65 string Seg\ (StuffIt segment)
#>65 string TARF (Unix tar archive)
#>65 string TEXT (ASCII)
#>65 string TIFF (TIFF image)
#>65 string TOVF (Eudora table of contents)
#>65 string WDBN (Microsoft Word word processor)
#>65 string WORD (MacWrite word processor)
#>65 string XLS\ (Microsoft Excel)
#>65 string ZIVM (compress (.Z))
#>65 string ZSYS (Pre-System 7 system file)
#>65 string acf3 (Aldus FreeHand)
#>65 string cdev (control panel)
#>65 string dfil (Desk Acessory suitcase)
#>65 string libr (library)
#>65 string nX^d (WriteNow word processor)
#>65 string nX^w (WriteNow dictionary)
#>65 string rsrc (resource)
#>65 string scbk (Scrapbook)
#>65 string shlb (shared library)
#>65 string ttro (SimpleText read-only)
#>65 string zsys (system file)
>69 string x \b, creator "%4.4s"
#>69 string x \b, creator "%4.4s"
# Somewhere, Apple has a repository of registered Creator IDs. These are
# just the ones that I happened to have files from and was able to identify.
>69 string 8BIM (Adobe Photoshop)
>69 string ALD3 (PageMaker 3)
>69 string ALD4 (PageMaker 4)
>69 string ALFA (Alpha editor)
>69 string APLS (Apple Scanner)
>69 string APSC (Apple Scanner)
>69 string BRKL (Brickles)
>69 string BTFT (BitFont)
>69 string CCL2 (Common Lisp 2)
>69 string CCL\ (Common Lisp)
>69 string CDmo (The Talking Moose)
>69 string CPCT (Compact Pro)
>69 string CSOm (Eudora)
>69 string DMOV (Font/DA Mover)
>69 string DSIM (DigSim)
>69 string EDIT (Macintosh Edit)
>69 string ERIK (Macintosh Finder)
>69 string EXTR (self-extracting archive)
>69 string Gzip (GNU gzip)
>69 string KAHL (Think C)
>69 string LWFU (LaserWriter Utility)
>69 string LZIV (compress)
>69 string MACA (MacWrite)
>69 string MACS (Macintosh operating system)
>69 string MAcK (MacKnowledge terminal emulator)
>69 string MLND (Defender)
>69 string MPNT (MacPaint)
>69 string MSBB (Microsoft BASIC (binary))
>69 string MSWD (Microsoft Word)
>69 string NCSA (NCSA Telnet)
>69 string PJMM (Think Pascal)
>69 string PSAL (Hunt the Wumpus)
>69 string PSI2 (Apple File Exchange)
>69 string R*ch (BBEdit)
>69 string RMKR (Resource Maker)
>69 string RSED (Resource Editor)
>69 string Rich (BBEdit)
>69 string SIT! (StuffIt)
>69 string SPNT (SuperPaint)
>69 string Unix (NeXT Mac filesystem)
>69 string VIM! (Vim editor)
>69 string WILD (HyperCard)
>69 string XCEL (Microsoft Excel)
>69 string aCa2 (Fontographer)
>69 string aca3 (Aldus FreeHand)
>69 string dosa (Macintosh MS-DOS file system)
>69 string movr (Font/DA Mover)
>69 string nX^n (WriteNow)
>69 string pdos (Apple ProDOS file system)
>69 string scbk (Scrapbook)
>69 string ttxt (SimpleText)
>69 string ufox (Foreign File Access)
#>69 string 8BIM (Adobe Photoshop)
#>69 string ALD3 (PageMaker 3)
#>69 string ALD4 (PageMaker 4)
#>69 string ALFA (Alpha editor)
#>69 string APLS (Apple Scanner)
#>69 string APSC (Apple Scanner)
#>69 string BRKL (Brickles)
#>69 string BTFT (BitFont)
#>69 string CCL2 (Common Lisp 2)
#>69 string CCL\ (Common Lisp)
#>69 string CDmo (The Talking Moose)
#>69 string CPCT (Compact Pro)
#>69 string CSOm (Eudora)
#>69 string DMOV (Font/DA Mover)
#>69 string DSIM (DigSim)
#>69 string EDIT (Macintosh Edit)
#>69 string ERIK (Macintosh Finder)
#>69 string EXTR (self-extracting archive)
#>69 string Gzip (GNU gzip)
#>69 string KAHL (Think C)
#>69 string LWFU (LaserWriter Utility)
#>69 string LZIV (compress)
#>69 string MACA (MacWrite)
#>69 string MACS (Macintosh operating system)
#>69 string MAcK (MacKnowledge terminal emulator)
#>69 string MLND (Defender)
#>69 string MPNT (MacPaint)
#>69 string MSBB (Microsoft BASIC (binary))
#>69 string MSWD (Microsoft Word)
#>69 string NCSA (NCSA Telnet)
#>69 string PJMM (Think Pascal)
#>69 string PSAL (Hunt the Wumpus)
#>69 string PSI2 (Apple File Exchange)
#>69 string R*ch (BBEdit)
#>69 string RMKR (Resource Maker)
#>69 string RSED (Resource Editor)
#>69 string Rich (BBEdit)
#>69 string SIT! (StuffIt)
#>69 string SPNT (SuperPaint)
#>69 string Unix (NeXT Mac filesystem)
#>69 string VIM! (Vim editor)
#>69 string WILD (HyperCard)
#>69 string XCEL (Microsoft Excel)
#>69 string aCa2 (Fontographer)
#>69 string aca3 (Aldus FreeHand)
#>69 string dosa (Macintosh MS-DOS file system)
#>69 string movr (Font/DA Mover)
#>69 string nX^n (WriteNow)
#>69 string pdos (Apple ProDOS file system)
#>69 string scbk (Scrapbook)
#>69 string ttxt (SimpleText)
#>69 string ufox (Foreign File Access)
# Just in case...
@ -236,6 +237,14 @@
>24 string CATALOG catalog
>24 string INDEX data file index
>24 string VIEW data view
# sas 7+ magic from Reinhold Koch (reinhold.koch@roche.com)
#
0x54 string SAS SAS 7+
>0x9C string DATA data file
>0x9C string CATALOG catalog
>0x9C string INDEX data file index
>0x9C string VIEW data view
# spss magic for SPSS system and portable files,
# from Bruce Foster (bef@nwu.edu).
@ -247,6 +256,7 @@
# Macintosh filesystem data
# From "Tom N Harris" <telliamed@mac.com>
# Fixed HFS+ and Partition map magic: Ethan Benson <erbenson@alaska.net>
# The MacOS epoch begins on 1 Jan 1904 instead of 1 Jan 1970, so these
# entries depend on the data arithmetic added after v.35
# There's also some Pascal strings in here, ditto...
@ -266,39 +276,39 @@
>0x412 beshort x number of blocks: %d,
>0x424 pstring x volume name: %s
0x400 beshort 0x4244 Macintosh HFS data
>0 beshort 0x4C4B (bootable)
>0x40a beshort &0x8000 (locked)
>0x40a beshort ^0x0100 (mounted)
>0x40a beshort &0x0800 (unclean)
>0x402 beldate-0x7C25B080 x created: %s,
>0x406 beldate-0x7C25B080 x last modified: %s,
>0x440 beldate-0x7C25B080 >0 last backup: %s,
>0x414 belong x block size: %d,
>0x412 beshort x number of blocks: %d,
>0x424 pstring x volume name: %s
#>0x480 beshort =0x482B Embedded HFS+ Volume:
#>>((0x482*(0x414))+(0x41c*512)) x \b
# Well, this is (theoretically) how we could do this. But it occurs to
# me that we likely don't read in a large enough chunk. I don't have any
# HFS+ volumes to see what a typical offset would be.
# "BD" is has many false positives
#0x400 beshort 0x4244 Macintosh HFS data
#>0 beshort 0x4C4B (bootable)
#>0x40a beshort &0x8000 (locked)
#>0x40a beshort ^0x0100 (mounted)
#>0x40a beshort &0x0200 (spared blocks)
#>0x40a beshort &0x0800 (unclean)
#>0x47C beshort 0x482B (Embedded HFS+ Volume)
#>0x402 beldate-0x7C25B080 x created: %s,
#>0x406 beldate-0x7C25B080 x last modified: %s,
#>0x440 beldate-0x7C25B080 >0 last backup: %s,
#>0x414 belong x block size: %d,
#>0x412 beshort x number of blocks: %d,
#>0x424 pstring x volume name: %s
0x400 beshort 0x482B Macintosh HFS Extended
>&2 beshort x version %d data
>&0 beshort x version %d data
>0 beshort 0x4C4B (bootable)
>&4 belong ^0x00000100 (mounted)
>&4 belong &0x00000800 (unclean)
>&4 belong &0x00008000 (locked)
>&8 string x last mounted by: '%.4s',
>0x404 belong ^0x00000100 (mounted)
>&2 belong &0x00000200 (spared blocks)
>&2 belong &0x00000800 (unclean)
>&2 belong &0x00008000 (locked)
>&6 string x last mounted by: '%.4s',
# really, that should be treated as a belong and we print a string
# based on the value. TN1150 only mentions '8.10' for "MacOS 8.1"
>&16 beldate-0x7C25B080 x created: %s,
>&20 beldate-0x7C25B080 x last modified: %s,
>&24 beldate-0x7C25B080 >0 last backup: %s,
>&28 beldate-0x7C25B080 >0 last checked: %s,
>&40 belong x block size: %d,
>&44 belong x number of blocks: %d,
>&48 belong x free blocks: %d
>&14 beldate-0x7C25B080 x created: %s,
# only the creation date is local time, all other timestamps in HFS+ are UTC.
>&18 bedate-0x7C25B080 x last modified: %s,
>&22 bedate-0x7C25B080 >0 last backup: %s,
>&26 bedate-0x7C25B080 >0 last checked: %s,
>&38 belong x block size: %d,
>&42 belong x number of blocks: %d,
>&46 belong x free blocks: %d
# I don't think this is really necessary since it doesn't do much and
# anything with a valid driver descriptor will also have a valid
@ -311,29 +321,40 @@
# cstring. Of course, partitions can contain more than four entries, but
# what're you gonna do?
0x200 beshort 0x504D Apple Partition data
>&2 beshort x block size: %d
>&48 string x first type: %s,
>&12 belong x number of blocks: %d,
>(&0x2.S) beshort 0x504D
>>&48 string x second type: %s
>>&12 belong x number of blocks: %d,
>>(&0x2.S) beshort 0x504D
>>>&48 string x third type: %s
>>>&12 belong x number of blocks: %d,
>>>(&0x2.S) beshort 0x504D
>>>>&48 string x fourth type: %s
>>>>&12 belong x number of blocks: %d,
>0x2 beshort x block size: %d,
>0x230 string x first type: %s,
>0x210 string x name: %s,
>0x254 belong x number of blocks: %d,
>0x400 beshort 0x504D
>>0x430 string x second type: %s,
>>0x410 string x name: %s,
>>0x454 belong x number of blocks: %d,
>>0x800 beshort 0x504D
>>>0x830 string x third type: %s,
>>>0x810 string x name: %s,
>>>0x854 belong x number of blocks: %d,
>>>0xa00 beshort 0x504D
>>>>0xa30 string x fourth type: %s,
>>>>0xa10 string x name: %s,
>>>>0xa54 belong x number of blocks: %d
# AFAIK, only the signature is different
0x200 beshort 0x5453 Apple Old Partition data
>&2 beshort x block size: %d
>&48 string x first type: %s,
>&12 belong x number of blocks: %d,
>(&0x2.S) beshort 0x504D
>>&48 string x second type: %s
>>&12 belong x number of blocks: %d,
>>(&0x2.S) beshort 0x504D
>>>&48 string x third type: %s
>>>&12 belong x number of blocks: %d,
>>>(&0x2.S) beshort 0x504D
>>>>&48 string x fourth type: %s
>>>>&12 belong x number of blocks: %d,
>0x2 beshort x block size: %d,
>0x230 string x first type: %s,
>0x210 string x name: %s,
>0x254 belong x number of blocks: %d,
>0x400 beshort 0x504D
>>0x430 string x second type: %s,
>>0x410 string x name: %s,
>>0x454 belong x number of blocks: %d,
>>0x800 beshort 0x504D
>>>0x830 string x third type: %s,
>>>0x810 string x name: %s,
>>>0x854 belong x number of blocks: %d,
>>>0xa00 beshort 0x504D
>>>>0xa30 string x fourth type: %s,
>>>>0xa10 string x name: %s,
>>>>0xa54 belong x number of blocks: %d
# From: Remi Mommsen <mommsen@slac.stanford.edu>
0 string BOMStore Mac OS X bill of materials (BOM) fil

View File

@ -26,3 +26,15 @@
# From: Kevin Sullivan <ksulliva@psc.edu>
0 string *mbx* MBX mail folder
# From: Simon Matter <simon.matter@invoca.ch>
0 string \241\002\213\015skiplist\ file\0\0\0 Cyrus skiplist DB
# JAM(mbp) Fidonet message area databases
# JHR file
0 string JAM\0 JAM message area header file
>12 leshort >0 (%d messages)
# Squish Fidonet message area databases
# SQD file (requires at least one message in the area)
256 leshort 0xAFAE4453 Squish message area data file
>4 leshort >0 (%d messages)

View File

@ -20,9 +20,9 @@
0 string \<PACKAGE= Maple help file
0 string \<HELP\ NAME= Maple help file
0 string \n\<HELP\ NAME= Maple help file with extra carriage return at start (yuck)
0 string #\ Newton Maple help file, old style
#0 string #\ Newton Maple help file, old style
0 string #\ daub Maple help file, old style
0 string #=========== Maple help file, old style
#0 string #=========== Maple help file, old style
# .mws
0 string \000\000\001\044\000\221 Maple worksheet

View File

@ -56,4 +56,13 @@
0 string (*********************** Mathematica 3.0 notebook
# other (* matches it is a comment start in these langs
0 string (* Mathematica, or Pascal, Modula-2 or 3 code
0 string (* Mathematica, or Pascal, Modula-2 or 3 code text
#########################
# MatLab v5
0 string MATLAB Matlab v5 mat-file
>126 short 0x494d (big endian)
>>124 beshort x version 0x%04x
>126 short 0x4d49 (little endian)
>>124 leshort x version 0x%04x

View File

@ -0,0 +1,14 @@
#------------------------------------------------------------------------------
# matroska: file(1) magic for Matroska files
#
# See http://www.matroska.org/
#
# EBML id:
0 belong 0x1a45dfa3
# DocType id:
>5 beshort 0x4282
# DocType contents:
>>8 string matroska Matroska data

View File

@ -0,0 +1,5 @@
#-----------------------------------------------------------------------------
# misctools: file(1) magic for miscelanous UNIX tools.
#
0 string %%!! X-Post-It-Note text
0 string BEGIN:VCALENDAR vCalendar calendar file

View File

@ -48,3 +48,23 @@
>6 belong x dat=%ld,
>10 belong x bss=%ld,
>14 belong x sym=%ld)
# Atari ST/TT... program format (sent by Wolfram Kleff <kleff@cs.uni-bonn.de>)
0 beshort 0x601A Atari 68xxx executable,
>2 belong x text len %lu,
>6 belong x data len %lu,
>10 belong x BSS len %lu,
>14 belong x symboltab len %lu,
>18 belong 0
>22 belong &0x01 fastload flag,
>22 belong &0x02 may be loaded to alternate RAM,
>22 belong &0x04 malloc may be from alternate RAM,
>22 belong x flags: 0x%lX,
>26 beshort 0 no relocation tab
>26 beshort !0 + relocation tab
>30 string SFX [Self-Extracting LZH SFX archive]
>38 string SFX [Self-Extracting LZH SFX archive]
>44 string ZIP! [Self-Extracting ZIP SFX archive]
0 beshort 0x0064 Atari 68xxx CPX file
>8 beshort x (version %04lx)

View File

@ -4,7 +4,7 @@
#
# .BAT files (Daniel Quinlan, quinlan@yggdrasil.com)
0 string @echo\ off MS-DOS batch file text
0 string/c @echo\ off MS-DOS batch file text
# XXX - according to Microsoft's spec, at an offset of 0x3c in a
# PE-format executable is the offset in the file of the PE header;
@ -144,9 +144,10 @@
#
#
# Windows NT Registry files.
# Windows Registry files.
#
0 string regf Windows NT Registry file
0 string regf Windows NT registry file
0 string CREG Windows 95 registry file
# Popular applications
2080 string Microsoft\ Word\ 6.0\ Document %s
@ -159,13 +160,17 @@
0 string PO^Q` Microsoft Word 6.0 Document
#
0 string \376\067\0\043 Microsoft Office Document
0 string \320\317\021\340\241\261 Microsoft Office Document
0 string \320\317\021\340\241\261\032\341 Microsoft Office Document
0 string \333\245-\0\0\0 Microsoft Office Document
#
2080 string Microsoft\ Excel\ 5.0\ Worksheet %s
2080 string Foglio\ di\ lavoro\ Microsoft\ Exce %s
#
# Pawel Wiecek <coven@i17linuxb.ists.pwr.wroc.pl> (for polish Excel)
2114 string Biff5 Microsoft Excel 5.0 Worksheet
# Italian MS-Excel
2121 string Biff5 Microsoft Excel 5.0 Worksheet
0 string \x09\x04\x06\x00\x00\x00\x10\x00 Microsoft Excel Worksheet
#
0 belong 0x00001a00 Lotus 1-2-3
>4 belong 0x00100400 wk3 document data
@ -180,9 +185,6 @@
# Help files
0 string ?_\3\0 MS Windows Help Data
# Microsoft CAB distribution format Dale Worley <root@dworley.ny.mediaone.net>
0 string MSCF\000\000\000\000 Microsoft CAB file
# DeIsL1.isu what this is I don't know
0 string \161\250\000\000\001\002 DeIsL1.isu whatever that is
@ -238,11 +240,6 @@
>>8 byte >0 \b, %d-colors
# True Type fonts currently misidentified as raw G3 data
0 string \000\001\000\000\000 MS-Windows true type font .ttf
# .chr files
0 string PK\010\010BGI Borland font
>4 string >\0 %s
@ -263,9 +260,9 @@
# Acroread or something files wrongly identified as G3 .pfm
# these have the form \000 \001 any? \002 \000 \000
# or \000 \001 any? \022 \000 \000
0 string \000\001 pfm?
>3 string \022\000\000Copyright\ yes
>3 string \002\000\000Copyright\ yes
#0 string \000\001 pfm?
#>3 string \022\000\000Copyright\ yes
#>3 string \002\000\000Copyright\ yes
#>3 string >\0 oops, not a font file. Cancel that.
#it clashes with ttf files so put it lower down.
@ -278,7 +275,8 @@
0 string DCU1 Borland Delphi .DCU file
0 string !<spell> MKS Spell hash list (old format)
0 string !<spell2> MKS Spell hash list
0 string AH Halo(TM) bitmapped font file
# Too simple - MPi
#0 string AH Halo(TM) bitmapped font file
0 lelong 0x08086b70 TurboC BGI file
0 lelong 0x08084b50 TurboC Font file
@ -309,3 +307,70 @@
# TNEF magic From "Joomy" <joomy@se-ed.net>
0 leshort 0x223e9f78 TNEF
# HtmlHelp files (.chm)
0 string ITSF\003\000\000\000\x60\000\000\000\001\000\000\000 MS Windows HtmlHelp Data
# GFA-BASIC (Wolfram Kleff)
2 string GFA-BASIC3 GFA-BASIC 3 data
# DJGPP compiled files
# v >2, uses DPMI & small(2k) stub (Robert vd Boon, rjvdboon@europe.com)
0x200 string go32stub DOS-executable compiled w/DJGPP
>0x20c string >0 (stub v%.4s)
>>0x8b2 string djp [compressed w/%s
>>>&1 string >\0 %.4s]
>>0x8ad string UPX [compressed w/%s
>>>&1 string >\0 %.4s]
>>0x1c string pmodedj stubbed with %s
# QDOS
4 belong 0x4AFB QDOS executable
>9 pstring x '%s'
0 beshort 0xFB01 QDOS object
>2 pstring x '%s'
#------------------------------------------------------------------------------
# From Stuart Caie <kyzer@4u.net> (developer of cabextract)
# Microsoft Cabinet files
0 string MSCF\0\0\0\0 Microsoft Cabinet file
>8 lelong x \b, %u bytes
>28 leshort 1 \b, 1 file
>28 leshort >1 \b, %u files
# InstallShield Cabinet files
0 string ISc( InstallShield Cabinet file
>5 byte&0xf0 =0x60 version 6,
>5 byte&0xf0 !0x60 version 4/5,
>(12.l+40) lelong x %u files
# Windows CE package files
0 string MSCE\0\0\0\0 Microsoft WinCE install header
>20 lelong 0 \b, architecture-independent
>20 lelong 103 \b, Hitachi SH3
>20 lelong 104 \b, Hitachi SH4
>20 lelong 0xA11 \b, StrongARM
>20 lelong 4000 \b, MIPS R4000
>20 lelong 10003 \b, Hitachi SH3
>20 lelong 10004 \b, Hitachi SH3E
>20 lelong 10005 \b, Hitachi SH4
>20 lelong 70001 \b, ARM 7TDMI
>52 leshort 1 \b, 1 file
>52 leshort >1 \b, %u files
>56 leshort 1 \b, 1 registry entry
>56 leshort >1 \b, %u registry entries
# Outlook Personal Folders
0 lelong 0x4E444221 Microsoft Outlook binary email folder
# From: Dirk Jagdmann <doj@cubic.org>
0 lelong 0x00035f3f Windows 3.x help file
# Christophe Monniez
0 string Client\ UrlCache\ MMF Microsoft Internet Explorer Cache File
>20 string >\0 Version %s
0 string \xCF\xAD\x12\xFE Microsoft Outlook Express DBX File
>4 byte =0xC5 Message database
>4 byte =0xC6 Folder database
>4 byte =0xC7 Accounts informations
>4 byte =0x30 Offline database

View File

@ -5,187 +5,187 @@
# All new-style magic numbers are in network byte order.
#
0 lelong 000000407 NetBSD little-endian object file
0 lelong 000000407 a.out NetBSD little-endian object file
>16 lelong >0 not stripped
0 belong 000000407 NetBSD big-endian object file
0 belong 000000407 a.out NetBSD big-endian object file
>16 belong >0 not stripped
0 belong&0377777777 041400413 NetBSD/i386 demand paged
0 belong&0377777777 041400413 a.out NetBSD/i386 demand paged
>0 byte &0x80
>>20 lelong <4096 shared library
>>20 lelong =4096 dynamically linked executable
>>20 lelong >4096 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 041400410 NetBSD/i386 pure
0 belong&0377777777 041400410 a.out NetBSD/i386 pure
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 041400407 NetBSD/i386
0 belong&0377777777 041400407 a.out NetBSD/i386
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80
>>0 byte &0x40 position independent
>>20 lelong !0 executable
>>20 lelong =0 object file
>16 lelong >0 not stripped
0 belong&0377777777 041400507 NetBSD/i386 core
0 belong&0377777777 041400507 a.out NetBSD/i386 core
>12 string >\0 from '%s'
>32 lelong !0 (signal %d)
0 belong&0377777777 041600413 NetBSD/m68k demand paged
0 belong&0377777777 041600413 a.out NetBSD/m68k demand paged
>0 byte &0x80
>>20 belong <8192 shared library
>>20 belong =8192 dynamically linked executable
>>20 belong >8192 dynamically linked executable
>0 byte ^0x80 executable
>16 belong >0 not stripped
0 belong&0377777777 041600410 NetBSD/m68k pure
0 belong&0377777777 041600410 a.out NetBSD/m68k pure
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80 executable
>16 belong >0 not stripped
0 belong&0377777777 041600407 NetBSD/m68k
0 belong&0377777777 041600407 a.out NetBSD/m68k
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80
>>0 byte &0x40 position independent
>>20 belong !0 executable
>>20 belong =0 object file
>16 belong >0 not stripped
0 belong&0377777777 041600507 NetBSD/m68k core
0 belong&0377777777 041600507 a.out NetBSD/m68k core
>12 string >\0 from '%s'
>32 belong !0 (signal %d)
0 belong&0377777777 042000413 NetBSD/m68k4k demand paged
0 belong&0377777777 042000413 a.out NetBSD/m68k4k demand paged
>0 byte &0x80
>>20 belong <4096 shared library
>>20 belong =4096 dynamically linked executable
>>20 belong >4096 dynamically linked executable
>0 byte ^0x80 executable
>16 belong >0 not stripped
0 belong&0377777777 042000410 NetBSD/m68k4k pure
0 belong&0377777777 042000410 a.out NetBSD/m68k4k pure
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80 executable
>16 belong >0 not stripped
0 belong&0377777777 042000407 NetBSD/m68k4k
0 belong&0377777777 042000407 a.out NetBSD/m68k4k
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80
>>0 byte &0x40 position independent
>>20 belong !0 executable
>>20 belong =0 object file
>16 belong >0 not stripped
0 belong&0377777777 042000507 NetBSD/m68k4k core
0 belong&0377777777 042000507 a.out NetBSD/m68k4k core
>12 string >\0 from '%s'
>32 belong !0 (signal %d)
0 belong&0377777777 042200413 NetBSD/ns32532 demand paged
0 belong&0377777777 042200413 a.out NetBSD/ns32532 demand paged
>0 byte &0x80
>>20 lelong <4096 shared library
>>20 lelong =4096 dynamically linked executable
>>20 lelong >4096 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 042200410 NetBSD/ns32532 pure
0 belong&0377777777 042200410 a.out NetBSD/ns32532 pure
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 042200407 NetBSD/ns32532
0 belong&0377777777 042200407 a.out NetBSD/ns32532
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80
>>0 byte &0x40 position independent
>>20 lelong !0 executable
>>20 lelong =0 object file
>16 lelong >0 not stripped
0 belong&0377777777 042200507 NetBSD/ns32532 core
0 belong&0377777777 042200507 a.out NetBSD/ns32532 core
>12 string >\0 from '%s'
>32 lelong !0 (signal %d)
0 belong&0377777777 045200507 NetBSD/powerpc core
0 belong&0377777777 045200507 a.out NetBSD/powerpc core
>12 string >\0 from '%s'
0 belong&0377777777 042400413 NetBSD/sparc demand paged
0 belong&0377777777 042400413 a.out NetBSD/sparc demand paged
>0 byte &0x80
>>20 belong <8192 shared library
>>20 belong =8192 dynamically linked executable
>>20 belong >8192 dynamically linked executable
>0 byte ^0x80 executable
>16 belong >0 not stripped
0 belong&0377777777 042400410 NetBSD/sparc pure
0 belong&0377777777 042400410 a.out NetBSD/sparc pure
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80 executable
>16 belong >0 not stripped
0 belong&0377777777 042400407 NetBSD/sparc
0 belong&0377777777 042400407 a.out NetBSD/sparc
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80
>>0 byte &0x40 position independent
>>20 belong !0 executable
>>20 belong =0 object file
>16 belong >0 not stripped
0 belong&0377777777 042400507 NetBSD/sparc core
0 belong&0377777777 042400507 a.out NetBSD/sparc core
>12 string >\0 from '%s'
>32 belong !0 (signal %d)
0 belong&0377777777 042600413 NetBSD/pmax demand paged
0 belong&0377777777 042600413 a.out NetBSD/pmax demand paged
>0 byte &0x80
>>20 lelong <4096 shared library
>>20 lelong =4096 dynamically linked executable
>>20 lelong >4096 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 042600410 NetBSD/pmax pure
0 belong&0377777777 042600410 a.out NetBSD/pmax pure
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 042600407 NetBSD/pmax
0 belong&0377777777 042600407 a.out NetBSD/pmax
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80
>>0 byte &0x40 position independent
>>20 lelong !0 executable
>>20 lelong =0 object file
>16 lelong >0 not stripped
0 belong&0377777777 042600507 NetBSD/pmax core
0 belong&0377777777 042600507 a.out NetBSD/pmax core
>12 string >\0 from '%s'
>32 lelong !0 (signal %d)
0 belong&0377777777 043000413 NetBSD/vax 1k demand paged
0 belong&0377777777 043000413 a.out NetBSD/vax 1k demand paged
>0 byte &0x80
>>20 lelong <4096 shared library
>>20 lelong =4096 dynamically linked executable
>>20 lelong >4096 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 043000410 NetBSD/vax 1k pure
0 belong&0377777777 043000410 a.out NetBSD/vax 1k pure
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 043000407 NetBSD/vax 1k
0 belong&0377777777 043000407 a.out NetBSD/vax 1k
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80
>>0 byte &0x40 position independent
>>20 lelong !0 executable
>>20 lelong =0 object file
>16 lelong >0 not stripped
0 belong&0377777777 043000507 NetBSD/vax 1k core
0 belong&0377777777 043000507 a.out NetBSD/vax 1k core
>12 string >\0 from '%s'
>32 lelong !0 (signal %d)
0 belong&0377777777 045400413 NetBSD/vax 4k demand paged
0 belong&0377777777 045400413 a.out NetBSD/vax 4k demand paged
>0 byte &0x80
>>20 lelong <4096 shared library
>>20 lelong =4096 dynamically linked executable
>>20 lelong >4096 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 045400410 NetBSD/vax 4k pure
0 belong&0377777777 045400410 a.out NetBSD/vax 4k pure
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 045400407 NetBSD/vax 4k
0 belong&0377777777 045400407 a.out NetBSD/vax 4k
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80
>>0 byte &0x40 position independent
>>20 lelong !0 executable
>>20 lelong =0 object file
>16 lelong >0 not stripped
0 belong&0377777777 045400507 NetBSD/vax 4k core
0 belong&0377777777 045400507 a.out NetBSD/vax 4k core
>12 string >\0 from '%s'
>32 lelong !0 (signal %d)
@ -195,44 +195,44 @@
0 lelong 0x00070185 ECOFF NetBSD/alpha binary
>10 leshort 0x0001 not stripped
>10 leshort 0x0000 stripped
0 belong&0377777777 043200507 NetBSD/alpha core
0 belong&0377777777 043200507 a.out NetBSD/alpha core
>12 string >\0 from '%s'
>32 lelong !0 (signal %d)
0 belong&0377777777 043400413 NetBSD/mips demand paged
0 belong&0377777777 043400413 a.out NetBSD/mips demand paged
>0 byte &0x80
>>20 belong <8192 shared library
>>20 belong =8192 dynamically linked executable
>>20 belong >8192 dynamically linked executable
>0 byte ^0x80 executable
>16 belong >0 not stripped
0 belong&0377777777 043400410 NetBSD/mips pure
0 belong&0377777777 043400410 a.out NetBSD/mips pure
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80 executable
>16 belong >0 not stripped
0 belong&0377777777 043400407 NetBSD/mips
0 belong&0377777777 043400407 a.out NetBSD/mips
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80
>>0 byte &0x40 position independent
>>20 belong !0 executable
>>20 belong =0 object file
>16 belong >0 not stripped
0 belong&0377777777 043400507 NetBSD/mips core
0 belong&0377777777 043400507 a.out NetBSD/mips core
>12 string >\0 from '%s'
>32 belong !0 (signal %d)
0 belong&0377777777 043600413 NetBSD/arm32 demand paged
0 belong&0377777777 043600413 a.out NetBSD/arm32 demand paged
>0 byte &0x80
>>20 lelong <4096 shared library
>>20 lelong =4096 dynamically linked executable
>>20 lelong >4096 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 043600410 NetBSD/arm32 pure
0 belong&0377777777 043600410 a.out NetBSD/arm32 pure
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80 executable
>16 lelong >0 not stripped
0 belong&0377777777 043600407 NetBSD/arm32
0 belong&0377777777 043600407 a.out NetBSD/arm32
>0 byte &0x80 dynamically linked executable
>0 byte ^0x80
>>0 byte &0x40 position independent
@ -241,6 +241,6 @@
>16 lelong >0 not stripped
# NetBSD/arm26 has always used ELF objects, but it shares a core file
# format with NetBSD/arm32.
0 belong&0377777777 043600507 NetBSD/arm core
0 belong&0377777777 043600507 a.out NetBSD/arm core
>12 string >\0 from '%s'
>32 lelong !0 (signal %d)

View File

@ -8,6 +8,9 @@
# Netscape Address book .nab
0 string \000\017\102\104\000\000\000\000\000\000\001\000\000\000\000\002\000\000\000\002\000\000\004\000 Netscape Address book
# Netscape Communicator address book
0 string \000\017\102\111 Netscape Communicator address book
# .snm Caches
0 string #\ Netscape\ folder\ cache Netscape folder cache
0 string \000\036\204\220\000 Netscape folder cache

13
contrib/file/Magdir/ocaml Normal file
View File

@ -0,0 +1,13 @@
#------------------------------------------------------------------------------
# ocaml: file(1) magic for Objective Caml files.
0 string Caml1999 Objective caml
>8 string X exec file
>8 string I interface file (.cmi)
>8 string O object file (.cmo)
>8 string A library file (.cma)
>8 string Y native object file (.cmx)
>8 string Z native library file (.cmxa)
>8 string M abstract syntax tree implementation file
>8 string N abstract syntax tree interface file
>9 string >\0 (Version %3.3s).

View File

@ -11,16 +11,16 @@
# OS/2 URL objects
# Provided 1998/08/22 by
# David Mediavilla <davidme.news@REMOVEIFNOTSPAMusa.net>
0 string http: OS/2 URL object text
>5 string >\ (WWW) <http:%s>
0 string mailto: OS/2 URL object text
>7 string >\ (email) <%s>
0 string news: OS/2 URL object text
>5 string >\ (Usenet) <%s>
0 string ftp: OS/2 URL object text
>4 string >\ (FTP) <ftp:%s>
0 string file: OS/2 URL object text
>5 string >\ (Local file) <%s>
#0 string http: OS/2 URL object text
#>5 string >\ (WWW) <http:%s>
#0 string mailto: OS/2 URL object text
#>7 string >\ (email) <%s>
#0 string news: OS/2 URL object text
#>5 string >\ (Usenet) <%s>
#0 string ftp: OS/2 URL object text
#>4 string >\ (FTP) <ftp:%s>
#0 string file: OS/2 URL object text
#>5 string >\ (Local file) <%s>
# >>>>> OS/2 INF/HLP <<<<< (source: Daniel Dissett ddissett@netcom.com)
# Carl Hauser (chauser.parc@xerox.com) and

View File

@ -13,3 +13,79 @@
# HACK
60 belong 0x4841434b HackMaster hack
>0 string >\0 "%s"
# Variety of PalmOS document types
# Michael-John Turner <mj@debian.org>
# Thanks to Hasan Umit Ezerce <humit@tr-net.net.tr> for his DocType
60 string BVokBDIC BDicty PalmOS document
>0 string >\0 "%s"
60 string DB99DBOS DB PalmOS document
>0 string >\0 "%s"
60 string vIMGView FireViewer/ImageViewer PalmOS document
>0 string >\0 "%s"
60 string PmDBPmDB HanDBase PalmOS document
>0 string >\0 "%s"
60 string InfoINDB InfoView PalmOS document
>0 string >\0 "%s"
60 string ToGoToGo iSilo PalmOS document
>0 string >\0 "%s"
60 string JfDbJBas JFile PalmOS document
>0 string >\0 "%s"
60 string JfDbJFil JFile Pro PalmOS document
>0 string >\0 "%s"
60 string DATALSdb List PalmOS document
>0 string >\0 "%s"
60 string Mdb1Mdb1 MobileDB PalmOS document
>0 string >\0 "%s"
60 string PNRdPPrs PeanutPress PalmOS document
>0 string >\0 "%s"
60 string DataPlkr Plucker PalmOS document
>0 string >\0 "%s"
60 string DataSprd QuickSheet PalmOS document
>0 string >\0 "%s"
60 string SM01SMem SuperMemo PalmOS document
>0 string >\0 "%s"
60 string DataTlPt TealDoc PalmOS document
>0 string >\0 "%s"
60 string InfoTlIf TealInfo PalmOS document
>0 string >\0 "%s"
60 string DataTlMl TealMeal PalmOS document
>0 string >\0 "%s"
60 string DataTlPt TealPaint PalmOS document
>0 string >\0 "%s"
60 string dataTDBP ThinkDB PalmOS document
>0 string >\0 "%s"
60 string TdatTide Tides PalmOS document
>0 string >\0 "%s"
60 string ToRaTRPW TomeRaider PalmOS document
>0 string >\0 "%s"
# A GutenPalm zTXT etext for use on Palm Pilots (http://gutenpalm.sf.net)
# For version 1.xx zTXTs, outputs version and numbers of bookmarks and
# annotations.
# For other versions, just outputs version.
#
60 string zTXT A GutenPalm zTXT e-book
>0 string >\0 "%s"
>(0x4E.L) byte 0
>>(0x4E.L+1) byte x (v0.%02d)
>(0x4E.L) byte 1
>>(0x4E.L+1) byte x (v1.%02d)
>>>(0x4E.L+10) beshort >0
>>>>(0x4E.L+10) beshort <2 - 1 bookmark
>>>>(0x4E.L+10) beshort >1 - %d bookmarks
>>>(0x4E.L+14) beshort >0
>>>>(0x4E.L+14) beshort <2 - 1 annotation
>>>>(0x4E.L+14) beshort >1 - %d annotations
>(0x4E.L) byte >1 (v%d.
>>(0x4E.L+1) byte x %02d)
# Palm OS .prc file types
60 string libr Palm OS dynamic library data
>0 string >\0 "%s"
60 string ptch Palm OS operating system patch data
>0 string >\0 "%s"
# Mobipocket (www.mobipocket.com), donated by Carl Witty
60 string BOOKMOBI Mobipocket E-book
>0 string >\0 "%s"

View File

@ -11,6 +11,7 @@
0 string eval\ "exec\ /usr/bin/perl perl script text
0 string/b #!\ /usr/local/bin/perl perl script text
0 string eval\ "exec\ /usr/local/bin/perl perl script text executable
0 string eval\ '(exit\ $?0)'\ &&\ eval\ 'exec perl script text
# a couple more, by me
# XXX: christos matches

View File

@ -0,0 +1,4 @@
#------------------------------------------------------------------------------
# plan9: file(1) magic for AT&T Bell Labs' Plan 9 executables
#
0 belong 0x000001EB Plan 9 executable

View File

@ -83,10 +83,34 @@
#
# Now magic for IMAGEN font files...
0 string Rast RST-format raster font data
>45 string >0 face %
>45 string >0 face %s
# From Jukka Ukkonen
0 string \033[K\002\0\0\017\033(a\001\0\001\033(g Canon Bubble Jet BJC formatted data
# From <mike@flyn.org>
# These are the /etc/magic entries to decode data sent to an Epson printer.
0 string \x1B\x40\x1B\x28\x52\x08\x00\x00REMOTE1P Epson Stylus Color 460 data
#------------------------------------------------------------------------------
# zenographics: file(1) magic for Zenographics ZjStream printer data
# Rick Richardson rickr@mn.rr.com
0 string JZJZ
>0x12 string ZZ Zenographics ZjStream printer data (big-endian)
0 string ZJZJ
>0x12 string ZZ Zenographics ZjStream printer data (little-endian)
#------------------------------------------------------------------------------
# Oak Technologies printer stream
# Rick Richardson <rickr@mn.rr.com>
0 string OAK
>0x07 byte 0
>0x0b byte 0 Oak Technologies printer stream
# This would otherwise be recognized as PostScript - nick@debian.org
0 string %!VMF SunClock's Vector Map Format data
#------------------------------------------------------------------------------
# HP LaserJet 1000 series downloadable firmware file
0 string \xbe\xefABCDEFGH HP LaserJet 1000 series downloadable firmware

43
contrib/file/Magdir/psion Normal file
View File

@ -0,0 +1,43 @@
#------------------------------------------------------------------------------
# psion: file(1) magic for Psion handhelds data
# from: Peter Breitenlohner <peb@mppmu.mpg.de>
#
0 lelong 0x10000037 Psion Series 5
>4 lelong 0x10000039 font file
>4 lelong 0x1000003A printer driver
>4 lelong 0x1000003B clipboard
>4 lelong 0x10000042 multi-bitmap image
>4 lelong 0x1000006A application infomation file
>4 lelong 0x1000006D
>>8 lelong 0x1000007D sketch image
>>8 lelong 0x1000007E voice note
>>8 lelong 0x1000007F word file
>>8 lelong 0x10000085 OPL program
>>8 lelong 0x10000088 sheet file
>>8 lelong 0x100001C4 EasyFax initialisation file
>4 lelong 0x10000073 OPO module
>4 lelong 0x10000074 OPL application
>4 lelong 0x1000008A exported multi-bitmap image
0 lelong 0x10000041 Psion Series 5 ROM multi-bitmap image
0 lelong 0x10000050 Psion Series 5
>4 lelong 0x1000006D database
>4 lelong 0x100000E4 ini file
0 lelong 0x10000079 Psion Series 5 binary:
>4 lelong 0x00000000 DLL
>4 lelong 0x10000049 comms hardware library
>4 lelong 0x1000004A comms protocol library
>4 lelong 0x1000005D OPX
>4 lelong 0x1000006C application
>4 lelong 0x1000008D DLL
>4 lelong 0x100000AC logical device driver
>4 lelong 0x100000AD physical device driver
>4 lelong 0x100000E5 file transfer protocol
>4 lelong 0x100000E5 file transfer protocol
>4 lelong 0x10000140 printer defintion
>4 lelong 0x10000141 printer defintion
0 lelong 0x1000007A Psion Series 5 executable

View File

@ -11,4 +11,4 @@
0 belong 0x87c60d0a python 2.0 byte-compiled
0 belong 0x2aeb0d0a python 2.1 byte-compiled
0 belong 0x2ded0d0a python 2.2 byte-compiled
#0 belong 0x31f20d0a python 2.3 byte-compiled
0 belong 0x3bf20d0a python 2.3 byte-compiled

View File

@ -0,0 +1,5 @@
#------------------------------------------------------------------------------
# file(1) magic for revision control files
# From Hendrik Scholz <hendrik@scholz.net>
0 string /1\ :pserver: cvs password text file

View File

@ -5,13 +5,7 @@
#
# http://www.seanet.com/users/matts/riffmci/riffmci.htm
#
# and
#
# http://www.ora.com/centers/gff/formats/micriff/index.htm
#
# and
#
# http://www.jtauber.com/music/encoding/niff/spec/
# AVI section extended by Patrik Rådman <patrik+file-magic@iki.fi>
#
0 string RIFF RIFF (little-endian) data
# RIFF Palette format
@ -40,8 +34,8 @@
>>20 leshort 1 \b, Microsoft PCM
>>>34 leshort >0 \b, %d bit
>>20 leshort 2 \b, Microsoft ADPCM
>>20 leshort 6 \b, ITU G.711 a-law
>>20 leshort 7 \b, ITU G.711 u-law
>>20 leshort 6 \b, ITU G.711 A-law
>>20 leshort 7 \b, ITU G.711 mu-law
>>20 leshort 17 \b, IMA ADPCM
>>20 leshort 20 \b, ITU G.723 ADPCM (Yamaha)
>>20 leshort 49 \b, GSM 6.10
@ -52,10 +46,124 @@
>>22 leshort =2 \b, stereo
>>22 leshort >2 \b, %d channels
>>24 lelong >0 %d Hz
# Corel Draw Picture
>8 string CDRA \b, Corel Draw Picture
# AVI == Audio Video Interleave
>8 string AVI\ \b, AVI
>8 string AVI\040 \b, AVI
>>12 string LIST
>>>20 string hdrlavih
>>>>&36 lelong x \b, %lu x
>>>>&40 lelong x %lu,
>>>>&4 lelong >1000000 <1 fps,
>>>>&4 lelong 1000000 1.00 fps,
>>>>&4 lelong 500000 2.00 fps,
>>>>&4 lelong 333333 3.00 fps,
>>>>&4 lelong 250000 4.00 fps,
>>>>&4 lelong 200000 5.00 fps,
>>>>&4 lelong 166667 6.00 fps,
>>>>&4 lelong 142857 7.00 fps,
>>>>&4 lelong 125000 8.00 fps,
>>>>&4 lelong 111111 9.00 fps,
>>>>&4 lelong 100000 10.00 fps,
# ]9.9,10.1[
>>>>&4 lelong <101010
>>>>>&-4 lelong >99010
>>>>>>&-4 lelong !100000 ~10 fps,
>>>>&4 lelong 83333 12.00 fps,
# ]11.9,12.1[
>>>>&4 lelong <84034
>>>>>&-4 lelong >82645
>>>>>>&-4 lelong !83333 ~12 fps,
>>>>&4 lelong 66667 15.00 fps,
# ]14.9,15.1[
>>>>&4 lelong <67114
>>>>>&-4 lelong >66225
>>>>>>&-4 lelong !66667 ~15 fps,
>>>>&4 lelong 50000 20.00 fps,
>>>>&4 lelong 41708 23.98 fps,
>>>>&4 lelong 41667 24.00 fps,
# ]23.9,24.1[
>>>>&4 lelong <41841
>>>>>&-4 lelong >41494
>>>>>>&-4 lelong !41708
>>>>>>>&-4 lelong !41667 ~24 fps,
>>>>&4 lelong 40000 25.00 fps,
# ]24.9,25.1[
>>>>&4 lelong <40161
>>>>>&-4 lelong >39841
>>>>>>&-4 lelong !40000 ~25 fps,
>>>>&4 lelong 33367 29.97 fps,
>>>>&4 lelong 33333 30.00 fps,
# ]29.9,30.1[
>>>>&4 lelong <33445
>>>>>&-4 lelong >33223
>>>>>>&-4 lelong !33367
>>>>>>>&-4 lelong !33333 ~30 fps,
>>>>&4 lelong <32224 >30 fps,
##>>>>&4 lelong x (%lu)
##>>>>&20 lelong x %lu frames,
# Note: The tests below assume that the AVI has 1 or 2 streams,
# "vids" optionally followed by "auds".
# (Should cover 99.9% of all AVIs.)
# assuming avih length = 56
>>>88 string LIST
>>>>96 string strlstrh
>>>>>108 string vids video:
>>>>>>&0 lelong 0 uncompressed
# skip past vids strh
>>>>>>(104.l+108) string strf
>>>>>>>(104.l+132) lelong 1 RLE 8bpp
>>>>>>>(104.l+132) string/c cvid Cinepak
>>>>>>>(104.l+132) string/c i263 Intel I.263
>>>>>>>(104.l+132) string/c iv32 Indeo 3.2
>>>>>>>(104.l+132) string/c iv41 Indeo 4.1
>>>>>>>(104.l+132) string/c iv50 Indeo 5.0
>>>>>>>(104.l+132) string/c mp42 Microsoft MPEG-4 v2
>>>>>>>(104.l+132) string/c mp43 Microsoft MPEG-4 v3
>>>>>>>(104.l+132) string/c mjpg Motion JPEG
>>>>>>>(104.l+132) string/c div3 DivX 3
>>>>>>>>112 string/c div3 Low-Motion
>>>>>>>>112 string/c div4 Fast-Motion
>>>>>>>(104.l+132) string/c divx DivX 4
>>>>>>>(104.l+132) string/c dx50 DivX 5
>>>>>>>(104.l+132) string/c xvid XviD
>>>>>>>(104.l+132) lelong 0
##>>>>>>>(104.l+132) string x (%.4s)
# skip past first (video) LIST
>>>>(92.l+96) string LIST
>>>>>(92.l+104) string strlstrh
>>>>>>(92.l+116) string auds \b, audio:
# auds strh length = 56:
>>>>>>>(92.l+172) string strf
>>>>>>>>(92.l+180) leshort 0x0001 uncompressed PCM
>>>>>>>>(92.l+180) leshort 0x0002 ADPCM
>>>>>>>>(92.l+180) leshort 0x0055 MPEG-1 Layer 3
>>>>>>>>(92.l+180) leshort 0x2000 Dolby AC3
>>>>>>>>(92.l+180) leshort 0x0161 DivX
##>>>>>>>>(92.l+180) leshort x (0x%.4x)
>>>>>>>>(92.l+182) leshort 1 (mono,
>>>>>>>>(92.l+182) leshort 2 (stereo,
>>>>>>>>(92.l+182) leshort >2 (%d channels,
>>>>>>>>(92.l+184) lelong x %d Hz)
# auds strh length = 64:
>>>>>>>(92.l+180) string strf
>>>>>>>>(92.l+188) leshort 0x0001 uncompressed PCM
>>>>>>>>(92.l+188) leshort 0x0002 ADPCM
>>>>>>>>(92.l+188) leshort 0x0055 MPEG-1 Layer 3
>>>>>>>>(92.l+188) leshort 0x2000 Dolby AC3
>>>>>>>>(92.l+188) leshort 0x0161 DivX
##>>>>>>>>(92.l+188) leshort x (0x%.4x)
>>>>>>>>(92.l+190) leshort 1 (mono,
>>>>>>>>(92.l+190) leshort 2 (stereo,
>>>>>>>>(92.l+190) leshort >2 (%d channels,
>>>>>>>>(92.l+192) lelong x %d Hz)
# Animated Cursor format
>8 string ACON \b, animated cursor
# SoundFont 2 <mpruett@sgi.com>
>8 string sfbk SoundFont/Bank
# MPEG-1 wrapped in a RIFF, apparently
>8 string CDXA \b, wrapped MPEG-1 (CDXA)
>8 string 4XMV \b, 4X Movie file
#
# XXX - some of the below may only appear in little-endian form.
@ -93,12 +201,13 @@
>>22 beshort =2 \b, stereo
>>22 beshort >2 \b, %d channels
>>24 belong >0 %d Hz
# Corel Draw Picture
>8 string CDRA \b, Corel Draw Picture
# AVI == Audio Video Interleave
>8 string AVI\ \b, AVI
>8 string AVI\040 \b, AVI
# Animated Cursor format
>8 string ACON \b, animated cursor
# Notation Interchange File Format (big-endian only)
>8 string NIFF \b, Notation Interchange File Format
# SoundFont 2 <mpruett@sgi.com>
>8 string sfbk SoundFont 2
>8 string sfbk SoundFont/Bank

View File

@ -2,7 +2,7 @@
#
# RPM: file(1) magic for Red Hat Packages Erik Troan (ewt@redhat.com)
#
0 beshort 0xedab
0 beshort 0xedab
>2 beshort 0xeedb RPM
>>4 byte x v%d
>>6 beshort 0 bin
@ -13,5 +13,10 @@
>>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
>>8 beshort 11 MIPSel
>>8 beshort 12 ARM
>>10 string x %s

View File

@ -1,177 +1,59 @@
#------------------------------------------------------------------------------
# sgi: file(1) magic for Silicon Graphics (MIPS, IRIS, IRIX, etc.)
# Dec Ultrix (MIPS)
# all of SGI's *current* machines and OSes run in big-endian mode on the
# MIPS machines, as far as I know.
# sgi: file(1) magic for Silicon Graphics applications
#
# XXX - what is the blank "-" line?
#
# kbd file definitions
0 string kbd!map kbd map file
>8 byte >0 Ver %d:
>10 short >0 with %d table(s)
0 belong 0407 old SGI 68020 executable
0 belong 0410 old SGI 68020 pure executable
0 beshort 0x8765 disk quotas file
0 beshort 0x0506 IRIS Showcase file
>2 byte 0x49 -
>3 byte x - version %ld
0 beshort 0x0226 IRIS Showcase template
>2 byte 0x63 -
>3 byte x - version %ld
0 belong 0x5343464d IRIS Showcase file
>4 byte x - version %ld
0 belong 0x5443464d IRIS Showcase template
>4 byte x - version %ld
0 belong 0xdeadbabe IRIX Parallel Arena
>8 belong >0 - version %ld
#
0 beshort 0x0160 MIPSEB COFF executable
>20 beshort 0407 (impure)
>20 beshort 0410 (swapped)
>20 beshort 0413 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>22 byte x - version %ld
>23 byte x .%ld
#
0 beshort 0x0162 MIPSEL COFF executable
>20 beshort 0407 (impure)
>20 beshort 0410 (swapped)
>20 beshort 0413 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>23 byte x - version %d
>22 byte x .%ld
#
0 beshort 0x6001 MIPSEB-LE COFF executable
>20 beshort 03401 (impure)
>20 beshort 04001 (swapped)
>20 beshort 05401 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>23 byte x - version %d
>22 byte x .%ld
#
0 beshort 0x6201 MIPSEL-LE COFF executable
>20 beshort 03401 (impure)
>20 beshort 04001 (swapped)
>20 beshort 05401 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>23 byte x - version %ld
>22 byte x .%ld
#
# MIPS 2 additions
#
0 beshort 0x0163 MIPSEB MIPS-II COFF executable
>20 beshort 0407 (impure)
>20 beshort 0410 (swapped)
>20 beshort 0413 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>22 byte x - version %ld
>23 byte x .%ld
#
0 beshort 0x0166 MIPSEL MIPS-II COFF executable
>20 beshort 0407 (impure)
>20 beshort 0410 (swapped)
>20 beshort 0413 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>22 byte x - version %ld
>23 byte x .%ld
#
0 beshort 0x6301 MIPSEB-LE MIPS-II COFF executable
>20 beshort 03401 (impure)
>20 beshort 04001 (swapped)
>20 beshort 05401 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>23 byte x - version %ld
>22 byte x .%ld
#
0 beshort 0x6601 MIPSEL-LE MIPS-II COFF executable
>20 beshort 03401 (impure)
>20 beshort 04001 (swapped)
>20 beshort 05401 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>23 byte x - version %ld
>22 byte x .%ld
#
# MIPS 3 additions
#
0 beshort 0x0140 MIPSEB MIPS-III COFF executable
>20 beshort 0407 (impure)
>20 beshort 0410 (swapped)
>20 beshort 0413 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>22 byte x - version %ld
>23 byte x .%ld
#
0 beshort 0x0142 MIPSEL MIPS-III COFF executable
>20 beshort 0407 (impure)
>20 beshort 0410 (swapped)
>20 beshort 0413 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>22 byte x - version %ld
>23 byte x .%ld
#
0 beshort 0x4001 MIPSEB-LE MIPS-III COFF executable
>20 beshort 03401 (impure)
>20 beshort 04001 (swapped)
>20 beshort 05401 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>23 byte x - version %ld
>22 byte x .%ld
#
0 beshort 0x4201 MIPSEL-LE MIPS-III COFF executable
>20 beshort 03401 (impure)
>20 beshort 04001 (swapped)
>20 beshort 05401 (paged)
>8 belong >0 not stripped
>8 belong 0 stripped
>23 byte x - version %ld
>22 byte x .%ld
#
0 beshort 0x180 MIPSEB Ucode
0 beshort 0x182 MIPSEL Ucode
# 32bit core file
0 belong 0xdeadadb0 IRIX core dump
>4 belong 1 of
>16 string >\0 '%s'
# 64bit core file
0 belong 0xdeadad40 IRIX 64-bit core dump
>4 belong 1 of
>16 string >\0 '%s'
# N32bit core file
0 belong 0xbabec0bb IRIX N32 core dump
>4 belong 1 of
>16 string >\0 '%s'
# New style crash dump file
0 string \x43\x72\x73\x68\x44\x75\x6d\x70 IRIX vmcore dump of
>36 string >\0 '%s'
# Trusted IRIX info
0 string SGIAUDIT SGI Audit file
>8 byte x - version %d
>9 byte x .%ld
#
0 string WNGZWZSC Wingz compiled script
0 string WNGZWZSS Wingz spreadsheet
0 string WNGZWZHP Wingz help file
#
0 string \#Inventor V IRIS Inventor 1.0 file
0 string \#Inventor V2 Open Inventor 2.0 file
# GLF is OpenGL stream encoding
0 string glfHeadMagic(); GLF_TEXT
4 belong 0x7d000000 GLF_BINARY_LSB_FIRST
4 belong 0x0000007d GLF_BINARY_MSB_FIRST
# GLS is OpenGL stream encoding; GLS is the successor of GLF
0 string glsBeginGLS( GLS_TEXT
4 belong 0x10000000 GLS_BINARY_LSB_FIRST
4 belong 0x00000010 GLS_BINARY_MSB_FIRST
# Performance Co-Pilot file types
0 string PmNs PCP compiled namespace (V.0)
0 string PmN PCP compiled namespace
>3 string >\0 (V.%1.1s)
3 lelong 0x84500526 PCP archive
>7 byte x (V.%d)
>20 lelong -2 temporal index
>20 lelong -1 metadata
>20 lelong 0 log volume #0
>20 lelong >0 log volume #%ld
>24 string >\0 host: %s
0 string PCPFolio PCP
>9 string Version: Archive Folio
>18 string >\0 (V.%s)
0 string #pmchart PCP pmchart view
>9 string Version
>17 string >\0 (V%-3.3s)
0 string pmview PCP pmview config
>7 string Version
>15 string >\0 (V%-3.3s)
0 string #pmlogger PCP pmlogger config
>10 string Version
>18 string >\0 (V%1.1s)
0 string PcPh PCP Help
>4 string 1 Index
>4 string 2 Text
>5 string >\0 (V.%1.1s)
0 string #pmieconf-rules PCP pmieconf rules
>16 string >\0 (V.%1.1s)
3 string pmieconf-pmie PCP pmie config
>17 string >\0 (V.%1.1s)
# SpeedShop data files
0 lelong 0x13130303 SpeedShop data file
# mdbm files
0 lelong 0x01023962 mdbm file, version 0 (obsolete)
0 string mdbm mdbm file,
>5 byte x version %d,
>6 byte x 2^%d pages,
>7 byte x pagesize 2^%d,
>17 byte x hash %d,
>11 byte x dataformat %d
# Alias|Wavefront Maya files
0 string //Maya ASCII Alias|Wavefront Maya Ascii File,
>13 string >\0 version %s
8 string MAYAFOR4 Alias|Wavefront Maya Binary File,
>32 string >\0 version %s scene
8 string MayaFOR4 Alias|Wavefront Maya Binary File,
>32 string >\0 version %s scene
8 string CIMG Alias|Wavefront Maya Image File
8 string DEEP Alias|Wavefront Maya Image File

View File

@ -4,14 +4,21 @@
# 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 \<!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
# Extensible markup language (XML), a subset of SGML
# from Marc Prud'hommeaux (marc@apocalypse.org)
0 string/cb \<?xml XML document text
0 string/cb \<?xml XML document text
0 string \<?xml\ version " XML
0 string \<?xml\ version=" XML
>15 string >\0 %.3s document text
>>23 string \<xsl:stylesheet (XSL stylesheet)
>>24 string \<xsl:stylesheet (XSL stylesheet)
0 string/b \<?xml XML document text
0 string/cb \<?xml broken XML document text
# SGML, mostly from rph@sq

View File

@ -0,0 +1,126 @@
#------------------------------------------------------------------------------
# sinclair: file(1) sinclair QL
# additions to /etc/magic by Thomas M. Ott (ThMO)
# Sinclair QL floppy disk formats (ThMO)
0 string =QL5 QL disk dump data,
>3 string =A 720 KB,
>3 string =B 1.44 MB,
>3 string =C 3.2 MB,
>4 string >\0 label:%.10s
# Sinclair QL OS dump (ThMO)
# (NOTE: if `file' would be able to use indirect references in a endian format
# differing from the natural host format, this could be written more
# reliably and faster...)
#
# we *can't* lookup QL OS code dumps, because `file' is UNABLE to read more
# than the first 8K of a file... #-(
#
#0 belong =0x30000
#>49124 belong <47104
#>>49128 belong <47104
#>>>49132 belong <47104
#>>>>49136 belong <47104 QL OS dump data,
#>>>>>49148 string >\0 type %.3s,
#>>>>>49142 string >\0 version %.4s
# Sinclair QL firmware executables (ThMO)
0 string NqNqNq`\004 QL firmware executable (BCPL)
# Sinclair QL libraries (ThMO)
0 beshort =0xFB01 QL library archive data
# Sinclair QL executbables (ThMO)
6 beshort =0x4AFB QL executable,
>10 string =\0 un-named
>8 beshort =1
>>10 string >\0 named: %.1s
>8 beshort =2
>>10 string >\0 named: %.2s
>8 beshort =3
>>10 string >\0 named: %.3s
>8 beshort =4
>>10 string >\0 named: %.4s
>8 beshort =5
>>10 string >\0 named: %.5s
>8 beshort =6
>>10 string >\0 named: %.6s
>8 beshort =7
>>10 string >\0 named: %.7s
>8 beshort =8
>>10 string >\0 named: %.8s
>8 beshort =9
>>10 string >\0 named: %.9s
>8 beshort =10
>>10 string >\0 named: %.10s
>8 beshort =11
>>10 string >\0 named: %.11s
>8 beshort =12
>>10 string >\0 named: %.12s
>8 beshort =13
>>10 string >\0 named: %.13s
>8 beshort =14
>>10 string >\0 named: %.14s
>8 beshort =15
>>10 string >\0 named: %.15s
>8 beshort =16
>>10 string >\0 named: %.16s
>8 beshort =17
>>10 string >\0 named: %.17s
>8 beshort =18
>>10 string >\0 named: %.18s
>8 beshort =19
>>10 string >\0 named: %.19s
>8 beshort =20
>>10 string >\0 named: %.20s
>8 beshort >20
>>10 string >\0 (truncated) named: %.20s
# Sinclair QL rom (ThMO)
0 belong =0x4AFB0001 QL plugin-ROM data,
>10 string =\0 un-named
>8 beshort =1
>>10 string >\0 named: %.1s
>8 beshort =2
>>10 string >\0 named: %.2s
>8 beshort =3
>>10 string >\0 named: %.3s
>8 beshort =4
>>10 string >\0 named: %.4s
>8 beshort =5
>>10 string >\0 named: %.5s
>8 beshort =6
>>10 string >\0 named: %.6s
>8 beshort =7
>>10 string >\0 named: %.7s
>8 beshort =8
>>10 string >\0 named: %.8s
>8 beshort =9
>>10 string >\0 named: %.9s
>8 beshort =10
>>10 string >\0 named: %.10s
>8 beshort =11
>>10 string >\0 named: %.11s
>8 beshort =12
>>10 string >\0 named: %.12s
>8 beshort =13
>>10 string >\0 named: %.13s
>8 beshort =14
>>10 string >\0 named: %.14s
>8 beshort =15
>>10 string >\0 named: %.15s
>8 beshort =16
>>10 string >\0 named: %.16s
>8 beshort =17
>>10 string >\0 named: %.17s
>8 beshort =18
>>10 string >\0 named: %.18s
>8 beshort =19
>>10 string >\0 named: %.19s
>8 beshort =20
>>10 string >\0 named: %.20s
>8 beshort >20
>>10 string >\0 (truncated) named: %.20s

View File

@ -9,23 +9,25 @@
# Microsoft Network Monitor 1.x capture files.
#
0 string RTSS NetMon capture file
>4 byte x - version %d
>5 byte x \b.%d
>5 byte x - version %d
>4 byte x \b.%d
>6 leshort 0 (Unknown)
>6 leshort 1 (Ethernet)
>6 leshort 2 (Token Ring)
>6 leshort 3 (FDDI)
>6 leshort 4 (ATM)
#
# Microsoft Network Monitor 2.x capture files.
#
0 string GMBU NetMon capture file
>4 byte x - version %d
>5 byte x \b.%d
>5 byte x - version %d
>4 byte x \b.%d
>6 leshort 0 (Unknown)
>6 leshort 1 (Ethernet)
>6 leshort 2 (Token Ring)
>6 leshort 3 (FDDI)
>6 leshort 4 (ATM)
#
# Network General Sniffer capture files.
@ -58,6 +60,9 @@
>44 leshort 0 (Ethernet)
>44 leshort 1 (Token Ring)
>44 leshort 2 (FDDI)
>44 leshort 3 (WAN)
>44 leshort 8 (ATM)
>44 leshort 9 (802.11)
#
# "libpcap" capture files.
@ -75,7 +80,7 @@
>20 belong 4 (ProNET
>20 belong 5 (CHAOS
>20 belong 6 (Token Ring
>20 belong 7 (ARCNET
>20 belong 7 (BSD ARCNET
>20 belong 8 (SLIP
>20 belong 9 (PPP
>20 belong 10 (FDDI
@ -92,10 +97,21 @@
>20 belong 104 (BSD/OS Cisco HDLC
>20 belong 105 (802.11
>20 belong 106 (Linux Classical IP over ATM
>20 belong 107 (Frame Relay
>20 belong 108 (OpenBSD loopback
>20 belong 109 (OpenBSD IPSEC encrypted
>20 belong 109 (OpenBSD IPsec encrypted
>20 belong 112 (Cisco HDLC
>20 belong 113 (Linux "cooked"
>20 belong 114 (LocalTalk
>20 belong 117 (OpenBSD PFLOG
>20 belong 119 (802.11 with Prism header
>20 belong 123 (SunATM
>20 belong 127 (802.11 with radiotap header
>20 belong 129 (Linux ARCNET
>20 belong 140 (MTP2
>20 belong 141 (MTP3
>20 belong 143 (DOCSIS
>20 belong 144 (IrDA
>16 belong x \b, capture length %d)
0 ulelong 0xa1b2c3d4 tcpdump capture file (little-endian)
>4 leshort x - version %d
@ -124,10 +140,21 @@
>20 lelong 104 (BSD/OS Cisco HDLC
>20 lelong 105 (802.11
>20 lelong 106 (Linux Classical IP over ATM
>20 lelong 107 (Frame Relay
>20 lelong 108 (OpenBSD loopback
>20 lelong 109 (OpenBSD IPSEC encrypted
>20 lelong 112 (Cisco HDLC
>20 lelong 113 (Linux "cooked"
>20 lelong 114 (LocalTalk
>20 lelong 117 (OpenBSD PFLOG
>20 lelong 119 (802.11 with Prism header
>20 lelong 123 (SunATM
>20 lelong 127 (802.11 with radiotap header
>20 lelong 129 (Linux ARCNET
>20 lelong 140 (MTP2
>20 lelong 141 (MTP3
>20 lelong 143 (DOCSIS
>20 lelong 144 (IrDA
>16 lelong x \b, capture length %d)
#
@ -178,6 +205,7 @@
#
# AIX "iptrace" capture files.
#
0 string iptrace\ 1.0 "iptrace" capture file
0 string iptrace\ 2.0 "iptrace" capture file
#

20
contrib/file/Magdir/spec Normal file
View File

@ -0,0 +1,20 @@
#------------------------------------------------------------------------------
# spec: file(1) magic for SPEC raw results (*.raw, *.rsf)
#
# Cloyce D. Spradling <cloyce@headgear.org>
0 string spec SPEC
>4 string .cpu CPU
>>8 string <: \b%.4s
>>12 string . raw result text
17 string version=SPECjbb SPECjbb
>32 string <: \b%.4s
>>37 string <: v%.4s raw result text
0 string BEGIN\040SPECWEB SPECweb
>13 string <: \b%.2s
>>15 string _SSL \b_SSL
>>>20 string <: v%.4s raw result text
>>16 string <: v%.4s raw result text

View File

@ -26,3 +26,19 @@
>3 byte 2 - character array
>3 byte 3 - memory block
>>14 belong 0x001B0040 (screen)
# The following three blocks are from pak21-spectrum@srcf.ucam.org
# TZX tape images
0 string ZXTape!\x1a Spectrum .TZX data
>8 byte x version %d
>9 byte x .%d
# RZX input recording files
0 string RZX! Spectrum .RZX data
>4 byte x version %d
>5 byte x .%d
# And three sorts of disk image
0 string MV\ -\ CPCEMU\ Disk-Fil Amstrad/Spectrum .DSK data
0 string MV\ -\ CPC\ format\ Dis Amstrad/Spectrum DU54 .DSK data
0 string EXTENDED\ CPC\ DSK\ Fil Amstrad/Spectrum Extended .DSK data

View File

@ -101,7 +101,23 @@
>12 belong 7 (IBM channel-to-channel adapter)
>12 belong 8 (FDDI)
>12 belong 9 (Unknown)
# Microsoft ICM color profile
36 string acspMSFT Microsoft ICM Color Profile
# Sun KCMS
36 string acsp Kodak Color Management System, ICC Profile
#---------------------------------------------------------------------------
# The following entries have been tested by Duncan Laurie <duncan@sun.com> (a
# lead Sun/Cobalt developer) who agrees that they are good and worthy of
# inclusion.
# Boot ROM images for Sun/Cobalt Linux server appliances
0 string Cobalt\ Networks\ Inc.\nFirmware\ v Paged COBALT boot rom
>38 string x V%.4s
# New format for Sun/Cobalt boot ROMs is annoying, it stores the version code
# at the very end where file(1) can't get it.
0 string CRfs COBALT boot rom data (Flat boot rom or file system)

View File

@ -4,13 +4,63 @@
#
0 byte 0xF0 SysEx File -
# North American Group
>1 byte 0x01 Sequential
>1 byte 0x02 IDP
>1 byte 0x03 OctavePlateau
>1 byte 0x04 Moog
>1 byte 0x05 Passport
>1 byte 0x06 Lexicon
>1 byte 0x07 Kurzweil
>1 byte 0x08 Fender
>1 byte 0x09 Gulbransen
>1 byte 0x0a AKG
>1 byte 0x0b Voyce
>1 byte 0x0c Waveframe
>1 byte 0x0d ADA
>1 byte 0x0e Garfield
>1 byte 0x0f Ensoniq
>1 byte 0x10 Oberheim
>1 byte 0x11 Apple
>1 byte 0x12 GreyMatter
>1 byte 0x14 PalmTree
>1 byte 0x15 JLCooper
>1 byte 0x16 Lowrey
>1 byte 0x17 AdamsSmith
>1 byte 0x18 E-mu
>1 byte 0x19 Harmony
>1 byte 0x1a ART
>1 byte 0x1b Baldwin
>1 byte 0x1c Eventide
>1 byte 0x1d Inventronics
>1 byte 0x1f Clarity
# European Group
>1 byte 0x21 SIEL
>1 byte 0x22 Synthaxe
>1 byte 0x24 Hohner
>1 byte 0x25 Twister
>1 byte 0x26 Solton
>1 byte 0x27 Jellinghaus
>1 byte 0x28 Southworth
>1 byte 0x29 PPG
>1 byte 0x2a JEN
>1 byte 0x2b SSL
>1 byte 0x2c AudioVertrieb
>1 byte 0x2f ELKA
>>3 byte 0x09 EK-44
>1 byte 0x30 Dynacord
>1 byte 0x33 Clavia
>1 byte 0x39 Soundcraft
>1 byte 0x3e Waldorf
>>3 byte 0x7f Microwave I
# Japanese Group
>1 byte 0x40 Kawai
>>3 byte 0x20 K1
>>3 byte 0x22 K4
>1 byte 0x41 Roland
@ -26,6 +76,7 @@
>1 byte 0x46 Kamiya
>1 byte 0x47 Akai
>1 byte 0x48 Victor
>1 byte 0x49 Mesosha
>1 byte 0x4b Fujitsu
>1 byte 0x4c Sony
>1 byte 0x4e Teac

View File

@ -1,36 +1,237 @@
# ------------------------------------------------------------------------
# ti-8x: file(1) magic for the TI-8x and TI-92 Graphing Calculators.
# ti-8x: file(1) magic for the TI-8x and TI-9x Graphing Calculators.
#
# From: Ryan McGuire (rmcguire@freenet.columbus.oh.us).
#
# NOTE: This list is not complete.
# Update: Romain Lievin (roms@lpg.ticalc.org).
#
# NOTE: This list is not complete.
# Files for the TI-80 and TI-81 are pretty rare. I'm not going to put the
# program/group magic numbers in here because I cannot find any.
0 string **TI80** TI-80 Graphing Calculator File.
0 string **TI81** TI-81 Graphing Calculator File.
#
# Magic Numbers for the TI-73
#
0 string **TI73** TI-73 Graphing Calculator
>0x00003B byte 0x00 (real number)
>0x00003B byte 0x01 (list)
>0x00003B byte 0x02 (matrix)
>0x00003B byte 0x03 (equation)
>0x00003B byte 0x04 (string)
>0x00003B byte 0x05 (program)
>0x00003B byte 0x06 (assembly program)
>0x00003B byte 0x07 (picture)
>0x00003B byte 0x08 (gdb)
>0x00003B byte 0x0C (complex number)
>0x00003B byte 0x0F (window settings)
>0x00003B byte 0x10 (zoom)
>0x00003B byte 0x11 (table setup)
>0x00003B byte 0x13 (backup)
# Magic Numbers for the TI-82
#
0 string **TI82** TI-82 Graphing Calculator
>0x000037 byte 0x0B TI-BASIC Group/Program File.
0 string **TI82** TI-82 Graphing Calculator
>0x00003B byte 0x00 (real)
>0x00003B byte 0x01 (list)
>0x00003B byte 0x02 (matrix)
>0x00003B byte 0x03 (Y-variable)
>0x00003B byte 0x05 (program)
>0x00003B byte 0x06 (protected prgm)
>0x00003B byte 0x07 (picture)
>0x00003B byte 0x08 (gdb)
>0x00003B byte 0x0B (window settings)
>0x00003B byte 0x0C (window settings)
>0x00003B byte 0x0D (table setup)
>0x00003B byte 0x0E (screenshot)
>0x00003B byte 0x0F (backup)
#
# Magic Numbers for the TI-83
#
0 string **TI83** TI-83 Graphing Calculator
>0x000037 byte 0x0B TI-BASIC Group/Program File.
0 string **TI83** TI-83 Graphing Calculator
>0x00003B byte 0x00 (real)
>0x00003B byte 0x01 (list)
>0x00003B byte 0x02 (matrix)
>0x00003B byte 0x03 (Y-variable)
>0x00003B byte 0x04 (string)
>0x00003B byte 0x05 (program)
>0x00003B byte 0x06 (protected prgm)
>0x00003B byte 0x07 (picture)
>0x00003B byte 0x08 (gdb)
>0x00003B byte 0x0B (window settings)
>0x00003B byte 0x0C (window settings)
>0x00003B byte 0x0D (table setup)
>0x00003B byte 0x0E (screenshot)
>0x00003B byte 0x13 (backup)
#
# Magic Numbers for the TI-83+
#
0 string **TI83F* TI-83+ Graphing Calculator
>0x00003B byte 0x00 (real number)
>0x00003B byte 0x01 (list)
>0x00003B byte 0x02 (matrix)
>0x00003B byte 0x03 (equation)
>0x00003B byte 0x04 (string)
>0x00003B byte 0x05 (program)
>0x00003B byte 0x06 (assembly program)
>0x00003B byte 0x07 (picture)
>0x00003B byte 0x08 (gdb)
>0x00003B byte 0x0C (complex number)
>0x00003B byte 0x0F (window settings)
>0x00003B byte 0x10 (zoom)
>0x00003B byte 0x11 (table setup)
>0x00003B byte 0x13 (backup)
>0x00003B byte 0x15 (application variable)
>0x00003B byte 0x17 (group of variable)
#
# Magic Numbers for the TI-85
#
0 string **TI85** TI-85 Graphing Calculator
>11 string Backup Backup File.
>0x000032 string ZS4 - ZShell Version 4 File.
>0x000032 string ZS3 - ZShell Version 3 File.
>0x00000B string GDatabase Graphics Database.
>0x00003B byte 0x12 TI-BASIC Group/Program File.
0 string **TI85** TI-85 Graphing Calculator
>0x00003B byte 0x00 (real number)
>0x00003B byte 0x01 (complex number)
>0x00003B byte 0x02 (real vector)
>0x00003B byte 0x03 (complex vector)
>0x00003B byte 0x04 (real list)
>0x00003B byte 0x05 (complex list)
>0x00003B byte 0x06 (real matrix)
>0x00003B byte 0x07 (complex matrix)
>0x00003B byte 0x08 (real constant)
>0x00003B byte 0x09 (complex constant)
>0x00003B byte 0x0A (equation)
>0x00003B byte 0x0C (string)
>0x00003B byte 0x0D (function GDB)
>0x00003B byte 0x0E (polar GDB)
>0x00003B byte 0x0F (parametric GDB)
>0x00003B byte 0x10 (diffeq GDB)
>0x00003B byte 0x11 (picture)
>0x00003B byte 0x12 (program)
>0x00003B byte 0x13 (range)
>0x00003B byte 0x17 (window settings)
>0x00003B byte 0x18 (window settings)
>0x00003B byte 0x19 (window settings)
>0x00003B byte 0x1A (window settings)
>0x00003B byte 0x1B (zoom)
>0x00003B byte 0x1D (backup)
>0x00003B byte 0x1E (unknown)
>0x00003B byte 0x2A (equation)
>0x000032 string ZS4 - ZShell Version 4 File.
>0x000032 string ZS3 - ZShell Version 3 File.
#
# Magic Numbers for the TI-86
#
0 string **TI86** TI-86 Graphing Calculator
>0x00003B byte 0x00 (real number)
>0x00003B byte 0x01 (complex number)
>0x00003B byte 0x02 (real vector)
>0x00003B byte 0x03 (complex vector)
>0x00003B byte 0x04 (real list)
>0x00003B byte 0x05 (complex list)
>0x00003B byte 0x06 (real matrix)
>0x00003B byte 0x07 (complex matrix)
>0x00003B byte 0x08 (real constant)
>0x00003B byte 0x09 (complex constant)
>0x00003B byte 0x0A (equation)
>0x00003B byte 0x0C (string)
>0x00003B byte 0x0D (function GDB)
>0x00003B byte 0x0E (polar GDB)
>0x00003B byte 0x0F (parametric GDB)
>0x00003B byte 0x10 (diffeq GDB)
>0x00003B byte 0x11 (picture)
>0x00003B byte 0x12 (program)
>0x00003B byte 0x13 (range)
>0x00003B byte 0x17 (window settings)
>0x00003B byte 0x18 (window settings)
>0x00003B byte 0x19 (window settings)
>0x00003B byte 0x1A (window settings)
>0x00003B byte 0x1B (zoom)
>0x00003B byte 0x1D (backup)
>0x00003B byte 0x1E (unknown)
>0x00003B byte 0x2A (equation)
#
# Magic Numbers for the TI-89
#
0 string **TI89** TI-89 Graphing Calculator
>0x000048 byte 0x00 (expression)
>0x000048 byte 0x04 (list)
>0x000048 byte 0x06 (matrix)
>0x000048 byte 0x0A (data)
>0x000048 byte 0x0B (text)
>0x000048 byte 0x0C (string)
>0x000048 byte 0x0D (graphic data base)
>0x000048 byte 0x0E (figure)
>0x000048 byte 0x10 (picture)
>0x000048 byte 0x12 (program)
>0x000048 byte 0x13 (function)
>0x000048 byte 0x14 (macro)
>0x000048 byte 0x1C (zipped)
>0x000048 byte 0x21 (assembler)
#
# Magic Numbers for the TI-92
#
0 string **TI92** TI-92 Graphing Calculator
>0x000058 byte 0x12 TI-BASIC Group File.
>0x000012 string Function Function.
>0x000048 byte 0x12 TI-BASIC Program.
# Files for the TI-80 and TI-81 are pretty rare. I'm not going to put the
# program/group magic numbers in here because I cannot find any.
0 string **TI80** TI-80 Graphing Calculator File.
0 string **TI81** TI-81 Graphing Calculator File.
0 string **TI92** TI-92 Graphing Calculator
>0x000048 byte 0x00 (expression)
>0x000048 byte 0x04 (list)
>0x000048 byte 0x06 (matrix)
>0x000048 byte 0x0A (data)
>0x000048 byte 0x0B (text)
>0x000048 byte 0x0C (string)
>0x000048 byte 0x0D (graphic data base)
>0x000048 byte 0x0E (figure)
>0x000048 byte 0x10 (picture)
>0x000048 byte 0x12 (program)
>0x000048 byte 0x13 (function)
>0x000048 byte 0x14 (macro)
>0x000048 byte 0x1D (backup)
#
# Magic Numbers for the TI-92+/V200
#
0 string **TI92P* TI-92+/V200 Graphing Calculator
>0x000048 byte 0x00 (expression)
>0x000048 byte 0x04 (list)
>0x000048 byte 0x06 (matrix)
>0x000048 byte 0x0A (data)
>0x000048 byte 0x0B (text)
>0x000048 byte 0x0C (string)
>0x000048 byte 0x0D (graphic data base)
>0x000048 byte 0x0E (figure)
>0x000048 byte 0x10 (picture)
>0x000048 byte 0x12 (program)
>0x000048 byte 0x13 (function)
>0x000048 byte 0x14 (macro)
>0x000048 byte 0x1C (zipped)
>0x000048 byte 0x21 (assembler)
#
# Magic Numbers for the TI-73/83+/89/92+/V200 FLASH upgrades
#
0x0000016 string Advanced TI-XX Graphing Calculator (FLASH)
0 string **TIFL** TI-XX Graphing Calculator (FLASH)
>8 byte >0 - Revision %d
>>9 byte x \b.%d,
>12 byte >0 Revision date %02x
>>13 byte x \b/%02x
>>14 beshort x \b/%04x,
>17 string >/0 name: '%s',
>48 byte 0x74 device: TI-73,
>48 byte 0x73 device: TI-83+,
>48 byte 0x98 device: TI-89,
>48 byte 0x88 device: TI-92+,
>49 byte 0x23 type: OS upgrade,
>49 byte 0x24 type: application,
>49 byte 0x25 type: certificate,
>49 byte 0x3e type: license,
>74 lelong >0 size: %ld bytes
# VTi & TiEmu skins (TI Graphing Calculators).
# From: Romain Lievin (roms@lpg.ticalc.org).
# Magic Numbers for the VTi skins
0 string VTI Virtual TI skin
>3 string v - Version
>>4 byte >0 \b %c
>>6 byte x \b.%c
# Magic Numbers for the TiEmu skins
0 string TiEmu TiEmu skin
>6 string v - Version
>>7 byte >0 \b %c
>>9 byte x \b.%c
>>10 byte x \b%c

View File

@ -15,7 +15,7 @@
# 0x10B is 0413; that's VAX demand-paged, but this is a short, not a
# long, as it would be on a VAX.
#
# 0x10C is 0414, 0x10D is 0415, and 0x10E is 416; those *are* unknown.
# 0x10C is 0414 and 0x10E is 416; those *are* unknown.
#
0 short 0x107 unknown machine executable
>8 short >0 not stripped
@ -31,6 +31,4 @@
>15 byte >0 - version %ld
0 long 0x10c unknown demand paged pure executable
>16 long >0 not stripped
0 long 0x10d unknown demand paged pure executable
>16 long >0 not stripped
0 long 0x10e unknown readable demand paged pure executable

View File

@ -28,5 +28,8 @@
>4 long x - version %ld
# From: Dave Pearson <davep@davep.org>
# Harbour <URL:http://www.harbour-project.org/> HRB files.
0 string \xc0HRB Harbour HRB file
>4 short x version %d
0 string \xc0HRB Harbour HRB file
>4 short x version %d
# From: "Stefan A. Haubenthal" <polluks@web.de>
0 belong 0x000001EB Plan 9 executable

View File

@ -0,0 +1,12 @@
#------------------------------------------------------------------------------
# varied.script: file(1) magic for various interpreter scripts
0 string #!\ / a
>3 string >\0 %s script text executable
0 string #!\ / a
>3 string >\0 %s script text executable
0 string #!/ a
>2 string >\0 %s script text executable
0 string #!\ script text executable
>3 string >\0 for %s

View File

@ -3,10 +3,10 @@
# VMware specific files (deducted from version 1.1 and log file entries)
# Anthon van der Neut (anthon@mnt.org)
0 belong 0x4d52564e VMware nvram
0 belong 0x434f5744
>8 byte 3 VMware virtual disk
0 belong 0x434f5744 VMware
>4 byte 3 virtual disk
>>32 lelong x (%d/
>>36 lelong x \b%d/
>>40 lelong x \b%d)
>8 byte 2 VMware undoable disk
>4 byte 2 undoable disk
>>32 string >\0 (%s)

View File

@ -17,6 +17,18 @@
##>4 byte 0 revision 0
>4 byte 0
##>>14 lelong x (Serial %lX)
# non-Vorbis content: FLAC (Free Lossless Audio Codec, http://flac.sourceforge.net)
>>28 string fLaC \b, FLAC audio
# non-Vorbis content: Theora
>>28 string \x80theora \b, Theora video
# non-Vorbis content: Speex
>>28 string Speex\ \ \ \b, Speex audio
# non-Vorbis content: OGM
>>28 string \x01video\0\0\0 \b, OGM video
>>>37 string/c div3 (DivX 3)
>>>37 string/c divx (DivX 4)
>>>37 string/c dx50 (DivX 5)
>>>37 string/c xvid (XviD)
# --- First vorbis packet - general header ---
>>28 string \x01vorbis \b, Vorbis audio,
>>>35 lelong !0 UNKNOWN VERSION %lu,
@ -29,19 +41,19 @@
# Minimal, nominal and maximal bitrates specified when encoding
>>>>48 string <\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \b,
# The above tests if at least one of these is specified:
>>>>>44 lelong !-1
>>>>>52 lelong !-1
# Vorbis RC2 has a bug which puts -1000 in the min/max bitrate fields
# instead of -1.
# Vorbis 1.0 uses 0 instead of -1.
>>>>>>44 lelong !-1000
>>>>>>>44 lelong !0
>>>>>>>>44 lelong x >%lu
>>>>>48 lelong !-1
>>>>>>48 lelong x ~%lu
>>>>>52 lelong !-1
>>>>>>52 lelong !0
>>>>>>>52 lelong !-1000
>>>>>>>>52 lelong x <%lu
>>>>>48 lelong !-1
>>>>>>48 lelong x ~%lu
>>>>>44 lelong !-1
>>>>>>44 lelong !-1000
>>>>>>>44 lelong !0
>>>>>>>>44 lelong x >%lu
>>>>>48 string <\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff bps
# -- Second vorbis header packet - the comments
# A kludge to read the vendor string. It's a counted string, not a
@ -52,28 +64,30 @@
# in a different place, so we must use an indirect offset.
>>>(84.b+85) string \x03vorbis
>>>>(84.b+96) string/c Xiphophorus\ libVorbis\ I \b, created by: Xiphophorus libVorbis I
>>>>>(84.b+120) string >00000000 %.8s
>>>>>(84.b+120) string >00000000
# Map to beta version numbers:
>>>>>>(84.b+120) string <20000508 (<beta1 - prepublic)
>>>>>>(84.b+120) string 20000508 (beta1/2)
>>>>>>(84.b+120) string <20000508 (<beta1, prepublic)
>>>>>>(84.b+120) string 20000508 (1.0 beta 1 or beta 2)
>>>>>>(84.b+120) string >20000508
>>>>>>>(84.b+120) string <20001031 (beta2-3)
>>>>>>(84.b+120) string 20001031 (beta3)
>>>>>>(84.b+120) string 20001031 (1.0 beta 3)
>>>>>>(84.b+120) string >20001031
>>>>>>>(84.b+120) string <20010225 (beta3-4)
>>>>>>(84.b+120) string 20010225 (beta4)
>>>>>>(84.b+120) string 20010225 (1.0 beta 4)
>>>>>>(84.b+120) string >20010225
>>>>>>>(84.b+120) string <20010615 (beta4-RC1)
>>>>>>(84.b+120) string 20010615 (RC1)
>>>>>>(84.b+120) string 20010813 (RC2)
>>>>>>(84.b+120) string 20010615 (1.0 RC1)
>>>>>>(84.b+120) string 20010813 (1.0 RC2)
>>>>>>(84.b+120) string 20010816 (RC2 - Garf tuned v1)
>>>>>>(84.b+120) string 20011014 (RC2 - Garf tuned v2)
>>>>>>(84.b+120) string 20011217 (pre-RC3 CVS)
>>>>>>(84.b+120) string 20011231 (RC3)
>>>>>>(84.b+120) string 20011217 (1.0 RC3)
>>>>>>(84.b+120) string 20011231 (1.0 RC3)
# Some pre-1.0 CVS snapshots still had "Xiphphorus"...
>>>>>>(84.b+120) string >20011231 (pre-1.0 CVS)
# For the 1.0 release, Xiphophorus is replaced by Xiph.Org
>>>>(84.b+96) string/c Xiph.Org\ libVorbis\ I \b, created by: Xiph.Org libVorbis I
>>>>>(84.b+117) string >00000000 %.8s
>>>>>(84.b+117) string >00000000
>>>>>>(84.b+117) string <20020717 (pre-1.0 CVS)
>>>>>>(84.b+117) string 20020717 (1.0)
>>>>>>(84.b+117) string 20030909 (1.0.1)
>>>>>>(84.b+117) string 20040629 (1.1.0 RC1)

View File

@ -0,0 +1,111 @@
#------------------------------------------------------------------------------
# wordprocessors: file(1) magic fo word processors.
#
####### PWP file format used on Smith Corona Personal Word Processors:
2 string \040\040\040\040\040\040\040\040\040\040\040ML4D\040\'92 Smith Corona PWP
>24 byte 2 \b, single spaced
>24 byte 3 \b, 1.5 spaced
>24 byte 4 \b, double spaced
>25 byte 0x42 \b, letter
>25 byte 0x54 \b, legal
>26 byte 0x46 \b, A4
#WordPerfect type files Version 1.6 - PLEASE DO NOT REMOVE THIS LINE
0 string \377WPC\020\000\000\000\022\012\001\001\000\000\000\000 (WP) loadable text
>15 byte 0 Optimized for Intel
>15 byte 1 Optimized for Non-Intel
1 string WPC (Corel/WP)
>8 short 257 WordPerfect macro
>8 short 258 WordPerfect help file
>8 short 259 WordPerfect keyboard file
>8 short 266 WordPerfect document
>8 short 267 WordPerfect dictionary
>8 short 268 WordPerfect thesaurus
>8 short 269 WordPerfect block
>8 short 270 WordPerfect rectangular block
>8 short 271 WordPerfect column block
>8 short 272 WordPerfect printer data
>8 short 275 WordPerfect printer data
>8 short 276 WordPerfect driver resource data
>8 short 279 WordPerfect hyphenation code
>8 short 280 WordPerfect hyphenation data
>8 short 281 WordPerfect macro resource data
>8 short 283 WordPerfect hyphenation lex
>8 short 285 WordPerfect wordlist
>8 short 286 WordPerfect equation resource data
>8 short 289 WordPerfect spell rules
>8 short 290 WordPerfect dictionary rules
>8 short 295 WordPerfect spell rules (Microlytics)
>8 short 299 WordPerfect settings file
>8 short 301 WordPerfect 4.2 document
>8 short 325 WordPerfect dialog file
>8 short 332 WordPerfect button bar
>8 short 513 Shell macro
>8 short 522 Shell definition
>8 short 769 Notebook macro
>8 short 770 Notebook help file
>8 short 771 Notebook keyboard file
>8 short 778 Notebook definition
>8 short 1026 Calculator help file
>8 short 1538 Calendar help file
>8 short 1546 Calendar data file
>8 short 1793 Editor macro
>8 short 1794 Editor help file
>8 short 1795 Editor keyboard file
>8 short 1817 Editor macro resource file
>8 short 2049 Macro editor macro
>8 short 2050 Macro editor help file
>8 short 2051 Macro editor keyboard file
>8 short 2305 PlanPerfect macro
>8 short 2306 PlanPerfect help file
>8 short 2307 PlanPerfect keyboard file
>8 short 2314 PlanPerfect worksheet
>8 short 2319 PlanPerfect printer definition
>8 short 2322 PlanPerfect graphic definition
>8 short 2323 PlanPerfect data
>8 short 2324 PlanPerfect temporary printer
>8 short 2329 PlanPerfect macro resource data
>8 byte 11 Mail
>8 short 2818 help file
>8 short 2821 distribution list
>8 short 2826 out box
>8 short 2827 in box
>8 short 2836 users archived mailbox
>8 short 2837 archived message database
>8 short 2838 archived attachments
>8 short 3083 Printer temporary file
>8 short 3330 Scheduler help file
>8 short 3338 Scheduler in file
>8 short 3339 Scheduler out file
>8 short 3594 GroupWise settings file
>8 short 3601 GroupWise directory services
>8 short 3627 GroupWise settings file
>8 short 4362 Terminal resource data
>8 short 4363 Terminal resource data
>8 short 4395 Terminal resource data
>8 short 4619 GUI loadable text
>8 short 4620 graphics resource data
>8 short 4621 printer settings file
>8 short 4622 port definition file
>8 short 4623 print queue parameters
>8 short 4624 compressed file
>8 short 5130 Network service msg file
>8 short 5131 Network service msg file
>8 short 5132 Async gateway login msg
>8 short 5134 GroupWise message file
>8 short 7956 GroupWise admin domain database
>8 short 7957 GroupWise admin host database
>8 short 7959 GroupWise admin remote host database
>8 short 7960 GroupWise admin ADS deferment data file
>8 short 8458 IntelliTAG (SGML) compiled DTD
>8 long 18219264 WordPerfect graphic image (1.0)
>8 long 18219520 WordPerfect graphic image (2.0)
#end of WordPerfect type files Version 1.6 - PLEASE DO NOT REMOVE THIS LINE
# Hangul (Korean) Word Processor File
0 string HWP\ Document\ File Hangul (Korean) Word Processor File
# CosmicBook, from Benoît Rouits
0 string CSBK Ted Neslson's CosmicBook hypertext file

View File

@ -0,0 +1,25 @@
#------------------------------------------------------------------------------
# xwindows: file(1) magic for various X/Window system file formats.
# Compiled X Keymap
# XKM (compiled X keymap) files (including version and byte ordering)
1 string mkx Compiled XKB Keymap: lsb,
>0 byte >0 version %d
>0 byte =0 obsolete
0 string xkm Compiled XKB Keymap: msb,
>3 byte >0 version %d
>0 byte =0 obsolete
# xfsdump archive
0 string xFSdump0 xfsdump archive
>8 long x (version %d)
# Jaleo XFS files
0 long 395726 Jaleo XFS file
>4 long x - version %ld
>8 long x - [%ld -
>20 long x %ldx
>24 long x %ldx
>28 long 1008 YUV422]
>28 long 1000 RGB24]

View File

@ -1,29 +1,8 @@
# don't enforce GNU packaging standards
AUTOMAKE_OPTIONS = foreign no-dependencies
pkgdata_DATA = magic magic.mime magic.mgc magic.mime.mgc
bin_PROGRAMS = file
EXTRA_DIST = magic2mime Localstuff Header magic.mime $(magic_FRAGMENTS)
data_DATA = magic magic.mime magic.mgc magic.mime.mgc
MAGIC = @datadir@/magic
CPPFLAGS = -DMAGIC='"$(MAGIC)"'
if FSECT5
man_MAGIC = magic.5
else
man_MAGIC = magic.4
endif
fsect = @fsect@
man_MANS = file.1 $(man_MAGIC)
file_SOURCES = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
compress.c is_tar.c readelf.c print.c \
file.h names.h patchlevel.h readelf.h tar.h
EXTRA_DIST = LEGAL.NOTICE MAINT PORTING Makefile.std magic2mime \
Localstuff Header $(magic_FRAGMENTS) file.man magic.man
CLEANFILES = $(man_MANS) magic magic.mgc magic.mime.mgc
CLEANFILES = magic magic.mgc magic.mime.mgc
magic: Header Localstuff $(magic_FRAGMENTS)
cat $(srcdir)/Header $(srcdir)/Localstuff > $@
@ -36,25 +15,11 @@ magic: Header Localstuff $(magic_FRAGMENTS)
cat $$f; \
done >> $@
magic.mgc: magic file
./file -C -m magic
magic.mgc: magic
$(top_builddir)/src/file -C -m magic
magic.mime.mgc: magic.mime file
./file -C -m $(srcdir)/magic.mime
file.1: Makefile file.man
@rm -f $@
sed -e s@__CSECTION__@1@g \
-e s@__FSECTION__@${fsect}@g \
-e s@__VERSION__@${VERSION}@g \
-e s@__MAGIC__@${MAGIC}@g $(srcdir)/file.man > $@
magic.${fsect}: Makefile magic.man
@rm -f $@
sed -e s@__CSECTION__@1@g \
-e s@__FSECTION__@${fsect}@g \
-e s@__VERSION__@${VERSION}@g \
-e s@__MAGIC__@${MAGIC}@g $(srcdir)/magic.man > $@
magic.mime.mgc: magic.mime
$(top_builddir)/src/file -C -m $(srcdir)/magic.mime
magic_FRAGMENTS = \
Magdir/acorn \
@ -73,22 +38,29 @@ Magdir/archive \
Magdir/asterix \
Magdir/att3b \
Magdir/audio \
Magdir/bFLT \
Magdir/blender \
Magdir/blit \
Magdir/bout \
Magdir/bsdi \
Magdir/cad \
Magdir/c-lang \
Magdir/c64 \
Magdir/cddb \
Magdir/chi \
Magdir/chord \
Magdir/cisco \
Magdir/citrus \
Magdir/claris \
Magdir/clipper \
Magdir/spec \
Magdir/commands \
Magdir/communications \
Magdir/compress \
Magdir/console \
Magdir/convex \
Magdir/ctags \
Magdir/cvs \
Magdir/dact \
Magdir/database \
Magdir/diamond \
Magdir/diff \
@ -100,12 +72,16 @@ Magdir/editors \
Magdir/elf \
Magdir/encore \
Magdir/epoc \
Magdir/fcs \
Magdir/filesystems \
Magdir/flash \
Magdir/fonts \
Magdir/frame \
Magdir/freebsd \
Magdir/fsav \
Magdir/games \
Magdir/geos \
Magdir/gcc \
Magdir/gimp \
Magdir/gnu \
Magdir/grace \
@ -113,6 +89,7 @@ Magdir/gringotts \
Magdir/hdf \
Magdir/hitachi-sh \
Magdir/hp \
Magdir/human68k \
Magdir/ibm370 \
Magdir/ibm6000 \
Magdir/iff \
@ -135,13 +112,15 @@ Magdir/magic \
Magdir/mail.news \
Magdir/maple \
Magdir/mathematica \
Magdir/matroska \
Magdir/mcrypt \
Magdir/mime \
Magdir/mips \
Magdir/mirage \
Magdir/misctools \
Magdir/mkid \
Magdir/mmdf \
Magdir/mlssa \
Magdir/mmdf \
Magdir/modem \
Magdir/motorola \
Magdir/msdos \
@ -152,6 +131,7 @@ Magdir/netbsd \
Magdir/netscape \
Magdir/news \
Magdir/nitpicker \
Magdir/ocaml \
Magdir/octave \
Magdir/olf \
Magdir/os2 \
@ -165,13 +145,16 @@ Magdir/pdp \
Magdir/perl \
Magdir/pgp \
Magdir/pkgadd \
Magdir/plan9 \
Magdir/plus5 \
Magdir/printer \
Magdir/project \
Magdir/psdbms \
Magdir/psion \
Magdir/pulsar \
Magdir/pyramid \
Magdir/python \
Magdir/revision \
Magdir/riff \
Magdir/rpm \
Magdir/rtf \
@ -179,8 +162,10 @@ Magdir/sc \
Magdir/sccs \
Magdir/sendmail \
Magdir/sequent \
Magdir/sgi \
Magdir/sgml \
Magdir/sharc \
Magdir/sinclair \
Magdir/sketch \
Magdir/smalltalk \
Magdir/sniffer \
@ -201,6 +186,7 @@ Magdir/typeset \
Magdir/unknown \
Magdir/uuencode \
Magdir/varied.out \
Magdir/varied.script \
Magdir/vax \
Magdir/vicar \
Magdir/visx \
@ -208,8 +194,9 @@ Magdir/vms \
Magdir/vmware \
Magdir/vorbis \
Magdir/vxl \
Magdir/wordperfect \
Magdir/wordprocessors \
Magdir/xdelta \
Magdir/xenix \
Magdir/xwindows \
Magdir/zilog \
Magdir/zyxel

View File

@ -1,6 +1,8 @@
# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
# Makefile.in generated by automake 1.7.9 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -10,84 +12,121 @@
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# don't enforce GNU packaging standards
SHELL = @SHELL@
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
top_builddir = .
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FSECT5_FALSE = @FSECT5_FALSE@
FSECT5_TRUE = @FSECT5_TRUE@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
AUTOMAKE_OPTIONS = foreign no-dependencies
bin_PROGRAMS = file
data_DATA = magic magic.mime magic.mgc magic.mime.mgc
MAGIC = @datadir@/magic
CPPFLAGS = -DMAGIC='"$(MAGIC)"'
@FSECT5_TRUE@man_MAGIC = @FSECT5_TRUE@magic.5
@FSECT5_FALSE@man_MAGIC = @FSECT5_FALSE@magic.4
ac_ct_CC = @ac_ct_CC@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
fsect = @fsect@
man_MANS = file.1 $(man_MAGIC)
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
pkgdata_DATA = magic magic.mime magic.mgc magic.mime.mgc
file_SOURCES = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
compress.c is_tar.c readelf.c print.c \
file.h names.h patchlevel.h readelf.h tar.h
EXTRA_DIST = magic2mime Localstuff Header magic.mime $(magic_FRAGMENTS)
EXTRA_DIST = LEGAL.NOTICE MAINT PORTING Makefile.std magic2mime \
Localstuff Header $(magic_FRAGMENTS) file.man magic.man
CLEANFILES = $(man_MANS) magic magic.mgc magic.mime.mgc
CLEANFILES = magic magic.mgc magic.mime.mgc
magic_FRAGMENTS = \
Magdir/acorn \
@ -106,22 +145,29 @@ Magdir/archive \
Magdir/asterix \
Magdir/att3b \
Magdir/audio \
Magdir/bFLT \
Magdir/blender \
Magdir/blit \
Magdir/bout \
Magdir/bsdi \
Magdir/cad \
Magdir/c-lang \
Magdir/c64 \
Magdir/cddb \
Magdir/chi \
Magdir/chord \
Magdir/cisco \
Magdir/citrus \
Magdir/claris \
Magdir/clipper \
Magdir/spec \
Magdir/commands \
Magdir/communications \
Magdir/compress \
Magdir/console \
Magdir/convex \
Magdir/ctags \
Magdir/cvs \
Magdir/dact \
Magdir/database \
Magdir/diamond \
Magdir/diff \
@ -133,12 +179,16 @@ Magdir/editors \
Magdir/elf \
Magdir/encore \
Magdir/epoc \
Magdir/fcs \
Magdir/filesystems \
Magdir/flash \
Magdir/fonts \
Magdir/frame \
Magdir/freebsd \
Magdir/fsav \
Magdir/games \
Magdir/geos \
Magdir/gcc \
Magdir/gimp \
Magdir/gnu \
Magdir/grace \
@ -146,6 +196,7 @@ Magdir/gringotts \
Magdir/hdf \
Magdir/hitachi-sh \
Magdir/hp \
Magdir/human68k \
Magdir/ibm370 \
Magdir/ibm6000 \
Magdir/iff \
@ -168,13 +219,15 @@ Magdir/magic \
Magdir/mail.news \
Magdir/maple \
Magdir/mathematica \
Magdir/matroska \
Magdir/mcrypt \
Magdir/mime \
Magdir/mips \
Magdir/mirage \
Magdir/misctools \
Magdir/mkid \
Magdir/mmdf \
Magdir/mlssa \
Magdir/mmdf \
Magdir/modem \
Magdir/motorola \
Magdir/msdos \
@ -185,6 +238,7 @@ Magdir/netbsd \
Magdir/netscape \
Magdir/news \
Magdir/nitpicker \
Magdir/ocaml \
Magdir/octave \
Magdir/olf \
Magdir/os2 \
@ -198,13 +252,16 @@ Magdir/pdp \
Magdir/perl \
Magdir/pgp \
Magdir/pkgadd \
Magdir/plan9 \
Magdir/plus5 \
Magdir/printer \
Magdir/project \
Magdir/psdbms \
Magdir/psion \
Magdir/pulsar \
Magdir/pyramid \
Magdir/python \
Magdir/revision \
Magdir/riff \
Magdir/rpm \
Magdir/rtf \
@ -212,8 +269,10 @@ Magdir/sc \
Magdir/sccs \
Magdir/sendmail \
Magdir/sequent \
Magdir/sgi \
Magdir/sgml \
Magdir/sharc \
Magdir/sinclair \
Magdir/sketch \
Magdir/smalltalk \
Magdir/sniffer \
@ -234,6 +293,7 @@ Magdir/typeset \
Magdir/unknown \
Magdir/uuencode \
Magdir/varied.out \
Magdir/varied.script \
Magdir/vax \
Magdir/vicar \
Magdir/visx \
@ -241,428 +301,181 @@ Magdir/vms \
Magdir/vmware \
Magdir/vorbis \
Magdir/vxl \
Magdir/wordperfect \
Magdir/wordprocessors \
Magdir/xdelta \
Magdir/xenix \
Magdir/xwindows \
Magdir/zilog \
Magdir/zyxel
subdir = magic
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
PROGRAMS = $(bin_PROGRAMS)
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
DIST_SOURCES =
DATA = $(pkgdata_DATA)
DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
all: all-am
DEFS = @DEFS@ -I. -I$(srcdir) -I.
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
file_OBJECTS = file.o apprentice.o fsmagic.o softmagic.o ascmagic.o \
compress.o is_tar.o readelf.o print.o
file_LDADD = $(LDADD)
file_DEPENDENCIES =
file_LDFLAGS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
man1dir = $(mandir)/man1
man4dir = $(mandir)/man4
man5dir = $(mandir)/man5
MANS = $(man_MANS)
NROFF = nroff
DATA = $(data_DATA)
DIST_COMMON = README ./stamp-h.in Makefile.am Makefile.in acconfig.h \
acinclude.m4 aclocal.m4 config.h.in configure configure.in install-sh \
missing mkinstalldirs
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
SOURCES = $(file_SOURCES)
OBJECTS = $(file_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu magic/Makefile
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-libtool:
-rm -f *.lo
$(ACLOCAL_M4): configure.in acinclude.m4
cd $(srcdir) && $(ACLOCAL)
clean-libtool:
-rm -rf .libs _libs
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
config.h: stamp-h
@if test ! -f $@; then \
rm -f stamp-h; \
$(MAKE) stamp-h; \
else :; fi
stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES= CONFIG_HEADERS=config.h \
$(SHELL) ./config.status
@echo timestamp > stamp-h 2> /dev/null
$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
@if test ! -f $@; then \
rm -f $(srcdir)/stamp-h.in; \
$(MAKE) $(srcdir)/stamp-h.in; \
else :; fi
$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h
cd $(top_srcdir) && $(AUTOHEADER)
@echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
mostlyclean-hdr:
clean-hdr:
distclean-hdr:
-rm -f config.h
maintainer-clean-hdr:
mostlyclean-binPROGRAMS:
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
distclean-binPROGRAMS:
maintainer-clean-binPROGRAMS:
install-binPROGRAMS: $(bin_PROGRAMS)
distclean-libtool:
-rm -f libtool
uninstall-info-am:
pkgdataDATA_INSTALL = $(INSTALL_DATA)
install-pkgdataDATA: $(pkgdata_DATA)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(bindir)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
if test -f $$p; then \
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
else :; fi; \
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)
@list='$(pkgdata_DATA)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(pkgdataDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f"; \
$(pkgdataDATA_INSTALL) $$d$$p $(DESTDIR)$(pkgdatadir)/$$f; \
done
uninstall-binPROGRAMS:
uninstall-pkgdataDATA:
@$(NORMAL_UNINSTALL)
list='$(bin_PROGRAMS)'; for p in $$list; do \
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
@list='$(pkgdata_DATA)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f $(DESTDIR)$(pkgdatadir)/$$f"; \
rm -f $(DESTDIR)$(pkgdatadir)/$$f; \
done
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
file: $(file_OBJECTS) $(file_DEPENDENCIES)
@rm -f file
$(LINK) $(file_LDFLAGS) $(file_OBJECTS) $(file_LDADD) $(LIBS)
install-man1:
$(mkinstalldirs) $(DESTDIR)$(man1dir)
@list='$(man1_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \
$(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \
done
uninstall-man1:
@list='$(man1_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \
rm -f $(DESTDIR)$(man1dir)/$$inst; \
done
install-man4:
$(mkinstalldirs) $(DESTDIR)$(man4dir)
@list='$(man4_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.4*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man4dir)/$$inst"; \
$(INSTALL_DATA) $$file $(DESTDIR)$(man4dir)/$$inst; \
done
uninstall-man4:
@list='$(man4_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.4*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f $(DESTDIR)$(man4dir)/$$inst"; \
rm -f $(DESTDIR)$(man4dir)/$$inst; \
done
install-man5:
$(mkinstalldirs) $(DESTDIR)$(man5dir)
@list='$(man5_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.5*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man5dir)/$$inst"; \
$(INSTALL_DATA) $$file $(DESTDIR)$(man5dir)/$$inst; \
done
uninstall-man5:
@list='$(man5_MANS)'; \
l2='$(man_MANS)'; for i in $$l2; do \
case "$$i" in \
*.5*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f $(DESTDIR)$(man5dir)/$$inst"; \
rm -f $(DESTDIR)$(man5dir)/$$inst; \
done
install-man: $(MANS)
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-man1 install-man4 install-man5
uninstall-man:
@$(NORMAL_UNINSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-man1 uninstall-man4 uninstall-man5
install-dataDATA: $(data_DATA)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(datadir)
@list='$(data_DATA)'; for p in $$list; do \
if test -f $(srcdir)/$$p; then \
echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(datadir)/$$p"; \
$(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(datadir)/$$p; \
else if test -f $$p; then \
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(datadir)/$$p"; \
$(INSTALL_DATA) $$p $(DESTDIR)$(datadir)/$$p; \
fi; fi; \
done
uninstall-dataDATA:
@$(NORMAL_UNINSTALL)
list='$(data_DATA)'; for p in $$list; do \
rm -f $(DESTDIR)$(datadir)/$$p; \
done
tags: TAGS
TAGS:
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
ctags: CTAGS
CTAGS:
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
mostlyclean-tags:
top_distdir = ..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
-rm -rf $(distdir)
GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
dc_install_base=`cd $(distdir)/=inst && pwd`; \
cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) dist
-rm -rf $(distdir)
@banner="$(distdir).tar.gz is ready for distribution"; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
echo "$$dashes"
dist: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
dist-all: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
distdir: $(DISTFILES)
-rm -rf $(distdir)
mkdir $(distdir)
-chmod 777 $(distdir)
$(mkinstalldirs) $(distdir)/Magdir
@for file in $(DISTFILES); do \
d=$(srcdir); \
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
all-recursive-am: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
all-am: Makefile $(DATA)
install-exec-am: install-binPROGRAMS
installdirs:
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)
install: install-am
install-exec: install-exec-am
install-data-am: install-man install-dataDATA
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-binPROGRAMS uninstall-man uninstall-dataDATA
uninstall: uninstall-am
all-am: Makefile $(PROGRAMS) $(MANS) $(DATA) config.h
all-redirect: all-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 \
$(DESTDIR)$(mandir)/man4 $(DESTDIR)$(mandir)/man5 \
$(DESTDIR)$(datadir)
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
mostlyclean-am: mostlyclean-hdr mostlyclean-binPROGRAMS \
mostlyclean-compile mostlyclean-tags \
mostlyclean-generic
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-libtool
dvi: dvi-am
dvi-am:
info: info-am
info-am:
install-data-am: install-pkgdataDATA
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
clean-am: clean-hdr clean-binPROGRAMS clean-compile clean-tags \
clean-generic mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
clean: clean-am
pdf: pdf-am
distclean-am: distclean-hdr distclean-binPROGRAMS distclean-compile \
distclean-tags distclean-generic clean-am
pdf-am:
distclean: distclean-am
-rm -f config.status
ps: ps-am
maintainer-clean-am: maintainer-clean-hdr maintainer-clean-binPROGRAMS \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
ps-am:
maintainer-clean: maintainer-clean-am
-rm -f config.status
uninstall-am: uninstall-info-am uninstall-pkgdataDATA
.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile install-man1 uninstall-man1 install-man4 \
uninstall-man4 install-man5 uninstall-man5 install-man uninstall-man \
uninstall-dataDATA install-dataDATA tags mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \
install-exec-am install-exec install-data-am install-data install-am \
install uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
distclean distclean-generic distclean-libtool distdir dvi \
dvi-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-pkgdataDATA install-strip \
installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
uninstall-info-am uninstall-pkgdataDATA
magic: Header Localstuff $(magic_FRAGMENTS)
@ -676,26 +489,11 @@ magic: Header Localstuff $(magic_FRAGMENTS)
cat $$f; \
done >> $@
magic.mgc: magic file
./file -C -m magic
magic.mime.mgc: magic.mime file
./file -C -m $(srcdir)/magic.mime
file.1: Makefile file.man
@rm -f $@
sed -e s@__CSECTION__@1@g \
-e s@__FSECTION__@${fsect}@g \
-e s@__VERSION__@${VERSION}@g \
-e s@__MAGIC__@${MAGIC}@g $(srcdir)/file.man > $@
magic.${fsect}: Makefile magic.man
@rm -f $@
sed -e s@__CSECTION__@1@g \
-e s@__FSECTION__@${fsect}@g \
-e s@__VERSION__@${VERSION}@g \
-e s@__MAGIC__@${MAGIC}@g $(srcdir)/magic.man > $@
magic.mgc: magic
$(top_builddir)/src/file -C -m magic
magic.mime.mgc: magic.mime
$(top_builddir)/src/file -C -m $(srcdir)/magic.mime
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -1,10 +1,16 @@
** README for file(1) Command **
@(#) $Id: README,v 1.29 2003/02/27 20:47:46 christos Exp $
@(#) $Id: README,v 1.33 2003/05/23 21:31:56 christos Exp $
This is Release 3.x of Ian Darwin's (copyright but distributable)
This is Release 4.x of Ian Darwin's (copyright but distributable)
file(1) command. This version is the standard "file" command for Linux,
*BSD, and other systems. (See "patchlevel.h" for the exact release number).
The major feature of 4.x is the refactoring of the code into a library,
and the re-write of the file command in terms of that library. The library
itself, libmagic can be used by 3rd party programs that wish to identify
file types without having to fork() and exec() file. The prime contributor
for 4.0 was M\xe5ns Rullg\xe5rd.
UNIX is a trademark of UNIX System Laboratories.
The prime contributor to Release 3.8 was Guy Harris, who put in megachanges
@ -33,7 +39,7 @@ In addition, the /etc/magic file is built from a subdirectory
for easier(?) maintenance. I will act as a clearinghouse for
magic numbers assigned to all sorts of data files that
are in reasonable circulation. Send your magic numbers,
in magic(4) format please, to the maintainer, Christos Zoulas.
in magic(5) format please, to the maintainer, Christos Zoulas.
LEGAL.NOTICE - read this first.
README - read this second (you are currently reading this file).
@ -83,15 +89,14 @@ E-mail: christos@astron.com
Phone: Do not even think of telephoning me about this program. Send cash first!
Parts of this software were developed at SoftQuad Inc., 56 Aberfoyle
Cres, # 810, Toronto, Ontario CANADA M8X 2W4. Phone: 416-239-4801 or
800-387-2777. Email: mail@sq.com. Call for information on SGML editing
and browsing, Unix text processing, and customised products on Unix,
DOS and Mac.
Parts of this software were developed at SoftQuad Inc., developers
of SGML/HTML/XML publishing software, in Toronto, Canada.
SoftQuad was swallowed up by Corel in 2002
and does not exist any longer.
From: Kees Zeelenberg
An MS-Windows (Win32) port of File-3.41 is available from
An MS-Windows (Win32) port of File-3.36 is available from
http://gnuwin32.sourceforge.net/
File is an implementation of the Unix File(1) command.
It knows the 'magic number' of several thousands of file types.

View File

@ -252,3 +252,33 @@ AC_DEFUN([AC_FUNC_FSEEKO],
[Define if fseeko (and presumably ftello) exists and is declared.])
fi])
# serial 9
# From Paul Eggert.
# BeOS 5 has <wchar.h> but does not define mbstate_t,
# so you can't declare an object of that type.
# Check for this incompatibility with Standard C.
# Include stdlib.h first, because otherwise this test would fail on Linux
# (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits
# a syntax error in wchar.h due to the use of undefined __int32_t.
AC_DEFUN([AC_MBSTATE_T],
[
AC_CHECK_HEADERS(stdlib.h)
AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
[AC_TRY_COMPILE([
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include <wchar.h>],
[mbstate_t x; return sizeof x;],
ac_cv_type_mbstate_t=yes,
ac_cv_type_mbstate_t=no)])
if test $ac_cv_type_mbstate_t = no; then
AC_DEFINE(mbstate_t, int,
[Define to a type if <wchar.h> does not define.])
fi])

1784
contrib/file/aclocal.m4 vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

170
contrib/file/apptype.c Normal file
View File

@ -0,0 +1,170 @@
/*
* Adapted from: apptype.c, Written by Eberhard Mattes and put into the
* public domain
*
* Notes: 1. Qualify the filename so that DosQueryAppType does not do extraneous
* searches.
*
* 2. DosQueryAppType will return FAPPTYP_DOS on a file ending with ".com"
* (other than an OS/2 exe or Win exe with this name). Eberhard Mattes
* remarks Tue, 6 Apr 93: Moreover, it reports the type of the (new and very
* bug ridden) Win Emacs as "OS/2 executable".
*
* 3. apptype() uses the filename if given, otherwise a tmp file is created with
* the contents of buf. If buf is not the complete file, apptype can
* incorrectly identify the exe type. The "-z" option of "file" is the reason
* for this ugly code.
*/
/*
* amai: Darrel Hankerson did the changes described here.
*
* It remains to check the validity of comments (2.) since it's referred to an
* "old" OS/2 version.
*
*/
#include "file.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef lint
FILE_RCSID("@(#)$Id: apptype.c,v 1.6 2003/11/11 20:01:45 christos Exp $")
#endif /* lint */
#ifdef __EMX__
#include <io.h>
#define INCL_DOSSESMGR
#define INCL_DOSERRORS
#define INCL_DOSFILEMGR
#include <os2.h>
typedef ULONG APPTYPE;
protected int
file_os2_apptype(struct magic_set *ms, const char *fn, const void *buf,
size_t nb)
{
APPTYPE rc, type;
char path[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR],
fname[_MAX_FNAME], ext[_MAX_EXT];
char *filename;
FILE *fp;
if (fn)
filename = strdup(fn);
else if ((filename = tempnam("./", "tmp")) == NULL) {
file_error(ms, errno, "cannot create tempnam");
return -1;
}
/* qualify the filename to prevent extraneous searches */
_splitpath(filename, drive, dir, fname, ext);
(void)sprintf(path, "%s%s%s%s", drive,
(*dir == '\0') ? "./" : dir,
fname,
(*ext == '\0') ? "." : ext);
if (fn == NULL) {
if ((fp = fopen(path, "wb")) == NULL) {
file_error(ms, errno, "cannot open tmp file `%s'", path);
return -1;
}
if (fwrite(buf, 1, nb, fp) != nb) {
file_error(ms, errno, "cannot write tmp file `%s'",
path);
return -1;
}
(void)fclose(fp);
}
rc = DosQueryAppType(path, &type);
if (fn == NULL) {
unlink(path);
free(filename);
}
#if 0
if (rc == ERROR_INVALID_EXE_SIGNATURE)
printf("%s: not an executable file\n", fname);
else if (rc == ERROR_FILE_NOT_FOUND)
printf("%s: not found\n", fname);
else if (rc == ERROR_ACCESS_DENIED)
printf("%s: access denied\n", fname);
else if (rc != 0)
printf("%s: error code = %lu\n", fname, rc);
else
#else
/*
* for our purpose here it's sufficient to just ignore the error and
* return w/o success (=0)
*/
if (rc)
return (0);
#endif
if (type & FAPPTYP_32BIT)
if (file_printf(ms, "32-bit ") == -1)
return -1;
if (type & FAPPTYP_PHYSDRV) {
if (file_printf(ms, "physical device driver") == -1)
return -1;
} else if (type & FAPPTYP_VIRTDRV) {
if (file_printf(ms, "virtual device driver") == -1)
return -1;
} else if (type & FAPPTYP_DLL) {
if (type & FAPPTYP_PROTDLL)
if (file_printf(ms, "protected ") == -1)
return -1;
if (file_printf(ms, "DLL") == -1)
return -1;
} else if (type & (FAPPTYP_WINDOWSREAL | FAPPTYP_WINDOWSPROT)) {
if (file_printf(ms, "Windows executable") == -1)
return -1;
} else if (type & FAPPTYP_DOS) {
/*
* The API routine is partially broken on filenames ending
* ".com".
*/
if (stricmp(ext, ".com") == 0)
if (strncmp((const char *)buf, "MZ", 2))
return (0);
if (file_printf(ms, "DOS executable") == -1)
return -1;
/* ---------------------------------------- */
/* Might learn more from the magic(4) entry */
if (file_printf(ms, ", magic(4)-> ") == -1)
return -1;
return (0);
/* ---------------------------------------- */
} else if (type & FAPPTYP_BOUND) {
if (file_printf(ms, "bound executable") == -1)
return -1;
} else if ((type & 7) == FAPPTYP_WINDOWAPI) {
if (file_printf(ms, "PM executable") == -1)
return -1;
} else if (file_printf(ms, "OS/2 executable") == -1)
return -1;
switch (type & (FAPPTYP_NOTWINDOWCOMPAT |
FAPPTYP_WINDOWCOMPAT |
FAPPTYP_WINDOWAPI)) {
case FAPPTYP_NOTWINDOWCOMPAT:
if (file_printf(ms, " [NOTWINDOWCOMPAT]") == -1)
return -1;
break;
case FAPPTYP_WINDOWCOMPAT:
if (file_printf(ms, " [WINDOWCOMPAT]") == -1)
return -1;
break;
case FAPPTYP_WINDOWAPI:
if (file_printf(ms, " [WINDOWAPI]") == -1)
return -1;
break;
}
return 1;
}
#endif

View File

@ -1,10 +1,39 @@
/*
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Ian F. Darwin and others.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* ASCII magic -- file types that we know based on keywords
* that can appear anywhere in the file.
*
* Copyright (c) Ian F. Darwin, 1987.
* Written by Ian F. Darwin.
*
* Extensively modified by Eric Fischer <enf@pobox.com> in July, 2000,
* to handle character codes other than ASCII on a unified basis.
*
@ -12,29 +41,9 @@
* international characters, now subsumed into this file.
*/
/*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
*
* 1. The author is not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
*
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
*
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
*
* 4. This notice may not be removed or altered.
*/
#include "file.h"
#include "magic.h"
#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <ctype.h>
@ -45,7 +54,7 @@
#include "names.h"
#ifndef lint
FILE_RCSID("@(#)$Id: ascmagic.c,v 1.33 2003/02/08 18:33:53 christos Exp $")
FILE_RCSID("@(#)$Id: ascmagic.c,v 1.40 2003/11/20 00:25:39 christos Exp $")
#endif /* lint */
typedef unsigned long unichar;
@ -54,29 +63,29 @@ typedef unsigned long unichar;
#define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \
|| (x) == 0x85 || (x) == '\f')
static int looks_ascii(const unsigned char *, int, unichar *, int *);
static int looks_utf8(const unsigned char *, int, unichar *, int *);
static int looks_unicode(const unsigned char *, int, unichar *, int *);
static int looks_latin1(const unsigned char *, int, unichar *, int *);
static int looks_extended(const unsigned char *, int, unichar *, int *);
static void from_ebcdic(const unsigned char *, int, unsigned char *);
static int ascmatch(const unsigned char *, const unichar *, int);
private int looks_ascii(const unsigned char *, size_t, unichar *, size_t *);
private int looks_utf8(const unsigned char *, size_t, unichar *, size_t *);
private int looks_unicode(const unsigned char *, size_t, unichar *, size_t *);
private int looks_latin1(const unsigned char *, size_t, unichar *, size_t *);
private int looks_extended(const unsigned char *, size_t, unichar *, size_t *);
private void from_ebcdic(const unsigned char *, size_t, unsigned char *);
private int ascmatch(const unsigned char *, const unichar *, size_t);
/* int nbytes: size actually read */
int
ascmagic(unsigned char *buf, int nbytes)
protected int
file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
{
int i;
size_t i;
unsigned char nbuf[HOWMANY+1]; /* one extra for terminating '\0' */
unichar ubuf[HOWMANY+1]; /* one extra for terminating '\0' */
int ulen;
size_t ulen;
struct names *p;
char *code = NULL;
char *code_mime = NULL;
char *type = NULL;
char *subtype = NULL;
char *subtype_mime = NULL;
const char *code = NULL;
const char *code_mime = NULL;
const char *type = NULL;
const char *subtype = NULL;
const char *subtype_mime = NULL;
int has_escapes = 0;
int has_backspace = 0;
@ -89,20 +98,6 @@ ascmagic(unsigned char *buf, int nbytes)
int last_line_end = -1;
int has_long_lines = 0;
/*
* Do the tar test first, because if the first file in the tar
* archive starts with a dot, we can confuse it with an nroff file.
*/
switch (is_tar(buf, nbytes)) {
case 1:
ckfputs(iflag ? "application/x-tar" : "tar archive", stdout);
return 1;
case 2:
ckfputs(iflag ? "application/x-tar, POSIX"
: "POSIX tar archive", stdout);
return 1;
}
/*
* Undo the NUL-termination kindly provided by process()
* but leave at least one byte to look at
@ -111,6 +106,10 @@ ascmagic(unsigned char *buf, int nbytes)
while (nbytes > 1 && buf[nbytes - 1] == '\0')
nbytes--;
/* nbuf and ubuf relies on this */
if (nbytes > HOWMANY)
nbytes = HOWMANY;
/*
* Then try to determine whether it's any character code we can
* identify. Each of these tests, if it succeeds, will leave
@ -125,7 +124,7 @@ ascmagic(unsigned char *buf, int nbytes)
code = "UTF-8 Unicode";
code_mime = "utf-8";
type = "text";
} else if ((i = looks_unicode(buf, nbytes, ubuf, &ulen))) {
} else if ((i = looks_unicode(buf, nbytes, ubuf, &ulen)) != 0) {
if (i == 1)
code = "Little-endian UTF-16 Unicode";
else
@ -171,8 +170,10 @@ ascmagic(unsigned char *buf, int nbytes)
while (ISSPC(*tp))
++tp; /* skip leading whitespace */
if ((tp[0] == '\\' && tp[1] == '\"') ||
(isascii(tp[0]) && isalnum(tp[0]) &&
isascii(tp[1]) && isalnum(tp[1]) &&
(isascii((unsigned char)tp[0]) &&
isalnum((unsigned char)tp[0]) &&
isascii((unsigned char)tp[1]) &&
isalnum((unsigned char)tp[1]) &&
ISSPC(tp[2]))) {
subtype_mime = "text/troff";
subtype = "troff or preprocessor input";
@ -190,7 +191,7 @@ ascmagic(unsigned char *buf, int nbytes)
i = 0;
while (i < ulen) {
int end;
size_t end;
/*
* skip past any leading space
@ -211,7 +212,7 @@ ascmagic(unsigned char *buf, int nbytes)
* compare the word thus isolated against the token list
*/
for (p = names; p < names + NNAMES; p++) {
if (ascmatch((unsigned char *)p->name, ubuf + i,
if (ascmatch((const unsigned char *)p->name, ubuf + i,
end - i)) {
subtype = types[p->type].human;
subtype_mime = types[p->type].mime;
@ -244,7 +245,7 @@ ascmagic(unsigned char *buf, int nbytes)
n_cr++;
last_line_end = i;
}
if (ubuf[i] == '\n' && (i - 1 < 0 || ubuf[i - 1] != '\r')) {
if (ubuf[i] == '\n' && ((int)i - 1 < 0 || ubuf[i - 1] != '\r')){
n_lf++;
last_line_end = i;
}
@ -254,29 +255,40 @@ ascmagic(unsigned char *buf, int nbytes)
}
}
if (iflag) {
if (subtype_mime)
ckfputs(subtype_mime, stdout);
else
ckfputs("text/plain", stdout);
if ((ms->flags & MAGIC_MIME)) {
if (subtype_mime) {
if (file_printf(ms, subtype_mime) == -1)
return -1;
} else {
if (file_printf(ms, "text/plain") == -1)
return -1;
}
if (code_mime) {
ckfputs("; charset=", stdout);
ckfputs(code_mime, stdout);
if (file_printf(ms, "; charset=") == -1)
return -1;
if (file_printf(ms, code_mime) == -1)
return -1;
}
} else {
ckfputs(code, stdout);
if (file_printf(ms, code) == -1)
return -1;
if (subtype) {
ckfputs(" ", stdout);
ckfputs(subtype, stdout);
if (file_printf(ms, " ") == -1)
return -1;
if (file_printf(ms, subtype) == -1)
return -1;
}
ckfputs(" ", stdout);
ckfputs(type, stdout);
if (file_printf(ms, " ") == -1)
return -1;
if (file_printf(ms, type) == -1)
return -1;
if (has_long_lines)
ckfputs(", with very long lines", stdout);
if (file_printf(ms, ", with very long lines") == -1)
return -1;
/*
* Only report line terminators if we find one other than LF,
@ -284,44 +296,56 @@ ascmagic(unsigned char *buf, int nbytes)
*/
if ((n_crlf == 0 && n_cr == 0 && n_nel == 0 && n_lf == 0) ||
(n_crlf != 0 || n_cr != 0 || n_nel != 0)) {
ckfputs(", with", stdout);
if (file_printf(ms, ", with") == -1)
return -1;
if (n_crlf == 0 && n_cr == 0 && n_nel == 0 && n_lf == 0)
ckfputs(" no", stdout);
else {
if (n_crlf == 0 && n_cr == 0 && n_nel == 0 && n_lf == 0) {
if (file_printf(ms, " no") == -1)
return -1;
} else {
if (n_crlf) {
ckfputs(" CRLF", stdout);
if (file_printf(ms, " CRLF") == -1)
return -1;
if (n_cr || n_lf || n_nel)
ckfputs(",", stdout);
if (file_printf(ms, ",") == -1)
return -1;
}
if (n_cr) {
ckfputs(" CR", stdout);
if (file_printf(ms, " CR") == -1)
return -1;
if (n_lf || n_nel)
ckfputs(",", stdout);
if (file_printf(ms, ",") == -1)
return -1;
}
if (n_lf) {
ckfputs(" LF", stdout);
if (file_printf(ms, " LF") == -1)
return -1;
if (n_nel)
ckfputs(",", stdout);
if (file_printf(ms, ",") == -1)
return -1;
}
if (n_nel)
ckfputs(" NEL", stdout);
if (file_printf(ms, " NEL") == -1)
return -1;
}
ckfputs(" line terminators", stdout);
if (file_printf(ms, " line terminators") == -1)
return -1;
}
if (has_escapes)
ckfputs(", with escape sequences", stdout);
if (file_printf(ms, ", with escape sequences") == -1)
return -1;
if (has_backspace)
ckfputs(", with overstriking", stdout);
if (file_printf(ms, ", with overstriking") == -1)
return -1;
}
return 1;
}
static int
ascmatch(const unsigned char *s, const unichar *us, int ulen)
private int
ascmatch(const unsigned char *s, const unichar *us, size_t ulen)
{
size_t i;
@ -393,7 +417,7 @@ ascmatch(const unsigned char *s, const unichar *us, int ulen)
#define I 2 /* character appears in ISO-8859 text */
#define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */
static char text_chars[256] = {
private char text_chars[256] = {
/* BEL BS HT LF FF CR */
F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */
/* ESC */
@ -415,8 +439,9 @@ static char text_chars[256] = {
I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */
};
static int
looks_ascii(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
private int
looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf,
size_t *ulen)
{
int i;
@ -434,8 +459,8 @@ looks_ascii(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
return 1;
}
static int
looks_latin1(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
private int
looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
{
int i;
@ -453,8 +478,9 @@ looks_latin1(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
return 1;
}
static int
looks_extended(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
private int
looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf,
size_t *ulen)
{
int i;
@ -472,8 +498,8 @@ looks_extended(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
return 1;
}
int
looks_utf8(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
private int
looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
{
int i, n;
unichar c;
@ -534,8 +560,9 @@ looks_utf8(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
return gotone; /* don't claim it's UTF-8 if it's all 7-bit */
}
static int
looks_unicode(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
private int
looks_unicode(const unsigned char *buf, size_t nbytes, unichar *ubuf,
size_t *ulen)
{
int bigend;
int i;
@ -562,7 +589,8 @@ looks_unicode(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
if (ubuf[*ulen - 1] == 0xfffe)
return 0;
if (ubuf[*ulen - 1] < 128 && text_chars[ubuf[*ulen - 1]] != T)
if (ubuf[*ulen - 1] < 128 &&
text_chars[(size_t)ubuf[*ulen - 1]] != T)
return 0;
}
@ -596,7 +624,7 @@ looks_unicode(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
* between old-style and internationalized examples of text.
*/
unsigned char ebcdic_to_ascii[] = {
private unsigned char ebcdic_to_ascii[] = {
0, 1, 2, 3, 156, 9, 134, 127, 151, 141, 142, 11, 12, 13, 14, 15,
16, 17, 18, 19, 157, 133, 8, 135, 24, 25, 146, 143, 28, 29, 30, 31,
128, 129, 130, 131, 132, 10, 23, 27, 136, 137, 138, 139, 140, 5, 6, 7,
@ -615,6 +643,7 @@ unsigned char ebcdic_to_ascii[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 250, 251, 252, 253, 254, 255
};
#ifdef notdef
/*
* The following EBCDIC-to-ASCII table may relate more closely to reality,
* or at least to modern reality. It comes from
@ -629,7 +658,7 @@ unsigned char ebcdic_to_ascii[] = {
* cases for the NEL character can be taken out of the code.
*/
unsigned char ebcdic_1047_to_8859[] = {
private unsigned char ebcdic_1047_to_8859[] = {
0x00,0x01,0x02,0x03,0x9C,0x09,0x86,0x7F,0x97,0x8D,0x8E,0x0B,0x0C,0x0D,0x0E,0x0F,
0x10,0x11,0x12,0x13,0x9D,0x0A,0x08,0x87,0x18,0x19,0x92,0x8F,0x1C,0x1D,0x1E,0x1F,
0x80,0x81,0x82,0x83,0x84,0x85,0x17,0x1B,0x88,0x89,0x8A,0x8B,0x8C,0x05,0x06,0x07,
@ -647,12 +676,13 @@ unsigned char ebcdic_1047_to_8859[] = {
0x5C,0xF7,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0xB2,0xD4,0xD6,0xD2,0xD3,0xD5,
0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0xB3,0xDB,0xDC,0xD9,0xDA,0x9F
};
#endif
/*
* Copy buf[0 ... nbytes-1] into out[], translating EBCDIC to ASCII.
*/
static void
from_ebcdic(const unsigned char *buf, int nbytes, unsigned char *out)
private void
from_ebcdic(const unsigned char *buf, size_t nbytes, unsigned char *out)
{
int i;

View File

@ -1,3 +1,35 @@
/*
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Ian F. Darwin and others.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* compress routines:
* zmagic() - returns 0 if not recognized, uncompresses and prints
@ -6,11 +38,15 @@
* using method, return sizeof new
*/
#include "file.h"
#include "magic.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
@ -19,15 +55,15 @@
#endif
#ifndef lint
FILE_RCSID("@(#)$Id: compress.c,v 1.25 2002/07/03 18:26:37 christos Exp $")
FILE_RCSID("@(#)$Id: compress.c,v 1.37 2004/07/24 21:00:56 christos Exp $")
#endif
static struct {
private struct {
const char *magic;
int maglen;
size_t maglen;
const char *const argv[3];
int silent;
int silent;
} compr[] = {
{ "\037\235", 2, { "gzip", "-cdq", NULL }, 1 }, /* compressed */
/* Uncompress can get stuck; so use gzip first if we have it
@ -41,47 +77,58 @@ static struct {
{ "BZh", 3, { "bzip2", "-cd", NULL }, 1 }, /* bzip2-ed */
};
static int ncompr = sizeof(compr) / sizeof(compr[0]);
private int ncompr = sizeof(compr) / sizeof(compr[0]);
static int swrite(int, const void *, size_t);
static int sread(int, void *, size_t);
static int uncompressbuf(int, const unsigned char *, unsigned char **, int);
private ssize_t swrite(int, const void *, size_t);
private ssize_t sread(int, void *, size_t);
private size_t uncompressbuf(struct magic_set *, size_t, const unsigned char *,
unsigned char **, size_t);
#ifdef HAVE_LIBZ
static int uncompressgzipped(const unsigned char *, unsigned char **, int);
private size_t uncompressgzipped(struct magic_set *, const unsigned char *,
unsigned char **, size_t);
#endif
int
zmagic(const char *fname, unsigned char *buf, int nbytes)
protected int
file_zmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
{
unsigned char *newbuf;
int newsize;
int i;
unsigned char *newbuf = NULL;
size_t i, nsz;
int rv = 0;
if ((ms->flags & MAGIC_COMPRESS) == 0)
return 0;
for (i = 0; i < ncompr; i++) {
if (nbytes < compr[i].maglen)
continue;
if (memcmp(buf, compr[i].magic, compr[i].maglen) == 0 &&
(newsize = uncompressbuf(i, buf, &newbuf, nbytes)) != 0) {
tryit(fname, newbuf, newsize, 1);
free(newbuf);
printf(" (");
tryit(fname, buf, nbytes, 0);
printf(")");
return 1;
(nsz = uncompressbuf(ms, i, buf, &newbuf, nbytes)) != 0) {
ms->flags &= ~MAGIC_COMPRESS;
rv = -1;
if (file_buffer(ms, newbuf, nsz) == -1)
goto error;
if (file_printf(ms, " (") == -1)
goto error;
if (file_buffer(ms, buf, nbytes) == -1)
goto error;
if (file_printf(ms, ")") == -1)
goto error;
rv = 1;
break;
}
}
if (i == ncompr)
return 0;
return 1;
error:
if (newbuf)
free(newbuf);
ms->flags |= MAGIC_COMPRESS;
return rv;
}
/*
* `safe' write for sockets and pipes.
*/
static int
private ssize_t
swrite(int fd, const void *buf, size_t n)
{
int rv;
@ -106,7 +153,7 @@ swrite(int fd, const void *buf, size_t n)
/*
* `safe' read for sockets and pipes.
*/
static int
private ssize_t
sread(int fd, void *buf, size_t n)
{
int rv;
@ -129,8 +176,9 @@ sread(int fd, void *buf, size_t n)
return rn;
}
int
pipe2file(int fd, void *startbuf, size_t nbytes)
protected int
file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
size_t nbytes)
{
char buf[4096];
int r, tfd;
@ -151,30 +199,28 @@ pipe2file(int fd, void *startbuf, size_t nbytes)
errno = r;
#endif
if (tfd == -1) {
error("Can't create temporary file for pipe copy (%s)\n",
strerror(errno));
/*NOTREACHED*/
file_error(ms, errno,
"cannot create temporary file for pipe copy");
return -1;
}
if (swrite(tfd, startbuf, nbytes) != nbytes)
if (swrite(tfd, startbuf, nbytes) != (ssize_t)nbytes)
r = 1;
else {
while ((r = sread(fd, buf, sizeof(buf))) > 0)
if (swrite(tfd, buf, r) != r)
if (swrite(tfd, buf, (size_t)r) != r)
break;
}
switch (r) {
case -1:
error("Error copying from pipe to temp file (%s)\n",
strerror(errno));
/*NOTREACHED*/
file_error(ms, errno, "error copying from pipe to temp file");
return -1;
case 0:
break;
default:
error("Error while writing to temp file (%s)\n",
strerror(errno));
/*NOTREACHED*/
file_error(ms, errno, "error while writing to temp file");
return -1;
}
/*
@ -183,14 +229,13 @@ pipe2file(int fd, void *startbuf, size_t nbytes)
* can still access the phantom inode.
*/
if ((fd = dup2(tfd, fd)) == -1) {
error("Couldn't dup destcriptor for temp file(%s)\n",
strerror(errno));
/*NOTREACHED*/
file_error(ms, errno, "could not dup descriptor for temp file");
return -1;
}
(void)close(tfd);
if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
error("Couldn't seek on temp file (%s)\n", strerror(errno));
/*NOTREACHED*/
file_badseek(ms);
return -1;
}
return fd;
}
@ -202,34 +247,42 @@ pipe2file(int fd, void *startbuf, size_t nbytes)
#define FNAME (1 << 3)
#define FCOMMENT (1 << 4)
static int
uncompressgzipped(const unsigned char *old, unsigned char **newch, int n)
private size_t
uncompressgzipped(struct magic_set *ms, const unsigned char *old,
unsigned char **newch, size_t n)
{
unsigned char flg = old[3];
int data_start = 10;
size_t data_start = 10;
z_stream z;
int rc;
if (flg & FEXTRA)
if (flg & FEXTRA) {
if (data_start+1 >= n)
return 0;
data_start += 2 + old[data_start] + old[data_start + 1] * 256;
}
if (flg & FNAME) {
while(old[data_start])
while(data_start < n && old[data_start])
data_start++;
data_start++;
}
if(flg & FCOMMENT) {
while(old[data_start])
while(data_start < n && old[data_start])
data_start++;
data_start++;
}
if(flg & FHCRC)
data_start += 2;
if (data_start >= n)
return 0;
if ((*newch = (unsigned char *)malloc(HOWMANY + 1)) == NULL) {
return 0;
}
z.next_in = (Bytef *)(old + data_start);
/* XXX: const castaway, via strchr */
z.next_in = (Bytef *)strchr((const char *)old + data_start,
old[data_start]);
z.avail_in = n - data_start;
z.next_out = *newch;
z.avail_out = HOWMANY;
@ -239,17 +292,17 @@ uncompressgzipped(const unsigned char *old, unsigned char **newch, int n)
rc = inflateInit2(&z, -15);
if (rc != Z_OK) {
(void) fprintf(stderr,"%s: zlib: %s\n", progname, z.msg);
file_error(ms, 0, "zlib: %s", z.msg);
return 0;
}
rc = inflate(&z, Z_SYNC_FLUSH);
if (rc != Z_OK && rc != Z_STREAM_END) {
fprintf(stderr,"%s: zlib: %s\n", progname, z.msg);
file_error(ms, 0, "zlib: %s", z.msg);
return 0;
}
n = z.total_out;
n = (size_t)z.total_out;
inflateEnd(&z);
/* let's keep the nul-terminate tradition */
@ -259,23 +312,24 @@ uncompressgzipped(const unsigned char *old, unsigned char **newch, int n)
}
#endif
static int
uncompressbuf(int method, const unsigned char *old, unsigned char **newch,
int n)
private size_t
uncompressbuf(struct magic_set *ms, size_t method, const unsigned char *old,
unsigned char **newch, size_t n)
{
int fdin[2], fdout[2];
int r;
/* The buffer is NUL terminated, and we don't need that. */
n--;
#ifdef HAVE_LIBZ
if (method == 2)
return uncompressgzipped(old,newch,n);
return uncompressgzipped(ms, old, newch, n);
#endif
if (pipe(fdin) == -1 || pipe(fdout) == -1) {
error("cannot create pipe (%s).\n", strerror(errno));
/*NOTREACHED*/
file_error(ms, errno, "cannot create pipe");
return 0;
}
switch (fork()) {
case 0: /* child */
@ -296,15 +350,27 @@ uncompressbuf(int method, const unsigned char *old, unsigned char **newch,
exit(1);
/*NOTREACHED*/
case -1:
error("could not fork (%s).\n", strerror(errno));
/*NOTREACHED*/
file_error(ms, errno, "could not fork");
return 0;
default: /* parent */
(void) close(fdin[0]);
(void) close(fdout[1]);
if (swrite(fdin[1], old, n) != n) {
n = 0;
goto err;
/* fork again, to avoid blocking because both pipes filled */
switch (fork()) {
case 0: /* child */
(void)close(fdout[0]);
if (swrite(fdin[1], old, n) != n)
exit(1);
exit(0);
/*NOTREACHED*/
case -1:
exit(1);
/*NOTREACHED*/
default: /* parent */
break;
}
(void) close(fdin[1]);
fdin[1] = -1;
@ -312,10 +378,13 @@ uncompressbuf(int method, const unsigned char *old, unsigned char **newch,
n = 0;
goto err;
}
if ((n = sread(fdout[0], *newch, HOWMANY)) <= 0) {
if ((r = sread(fdout[0], *newch, HOWMANY)) <= 0) {
free(*newch);
n = 0;
newch[0] = '\0';
goto err;
} else {
n = r;
}
/* NUL terminate, as every buffer is handled here. */
(*newch)[n++] = '\0';
@ -323,7 +392,12 @@ uncompressbuf(int method, const unsigned char *old, unsigned char **newch,
if (fdin[1] != -1)
(void) close(fdin[1]);
(void) close(fdout[0]);
(void) wait(NULL);
#ifdef WNOHANG
while (waitpid(-1, NULL, WNOHANG) != -1)
continue;
#else
(void)wait(NULL);
#endif
return n;
}
}

View File

@ -1,31 +1,9 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* config.h.in. Generated from configure.in by autoheader. */
/* Autoheader needs me */
#undef PACKAGE
/* Define to empty if the keyword does not work. */
#undef const
/* Define if your struct stat has st_rdev. */
#undef HAVE_ST_RDEV
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define if major, minor, and makedev are declared in <mkdev.h>. */
#undef MAJOR_IN_MKDEV
/* Define if major, minor, and makedev are declared in <sysmacros.h>. */
#undef MAJOR_IN_SYSMACROS
/* Define to `long' if <sys/types.h> doesn't define. */
#undef off_t
/* Define to `unsigned' if <sys/types.h> doesn't define. */
#undef size_t
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define if your <sys/time.h> declares struct tm. */
#undef TM_IN_SYS_TIME
/* Autoheader needs me */
#undef VERSION
/* Define if builtin ELF support is enabled. */
#undef BUILTIN_ELF
@ -36,12 +14,21 @@
/* Define if the `long long' type works. */
#undef HAVE_LONG_LONG
/* Define if we have "tm_zone" in "struct tm". */
#undef HAVE_TM_ZONE
/* Define if we have a global "char * []" "tzname" variable. */
#undef HAVE_TZNAME
/* Define if we have "tm_isdst" in "struct tm". */
#undef HAVE_TM_ISDST
/* Define if we have a global "int" variable "daylight". */
#undef HAVE_DAYLIGHT
/* Define if we have a mkstemp */
#undef HAVE_MKSTEMP
/* Define to `unsigned char' if standard headers don't define. */
#undef uint8_t
@ -58,6 +45,9 @@
/* Define to `int' if standard headers don't define. */
#undef int32_t
/* FIXME: These have to be added manually because autoheader doesn't know
about AC_CHECK_SIZEOF_INCLUDES. */
/* The number of bytes in a uint8_t. */
#define SIZEOF_UINT8_T 0
@ -70,56 +60,75 @@
/* The number of bytes in a uint64_t. */
#define SIZEOF_UINT64_T 0
/* Define if you have the getopt_long function. */
#undef HAVE_GETOPT_LONG
/* Define if you have the mkstemp function. */
#undef HAVE_MKSTEMP
/* Define if you have the mmap function. */
#undef HAVE_MMAP
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
/* Define if you have the strtoul function. */
#undef HAVE_STRTOUL
/* Define if you have the <fcntl.h> header file. */
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the <getopt.h> header file. */
/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
/* Define if you have the <inttypes.h> header file. */
/* Define to 1 if you have the `getopt_long' function. */
#undef HAVE_GETOPT_LONG
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
/* Define if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define if you have the z library (-lz). */
/* Define to 1 if you have the `z' library (-lz). */
#undef HAVE_LIBZ
/* Name of package */
#undef PACKAGE
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Version number of package */
#undef VERSION
/* Define to 1 if you have the `mbrtowc' function. */
#undef HAVE_MBRTOWC
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `mkstemp' function. */
#undef HAVE_MKSTEMP
/* Define to 1 if you have the `mmap' function. */
#undef HAVE_MMAP
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strtoul' function. */
#undef HAVE_STRTOUL
/* Define to 1 if `st_rdev' is member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_RDEV
/* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use
`HAVE_STRUCT_STAT_ST_RDEV' instead. */
#undef HAVE_ST_RDEV
/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <sys/utime.h> header file. */
#undef HAVE_SYS_UTIME_H
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* HAVE_TM_ZONE */
#undef HAVE_TM_ZONE
@ -127,9 +136,73 @@
/* HAVE_TZNAME */
#undef HAVE_TZNAME
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `utime' function. */
#undef HAVE_UTIME
/* Define to 1 if you have the `utimes' function. */
#undef HAVE_UTIMES
/* Define to 1 if you have the <utime.h> header file. */
#undef HAVE_UTIME_H
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
/* Define to 1 if you have the `wcwidth' function. */
#undef HAVE_WCWIDTH
/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
*/
#undef MAJOR_IN_MKDEV
/* Define to 1 if `major', `minor', and `makedev' are declared in
<sysmacros.h>. */
#undef MAJOR_IN_SYSMACROS
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
/* Version number of package */
#undef VERSION
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to a type if <wchar.h> does not define. */
#undef mbstate_t
/* Define to `long' if <sys/types.h> does not define. */
#undef off_t
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t

10033
contrib/file/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,8 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(file.c)
AM_INIT_AUTOMAKE(file, 3.41)
AC_INIT(src/file.c)
AM_INIT_AUTOMAKE(file, 4.10)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
AC_MSG_CHECKING(for builtin ELF support)
AC_ARG_ENABLE(elf,
@ -52,6 +53,7 @@ dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_LIBTOOL
dnl Checks for headers
AC_HEADER_STDC
@ -64,6 +66,9 @@ AC_CHECK_HEADERS(stdint.h inttypes.h)
AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(getopt.h)
AC_CHECK_HEADERS(locale.h)
AC_CHECK_HEADERS(utime.h)
AC_CHECK_HEADERS(sys/utime.h)
AC_CHECK_HEADERS(wchar.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@ -72,6 +77,7 @@ AC_TYPE_SIZE_T
AC_STRUCT_ST_RDEV
AC_STRUCT_TIMEZONE_DAYLIGHT
AC_SYS_LARGEFILE
AC_MBSTATE_T
AC_CHECK_TYPE_STDC(uint8_t, unsigned char)
AC_CHECK_TYPE_STDC(uint16_t, unsigned short)
@ -92,9 +98,9 @@ AC_CHECK_SIZEOF_STDC_HEADERS(uint32_t, 0)
AC_CHECK_SIZEOF_STDC_HEADERS(uint64_t, 0)
dnl Checks for functions
AC_CHECK_FUNCS(mmap strerror strtoul mkstemp getopt_long)
AC_CHECK_FUNCS(mmap strerror strtoul mbrtowc mkstemp getopt_long utimes utime wcwidth)
dnl Checks for libraries
AC_CHECK_LIB(z,gzopen)
AC_OUTPUT(Makefile)
AC_OUTPUT(Makefile src/Makefile magic/Makefile doc/Makefile)

View File

@ -1,35 +1,49 @@
/*
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Ian F. Darwin and others.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* file - find type of a file or files - main program.
*
* Copyright (c) Ian F. Darwin, 1987.
* Written by Ian F. Darwin.
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
*
* 1. The author is not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
*
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
*
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
*
* 4. This notice may not be removed or altered.
*/
#include "file.h"
#include "magic.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/param.h> /* for MAXPATHLEN */
#include <sys/stat.h>
#include <fcntl.h> /* for open() */
#ifdef RESTORE_TIME
# if (__COHERENT__ >= 0x420)
@ -48,9 +62,14 @@
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h> /* for long options (is this portable?)*/
#else
#undef HAVE_GETOPT_LONG
#endif
#include <netinet/in.h> /* for byte swapping */
@ -58,80 +77,65 @@
#include "patchlevel.h"
#ifndef lint
FILE_RCSID("@(#)$Id: file.c,v 1.69 2003/02/27 20:47:46 christos Exp $")
FILE_RCSID("@(#)$Id: file.c,v 1.93 2004/04/07 14:23:55 christos Exp $")
#endif /* lint */
#ifdef S_IFLNK
# define USAGE "Usage: %s [-bciknsvzL] [-f namefile] [-m magicfiles] file...\n"
#define SYMLINKFLAG "L"
#else
# define USAGE "Usage: %s [-bciknsvz] [-f namefile] [-m magicfiles] file...\n"
#define SYMLINKFLAG ""
#endif
#ifdef __EMX__
static char *apptypeName = NULL;
int os2_apptype (const char *fn, char *buf, int nb);
#endif /* __EMX__ */
#ifndef MAGIC
# define MAGIC "/etc/magic"
#endif
# define USAGE "Usage: %s [-bcik" SYMLINKFLAG "nNsvz] [-f namefile] [-F separator] [-m magicfiles] file...\n %s -C -m magicfiles\n"
#ifndef MAXPATHLEN
#define MAXPATHLEN 512
#endif
int /* Global command-line options */
debug = 0, /* debugging */
lflag = 0, /* follow Symlinks (BSD only) */
private int /* Global command-line options */
bflag = 0, /* brief output format */
zflag = 0, /* follow (uncompress) compressed files */
sflag = 0, /* read block special files */
iflag = 0,
nopad = 0, /* Don't pad output */
nobuffer = 0, /* Do not buffer stdout */
kflag = 0; /* Keep going after the first match */
nobuffer = 0; /* Do not buffer stdout */
int /* Misc globals */
nmagic = 0; /* number of valid magic[]s */
private const char *magicfile = 0; /* where the magic is */
private const char *default_magicfile = MAGIC;
private char *separator = ":"; /* Default field separator */
struct magic *magic; /* array of magic entries */
private char *progname; /* used throughout */
const char *magicfile = 0; /* where the magic is */
const char *default_magicfile = MAGIC;
private struct magic_set *magic;
char separator = ':'; /* Default field separator */
char *progname; /* used throughout */
int lineno; /* line number in the magic file */
static void unwrap(char *fn);
static void usage(void);
private void unwrap(char *);
private void usage(void);
#ifdef HAVE_GETOPT_LONG
static void help(void);
private void help(void);
#endif
#if 0
static int byteconv4(int, int, int);
static short byteconv2(int, int, int);
private int byteconv4(int, int, int);
private short byteconv2(int, int, int);
#endif
int main(int, char *[]);
private void process(const char *, int);
private void load(const char *, int);
/*
* main - parse arguments and handle options
*/
int
main(int argc, char **argv)
main(int argc, char *argv[])
{
int c;
int action = 0, didsomefiles = 0, errflg = 0, ret = 0, app = 0;
char *mime, *home, *usermagic;
int action = 0, didsomefiles = 0, errflg = 0;
int flags = 0;
char *home, *usermagic;
struct stat sb;
#define OPTSTRING "bcdf:F:ikm:nNsvzCL"
#define OPTSTRING "bcCdf:F:ikLm:nNprsvz"
#ifdef HAVE_GETOPT_LONG
int longindex;
static struct option long_options[] =
private struct option long_options[] =
{
{"version", 0, 0, 'v'},
{"help", 0, 0, 0},
@ -146,7 +150,11 @@ main(int argc, char **argv)
{"dereference", 0, 0, 'L'},
#endif
{"magic-file", 1, 0, 'm'},
#if defined(HAVE_UTIME) || defined(HAVE_UTIMES)
{"preserve-date", 0, 0, 'p'},
#endif
{"uncompress", 0, 0, 'z'},
{"raw", 0, 0, 'r'},
{"no-buffer", 0, 0, 'n'},
{"no-pad", 0, 0, 'N'},
{"special-files", 0, 0, 's'},
@ -201,37 +209,29 @@ main(int argc, char **argv)
++bflag;
break;
case 'c':
action = CHECK;
action = FILE_CHECK;
break;
case 'C':
action = COMPILE;
action = FILE_COMPILE;
break;
case 'd':
++debug;
flags |= MAGIC_DEBUG|MAGIC_CHECK;
break;
case 'f':
if (!app) {
ret = apprentice(magicfile, action);
if (action)
exit(ret);
app = 1;
}
if(action)
usage();
load(magicfile, flags);
unwrap(optarg);
++didsomefiles;
break;
case 'F':
separator = *optarg;
separator = optarg;
break;
case 'i':
iflag++;
if ((mime = malloc(strlen(magicfile) + 6)) != NULL) {
(void)strcpy(mime, magicfile);
(void)strcat(mime, ".mime");
magicfile = mime;
}
flags |= MAGIC_MIME;
break;
case 'k':
kflag = 1;
flags |= MAGIC_CONTINUE;
break;
case 'm':
magicfile = optarg;
@ -242,21 +242,29 @@ main(int argc, char **argv)
case 'N':
++nopad;
break;
#if defined(HAVE_UTIME) || defined(HAVE_UTIMES)
case 'p':
flags |= MAGIC_PRESERVE_ATIME;
break;
#endif
case 'r':
flags |= MAGIC_RAW;
break;
case 's':
sflag++;
flags |= MAGIC_DEVICES;
break;
case 'v':
(void) fprintf(stdout, "%s-%d.%d\n", progname,
(void) fprintf(stdout, "%s-%d.%.2d\n", progname,
FILE_VERSION_MAJOR, patchlevel);
(void) fprintf(stdout, "magic file from %s\n",
magicfile);
return 1;
case 'z':
zflag++;
flags |= MAGIC_COMPRESS;
break;
#ifdef S_IFLNK
case 'L':
++lflag;
flags |= MAGIC_SYMLINK;
break;
#endif
case '?':
@ -269,11 +277,26 @@ main(int argc, char **argv)
usage();
}
if (!app) {
ret = apprentice(magicfile, action);
if (action)
exit(ret);
app = 1;
switch(action) {
case FILE_CHECK:
case FILE_COMPILE:
magic = magic_open(flags|MAGIC_CHECK);
if (magic == NULL) {
(void)fprintf(stderr, "%s: %s\n", progname,
strerror(errno));
return 1;
}
c = action == FILE_CHECK ? magic_check(magic, magicfile) :
magic_compile(magic, magicfile);
if (c == -1) {
(void)fprintf(stderr, "%s: %s\n", progname,
magic_error(magic));
return -1;
}
return 0;
default:
load(magicfile, flags);
break;
}
if (optind == argc) {
@ -284,7 +307,7 @@ main(int argc, char **argv)
else {
int i, wid, nw;
for (wid = 0, i = optind; i < argc; i++) {
nw = strlen(argv[i]);
nw = file_mbswidth(argv[i]);
if (nw > wid)
wid = nw;
}
@ -296,10 +319,27 @@ main(int argc, char **argv)
}
private void
load(const char *m, int flags)
{
if (magic)
return;
magic = magic_open(flags);
if (magic == NULL) {
(void)fprintf(stderr, "%s: %s\n", progname, strerror(errno));
exit(1);
}
if (magic_load(magic, magicfile) == -1) {
(void)fprintf(stderr, "%s: %s\n",
progname, magic_error(magic));
exit(1);
}
}
/*
* unwrap -- read a file of filenames, do each one.
*/
static void
private void
unwrap(char *fn)
{
char buf[MAXPATHLEN];
@ -311,12 +351,13 @@ unwrap(char *fn)
wid = 1;
} else {
if ((f = fopen(fn, "r")) == NULL) {
error("Cannot open `%s' (%s).\n", fn, strerror(errno));
/*NOTREACHED*/
(void)fprintf(stderr, "%s: Cannot open `%s' (%s).\n",
progname, fn, strerror(errno));
exit(1);
}
while (fgets(buf, MAXPATHLEN, f) != NULL) {
cwid = strlen(buf) - 1;
cwid = file_mbswidth(buf) - 1;
if (cwid > wid)
wid = cwid;
}
@ -325,7 +366,7 @@ unwrap(char *fn)
}
while (fgets(buf, MAXPATHLEN, f) != NULL) {
buf[strlen(buf)-1] = '\0';
buf[file_mbswidth(buf)-1] = '\0';
process(buf, wid);
if(nobuffer)
(void) fflush(stdout);
@ -334,6 +375,23 @@ unwrap(char *fn)
(void) fclose(f);
}
private void
process(const char *inname, int wid)
{
const char *type;
int std_in = strcmp(inname, "-") == 0;
if (wid > 0 && !bflag)
(void) printf("%s%s%*s ", std_in ? "/dev/stdin" : inname,
separator, (int) (nopad ? 0 : (wid - file_mbswidth(inname))), "");
type = magic_file(magic, std_in ? NULL : inname);
if (type == NULL)
printf("ERROR: %s\n", magic_error(magic));
else
printf("%s\n", type);
}
#if 0
/*
@ -343,7 +401,7 @@ unwrap(char *fn)
* same whether to perform byte swapping
* big_endian whether we are a big endian host
*/
static int
private int
byteconv4(int from, int same, int big_endian)
{
if (same)
@ -370,7 +428,7 @@ byteconv4(int from, int same, int big_endian)
* byteconv2
* Same as byteconv4, but for shorts
*/
static short
private short
byteconv2(int from, int same, int big_endian)
{
if (same)
@ -392,148 +450,44 @@ byteconv2(int from, int same, int big_endian)
}
#endif
/*
* process - process input file
*/
void
process(const char *inname, int wid)
size_t
file_mbswidth(const char *s)
{
int fd = 0;
static const char stdname[] = "standard input";
unsigned char buf[HOWMANY+1]; /* one extra for terminating '\0' */
struct stat sb;
int nbytes = 0; /* number of bytes read from a datafile */
char match = '\0';
#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
size_t bytesconsumed, old_n, n, width = 0;
mbstate_t state;
wchar_t nextchar;
(void)memset(&state, 0, sizeof(mbstate_t));
old_n = n = strlen(s);
if (strcmp("-", inname) == 0) {
if (fstat(0, &sb)<0) {
error("cannot fstat `%s' (%s).\n", stdname,
strerror(errno));
/*NOTREACHED*/
while (n > 0) {
bytesconsumed = mbrtowc(&nextchar, s, n, &state);
if (bytesconsumed == (size_t)(-1) ||
bytesconsumed == (size_t)(-2)) {
/* Something went wrong, return something reasonable */
return old_n;
}
inname = stdname;
}
if (wid > 0 && !bflag)
(void) printf("%s%c%*s", inname, separator,
(int) (nopad ? 0 : 1 + (wid - strlen(inname))), "");
if (inname != stdname) {
/*
* first try judging the file based on its filesystem status
*/
if (fsmagic(inname, &sb) != 0) {
putchar('\n');
return;
}
if ((fd = open(inname, O_RDONLY)) < 0) {
/* We can't open it, but we were able to stat it. */
if (sb.st_mode & 0002) ckfputs("writable, ", stdout);
if (sb.st_mode & 0111) ckfputs("executable, ", stdout);
ckfprintf(stdout, "can't read `%s' (%s).\n",
inname, strerror(errno));
return;
}
}
/*
* try looking at the first HOWMANY bytes
*/
if ((nbytes = read(fd, (char *)buf, HOWMANY)) == -1) {
error("read failed (%s).\n", strerror(errno));
/*NOTREACHED*/
}
if (nbytes == 0)
ckfputs(iflag ? "application/x-empty" : "empty", stdout);
else {
buf[nbytes++] = '\0'; /* null-terminate it */
match = tryit(inname, buf, nbytes, zflag);
}
#ifdef BUILTIN_ELF
if (match == 's' && nbytes > 5) {
/*
* We matched something in the file, so this *might*
* be an ELF file, and the file is at least 5 bytes long,
* so if it's an ELF file it has at least one byte
* past the ELF magic number - try extracting information
* from the ELF headers that can't easily be extracted
* with rules in the magic file.
*/
tryelf(fd, buf, nbytes);
if (s[0] == '\n') {
/*
* do what strlen() would do, so that caller
* is always right
*/
width++;
} else
width += wcwidth(nextchar);
s += bytesconsumed, n -= bytesconsumed;
}
return width;
#else
return strlen(s);
#endif
if (inname != stdname) {
#ifdef RESTORE_TIME
/*
* Try to restore access, modification times if read it.
* This is really *bad* because it will modify the status
* time of the file... And of course this will affect
* backup programs
*/
# ifdef USE_UTIMES
struct timeval utsbuf[2];
utsbuf[0].tv_sec = sb.st_atime;
utsbuf[1].tv_sec = sb.st_mtime;
(void) utimes(inname, utsbuf); /* don't care if loses */
# else
struct utimbuf utbuf;
utbuf.actime = sb.st_atime;
utbuf.modtime = sb.st_mtime;
(void) utime(inname, &utbuf); /* don't care if loses */
# endif
#endif
(void) close(fd);
}
(void) putchar('\n');
}
int
tryit(const char *fn, unsigned char *buf, int nb, int zfl)
{
/*
* The main work is done here!
* We have the file name and/or the data buffer to be identified.
*/
#ifdef __EMX__
/*
* Ok, here's the right place to add a call to some os-specific
* routine, e.g.
*/
if (os2_apptype(fn, buf, nb) == 1)
return 'o';
#endif
/* try compression stuff */
if (zfl && zmagic(fn, buf, nb))
return 'z';
/* try tests in /etc/magic (or surrogate magic file) */
if (softmagic(buf, nb))
return 's';
/* try known keywords, check whether it is ASCII */
if (ascmagic(buf, nb))
return 'a';
/* abandon hope, all ye who remain here */
ckfputs(iflag ? "application/octet-stream" : "data", stdout);
return '\0';
}
static void
private void
usage(void)
{
(void)fprintf(stderr, USAGE, progname);
(void)fprintf(stderr, "Usage: %s -C [-m magic]\n", progname);
(void)fprintf(stderr, USAGE, progname, progname);
#ifdef HAVE_GETOPT_LONG
(void)fputs("Try `file --help' for more information.\n", stderr);
#endif
@ -541,7 +495,7 @@ usage(void)
}
#ifdef HAVE_GETOPT_LONG
static void
private void
help(void)
{
puts(
@ -556,10 +510,14 @@ help(void)
" conjunction with -m to debug a new magic file\n"
" before installing it\n"
" -f, --files-from FILE read the filenames to be examined from FILE\n"
" -F, --separator string use string as separator instead of `:'\n"
" -i, --mime output mime type strings\n"
" -k, --keep-going don't stop at the first match\n"
" -L, --dereference causes symlinks to be followed\n"
" -n, --no-buffer do not buffer output\n"
" -N, --no-pad do not pad output\n"
" -p, --preserve-date preserve access times on files\n"
" -r, --raw don't translate unprintable chars to \\ooo\n"
" -s, --special-files treat special (block/char devices) files as\n"
" ordinary ones\n"
" --help display this help and exit\n"

View File

@ -1,111 +1,188 @@
/*
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Ian F. Darwin and others.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* file.h - definitions for file(1) program
* @(#)$Id: file.h,v 1.45 2003/02/08 18:33:53 christos Exp $
*
* Copyright (c) Ian F. Darwin, 1987.
* Written by Ian F. Darwin.
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
*
* 1. The author is not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
*
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
*
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
*
* 4. This notice may not be removed or altered.
* @(#)$Id: file.h,v 1.61 2004/05/12 14:53:01 christos Exp $
*/
#ifndef __file_h__
#define __file_h__
#ifndef __linux__
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
#endif
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h> /* Include that here, to make sure __P gets defined */
#include <errno.h>
#include <stdio.h>
#ifdef HAVE_STDINT_H
#include <stdint.h>
#elif defined(HAVE_INTTYPES_H)
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
/* Do this here and now, because struct stat gets re-defined on solaris */
#include <sys/stat.h>
#ifndef MAGIC
#define MAGIC "/etc/magic"
#endif
#ifdef __EMX__
#define PATHSEP ';'
#else
#define PATHSEP ':'
#endif
#define private static
#ifndef protected
#define protected
#endif
#define public
#ifndef HOWMANY
# define HOWMANY 65536 /* how much of the file to look at */
#endif
#define MAXMAGIS 4096 /* max entries in /etc/magic */
#define MAXDESC 50 /* max leng of text description */
#define MAXDESC 64 /* max leng of text description */
#define MAXstring 32 /* max leng of "string" types */
#define MAGICNO 0xF11E041C
#define VERSIONNO 1
#define VERSIONNO 2
#define FILE_MAGICSIZE (32 * 4)
#define CHECK 1
#define COMPILE 2
#ifndef __GNUC__
#define __attribute__(a)
#endif
#define FILE_LOAD 0
#define FILE_CHECK 1
#define FILE_COMPILE 2
struct magic {
/* Word 1 */
uint16_t cont_level; /* level of ">" */
uint8_t nospflag; /* supress space character */
uint8_t flag;
#define INDIR 1 /* if '>(...)' appears, */
#define UNSIGNED 2 /* comparison is unsigned */
#define OFFADD 4 /* if '>&' appears, */
/* Word 2 */
uint8_t reln; /* relation (0=eq, '>'=gt, etc) */
uint8_t vallen; /* length of string value, if any */
uint8_t type; /* int, short, long or string. */
uint8_t in_type; /* type of indirrection */
#define BYTE 1
#define SHORT 2
#define LONG 4
#define STRING 5
#define DATE 6
#define BESHORT 7
#define BELONG 8
#define BEDATE 9
#define LESHORT 10
#define LELONG 11
#define LEDATE 12
#define PSTRING 13
#define LDATE 14
#define BELDATE 15
#define LELDATE 16
#define REGEX 17
#define FILE_BYTE 1
#define FILE_SHORT 2
#define FILE_LONG 4
#define FILE_STRING 5
#define FILE_DATE 6
#define FILE_BESHORT 7
#define FILE_BELONG 8
#define FILE_BEDATE 9
#define FILE_LESHORT 10
#define FILE_LELONG 11
#define FILE_LEDATE 12
#define FILE_PSTRING 13
#define FILE_LDATE 14
#define FILE_BELDATE 15
#define FILE_LELDATE 16
#define FILE_REGEX 17
#define FILE_FORMAT_NAME \
/* 0 */ "invalid 0", \
/* 1 */ "byte", \
/* 2 */ "short", \
/* 3 */ "invalid 3", \
/* 4 */ "long", \
/* 5 */ "string", \
/* 6 */ "date", \
/* 7 */ "beshort", \
/* 8 */ "belong", \
/* 9 */ "bedate" \
/* 10 */ "leshort", \
/* 11 */ "lelong", \
/* 12 */ "ledate", \
/* 13 */ "pstring", \
/* 14 */ "ldate", \
/* 15 */ "beldate", \
/* 16 */ "leldate", \
/* 17 */ "regex",
#define FILE_FMT_NUM "cduxXi"
#define FILE_FMT_STR "s"
#define FILE_FORMAT_STRING \
/* 0 */ NULL, \
/* 1 */ FILE_FMT_NUM, \
/* 2 */ FILE_FMT_NUM, \
/* 3 */ NULL, \
/* 4 */ FILE_FMT_NUM, \
/* 5 */ FILE_FMT_STR, \
/* 6 */ FILE_FMT_STR, \
/* 7 */ FILE_FMT_NUM, \
/* 8 */ FILE_FMT_NUM, \
/* 9 */ FILE_FMT_STR, \
/* 10 */ FILE_FMT_NUM, \
/* 11 */ FILE_FMT_NUM, \
/* 12 */ FILE_FMT_STR, \
/* 13 */ FILE_FMT_STR, \
/* 14 */ FILE_FMT_STR, \
/* 15 */ FILE_FMT_STR, \
/* 16 */ FILE_FMT_STR, \
/* 17 */ FILE_FMT_STR,
/* Word 3 */
uint8_t in_op; /* operator for indirection */
uint8_t mask_op; /* operator for mask */
#define OPAND 1
#define OPOR 2
#define OPXOR 3
#define OPADD 4
#define OPMINUS 5
#define OPMULTIPLY 6
#define OPDIVIDE 7
#define OPMODULO 8
#define OPINVERSE 0x80
int32_t offset; /* offset to magic number */
int32_t in_offset; /* offset from indirection */
uint8_t dummy1;
uint8_t dummy2;
#define FILE_OPS "&|^+-*/%"
#define FILE_OPAND 0
#define FILE_OPOR 1
#define FILE_OPXOR 2
#define FILE_OPADD 3
#define FILE_OPMINUS 4
#define FILE_OPMULTIPLY 5
#define FILE_OPDIVIDE 6
#define FILE_OPMODULO 7
#define FILE_OPINVERSE 0x80
/* Word 4 */
uint32_t offset; /* offset to magic number */
/* Word 5 */
uint32_t in_offset; /* offset from indirection */
/* Word 6 */
uint32_t mask; /* mask before comparison with value */
/* Word 7 */
uint32_t dummy3;
/* Word 8 */
uint32_t dummp4;
/* Words 9-16 */
union VALUETYPE {
uint8_t b;
uint16_t h;
@ -115,9 +192,9 @@ struct magic {
uint8_t hs[2]; /* 2 bytes of a fixed-endian "short" */
uint8_t hl[4]; /* 4 bytes of a fixed-endian "long" */
} value; /* either number or string */
uint32_t mask; /* mask before comparison with value */
/* Words 17..31 */
char desc[MAXDESC]; /* description */
} __attribute__((__packed__));
};
#define BIT(A) (1 << (A))
#define STRING_IGNORE_LOWERCASE BIT(0)
@ -131,48 +208,58 @@ struct magic {
/* list of magic entries */
struct mlist {
struct magic *magic; /* array of magic entries */
uint32_t nmagic; /* number of entries in array */
uint32_t nmagic; /* number of entries in array */
int mapped; /* allocation type: 0 => apprentice_file
* 1 => apprentice_map + malloc
* 2 => apprentice_map + mmap */
struct mlist *next, *prev;
};
extern int apprentice(const char *, int);
extern int ascmagic(unsigned char *, int);
extern void error(const char *, ...);
extern void ckfputs(const char *, FILE *);
struct magic_set {
struct mlist *mlist;
struct cont {
size_t len;
int32_t *off;
} c;
struct out {
/* Accumulation buffer */
char *buf;
char *ptr;
size_t len;
size_t size;
/* Printable buffer */
char *pbuf;
size_t psize;
} o;
int error;
int flags;
int haderr;
};
struct stat;
extern int fsmagic(const char *, struct stat *);
extern char *fmttime(long, int);
extern int is_compress(const unsigned char *, int *);
extern int is_tar(unsigned char *, int);
extern void magwarn(const char *, ...);
extern void mdump(struct magic *);
extern void process(const char *, int);
extern void showstr(FILE *, const char *, int);
extern int softmagic(unsigned char *, int);
extern int tryit(const char *, unsigned char *, int, int);
extern int zmagic(const char *, unsigned char *, int);
extern void ckfprintf(FILE *, const char *, ...);
extern uint32_t signextend(struct magic *, unsigned int32);
extern void tryelf(int, unsigned char *, int);
extern int pipe2file(int, void *, size_t);
extern char *progname; /* the program name */
extern const char *magicfile; /* name of the magic file */
extern int lineno; /* current line number in magic file */
extern struct mlist mlist; /* list of arrays of magic entries */
extern int debug; /* enable debugging? */
extern int zflag; /* process compressed files? */
extern int lflag; /* follow symbolic links? */
extern int sflag; /* read/analyze block special files? */
extern int iflag; /* Output types as mime-types */
#ifdef NEED_GETOPT
extern int optind; /* From getopt(3) */
extern char *optarg;
#endif
protected char *file_fmttime(uint32_t, int);
protected int file_buffer(struct magic_set *, const void *, size_t);
protected int file_fsmagic(struct magic_set *, const char *, struct stat *);
protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
protected int file_printf(struct magic_set *, const char *, ...);
protected int file_reset(struct magic_set *);
protected int file_tryelf(struct magic_set *, int, const unsigned char *, size_t);
protected int file_zmagic(struct magic_set *, const unsigned char *, size_t);
protected int file_ascmagic(struct magic_set *, const unsigned char *, size_t);
protected int file_is_tar(struct magic_set *, const unsigned char *, size_t);
protected int file_softmagic(struct magic_set *, const unsigned char *, size_t);
protected struct mlist *file_apprentice(struct magic_set *, const char *, int);
protected uint32_t file_signextend(struct magic_set *, struct magic *, uint32_t);
protected void file_delmagic(struct magic *, int type, size_t entries);
protected void file_badread(struct magic_set *);
protected void file_badseek(struct magic_set *);
protected void file_oomem(struct magic_set *);
protected void file_error(struct magic_set *, int, const char *, ...);
protected void file_magwarn(const char *, ...);
protected void file_mdump(struct magic *);
protected void file_showstr(FILE *, const char *, size_t);
protected size_t file_mbswidth(const char *);
protected const char *file_getbuffer(struct magic_set *);
#ifndef HAVE_STRERROR
extern int sys_nerr;
@ -193,5 +280,6 @@ extern char *sys_errlist[];
static const char *rcsid(const char *p) { \
return rcsid(p = id); \
}
#else
#endif /* __file_h__ */

View File

@ -1,12 +1,12 @@
.TH FILE __CSECTION__ "Copyright but distributable"
.\" $Id: file.man,v 1.44 2003/02/27 20:47:46 christos Exp $
.\" $Id: file.man,v 1.54 2003/10/27 18:09:08 christos Exp $
.SH NAME
file
\- determine file type
.SH SYNOPSIS
.B file
[
.B \-bciknNsvzL
.B \-bcikLnNprsvz
]
[
.B \-f
@ -14,18 +14,19 @@ file
]
[
.B \-F
separator ]
.I separator
]
[
.B \-m
.B \-m
.I magicfiles
]
.I file
\*[Am]...
\&...
.br
.B file
.B -C
[
.B \-m
.B \-m
magicfile ]
.SH DESCRIPTION
This manual page documents version __VERSION__ of the
@ -57,7 +58,7 @@ Exceptions are well-known file formats (core files, tar archives)
that are known to contain binary data.
When modifying the file
.I __MAGIC__
or the program itself,
or the program itself,
.B "preserve these keywords" .
People depend on knowing that all the readable files in a directory
have the word ``text'' printed.
@ -80,13 +81,13 @@ Any known file types appropriate to the system you are running on
implement them)
are intuited if they are defined in
the system header file
.IR \*[Lt]sys/stat.h\*[Gt] .
.IR <sys/stat.h> .
.PP
The magic number tests are used to check for files with data in
particular fixed formats.
The canonical example of this is a binary executable (compiled program)
.I a.out
file, whose format is defined in
file, whose format is defined in
.I a.out.h
and possibly
.I exec.h
@ -100,7 +101,7 @@ offset into the file can usually be described in this way.
The information identifying these files is read from the compiled
magic file
.I __MAGIC__.mgc ,
or
or
.I __MAGIC__
if the compile file does not exist.
.PP
@ -138,13 +139,13 @@ For example, the keyword
.B .br
indicates that the file is most likely a
.BR troff (1)
input file, just as the keyword
input file, just as the keyword
.B struct
indicates a C program.
These tests are less reliable than the previous
two groups, so they are performed last.
The language test routines also test for some miscellany
(such as
(such as
.BR tar (1)
archives).
.PP
@ -152,36 +153,36 @@ Any file that cannot be identified as having been written
in any of the character sets listed above is simply said to be ``data''.
.SH OPTIONS
.TP 8
.B \-b
.B "\-b, \-\-brief"
Do not prepend filenames to output lines (brief mode).
.TP 8
.B \-c
.B "\-c, \-\-checking\-printout"
Cause a checking printout of the parsed form of the magic file.
This is usually used in conjunction with
This is usually used in conjunction with
.B \-m
to debug a new magic file before installing it.
.TP 8
.B \-C
.B "\-C, \-\-compile"
Write a magic.mgc output file that contains a pre-parsed version of
file.
.TP 8
.BI \-f " namefile"
Read the names of the files to be examined from
.BI "\-f, \-\-files\-from" " namefile"
Read the names of the files to be examined from
.I namefile
(one per line)
(one per line)
before the argument list.
Either
Either
.I namefile
or at least one filename argument must be present;
to test the standard input, use ``\-'' as a filename argument.
.TP 8
.BI \-F " separator"
Use the specified separator character instead of ``:''.
.BI "\-F, \-\-separator" " separator"
Use the specified string as the separator between the filename and the
file result returned. Defaults to ``:''.
.TP 8
.B \-i
.B "\-i, \-\-mime"
Causes the file command to output mime type strings rather than the more
traditional human readable ones.
Thus it may say
traditional human readable ones. Thus it may say
``text/plain; charset=us-ascii''
rather
than ``ASCII text''.
@ -191,33 +192,44 @@ text file types, directories etc), and makes use of an alternative
``magic'' file.
(See ``FILES'' section, below).
.TP 8
.B \-k
.B "\-k, \-\-keep\-going"
Don't stop at the first match, keep going.
.TP 8
.BI \-m " list"
Specify an alternate list of files containing magic numbers.
This can be a single file, or a colon-separated list of files.
.TP 8
.B \-n
Force stdout to be flushed after checking each file.
This is only useful if checking a list of files.
It is intended to be used by programs that want filetype output from a pipe.
.TP 8
.B \-N
Don't pad output to align filenames nicely.
.TP 8
.B \-v
Print the version of the program and exit.
.TP 8
.B \-z
Try to look inside compressed files.
.TP 8
.B \-L
.B "\-L, \-\-dereference"
option causes symlinks to be followed, as the like-named option in
.BR ls (1).
(on systems that support symbolic links).
.TP 8
.B \-s
.BI "\-m, \-\-magic\-file" " list"
Specify an alternate list of files containing magic numbers.
This can be a single file, or a colon-separated list of files.
If a compiled magic file is found alongside, it will be used instead.
With the \-i or \-\-mime option, the program adds ".mime" to each file name.
.TP 8
.B "\-n, \-\-no\-buffer"
Force stdout to be flushed after checking each file.
This is only useful if checking a list of files.
It is intended to be used by programs that want filetype output from a pipe.
.TP 8
.B "\-N, \-\-no\-pad"
Don't pad filenames so that they align in the output.
.TP 8
.B "\-p, \-\-preserve\-date"
On systems that support
.BR utime (2)
or
.BR utimes(2),
attempt to preserve the access time of files analyzed, to pretend that
.BR file (2)
never read them.
.TP 8
.B "\-r, \-\-raw"
Don't translate unprintable characters to \eooo.
Normally
.B file
translates unprintable characters to their octal representation.
.TP 8
.B "\-s, \-\-special\-files"
Normally,
.B file
only attempts to read and determine the type of argument files which
@ -237,21 +249,40 @@ This option also causes
to disregard the file size as reported by
.BR stat (2)
since on some systems it reports a zero size for raw disk partitions.
.TP 8
.B "\-v, \-\-version"
Print the version of the program and exit.
.TP 8
.B "\-z, \-\-uncompress"
Try to look inside compressed files.
.TP 8
.B "\-\-help"
Print a help message and exit.
.SH FILES
.TP
.I __MAGIC__.mgc
\- default compiled list of magic numbers
.PP
Default compiled list of magic numbers
.TP
.I __MAGIC__
\- default list of magic numbers
.PP
Default list of magic numbers
.TP
.I __MAGIC__.mime.mgc
Default compiled list of magic numbers, used to output mime types when
the -i option is specified.
.TP
.I __MAGIC__.mime
\- default list of magic numbers, used to output mime types when the -i option
Default list of magic numbers, used to output mime types when the -i option
is specified.
.TP
.I /etc/magic
Local additions to magic wisdom.
.SH ENVIRONMENT
The environment variable
.B MAGIC
can be used to set the default magic number files.
can be used to set the default magic number file name.
.B file
adds ".mime" and/or ".mgc" to the value of this variable as appropriate.
.SH SEE ALSO
.BR magic (__FSECTION__)
\- description of magic file format.
@ -261,25 +292,26 @@ can be used to set the default magic number files.
.SH STANDARDS CONFORMANCE
This program is believed to exceed the System V Interface Definition
of FILE(CMD), as near as one can determine from the vague language
contained therein.
contained therein.
Its behaviour is mostly compatible with the System V program of the same name.
This version knows more magic, however, so it will produce
different (albeit more accurate) output in many cases.
different (albeit more accurate) output in many cases.
.PP
The one significant difference
The one significant difference
between this version and System V
is that this version treats any white space
as a delimiter, so that spaces in pattern strings must be escaped.
For example,
.br
\*[Gt]10 string language impress\ (imPRESS data)
>10 string language impress\ (imPRESS data)
.br
in an existing magic file would have to be changed to
.br
\*[Gt]10 string language\e impress (imPRESS data)
>10 string language\e impress (imPRESS data)
.br
In addition, in this version, if a pattern string contains a backslash,
it must be escaped. For example
it must be escaped.
For example
.br
0 string \ebegindata Andrew Toolkit document
.br
@ -292,16 +324,16 @@ SunOS releases 3.2 and later from Sun Microsystems include a
.BR file (1)
command derived from the System V one, but with some extensions.
My version differs from Sun's only in minor ways.
It includes the extension of the `\*[Am]' operator, used as,
It includes the extension of the `&' operator, used as,
for example,
.br
\*[Gt]16 long\*[Am]0x7fffffff \*[Gt]0 not stripped
>16 long&0x7fffffff >0 not stripped
.SH MAGIC DIRECTORY
The magic file entries have been collected from various sources,
mainly USENET, and contributed by various authors.
Christos Zoulas (address below) will collect additional
or corrected magic file entries.
A consolidation of magic file entries
A consolidation of magic file entries
will be distributed periodically.
.PP
The order of entries in the magic file is significant.
@ -311,7 +343,7 @@ If your old
.B file
command uses a magic file,
keep the old magic file around for comparison purposes
(rename it to
(rename it to
.IR __MAGIC__.orig ).
.SH EXAMPLES
.nf
@ -324,7 +356,7 @@ file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
$ file -s /dev/wd0{b,d}
/dev/wd0b: data
/dev/wd0d: x86 boot sector
$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10} # Linux
$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
/dev/hda: x86 boot sector
/dev/hda1: Linux/i386 ext2 filesystem
/dev/hda2: x86 boot sector
@ -337,22 +369,6 @@ $ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10} # Linux
/dev/hda9: empty
/dev/hda10: empty
$ file -s /dev/rwd0e # BSD
/dev/rwd0e:
Unix Fast File system (little-endian),
last mounted on /usr,
last written at Mon Feb 10 13:22:40 2003,
clean flag 2,
number of blocks 28754208,
number of data blocks 27812712,
number of cylinder groups 3566,
block size 8192,
fragment size 1024,
minimum percentage of free blocks 5,
rotational delay 0ms,
disk rotational speed 60rps,
TIME optimization
$ file -i file.c file /dev/{wd0a,hda}
file.c: text/x-c
file: application/x-executable, dynamically linked (uses shared libs),
@ -362,7 +378,7 @@ not stripped
.fi
.SH HISTORY
There has been a
There has been a
.B file
command in every \s-1UNIX\s0 since at least Research Version 4
(man page dated November, 1973).
@ -371,14 +387,14 @@ the external list of magic number types.
This slowed the program down slightly but made it a lot more flexible.
.PP
This program, based on the System V version,
was written by Ian Darwin \*[Lt]ian@darwinsys.com\*[Gt]
was written by Ian Darwin <ian@darwinsys.com>
without looking at anybody else's source code.
.PP
John Gilmore revised the code extensively, making it better than
the first version.
Geoff Collyer found several inadequacies
and provided some magic file entries.
Contributions by the `\*[Am]' operator by Rob McMahon, cudcv@warwick.ac.uk, 1989.
Contributions by the `&' operator by Rob McMahon, cudcv@warwick.ac.uk, 1989.
.PP
Guy Harris, guy@netapp.com, made many changes from 1993 to the present.
.PP
@ -411,7 +427,7 @@ were written by John Gilmore from his public-domain
program, and are not covered by the above license.
.SH BUGS
There must be a better way to automate the construction of the Magic
file from all the glop in Magdir.
file from all the glop in magdir.
What is it?
Better yet, the magic file should be compiled into binary (say,
.BR ndbm (3)
@ -447,11 +463,11 @@ commands vs man page macros.
Regular expression support would make this easy.
.PP
The program doesn't grok \s-2FORTRAN\s0.
It should be able to figure \s-2FORTRAN\s0 by seeing some keywords which
It should be able to figure \s-2FORTRAN\s0 by seeing some keywords which
appear indented at the start of line.
Regular expression support would make this easy.
.PP
The list of keywords in
The list of keywords in
.I ascmagic
probably belongs in the Magic file.
This could be done by using some keyword like `*' for the offset value.
@ -464,13 +480,13 @@ Complain about conflicts in the magic file entries.
Make a rule that the magic entries sort based on file offset rather
than position within the magic file?
.PP
The program should provide a way to give an estimate
The program should provide a way to give an estimate
of ``how good'' a guess is.
We end up removing guesses (e.g. ``From '' as first 5 chars of file) because
they are not as good as other guesses (e.g. ``Newsgroups:'' versus
``Return-Path:'').
Still, if the others don't pan out, it should be
possible to use the first guess.
Still, if the others don't pan out, it should be possible to use the
first guess.
.PP
This program is slower than some vendors' file commands.
The new support for multiple character codes makes it even slower.

View File

@ -1,37 +1,48 @@
/*
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Ian F. Darwin and others.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* fsmagic - magic based on filesystem info - directory, special files, etc.
*
* Copyright (c) Ian F. Darwin, 1987.
* Written by Ian F. Darwin.
*
* This software is not subject to any license of the American Telephone
* and Telegraph Company or of the Regents of the University of California.
*
* Permission is granted to anyone to use this software for any purpose on
* any computer system, and to alter it and redistribute it freely, subject
* to the following restrictions:
*
* 1. The author is not responsible for the consequences of use of this
* software, no matter how awful, even if they arise from flaws in it.
*
* 2. The origin of this software must not be misrepresented, either by
* explicit claim or by omission. Since few users ever read sources,
* credits must appear in the documentation.
*
* 3. Altered versions must be plainly marked as such, and must not be
* misrepresented as being the original software. Since few users
* ever read sources, credits must appear in the documentation.
*
* 4. This notice may not be removed or altered.
*/
#include "file.h"
#include "magic.h"
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdlib.h>
/* Since major is a function on SVR4, we can't use `ifndef major'. */
#include <sys/stat.h>
/* Since major is a function on SVR4, we cannot use `ifndef major'. */
#ifdef MAJOR_IN_MKDEV
# include <sys/mkdev.h>
# define HAVE_MAJOR
@ -51,54 +62,74 @@
#undef HAVE_MAJOR
#ifndef lint
FILE_RCSID("@(#)$Id: fsmagic.c,v 1.36 2002/07/03 19:00:41 christos Exp $")
FILE_RCSID("@(#)$Id: fsmagic.c,v 1.43 2003/10/14 19:29:55 christos Exp $")
#endif /* lint */
int
fsmagic(const char *fn, struct stat *sb)
protected int
file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
{
int ret = 0;
#ifdef S_IFLNK
char buf[BUFSIZ+4];
int nch;
struct stat tstatbuf;
#endif
if (fn == NULL)
return 0;
/*
* Fstat is cheaper but fails for files you don't have read perms on.
* On 4.2BSD and similar systems, use lstat() to identify symlinks.
*/
#ifdef S_IFLNK
if (!lflag)
if ((ms->flags & MAGIC_SYMLINK) == 0)
ret = lstat(fn, sb);
else
#endif
ret = stat(fn, sb); /* don't merge into if; see "ret =" above */
if (ret) {
ckfprintf(stdout,
/* Yes, I do mean stdout. */
/* No \n, caller will provide. */
"can't stat `%s' (%s).", fn, strerror(errno));
if (ms->flags & MAGIC_ERROR) {
file_error(ms, errno, "cannot stat `%s'", fn);
return -1;
}
if (file_printf(ms, "cannot open (%s)",
fn, strerror(errno)) == -1)
return -1;
return 1;
}
if (iflag) {
if ((ms->flags & MAGIC_MIME) != 0) {
if ((sb->st_mode & S_IFMT) != S_IFREG) {
ckfputs("application/x-not-regular-file", stdout);
if (file_printf(ms, "application/x-not-regular-file")
== -1)
return -1;
return 1;
}
}
else {
#ifdef S_ISUID
if (sb->st_mode & S_ISUID) ckfputs("setuid ", stdout);
if (sb->st_mode & S_ISUID)
if (file_printf(ms, "setuid ") == -1)
return -1;
#endif
#ifdef S_ISGID
if (sb->st_mode & S_ISGID) ckfputs("setgid ", stdout);
if (sb->st_mode & S_ISGID)
if (file_printf(ms, "setgid ") == -1)
return -1;
#endif
#ifdef S_ISVTX
if (sb->st_mode & S_ISVTX) ckfputs("sticky ", stdout);
if (sb->st_mode & S_ISVTX)
if (file_printf(ms, "sticky ") == -1)
return -1;
#endif
}
switch (sb->st_mode & S_IFMT) {
case S_IFDIR:
ckfputs("directory", stdout);
if (file_printf(ms, "directory") == -1)
return -1;
return 1;
#ifdef S_IFCHR
case S_IFCHR:
@ -107,20 +138,22 @@ fsmagic(const char *fn, struct stat *sb)
* like ordinary files. Otherwise, just report that they
* are block special files and go on to the next file.
*/
if (sflag)
if ((ms->flags & MAGIC_DEVICES) != 0)
break;
#ifdef HAVE_ST_RDEV
# ifdef dv_unit
(void) printf("character special (%d/%d/%d)",
major(sb->st_rdev),
dv_unit(sb->st_rdev),
dv_subunit(sb->st_rdev));
if (file_printf(ms, "character special (%d/%d/%d)",
major(sb->st_rdev), dv_unit(sb->st_rdev),
dv_subunit(sb->st_rdev)) == -1)
return -1;
# else
(void) printf("character special (%ld/%ld)",
(long) major(sb->st_rdev), (long) minor(sb->st_rdev));
if (file_printf(ms, "character special (%ld/%ld)",
(long) major(sb->st_rdev), (long) minor(sb->st_rdev)) == -1)
return -1;
# endif
#else
(void) printf("character special");
if (file_printf(ms, "character special") == -1)
return -1;
#endif
return 1;
#endif
@ -131,98 +164,132 @@ fsmagic(const char *fn, struct stat *sb)
* like ordinary files. Otherwise, just report that they
* are block special files and go on to the next file.
*/
if (sflag)
if ((ms->flags & MAGIC_DEVICES) != 0)
break;
#ifdef HAVE_ST_RDEV
# ifdef dv_unit
(void) printf("block special (%d/%d/%d)",
major(sb->st_rdev),
dv_unit(sb->st_rdev),
dv_subunit(sb->st_rdev));
if (file_printf(ms, "block special (%d/%d/%d)",
major(sb->st_rdev), dv_unit(sb->st_rdev),
dv_subunit(sb->st_rdev)) == -1)
return -1;
# else
(void) printf("block special (%ld/%ld)",
(long) major(sb->st_rdev), (long) minor(sb->st_rdev));
if (file_printf(ms, "block special (%ld/%ld)",
(long)major(sb->st_rdev), (long)minor(sb->st_rdev)) == -1)
return -1;
# endif
#else
(void) printf("block special");
if (file_printf(ms, "block special") == -1)
return -1;
#endif
return 1;
#endif
/* TODO add code to handle V7 MUX and Blit MUX files */
#ifdef S_IFIFO
case S_IFIFO:
ckfputs("fifo (named pipe)", stdout);
if (file_printf(ms, "fifo (named pipe)") == -1)
return -1;
return 1;
#endif
#ifdef S_IFDOOR
case S_IFDOOR:
ckfputs("door", stdout);
if (file_printf(ms, "door") == -1)
return -1;
return 1;
#endif
#ifdef S_IFLNK
case S_IFLNK:
{
char buf[BUFSIZ+4];
int nch;
struct stat tstatbuf;
if ((nch = readlink(fn, buf, BUFSIZ-1)) <= 0) {
ckfprintf(stdout, "unreadable symlink (%s).",
strerror(errno));
return 1;
if ((nch = readlink(fn, buf, BUFSIZ-1)) <= 0) {
if (ms->flags & MAGIC_ERROR) {
file_error(ms, errno, "unreadable symlink `%s'",
fn);
return -1;
}
buf[nch] = '\0'; /* readlink(2) forgets this */
if (file_printf(ms,
"unreadable symlink `%s' (%s)", fn,
strerror(errno)) == -1)
return -1;
return 1;
}
buf[nch] = '\0'; /* readlink(2) forgets this */
/* If broken symlink, say so and quit early. */
if (*buf == '/') {
if (stat(buf, &tstatbuf) < 0) {
ckfprintf(stdout,
"broken symbolic link to %s", buf);
return 1;
}
}
else {
char *tmp;
char buf2[BUFSIZ+BUFSIZ+4];
/* If broken symlink, say so and quit early. */
if (*buf == '/') {
if (stat(buf, &tstatbuf) < 0) {
if (ms->flags & MAGIC_ERROR) {
file_error(ms, errno,
"broken symbolic link to `%s'", buf);
return -1;
}
if (file_printf(ms, "broken symbolic link to `%s'",
buf) == -1)
return -1;
return 1;
}
}
else {
char *tmp;
char buf2[BUFSIZ+BUFSIZ+4];
if ((tmp = strrchr(fn, '/')) == NULL) {
if ((tmp = strrchr(fn, '/')) == NULL) {
tmp = buf; /* in current directory anyway */
}
else {
strcpy (buf2, fn); /* take directory part */
buf2[tmp-fn+1] = '\0';
strcat (buf2, buf); /* plus (relative) symlink */
} else {
if (tmp - fn + 1 > BUFSIZ) {
if (ms->flags & MAGIC_ERROR) {
file_error(ms, 0,
"path too long: `%s'", buf);
return -1;
}
if (file_printf(ms,
"path too long: `%s'", fn) == -1)
return -1;
return 1;
}
(void)strcpy(buf2, fn); /* take dir part */
buf2[tmp - fn + 1] = '\0';
(void)strcat(buf2, buf); /* plus (rel) link */
tmp = buf2;
}
if (stat(tmp, &tstatbuf) < 0) {
ckfprintf(stdout,
"broken symbolic link to %s", buf);
}
if (stat(tmp, &tstatbuf) < 0) {
if (ms->flags & MAGIC_ERROR) {
file_error(ms, errno,
"broken symbolic link to `%s'",
buf);
return -1;
}
if (file_printf(ms,
"broken symbolic link to `%s'", buf) == -1)
return -1;
return 1;
}
}
/* Otherwise, handle it. */
if (lflag) {
process(buf, strlen(buf));
return 1;
} else { /* just print what it points to */
ckfputs("symbolic link to ", stdout);
ckfputs(buf, stdout);
}
}
return 1;
/* Otherwise, handle it. */
if ((ms->flags & MAGIC_SYMLINK) != 0) {
const char *p;
ms->flags &= MAGIC_SYMLINK;
p = magic_file(ms, buf);
ms->flags |= MAGIC_SYMLINK;
return p != NULL ? 1 : -1;
} else { /* just print what it points to */
if (file_printf(ms, "symbolic link to `%s'",
buf) == -1)
return -1;
}
return 1;
#endif
#ifdef S_IFSOCK
#ifndef __COHERENT__
case S_IFSOCK:
ckfputs("socket", stdout);
if (file_printf(ms, "socket") == -1)
return -1;
return 1;
#endif
#endif
case S_IFREG:
break;
default:
error("invalid mode 0%o.\n", sb->st_mode);
file_error(ms, 0, "invalid mode 0%o", sb->st_mode);
return -1;
/*NOTREACHED*/
}
@ -238,8 +305,10 @@ fsmagic(const char *fn, struct stat *sb)
* the fact that it is empty will be detected and reported correctly
* when we read the file.)
*/
if (!sflag && sb->st_size == 0) {
ckfputs(iflag ? "application/x-empty" : "empty", stdout);
if ((ms->flags & MAGIC_DEVICES) == 0 && sb->st_size == 0) {
if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
"application/x-empty" : "empty") == -1)
return -1;
return 1;
}
return 0;

186
contrib/file/funcs.c Normal file
View File

@ -0,0 +1,186 @@
/*
* Copyright (c) Christos Zoulas 2003.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "file.h"
#include "magic.h"
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifndef lint
FILE_RCSID("@(#)$Id: funcs.c,v 1.12 2004/06/04 14:40:20 christos Exp $")
#endif /* lint */
/*
* Like printf, only we print to a buffer and advance it.
*/
protected int
file_printf(struct magic_set *ms, const char *fmt, ...)
{
va_list ap;
size_t len;
char *buf;
va_start(ap, fmt);
if ((len = vsnprintf(ms->o.ptr, ms->o.len, fmt, ap)) >= ms->o.len) {
va_end(ap);
if ((buf = realloc(ms->o.buf, len + 1024)) == NULL) {
file_oomem(ms);
return -1;
}
ms->o.ptr = buf + (ms->o.ptr - ms->o.buf);
ms->o.buf = buf;
ms->o.len = ms->o.size - (ms->o.ptr - ms->o.buf);
ms->o.size = len + 1024;
va_start(ap, fmt);
len = vsnprintf(ms->o.ptr, ms->o.len, fmt, ap);
}
ms->o.ptr += len;
ms->o.len -= len;
va_end(ap);
return 0;
}
/*
* error - print best error message possible
*/
/*VARARGS*/
protected void
file_error(struct magic_set *ms, int error, const char *f, ...)
{
va_list va;
/* Only the first error is ok */
if (ms->haderr)
return;
va_start(va, f);
(void)vsnprintf(ms->o.buf, ms->o.size, f, va);
va_end(va);
if (error > 0) {
size_t len = strlen(ms->o.buf);
(void)snprintf(ms->o.buf + len, ms->o.size - len, " (%s)",
strerror(error));
}
ms->haderr++;
ms->error = error;
}
protected void
file_oomem(struct magic_set *ms)
{
file_error(ms, errno, "cannot allocate memory");
}
protected void
file_badseek(struct magic_set *ms)
{
file_error(ms, errno, "error seeking");
}
protected void
file_badread(struct magic_set *ms)
{
file_error(ms, errno, "error reading");
}
#ifndef COMPILE_ONLY
protected int
file_buffer(struct magic_set *ms, const void *buf, size_t nb)
{
int m;
/* try compression stuff */
if ((m = file_zmagic(ms, buf, nb)) == 0) {
/* Check if we have a tar file */
if ((m = file_is_tar(ms, buf, nb)) == 0) {
/* try tests in /etc/magic (or surrogate magic file) */
if ((m = file_softmagic(ms, buf, nb)) == 0) {
/* try known keywords, check whether it is ASCII */
if ((m = file_ascmagic(ms, buf, nb)) == 0) {
/* abandon hope, all ye who remain here */
if (file_printf(ms, ms->flags & MAGIC_MIME ?
"application/octet-stream" : "data") == -1)
return -1;
m = 1;
}
}
}
}
return m;
}
#endif
protected int
file_reset(struct magic_set *ms)
{
if (ms->mlist == NULL) {
file_error(ms, 0, "no magic files loaded");
return -1;
}
ms->o.ptr = ms->o.buf;
ms->haderr = 0;
ms->error = -1;
return 0;
}
protected const char *
file_getbuffer(struct magic_set *ms)
{
char *nbuf, *op, *np;
size_t nsize;
if (ms->haderr)
return NULL;
if (ms->flags & MAGIC_RAW)
return ms->o.buf;
nsize = ms->o.len * 4 + 1;
if (ms->o.psize < nsize) {
if ((nbuf = realloc(ms->o.pbuf, nsize)) == NULL) {
file_oomem(ms);
return NULL;
}
ms->o.psize = nsize;
ms->o.pbuf = nbuf;
}
for (np = ms->o.pbuf, op = ms->o.buf; *op; op++) {
if (isprint((unsigned char)*op)) {
*np++ = *op;
} else {
*np++ = '\\';
*np++ = ((*op >> 6) & 3) + '0';
*np++ = ((*op >> 3) & 7) + '0';
*np++ = ((*op >> 0) & 7) + '0';
}
}
*np = '\0';
return ms->o.pbuf;
}

View File

@ -1,3 +1,35 @@
/*
* Copyright (c) Ian F. Darwin 1986-1995.
* Software written by Ian F. Darwin and others;
* maintained 1995-present by Christos Zoulas and others.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Ian F. Darwin and others.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* is_tar() -- figure out whether file is a tar archive.
*
@ -5,25 +37,49 @@
* Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
*
* @(#)list.c 1.18 9/23/86 Public Domain - gnu
* $Id: is_tar.c,v 1.17 2002/07/03 18:26:38 christos Exp $
*
* Comments changed and some code/comments reformatted
* for file command by Ian Darwin.
*/
#include "file.h"
#include "magic.h"
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include "tar.h"
#ifndef lint
FILE_RCSID("@(#)$Id: is_tar.c,v 1.17 2002/07/03 18:26:38 christos Exp $")
FILE_RCSID("@(#)$Id: is_tar.c,v 1.24 2003/11/11 20:01:46 christos Exp $")
#endif
#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
static int from_oct(int, char *); /* Decode octal number */
private int is_tar(const unsigned char *, size_t);
private int from_oct(int, const char *); /* Decode octal number */
protected int
file_is_tar(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
{
/*
* Do the tar test first, because if the first file in the tar
* archive starts with a dot, we can confuse it with an nroff file.
*/
switch (is_tar(buf, nbytes)) {
case 1:
if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
"application/x-tar" : "tar archive") == -1)
return -1;
return 1;
case 2:
if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
"application/x-tar, POSIX" : "POSIX tar archive") == -1)
return -1;
return 1;
default:
return 0;
}
}
/*
* Return
@ -31,13 +87,13 @@ static int from_oct(int, char *); /* Decode octal number */
* 1 for old UNIX tar file,
* 2 for Unix Std (POSIX) tar file.
*/
int
is_tar(unsigned char *buf, int nbytes)
private int
is_tar(const unsigned char *buf, size_t nbytes)
{
union record *header = (union record *)buf;
const union record *header = (const union record *)(const void *)buf;
int i;
int sum, recsum;
char *p;
const char *p;
if (nbytes < sizeof(union record))
return 0;
@ -48,7 +104,7 @@ is_tar(unsigned char *buf, int nbytes)
p = header->charptr;
for (i = sizeof(union record); --i >= 0;) {
/*
* We can't use unsigned char here because of old compilers,
* We cannot use unsigned char here because of old compilers,
* e.g. V7.
*/
sum += 0xFF & *p++;
@ -74,8 +130,8 @@ is_tar(unsigned char *buf, int nbytes)
*
* Result is -1 if the field is invalid (all blank, or nonoctal).
*/
static int
from_oct(int digs, char *where)
private int
from_oct(int digs, const char *where)
{
int value;

228
contrib/file/libmagic.man Normal file
View File

@ -0,0 +1,228 @@
.\"
.\" Copyright (c) Christos Zoulas 2003.
.\" All Rights Reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice immediately at the beginning of the file, without modification,
.\" this list of conditions, and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd March 22, 2003
.Dt MAGIC 3
.Os
.Sh NAME
.Nm magic_open ,
.Nm magic_close ,
.Nm magic_error ,
.Nm magic_file ,
.Nm magic_buffer ,
.Nm magic_setflags ,
.Nm magic_check ,
.Nm magic_compile ,
.Nm magic_load
.Nd Magic number recognition library.
.Sh LIBRARY
.Lb libmagic
.Sh SYNOPSIS
.In magic.h
.Ft magic_t
.Fn magic_open "int flags"
.Ft void
.Fn magic_close "magic_t cookie"
.Ft const char *
.Fn magic_error "magic_t cookie"
.Ft int
.Fn magic_errno "magic_t cookie"
.Ft const char *
.Fn magic_file "magic_t cookie, const char *filename"
.Ft const char *
.Fn magic_buffer "magic_t cookie, const void *buffer, size_t length"
.Ft int
.Fn magic_setflags "magic_t cookie, int flags"
.Ft int
.Fn magic_check "magic_t cookie, const char *filename"
.Ft int
.Fn magic_compile "magic_t cookie, const char *filename"
.Ft int
.Fn magic_load "magic_t cookie, const char *filename"
.Sh DESCRIPTION
These functions
operate on the magic database file
which is described
in
.Xr magic __FSECTION__ .
.Pp
The function
.Fn magic_open
creates a magic cookie pointer and returns it. It returns NULL if
there was an error allocating the magic cookie. The
.Ar flags
argument specifies how the other magic functions should behave:
.Bl -tag -width MAGIC_COMPRESS
.It Dv MAGIC_NONE
No special handling.
.It Dv MAGIC_DEBUG
Print debugging messages to stderr.
.It Dv MAGIC_SYMLINK
If the file queried is a symlink, follow it.
.It Dv MAGIC_COMPRESS
If the file is compressed, unpack it and look at the contents.
.It Dv MAGIC_DEVICES
If the file is a block or character special device, then open the device
and try to look in its contents.
.It Dv MAGIC_MIME
Return a mime string, instead of a textual description.
.It Dv MAGIC_CONTINUE
Return all matches, not just the first.
.It Dv MAGIC_CHECK
Check the magic database for consistency and print warnings to stderr.
.It Dv MAGIC_PRESERVE_ATIME
On systems that support
.Xr utime 2
or
.Xr utimes 2 ,
attempt to preserve the access time of files analyzed.
.It Dv MAGIC_RAW
Don't translate unprintable characters to a \eooo octal representation.
.It Dv MAGIC_ERROR
Treat operating system errors while trying to open files and follow symlinks
as real errors, instead of printing them in the magic buffer.
.El
.Pp
The
.Fn magic_close
function closes the
.Xr magic __FSECTION__
database and deallocates any resources used.
.Pp
The
.Fn magic_error
function returns a textual explanation of the last error, or NULL if there was
no error.
.Pp
The
.Fn magic_errno
function returns the last operating system error number (
.Xr errno 3 )
that was encountered by a system call.
.Pp
The
.Fn magic_file
function returns a textual description of the contents of the
.Ar filename
argument, or NULL if an error occurred.
If the
.Ar filename
is NULL, then stdin is used.
.Pp
The
.Fn magic_buffer
function returns a textual description of the contents of the
.Ar buffer
argument with
.Ar length
bytes size.
.Pp
The
.Fn magic_setflags
function, sets the
.Ar flags
described above.
.Pp
The
.Fn magic_check
function can be used to check the validity of entries in the colon
separated database files passed in as
.Ar filename ,
or NULL for the default database. It returns 0 on success and -1 on
failure.
.Pp
The
.Fn magic_compile
function can be used to compile the the colon
separated list of database files passed in as
.Ar filename ,
or NULL for the default database. It returns 0 on success and -1 on
failure. The compiled files created are named from the
.Xr basename 1
of each file argument with ".mgc" appended to it.
.Pp
The
.Fn magic_load
function must be used to load the the colon
separated list of database files passed in as
.Ar filename ,
or NULL for the default database file
before any magic queries can performed.
.Pp
The default database file is named by the MAGIC environment variable. If
that variable is not set, the default database file name is __MAGIC__.
.Pp
.Fn magic_load
adds ".mime" and/or ".mgc" to the database filename as appropriate.
.Sh RETURN VALUES
The function
.Fn magic_open
returns a magic cookie on success and NULL on failure setting errno to
an appropriate value. It will set errno to EINVAL if an unsupported
value for flags was given.
The
.Fn magic_load ,
.Fn magic_compile ,
and
.Fn magic_check
functions return 0 on success and -1 on failure.
The
.Fn magic_file ,
and
.Fn magic_buffer
functions return a string on success and NULL on failure. The
.Fn magic_error
function returns a textual description of the errors of the above
functions, or NULL if there was no error.
Finally,
.Fn magic_setflags
returns -1 on systems that don't support
.Xr utime 2 ,
or
.Xr utimes 2
when
.Dv MAGIC_PRESERVE_ATIME
is set.
.Sh FILES
.Bl -tag -width __MAGIC__.mime.mgc -compact
.It Pa __MAGIC__.mime
The non-compiled default magic mime database.
.It Pa __MAGIC__.mime.mgc
The compiled default magic mime database.
.It Pa __MAGIC__
The non-compiled default magic database.
.It Pa __MAGIC__.mgc
The compiled default magic database.
.El
.Sh SEE ALSO
.Xr file __CSECTION__ ,
.Xr magic __FSECTION__
.Sh AUTHORS
Måns Rullgård Initial libmagic implementation,
and configuration.
Christos Zoulas API cleanup, error code and allocation handling.

343
contrib/file/magic.c Normal file
View File

@ -0,0 +1,343 @@
/*
* Copyright (c) Christos Zoulas 2003.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "file.h"
#include "magic.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/param.h> /* for MAXPATHLEN */
#include <sys/stat.h>
#include <fcntl.h> /* for open() */
#ifdef QUICK
#include <sys/mman.h>
#endif
#if defined(HAVE_UTIMES)
# include <sys/time.h>
#elif defined(HAVE_UTIME)
# if defined(HAVE_SYS_UTIME_H)
# include <sys/utime.h>
# elif defined(HAVE_UTIME_H)
# include <utime.h>
# endif
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* for read() */
#endif
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include <netinet/in.h> /* for byte swapping */
#include "patchlevel.h"
#ifndef lint
FILE_RCSID("@(#)$Id: magic.c,v 1.22 2004/07/24 19:55:17 christos Exp $")
#endif /* lint */
#ifdef __EMX__
private char *apptypeName = NULL;
protected int file_os2_apptype(struct magic_set *ms, const char *fn,
const void *buf, size_t nb);
#endif /* __EMX__ */
private void free_mlist(struct mlist *);
private void close_and_restore(const struct magic_set *, const char *, int,
const struct stat *);
public struct magic_set *
magic_open(int flags)
{
struct magic_set *ms;
if ((ms = malloc(sizeof(struct magic_set))) == NULL)
return NULL;
if (magic_setflags(ms, flags) == -1) {
free(ms);
errno = EINVAL;
return NULL;
}
ms->o.ptr = ms->o.buf = malloc(ms->o.size = 1024);
ms->o.len = 0;
if (ms->o.buf == NULL) {
free(ms);
return NULL;
}
ms->o.pbuf = malloc(ms->o.psize = 1024);
if (ms->o.pbuf == NULL) {
free(ms->o.buf);
free(ms);
return NULL;
}
ms->c.off = malloc((ms->c.len = 10) * sizeof(*ms->c.off));
if (ms->c.off == NULL) {
free(ms->o.pbuf);
free(ms->o.buf);
free(ms);
return NULL;
}
ms->haderr = 0;
ms->error = -1;
ms->mlist = NULL;
return ms;
}
private void
free_mlist(struct mlist *mlist)
{
struct mlist *ml;
if (mlist == NULL)
return;
for (ml = mlist->next; ml != mlist;) {
struct mlist *next = ml->next;
struct magic *mg = ml->magic;
file_delmagic(mg, ml->mapped, ml->nmagic);
free(ml);
ml = next;
}
free(ml);
}
public void
magic_close(ms)
struct magic_set *ms;
{
free_mlist(ms->mlist);
free(ms->o.buf);
free(ms->c.off);
free(ms);
}
/*
* load a magic file
*/
public int
magic_load(struct magic_set *ms, const char *magicfile)
{
struct mlist *ml = file_apprentice(ms, magicfile, FILE_LOAD);
if (ml) {
free_mlist(ms->mlist);
ms->mlist = ml;
return 0;
}
return -1;
}
public int
magic_compile(struct magic_set *ms, const char *magicfile)
{
struct mlist *ml = file_apprentice(ms, magicfile, FILE_COMPILE);
free_mlist(ml);
return ml ? 0 : -1;
}
public int
magic_check(struct magic_set *ms, const char *magicfile)
{
struct mlist *ml = file_apprentice(ms, magicfile, FILE_CHECK);
free_mlist(ml);
return ml ? 0 : -1;
}
private void
close_and_restore(const struct magic_set *ms, const char *name, int fd,
const struct stat *sb)
{
(void) close(fd);
if (fd != STDIN_FILENO && (ms->flags & MAGIC_PRESERVE_ATIME) != 0) {
/*
* Try to restore access, modification times if read it.
* This is really *bad* because it will modify the status
* time of the file... And of course this will affect
* backup programs
*/
#ifdef HAVE_UTIMES
struct timeval utsbuf[2];
utsbuf[0].tv_sec = sb->st_atime;
utsbuf[1].tv_sec = sb->st_mtime;
(void) utimes(name, utsbuf); /* don't care if loses */
#elif defined(HAVE_UTIME_H) || defined(HAVE_SYS_UTIME_H)
struct utimbuf utbuf;
utbuf.actime = sb->st_atime;
utbuf.modtime = sb->st_mtime;
(void) utime(name, &utbuf); /* don't care if loses */
#endif
}
}
#ifndef COMPILE_ONLY
/*
* find type of named file
*/
public const char *
magic_file(struct magic_set *ms, const char *inname)
{
int fd = 0;
unsigned char buf[HOWMANY+1]; /* one extra for terminating '\0' */
struct stat sb;
ssize_t nbytes = 0; /* number of bytes read from a datafile */
if (file_reset(ms) == -1)
return NULL;
switch (file_fsmagic(ms, inname, &sb)) {
case -1:
return NULL;
case 0:
break;
default:
return file_getbuffer(ms);
}
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
if (inname == NULL)
fd = STDIN_FILENO;
else if ((fd = open(inname, O_RDONLY)) < 0) {
/* We cannot open it, but we were able to stat it. */
if (sb.st_mode & 0222)
if (file_printf(ms, "writable, ") == -1)
return NULL;
if (sb.st_mode & 0111)
if (file_printf(ms, "executable, ") == -1)
return NULL;
if (S_ISREG(sb.st_mode))
if (file_printf(ms, "regular file, ") == -1)
return NULL;
if (file_printf(ms, "no read permission") == -1)
return NULL;
return file_getbuffer(ms);
}
/*
* try looking at the first HOWMANY bytes
*/
if ((nbytes = read(fd, (char *)buf, HOWMANY)) == -1) {
file_error(ms, errno, "cannot read `%s'", inname);
goto done;
}
if (nbytes == 0) {
if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
"application/x-empty" : "empty") == -1)
goto done;
goto gotit;
} else if (nbytes == 1) {
if (file_printf(ms, "very short file (no magic)") == -1)
goto done;
goto gotit;
} else {
buf[nbytes] = '\0'; /* null-terminate it */
#ifdef __EMX__
switch (file_os2_apptype(ms, inname, buf, nbytes)) {
case -1:
goto done;
case 0:
break;
default:
goto gotit;
}
#endif
if (file_buffer(ms, buf, (size_t)nbytes) == -1)
goto done;
#ifdef BUILTIN_ELF
if (nbytes > 5) {
/*
* We matched something in the file, so this *might*
* be an ELF file, and the file is at least 5 bytes
* long, so if it's an ELF file it has at least one
* byte past the ELF magic number - try extracting
* information from the ELF headers that cannot easily
* be extracted with rules in the magic file.
*/
file_tryelf(ms, fd, buf, (size_t)nbytes);
}
#endif
}
gotit:
close_and_restore(ms, inname, fd, &sb);
return file_getbuffer(ms);
done:
close_and_restore(ms, inname, fd, &sb);
return NULL;
}
public const char *
magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
{
if (file_reset(ms) == -1)
return NULL;
/*
* The main work is done here!
* We have the file name and/or the data buffer to be identified.
*/
if (file_buffer(ms, buf, nb) == -1) {
return NULL;
}
return file_getbuffer(ms);
}
#endif
public const char *
magic_error(struct magic_set *ms)
{
return ms->haderr ? ms->o.buf : NULL;
}
public int
magic_errno(struct magic_set *ms)
{
return ms->haderr ? ms->error : 0;
}
public int
magic_setflags(struct magic_set *ms, int flags)
{
#if !defined(HAVE_UTIME) && !defined(HAVE_UTIMES)
if (flags & MAGIC_PRESERVE_ATIME)
return -1;
#endif
ms->flags = flags;
return 0;
}

69
contrib/file/magic.h Normal file
View File

@ -0,0 +1,69 @@
/*
* Copyright (c) Christos Zoulas 2003.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice immediately at the beginning of the file, without modification,
* this list of conditions, and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _MAGIC_H
#define _MAGIC_H
#include <sys/types.h>
#define MAGIC_NONE 0x000 /* No flags */
#define MAGIC_DEBUG 0x001 /* Turn on debugging */
#define MAGIC_SYMLINK 0x002 /* Follow symlinks */
#define MAGIC_COMPRESS 0x004 /* Check inside compressed files */
#define MAGIC_DEVICES 0x008 /* Look at the contents of devices */
#define MAGIC_MIME 0x010 /* Return a mime string */
#define MAGIC_CONTINUE 0x020 /* Return all matches */
#define MAGIC_CHECK 0x040 /* Print warnings to stderr */
#define MAGIC_PRESERVE_ATIME 0x080 /* Restore access time on exit */
#define MAGIC_RAW 0x100 /* Don't translate unprintable chars */
#define MAGIC_ERROR 0x200 /* Handle ENOENT etc as real errors */
#ifdef __cplusplus
extern "C" {
#endif
typedef struct magic_set *magic_t;
magic_t magic_open(int);
void magic_close(magic_t);
const char *magic_file(magic_t, const char *);
const char *magic_buffer(magic_t, const void *, size_t);
const char *magic_error(magic_t);
int magic_setflags(magic_t, int);
int magic_load(magic_t, const char *);
int magic_compile(magic_t, const char *);
int magic_check(magic_t, const char *);
int magic_errno(magic_t);
#ifdef __cplusplus
};
#endif
#endif /* _MAGIC_H */

Some files were not shown because too many files have changed in this diff Show More