Import file version 4.23 onto the vendor branch
This commit is contained in:
parent
17c6260f4c
commit
974b70c47d
@ -1,3 +1,84 @@
|
||||
2007-12-28 15:06 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* strtof detection
|
||||
|
||||
* remove bogus regex magic that could cause a DoS
|
||||
|
||||
* better mismatch version message
|
||||
|
||||
2007-12-27 11:35 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* bring back some fixes from OpenBSD
|
||||
|
||||
* treat ELF dynamic objects as executables
|
||||
|
||||
* fix gcc warnings
|
||||
|
||||
2007-12-01 19:55 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* make sure we have zlib.h and libz to compile the builtin
|
||||
decompress code
|
||||
|
||||
2007-10-28 20:48 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* float and double magic support (Behan Webster)
|
||||
|
||||
2007-10-28 20:48 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* Convert fortran to a soft test (Reuben Thomas)
|
||||
|
||||
2007-10-23 5:25 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* Add --with-filename, and --no-filename (Reuben Thomas)
|
||||
|
||||
2007-10-23 3:59 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* Rest of the mime split (Reuben Thomas)
|
||||
|
||||
* Make usage message generated from the flags so that
|
||||
they stay consistent (Reuben Thomas)
|
||||
|
||||
2007-10-20 3:06 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* typo in comment, missing ifdef QUICK, remove unneeded code
|
||||
(Charles Longeau)
|
||||
|
||||
2007-10-17 3:33 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* Fix problem printing -\012 in some entries
|
||||
|
||||
* Separate magic type and encoding flags (Reuben Thomas)
|
||||
|
||||
2007-10-09 3:55 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* configure fix for int64 and strndup (Reuben Thomas)
|
||||
|
||||
2007-09-26 4:45 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* Add magic_descriptor() function.
|
||||
|
||||
* Fix regression in elf reading code where the core name was
|
||||
not being printed.
|
||||
|
||||
* Don't convert NUL's to spaces in {l,b}estring16 (Daniel Dawson)
|
||||
|
||||
2007-08-19 6:30 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* Make mime format consistent so that it can
|
||||
be easily parsed:
|
||||
mimetype [charset=character-set] [encoding=encoding-mime-type]
|
||||
|
||||
Remove spurious extra text from some MIME type printouts
|
||||
(mostly in is_tar).
|
||||
|
||||
Fix one case where -i produced nothing at all (for a 1-byte file,
|
||||
which is now classed as application/octet-stream).
|
||||
|
||||
Remove 7/8bit classifications, since they were arbitrary
|
||||
and not based on the file data.
|
||||
|
||||
This work was done by Reuben Thomas
|
||||
|
||||
2007-05-24 10:00 Christos Zoulas <christos@zoulas.com>
|
||||
|
||||
* Fix another integer overflow (Colin Percival)
|
||||
|
@ -30,3 +30,38 @@
|
||||
0 string Maestro\r RISC OS music file
|
||||
>8 byte x version %d
|
||||
|
||||
>8 byte x type %d
|
||||
|
||||
# Digital Symphony data files
|
||||
# From: Bernard Jungen (bern8817@euphonynet.be)
|
||||
0 string \x02\x01\x13\x13\x13\x01\x0d\x10 Digital Symphony sound sample (RISC OS),
|
||||
>8 byte x version %d,
|
||||
>9 pstring x named "%s",
|
||||
>(9.b+19) byte =0 8-bit logarithmic
|
||||
>(9.b+19) byte =1 LZW-compressed linear
|
||||
>(9.b+19) byte =2 8-bit linear signed
|
||||
>(9.b+19) byte =3 16-bit linear signed
|
||||
>(9.b+19) byte =4 SigmaDelta-compressed linear
|
||||
>(9.b+19) byte =5 SigmaDelta-compressed logarithmic
|
||||
>(9.b+19) byte >5 unknown format
|
||||
|
||||
0 string \x02\x01\x13\x13\x14\x12\x01\x0b Digital Symphony song (RISC OS),
|
||||
>8 byte x version %d,
|
||||
>9 byte =1 1 voice,
|
||||
>9 byte !1 %d voices,
|
||||
>10 leshort =1 1 track,
|
||||
>10 leshort !1 %d tracks,
|
||||
>12 leshort =1 1 pattern
|
||||
>12 leshort !1 %d patterns
|
||||
|
||||
0 string \x02\x01\x13\x13\x10\x14\x12\x0e
|
||||
>9 byte =0 Digital Symphony sequence (RISC OS),
|
||||
>>8 byte x version %d,
|
||||
>>10 byte =1 1 line,
|
||||
>>10 byte !1 %d lines,
|
||||
>>11 leshort =1 1 position
|
||||
>>11 leshort !1 %d positions
|
||||
>9 byte =1 Digital Symphony pattern data (RISC OS),
|
||||
>>8 byte x version %d,
|
||||
>>10 leshort =1 1 pattern
|
||||
>>10 leshort !1 %d patterns
|
||||
|
@ -678,3 +678,14 @@
|
||||
>0x21 byte x v%x
|
||||
0 string DVDVIDEO-VMG Video manager,
|
||||
>0x21 byte x v%x
|
||||
|
||||
# From: Behan Webster <behanw@websterwood.com>
|
||||
# NuppelVideo used by Mythtv (*.nuv)
|
||||
0 regex NuppelVideo|MythTVVideo MythTV NuppelVideo
|
||||
>12 string x v%s
|
||||
>20 lelong x (%d
|
||||
>24 lelong x \bx%d),
|
||||
>36 string P \bprogressive,
|
||||
>36 string I \binterlaced,
|
||||
>40 ledouble x \baspect:%.2f,
|
||||
>48 ledouble x \bfps:%.2f
|
||||
|
@ -189,3 +189,44 @@
|
||||
>0 byte <5 \b
|
||||
>>13 byte 0x81 \b
|
||||
>>>14 uleshort x \b, system %hd
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# CAF: Apple CoreAudio File Format
|
||||
#
|
||||
# Container format for high-end audio purposes.
|
||||
# From: David Remahl <dremahl@apple.com>
|
||||
#
|
||||
0 string caff CoreAudio Format audio file
|
||||
>4 beshort <10 version %d
|
||||
>6 beshort x
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Keychain database files
|
||||
0 string kych Mac OS X Keychain File
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Code Signing related file types
|
||||
0 belong 0xfade0c00 Mac OS X Code Requirement
|
||||
>8 belong 1 (opExpr)
|
||||
>4 belong x - %d bytes
|
||||
|
||||
0 belong 0xfade0c01 Mac OS X Code Requirement Set
|
||||
>8 belong >1 containing %d items
|
||||
>4 belong x - %d bytes
|
||||
|
||||
0 belong 0xfade0c02 Mac OS X Code Directory
|
||||
>8 belong x version %x
|
||||
>12 belong >0 flags 0x%x
|
||||
>4 belong x - %d bytes
|
||||
|
||||
0 belong 0xfade0cc0 Mac OS X Detached Code Signature (non-executable)
|
||||
>4 belong x - %d bytes
|
||||
|
||||
0 belong 0xfade0cc1 Mac OS X Detached Code Signature
|
||||
>8 belong >1 (%d elements)
|
||||
>4 belong x - %d bytes
|
||||
|
||||
# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
|
||||
# .vdi
|
||||
4 string innotek\ VirtualBox\ Disk\ Image %s
|
||||
|
@ -531,6 +531,7 @@
|
||||
|
||||
# ZIP archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu)
|
||||
0 string PK\003\004
|
||||
>4 byte 0x00 Zip archive data
|
||||
>4 byte 0x09 Zip archive data, at least v0.9 to extract
|
||||
>4 byte 0x0a Zip archive data, at least v1.0 to extract
|
||||
>4 byte 0x0b Zip archive data, at least v1.1 to extract
|
||||
@ -731,3 +732,19 @@
|
||||
>4 lelong 0x1000006D (EPOC release 3/4/5)
|
||||
>4 lelong 0x10003A12 (EPOC release 6)
|
||||
0 lelong 0x10201A7A Symbian installation file (Symbian OS 9.x)
|
||||
|
||||
# Pack200 Java archives, http://jcp.org/en/jsr/detail?id=200
|
||||
0 belong 0xcafed00d Pack200 Java archive
|
||||
|
||||
# From "Nelson A. de Oliveira" <naoliv@gmail.com>
|
||||
0 string MPQ\032 MoPaQ (MPQ) archive
|
||||
|
||||
# From: Dirk Jagdmann <doj@cubic.org>
|
||||
# xar archive format: http://code.google.com/p/xar/
|
||||
0 string xar! xar archive
|
||||
>6 beshort x - version %ld
|
||||
|
||||
# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
|
||||
# .kgb
|
||||
0 string KGB_arch KGB Archiver file
|
||||
>10 string x with compression level %.1s
|
||||
|
@ -556,3 +556,10 @@
|
||||
# From: Matthew Flaschen <matthew.flaschen@gatech.edu>
|
||||
0 string #EXTM3U M3U playlist text
|
||||
|
||||
# From: "Mateus Caruccio" <mateus@caruccio.com>
|
||||
# guitar pro v3,4,5 from http://filext.com/file-extension/gp3
|
||||
0 string \030FICHIER\ GUITAR\ PRO\ v3. Guitar Pro Ver. 3 Tablature
|
||||
|
||||
# From: "Leslie P. Polzer" <leslie.polzer@gmx.net>
|
||||
60 string SONG SoundFX Module sound file
|
||||
|
||||
|
@ -1,17 +1,37 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# blender: file(1) magic for Blender 3D data files
|
||||
# blender: file(1) magic for Blender 3D related files
|
||||
#
|
||||
# Coded by Guillermo S. Romero <gsromero@alumnos.euitt.upm.es> using the
|
||||
# data from Ton Roosendaal <ton@blender.nl>. Ton or his company do not
|
||||
# support the rule, so mail GSR if problems with it. Rule version: 1.1.
|
||||
# You can get latest version with comments and details about the format
|
||||
# at http://acd.asoc.euitt.upm.es/~gsromero/3d/blender/magic.blender
|
||||
# Native format rule v1.2. For questions use the developers list
|
||||
# http://lists.blender.org/mailman/listinfo/bf-committers
|
||||
# GLOB chunk was moved near start and provides subversion info since 2.42
|
||||
|
||||
0 string =BLENDER Blender3D,
|
||||
>7 string =_ saved as 32-bits
|
||||
>7 string =- saved as 64-bits
|
||||
>8 string =v little endian
|
||||
>8 string =V big endian
|
||||
>9 byte x with version %c.
|
||||
>10 byte x \b%c
|
||||
>11 byte x \b%c
|
||||
0 string =BLENDER Blender3D,
|
||||
>7 string =_ saved as 32-bits
|
||||
>>8 string =v little endian
|
||||
>>>9 byte x with version %c.
|
||||
>>>10 byte x \b%c
|
||||
>>>11 byte x \b%c
|
||||
>>>0x40 string =GLOB \b.
|
||||
>>>>0x58 leshort x \b%.4d
|
||||
>>8 string =V big endian
|
||||
>>>9 byte x with version %c.
|
||||
>>>10 byte x \b%c
|
||||
>>>11 byte x \b%c
|
||||
>>>0x40 string =GLOB \b.
|
||||
>>>>0x58 beshort x \b%.4d
|
||||
>7 string =- saved as 64-bits
|
||||
>>8 string =v little endian
|
||||
>>9 byte x with version %c.
|
||||
>>10 byte x \b%c
|
||||
>>11 byte x \b%c
|
||||
>>0x44 string =GLOB \b.
|
||||
>>>0x60 leshort x \b%.4d
|
||||
>>8 string =V big endian
|
||||
>>>9 byte x with version %c.
|
||||
>>>10 byte x \b%c
|
||||
>>>11 byte x \b%c
|
||||
>>>0x44 string =GLOB \b.
|
||||
>>>>0x60 beshort x \b%.4d
|
||||
|
||||
# Scripts that run in the embeded Python interpreter
|
||||
0 string #!BPY Blender3D BPython script
|
||||
|
@ -28,7 +28,8 @@
|
||||
0 string/b #!\ /bin/awk awk script text executable
|
||||
0 string/b #!\ /usr/bin/awk awk script text executable
|
||||
# update to distinguish from *.vcf files
|
||||
0 regex BEGIN[[:space:]]*[{] awk script text
|
||||
# this is broken because postscript has /EBEGIN{ for example.
|
||||
#0 regex BEGIN[[:space:]]*[{] awk script text
|
||||
|
||||
# AT&T Bell Labs' Plan 9 shell
|
||||
0 string/b #!\ /bin/rc Plan 9 rc shell script text executable
|
||||
|
@ -191,3 +191,64 @@
|
||||
0 string PPF10 Playstation Patch File version 1.0
|
||||
>5 byte 0 \b, Simple Encoding
|
||||
>6 string x \b, description: %s
|
||||
|
||||
# From: Daniel Dawson <ddawson@icehouse.net>
|
||||
# SNES9x .smv "movie" file format.
|
||||
0 string SMV\x1A SNES9x input recording
|
||||
>0x4 lelong x \b, version %d
|
||||
# version 4 is latest so far
|
||||
>0x4 lelong <5
|
||||
>>0x8 ledate x \b, recorded at %s
|
||||
>>0xc lelong >0 \b, rerecorded %d times
|
||||
>>0x10 lelong x \b, %d frames long
|
||||
>>0x14 byte >0 \b, data for controller(s):
|
||||
>>>0x14 byte &0x1 #1
|
||||
>>>0x14 byte &0x2 #2
|
||||
>>>0x14 byte &0x4 #3
|
||||
>>>0x14 byte &0x8 #4
|
||||
>>>0x14 byte &0x10 #5
|
||||
>>0x15 byte ^0x1 \b, begins from snapshot
|
||||
>>0x15 byte &0x1 \b, begins from reset
|
||||
>>0x15 byte ^0x2 \b, NTSC standard
|
||||
>>0x15 byte &0x2 \b, PAL standard
|
||||
>>0x17 byte &0x1 \b, settings:
|
||||
# WIP1Timing not used as of version 4
|
||||
>>>0x4 lelong <4
|
||||
>>>>0x17 byte &0x2 WIP1Timing
|
||||
>>>0x17 byte &0x4 Left+Right
|
||||
>>>0x17 byte &0x8 VolumeEnvX
|
||||
>>>0x17 byte &0x10 FakeMute
|
||||
>>>0x17 byte &0x20 SyncSound
|
||||
# New flag as of version 4
|
||||
>>>0x4 lelong >3
|
||||
>>>>0x17 byte &0x80 NoCPUShutdown
|
||||
>>0x4 lelong <4
|
||||
>>>0x18 lelong >0x23
|
||||
>>>>0x20 leshort !0
|
||||
>>>>>0x20 lestring16 x \b, metadata: "%s"
|
||||
>>0x4 lelong >3
|
||||
>>>0x24 byte >0 \b, port 1:
|
||||
>>>>0x24 byte 1 joypad
|
||||
>>>>0x24 byte 2 mouse
|
||||
>>>>0x24 byte 3 SuperScope
|
||||
>>>>0x24 byte 4 Justifier
|
||||
>>>>0x24 byte 5 multitap
|
||||
>>>0x24 byte >0 \b, port 2:
|
||||
>>>>0x25 byte 1 joypad
|
||||
>>>>0x25 byte 2 mouse
|
||||
>>>>0x25 byte 3 SuperScope
|
||||
>>>>0x25 byte 4 Justifier
|
||||
>>>>0x25 byte 5 multitap
|
||||
>>>0x18 lelong >0x43
|
||||
>>>>0x40 leshort !0
|
||||
>>>>>0x40 lestring16 x \b, metadata: "%s"
|
||||
>>0x17 byte &0x40 \b, ROM:
|
||||
>>>(0x18.l-26) lelong x CRC32 0x%08x
|
||||
>>>(0x18.l-23) string x "%s"
|
||||
|
||||
# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
|
||||
# .w3g
|
||||
0 string Warcraft\ III\ recorded\ game %s
|
||||
# .w3m
|
||||
0 string HM3W Warcraft III map file
|
||||
|
||||
|
@ -210,3 +210,13 @@
|
||||
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
|
||||
|
||||
# From: Maxime Henrion <mux@FreeBSD.org>
|
||||
# PostgreSQL's custom dump format, Maxime Henrion <mux@FreeBSD.org>
|
||||
0 string PGDMP PostgreSQL custom database dump
|
||||
>5 byte x - v%d
|
||||
>6 byte x \b.%d
|
||||
>5 beshort <=0x100 \b-0
|
||||
>5 beshort >0x100
|
||||
>>7 byte x \b-%d
|
||||
|
||||
|
14
contrib/file/Magdir/efi
Normal file
14
contrib/file/Magdir/efi
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# efi: file(1) magic for Universal EFI binaries
|
||||
|
||||
0 lelong 0x0ef1fab9
|
||||
>4 lelong 1 Universal EFI binary with 1 architecture
|
||||
>>&0 lelong 7 \b, i386
|
||||
>>&0 lelong 0x01000007 \b, x86_64
|
||||
>4 lelong 2 Universal EFI binary with 2 architectures
|
||||
>>&0 lelong 7 \b, i386
|
||||
>>&0 lelong 0x01000007 \b, x86_64
|
||||
>>&20 lelong 7 \b, i386
|
||||
>>&20 lelong 0x01000007 \b, x86_64
|
||||
>4 lelong >2 Universal EFI binary with %ld architectures
|
@ -51,10 +51,10 @@
|
||||
>>>>36 lelong&0xf0000000 0x20000000 MIPS-III
|
||||
>>>>36 lelong&0xf0000000 0x30000000 MIPS-IV
|
||||
>>>>36 lelong&0xf0000000 0x40000000 MIPS-V
|
||||
>>>>36 lelong&0xf0000000 0x60000000 MIPS32
|
||||
>>>>36 lelong&0xf0000000 0x70000000 MIPS64
|
||||
>>>>36 lelong&0xf0000000 0x80000000 MIPS32 rel2
|
||||
>>>>36 lelong&0xf0000000 0x90000000 MIPS64 rel2
|
||||
>>>>36 lelong&0xf0000000 0x50000000 MIPS32
|
||||
>>>>36 lelong&0xf0000000 0x60000000 MIPS64
|
||||
>>>>36 lelong&0xf0000000 0x70000000 MIPS32 rel2
|
||||
>>>>36 lelong&0xf0000000 0x80000000 MIPS64 rel2
|
||||
# only for 64-bit
|
||||
>>>4 byte 2
|
||||
>>>>48 lelong&0xf0000000 0x00000000 MIPS-I
|
||||
@ -62,10 +62,10 @@
|
||||
>>>>48 lelong&0xf0000000 0x20000000 MIPS-III
|
||||
>>>>48 lelong&0xf0000000 0x30000000 MIPS-IV
|
||||
>>>>48 lelong&0xf0000000 0x40000000 MIPS-V
|
||||
>>>>48 lelong&0xf0000000 0x60000000 MIPS32
|
||||
>>>>48 lelong&0xf0000000 0x70000000 MIPS64
|
||||
>>>>48 lelong&0xf0000000 0x80000000 MIPS32 rel2
|
||||
>>>>48 lelong&0xf0000000 0x90000000 MIPS64 rel2
|
||||
>>>>48 lelong&0xf0000000 0x50000000 MIPS32
|
||||
>>>>48 lelong&0xf0000000 0x60000000 MIPS64
|
||||
>>>>48 lelong&0xf0000000 0x70000000 MIPS32 rel2
|
||||
>>>>48 lelong&0xf0000000 0x80000000 MIPS64 rel2
|
||||
>>18 leshort 9 Amdahl - invalid byte order,
|
||||
>>18 leshort 10 MIPS (deprecated),
|
||||
>>18 leshort 11 RS6000 - invalid byte order,
|
||||
@ -139,10 +139,10 @@
|
||||
>>>>36 belong&0xf0000000 0x20000000 MIPS-III
|
||||
>>>>36 belong&0xf0000000 0x30000000 MIPS-IV
|
||||
>>>>36 belong&0xf0000000 0x40000000 MIPS-V
|
||||
>>>>36 belong&0xf0000000 0x60000000 MIPS32
|
||||
>>>>36 belong&0xf0000000 0x70000000 MIPS64
|
||||
>>>>36 belong&0xf0000000 0x80000000 MIPS32 rel2
|
||||
>>>>36 belong&0xf0000000 0x90000000 MIPS64 rel2
|
||||
>>>>36 belong&0xf0000000 0x50000000 MIPS32
|
||||
>>>>36 belong&0xf0000000 0x60000000 MIPS64
|
||||
>>>>36 belong&0xf0000000 0x70000000 MIPS32 rel2
|
||||
>>>>36 belong&0xf0000000 0x80000000 MIPS64 rel2
|
||||
# only for 64-bit
|
||||
>>>4 byte 2
|
||||
>>>>48 belong&0xf0000000 0x00000000 MIPS-I
|
||||
@ -150,10 +150,10 @@
|
||||
>>>>48 belong&0xf0000000 0x20000000 MIPS-III
|
||||
>>>>48 belong&0xf0000000 0x30000000 MIPS-IV
|
||||
>>>>48 belong&0xf0000000 0x40000000 MIPS-V
|
||||
>>>>48 belong&0xf0000000 0x60000000 MIPS32
|
||||
>>>>48 belong&0xf0000000 0x70000000 MIPS64
|
||||
>>>>48 belong&0xf0000000 0x80000000 MIPS32 rel2
|
||||
>>>>48 belong&0xf0000000 0x90000000 MIPS64 rel2
|
||||
>>>>48 belong&0xf0000000 0x50000000 MIPS32
|
||||
>>>>48 belong&0xf0000000 0x60000000 MIPS64
|
||||
>>>>48 belong&0xf0000000 0x70000000 MIPS32 rel2
|
||||
>>>>48 belong&0xf0000000 0x80000000 MIPS64 rel2
|
||||
>>18 beshort 9 Amdahl,
|
||||
>>18 beshort 10 MIPS (deprecated),
|
||||
>>18 beshort 11 RS6000,
|
||||
@ -196,6 +196,7 @@
|
||||
>>18 beshort 88 Renesas M32R,
|
||||
>>18 beshort 94 Tensilica Xtensa,
|
||||
>>18 beshort 97 NatSemi 32k,
|
||||
>>18 beshort 0x18ad AVR32 (unofficial),
|
||||
>>18 beshort 0x9026 Alpha (unofficial),
|
||||
>>18 beshort 0xa390 IBM S/390 (obsolete),
|
||||
>>20 belong 0 invalid version
|
||||
|
@ -52,7 +52,13 @@
|
||||
>>>>11 ulelong >0 \b, %d sectors/track
|
||||
>>>>15 ulelong >0 \b, %d cylinders
|
||||
|
||||
# updated by Joerg Jenderek at Sep 2007
|
||||
# only for sector sizes with 512 or more Bytes
|
||||
0x1FE leshort 0xAA55 x86 boot sector
|
||||
# to do also for sectors < than 512 Bytes and some other files, GRR
|
||||
#30 search/481 \x55\xAA x86 boot sector
|
||||
# not for BeOS floppy 1440k, MBRs
|
||||
#(11.s-2) uleshort 0xAA55 x86 boot sector
|
||||
>2 string OSBS \b, OS/BS MBR
|
||||
# J\xf6rg Jenderek <joerg dot jenderek at web dot de>
|
||||
>0x8C string Invalid\ partition\ table \b, MS-DOS MBR
|
||||
@ -173,56 +179,59 @@
|
||||
>>498 string BCDL\ \ \ \ BIN \b, Bootable CD Loader (1.50Z)
|
||||
# mbr partion table entries
|
||||
# OEM-ID not Microsoft,SYSLINUX,or MTOOLs
|
||||
>3 string !MS
|
||||
>3 string !MS
|
||||
>>3 string !SYSLINUX
|
||||
>>>3 string !MTOOL
|
||||
# not FAT (32 bit)
|
||||
>>>>82 string !FAT32
|
||||
#not IO.SYS
|
||||
>>>>>472 string !IO\ \ \ \ \ \ SYS
|
||||
>>>>>>480 string !IO\ \ \ \ \ \ SYS
|
||||
#not Linux kernel
|
||||
>>>>>>514 string !HdrS
|
||||
>>>>>>>514 string !HdrS
|
||||
#not BeOS
|
||||
>>>>>>>>422 string !Be\ Boot\ Loader
|
||||
# active flag 0 or 0x80 and type > 0
|
||||
>>>>>>>446 ubyte <0x81
|
||||
>>>>>>>>446 ubyte&0x7F 0
|
||||
>>>>>>>>>446 ubyte <0x81
|
||||
>>>>>>>>>>446 ubyte&0x7F 0
|
||||
>>>>>>>>>>>450 ubyte >0 \b; partition 1: ID=0x%x
|
||||
>>>>>>>>>>446 ubyte 0x80 \b, active
|
||||
>>>>>>>>>>447 ubyte x \b, starthead %u
|
||||
#>>>>>>>>>>448 ubyte x \b, start C_S: 0x%x
|
||||
#>>>>>>>>>>448 ubeshort&1023 x \b, startcylinder? %d
|
||||
>>>>>>>>>>454 ulelong x \b, startsector %u
|
||||
>>>>>>>>>>458 ulelong x \b, %u sectors
|
||||
>>>>>>>>>>>>446 ubyte 0x80 \b, active
|
||||
>>>>>>>>>>>>447 ubyte x \b, starthead %u
|
||||
#>>>>>>>>>>>>448 ubyte x \b, start C_S: 0x%x
|
||||
#>>>>>>>>>>>>448 ubeshort&1023 x \b, startcylinder? %d
|
||||
>>>>>>>>>>>>454 ulelong x \b, startsector %u
|
||||
>>>>>>>>>>>>458 ulelong x \b, %u sectors
|
||||
#
|
||||
>>>>>>>462 ubyte <0x81
|
||||
>>>>>>>>462 ubyte&0x7F 0
|
||||
>>>>>>>>>466 ubyte >0 \b; partition 2: ID=0x%x
|
||||
>>>>>>>>>>462 ubyte 0x80 \b, active
|
||||
>>>>>>>>>>463 ubyte x \b, starthead %u
|
||||
#>>>>>>>>>>464 ubyte x \b, start C_S: 0x%x
|
||||
#>>>>>>>>>>464 ubeshort&1023 x \b, startcylinder? %d
|
||||
>>>>>>>>>>470 ulelong x \b, startsector %u
|
||||
>>>>>>>>>>474 ulelong x \b, %u sectors
|
||||
>>>>>>>>>462 ubyte <0x81
|
||||
>>>>>>>>>>462 ubyte&0x7F 0
|
||||
>>>>>>>>>>>466 ubyte >0 \b; partition 2: ID=0x%x
|
||||
>>>>>>>>>>>>462 ubyte 0x80 \b, active
|
||||
>>>>>>>>>>>>463 ubyte x \b, starthead %u
|
||||
#>>>>>>>>>>>>464 ubyte x \b, start C_S: 0x%x
|
||||
#>>>>>>>>>>>>464 ubeshort&1023 x \b, startcylinder? %d
|
||||
>>>>>>>>>>>>470 ulelong x \b, startsector %u
|
||||
>>>>>>>>>>>>474 ulelong x \b, %u sectors
|
||||
#
|
||||
>>>>>>>478 ubyte <0x81
|
||||
>>>>>>>>478 ubyte&0x7F 0
|
||||
>>>>>>>>>482 ubyte >0 \b; partition 3: ID=0x%x
|
||||
>>>>>>>>>>478 ubyte 0x80 \b, active
|
||||
>>>>>>>>>>479 ubyte x \b, starthead %u
|
||||
#>>>>>>>>>>480 ubyte x \b, start C_S: 0x%x
|
||||
#>>>>>>>>>>481 ubyte x \b, start C2S: 0x%x
|
||||
#>>>>>>>>>>480 ubeshort&1023 x \b, startcylinder? %d
|
||||
>>>>>>>>>>486 ulelong x \b, startsector %u
|
||||
>>>>>>>>>>490 ulelong x \b, %u sectors
|
||||
>>>>>>>>>478 ubyte <0x81
|
||||
>>>>>>>>>>478 ubyte&0x7F 0
|
||||
>>>>>>>>>>>482 ubyte >0 \b; partition 3: ID=0x%x
|
||||
>>>>>>>>>>>>478 ubyte 0x80 \b, active
|
||||
>>>>>>>>>>>>479 ubyte x \b, starthead %u
|
||||
#>>>>>>>>>>>>480 ubyte x \b, start C_S: 0x%x
|
||||
#>>>>>>>>>>>>481 ubyte x \b, start C2S: 0x%x
|
||||
#>>>>>>>>>>>>480 ubeshort&1023 x \b, startcylinder? %d
|
||||
>>>>>>>>>>>>486 ulelong x \b, startsector %u
|
||||
>>>>>>>>>>>>490 ulelong x \b, %u sectors
|
||||
#
|
||||
>>>>>>>494 ubyte <0x81
|
||||
>>>>>>>>494 ubyte&0x7F 0
|
||||
>>>>>>>>>498 ubyte >0 \b; partition 4: ID=0x%x
|
||||
>>>>>>>>>>494 ubyte 0x80 \b, active
|
||||
>>>>>>>>>>495 ubyte x \b, starthead %u
|
||||
#>>>>>>>>>>496 ubyte x \b, start C_S: 0x%x
|
||||
#>>>>>>>>>>496 ubeshort&1023 x \b, startcylinder? %d
|
||||
>>>>>>>>>>502 ulelong x \b, startsector %u
|
||||
>>>>>>>>>>506 ulelong x \b, %u sectors
|
||||
>>>>>>>>>494 ubyte <0x81
|
||||
>>>>>>>>>>494 ubyte&0x7F 0
|
||||
>>>>>>>>>>>498 ubyte >0 \b; partition 4: ID=0x%x
|
||||
>>>>>>>>>>>>494 ubyte 0x80 \b, active
|
||||
>>>>>>>>>>>>495 ubyte x \b, starthead %u
|
||||
#>>>>>>>>>>>>496 ubyte x \b, start C_S: 0x%x
|
||||
#>>>>>>>>>>>>496 ubeshort&1023 x \b, startcylinder? %d
|
||||
>>>>>>>>>>>>502 ulelong x \b, startsector %u
|
||||
>>>>>>>>>>>>506 ulelong x \b, %u sectors
|
||||
# mbr partion table entries end
|
||||
# http://www.acronis.de/
|
||||
#FAT label=ACRONIS\ SZ
|
||||
@ -507,34 +516,52 @@
|
||||
>>>>>>>498 ubyte&0xDF >0
|
||||
>>>>>>>>498 string x \b.%-.3s
|
||||
#
|
||||
>486 ubyte&0xDF >0
|
||||
>>416 string Non-System\ disk\ or\
|
||||
>>>435 string disk\ error\r
|
||||
>>>>447 string Replace\ and\ press\ any\ key\
|
||||
>>>>>473 string when\ ready\r \b, Microsoft DOS Bootloader
|
||||
>480 ubyte&0xDF >0
|
||||
>>393 string Non-System\ disk\ or\
|
||||
>>>412 string disk\ error\r
|
||||
>>>>424 string Replace\ and\ press\ any\ key\
|
||||
>>>>>450 string when\ ready\r \b, Microsoft DOS bootloader
|
||||
#IO.SYS
|
||||
>>>>>480 string x \b %-.2s
|
||||
>>>>>>482 ubyte&0xDF >0
|
||||
>>>>>>>48 string x \b%-.6s
|
||||
>>>>>488 ubyte&0xDF >0
|
||||
>>>>>>488 string x \b.%-.3s
|
||||
#MSDOS.SYS
|
||||
>>>>>>491 ubyte&0xDF >0 \b+
|
||||
>>>>>>>491 string x \b%-.5s
|
||||
>>>>>>>>496 ubyte&0xDF >0
|
||||
>>>>>>>>>496 string x \b%-.3s
|
||||
>>>>>>>499 ubyte&0xDF >0
|
||||
>>>>>>>>499 string x \b.%-.3s
|
||||
>376 search/41 Non-System\ disk\ or\
|
||||
>>395 search/41 disk\ error\r
|
||||
>>>407 search/41 Replace\ and\
|
||||
>>>>419 search/41 press\ \b,
|
||||
>>>>419 search/41 strike\ \b, old
|
||||
>>>>426 search/41 any\ key\ when\ ready\r MS or PC-DOS bootloader
|
||||
#449 Disk\ Boot\ failure\r MS 3.21
|
||||
#466 Boot\ Failure\r MS 3.30
|
||||
>>>>>468 search/18 \0
|
||||
#IO.SYS,IBMBIO.COM
|
||||
>>>>>>&0 string x \b %-.2s
|
||||
>>>>>>>&-20 ubyte&0xDF >0
|
||||
>>>>>>>>&-1 string x \b%-.4s
|
||||
>>>>>>>>>&-16 ubyte&0xDF >0
|
||||
>>>>>>>>>>&-1 string x \b%-.2s
|
||||
>>>>>>&8 ubyte&0xDF >0 \b.
|
||||
>>>>>>>&-1 string x \b%-.3s
|
||||
#MSDOS.SYS,IBMDOS.COM
|
||||
>>>>>>&11 ubyte&0xDF >0 \b+
|
||||
>>>>>>>&-1 string x \b%-.5s
|
||||
>>>>>>>>&-6 ubyte&0xDF >0
|
||||
>>>>>>>>>&-1 string x \b%-.1s
|
||||
>>>>>>>>>>&-5 ubyte&0xDF >0
|
||||
>>>>>>>>>>>&-1 string x \b%-.2s
|
||||
>>>>>>>&7 ubyte&0xDF >0 \b.
|
||||
>>>>>>>>&-1 string x \b%-.3s
|
||||
>441 string Cannot\ load\ from\ harddisk.\n\r
|
||||
>>469 string Insert\ Systemdisk\
|
||||
>>>487 string and\ press\ any\ key.\n\r \b, MS (2.11) DOS bootloader
|
||||
#>43 string \224R-LOADER\ \ SYS =label
|
||||
>54 string SYS
|
||||
>>324 string VASKK
|
||||
>>>495 string NEWLDR\0 \b, DR-DOS Bootloader (LOADER.SYS)
|
||||
#
|
||||
>98 string Press\ a\ key\ to\ retry\0\r
|
||||
>>120 string Cannot\ find\ file\ \0\r
|
||||
>>>139 string Disk\ read\ error\0\r
|
||||
>>>>156 string Loading\ ...\0 \b, DR-DOS (3.41) Bootloader
|
||||
#DRBIOS.SYS
|
||||
>>>>>44 ubyte&0xDF >0
|
||||
>>>>>>44 string x \b %-.6s
|
||||
>>>>>>>50 ubyte&0xDF >0
|
||||
>>>>>>>>50 string x \b%-.2s
|
||||
>>>>>>52 ubyte&0xDF >0
|
||||
>>>>>>>52 string x \b.%-.3s
|
||||
#
|
||||
>70 string IBMBIO\ \ COM
|
||||
>>472 string Cannot\ load\ DOS!\
|
||||
>>>489 string Any\ key\ to\ retry \b, DR-DOS Bootloader
|
||||
@ -679,26 +706,43 @@
|
||||
#it also hangs with another message ("NF").
|
||||
>>>>>492 string RENF \b, FAT (12 bit)
|
||||
>>>>>495 string RENF \b, FAT (16 bit)
|
||||
# added by Joerg Jenderek
|
||||
# http://syslinux.zytor.com/iso.php
|
||||
0 ulelong 0x7c40eafa isolinux Loader
|
||||
# http://syslinux.zytor.com/pxe.php
|
||||
0 ulelong 0x007c05ea pxelinux Loader
|
||||
0 ulelong 0x60669c66 pxelinux Loader
|
||||
# loader end
|
||||
# Joerg Jenderek
|
||||
>446 ubyte 0
|
||||
>>450 ubyte >0
|
||||
>>>482 ubyte 0
|
||||
>>>>498 ubyte 0
|
||||
>>>>466 ubyte 0x05 \b, extended partition table
|
||||
>>>>466 ubyte 0x0F \b, extended partition table (LBA)
|
||||
>>>>466 ubyte 0x0 \b, extended partition table (last)
|
||||
# updated by Joerg Jenderek at Sep 2007
|
||||
>3 ubyte 0
|
||||
#no active flag
|
||||
>>446 ubyte 0
|
||||
# partition 1 not empty
|
||||
>>>450 ubyte >0
|
||||
# partitions 3,4 empty
|
||||
>>>>482 ubyte 0
|
||||
>>>>>498 ubyte 0
|
||||
# partition 2 ID=0,5,15
|
||||
>>>>>>466 ubyte <0x10
|
||||
>>>>>>>466 ubyte 0x05 \b, extended partition table
|
||||
>>>>>>>466 ubyte 0x0F \b, extended partition table (LBA)
|
||||
>>>>>>>466 ubyte 0x0 \b, extended partition table (last)
|
||||
# JuMP short bootcodeoffset NOP assembler instructions will usually be EB xx 90
|
||||
# older drives may use E9 xx xx
|
||||
# http://mirror.href.com/thestarman/asm/2bytejumps.htmm#FWD
|
||||
# older drives may use Near JuMP instruction E9 xx xx
|
||||
>0 lelong&0x009000EB 0x009000EB
|
||||
>0 lelong&0x000000E9 0x000000E9
|
||||
>>1 ubyte >37 \b, code offset 0x%x
|
||||
# maximal short forward jump is 07fx
|
||||
>1 ubyte <0xff \b, code offset 0x%x
|
||||
# mtools-3.9.8/msdos.h
|
||||
# usual values are marked with comments to get only informations of strange FAT systems
|
||||
# valid sectorsize are from 32 to 2048
|
||||
>>>11 uleshort <2049
|
||||
>>>>11 uleshort >31
|
||||
# valid sectorsize must be a power of 2 from 32 to 32768
|
||||
>>11 uleshort&0x000f x
|
||||
>>>11 uleshort <32769
|
||||
>>>>11 uleshort >31
|
||||
>>>>>3 string >\0 \b, OEM-ID "%8.8s"
|
||||
#http://mirror.href.com/thestarman/asm/debug/debug2.htm#IHC
|
||||
>>>>>>8 string IHC \b cached by Windows 9M
|
||||
>>>>>11 uleshort >512 \b, Bytes/sector %u
|
||||
#>>>>>11 uleshort =512 \b, Bytes/sector %u=512 (usual)
|
||||
>>>>>11 uleshort <512 \b, Bytes/sector %u
|
||||
@ -725,17 +769,18 @@
|
||||
>>>>>26 ubyte >2 \b, heads %u
|
||||
#>>>>>26 ubyte =2 \b, heads %u (usual floppy)
|
||||
>>>>>26 ubyte =1 \b, heads %u
|
||||
>>>>>28 ulelong >0 \b, hidden sectors %u
|
||||
#>>>>>28 ulelong =0 \b, hidden sectors %u (usual floppy)
|
||||
>>>>>32 ulelong >0 \b, sectors %u (volumes > 32 MB)
|
||||
#>>>>>32 ulelong =0 \b, sectors %u (volumes > 32 MB)
|
||||
#skip for Digital Research DOS (version 3.41) 1440 kB Bootdisk
|
||||
>>>>>38 ubyte !0x70
|
||||
>>>>>>28 ulelong >0 \b, hidden sectors %u
|
||||
#>>>>>>28 ulelong =0 \b, hidden sectors %u (usual floppy)
|
||||
>>>>>>32 ulelong >0 \b, sectors %u (volumes > 32 MB)
|
||||
#>>>>>>32 ulelong =0 \b, sectors %u (volumes > 32 MB)
|
||||
# FAT<32 specific
|
||||
# NOT le FAT3=NOT 3TAF=0xCCABBEB9
|
||||
>>>>>82 ulelong&0xCCABBEB9 >0
|
||||
>>>>>>36 ubyte >0x80 \b, physical drive 0x%x
|
||||
#>>>>>>36 ubyte =0x80 \b, physical drive 0x%x=0x80 (usual harddisk)
|
||||
>>>>>>36 ubyte&0x7F >0 \b, physical drive 0x%x
|
||||
#>>>>>>36 ubyte =0 \b, physical drive 0x%x=0 (usual floppy)
|
||||
>>>>>82 string !FAT32
|
||||
#>>>>>>36 ubyte 0x80 \b, physical drive 0x%x=0x80 (usual harddisk)
|
||||
#>>>>>>36 ubyte 0 \b, physical drive 0x%x=0 (usual floppy)
|
||||
>>>>>>36 ubyte !0x80
|
||||
>>>>>>>36 ubyte !0 \b, physical drive 0x%x
|
||||
>>>>>>37 ubyte >0 \b, reserved 0x%x
|
||||
#>>>>>>37 ubyte =0 \b, reserved 0x%x
|
||||
>>>>>>38 ubyte >0x29 \b, dos < 4.0 BootSector (0x%x)
|
||||
@ -1072,13 +1117,12 @@
|
||||
# Modified for UDF by gerardo.cacciari@gmail.com
|
||||
32769 string CD001
|
||||
>38913 string !NSR0 ISO 9660 CD-ROM filesystem data
|
||||
>38913 string NSR01 UDF filesystem data (version 1.0)
|
||||
>38913 string NSR02 UDF filesystem data (version 1.5)
|
||||
>38913 string NSR03 UDF filesystem data (version 2.0)
|
||||
>38913 string >NSR03 UDF filesystem data (unknown version,
|
||||
>>38917 byte x id 'NSR0%c')
|
||||
>38913 string <NSR01 UDF filesystem data (unknown version,
|
||||
>>38917 byte x id 'NSR0%c')
|
||||
>38913 string NSR0 UDF filesystem data
|
||||
>>38917 string 1 (version 1.0)
|
||||
>>38917 string 2 (version 1.5)
|
||||
>>38917 string 3 (version 2.0)
|
||||
>>38917 byte >0x33 (unknown version, ID 0x%X)
|
||||
>>38917 byte <0x31 (unknown version, ID 0x%X)
|
||||
# "application id" which appears to be used as a volume label
|
||||
>32808 string >\0 '%s'
|
||||
>34816 string \000CD001\001EL\ TORITO\ SPECIFICATION (bootable)
|
||||
@ -1210,3 +1254,8 @@
|
||||
>525 byte x Level %d
|
||||
>525 byte x (ODS-%d OpenVMS file system),
|
||||
>984 string x volume label is '%-12.12s'
|
||||
|
||||
# From: Thomas Klausner <wiz@NetBSD.org>
|
||||
# http://filext.com/file-extension/DAA
|
||||
# describes the daa file format. The magic would be:
|
||||
0 string DAA\x0\x0\x0\x0\x0 PowerISO Direct-Access-Archive
|
||||
|
2
contrib/file/Magdir/fortran
Normal file
2
contrib/file/Magdir/fortran
Normal file
@ -0,0 +1,2 @@
|
||||
# FORTRAN source
|
||||
0 string/c c\ FORTRAN program
|
@ -7,3 +7,17 @@
|
||||
# From Martin Pool (m.pool@pharos.com.au)
|
||||
0 beshort 0xaced Java serialization data
|
||||
>2 beshort >0x0004 \b, version %d
|
||||
|
||||
0 belong 0xfeedfeed Java KeyStore
|
||||
|
||||
0 belong 0xcececece Java JCE KeyStore
|
||||
|
||||
# Dalvik .dex format. http://retrodev.com/android/dexformat.html
|
||||
# From <mkf@google.com> "Mike Fleming"
|
||||
0 string dex\n
|
||||
>0 regex dex\n[0-9][0-9][0-9]\0 Dalvik dex file
|
||||
>4 string >000 version %s
|
||||
0 string dey\n
|
||||
>0 regex dey\n[0-9][0-9][0-9]\0 Dalvik dex file (optimized for host)
|
||||
>4 string >000 version %s
|
||||
|
||||
|
@ -357,4 +357,4 @@
|
||||
>>>>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
|
||||
0 string BOMStore Mac OS X bill of materials (BOM) file
|
||||
|
@ -17,10 +17,6 @@
|
||||
100 regex/c =^[\ \t]{0,10}call[\ \t]{1,10}rxfunc OS/2 REXX batch file text
|
||||
100 regex/c =^[\ \t]{0,10}say\ ['"] OS/2 REXX batch file text
|
||||
|
||||
|
||||
100 regex/c =^\\s*call\\s+rxfuncadd.*sysloadfu OS/2 REXX batch file text
|
||||
100 regex/c =^\\s*say\ ['"] OS/2 REXX batch file text
|
||||
|
||||
0 leshort 0x14c MS Windows COFF Intel 80386 object file
|
||||
#>4 ledate x stamp %s
|
||||
0 leshort 0x166 MS Windows COFF MIPS R4000 object file
|
||||
@ -363,8 +359,6 @@
|
||||
>30 byte 12 (4kB sectors)
|
||||
|
||||
# Popular applications
|
||||
# False positive with PPT
|
||||
#0 string \xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E\x00\x03\x00\xFE\xFF Microsoft Installer
|
||||
2080 string Microsoft\ Word\ 6.0\ Document %s
|
||||
2080 string Documento\ Microsoft\ Word\ 6 Spanish Microsoft Word 6 document data
|
||||
# Pawel Wiecek <coven@i17linuxb.ists.pwr.wroc.pl> (for polish Word)
|
||||
@ -610,10 +604,44 @@
|
||||
0 string VMDK VMware4 disk image
|
||||
0 string KDMV VMware4 disk image
|
||||
|
||||
0 belong 0x514649fb QEMU Copy-On-Write disk image
|
||||
>4 belong x version %d,
|
||||
>24 belong x size %d +
|
||||
>28 belong x %d
|
||||
#--------------------------------------------------------------------
|
||||
# Qemu Emulator Images
|
||||
# Lines written by Friedrich Schwittay (f.schwittay@yousable.de)
|
||||
# Made by reading sources and doing trial and error on existing
|
||||
# qcow files
|
||||
0 string QFI Qemu Image, Format: Qcow
|
||||
|
||||
# Uncomment the following line to display Magic (only used for debugging
|
||||
# this magic number)
|
||||
#>0 string x , Magic: %s
|
||||
|
||||
# There are currently 2 Versions: "1" and "2"
|
||||
# I do not use Version 2 and therefor branch here
|
||||
# but can assure: it works (tested on both versions)
|
||||
# Also my Qemu 0.9.0 which uses this Version 2 refuses
|
||||
# to start in its bios
|
||||
>0x04 belong 2 , Version: 2
|
||||
>0x04 belong 1 , Version: 1
|
||||
|
||||
# Using the existence of the Backing File Offset to Branch or not
|
||||
# to read Backing File Information
|
||||
>>0xc belong >0 , Backing File( Offset: %d
|
||||
>>>(0xc.L) string >\0 , Path: %s
|
||||
|
||||
# Didnt got the Trick here how qemu stores the "Size" at this Position
|
||||
# There is actually something stored but nothing makes sense
|
||||
# The header in the sources talks about it
|
||||
#>>>16 lelong x , Size: %d
|
||||
|
||||
# Modification time of the Backing File
|
||||
# Really usefull if you want to know if your backing
|
||||
# file is still usable together with this image
|
||||
>>>20 bedate x , Mtime: %s )
|
||||
|
||||
# Dont know how to calculate in Magicfiles
|
||||
# Also: this Information is not reliably
|
||||
# stored in image-files
|
||||
>>24 lelong x , Disk Size could be: %d * 256 bytes
|
||||
|
||||
0 string QEVM QEMU's suspend to disk image
|
||||
|
||||
@ -624,5 +652,14 @@
|
||||
0 lelong 0x02468ace Bochs Sparse disk image
|
||||
|
||||
# from http://filext.com by Derek M Jones <derek@knosof.co.uk>
|
||||
0 string \xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E\x00\x03\x00\xFE\xFF Microsoft Installer
|
||||
# False positive with PPT
|
||||
#0 string \xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E\x00\x03\x00\xFE\xFF Microsoft Installer
|
||||
0 string \320\317\021\340\241\261\032\341 Microsoft Office Document
|
||||
|
||||
# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
|
||||
# Magic type for Dell's BIOS .hdr files
|
||||
# Dell's .hdr
|
||||
0 string $RBU
|
||||
>23 string Dell %s system BIOS
|
||||
>48 string x version %.3s
|
||||
|
||||
|
@ -5,3 +5,9 @@
|
||||
0 string %PDF- PDF document
|
||||
>5 byte x \b, version %c
|
||||
>7 byte x \b.%c
|
||||
|
||||
# From: Nick Schmalenberger <nick@schmalenberger.us>
|
||||
# Forms Data Format
|
||||
0 string %FDF- FDF text
|
||||
>5 byte x \b, version %c
|
||||
>7 byte x \b.%c
|
||||
|
@ -15,19 +15,22 @@
|
||||
>20 lelong 0 log volume #0
|
||||
>20 lelong >0 log volume #%ld
|
||||
>24 string >\0 host: %s
|
||||
0 string PCPFolio PCP
|
||||
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 #kmchart PCP kmchart view
|
||||
>9 string Version
|
||||
>17 string >\0 (V.%s)
|
||||
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
|
||||
0 string PcPh PCP Help
|
||||
>4 string 1 Index
|
||||
>4 string 2 Text
|
||||
>5 string >\0 (V.%1.1s)
|
||||
|
@ -77,6 +77,7 @@ Magdir/digital \
|
||||
Magdir/dolby \
|
||||
Magdir/dump \
|
||||
Magdir/editors \
|
||||
Magdir/efi \
|
||||
Magdir/elf \
|
||||
Magdir/encore \
|
||||
Magdir/epoc \
|
||||
@ -85,6 +86,7 @@ Magdir/fcs \
|
||||
Magdir/filesystems \
|
||||
Magdir/flash \
|
||||
Magdir/fonts \
|
||||
Magdir/fortran \
|
||||
Magdir/frame \
|
||||
Magdir/freebsd \
|
||||
Magdir/fsav \
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Makefile.in generated by automake 1.9.6 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.10 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# 2003, 2004, 2005, 2006 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.
|
||||
@ -14,15 +14,11 @@
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
top_builddir = ..
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
INSTALL = @INSTALL@
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
@ -59,8 +55,6 @@ pkgdataDATA_INSTALL = $(INSTALL_DATA)
|
||||
DATA = $(pkgdata_DATA)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMDEP_FALSE = @AMDEP_FALSE@
|
||||
AMDEP_TRUE = @AMDEP_TRUE@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
@ -87,14 +81,12 @@ EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
FFLAGS = @FFLAGS@
|
||||
FSECT5_FALSE = @FSECT5_FALSE@
|
||||
FSECT5_TRUE = @FSECT5_TRUE@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
IS_CROSS_COMPILE_FALSE = @IS_CROSS_COMPILE_FALSE@
|
||||
IS_CROSS_COMPILE_TRUE = @IS_CROSS_COMPILE_TRUE@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
@ -102,9 +94,8 @@ LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
|
||||
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
@ -118,16 +109,13 @@ SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_F77 = @ac_ct_F77@
|
||||
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__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
|
||||
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
@ -139,7 +127,11 @@ build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
fsect = @fsect@
|
||||
host = @host@
|
||||
@ -147,21 +139,28 @@ host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
pkgdata_DATA = magic magic.mime magic.mgc magic.mime.mgc
|
||||
EXTRA_DIST = magic2mime Localstuff Header magic.mime $(magic_FRAGMENTS)
|
||||
CLEANFILES = magic magic.mgc magic.mime.mgc
|
||||
@ -217,6 +216,7 @@ Magdir/digital \
|
||||
Magdir/dolby \
|
||||
Magdir/dump \
|
||||
Magdir/editors \
|
||||
Magdir/efi \
|
||||
Magdir/elf \
|
||||
Magdir/encore \
|
||||
Magdir/epoc \
|
||||
@ -225,6 +225,7 @@ Magdir/fcs \
|
||||
Magdir/filesystems \
|
||||
Magdir/flash \
|
||||
Magdir/fonts \
|
||||
Magdir/fortran \
|
||||
Magdir/frame \
|
||||
Magdir/freebsd \
|
||||
Magdir/fsav \
|
||||
@ -394,13 +395,9 @@ mostlyclean-libtool:
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool
|
||||
uninstall-info-am:
|
||||
install-pkgdataDATA: $(pkgdata_DATA)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(pkgdatadir)" || $(mkdir_p) "$(DESTDIR)$(pkgdatadir)"
|
||||
test -z "$(pkgdatadir)" || $(MKDIR_P) "$(DESTDIR)$(pkgdatadir)"
|
||||
@list='$(pkgdata_DATA)'; for p in $$list; do \
|
||||
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||
f=$(am__strip_dir) \
|
||||
@ -423,23 +420,21 @@ CTAGS:
|
||||
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
$(mkdir_p) $(distdir)/Magdir
|
||||
@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; \
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
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"; \
|
||||
$(mkdir_p) "$(distdir)$$dir"; \
|
||||
else \
|
||||
dir=''; \
|
||||
fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
@ -455,7 +450,7 @@ check: check-am
|
||||
all-am: Makefile $(DATA)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(pkgdatadir)"; do \
|
||||
test -z "$$dir" || $(mkdir_p) "$$dir"; \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
@ -488,7 +483,7 @@ clean-am: clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-generic distclean-libtool
|
||||
distclean-am: clean-am distclean-generic
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
@ -502,12 +497,20 @@ info-am:
|
||||
|
||||
install-data-am: install-pkgdataDATA
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
@ -526,17 +529,21 @@ ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-info-am uninstall-pkgdataDATA
|
||||
uninstall-am: uninstall-pkgdataDATA
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
|
||||
distclean distclean-generic distclean-libtool distdir dvi \
|
||||
dvi-am html html-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-data install-data-am install-dvi install-dvi-am \
|
||||
install-exec install-exec-am install-html install-html-am \
|
||||
install-info install-info-am install-man install-pdf \
|
||||
install-pdf-am install-pkgdataDATA install-ps install-ps-am \
|
||||
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
|
||||
uninstall uninstall-am uninstall-pkgdataDATA
|
||||
|
||||
|
||||
magic: Header Localstuff $(magic_FRAGMENTS)
|
||||
|
@ -157,8 +157,6 @@ fi
|
||||
dnl AC_HEADER_STDINT
|
||||
AC_DEFUN([AC_HEADER_STDINT], [AC_CHECK_HEADERS(stdint.h)])
|
||||
|
||||
#serial 19
|
||||
|
||||
dnl By default, many hosts won't let programs access large files;
|
||||
dnl one must use special compiler options to get large-file access to work.
|
||||
dnl For more details about this brain damage please see:
|
||||
@ -252,8 +250,6 @@ 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,
|
||||
|
174
contrib/file/aclocal.m4
vendored
174
contrib/file/aclocal.m4
vendored
@ -1,7 +1,7 @@
|
||||
# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
|
||||
# generated automatically by aclocal 1.10 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
# 2005 Free Software Foundation, Inc.
|
||||
# 2005, 2006 Free Software Foundation, Inc.
|
||||
# This file 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.
|
||||
@ -11,6 +11,11 @@
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
m4_if(m4_PACKAGE_VERSION, [2.61],,
|
||||
[m4_fatal([this file was generated for autoconf 2.61.
|
||||
You have another version of autoconf. If you want to use that,
|
||||
you should regenerate the build system entirely.], [63])])
|
||||
|
||||
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
|
||||
|
||||
# serial 47 AC_PROG_LIBTOOL
|
||||
@ -6159,7 +6164,7 @@ SED=$lt_cv_path_SED
|
||||
AC_MSG_RESULT([$SED])
|
||||
])
|
||||
|
||||
# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -6169,14 +6174,29 @@ AC_MSG_RESULT([$SED])
|
||||
# ----------------------------
|
||||
# Automake X.Y traces this macro to ensure aclocal.m4 has been
|
||||
# generated from the m4 files accompanying Automake X.Y.
|
||||
AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
|
||||
# (This private macro should not be called outside this file.)
|
||||
AC_DEFUN([AM_AUTOMAKE_VERSION],
|
||||
[am__api_version='1.10'
|
||||
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
|
||||
dnl require some minimum version. Point them to the right macro.
|
||||
m4_if([$1], [1.10], [],
|
||||
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
|
||||
])
|
||||
|
||||
# _AM_AUTOCONF_VERSION(VERSION)
|
||||
# -----------------------------
|
||||
# aclocal traces this macro to find the Autoconf version.
|
||||
# This is a private macro too. Using m4_define simplifies
|
||||
# the logic in aclocal, which can simply ignore this definition.
|
||||
m4_define([_AM_AUTOCONF_VERSION], [])
|
||||
|
||||
# AM_SET_CURRENT_AUTOMAKE_VERSION
|
||||
# -------------------------------
|
||||
# Call AM_AUTOMAKE_VERSION so it can be traced.
|
||||
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
|
||||
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
|
||||
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
|
||||
[AM_AUTOMAKE_VERSION([1.9.6])])
|
||||
[AM_AUTOMAKE_VERSION([1.10])dnl
|
||||
_AM_AUTOCONF_VERSION(m4_PACKAGE_VERSION)])
|
||||
|
||||
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
|
||||
|
||||
@ -6233,14 +6253,14 @@ am_aux_dir=`cd $ac_aux_dir && pwd`
|
||||
|
||||
# AM_CONDITIONAL -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
|
||||
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file 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.
|
||||
|
||||
# serial 7
|
||||
# serial 8
|
||||
|
||||
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
|
||||
# -------------------------------------
|
||||
@ -6249,8 +6269,10 @@ AC_DEFUN([AM_CONDITIONAL],
|
||||
[AC_PREREQ(2.52)dnl
|
||||
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
|
||||
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
|
||||
AC_SUBST([$1_TRUE])
|
||||
AC_SUBST([$1_FALSE])
|
||||
AC_SUBST([$1_TRUE])dnl
|
||||
AC_SUBST([$1_FALSE])dnl
|
||||
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
|
||||
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
|
||||
if $2; then
|
||||
$1_TRUE=
|
||||
$1_FALSE='#'
|
||||
@ -6264,15 +6286,14 @@ AC_CONFIG_COMMANDS_PRE(
|
||||
Usually this means the macro was only invoked conditionally.]])
|
||||
fi])])
|
||||
|
||||
|
||||
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file 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.
|
||||
|
||||
# serial 8
|
||||
# serial 9
|
||||
|
||||
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
|
||||
# written in clear, in which case automake, when reading aclocal.m4,
|
||||
@ -6300,6 +6321,7 @@ AC_REQUIRE([AM_DEP_TRACK])dnl
|
||||
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
|
||||
[$1], CXX, [depcc="$CXX" am_compiler_list=],
|
||||
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
|
||||
[$1], UPC, [depcc="$UPC" am_compiler_list=],
|
||||
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
|
||||
[depcc="$$1" am_compiler_list=])
|
||||
|
||||
@ -6365,6 +6387,7 @@ AC_CACHE_CHECK([dependency style of $depcc],
|
||||
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
|
||||
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
|
||||
>/dev/null 2>conftest.err &&
|
||||
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
|
||||
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
|
||||
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
|
||||
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
|
||||
@ -6417,7 +6440,8 @@ if test "x$enable_dependency_tracking" != xno; then
|
||||
AMDEPBACKSLASH='\'
|
||||
fi
|
||||
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
|
||||
AC_SUBST([AMDEPBACKSLASH])
|
||||
AC_SUBST([AMDEPBACKSLASH])dnl
|
||||
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
|
||||
])
|
||||
|
||||
# Generate code to set up dependency tracking. -*- Autoconf -*-
|
||||
@ -6442,8 +6466,9 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
# some people rename them; so instead we look at the file content.
|
||||
# Grep'ing the first line is not enough: some people post-process
|
||||
# each Makefile.in and add a new line on top of each file to say so.
|
||||
# So let's grep whole file.
|
||||
if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
|
||||
# Grep'ing the whole file is not good either: AIX grep has a line
|
||||
# limit of 2048, but all sed's we know have understand at least 4000.
|
||||
if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then
|
||||
dirpart=`AS_DIRNAME("$mf")`
|
||||
else
|
||||
continue
|
||||
@ -6502,8 +6527,8 @@ AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
|
||||
|
||||
# Do all the work for Automake. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
# Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
# 2005, 2006 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -6526,16 +6551,20 @@ AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
|
||||
# arguments mandatory, and then we can depend on a new Autoconf
|
||||
# release and drop the old call support.
|
||||
AC_DEFUN([AM_INIT_AUTOMAKE],
|
||||
[AC_PREREQ([2.58])dnl
|
||||
[AC_PREREQ([2.60])dnl
|
||||
dnl Autoconf wants to disallow AM_ names. We explicitly allow
|
||||
dnl the ones we care about.
|
||||
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
|
||||
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
|
||||
AC_REQUIRE([AC_PROG_INSTALL])dnl
|
||||
# test to see if srcdir already configured
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`" &&
|
||||
test -f $srcdir/config.status; then
|
||||
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`"; then
|
||||
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output
|
||||
# is not polluted with repeated "-I."
|
||||
AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
|
||||
# test to see if srcdir already configured
|
||||
if test -f $srcdir/config.status; then
|
||||
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||
fi
|
||||
fi
|
||||
|
||||
# test whether we have cygpath
|
||||
@ -6555,6 +6584,9 @@ m4_ifval([$2],
|
||||
AC_SUBST([PACKAGE], [$1])dnl
|
||||
AC_SUBST([VERSION], [$2])],
|
||||
[_AM_SET_OPTIONS([$1])dnl
|
||||
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
|
||||
m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
|
||||
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
|
||||
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
|
||||
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
|
||||
|
||||
@ -6590,6 +6622,10 @@ AC_PROVIDE_IFELSE([AC_PROG_CXX],
|
||||
[_AM_DEPENDENCIES(CXX)],
|
||||
[define([AC_PROG_CXX],
|
||||
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
|
||||
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
|
||||
[_AM_DEPENDENCIES(OBJC)],
|
||||
[define([AC_PROG_OBJC],
|
||||
defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
|
||||
])
|
||||
])
|
||||
|
||||
@ -6625,7 +6661,7 @@ echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
|
||||
# Define $install_sh.
|
||||
AC_DEFUN([AM_PROG_INSTALL_SH],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
install_sh=${install_sh-"$am_aux_dir/install-sh"}
|
||||
install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
|
||||
AC_SUBST(install_sh)])
|
||||
|
||||
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
|
||||
@ -6732,14 +6768,14 @@ rm -f confinc confmf
|
||||
|
||||
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
|
||||
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file 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.
|
||||
|
||||
# serial 4
|
||||
# serial 5
|
||||
|
||||
# AM_MISSING_PROG(NAME, PROGRAM)
|
||||
# ------------------------------
|
||||
@ -6755,6 +6791,7 @@ AC_SUBST($1)])
|
||||
# If it does, set am_missing_run to use it, otherwise, to nothing.
|
||||
AC_DEFUN([AM_MISSING_HAS_RUN],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
AC_REQUIRE_AUX_FILE([missing])dnl
|
||||
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
|
||||
# Use eval to expand $SHELL
|
||||
if eval "$MISSING --run true"; then
|
||||
@ -6765,7 +6802,7 @@ else
|
||||
fi
|
||||
])
|
||||
|
||||
# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -6773,60 +6810,23 @@ fi
|
||||
|
||||
# AM_PROG_MKDIR_P
|
||||
# ---------------
|
||||
# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
|
||||
#
|
||||
# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
|
||||
# created by `make install' are always world readable, even if the
|
||||
# installer happens to have an overly restrictive umask (e.g. 077).
|
||||
# This was a mistake. There are at least two reasons why we must not
|
||||
# use `-m 0755':
|
||||
# - it causes special bits like SGID to be ignored,
|
||||
# - it may be too restrictive (some setups expect 775 directories).
|
||||
#
|
||||
# Do not use -m 0755 and let people choose whatever they expect by
|
||||
# setting umask.
|
||||
#
|
||||
# We cannot accept any implementation of `mkdir' that recognizes `-p'.
|
||||
# Some implementations (such as Solaris 8's) are not thread-safe: if a
|
||||
# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
|
||||
# concurrently, both version can detect that a/ is missing, but only
|
||||
# one can create it and the other will error out. Consequently we
|
||||
# restrict ourselves to GNU make (using the --version option ensures
|
||||
# this.)
|
||||
# Check for `mkdir -p'.
|
||||
AC_DEFUN([AM_PROG_MKDIR_P],
|
||||
[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
|
||||
# We used to keeping the `.' as first argument, in order to
|
||||
# allow $(mkdir_p) to be used without argument. As in
|
||||
# $(mkdir_p) $(somedir)
|
||||
# where $(somedir) is conditionally defined. However this is wrong
|
||||
# for two reasons:
|
||||
# 1. if the package is installed by a user who cannot write `.'
|
||||
# make install will fail,
|
||||
# 2. the above comment should most certainly read
|
||||
# $(mkdir_p) $(DESTDIR)$(somedir)
|
||||
# so it does not work when $(somedir) is undefined and
|
||||
# $(DESTDIR) is not.
|
||||
# To support the latter case, we have to write
|
||||
# test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
|
||||
# so the `.' trick is pointless.
|
||||
mkdir_p='mkdir -p --'
|
||||
else
|
||||
# On NextStep and OpenStep, the `mkdir' command does not
|
||||
# recognize any option. It will interpret all options as
|
||||
# directories to create, and then abort because `.' already
|
||||
# exists.
|
||||
for d in ./-p ./--version;
|
||||
do
|
||||
test -d $d && rmdir $d
|
||||
done
|
||||
# $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
|
||||
if test -f "$ac_aux_dir/mkinstalldirs"; then
|
||||
mkdir_p='$(mkinstalldirs)'
|
||||
else
|
||||
mkdir_p='$(install_sh) -d'
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([mkdir_p])])
|
||||
[AC_PREREQ([2.60])dnl
|
||||
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
|
||||
dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P,
|
||||
dnl while keeping a definition of mkdir_p for backward compatibility.
|
||||
dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
|
||||
dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
|
||||
dnl Makefile.ins that do not define MKDIR_P, so we do our own
|
||||
dnl adjustment using top_builddir (which is defined more often than
|
||||
dnl MKDIR_P).
|
||||
AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
|
||||
case $mkdir_p in
|
||||
[[\\/$]]* | ?:[[\\/]]*) ;;
|
||||
*/*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
|
||||
esac
|
||||
])
|
||||
|
||||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
|
||||
@ -6938,9 +6938,21 @@ dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
|
||||
if test "$cross_compiling" != no; then
|
||||
AC_CHECK_TOOL([STRIP], [strip], :)
|
||||
fi
|
||||
INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
|
||||
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
|
||||
AC_SUBST([INSTALL_STRIP_PROGRAM])])
|
||||
|
||||
# Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file 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.
|
||||
|
||||
# _AM_SUBST_NOTMAKE(VARIABLE)
|
||||
# ---------------------------
|
||||
# Prevent Automake from outputing VARIABLE = @VARIABLE@ in Makefile.in.
|
||||
# This macro is traced by Automake.
|
||||
AC_DEFUN([_AM_SUBST_NOTMAKE])
|
||||
|
||||
# Check how to create a tarball. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "file.h"
|
||||
#include "magic.h"
|
||||
#include "patchlevel.h"
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@ -46,7 +47,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: apprentice.c,v 1.105 2007/05/16 20:51:40 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: apprentice.c,v 1.109 2007/12/27 20:52:36 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#define EATAB {while (isascii((unsigned char) *l) && \
|
||||
@ -110,6 +111,7 @@ private int apprentice_compile(struct magic_set *, struct magic **, uint32_t *,
|
||||
const char *);
|
||||
private int check_format_type(const char *, int);
|
||||
private int check_format(struct magic_set *, struct magic *);
|
||||
private int get_op(char);
|
||||
|
||||
private size_t maxmagic = 0;
|
||||
private size_t magicsize = sizeof(struct magic);
|
||||
@ -188,6 +190,12 @@ static const struct type_tbl_s {
|
||||
{ XX("qldate"), FILE_QLDATE, FILE_FMT_STR },
|
||||
{ XX("leqldate"), FILE_LEQLDATE, FILE_FMT_STR },
|
||||
{ XX("beqldate"), FILE_BEQLDATE, FILE_FMT_STR },
|
||||
{ XX("float"), FILE_FLOAT, FILE_FMT_FLOAT },
|
||||
{ XX("befloat"), FILE_BEFLOAT, FILE_FMT_FLOAT },
|
||||
{ XX("lefloat"), FILE_LEFLOAT, FILE_FMT_FLOAT },
|
||||
{ XX("double"), FILE_DOUBLE, FILE_FMT_DOUBLE },
|
||||
{ XX("bedouble"), FILE_BEDOUBLE, FILE_FMT_DOUBLE },
|
||||
{ XX("ledouble"), FILE_LEDOUBLE, FILE_FMT_DOUBLE },
|
||||
{ XX_NULL, FILE_INVALID, FILE_FMT_NONE },
|
||||
# undef XX
|
||||
# undef XX_NULL
|
||||
@ -261,7 +269,6 @@ apprentice_1(struct magic_set *ms, const char *fn, int action,
|
||||
rv = apprentice_file(ms, &magic, &nmagic, fn, action);
|
||||
if (rv != 0)
|
||||
return -1;
|
||||
mapped = 0;
|
||||
}
|
||||
|
||||
mapped = rv;
|
||||
@ -296,10 +303,12 @@ file_delmagic(struct magic *p, int type, size_t entries)
|
||||
if (p == NULL)
|
||||
return;
|
||||
switch (type) {
|
||||
#ifdef QUICK
|
||||
case 2:
|
||||
p--;
|
||||
(void)munmap((void *)p, sizeof(*p) * (entries + 1));
|
||||
break;
|
||||
#endif
|
||||
case 1:
|
||||
p--;
|
||||
/*FALLTHROUGH*/
|
||||
@ -431,6 +440,9 @@ apprentice_magic_strength(const struct magic *m)
|
||||
case FILE_LELDATE:
|
||||
case FILE_BELDATE:
|
||||
case FILE_MELDATE:
|
||||
case FILE_FLOAT:
|
||||
case FILE_BEFLOAT:
|
||||
case FILE_LEFLOAT:
|
||||
val += 4 * MULT;
|
||||
break;
|
||||
|
||||
@ -443,6 +455,9 @@ apprentice_magic_strength(const struct magic *m)
|
||||
case FILE_QLDATE:
|
||||
case FILE_LEQLDATE:
|
||||
case FILE_BEQLDATE:
|
||||
case FILE_DOUBLE:
|
||||
case FILE_BEDOUBLE:
|
||||
case FILE_LEDOUBLE:
|
||||
val += 8 * MULT;
|
||||
break;
|
||||
|
||||
@ -512,7 +527,7 @@ apprentice_file(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
|
||||
private const char hdr[] =
|
||||
"cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
|
||||
FILE *f;
|
||||
char line[BUFSIZ+1];
|
||||
char line[BUFSIZ];
|
||||
int errs = 0;
|
||||
struct magic_entry *marray;
|
||||
uint32_t marraycount, i, mentrycount = 0;
|
||||
@ -541,7 +556,7 @@ apprentice_file(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
|
||||
(void)fprintf(stderr, "%s\n", hdr);
|
||||
|
||||
/* read and parse this file */
|
||||
for (ms->line = 1; fgets(line, BUFSIZ, f) != NULL; ms->line++) {
|
||||
for (ms->line = 1; fgets(line, sizeof(line), f) != NULL; ms->line++) {
|
||||
size_t len;
|
||||
len = strlen(line);
|
||||
if (len == 0) /* null line, garbage, etc */
|
||||
@ -646,6 +661,9 @@ file_signextend(struct magic_set *ms, struct magic *m, uint64_t v)
|
||||
case FILE_BELONG:
|
||||
case FILE_LELONG:
|
||||
case FILE_MELONG:
|
||||
case FILE_FLOAT:
|
||||
case FILE_BEFLOAT:
|
||||
case FILE_LEFLOAT:
|
||||
v = (int32_t) v;
|
||||
break;
|
||||
case FILE_QUAD:
|
||||
@ -657,6 +675,9 @@ file_signextend(struct magic_set *ms, struct magic *m, uint64_t v)
|
||||
case FILE_BEQLDATE:
|
||||
case FILE_LEQDATE:
|
||||
case FILE_LEQLDATE:
|
||||
case FILE_DOUBLE:
|
||||
case FILE_BEDOUBLE:
|
||||
case FILE_LEDOUBLE:
|
||||
v = (int64_t) v;
|
||||
break;
|
||||
case FILE_STRING:
|
||||
@ -959,6 +980,16 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
|
||||
case 'B':
|
||||
m->in_type = FILE_BYTE;
|
||||
break;
|
||||
case 'e':
|
||||
case 'f':
|
||||
case 'g':
|
||||
m->in_type = FILE_LEDOUBLE;
|
||||
break;
|
||||
case 'E':
|
||||
case 'F':
|
||||
case 'G':
|
||||
m->in_type = FILE_BEDOUBLE;
|
||||
break;
|
||||
default:
|
||||
if (ms->flags & MAGIC_CHECK)
|
||||
file_magwarn(ms,
|
||||
@ -1252,6 +1283,31 @@ check_format_type(const char *ptr, int type)
|
||||
return -1;
|
||||
}
|
||||
|
||||
case FILE_FMT_FLOAT:
|
||||
case FILE_FMT_DOUBLE:
|
||||
if (*ptr == '-')
|
||||
ptr++;
|
||||
if (*ptr == '.')
|
||||
ptr++;
|
||||
while (isdigit((unsigned char)*ptr)) ptr++;
|
||||
if (*ptr == '.')
|
||||
ptr++;
|
||||
while (isdigit((unsigned char)*ptr)) ptr++;
|
||||
|
||||
switch (*ptr++) {
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'f':
|
||||
case 'F':
|
||||
case 'g':
|
||||
case 'G':
|
||||
return 0;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
case FILE_FMT_STR:
|
||||
if (*ptr == '-')
|
||||
ptr++;
|
||||
@ -1358,6 +1414,28 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action)
|
||||
}
|
||||
m->vallen = slen;
|
||||
return 0;
|
||||
case FILE_FLOAT:
|
||||
case FILE_BEFLOAT:
|
||||
case FILE_LEFLOAT:
|
||||
if (m->reln != 'x') {
|
||||
char *ep;
|
||||
#ifdef HAVE_STRTOF
|
||||
m->value.f = strtof(*p, &ep);
|
||||
#else
|
||||
m->value.f = (float)strtod(*p, &ep);
|
||||
#endif
|
||||
*p = ep;
|
||||
}
|
||||
return 0;
|
||||
case FILE_DOUBLE:
|
||||
case FILE_BEDOUBLE:
|
||||
case FILE_LEDOUBLE:
|
||||
if (m->reln != 'x') {
|
||||
char *ep;
|
||||
m->value.d = strtod(*p, &ep);
|
||||
*p = ep;
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
if (m->reln != 'x') {
|
||||
char *ep;
|
||||
@ -1685,8 +1763,9 @@ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
|
||||
else
|
||||
version = ptr[1];
|
||||
if (version != VERSIONNO) {
|
||||
file_error(ms, 0, "version mismatch (%d != %d) in `%s'",
|
||||
version, VERSIONNO, dbname);
|
||||
file_error(ms, 0, "File %d.%d supports only %d version magic "
|
||||
"files. `%s' is version %d", FILE_VERSION_MAJOR, patchlevel,
|
||||
VERSIONNO, dbname, version);
|
||||
goto error;
|
||||
}
|
||||
*nmagicp = (uint32_t)(st.st_size / sizeof(struct magic)) - 1;
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include "names.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: ascmagic.c,v 1.50 2007/03/15 14:51:00 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: ascmagic.c,v 1.53 2007/10/29 00:54:08 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
typedef unsigned long unichar;
|
||||
@ -76,6 +76,7 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
|
||||
size_t ulen;
|
||||
struct names *p;
|
||||
int rv = -1;
|
||||
int mime = ms->flags & MAGIC_MIME;
|
||||
|
||||
const char *code = NULL;
|
||||
const char *code_mime = NULL;
|
||||
@ -184,13 +185,6 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
|
||||
}
|
||||
}
|
||||
|
||||
if ((ms->flags & MAGIC_NO_CHECK_FORTRAN) == 0 &&
|
||||
(*buf == 'c' || *buf == 'C') && ISSPC(buf[1])) {
|
||||
subtype_mime = "text/fortran";
|
||||
subtype = "fortran program";
|
||||
goto subtype_identified;
|
||||
}
|
||||
|
||||
/* look for tokens from names.h - this is expensive! */
|
||||
|
||||
if ((ms->flags & MAGIC_NO_CHECK_TOKENS) != 0)
|
||||
@ -271,21 +265,27 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
|
||||
if (seen_cr && nbytes < HOWMANY)
|
||||
n_cr++;
|
||||
|
||||
if ((ms->flags & MAGIC_MIME)) {
|
||||
if (subtype_mime) {
|
||||
if (file_printf(ms, subtype_mime) == -1)
|
||||
goto done;
|
||||
} else {
|
||||
if (file_printf(ms, "text/plain") == -1)
|
||||
goto done;
|
||||
if (mime) {
|
||||
if (mime & MAGIC_MIME_TYPE) {
|
||||
if (subtype_mime) {
|
||||
if (file_printf(ms, subtype_mime) == -1)
|
||||
goto done;
|
||||
} else {
|
||||
if (file_printf(ms, "text/plain") == -1)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (code_mime) {
|
||||
if (file_printf(ms, "; charset=") == -1)
|
||||
if ((mime == 0 || mime == MAGIC_MIME) && code_mime) {
|
||||
if ((mime & MAGIC_MIME_TYPE) &&
|
||||
file_printf(ms, " charset=") == -1)
|
||||
goto done;
|
||||
if (file_printf(ms, code_mime) == -1)
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (mime == MAGIC_MIME_ENCODING)
|
||||
file_printf(ms, "binary");
|
||||
} else {
|
||||
if (file_printf(ms, code) == -1)
|
||||
goto done;
|
||||
|
@ -49,13 +49,14 @@
|
||||
#if defined(HAVE_SYS_TIME_H)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIBZ
|
||||
#if defined(HAVE_ZLIB_H) && defined(HAVE_LIBZ)
|
||||
#define BUILTIN_DECOMPRESS
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: compress.c,v 1.51 2007/03/05 02:41:29 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: compress.c,v 1.54 2007/12/02 00:28:10 christos Exp $")
|
||||
#endif
|
||||
|
||||
private struct {
|
||||
@ -86,7 +87,7 @@ private size_t ncompr = sizeof(compr) / sizeof(compr[0]);
|
||||
private ssize_t swrite(int, const void *, size_t);
|
||||
private size_t uncompressbuf(struct magic_set *, int, size_t,
|
||||
const unsigned char *, unsigned char **, size_t);
|
||||
#ifdef HAVE_LIBZ
|
||||
#ifdef BUILTIN_DECOMPRESS
|
||||
private size_t uncompressgzipped(struct magic_set *, const unsigned char *,
|
||||
unsigned char **, size_t);
|
||||
#endif
|
||||
@ -98,6 +99,7 @@ file_zmagic(struct magic_set *ms, int fd, const char *name,
|
||||
unsigned char *newbuf = NULL;
|
||||
size_t i, nsz;
|
||||
int rv = 0;
|
||||
int mime = ms->flags & MAGIC_MIME;
|
||||
|
||||
if ((ms->flags & MAGIC_COMPRESS) == 0)
|
||||
return 0;
|
||||
@ -112,11 +114,18 @@ file_zmagic(struct magic_set *ms, int fd, const char *name,
|
||||
rv = -1;
|
||||
if (file_buffer(ms, -1, name, newbuf, nsz) == -1)
|
||||
goto error;
|
||||
if (file_printf(ms, " (") == -1)
|
||||
|
||||
if (mime == MAGIC_MIME || mime == 0) {
|
||||
if (file_printf(ms, mime ?
|
||||
" compressed-encoding=" : " (") == -1)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((mime == 0 || mime & MAGIC_MIME_ENCODING) &&
|
||||
file_buffer(ms, -1, NULL, buf, nbytes) == -1)
|
||||
goto error;
|
||||
if (file_buffer(ms, -1, NULL, buf, nbytes) == -1)
|
||||
goto error;
|
||||
if (file_printf(ms, ")") == -1)
|
||||
|
||||
if (!mime && file_printf(ms, ")") == -1)
|
||||
goto error;
|
||||
rv = 1;
|
||||
break;
|
||||
@ -285,7 +294,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
|
||||
return fd;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
#ifdef BUILTIN_DECOMPRESS
|
||||
|
||||
#define FHCRC (1 << 1)
|
||||
#define FEXTRA (1 << 2)
|
||||
@ -364,7 +373,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
|
||||
int fdin[2], fdout[2];
|
||||
int r;
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
#ifdef BUILTIN_DECOMPRESS
|
||||
if (method == 2)
|
||||
return uncompressgzipped(ms, old, newch, n);
|
||||
#endif
|
||||
|
@ -72,6 +72,9 @@
|
||||
/* Define to 1 if you have the `strndup' function. */
|
||||
#undef HAVE_STRNDUP
|
||||
|
||||
/* Define to 1 if you have the `strtof' function. */
|
||||
#undef HAVE_STRTOF
|
||||
|
||||
/* Define to 1 if you have the `strtoul' function. */
|
||||
#undef HAVE_STRTOUL
|
||||
|
||||
@ -133,6 +136,9 @@
|
||||
/* Define to 1 if you have the `wcwidth' function. */
|
||||
#undef HAVE_WCWIDTH
|
||||
|
||||
/* Define to 1 if you have the <zlib.h> header file. */
|
||||
#undef HAVE_ZLIB_H
|
||||
|
||||
/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
|
||||
*/
|
||||
#undef MAJOR_IN_MKDEV
|
||||
@ -159,6 +165,9 @@
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* */
|
||||
#undef SIZEOF_INT64_T
|
||||
|
||||
/* */
|
||||
#undef SIZEOF_UINT16_T
|
||||
|
||||
@ -183,6 +192,11 @@
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#undef _FILE_OFFSET_BITS
|
||||
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# undef _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
/* Define for large files, on AIX-style hosts. */
|
||||
#undef _LARGE_FILES
|
||||
|
||||
@ -192,13 +206,16 @@
|
||||
/* */
|
||||
#undef int32_t
|
||||
|
||||
/* */
|
||||
#undef int64_t
|
||||
|
||||
/* Define to a type if <wchar.h> does not define. */
|
||||
#undef mbstate_t
|
||||
|
||||
/* Define to `long' if <sys/types.h> does not define. */
|
||||
/* Define to `long int' if <sys/types.h> does not define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* */
|
||||
|
9816
contrib/file/configure
vendored
9816
contrib/file/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT
|
||||
AC_CONFIG_SRCDIR([src/file.c])
|
||||
AM_INIT_AUTOMAKE(file, 4.21)
|
||||
AM_INIT_AUTOMAKE(file, 4.23)
|
||||
AM_CONFIG_HEADER([config.h])
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
@ -49,6 +49,7 @@ fi], [
|
||||
])
|
||||
AC_SUBST(fsect)
|
||||
AM_CONDITIONAL(FSECT5, test x$fsect = x5)
|
||||
AC_GNU_SOURCE
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
@ -66,11 +67,13 @@ AH_TEMPLATE([HAVE_LONG_LONG], [])
|
||||
AH_TEMPLATE([HAVE_TM_ISDST], [])
|
||||
AH_TEMPLATE([SIZEOF_UINT16_T], [])
|
||||
AH_TEMPLATE([SIZEOF_UINT32_T], [])
|
||||
AH_TEMPLATE([SIZEOF_INT64_T], [])
|
||||
AH_TEMPLATE([SIZEOF_UINT64_T], [])
|
||||
AH_TEMPLATE([SIZEOF_UINT8_T], [])
|
||||
AH_TEMPLATE([int32_t], [])
|
||||
AH_TEMPLATE([uint16_t], [])
|
||||
AH_TEMPLATE([uint32_t], [])
|
||||
AH_TEMPLATE([int64_t], [])
|
||||
AH_TEMPLATE([uint64_t], [])
|
||||
AH_TEMPLATE([uint8_t], [])
|
||||
|
||||
@ -82,6 +85,7 @@ AC_HEADER_STDINT
|
||||
AC_CHECK_HEADERS(fcntl.h locale.h stdint.h inttypes.h unistd.h getopt.h)
|
||||
AC_CHECK_HEADERS(utime.h wchar.h wctype.h limits.h)
|
||||
AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
|
||||
AC_CHECK_HEADERS(zlib.h)
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
@ -106,20 +110,24 @@ AC_CHECK_TYPE_STDC(uint32_t, unsigned int)
|
||||
AC_CHECK_TYPE_STDC(int32_t, int)
|
||||
AC_C_LONG_LONG
|
||||
if test $ac_cv_c_long_long = yes; then
|
||||
long64='unsigned long long';
|
||||
ulong64='unsigned long long';
|
||||
long64='long long';
|
||||
else
|
||||
long64='unsigned long';
|
||||
ulong64='unsigned long';
|
||||
long64='long';
|
||||
fi
|
||||
dnl This needs a patch to autoconf 2.13 acgeneral.m4
|
||||
AC_CHECK_TYPE2_STDC(uint64_t, $long64)
|
||||
AC_CHECK_TYPE2_STDC(uint64_t, $ulong64)
|
||||
AC_CHECK_TYPE2_STDC(int64_t, $long64)
|
||||
|
||||
AC_CHECK_SIZEOF_STDC_HEADERS(uint8_t, 0)
|
||||
AC_CHECK_SIZEOF_STDC_HEADERS(uint16_t, 0)
|
||||
AC_CHECK_SIZEOF_STDC_HEADERS(uint32_t, 0)
|
||||
AC_CHECK_SIZEOF_STDC_HEADERS(int64_t, 0)
|
||||
AC_CHECK_SIZEOF_STDC_HEADERS(uint64_t, 0)
|
||||
|
||||
dnl Checks for functions
|
||||
AC_CHECK_FUNCS(mmap strerror strndup strtoul mbrtowc mkstemp getopt_long utimes utime wcwidth snprintf vsnprintf)
|
||||
AC_CHECK_FUNCS(mmap strerror strndup strtoul mbrtowc mkstemp getopt_long utimes utime wcwidth snprintf vsnprintf strtof)
|
||||
|
||||
dnl Checks for libraries
|
||||
AC_CHECK_LIB(z,gzopen)
|
||||
|
@ -71,7 +71,7 @@
|
||||
#include "patchlevel.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: file.c,v 1.111 2007/05/08 14:44:18 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: file.c,v 1.117 2007/12/27 16:35:58 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
|
||||
@ -122,7 +122,8 @@ private void load(const char *, int);
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int c, i;
|
||||
int c;
|
||||
size_t i;
|
||||
int action = 0, didsomefiles = 0, errflg = 0;
|
||||
int flags = 0;
|
||||
char *home, *usermagic;
|
||||
@ -133,33 +134,15 @@ main(int argc, char *argv[])
|
||||
int longindex;
|
||||
static const struct option long_options[] =
|
||||
{
|
||||
{"version", 0, 0, 'v'},
|
||||
{"help", 0, 0, 0},
|
||||
{"brief", 0, 0, 'b'},
|
||||
{"checking-printout", 0, 0, 'c'},
|
||||
{"debug", 0, 0, 'd'},
|
||||
{"exclude", 1, 0, 'e' },
|
||||
{"files-from", 1, 0, 'f'},
|
||||
{"separator", 1, 0, 'F'},
|
||||
{"mime", 0, 0, 'i'},
|
||||
{"keep-going", 0, 0, 'k'},
|
||||
#ifdef S_IFLNK
|
||||
{"dereference", 0, 0, 'L'},
|
||||
{"no-dereference", 0, 0, 'h'},
|
||||
#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'},
|
||||
{"compile", 0, 0, 'C'},
|
||||
{"print0", 0, 0, '0'},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
#define OPT(shortname, longname, opt, doc) \
|
||||
{longname, opt, NULL, shortname},
|
||||
#define OPT_LONGONLY(longname, opt, doc) \
|
||||
{longname, opt, NULL, 0},
|
||||
#include "file_opts.h"
|
||||
#undef OPT
|
||||
#undef OPT_LONGONLY
|
||||
{0, 0, NULL, 0}
|
||||
};
|
||||
#endif
|
||||
|
||||
static const struct {
|
||||
@ -170,7 +153,6 @@ main(int argc, char *argv[])
|
||||
{ "ascii", MAGIC_NO_CHECK_ASCII },
|
||||
{ "compress", MAGIC_NO_CHECK_COMPRESS },
|
||||
{ "elf", MAGIC_NO_CHECK_ELF },
|
||||
{ "fortran", MAGIC_NO_CHECK_FORTRAN },
|
||||
{ "soft", MAGIC_NO_CHECK_SOFT },
|
||||
{ "tar", MAGIC_NO_CHECK_TAR },
|
||||
{ "tokens", MAGIC_NO_CHECK_TOKENS },
|
||||
@ -220,15 +202,24 @@ main(int argc, char *argv[])
|
||||
switch (c) {
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
case 0 :
|
||||
if (longindex == 1)
|
||||
switch (longindex) {
|
||||
case 0:
|
||||
help();
|
||||
break;
|
||||
case 10:
|
||||
flags |= MAGIC_MIME_TYPE;
|
||||
break;
|
||||
case 11:
|
||||
flags |= MAGIC_MIME_ENCODING;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case '0':
|
||||
nulsep = 1;
|
||||
break;
|
||||
case 'b':
|
||||
++bflag;
|
||||
bflag++;
|
||||
break;
|
||||
case 'c':
|
||||
action = FILE_CHECK;
|
||||
@ -287,9 +278,9 @@ main(int argc, char *argv[])
|
||||
flags |= MAGIC_DEVICES;
|
||||
break;
|
||||
case 'v':
|
||||
(void)fprintf(stdout, "%s-%d.%.2d\n", progname,
|
||||
(void)fprintf(stderr, "%s-%d.%.2d\n", progname,
|
||||
FILE_VERSION_MAJOR, patchlevel);
|
||||
(void)fprintf(stdout, "magic file from %s\n",
|
||||
(void)fprintf(stderr, "magic file from %s\n",
|
||||
magicfile);
|
||||
return 1;
|
||||
case 'z':
|
||||
@ -341,12 +332,19 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
else {
|
||||
int i, wid, nw;
|
||||
for (wid = 0, i = optind; i < argc; i++) {
|
||||
nw = file_mbswidth(argv[i]);
|
||||
size_t j, wid, nw;
|
||||
for (wid = 0, j = (size_t)optind; j < (size_t)argc; j++) {
|
||||
nw = file_mbswidth(argv[j]);
|
||||
if (nw > wid)
|
||||
wid = nw;
|
||||
}
|
||||
/*
|
||||
* If bflag is only set twice, set it depending on
|
||||
* number of files [this is undocumented, and subject to change]
|
||||
*/
|
||||
if (bflag == 2) {
|
||||
bflag = optind >= argc - 1;
|
||||
}
|
||||
for (; optind < argc; optind++)
|
||||
process(argv[optind], wid);
|
||||
}
|
||||
@ -383,7 +381,6 @@ unwrap(char *fn)
|
||||
char buf[MAXPATHLEN];
|
||||
FILE *f;
|
||||
int wid = 0, cwid;
|
||||
size_t len;
|
||||
|
||||
if (strcmp("-", fn) == 0) {
|
||||
f = stdin;
|
||||
@ -396,9 +393,7 @@ unwrap(char *fn)
|
||||
}
|
||||
|
||||
while (fgets(buf, MAXPATHLEN, f) != NULL) {
|
||||
len = strlen(buf);
|
||||
if (len > 0 && buf[len - 1] == '\n')
|
||||
buf[len - 1] = '\0';
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
cwid = file_mbswidth(buf);
|
||||
if (cwid > wid)
|
||||
wid = cwid;
|
||||
@ -407,10 +402,8 @@ unwrap(char *fn)
|
||||
rewind(f);
|
||||
}
|
||||
|
||||
while (fgets(buf, MAXPATHLEN, f) != NULL) {
|
||||
len = strlen(buf);
|
||||
if (len > 0 && buf[len - 1] == '\n')
|
||||
buf[len - 1] = '\0';
|
||||
while (fgets(buf, sizeof(buf), f) != NULL) {
|
||||
buf[strcspn(buf, "\n")] = '\0';
|
||||
process(buf, wid);
|
||||
if(nobuffer)
|
||||
(void)fflush(stdout);
|
||||
@ -551,38 +544,17 @@ usage(void)
|
||||
private void
|
||||
help(void)
|
||||
{
|
||||
(void)puts(
|
||||
"Usage: file [OPTION]... [FILE]...\n"
|
||||
"Determine file type of FILEs.\n"
|
||||
"\n"
|
||||
" -m, --magic-file LIST use LIST as a colon-separated list of magic\n"
|
||||
" number files\n"
|
||||
" -z, --uncompress try to look inside compressed files\n"
|
||||
" -b, --brief do not prepend filenames to output lines\n"
|
||||
" -c, --checking-printout print the parsed form of the magic file, use in\n"
|
||||
" conjunction with -m to debug a new magic file\n"
|
||||
" before installing it\n"
|
||||
" -e, --exclude exclude test from the list of test to be\n"
|
||||
" performed for file. Valid tests are:\n"
|
||||
" ascii, apptype, elf, compress, soft, tar\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"
|
||||
"or\n"
|
||||
" --help display this help and exit\n"
|
||||
"or\n"
|
||||
" --version output version information and exit\n"
|
||||
"or\n"
|
||||
" -C, --compile compile file specified by -m\n"
|
||||
);
|
||||
(void)fputs(
|
||||
"Usage: file [OPTION...] [FILE...]\n"
|
||||
"Determine type of FILEs.\n"
|
||||
"\n", stderr);
|
||||
#define OPT(shortname, longname, opt, doc) \
|
||||
fprintf(stderr, " -%c, --" longname doc, shortname);
|
||||
#define OPT_LONGONLY(longname, opt, doc) \
|
||||
fprintf(stderr, " --" longname doc);
|
||||
#include "file_opts.h"
|
||||
#undef OPT
|
||||
#undef OPT_LONGONLY
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
@ -27,7 +27,7 @@
|
||||
*/
|
||||
/*
|
||||
* file.h - definitions for file(1) program
|
||||
* @(#)$File: file.h,v 1.91 2007/03/25 03:13:47 christos Exp $
|
||||
* @(#)$File: file.h,v 1.92 2007/11/08 00:31:37 christos Exp $
|
||||
*/
|
||||
|
||||
#ifndef __file_h__
|
||||
@ -146,7 +146,13 @@ struct magic {
|
||||
#define FILE_QLDATE 30
|
||||
#define FILE_LEQLDATE 31
|
||||
#define FILE_BEQLDATE 32
|
||||
#define FILE_NAMES_SIZE 33/* size of array to contain all names */
|
||||
#define FILE_FLOAT 33
|
||||
#define FILE_BEFLOAT 34
|
||||
#define FILE_LEFLOAT 35
|
||||
#define FILE_DOUBLE 36
|
||||
#define FILE_BEDOUBLE 37
|
||||
#define FILE_LEDOUBLE 38
|
||||
#define FILE_NAMES_SIZE 39/* size of array to contain all names */
|
||||
|
||||
#define IS_STRING(t) \
|
||||
((t) == FILE_STRING || \
|
||||
@ -161,6 +167,8 @@ struct magic {
|
||||
#define FILE_FMT_NUM 1 /* "cduxXi" */
|
||||
#define FILE_FMT_STR 2 /* "s" */
|
||||
#define FILE_FMT_QUAD 3 /* "ll" */
|
||||
#define FILE_FMT_FLOAT 4 /* "eEfFgG" */
|
||||
#define FILE_FMT_DOUBLE 5 /* "eEfFgG" */
|
||||
|
||||
/* Word 3 */
|
||||
uint8_t in_op; /* operator for indirection */
|
||||
@ -224,6 +232,8 @@ struct magic {
|
||||
uint8_t hl[4]; /* 4 bytes of a fixed-endian "long" */
|
||||
uint8_t hq[8]; /* 8 bytes of a fixed-endian "quad" */
|
||||
char s[MAXstring]; /* the search string or regex pattern */
|
||||
float f;
|
||||
double d;
|
||||
} value; /* either number or string */
|
||||
/* Words 17..31 */
|
||||
char desc[MAXDESC]; /* description */
|
||||
|
@ -1,78 +1,75 @@
|
||||
.TH FILE __CSECTION__ "Copyright but distributable"
|
||||
.\" $Id: file.man,v 1.57 2005/08/18 15:18:22 christos Exp $
|
||||
.SH NAME
|
||||
file
|
||||
\- determine file type
|
||||
.SH SYNOPSIS
|
||||
.B file
|
||||
[
|
||||
.B \-bchikLnNprsvz
|
||||
]
|
||||
[
|
||||
.B \-f
|
||||
.I namefile
|
||||
]
|
||||
[
|
||||
.B \-F
|
||||
.I separator
|
||||
]
|
||||
[
|
||||
.B \-m
|
||||
.I magicfiles
|
||||
]
|
||||
.I file
|
||||
\&...
|
||||
.br
|
||||
.B file
|
||||
.B -C
|
||||
[
|
||||
.B \-m
|
||||
magicfile ]
|
||||
.SH DESCRIPTION
|
||||
.\" $File: file.man,v 1.66 2007/10/23 19:58:59 christos Exp $
|
||||
.Dd January 8, 2007
|
||||
.Dt FILE __CSECTION__
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm file
|
||||
.Nd determine file type
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl bchikLnNprsvz
|
||||
.Op Fl mime-type
|
||||
.Op Fl mime-encoding
|
||||
.Op Fl f Ar namefile
|
||||
.Op Fl F Ar separator
|
||||
.Op Fl m Ar magicfiles
|
||||
.Ar file
|
||||
.Nm
|
||||
.Fl C
|
||||
.Op Fl m Ar magicfile
|
||||
.Sh DESCRIPTION
|
||||
This manual page documents version __VERSION__ of the
|
||||
.B file
|
||||
.Nm
|
||||
command.
|
||||
.PP
|
||||
.B File
|
||||
.Pp
|
||||
.Nm
|
||||
tests each argument in an attempt to classify it.
|
||||
There are three sets of tests, performed in this order:
|
||||
filesystem tests, magic number tests, and language tests.
|
||||
The
|
||||
.I first
|
||||
.Em first
|
||||
test that succeeds causes the file type to be printed.
|
||||
.PP
|
||||
.Pp
|
||||
The type printed will usually contain one of the words
|
||||
.B text
|
||||
.Em text
|
||||
(the file contains only
|
||||
printing characters and a few common control
|
||||
characters and is probably safe to read on an
|
||||
.SM ASCII
|
||||
.Dv ASCII
|
||||
terminal),
|
||||
.B executable
|
||||
.Em executable
|
||||
(the file contains the result of compiling a program
|
||||
in a form understandable to some \s-1UNIX\s0 kernel or another),
|
||||
in a form understandable to some
|
||||
.Dv UNIX
|
||||
kernel or another),
|
||||
or
|
||||
.B data
|
||||
meaning anything else (data is usually `binary' or non-printable).
|
||||
.Em data
|
||||
meaning anything else (data is usually
|
||||
.Sq binary
|
||||
or non-printable).
|
||||
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,
|
||||
.B "preserve these keywords" .
|
||||
.Pa __MAGIC__
|
||||
or the program itself, make sure to
|
||||
.Em "preserve these keywords" .
|
||||
People depend on knowing that all the readable files in a directory
|
||||
have the word ``text'' printed.
|
||||
Don't do as Berkeley did and change ``shell commands text''
|
||||
to ``shell script''.
|
||||
have the word
|
||||
.Dq text
|
||||
printed.
|
||||
Don't do as Berkeley did and change
|
||||
.Dq shell commands text
|
||||
to
|
||||
.Dq shell script .
|
||||
Note that the file
|
||||
.I __MAGIC__
|
||||
.Pa __MAGIC__
|
||||
is built mechanically from a large number of small files in
|
||||
the subdirectory
|
||||
.I Magdir
|
||||
.Pa Magdir
|
||||
in the source distribution of this program.
|
||||
.PP
|
||||
.Pp
|
||||
The filesystem tests are based on examining the return from a
|
||||
.BR stat (2)
|
||||
.Xr stat 2
|
||||
system call.
|
||||
The program checks to see if the file is empty,
|
||||
or if it's some sort of special file.
|
||||
@ -81,36 +78,42 @@ 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 <sys/stat.h> .
|
||||
.PP
|
||||
.In 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
|
||||
.Dv a.out
|
||||
file, whose format is defined in
|
||||
.I a.out.h
|
||||
.In elf.h ,
|
||||
.In a.out.h
|
||||
and possibly
|
||||
.I exec.h
|
||||
.In exec.h
|
||||
in the standard include directory.
|
||||
These files have a `magic number' stored in a particular place
|
||||
near the beginning of the file that tells the \s-1UNIX\s0 operating system
|
||||
These files have a
|
||||
.Sq "magic number"
|
||||
stored in a particular place
|
||||
near the beginning of the file that tells the
|
||||
.Dv UNIX operating system
|
||||
that the file is a binary executable, and which of several types thereof.
|
||||
The concept of `magic number' has been applied by extension to data files.
|
||||
The concept of a
|
||||
.Sq "magic number"
|
||||
has been applied by extension to data files.
|
||||
Any file with some invariant identifier at a small fixed
|
||||
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 ,
|
||||
.Pa __MAGIC__.mgc ,
|
||||
or
|
||||
.I __MAGIC__
|
||||
.Pa __MAGIC__
|
||||
if the compile file does not exist. In addition
|
||||
.B file
|
||||
.Nm
|
||||
will look in
|
||||
.I $HOME/.magic.mgc ,
|
||||
.Pa $HOME/.magic.mgc ,
|
||||
or
|
||||
.I $HOME/.magic
|
||||
.Pa $HOME/.magic
|
||||
for magic entries.
|
||||
.PP
|
||||
.Pp
|
||||
If a file does not match any of the entries in the magic file,
|
||||
it is examined to see if it seems to be a text file.
|
||||
ASCII, ISO-8859-x, non-ISO 8-bit extended-ASCII character sets
|
||||
@ -121,270 +124,320 @@ ranges and sequences of bytes that constitute printable text
|
||||
in each set.
|
||||
If a file passes any of these tests, its character set is reported.
|
||||
ASCII, ISO-8859-x, UTF-8, and extended-ASCII files are identified
|
||||
as ``text'' because they will be mostly readable on nearly any terminal;
|
||||
UTF-16 and EBCDIC are only ``character data'' because, while
|
||||
as
|
||||
.Dq text
|
||||
because they will be mostly readable on nearly any terminal;
|
||||
UTF-16 and EBCDIC are only
|
||||
.Dq character data
|
||||
because, while
|
||||
they contain text, it is text that will require translation
|
||||
before it can be read.
|
||||
In addition,
|
||||
.B file
|
||||
.Nm
|
||||
will attempt to determine other characteristics of text-type files.
|
||||
If the lines of a file are terminated by CR, CRLF, or NEL, instead
|
||||
of the Unix-standard LF, this will be reported.
|
||||
Files that contain embedded escape sequences or overstriking
|
||||
will also be identified.
|
||||
.PP
|
||||
.Pp
|
||||
Once
|
||||
.B file
|
||||
.Nm
|
||||
has determined the character set used in a text-type file,
|
||||
it will
|
||||
attempt to determine in what language the file is written.
|
||||
The language tests look for particular strings (cf
|
||||
.IR names.h )
|
||||
.In names.h
|
||||
that can appear anywhere in the first few blocks of a file.
|
||||
For example, the keyword
|
||||
.B .br
|
||||
.Em .br
|
||||
indicates that the file is most likely a
|
||||
.BR troff (1)
|
||||
.Xr troff 1
|
||||
input file, just as the keyword
|
||||
.B struct
|
||||
.Em 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
|
||||
.BR tar (1)
|
||||
.Xr tar 1
|
||||
archives).
|
||||
.PP
|
||||
.Pp
|
||||
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, \-\-brief"
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width indent
|
||||
.It Fl b , -brief
|
||||
Do not prepend filenames to output lines (brief mode).
|
||||
.TP 8
|
||||
.B "\-c, \-\-checking\-printout"
|
||||
.It Fl c , -checking-printout
|
||||
Cause a checking printout of the parsed form of the magic file.
|
||||
This is usually used in conjunction with
|
||||
.B \-m
|
||||
to debug a new magic file before installing it.
|
||||
.TP 8
|
||||
.B "\-C, \-\-compile"
|
||||
Write a magic.mgc output file that contains a pre-parsed version of
|
||||
file.
|
||||
.TP 8
|
||||
.BI "\-f, \-\-files\-from" " namefile"
|
||||
This is usually used in conjunction with the
|
||||
.Fl m
|
||||
flag to debug a new magic file before installing it.
|
||||
.It Fl C , -compile
|
||||
Write a
|
||||
.Pa magic.mgc
|
||||
output file that contains a pre-parsed version of the magic file.
|
||||
.It Fl e , -exclude Ar testname
|
||||
Exclude the test named in
|
||||
.Ar testname
|
||||
from the list of tests made to determine the file type. Valid test names
|
||||
are:
|
||||
.Bl -tag -width
|
||||
.It apptype
|
||||
Check for
|
||||
.Dv EMX
|
||||
application type (only on EMX).
|
||||
.It ascii
|
||||
Check for various types of ascii files.
|
||||
.It compress
|
||||
Don't look for, or inside compressed files.
|
||||
.It elf
|
||||
Don't print elf details.
|
||||
.It fortran
|
||||
Don't look for fortran sequences inside ascii files.
|
||||
.It soft
|
||||
Don't consult magic files.
|
||||
.It tar
|
||||
Don't examine tar files.
|
||||
.It token
|
||||
Don't look for known tokens inside ascii files.
|
||||
.It troff
|
||||
Don't look for troff sequences inside ascii files.
|
||||
.El
|
||||
.It Fl f , -files-from Ar namefile
|
||||
Read the names of the files to be examined from
|
||||
.I namefile
|
||||
.Ar namefile
|
||||
(one per line)
|
||||
before the argument list.
|
||||
Either
|
||||
.I namefile
|
||||
.Ar 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" " separator"
|
||||
to test the standard input, use
|
||||
.Sq -
|
||||
as a filename argument.
|
||||
.It Fl F , -separator Ar separator
|
||||
Use the specified string as the separator between the filename and the
|
||||
file result returned. Defaults to ``:''.
|
||||
.TP 8
|
||||
.B "\-h, \-\-no-dereference"
|
||||
file result returned. Defaults to
|
||||
.Sq \&: .
|
||||
.It Fl h , -no-dereference
|
||||
option causes symlinks not to be followed
|
||||
(on systems that support symbolic links). This is the default if the
|
||||
environment variable
|
||||
.I POSIXLY_CORRECT
|
||||
.Dv POSIXLY_CORRECT
|
||||
is not defined.
|
||||
.TP 8
|
||||
.B "\-i, \-\-mime"
|
||||
.It Fl i , -mime
|
||||
Causes the file command to output mime type strings rather than the more
|
||||
traditional human readable ones. Thus it may say
|
||||
``text/plain; charset=us-ascii''
|
||||
rather
|
||||
than ``ASCII text''.
|
||||
.Dq text/plain charset=us-ascii
|
||||
rather than
|
||||
.Dq ASCII text .
|
||||
In order for this option to work, file changes the way
|
||||
it handles files recognised by the command itself (such as many of the
|
||||
it handles files recognized by the command itself (such as many of the
|
||||
text file types, directories etc), and makes use of an alternative
|
||||
``magic'' file.
|
||||
(See ``FILES'' section, below).
|
||||
.TP 8
|
||||
.B "\-k, \-\-keep\-going"
|
||||
.Dq magic
|
||||
file.
|
||||
(See
|
||||
.Dq FILES
|
||||
section, below).
|
||||
.It Fl -mime-type , -mime-encoding
|
||||
Like
|
||||
.Fl i ,
|
||||
but print only the specified element(s).
|
||||
.It Fl k , -keep-going
|
||||
Don't stop at the first match, keep going.
|
||||
.TP 8
|
||||
.B "\-L, \-\-dereference"
|
||||
.It Fl L , -dereference
|
||||
option causes symlinks to be followed, as the like-named option in
|
||||
.BR ls (1)
|
||||
.Xr ls 1
|
||||
(on systems that support symbolic links).
|
||||
This is the default if the environment variable
|
||||
.I POSIXLY_CORRECT
|
||||
.Dv POSIXLY_CORRECT
|
||||
is defined.
|
||||
.TP 8
|
||||
.BI "\-m, \-\-magic\-file" " list"
|
||||
.It Fl m , -magic-file Ar 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"
|
||||
With the
|
||||
.Fl i
|
||||
or
|
||||
.Fl "mime"
|
||||
option, the program adds
|
||||
.Dq .mime
|
||||
to each file name.
|
||||
.It Fl 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"
|
||||
.It Fl N , -no-pad
|
||||
Don't pad filenames so that they align in the output.
|
||||
.TP 8
|
||||
.B "\-p, \-\-preserve\-date"
|
||||
.It Fl p , -preserve-date
|
||||
On systems that support
|
||||
.BR utime (2)
|
||||
.Xr utime 2
|
||||
or
|
||||
.BR utimes(2),
|
||||
.Xr utimes 2 ,
|
||||
attempt to preserve the access time of files analyzed, to pretend that
|
||||
.BR file (2)
|
||||
.Nm
|
||||
never read them.
|
||||
.TP 8
|
||||
.B "\-r, \-\-raw"
|
||||
.It Fl r , -raw
|
||||
Don't translate unprintable characters to \eooo.
|
||||
Normally
|
||||
.B file
|
||||
.Nm
|
||||
translates unprintable characters to their octal representation.
|
||||
.TP 8
|
||||
.B "\-s, \-\-special\-files"
|
||||
.It Fl s , -special-files
|
||||
Normally,
|
||||
.B file
|
||||
.Nm
|
||||
only attempts to read and determine the type of argument files which
|
||||
.BR stat (2)
|
||||
.Xr stat 2
|
||||
reports are ordinary files.
|
||||
This prevents problems, because reading special files may have peculiar
|
||||
consequences.
|
||||
Specifying the
|
||||
.BR \-s
|
||||
.Fl s
|
||||
option causes
|
||||
.B file
|
||||
.Nm
|
||||
to also read argument files which are block or character special files.
|
||||
This is useful for determining the filesystem types of the data in raw
|
||||
disk partitions, which are block special files.
|
||||
This option also causes
|
||||
.B file
|
||||
.Nm
|
||||
to disregard the file size as reported by
|
||||
.BR stat (2)
|
||||
.Xr stat 2
|
||||
since on some systems it reports a zero size for raw disk partitions.
|
||||
.TP 8
|
||||
.B "\-v, \-\-version"
|
||||
.It Fl v , -version
|
||||
Print the version of the program and exit.
|
||||
.TP 8
|
||||
.B "\-z, \-\-uncompress"
|
||||
.It Fl z , -uncompress
|
||||
Try to look inside compressed files.
|
||||
.TP 8
|
||||
.B "\-\-help"
|
||||
.It Fl 0 , -print0
|
||||
Output a null character
|
||||
.Sq \e0
|
||||
after the end of the filename. Nice to
|
||||
.Xr cut 1
|
||||
the output. This does not affect the separator which is still printed.
|
||||
.It Fl -help
|
||||
Print a help message and exit.
|
||||
.SH FILES
|
||||
.TP
|
||||
.I __MAGIC__.mgc
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width __MAGIC__.mime.mgc -compact
|
||||
.It Pa __MAGIC__.mgc
|
||||
Default compiled list of magic numbers
|
||||
.TP
|
||||
.I __MAGIC__
|
||||
.It Pa __MAGIC__
|
||||
Default list of magic numbers
|
||||
.TP
|
||||
.I __MAGIC__.mime.mgc
|
||||
.It Pa __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
|
||||
is specified.
|
||||
|
||||
.SH ENVIRONMENT
|
||||
the
|
||||
.Fl i
|
||||
option is specified.
|
||||
.It Pa __MAGIC__.mime
|
||||
Default list of magic numbers, used to output mime types when the
|
||||
.Fl i
|
||||
option is specified.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
The environment variable
|
||||
.B MAGIC
|
||||
.Dv MAGIC
|
||||
can be used to set the default magic number file name.
|
||||
If that variable is set, then
|
||||
.B file
|
||||
.Nm
|
||||
will not attempt to open
|
||||
.B $HOME/.magic .
|
||||
.B file
|
||||
adds ".mime" and/or ".mgc" to the value of this variable as appropriate.
|
||||
.Pa $HOME/.magic .
|
||||
.Nm
|
||||
adds
|
||||
.Dq .mime
|
||||
and/or
|
||||
.Dq .mgc
|
||||
to the value of this variable as appropriate.
|
||||
The environment variable
|
||||
.B POSIXLY_CORRECT
|
||||
.Dv POSIXLY_CORRECT
|
||||
controls (on systems that support symbolic links), if
|
||||
.B file
|
||||
.Nm
|
||||
will attempt to follow symlinks or not. If set, then
|
||||
.B file
|
||||
.Nm
|
||||
follows symlink, otherwise it does not. This is also controlled
|
||||
by the
|
||||
.B L
|
||||
.Fl L
|
||||
and
|
||||
.B h
|
||||
.Fl h
|
||||
options.
|
||||
.SH SEE ALSO
|
||||
.BR magic (__FSECTION__)
|
||||
\- description of magic file format.
|
||||
.br
|
||||
.BR strings (1), " od" (1), " hexdump(1)"
|
||||
\- tools for examining non-textfiles.
|
||||
.SH STANDARDS CONFORMANCE
|
||||
.Sh SEE ALSO
|
||||
.Xr magic __FSECTION__ ,
|
||||
.Xr strings 1 ,
|
||||
.Xr od 1 ,
|
||||
.Xr hexdump 1
|
||||
.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.
|
||||
Its behaviour is mostly compatible with the System V program of the same name.
|
||||
Its behavior 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.
|
||||
.PP
|
||||
.\" URL: http://www.opengroup.org/onlinepubs/009695399/utilities/file.html
|
||||
.Pp
|
||||
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
|
||||
.Bd -literal -offset indent
|
||||
>10 string language impress\ (imPRESS data)
|
||||
.br
|
||||
.Ed
|
||||
.Pp
|
||||
in an existing magic file would have to be changed to
|
||||
.br
|
||||
.Bd -literal -offset indent
|
||||
>10 string language\e impress (imPRESS data)
|
||||
.br
|
||||
.Ed
|
||||
.Pp
|
||||
In addition, in this version, if a pattern string contains a backslash,
|
||||
it must be escaped.
|
||||
For example
|
||||
.br
|
||||
.Bd -literal -offset indent
|
||||
0 string \ebegindata Andrew Toolkit document
|
||||
.br
|
||||
.Ed
|
||||
.Pp
|
||||
in an existing magic file would have to be changed to
|
||||
.br
|
||||
.Bd -literal -offset indent
|
||||
0 string \e\ebegindata Andrew Toolkit document
|
||||
.br
|
||||
.PP
|
||||
.Ed
|
||||
.Pp
|
||||
SunOS releases 3.2 and later from Sun Microsystems include a
|
||||
.BR file (1)
|
||||
.Nm
|
||||
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 `&' operator, used as,
|
||||
It includes the extension of the
|
||||
.Sq &
|
||||
operator, used as,
|
||||
for example,
|
||||
.br
|
||||
.Bd -literal -offset indent
|
||||
>16 long&0x7fffffff >0 not stripped
|
||||
.SH MAGIC DIRECTORY
|
||||
.Ed
|
||||
.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
|
||||
will be distributed periodically.
|
||||
.PP
|
||||
.Pp
|
||||
The order of entries in the magic file is significant.
|
||||
Depending on what system you are using, the order that
|
||||
they are put together may be incorrect.
|
||||
If your old
|
||||
.B file
|
||||
.Nm
|
||||
command uses a magic file,
|
||||
keep the old magic file around for comparison purposes
|
||||
(rename it to
|
||||
.IR __MAGIC__.orig ).
|
||||
.SH EXAMPLES
|
||||
.nf
|
||||
.Pa __MAGIC__.orig ).
|
||||
.Sh EXAMPLES
|
||||
.Bd -literal -offset indent
|
||||
$ file file.c file /dev/{wd0a,hda}
|
||||
file.c: C program text
|
||||
file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
|
||||
dynamically linked (uses shared libs), stripped
|
||||
/dev/wd0a: block special (0/0)
|
||||
/dev/hda: block special (3/0)
|
||||
|
||||
$ 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}
|
||||
/dev/hda: x86 boot sector
|
||||
/dev/hda1: Linux/i386 ext2 filesystem
|
||||
@ -400,130 +453,147 @@ $ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
|
||||
|
||||
$ file -i file.c file /dev/{wd0a,hda}
|
||||
file.c: text/x-c
|
||||
file: application/x-executable, dynamically linked (uses shared libs),
|
||||
not stripped
|
||||
file: application/x-executable
|
||||
/dev/hda: application/x-not-regular-file
|
||||
/dev/wd0a: application/x-not-regular-file
|
||||
|
||||
.fi
|
||||
.SH HISTORY
|
||||
.Ed
|
||||
.Sh HISTORY
|
||||
There has been a
|
||||
.B file
|
||||
command in every \s-1UNIX\s0 since at least Research Version 4
|
||||
.Nm
|
||||
command in every
|
||||
.Dv UNIX since at least Research Version 4
|
||||
(man page dated November, 1973).
|
||||
The System V version introduced one significant major change:
|
||||
the external list of magic number types.
|
||||
This slowed the program down slightly but made it a lot more flexible.
|
||||
.PP
|
||||
.Pp
|
||||
This program, based on the System V version,
|
||||
was written by Ian Darwin <ian@darwinsys.com>
|
||||
without looking at anybody else's source code.
|
||||
.PP
|
||||
.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 `&' operator by Rob McMahon, cudcv@warwick.ac.uk, 1989.
|
||||
.PP
|
||||
.Pp
|
||||
Guy Harris, guy@netapp.com, made many changes from 1993 to the present.
|
||||
.PP
|
||||
.Pp
|
||||
Primary development and maintenance from 1990 to the present by
|
||||
Christos Zoulas (christos@astron.com).
|
||||
.PP
|
||||
.Pp
|
||||
Altered by Chris Lowth, chris@lowth.com, 2000:
|
||||
Handle the ``-i'' option to output mime type strings and using an alternative
|
||||
Handle the
|
||||
.Fl i
|
||||
option to output mime type strings and using an alternative
|
||||
magic file and internal logic.
|
||||
.PP
|
||||
.Pp
|
||||
Altered by Eric Fischer (enf@pobox.com), July, 2000,
|
||||
to identify character codes and attempt to identify the languages
|
||||
of non-ASCII files.
|
||||
.PP
|
||||
.Pp
|
||||
The list of contributors to the "Magdir" directory (source for the
|
||||
.I __MAGIC__
|
||||
.Pa __MAGIC__
|
||||
file) is too long to include here.
|
||||
You know who you are; thank you.
|
||||
.SH LEGAL NOTICE
|
||||
.Sh LEGAL NOTICE
|
||||
Copyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999.
|
||||
Covered by the standard Berkeley Software Distribution copyright; see the file
|
||||
LEGAL.NOTICE in the source distribution.
|
||||
.PP
|
||||
.Pp
|
||||
The files
|
||||
.I tar.h
|
||||
.Dv tar.h
|
||||
and
|
||||
.I is_tar.c
|
||||
.Dv is_tar.c
|
||||
were written by John Gilmore from his public-domain
|
||||
.B tar
|
||||
.Xr tar 1
|
||||
program, and are not covered by the above license.
|
||||
.SH BUGS
|
||||
.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)
|
||||
or, better yet, fixed-length
|
||||
.SM ASCII
|
||||
strings for use in heterogenous network environments) for faster startup.
|
||||
Then the program would run as fast as the Version 7 program of the same name,
|
||||
with the flexibility of the System V version.
|
||||
.PP
|
||||
.B File
|
||||
.\" Compilation support has been done
|
||||
.\" Better yet, the magic file should be compiled into binary (say,
|
||||
.\" .Xr ndbm 3
|
||||
.\" or, better yet, fixed-length
|
||||
.\" .Dv ASCII
|
||||
.\" strings for use in heterogenous network environments) for faster startup.
|
||||
.\" Then the program would run as fast as the Version 7 program of the same
|
||||
.\" name, with the flexibility of the System V version.
|
||||
.Pp
|
||||
.Nm
|
||||
uses several algorithms that favor speed over accuracy,
|
||||
thus it can be misled about the contents of
|
||||
text
|
||||
files.
|
||||
.PP
|
||||
The support for
|
||||
text
|
||||
files (primarily for programming languages)
|
||||
.Pp
|
||||
The support for text files (primarily for programming languages)
|
||||
is simplistic, inefficient and requires recompilation to update.
|
||||
.PP
|
||||
There should be an ``else'' clause to follow a series of continuation lines.
|
||||
.PP
|
||||
The magic file and keywords should have regular expression support.
|
||||
.\" Else support has been done
|
||||
.\" There should be an
|
||||
.\" .Dv else
|
||||
.\" clause to follow a series of continuation lines.
|
||||
.\" .Pp
|
||||
.\" Regular expression support has been done
|
||||
.\" The magic file and keywords should have regular expression support.
|
||||
Their use of
|
||||
.SM "ASCII TAB"
|
||||
.Dv ASCII TAB
|
||||
as a field delimiter is ugly and makes
|
||||
it hard to edit the files, but is entrenched.
|
||||
.PP
|
||||
.Pp
|
||||
It might be advisable to allow upper-case letters in keywords
|
||||
for e.g.,
|
||||
.BR troff (1)
|
||||
.Xr troff 1
|
||||
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
|
||||
.Pp
|
||||
The program doesn't grok
|
||||
.Dv FORTRAN .
|
||||
It should be able to figure
|
||||
.Dv FORTRAN
|
||||
by seeing some keywords which
|
||||
appear indented at the start of line.
|
||||
Regular expression support would make this easy.
|
||||
.PP
|
||||
.Pp
|
||||
The list of keywords in
|
||||
.I ascmagic
|
||||
.Dv ascmagic
|
||||
probably belongs in the Magic file.
|
||||
This could be done by using some keyword like `*' for the offset value.
|
||||
.PP
|
||||
Another optimisation would be to sort
|
||||
the magic file so that we can just run down all the
|
||||
tests for the first byte, first word, first long, etc, once we
|
||||
have fetched it.
|
||||
This could be done by using some keyword like
|
||||
.Sq *
|
||||
for the offset value.
|
||||
.Pp
|
||||
.\" Sorting has been done.
|
||||
.\" Another optimization would be to sort
|
||||
.\" the magic file so that we can just run down all the
|
||||
.\" tests for the first byte, first word, first long, etc, once we
|
||||
.\" have fetched it.
|
||||
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
|
||||
.Pp
|
||||
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:'').
|
||||
of
|
||||
.Dq how good
|
||||
a guess is.
|
||||
We end up removing guesses (e.g.
|
||||
.Dq From\
|
||||
as first 5 chars of file) because
|
||||
they are not as good as other guesses (e.g.
|
||||
.Dq Newsgroups:
|
||||
versus
|
||||
.Dq Return-Path:
|
||||
).
|
||||
Still, if the others don't pan out, it should be possible to use the
|
||||
first guess.
|
||||
.PP
|
||||
.Pp
|
||||
This program is slower than some vendors' file commands.
|
||||
The new support for multiple character codes makes it even slower.
|
||||
.PP
|
||||
.Pp
|
||||
This manual page, and particularly this section, is too long.
|
||||
.SH AVAILABILITY
|
||||
.Sh AVAILABILITY
|
||||
You can obtain the original author's latest version by anonymous FTP
|
||||
on
|
||||
.B ftp.astron.com
|
||||
.Dv ftp.astron.com
|
||||
in the directory
|
||||
.I /pub/file/file-X.YZ.tar.gz
|
||||
.Dv /pub/file/file-X.YZ.tar.gz
|
||||
|
48
contrib/file/file_opts.h
Normal file
48
contrib/file/file_opts.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Table of command-line options
|
||||
*
|
||||
* The first column specifies the short name, if any, or 0 if none.
|
||||
* The second column specifies the long name.
|
||||
* The third column specifies whether it takes a parameter.
|
||||
* The fourth column is the documentation.
|
||||
*
|
||||
* N.B. The long options' order must correspond to the code in file.c,
|
||||
* and OPTSTRING must be kept up-to-date with the short options.
|
||||
* Pay particular attention to the numbers of long-only options in the
|
||||
* switch statement!
|
||||
*/
|
||||
|
||||
OPT_LONGONLY("help", 0, " display this help and exit\n")
|
||||
OPT('v', "version", 0, " output version information and exit\n")
|
||||
OPT('m', "magic-file", 1, " LIST use LIST as a colon-separated list of magic\n"
|
||||
" number files\n")
|
||||
OPT('z', "uncompress", 0, " try to look inside compressed files\n")
|
||||
OPT('b', "brief", 0, " do not prepend filenames to output lines\n")
|
||||
OPT('c', "checking-printout", 0, " print the parsed form of the magic file, use in\n"
|
||||
" conjunction with -m to debug a new magic file\n"
|
||||
" before installing it\n")
|
||||
OPT('e', "exclude", 1, " TEST exclude TEST from the list of test to be\n"
|
||||
" performed for file. Valid tests are:\n"
|
||||
" ascii, apptype, compress, elf, soft, tar, tokens, troff\n")
|
||||
OPT('f', "files-from", 1, " FILE read the filenames to be examined from FILE\n")
|
||||
OPT('F', "separator", 1, " STRING use string as separator instead of `:'\n")
|
||||
OPT('i', "mime", 0, " output MIME type strings (--mime-type and\n"
|
||||
" --mime-encoding)\n")
|
||||
OPT_LONGONLY("mime-type", 0, " output the MIME type\n")
|
||||
OPT_LONGONLY("mime-encoding", 0, " output the MIME encoding\n")
|
||||
OPT('k', "keep-going", 0, " don't stop at the first match\n")
|
||||
#ifdef S_IFLNK
|
||||
OPT('L', "dereference", 0, " follow symlinks (default)\n")
|
||||
OPT('h', "no-dereference", 0, " don't follow symlinks\n")
|
||||
#endif
|
||||
OPT('n', "no-buffer", 0, " do not buffer output\n")
|
||||
OPT('N', "no-pad", 0, " do not pad output\n")
|
||||
OPT('0', "print0", 0, " terminate filenames with ASCII NUL\n")
|
||||
#if defined(HAVE_UTIME) || defined(HAVE_UTIMES)
|
||||
OPT('p', "preserve-date", 0, " preserve access times on files\n")
|
||||
#endif
|
||||
OPT('r', "raw", 0, " don't translate unprintable chars to \\ooo\n")
|
||||
OPT('s', "special-files", 0, " treat special (block/char devices) files as\n"
|
||||
" ordinary ones\n")
|
||||
OPT('C', "compile", 0, " compile file specified by -m\n")
|
||||
OPT('d', "debug", 0, " print debugging messages\n")
|
@ -57,13 +57,14 @@
|
||||
#undef HAVE_MAJOR
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: fsmagic.c,v 1.47 2007/01/12 17:38:28 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: fsmagic.c,v 1.48 2007/10/17 19:33:31 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
protected int
|
||||
file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
|
||||
{
|
||||
int ret = 0;
|
||||
int mime = ms->flags & MAGIC_MIME;
|
||||
#ifdef S_IFLNK
|
||||
char buf[BUFSIZ+4];
|
||||
int nch;
|
||||
@ -95,11 +96,12 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((ms->flags & MAGIC_MIME) != 0) {
|
||||
if (mime) {
|
||||
if ((sb->st_mode & S_IFMT) != S_IFREG) {
|
||||
if (file_printf(ms, "application/x-not-regular-file")
|
||||
if ((mime & MAGIC_MIME_TYPE) &&
|
||||
file_printf(ms, "application/x-not-regular-file")
|
||||
== -1)
|
||||
return -1;
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -303,8 +305,9 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
|
||||
* when we read the file.)
|
||||
*/
|
||||
if ((ms->flags & MAGIC_DEVICES) == 0 && sb->st_size == 0) {
|
||||
if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
|
||||
"application/x-empty" : "empty") == -1)
|
||||
if ((!mime || (mime & MAGIC_MIME_TYPE)) &&
|
||||
file_printf(ms, mime ? "application/x-empty" :
|
||||
"empty") == -1)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
@ -41,14 +41,14 @@
|
||||
#endif
|
||||
#ifndef SIZE_T_MAX
|
||||
#ifdef __LP64__
|
||||
#define SIZE_T_MAX (size_t)0xfffffffffffffffffU
|
||||
#define SIZE_T_MAX (size_t)0xffffffffffffffffU
|
||||
#else
|
||||
#define SIZE_T_MAX (size_t)0xffffffffU
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: funcs.c,v 1.32 2007/05/24 17:22:27 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: funcs.c,v 1.35 2007/12/27 16:35:59 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
@ -62,12 +62,16 @@ protected int
|
||||
file_printf(struct magic_set *ms, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
size_t len, size;
|
||||
size_t size;
|
||||
ssize_t len;
|
||||
char *buf;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
if ((len = vsnprintf(ms->o.ptr, ms->o.left, fmt, ap)) >= ms->o.left) {
|
||||
len = vsnprintf(ms->o.ptr, ms->o.left, fmt, ap);
|
||||
if (len == -1)
|
||||
goto out;
|
||||
if (len >= (ssize_t)ms->o.left) {
|
||||
long diff; /* XXX: really ptrdiff_t */
|
||||
|
||||
va_end(ap);
|
||||
@ -84,11 +88,16 @@ file_printf(struct magic_set *ms, const char *fmt, ...)
|
||||
|
||||
va_start(ap, fmt);
|
||||
len = vsnprintf(ms->o.ptr, ms->o.left, fmt, ap);
|
||||
if (len == -1)
|
||||
goto out;
|
||||
}
|
||||
va_end(ap);
|
||||
ms->o.ptr += len;
|
||||
ms->o.left -= len;
|
||||
return 0;
|
||||
out:
|
||||
file_error(ms, errno, "vsnprintf failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -164,59 +173,73 @@ protected int
|
||||
file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
|
||||
size_t nb)
|
||||
{
|
||||
int m;
|
||||
int m;
|
||||
int mime = ms->flags & MAGIC_MIME;
|
||||
|
||||
if (nb == 0) {
|
||||
if ((!mime || (mime & MAGIC_MIME_TYPE)) &&
|
||||
file_printf(ms, mime ? "application/x-empty" :
|
||||
"empty") == -1)
|
||||
return -1;
|
||||
return 1;
|
||||
} else if (nb == 1) {
|
||||
if ((!mime || (mime & MAGIC_MIME_TYPE)) &&
|
||||
file_printf(ms, mime ? "application/octet-stream" :
|
||||
"very short file (no magic)") == -1)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef __EMX__
|
||||
if ((ms->flags & MAGIC_NO_CHECK_APPTYPE) == 0 && inname) {
|
||||
switch (file_os2_apptype(ms, inname, buf, nb)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
if ((ms->flags & MAGIC_NO_CHECK_APPTYPE) == 0 && inname) {
|
||||
switch (file_os2_apptype(ms, inname, buf, nb)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* try compression stuff */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_COMPRESS) != 0 ||
|
||||
(m = file_zmagic(ms, fd, inname, buf, nb)) == 0) {
|
||||
/* Check if we have a tar file */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_TAR) != 0 ||
|
||||
(m = file_is_tar(ms, buf, nb)) == 0) {
|
||||
/* try tests in /etc/magic (or surrogate magic file) */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_SOFT) != 0 ||
|
||||
(m = file_softmagic(ms, buf, nb)) == 0) {
|
||||
/* try known keywords, check whether it is ASCII */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_ASCII) != 0 ||
|
||||
(m = file_ascmagic(ms, buf, nb)) == 0) {
|
||||
/* abandon hope, all ye who remain here */
|
||||
if (file_printf(ms, ms->flags & MAGIC_MIME ?
|
||||
(nb ? "application/octet-stream" :
|
||||
"application/empty") :
|
||||
(nb ? "data" :
|
||||
"empty")) == -1)
|
||||
return -1;
|
||||
m = 1;
|
||||
/* try compression stuff */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_COMPRESS) != 0 ||
|
||||
(m = file_zmagic(ms, fd, inname, buf, nb)) == 0) {
|
||||
/* Check if we have a tar file */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_TAR) != 0 ||
|
||||
(m = file_is_tar(ms, buf, nb)) == 0) {
|
||||
/* try tests in /etc/magic (or surrogate magic file) */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_SOFT) != 0 ||
|
||||
(m = file_softmagic(ms, buf, nb)) == 0) {
|
||||
/* try known keywords, check whether it is ASCII */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_ASCII) != 0 ||
|
||||
(m = file_ascmagic(ms, buf, nb)) == 0) {
|
||||
/* abandon hope, all ye who remain here */
|
||||
if ((!mime || (mime & MAGIC_MIME_TYPE)) &&
|
||||
file_printf(ms, mime ? "application/octet-stream" :
|
||||
"data") == -1)
|
||||
return -1;
|
||||
m = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef BUILTIN_ELF
|
||||
if ((ms->flags & MAGIC_NO_CHECK_ELF) == 0 && m == 1 && nb > 5 && fd != -1) {
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
(void)file_tryelf(ms, fd, buf, nb);
|
||||
}
|
||||
if ((ms->flags & MAGIC_NO_CHECK_ELF) == 0 && m == 1 &&
|
||||
nb > 5 && fd != -1) {
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
(void)file_tryelf(ms, fd, buf, nb);
|
||||
}
|
||||
#endif
|
||||
return m;
|
||||
return m;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2005-05-14.22
|
||||
scriptversion=2006-10-14.15
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
@ -39,15 +39,24 @@ scriptversion=2005-05-14.22
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
# from scratch.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
if test -z "$doit"; then
|
||||
doit_exec=exec
|
||||
else
|
||||
doit_exec=$doit
|
||||
fi
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
@ -58,7 +67,13 @@ stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
chmodcmd="$chmodprog 0755"
|
||||
posix_glob=
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
chgrpcmd=
|
||||
stripcmd=
|
||||
@ -95,7 +110,7 @@ Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test -n "$1"; do
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) shift
|
||||
continue;;
|
||||
@ -111,9 +126,15 @@ while test -n "$1"; do
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
-m) mode=$2
|
||||
shift
|
||||
shift
|
||||
case $mode in
|
||||
*' '* | *' '* | *'
|
||||
'* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
@ -136,25 +157,33 @@ while test -n "$1"; do
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
*) # When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
test -n "$dir_arg$dstarg" && break
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dstarg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dstarg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dstarg=$arg
|
||||
done
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test -z "$1"; then
|
||||
if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dstarg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dstarg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dstarg=$arg
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
@ -164,6 +193,33 @@ if test -z "$1"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
@ -173,15 +229,11 @@ do
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
src=
|
||||
|
||||
if test -d "$dst"; then
|
||||
mkdircmd=:
|
||||
chmodcmd=
|
||||
else
|
||||
mkdircmd=$mkdirprog
|
||||
fi
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
@ -208,53 +260,188 @@ do
|
||||
echo "$0: $dstarg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst/`basename "$src"`
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||
dstdir=`
|
||||
(dirname "$dst") 2>/dev/null ||
|
||||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$dst" : 'X\(//\)[^/]' \| \
|
||||
X"$dst" : 'X\(//\)$' \| \
|
||||
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$dst" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'
|
||||
`
|
||||
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
# This sed command emulates the dirname command.
|
||||
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if test ! -d "$dstdir"; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-$defaultIFS}"
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
oIFS=$IFS
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
shift
|
||||
IFS=$oIFS
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
pathcomp=
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
while test $# -ne 0 ; do
|
||||
pathcomp=$pathcomp$1
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writeable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix=/ ;;
|
||||
-*) prefix=./ ;;
|
||||
*) prefix= ;;
|
||||
esac
|
||||
|
||||
case $posix_glob in
|
||||
'')
|
||||
if (set -f) 2>/dev/null; then
|
||||
posix_glob=true
|
||||
else
|
||||
posix_glob=false
|
||||
fi ;;
|
||||
esac
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
$posix_glob && set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
if test ! -d "$pathcomp"; then
|
||||
$mkdirprog "$pathcomp"
|
||||
# mkdir can fail with a `File exist' error in case several
|
||||
# install-sh are creating the directory concurrently. This
|
||||
# is OK.
|
||||
test -d "$pathcomp" || exit
|
||||
$posix_glob && set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test -z "$d" && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
pathcomp=$pathcomp/
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
$doit $mkdircmd "$dst" \
|
||||
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
|
||||
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
|
||||
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
|
||||
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
|
||||
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
dstfile=`basename "$dst"`
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
@ -262,10 +449,9 @@ do
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
$doit $cpprog "$src" "$dsttmp" &&
|
||||
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
@ -276,10 +462,10 @@ do
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
|
||||
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
|
||||
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
|
||||
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
|
||||
&& { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|
||||
{ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \
|
||||
|| {
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
@ -291,11 +477,12 @@ do
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
if test -f "$dstdir/$dstfile"; then
|
||||
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|
||||
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|
||||
if test -f "$dst"; then
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null \
|
||||
|| { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \
|
||||
&& { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\
|
||||
|| {
|
||||
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
|
||||
echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
else
|
||||
@ -304,16 +491,13 @@ do
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
}
|
||||
fi || { (exit 1); exit 1; }
|
||||
done
|
||||
} || exit 1
|
||||
|
||||
# The final little trick to "correctly" pass the exit status to the exit trap.
|
||||
{
|
||||
(exit 0); exit 0
|
||||
}
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include "tar.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: is_tar.c,v 1.27 2007/01/12 17:38:28 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: is_tar.c,v 1.29 2007/10/17 19:33:31 christos Exp $")
|
||||
#endif
|
||||
|
||||
#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
|
||||
@ -53,6 +53,12 @@ FILE_RCSID("@(#)$File: is_tar.c,v 1.27 2007/01/12 17:38:28 christos Exp $")
|
||||
private int is_tar(const unsigned char *, size_t);
|
||||
private int from_oct(int, const char *); /* Decode octal number */
|
||||
|
||||
static const char *tartype[] = {
|
||||
"tar archive",
|
||||
"POSIX tar archive",
|
||||
"POSIX tar archive (GNU)",
|
||||
};
|
||||
|
||||
protected int
|
||||
file_is_tar(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
|
||||
{
|
||||
@ -60,26 +66,19 @@ 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;
|
||||
case 3:
|
||||
if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
|
||||
"application/x-tar, POSIX (GNU)" :
|
||||
"POSIX tar archive (GNU)") == -1)
|
||||
return -1;
|
||||
return 1;
|
||||
default:
|
||||
int tar = is_tar(buf, nbytes);
|
||||
int mime = ms->flags & MAGIC_MIME;
|
||||
|
||||
if (tar < 1 || tar > 3)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mime == MAGIC_MIME_ENCODING)
|
||||
return 0;
|
||||
|
||||
if (file_printf(ms, mime ? "application/x-tar" :
|
||||
tartype[tar - 1]) == -1)
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd March 22, 2003
|
||||
.Dd November 15, 2006
|
||||
.Dt MAGIC 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -87,8 +87,10 @@ 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_MIME_TYPE
|
||||
Return a MIME type string, instead of a textual description.
|
||||
.It Dv MAGIC_MIME_ENCODING
|
||||
Return a MIME encoding, instead of a textual description.
|
||||
.It Dv MAGIC_CONTINUE
|
||||
Return all matches, not just the first.
|
||||
.It Dv MAGIC_CHECK
|
||||
@ -104,6 +106,26 @@ 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.
|
||||
.It Dv MAGIC_NO_CHECK_APPTYPE
|
||||
Check for
|
||||
.Dv EMX
|
||||
application type (only on EMX).
|
||||
.It Dv MAGIC_NO_CHECK_ASCII
|
||||
Check for various types of ascii files.
|
||||
.It Dv MAGIC_NO_CHECK_COMPRESS
|
||||
Don't look for, or inside compressed files.
|
||||
.It Dv MAGIC_NO_CHECK_ELF
|
||||
Don't print elf details.
|
||||
.It Dv MAGIC_NO_CHECK_FORTRAN
|
||||
Don't look for fortran sequences inside ascii files.
|
||||
.It Dv MAGIC_NO_CHECK_SOFT
|
||||
Don't consult magic files.
|
||||
.It Dv MAGIC_NO_CHECK_TAR
|
||||
Don't examine tar files.
|
||||
.It Dv MAGIC_NO_CHECK_TOKENS
|
||||
Don't look for known tokens inside ascii files.
|
||||
.It Dv MAGIC_NO_CHECK_TROFF
|
||||
Don't look for troff sequences inside ascii files.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
@ -119,8 +141,8 @@ no error.
|
||||
.Pp
|
||||
The
|
||||
.Fn magic_errno
|
||||
function returns the last operating system error number (
|
||||
.Xr errno 3 )
|
||||
function returns the last operating system error number
|
||||
.Pq Xr errno 2
|
||||
that was encountered by a system call.
|
||||
.Pp
|
||||
The
|
||||
@ -144,7 +166,8 @@ The
|
||||
.Fn magic_setflags
|
||||
function, sets the
|
||||
.Ar flags
|
||||
described above.
|
||||
described above. Note that using both MIME flags together can also
|
||||
return extra information on the charset.
|
||||
.Pp
|
||||
The
|
||||
.Fn magic_check
|
||||
|
@ -63,7 +63,7 @@
|
||||
#include "patchlevel.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: magic.c,v 1.41 2007/03/26 17:59:50 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: magic.c,v 1.45 2007/12/27 16:35:59 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#ifdef __EMX__
|
||||
@ -76,6 +76,9 @@ private void free_mlist(struct mlist *);
|
||||
private void close_and_restore(const struct magic_set *, const char *, int,
|
||||
const struct stat *);
|
||||
private int info_from_stat(struct magic_set *, mode_t);
|
||||
#ifndef COMPILE_ONLY
|
||||
private const char *file_or_fd(struct magic_set *, const char *, int);
|
||||
#endif
|
||||
|
||||
#ifndef STDIN_FILENO
|
||||
#define STDIN_FILENO 0
|
||||
@ -230,13 +233,28 @@ close_and_restore(const struct magic_set *ms, const char *name, int fd,
|
||||
}
|
||||
|
||||
#ifndef COMPILE_ONLY
|
||||
|
||||
/*
|
||||
* find type of descriptor
|
||||
*/
|
||||
public const char *
|
||||
magic_descriptor(struct magic_set *ms, int fd)
|
||||
{
|
||||
return file_or_fd(ms, NULL, fd);
|
||||
}
|
||||
|
||||
/*
|
||||
* find type of named file
|
||||
*/
|
||||
public const char *
|
||||
magic_file(struct magic_set *ms, const char *inname)
|
||||
{
|
||||
int fd = 0;
|
||||
return file_or_fd(ms, inname, STDIN_FILENO);
|
||||
}
|
||||
|
||||
private const char *
|
||||
file_or_fd(struct magic_set *ms, const char *inname, int fd)
|
||||
{
|
||||
int rv = -1;
|
||||
unsigned char *buf;
|
||||
struct stat sb;
|
||||
@ -265,7 +283,6 @@ magic_file(struct magic_set *ms, const char *inname)
|
||||
}
|
||||
|
||||
if (inname == NULL) {
|
||||
fd = STDIN_FILENO;
|
||||
if (fstat(fd, &sb) == 0 && S_ISFIFO(sb.st_mode))
|
||||
ispipe = 1;
|
||||
} else {
|
||||
@ -279,16 +296,16 @@ magic_file(struct magic_set *ms, const char *inname)
|
||||
errno = 0;
|
||||
if ((fd = open(inname, flags)) < 0) {
|
||||
#ifdef __CYGWIN__
|
||||
char *tmp = alloca(strlen(inname) + 5);
|
||||
(void)strcat(strcpy(tmp, inname), ".exe");
|
||||
if ((fd = open(tmp, flags)) < 0) {
|
||||
char *tmp = alloca(strlen(inname) + 5);
|
||||
(void)strcat(strcpy(tmp, inname), ".exe");
|
||||
if ((fd = open(tmp, flags)) < 0) {
|
||||
#endif
|
||||
if (info_from_stat(ms, sb.st_mode) == -1)
|
||||
goto done;
|
||||
rv = 0;
|
||||
goto done;
|
||||
if (info_from_stat(ms, sb.st_mode) == -1)
|
||||
goto done;
|
||||
rv = 0;
|
||||
goto done;
|
||||
#ifdef __CYGWIN__
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef O_NONBLOCK
|
||||
@ -326,18 +343,9 @@ magic_file(struct magic_set *ms, const char *inname)
|
||||
}
|
||||
}
|
||||
|
||||
if (nbytes == 0) {
|
||||
if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
|
||||
"application/x-empty" : "empty") == -1)
|
||||
goto done;
|
||||
} else if (nbytes == 1) {
|
||||
if (file_printf(ms, "very short file (no magic)") == -1)
|
||||
goto done;
|
||||
} else {
|
||||
(void)memset(buf + nbytes, 0, SLOP); /* NUL terminate */
|
||||
if (file_buffer(ms, fd, inname, buf, (size_t)nbytes) == -1)
|
||||
goto done;
|
||||
}
|
||||
(void)memset(buf + nbytes, 0, SLOP); /* NUL terminate */
|
||||
if (file_buffer(ms, fd, inname, buf, (size_t)nbytes) == -1)
|
||||
goto done;
|
||||
rv = 0;
|
||||
done:
|
||||
free(buf);
|
||||
|
@ -34,21 +34,25 @@
|
||||
#define MAGIC_SYMLINK 0x000002 /* Follow symlinks */
|
||||
#define MAGIC_COMPRESS 0x000004 /* Check inside compressed files */
|
||||
#define MAGIC_DEVICES 0x000008 /* Look at the contents of devices */
|
||||
#define MAGIC_MIME 0x000010 /* Return a mime string */
|
||||
#define MAGIC_MIME_TYPE 0x000010 /* Return only the MIME type */
|
||||
#define MAGIC_CONTINUE 0x000020 /* Return all matches */
|
||||
#define MAGIC_CHECK 0x000040 /* Print warnings to stderr */
|
||||
#define MAGIC_PRESERVE_ATIME 0x000080 /* Restore access time on exit */
|
||||
#define MAGIC_RAW 0x000100 /* Don't translate unprintable chars */
|
||||
#define MAGIC_RAW 0x000100 /* Don't translate unprint chars */
|
||||
#define MAGIC_ERROR 0x000200 /* Handle ENOENT etc as real errors */
|
||||
#define MAGIC_NO_CHECK_COMPRESS 0x001000 /* Don't check for compressed files */
|
||||
#define MAGIC_NO_CHECK_TAR 0x002000 /* Don't check for tar files */
|
||||
#define MAGIC_NO_CHECK_SOFT 0x004000 /* Don't check magic entries */
|
||||
#define MAGIC_NO_CHECK_APPTYPE 0x008000 /* Don't check application type */
|
||||
#define MAGIC_NO_CHECK_ELF 0x010000 /* Don't check for elf details */
|
||||
#define MAGIC_NO_CHECK_ASCII 0x020000 /* Don't check for ascii files */
|
||||
#define MAGIC_NO_CHECK_TROFF 0x040000 /* Don't check ascii/troff */
|
||||
#define MAGIC_NO_CHECK_FORTRAN 0x080000 /* Don't check ascii/fortran */
|
||||
#define MAGIC_NO_CHECK_TOKENS 0x100000 /* Don't check ascii/tokens */
|
||||
#define MAGIC_MIME_ENCODING 0x000400 /* Return only the MIME encoding */
|
||||
#define MAGIC_MIME (MAGIC_MIME_TYPE|MAGIC_MIME_ENCODING)
|
||||
#define MAGIC_NO_CHECK_COMPRESS 0x001000 /* Don't check for compressed files */
|
||||
#define MAGIC_NO_CHECK_TAR 0x002000 /* Don't check for tar files */
|
||||
#define MAGIC_NO_CHECK_SOFT 0x004000 /* Don't check magic entries */
|
||||
#define MAGIC_NO_CHECK_APPTYPE 0x008000 /* Don't check application type */
|
||||
#define MAGIC_NO_CHECK_ELF 0x010000 /* Don't check for elf details */
|
||||
#define MAGIC_NO_CHECK_ASCII 0x020000 /* Don't check for ascii files */
|
||||
#define MAGIC_NO_CHECK_TROFF 0x040000 /* Don't check ascii/troff */
|
||||
#define MAGIC_NO_CHECK_TOKENS 0x100000 /* Don't check ascii/tokens */
|
||||
|
||||
/* Defined for backwards compatibility; does nothing */
|
||||
#define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -59,6 +63,7 @@ magic_t magic_open(int);
|
||||
void magic_close(magic_t);
|
||||
|
||||
const char *magic_file(magic_t, const char *);
|
||||
const char *magic_descriptor(magic_t, int);
|
||||
const char *magic_buffer(magic_t, const void *, size_t);
|
||||
|
||||
const char *magic_error(magic_t);
|
||||
|
@ -1,389 +1,460 @@
|
||||
.TH MAGIC __FSECTION__ "Public Domain"
|
||||
.\" $File: magic.man,v 1.39 2007/11/08 00:31:37 christos Exp $
|
||||
.Dd January 10, 2007
|
||||
.Dt MAGIC __FSECTION__
|
||||
.Os
|
||||
.\" install as magic.4 on USG, magic.5 on V7 or Berkeley systems.
|
||||
.SH NAME
|
||||
magic \- file command's magic number file
|
||||
.SH DESCRIPTION
|
||||
.Sh NAME
|
||||
.Nm magic
|
||||
.Nd file command's magic number file
|
||||
.Sh DESCRIPTION
|
||||
This manual page documents the format of the magic file as
|
||||
used by the
|
||||
.BR file (__CSECTION__)
|
||||
.Xr file __CSECTION__
|
||||
command, version __VERSION__.
|
||||
The
|
||||
.BR file
|
||||
.Xr file __CSECTION__
|
||||
command identifies the type of a file using,
|
||||
among other tests,
|
||||
a test for whether the file begins with a certain
|
||||
.IR "magic number" .
|
||||
.Dq "magic number" .
|
||||
The file
|
||||
.I __MAGIC__
|
||||
.Pa __MAGIC__
|
||||
specifies what magic numbers are to be tested for,
|
||||
what message to print if a particular magic number is found,
|
||||
and additional information to extract from the file.
|
||||
.PP
|
||||
.Pp
|
||||
Each line of the file specifies a test to be performed.
|
||||
A test compares the data starting at a particular offset
|
||||
in the file with a 1-byte, 2-byte, or 4-byte numeric value or
|
||||
a string.
|
||||
If the test succeeds, a message is printed.
|
||||
The line consists of the following fields:
|
||||
.IP offset \w'message'u+2n
|
||||
.Bl -tag -width ".Dv message"
|
||||
.It Dv offset
|
||||
A number specifying the offset, in bytes, into the file of the data
|
||||
which is to be tested.
|
||||
.IP type
|
||||
.It Dv type
|
||||
The type of the data to be tested.
|
||||
The possible values are:
|
||||
.RS
|
||||
.IP byte \w'message'u+2n
|
||||
.Bl -tag -width ".Dv lestring16"
|
||||
.It Dv byte
|
||||
A one-byte value.
|
||||
.IP short
|
||||
.It Dv short
|
||||
A two-byte value (on most systems) in this machine's native byte order.
|
||||
.IP long
|
||||
.It Dv long
|
||||
A four-byte value (on most systems) in this machine's native byte order.
|
||||
.IP string
|
||||
.It Dv quad
|
||||
An eight-byte value (on most systems) in this machine's native byte order.
|
||||
.It Dv float
|
||||
A 32-bit (on most systems) single precision IEEE floating point number in this machine's native byte order.
|
||||
.It Dv double
|
||||
A 64-bit (on most systems) double precision IEEE floating point number in this machine's native byte order.
|
||||
.It Dv string
|
||||
A string of bytes.
|
||||
The string type specification can be optionally followed
|
||||
by /[Bbc]*.
|
||||
The ``B'' flag compacts whitespace in the target, which must
|
||||
The
|
||||
.Dq B
|
||||
flag compacts whitespace in the target, which must
|
||||
contain at least one whitespace character.
|
||||
If the magic has
|
||||
.I n
|
||||
.Dv n
|
||||
consecutive blanks, the target needs at least
|
||||
.I n
|
||||
.Dv n
|
||||
consecutive blanks to match.
|
||||
The ``b'' flag treats every blank in the target as an optional blank.
|
||||
Finally the ``c'' flag, specifies case insensitive matching: lowercase
|
||||
The
|
||||
.Dq b
|
||||
flag treats every blank in the target as an optional blank.
|
||||
Finally the
|
||||
.Dq c
|
||||
flag, specifies case insensitive matching: lowercase
|
||||
characters in the magic match both lower and upper case characters in the
|
||||
targer, whereas upper case characters in the magic, only much uppercase
|
||||
characters in the target.
|
||||
.IP pstring
|
||||
.It Dv pstring
|
||||
A pascal style string where the first byte is interpreted as the an
|
||||
unsigned length. The string is not NUL terminated.
|
||||
.IP date
|
||||
unsigned length.
|
||||
The string is not NUL terminated.
|
||||
.It Dv date
|
||||
A four-byte value interpreted as a UNIX date.
|
||||
.IP ldate
|
||||
.It Dv qdate
|
||||
A eight-byte value interpreted as a UNIX date.
|
||||
.It Dv ldate
|
||||
A four-byte value interpreted as a UNIX-style date, but interpreted as
|
||||
local time rather than UTC.
|
||||
.IP beshort
|
||||
.It Dv qldate
|
||||
An eight-byte value interpreted as a UNIX-style date, but interpreted as
|
||||
local time rather than UTC.
|
||||
.It Dv beshort
|
||||
A two-byte value (on most systems) in big-endian byte order.
|
||||
.IP belong
|
||||
.It Dv belong
|
||||
A four-byte value (on most systems) in big-endian byte order.
|
||||
.IP bedate
|
||||
.It Dv bequad
|
||||
An eight-byte value (on most systems) in big-endian byte order.
|
||||
.It Dv befloat
|
||||
A 32-bit (on most systems) single precision IEEE floating point number in big-endian byte order.
|
||||
.It Dv bedouble
|
||||
A 64-bit (on most systems) double precision IEEE floating point number in big-endian byte order.
|
||||
.It Dv bedate
|
||||
A four-byte value (on most systems) in big-endian byte order,
|
||||
interpreted as a Unix date.
|
||||
.IP beldate
|
||||
.It Dv beqdate
|
||||
An eight-byte value (on most systems) in big-endian byte order,
|
||||
interpreted as a Unix date.
|
||||
.It Dv beldate
|
||||
A four-byte value (on most systems) in big-endian byte order,
|
||||
interpreted as a UNIX-style date, but interpreted as local time rather
|
||||
than UTC.
|
||||
.IP bestring16
|
||||
.It Dv beqldate
|
||||
An eight-byte value (on most systems) in big-endian byte order,
|
||||
interpreted as a UNIX-style date, but interpreted as local time rather
|
||||
than UTC.
|
||||
.It Dv bestring16
|
||||
A two-byte unicode (UCS16) string in big-endian byte order.
|
||||
.IP leshort
|
||||
.It Dv leshort
|
||||
A two-byte value (on most systems) in little-endian byte order.
|
||||
.IP lelong
|
||||
.It Dv lelong
|
||||
A four-byte value (on most systems) in little-endian byte order.
|
||||
.IP ledate
|
||||
.It Dv lequad
|
||||
An eight-byte value (on most systems) in little-endian byte order.
|
||||
.It Dv lefloat
|
||||
A 32-bit (on most systems) single precision IEEE floating point number in little-endian byte order.
|
||||
.It Dv ledouble
|
||||
A 64-bit (on most systems) double precision IEEE floating point number in little-endian byte order.
|
||||
.It Dv ledate
|
||||
A four-byte value (on most systems) in little-endian byte order,
|
||||
interpreted as a UNIX date.
|
||||
.IP leldate
|
||||
.It Dv leqdate
|
||||
An eight-byte value (on most systems) in little-endian byte order,
|
||||
interpreted as a UNIX date.
|
||||
.It Dv leldate
|
||||
A four-byte value (on most systems) in little-endian byte order,
|
||||
interpreted as a UNIX-style date, but interpreted as local time rather
|
||||
than UTC.
|
||||
.IP lestring16
|
||||
.It Dv leqldate
|
||||
An eight-byte value (on most systems) in little-endian byte order,
|
||||
interpreted as a UNIX-style date, but interpreted as local time rather
|
||||
than UTC.
|
||||
.It Dv lestring16
|
||||
A two-byte unicode (UCS16) string in little-endian byte order.
|
||||
.IP melong
|
||||
.It Dv melong
|
||||
A four-byte value (on most systems) in middle-endian (PDP-11) byte order.
|
||||
.IP medate
|
||||
.It Dv medate
|
||||
A four-byte value (on most systems) in middle-endian (PDP-11) byte order,
|
||||
interpreted as a UNIX date.
|
||||
.IP meldate
|
||||
.It Dv meldate
|
||||
A four-byte value (on most systems) in middle-endian (PDP-11) byte order,
|
||||
interpreted as a UNIX-style date, but interpreted as local time rather
|
||||
than UTC.
|
||||
.IP regex
|
||||
.It Dv regex
|
||||
A regular expression match in extended POSIX regular expression syntax
|
||||
(much like egrep).
|
||||
The type specification can be optionally followed by
|
||||
.B /c
|
||||
for case-insensitive matches.
|
||||
The regular expression is always
|
||||
tested against the first
|
||||
.B N
|
||||
The type specification can be optionally followed by /[cse]*.
|
||||
The
|
||||
.Dq c
|
||||
flag makes the match case insensitive, while the
|
||||
.Dq s
|
||||
or
|
||||
.Dq e
|
||||
flags update the offset to the starting or ending offsets of the
|
||||
match (only one should be used).
|
||||
By default, regex does not update the offset.
|
||||
The regular expression is always tested against the first
|
||||
.Dv N
|
||||
lines, where
|
||||
.B N
|
||||
.Dv N
|
||||
is the given offset, thus it
|
||||
is only useful for (single-byte encoded) text.
|
||||
.B ^
|
||||
.Dv ^
|
||||
and
|
||||
.B $
|
||||
.Dv $
|
||||
will match the beginning and end of individual lines, respectively,
|
||||
not beginning and end of file.
|
||||
.IP search
|
||||
A literal string search starting at the given offset. It must be followed by
|
||||
.B /<number>
|
||||
.It Dv search
|
||||
A literal string search starting at the given offset.
|
||||
It must be followed by
|
||||
.Dv \*[Lt]number\*[Gt]
|
||||
which specifies how many matches shall be attempted (the range).
|
||||
This is suitable for searching larger binary expressions with variable
|
||||
offsets, using
|
||||
.B \e
|
||||
.Dv \e
|
||||
escapes for special characters.
|
||||
.RE
|
||||
.PP
|
||||
.It Dv default
|
||||
This is intended to be used with the text
|
||||
.Dv x
|
||||
(which is always true) and a message that is to be used if there are
|
||||
no other matches.
|
||||
.El
|
||||
.El
|
||||
.Pp
|
||||
The numeric types may optionally be followed by
|
||||
.B &
|
||||
.Dv \*[Am]
|
||||
and a numeric value,
|
||||
to specify that the value is to be AND'ed with the
|
||||
numeric value before any comparisons are done.
|
||||
Prepending a
|
||||
.B u
|
||||
.Dv u
|
||||
to the type indicates that ordered comparisons should be unsigned.
|
||||
.IP test
|
||||
.Bl -tag -width ".Dv message"
|
||||
.It Dv test
|
||||
The value to be compared with the value from the file.
|
||||
If the type is
|
||||
numeric, this value
|
||||
is specified in C form; if it is a string, it is specified as a C string
|
||||
with the usual escapes permitted (e.g. \en for new-line).
|
||||
.IP
|
||||
.Pp
|
||||
Numeric values
|
||||
may be preceded by a character indicating the operation to be performed.
|
||||
It may be
|
||||
.BR = ,
|
||||
.Dv = ,
|
||||
to specify that the value from the file must equal the specified value,
|
||||
.BR < ,
|
||||
.Dv \*[Lt] ,
|
||||
to specify that the value from the file must be less than the specified
|
||||
value,
|
||||
.BR > ,
|
||||
.Dv \*[Gt] ,
|
||||
to specify that the value from the file must be greater than the specified
|
||||
value,
|
||||
.BR & ,
|
||||
.Dv \*[Am] ,
|
||||
to specify that the value from the file must have set all of the bits
|
||||
that are set in the specified value,
|
||||
.BR ^ ,
|
||||
.Dv ^ ,
|
||||
to specify that the value from the file must have clear any of the bits
|
||||
that are set in the specified value, or
|
||||
.BR ~ ,
|
||||
.Dv ~ ,
|
||||
the value specified after is negated before tested.
|
||||
.BR x ,
|
||||
.Dv x ,
|
||||
to specify that any value will match.
|
||||
If the character is omitted, it is assumed to be
|
||||
.BR = .
|
||||
For all tests except
|
||||
.B string
|
||||
.Dv = .
|
||||
Operators
|
||||
.Dv \*[Am] ,
|
||||
.Dv ^ ,
|
||||
and
|
||||
.B regex,
|
||||
.Dv ~
|
||||
don't work with floats and doubles.
|
||||
For all tests except
|
||||
.Em string
|
||||
and
|
||||
.Em regex ,
|
||||
operation
|
||||
.BR !
|
||||
.Dv !
|
||||
specifies that the line matches if the test does
|
||||
.B not
|
||||
.Em not
|
||||
succeed.
|
||||
.IP
|
||||
.Pp
|
||||
Numeric values are specified in C form; e.g.
|
||||
.B 13
|
||||
.Dv 13
|
||||
is decimal,
|
||||
.B 013
|
||||
.Dv 013
|
||||
is octal, and
|
||||
.B 0x13
|
||||
.Dv 0x13
|
||||
is hexadecimal.
|
||||
.IP
|
||||
.Pp
|
||||
For string values, the byte string from the
|
||||
file must match the specified byte string.
|
||||
The operators
|
||||
.BR = ,
|
||||
.B <
|
||||
.Dv = ,
|
||||
.Dv \*[Lt]
|
||||
and
|
||||
.B >
|
||||
.Dv \*[Gt]
|
||||
(but not
|
||||
.BR & )
|
||||
.Dv \*[Am] )
|
||||
can be applied to strings.
|
||||
The length used for matching is that of the string argument
|
||||
in the magic file.
|
||||
This means that a line can match any string, and
|
||||
then presumably print that string, by doing
|
||||
.B >\e0
|
||||
.Em \*[Gt]\e0
|
||||
(because all strings are greater than the null string).
|
||||
.IP message
|
||||
The message to be printed if the comparison succeeds. If the string
|
||||
contains a
|
||||
.BR printf (3)
|
||||
.Pp
|
||||
The special test
|
||||
.Em x
|
||||
always evaluates to true.
|
||||
.Dv message
|
||||
The message to be printed if the comparison succeeds.
|
||||
If the string contains a
|
||||
.Xr printf 3
|
||||
format specification, the value from the file (with any specified masking
|
||||
performed) is printed using the message as the format string.
|
||||
.PP
|
||||
If the string begins with ``\\b'', the message printed is the
|
||||
remainder of the string with no whitespace added before it: multiple
|
||||
matches are normally separated by a single space.
|
||||
.El
|
||||
.Pp
|
||||
Some file formats contain additional information which is to be printed
|
||||
along with the file type or need additional tests to determine the true
|
||||
file type.
|
||||
These additional tests are introduced by one or more
|
||||
.B >
|
||||
.Em \*[Gt]
|
||||
characters preceding the offset.
|
||||
The number of
|
||||
.B >
|
||||
.Em \*[Gt]
|
||||
on the line indicates the level of the test; a line with no
|
||||
.B >
|
||||
.Em \*[Gt]
|
||||
at the beginning is considered to be at level 0.
|
||||
Tests are arranged in a tree-like hierarchy:
|
||||
If a the test on a line at level
|
||||
.IB n
|
||||
.Em n
|
||||
succeeds, all following tests at level
|
||||
.IB n+1
|
||||
.Em n+1
|
||||
are performed, and the messages printed if the tests succeed, untile a line
|
||||
with level
|
||||
.IB n
|
||||
.Em n
|
||||
(or less) appears.
|
||||
For more complex files, one can use empty messages to get just the
|
||||
"if/then" effect, in the following way:
|
||||
.sp
|
||||
.nf
|
||||
0 string MZ
|
||||
>0x18 leshort <0x40 MS-DOS executable
|
||||
>0x18 leshort >0x3f extended PC executable (e.g., MS Windows)
|
||||
.fi
|
||||
.PP
|
||||
.Bd -literal -offset indent
|
||||
0 string MZ
|
||||
\*[Gt]0x18 leshort \*[Lt]0x40 MS-DOS executable
|
||||
\*[Gt]0x18 leshort \*[Gt]0x3f extended PC executable (e.g., MS Windows)
|
||||
.Ed
|
||||
.Pp
|
||||
Offsets do not need to be constant, but can also be read from the file
|
||||
being examined.
|
||||
If the first character following the last
|
||||
.B >
|
||||
.Em \*[Gt]
|
||||
is a
|
||||
.B (
|
||||
.Em (
|
||||
then the string after the parenthesis is interpreted as an indirect offset.
|
||||
That means that the number after the parenthesis is used as an offset in
|
||||
the file.
|
||||
The value at that offset is read, and is used again as an offset
|
||||
in the file.
|
||||
Indirect offsets are of the form:
|
||||
.BI (( x [.[bslBSL]][+\-][ y ]).
|
||||
.Em (( x [.[bslBSL]][+\-][ y ]) .
|
||||
The value of
|
||||
.I x
|
||||
is used as an offset in the file. A byte, short or long is read at that offset
|
||||
depending on the
|
||||
.B [bslBSLm]
|
||||
.Em x
|
||||
is used as an offset in the file.
|
||||
A byte, short or long is read at that offset depending on the
|
||||
.Em [bslBSLm]
|
||||
type specifier.
|
||||
The capitalized types interpret the number as a big endian
|
||||
value, whereas the small letter versions interpret the number as a little
|
||||
endian value;
|
||||
the
|
||||
.B m
|
||||
.Em m
|
||||
type interprets the number as a middle endian (PDP-11) value.
|
||||
To that number the value of
|
||||
.I y
|
||||
.Em y
|
||||
is added and the result is used as an offset in the file.
|
||||
The default type if one is not specified is long.
|
||||
.PP
|
||||
.Pp
|
||||
That way variable length structures can be examined:
|
||||
.sp
|
||||
.nf
|
||||
# MS Windows executables are also valid MS-DOS executables
|
||||
0 string MZ
|
||||
>0x18 leshort <0x40 MZ executable (MS-DOS)
|
||||
# skip the whole block below if it is not an extended executable
|
||||
>0x18 leshort >0x3f
|
||||
>>(0x3c.l) string PE\e0\e0 PE executable (MS-Windows)
|
||||
>>(0x3c.l) string LX\e0\e0 LX executable (OS/2)
|
||||
.fi
|
||||
.PP
|
||||
.Bd -literal -offset indent
|
||||
# MS Windows executables are also valid MS-DOS executables
|
||||
0 string MZ
|
||||
\*[Gt]0x18 leshort \*[Lt]0x40 MZ executable (MS-DOS)
|
||||
# skip the whole block below if it is not an extended executable
|
||||
\*[Gt]0x18 leshort \*[Gt]0x3f
|
||||
\*[Gt]\*[Gt](0x3c.l) string PE\e0\e0 PE executable (MS-Windows)
|
||||
\*[Gt]\*[Gt](0x3c.l) string LX\e0\e0 LX executable (OS/2)
|
||||
.Ed
|
||||
.Pp
|
||||
This strategy of examining has one drawback: You must make sure that
|
||||
you eventually print something, or users may get empty output (like, when
|
||||
there is neither PE\e0\e0 nor LE\e0\e0 in the above example)
|
||||
.PP
|
||||
.Pp
|
||||
If this indirect offset cannot be used as-is, there are simple calculations
|
||||
possible: appending
|
||||
.BI [+-*/%&|^]<number>
|
||||
.Em [+-*/%\*[Am]|^]\*[Lt]number\*[Gt]
|
||||
inside parentheses allows one to modify
|
||||
the value read from the file before it is used as an offset:
|
||||
.sp
|
||||
.nf
|
||||
# MS Windows executables are also valid MS-DOS executables
|
||||
0 string MZ
|
||||
# sometimes, the value at 0x18 is less that 0x40 but there's still an
|
||||
# extended executable, simply appended to the file
|
||||
>0x18 leshort <0x40
|
||||
>>(4.s*512) leshort 0x014c COFF executable (MS-DOS, DJGPP)
|
||||
>>(4.s*512) leshort !0x014c MZ executable (MS-DOS)
|
||||
.fi
|
||||
.PP
|
||||
.Bd -literal -offset indent
|
||||
# MS Windows executables are also valid MS-DOS executables
|
||||
0 string MZ
|
||||
# sometimes, the value at 0x18 is less that 0x40 but there's still an
|
||||
# extended executable, simply appended to the file
|
||||
\*[Gt]0x18 leshort \*[Lt]0x40
|
||||
\*[Gt]\*[Gt](4.s*512) leshort 0x014c COFF executable (MS-DOS, DJGPP)
|
||||
\*[Gt]\*[Gt](4.s*512) leshort !0x014c MZ executable (MS-DOS)
|
||||
.Ed
|
||||
.Pp
|
||||
Sometimes you do not know the exact offset as this depends on the length or
|
||||
position (when indirection was used before) of preceding fields. You can
|
||||
specify an offset relative to the end of the last uplevel field using
|
||||
.BI &
|
||||
position (when indirection was used before) of preceding fields.
|
||||
You can specify an offset relative to the end of the last up-level
|
||||
field using
|
||||
.Sq \*[Am]
|
||||
as a prefix to the offset:
|
||||
.sp
|
||||
.nf
|
||||
0 string MZ
|
||||
>0x18 leshort >0x3f
|
||||
>>(0x3c.l) string PE\e0\e0 PE executable (MS-Windows)
|
||||
# immediately following the PE signature is the CPU type
|
||||
>>>&0 leshort 0x14c for Intel 80386
|
||||
>>>&0 leshort 0x184 for DEC Alpha
|
||||
.fi
|
||||
.PP
|
||||
.Bd -literal -offset indent
|
||||
0 string MZ
|
||||
\*[Gt]0x18 leshort \*[Gt]0x3f
|
||||
\*[Gt]\*[Gt](0x3c.l) string PE\e0\e0 PE executable (MS-Windows)
|
||||
# immediately following the PE signature is the CPU type
|
||||
\*[Gt]\*[Gt]\*[Gt]\*[Am]0 leshort 0x14c for Intel 80386
|
||||
\*[Gt]\*[Gt]\*[Gt]\*[Am]0 leshort 0x184 for DEC Alpha
|
||||
.Ed
|
||||
.Pp
|
||||
Indirect and relative offsets can be combined:
|
||||
.sp
|
||||
.nf
|
||||
0 string MZ
|
||||
>0x18 leshort <0x40
|
||||
>>(4.s*512) leshort !0x014c MZ executable (MS-DOS)
|
||||
# if it's not COFF, go back 512 bytes and add the offset taken
|
||||
# from byte 2/3, which is yet another way of finding the start
|
||||
# of the extended executable
|
||||
>>>&(2.s-514) string LE LE executable (MS Windows VxD driver)
|
||||
.fi
|
||||
.PP
|
||||
.Bd -literal -offset indent
|
||||
0 string MZ
|
||||
\*[Gt]0x18 leshort \*[Lt]0x40
|
||||
\*[Gt]\*[Gt](4.s*512) leshort !0x014c MZ executable (MS-DOS)
|
||||
# if it's not COFF, go back 512 bytes and add the offset taken
|
||||
# from byte 2/3, which is yet another way of finding the start
|
||||
# of the extended executable
|
||||
\*[Gt]\*[Gt]\*[Gt]\*[Am](2.s-514) string LE LE executable (MS Windows VxD driver)
|
||||
.Ed
|
||||
.Pp
|
||||
Or the other way around:
|
||||
.sp
|
||||
.nf
|
||||
0 string MZ
|
||||
>0x18 leshort >0x3f
|
||||
>>(0x3c.l) string LE\e0\e0 LE executable (MS-Windows)
|
||||
# at offset 0x80 (-4, since relative offsets start at the end
|
||||
# of the uplevel match) inside the LE header, we find the absolute
|
||||
# offset to the code area, where we look for a specific signature
|
||||
>>>(&0x7c.l+0x26) string UPX \eb, UPX compressed
|
||||
.fi
|
||||
.PP
|
||||
.Bd -literal -offset indent
|
||||
0 string MZ
|
||||
\*[Gt]0x18 leshort \*[Gt]0x3f
|
||||
\*[Gt]\*[Gt](0x3c.l) string LE\e0\e0 LE executable (MS-Windows)
|
||||
# at offset 0x80 (-4, since relative offsets start at the end
|
||||
# of the up-level match) inside the LE header, we find the absolute
|
||||
# offset to the code area, where we look for a specific signature
|
||||
\*[Gt]\*[Gt]\*[Gt](\*[Am]0x7c.l+0x26) string UPX \eb, UPX compressed
|
||||
.Ed
|
||||
.Pp
|
||||
Or even both!
|
||||
.sp
|
||||
.nf
|
||||
0 string MZ
|
||||
>0x18 leshort >0x3f
|
||||
>>(0x3c.l) string LE\e0\e0 LE executable (MS-Windows)
|
||||
# at offset 0x58 inside the LE header, we find the relative offset
|
||||
# to a data area where we look for a specific signature
|
||||
>>>&(&0x54.l-3) string UNACE \eb, ACE self-extracting archive
|
||||
.fi
|
||||
.PP
|
||||
.Bd -literal -offset indent
|
||||
0 string MZ
|
||||
\*[Gt]0x18 leshort \*[Gt]0x3f
|
||||
\*[Gt]\*[Gt](0x3c.l) string LE\e0\e0 LE executable (MS-Windows)
|
||||
# at offset 0x58 inside the LE header, we find the relative offset
|
||||
# to a data area where we look for a specific signature
|
||||
\*[Gt]\*[Gt]\*[Gt]\*[Am](\*[Am]0x54.l-3) string UNACE \eb, ACE self-extracting archive
|
||||
.Ed
|
||||
.Pp
|
||||
Finally, if you have to deal with offset/length pairs in your file, even the
|
||||
second value in a parenthesed expression can be taken from the file itself,
|
||||
using another set of parentheses. Note that this additional indirect offset
|
||||
is always relative to the start of the main indirect offset.
|
||||
.sp
|
||||
.nf
|
||||
0 string MZ
|
||||
>0x18 leshort >0x3f
|
||||
>>(0x3c.l) string PE\e0\e0 PE executable (MS-Windows)
|
||||
# search for the PE section called ".idata"...
|
||||
>>>&0xf4 search/0x140 .idata
|
||||
# ...and go to the end of it, calculated from start+length;
|
||||
# these are located 14 and 10 bytes after the section name
|
||||
>>>>(&0xe.l+(-4)) string PK\e3\e4 \eb, ZIP self-extracting archive
|
||||
.fi
|
||||
.SH BUGS
|
||||
second value in a parenthesized expression can be taken from the file itself,
|
||||
using another set of parentheses.
|
||||
Note that this additional indirect offset is always relative to the
|
||||
start of the main indirect offset.
|
||||
.Bd -literal -offset indent
|
||||
0 string MZ
|
||||
\*[Gt]0x18 leshort \*[Gt]0x3f
|
||||
\*[Gt]\*[Gt](0x3c.l) string PE\e0\e0 PE executable (MS-Windows)
|
||||
# search for the PE section called ".idata"...
|
||||
\*[Gt]\*[Gt]\*[Gt]\*[Am]0xf4 search/0x140 .idata
|
||||
# ...and go to the end of it, calculated from start+length;
|
||||
# these are located 14 and 10 bytes after the section name
|
||||
\*[Gt]\*[Gt]\*[Gt]\*[Gt](\*[Am]0xe.l+(-4)) string PK\e3\e4 \eb, ZIP self-extracting archive
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr file __CSECTION__
|
||||
\- the command that reads this file.
|
||||
.Sh BUGS
|
||||
The formats
|
||||
.IR long ,
|
||||
.IR belong ,
|
||||
.IR lelong ,
|
||||
.IR melong ,
|
||||
.IR short ,
|
||||
.IR beshort ,
|
||||
.IR leshort ,
|
||||
.IR date ,
|
||||
.IR bedate ,
|
||||
.IR medate ,
|
||||
.IR ledate ,
|
||||
.IR beldate ,
|
||||
.IR leldate ,
|
||||
.Dv long ,
|
||||
.Dv belong ,
|
||||
.Dv lelong ,
|
||||
.Dv melong ,
|
||||
.Dv short ,
|
||||
.Dv beshort ,
|
||||
.Dv leshort ,
|
||||
.Dv date ,
|
||||
.Dv bedate ,
|
||||
.Dv medate ,
|
||||
.Dv ledate ,
|
||||
.Dv beldate ,
|
||||
.Dv leldate ,
|
||||
and
|
||||
.I meldate
|
||||
.Dv meldate
|
||||
are system-dependent; perhaps they should be specified as a number
|
||||
of bytes (2B, 4B, etc),
|
||||
since the files being recognized typically come from
|
||||
a system on which the lengths are invariant.
|
||||
.SH SEE ALSO
|
||||
.BR file (__CSECTION__)
|
||||
\- the command that reads this file.
|
||||
.\"
|
||||
.\" From: guy@sun.uucp (Guy Harris)
|
||||
.\" Newsgroups: net.bugs.usg
|
||||
@ -397,4 +468,4 @@ a system on which the lengths are invariant.
|
||||
.\" the changes I posted to the S5R2 version.
|
||||
.\"
|
||||
.\" Modified for Ian Darwin's version of the file command.
|
||||
.\" @(#)$Id: magic.man,v 1.30 2006/02/19 18:16:03 christos Exp $
|
||||
.\" @(#)$Id: magic.man,v 1.39 2007/11/08 00:31:37 christos Exp $
|
||||
|
@ -1,5 +1,25 @@
|
||||
# Magic data for KMimeMagic (originally for file(1) command)
|
||||
#
|
||||
# Note on adding additional MIME types:
|
||||
#
|
||||
# [RFC2045,RFC2046] specifies that Content Types, Content Subtypes, Character
|
||||
# Sets, Access Types, and conversion values for MIME mail will be assigned and
|
||||
# listed by the IANA.
|
||||
# http://www.iana.org/assignments/media-types/
|
||||
#
|
||||
# Any unregistered file type should be listed with a preceding x-, as in
|
||||
# application/x-foo (RFC2045 5.1), or a x., as in application/x.foo (RFC4288
|
||||
# 4.3). Any non x-prefixed type should be registered with IANA and listed at
|
||||
# the above address. Any other behavior is a MIME standards violation!
|
||||
#
|
||||
# It is preferred that when a registered MIME type exists, that
|
||||
# the registered Content-Type and Subtype be used to refer to a file of
|
||||
# that type, so don't use application/x-zip when application/zip is
|
||||
# registered.
|
||||
#
|
||||
# If an active RFC suggests that a MIME registration for a new type is in
|
||||
# progress, make a note of it pointing to that RFC.
|
||||
#
|
||||
# The format is 4-5 columns:
|
||||
# Column #1: byte number to begin checking from, ">" indicates continuation
|
||||
# Column #2: type of data to match
|
||||
@ -101,6 +121,10 @@
|
||||
|
||||
38 string \<\!DOCTYPE\040svg image/svg+xml
|
||||
|
||||
0 belong 0xfeedfeed application/x-java-keystore
|
||||
|
||||
0 belong 0xcececece application/x-java-jce-keystore
|
||||
|
||||
|
||||
# xml
|
||||
0 string \<?xml text/xml
|
||||
@ -110,7 +134,8 @@
|
||||
# Java
|
||||
|
||||
0 beshort 0xcafe
|
||||
>2 beshort 0xbabe application/java
|
||||
>2 beshort 0xbabe application/x-java-applet
|
||||
>2 beshort 0xd00d application/x-java-pack200
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# audio: file(1) magic for sound formats
|
||||
@ -156,15 +181,15 @@
|
||||
|
||||
# Creative Labs AUDIO stuff
|
||||
# Standard MIDI data
|
||||
0 string MThd audio/unknown
|
||||
0 string MThd audio/x-midi
|
||||
#>9 byte >0 (format %d)
|
||||
#>11 byte >1 using %d channels
|
||||
# Creative Music (CMF) data
|
||||
0 string CTMF audio/unknown
|
||||
0 string CTMF audio/x-unknown
|
||||
# SoundBlaster instrument data
|
||||
0 string SBI audio/unknown
|
||||
0 string SBI audio/x-unknown
|
||||
# Creative Labs voice data
|
||||
0 string Creative\ Voice\ File audio/unknown
|
||||
0 string Creative\ Voice\ File audio/x-unknown
|
||||
## is this next line right? it came this way...
|
||||
#>19 byte 0x1A
|
||||
#>23 byte >0 - version %d
|
||||
@ -210,7 +235,7 @@
|
||||
|
||||
# XPM icons (Greg Roelofs, newt@uchicago.edu)
|
||||
# ideally should go into "images", but entries below would tag XPM as C source
|
||||
0 string /*\ XPM image/x-xpmi 7bit
|
||||
0 string /*\ XPM image/x-xpmi
|
||||
|
||||
# 3DS (3d Studio files) Conflicts with diff output 0x3d '='
|
||||
#16 beshort 0x3d3d image/x-3ds
|
||||
@ -273,7 +298,8 @@
|
||||
0 string #!/usr/bin/awk application/x-awk
|
||||
0 string #!\ /usr/bin/awk application/x-awk
|
||||
# update to distinguish from *.vcf files by Joerg Jenderek: joerg dot jenderek at web dot de
|
||||
0 regex BEGIN[[:space:]]*[{] application/x-awk
|
||||
# Too general, \EBEGIN matches in postscript
|
||||
#0 regex BEGIN[[:space:]]*[{] application/x-awk
|
||||
|
||||
# For Larry Wall's perl language. The ``eval'' line recognizes an
|
||||
# outrageously clever hack for USG systems.
|
||||
@ -303,7 +329,7 @@
|
||||
# gzip (GNU zip, not to be confused with [Info-ZIP/PKWARE] zip archiver)
|
||||
0 string \037\213 application/x-gzip
|
||||
|
||||
0 string PK\003\004 application/x-zip
|
||||
0 string PK\003\004 application/zip
|
||||
|
||||
# RAR archiver (Greg Roelofs, newt@uchicago.edu)
|
||||
0 string Rar! application/x-rar
|
||||
@ -389,13 +415,16 @@
|
||||
# This stuff came on a FrameMaker demo tape, most of which is
|
||||
# copyright, but this file is "published" as witness the following:
|
||||
#
|
||||
0 string \<MakerFile application/x-frame
|
||||
0 string \<MIFFile application/x-frame
|
||||
0 string \<MakerDictionary application/x-frame
|
||||
0 string \<MakerScreenFon application/x-frame
|
||||
0 string \<MML application/x-frame
|
||||
0 string \<Book application/x-frame
|
||||
0 string \<Maker application/x-frame
|
||||
# Note that this is the Framemaker Maker Interchange Format, not the
|
||||
# Normal format which would be application/vnd.framemaker.
|
||||
#
|
||||
0 string \<MakerFile application/x-mif
|
||||
0 string \<MIFFile application/x-mif
|
||||
0 string \<MakerDictionary application/x-mif
|
||||
0 string \<MakerScreenFon application/x-mif
|
||||
0 string \<MML application/x-mif
|
||||
0 string \<Book application/x-mif
|
||||
0 string \<Maker application/x-mif
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# html: file(1) magic for HTML (HyperText Markup Language) docs
|
||||
@ -429,11 +458,11 @@
|
||||
|
||||
# PBMPLUS
|
||||
# PBM file
|
||||
0 string P1 image/x-portable-bitmap 7bit
|
||||
0 string P1 image/x-portable-bitmap
|
||||
# PGM file
|
||||
0 string P2 image/x-portable-greymap 7bit
|
||||
0 string P2 image/x-portable-greymap
|
||||
# PPM file
|
||||
0 string P3 image/x-portable-pixmap 7bit
|
||||
0 string P3 image/x-portable-pixmap
|
||||
# PBM "rawbits" file
|
||||
0 string P4 image/x-portable-bitmap
|
||||
# PGM "rawbits" file
|
||||
@ -456,16 +485,16 @@
|
||||
#
|
||||
# GRR 950115: this was mine ("Zip GIF"):
|
||||
# ZIF image (GIF+deflate alpha)
|
||||
0 string GIF94z image/unknown
|
||||
0 string GIF94z image/x-unknown
|
||||
#
|
||||
# GRR 950115: this is Jeremy Wohl's Free Graphics Format (better):
|
||||
# FGF image (GIF+deflate beta)
|
||||
0 string FGF95a image/unknown
|
||||
0 string FGF95a image/x-unknown
|
||||
#
|
||||
# GRR 950115: this is Thomas Boutell's Portable Bitmap Format proposal
|
||||
# (best; not yet implemented):
|
||||
# PBF image (deflate compression)
|
||||
0 string PBF image/unknown
|
||||
0 string PBF image/x-unknown
|
||||
|
||||
# GIF
|
||||
0 string GIF image/gif
|
||||
@ -485,7 +514,7 @@
|
||||
#0 string BA bitmap array
|
||||
|
||||
# CDROM Filesystems
|
||||
32769 string CD001 application/x-iso9660
|
||||
32769 string CD001 application/x-iso9660-image
|
||||
|
||||
# Newer StuffIt archives (grant@netbsd.org)
|
||||
0 string StuffIt application/x-stuffit
|
||||
@ -501,7 +530,7 @@
|
||||
# lisp: file(1) magic for lisp programs
|
||||
#
|
||||
# various lisp types, from Daniel Quinlan (quinlan@yggdrasil.com)
|
||||
0 string ;; text/plain 8bit
|
||||
0 string ;; text/plain
|
||||
# Emacs 18 - this is always correct, but not very magical.
|
||||
0 string \012( application/x-elc
|
||||
# Emacs 19
|
||||
@ -511,17 +540,17 @@
|
||||
# mail.news: file(1) magic for mail and news
|
||||
#
|
||||
# There are tests to ascmagic.c to cope with mail and news.
|
||||
0 string Relay-Version: message/rfc822 7bit
|
||||
0 string #!\ rnews message/rfc822 7bit
|
||||
0 string N#!\ rnews message/rfc822 7bit
|
||||
0 string Forward\ to message/rfc822 7bit
|
||||
0 string Pipe\ to message/rfc822 7bit
|
||||
0 string Return-Path: message/rfc822 7bit
|
||||
0 string Relay-Version: message/rfc822
|
||||
0 string #!\ rnews message/rfc822
|
||||
0 string N#!\ rnews message/rfc822
|
||||
0 string Forward\ to message/rfc822
|
||||
0 string Pipe\ to message/rfc822
|
||||
0 string Return-Path: message/rfc822
|
||||
0 string Received: message/rfc822
|
||||
0 string Path: message/news 8bit
|
||||
0 string Xref: message/news 8bit
|
||||
0 string From: message/rfc822 7bit
|
||||
0 string Article message/news 8bit
|
||||
0 string Path: message/news
|
||||
0 string Xref: message/news
|
||||
0 string From: message/rfc822
|
||||
0 string Article message/news
|
||||
#------------------------------------------------------------------------------
|
||||
# msword: file(1) magic for MS Word files
|
||||
#
|
||||
@ -618,13 +647,13 @@
|
||||
>4 byte&0x1F 0x07 video/h264
|
||||
|
||||
# FLI animation format
|
||||
0 leshort 0xAF11 video/fli
|
||||
0 leshort 0xAF11 video/x-fli
|
||||
# FLC animation format
|
||||
0 leshort 0xAF12 video/flc
|
||||
0 leshort 0xAF12 video/x-flc
|
||||
#
|
||||
# SGI and Apple formats
|
||||
# Added ISO mimes
|
||||
0 string MOVI video/sgi
|
||||
0 string MOVI video/x-sgi-movie
|
||||
4 string moov video/quicktime
|
||||
4 string mdat video/quicktime
|
||||
4 string wide video/quicktime
|
||||
@ -632,7 +661,7 @@
|
||||
4 string free video/quicktime
|
||||
4 string idsc image/x-quicktime
|
||||
4 string idat image/x-quicktime
|
||||
4 string pckg application/x-quicktime
|
||||
4 string pckg application/x-quicktime-player
|
||||
4 string/B jP image/jp2
|
||||
4 string ftyp
|
||||
>8 string isom video/mp4
|
||||
@ -654,8 +683,8 @@
|
||||
# 255 (hex FF)! DL format SUCKS BIG ROCKS.
|
||||
#
|
||||
# DL file version 1 , medium format (160x100, 4 images/screen)
|
||||
0 byte 1 video/unknown
|
||||
0 byte 2 video/unknown
|
||||
0 byte 1 video/x-unknown
|
||||
0 byte 2 video/x-unknown
|
||||
#
|
||||
# Databases
|
||||
#
|
||||
@ -689,7 +718,7 @@
|
||||
0 string [KDE\ Desktop\ Entry] application/x-kdelnk
|
||||
0 string #\ KDE\ Config\ File application/x-kdelnk
|
||||
# xmcd database file for kscd
|
||||
0 string #\ xmcd text/xmcd
|
||||
0 string #\ xmcd text/x-xmcd
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# pkgadd: file(1) magic for SysV R4 PKG Datastreams
|
||||
@ -710,7 +739,7 @@
|
||||
0 string \211HDF\r\n\032 Hierarchical Data Format (version 5) data
|
||||
|
||||
# Adobe Photoshop
|
||||
0 string 8BPS image/x-photoshop
|
||||
0 string 8BPS image/vnd.adobe.photoshop
|
||||
|
||||
# Felix von Leitner <felix-file@fefe.de>
|
||||
0 string d8:announce application/x-bittorrent
|
||||
@ -721,7 +750,7 @@
|
||||
0 belong 0x00000200 application/x-123
|
||||
|
||||
# MS Access database
|
||||
4 string Standard\ Jet\ DB application/msaccess
|
||||
4 string Standard\ Jet\ DB application/x-msaccess
|
||||
|
||||
## magic for XBase files
|
||||
#0 byte 0x02
|
||||
@ -777,10 +806,10 @@
|
||||
# Debian has entries for the old PGP formats:
|
||||
# pgp: file(1) magic for Pretty Good Privacy
|
||||
# see http://lists.gnupg.org/pipermail/gnupg-devel/1999-September/016052.html
|
||||
0 beshort 0x9900 text/PGP key public ring
|
||||
0 beshort 0x9501 text/PGP key security ring
|
||||
0 beshort 0x9500 text/PGP key security ring
|
||||
0 beshort 0xa600 text/PGP encrypted data
|
||||
0 beshort 0x9900 application/x-pgp-keyring
|
||||
0 beshort 0x9501 application/x-pgp-keyring
|
||||
0 beshort 0x9500 application/x-pgp-keyring
|
||||
0 beshort 0xa600 application/pgp-encrypted
|
||||
0 string -----BEGIN\040PGP text/PGP armored data
|
||||
>15 string PUBLIC\040KEY\040BLOCK- public key block
|
||||
>15 string MESSAGE- message
|
||||
@ -790,7 +819,7 @@
|
||||
#
|
||||
# GnuPG Magic:
|
||||
#
|
||||
0 beshort 0x9901 text/GnuPG key public ring
|
||||
0 beshort 0x9901 application/x-gnupg-keyring
|
||||
0 beshort 0x8501 text/OpenPGP data
|
||||
|
||||
# flash: file(1) magic for Macromedia Flash file format
|
||||
@ -801,6 +830,9 @@
|
||||
#
|
||||
0 string FWS
|
||||
>3 byte x application/x-shockwave-flash
|
||||
# Flash Video
|
||||
0 string FLV video/x-flv
|
||||
|
||||
|
||||
# The following paramaters are created for Namazu.
|
||||
# <http://www.namazu.org/>
|
||||
@ -822,14 +854,14 @@
|
||||
#
|
||||
|
||||
0 string DOC
|
||||
>43 byte 0x14 application/ichitaro4
|
||||
>144 string JDASH application/ichitaro4
|
||||
>43 byte 0x14 application/x-ichitaro4
|
||||
>144 string JDASH application/x-ichitaro4
|
||||
|
||||
0 string DOC
|
||||
>43 byte 0x15 application/ichitaro5
|
||||
>43 byte 0x15 application/x-ichitaro5
|
||||
|
||||
0 string DOC
|
||||
>43 byte 0x16 application/ichitaro6
|
||||
>43 byte 0x16 application/x-ichitaro6
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# office97: file(1) magic for MicroSoft Office files
|
||||
@ -841,8 +873,8 @@
|
||||
#0 string \320\317\021\340\241\261\032\341
|
||||
#>48 byte 0x1B application/excel
|
||||
|
||||
2080 string Microsoft\ Excel\ 5.0\ Worksheet application/excel
|
||||
2114 string Biff5 application/excel
|
||||
2080 string Microsoft\ Excel\ 5.0\ Worksheet application/vnd.ms-excel
|
||||
2114 string Biff5 application/vnd.ms-excel
|
||||
|
||||
0 string \224\246\056 application/msword
|
||||
|
||||
@ -883,10 +915,10 @@
|
||||
>24 string @ application/octet-stream
|
||||
|
||||
0 string MZ
|
||||
>30 string Copyright\ 1989-1990\ PKWARE\ Inc. application/x-zip
|
||||
>30 string Copyright\ 1989-1990\ PKWARE\ Inc. application/zip
|
||||
|
||||
0 string MZ
|
||||
>30 string PKLITE\ Copr. application/x-zip
|
||||
>30 string PKLITE\ Copr. application/zip
|
||||
|
||||
0 string MZ
|
||||
>36 string LHa's\ SFX application/x-lha
|
||||
@ -910,11 +942,11 @@
|
||||
0 lelong&0x8080ffff 0x0000061a application/x-arc
|
||||
|
||||
# Microsoft Outlook's Transport Neutral Encapsulation Format (TNEF)
|
||||
0 lelong 0x223e9f78 application/ms-tnef
|
||||
0 lelong 0x223e9f78 application/vnd.ms-tnef
|
||||
|
||||
# From: stephane.loeuillet@tiscali.f
|
||||
# http://www.djvuzone.org/
|
||||
0 string AT&TFORM image/x.djvu
|
||||
0 string AT&TFORM image/vnd.djvu
|
||||
|
||||
# Danny Milosavljevic <danny.milo@gmx.net>
|
||||
# this are adrift (adventure game standard) game files, extension .taf
|
||||
@ -947,7 +979,7 @@
|
||||
0 string/c BEGIN:VCARD text/x-vcard
|
||||
0 string WordPro\0 application/vnd.lotus-wordpro
|
||||
0 string WordPro\r\373 application/vnd.lotus-wordpro
|
||||
0 string CPC\262 image/cpi
|
||||
0 string CPC\262 image/x-cpi
|
||||
|
||||
#
|
||||
128 string DICM application/dicom
|
||||
@ -955,3 +987,5 @@
|
||||
# Symbian installation files
|
||||
8 lelong 0x10000419 application/vnd.symbian.install
|
||||
0 lelong 0x10201A7A x-epoc/x-sisx-app
|
||||
# FORTRAN source
|
||||
0 string/c c\ text/x-fortran
|
||||
|
@ -1,7 +1,7 @@
|
||||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
|
||||
scriptversion=2005-06-29.22
|
||||
scriptversion=2006-05-11.19
|
||||
|
||||
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Created: 1993-05-16
|
||||
@ -11,6 +11,9 @@ scriptversion=2005-06-29.22
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
errstatus=0
|
||||
dirmode=
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
* appear at fixed offsets into the file. Don't make HOWMANY
|
||||
* too high unless you have a very fast CPU.
|
||||
*
|
||||
* $File: names.h,v 1.27 2007/05/08 16:47:03 christos Exp $
|
||||
* $File: names.h,v 1.29 2007/12/27 20:30:35 christos Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -43,19 +43,18 @@
|
||||
/* these types are used to index the table 'types': keep em in sync! */
|
||||
#define L_C 0 /* first and foremost on UNIX */
|
||||
#define L_CC 1 /* Bjarne's postincrement */
|
||||
#define L_FORT 2 /* the oldest one */
|
||||
#define L_MAKE 3 /* Makefiles */
|
||||
#define L_PLI 4 /* PL/1 */
|
||||
#define L_MACH 5 /* some kinda assembler */
|
||||
#define L_ENG 6 /* English */
|
||||
#define L_PAS 7 /* Pascal */
|
||||
#define L_MAIL 8 /* Electronic mail */
|
||||
#define L_NEWS 9 /* Usenet Netnews */
|
||||
#define L_JAVA 10 /* Java code */
|
||||
#define L_HTML 11 /* HTML */
|
||||
#define L_BCPL 12 /* BCPL */
|
||||
#define L_M4 13 /* M4 */
|
||||
#define L_PO 14 /* PO */
|
||||
#define L_MAKE 2 /* Makefiles */
|
||||
#define L_PLI 3 /* PL/1 */
|
||||
#define L_MACH 4 /* some kinda assembler */
|
||||
#define L_ENG 5 /* English */
|
||||
#define L_PAS 6 /* Pascal */
|
||||
#define L_MAIL 7 /* Electronic mail */
|
||||
#define L_NEWS 8 /* Usenet Netnews */
|
||||
#define L_JAVA 9 /* Java code */
|
||||
#define L_HTML 10 /* HTML */
|
||||
#define L_BCPL 11 /* BCPL */
|
||||
#define L_M4 12 /* M4 */
|
||||
#define L_PO 13 /* PO */
|
||||
|
||||
static const struct {
|
||||
const char *human;
|
||||
@ -63,7 +62,6 @@ static const struct {
|
||||
} types[] = {
|
||||
{ "C program", "text/x-c", },
|
||||
{ "C++ program", "text/x-c++" },
|
||||
{ "FORTRAN program", "text/x-fortran" },
|
||||
{ "make commands", "text/x-makefile" },
|
||||
{ "PL/1 program", "text/x-pl1" },
|
||||
{ "assembler program", "text/x-asm" },
|
||||
|
@ -1,11 +1,17 @@
|
||||
#define FILE_VERSION_MAJOR 4
|
||||
#define patchlevel 21
|
||||
#define patchlevel 23
|
||||
|
||||
/*
|
||||
* Patchlevel file for Ian Darwin's MAGIC command.
|
||||
* $File: patchlevel.h,v 1.65 2007/05/24 17:22:27 christos Exp $
|
||||
* $File: patchlevel.h,v 1.67 2007/12/28 20:08:40 christos Exp $
|
||||
*
|
||||
* $Log: patchlevel.h,v $
|
||||
* Revision 1.67 2007/12/28 20:08:40 christos
|
||||
* welcome to 4.23.
|
||||
*
|
||||
* Revision 1.66 2007/12/27 16:38:24 christos
|
||||
* welcome to 4.22
|
||||
*
|
||||
* Revision 1.65 2007/05/24 17:22:27 christos
|
||||
* Welcome to 4.21
|
||||
*
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: print.c,v 1.59 2007/03/05 02:41:29 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: print.c,v 1.61 2007/12/27 16:35:59 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
|
||||
@ -157,6 +157,16 @@ file_mdump(struct magic *m)
|
||||
(void)fprintf(stderr, "%s,",
|
||||
file_fmttime((uint32_t)m->value.q, 0));
|
||||
break;
|
||||
case FILE_FLOAT:
|
||||
case FILE_BEFLOAT:
|
||||
case FILE_LEFLOAT:
|
||||
(void) fprintf(stderr, "%G", m->value.f);
|
||||
break;
|
||||
case FILE_DOUBLE:
|
||||
case FILE_BEDOUBLE:
|
||||
case FILE_LEDOUBLE:
|
||||
(void) fprintf(stderr, "%G", m->value.d);
|
||||
break;
|
||||
case FILE_DEFAULT:
|
||||
/* XXX - do anything here? */
|
||||
break;
|
||||
@ -189,7 +199,7 @@ file_magwarn(struct magic_set *ms, const char *f, ...)
|
||||
protected const char *
|
||||
file_fmttime(uint32_t v, int local)
|
||||
{
|
||||
char *pp, *rt;
|
||||
char *pp;
|
||||
time_t t = (time_t)v;
|
||||
struct tm *tm;
|
||||
|
||||
@ -219,7 +229,6 @@ file_fmttime(uint32_t v, int local)
|
||||
pp = asctime(tm);
|
||||
}
|
||||
|
||||
if ((rt = strchr(pp, '\n')) != NULL)
|
||||
*rt = '\0';
|
||||
pp[strcspn(pp, "\n")] = '\0';
|
||||
return pp;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "readelf.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: readelf.c,v 1.63 2007/01/16 14:56:45 ljt Exp $")
|
||||
FILE_RCSID("@(#)$File: readelf.c,v 1.68 2007/12/27 16:13:26 christos Exp $")
|
||||
#endif
|
||||
|
||||
#ifdef ELFCORE
|
||||
@ -191,15 +191,15 @@ getu64(int swap, uint64_t value)
|
||||
#ifdef ELFCORE
|
||||
size_t prpsoffsets32[] = {
|
||||
8, /* FreeBSD */
|
||||
28, /* Linux 2.0.36 (short name) */
|
||||
44, /* Linux (path name) */
|
||||
28, /* Linux 2.0.36 (short name) */
|
||||
84, /* SunOS 5.x */
|
||||
};
|
||||
|
||||
size_t prpsoffsets64[] = {
|
||||
16, /* FreeBSD, 64-bit */
|
||||
40, /* Linux (tested on core from 2.4.x, short name) */
|
||||
56, /* Linux (path name) */
|
||||
40, /* Linux (tested on core from 2.4.x, short name) */
|
||||
120, /* SunOS 5.x, 64-bit */
|
||||
};
|
||||
|
||||
@ -241,6 +241,7 @@ private const char *os_style_names[] = {
|
||||
|
||||
#define FLAGS_DID_CORE 1
|
||||
#define FLAGS_DID_NOTE 2
|
||||
#define FLAGS_DID_CORE_STYLE 4
|
||||
|
||||
private int
|
||||
dophn_core(struct magic_set *ms, int class, int swap, int fd, off_t off,
|
||||
@ -587,10 +588,11 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
|
||||
if ((*flags & FLAGS_DID_CORE) != 0)
|
||||
return size;
|
||||
|
||||
if (os_style != -1) {
|
||||
if (os_style != -1 && (*flags & FLAGS_DID_CORE_STYLE) == 0) {
|
||||
if (file_printf(ms, ", %s-style", os_style_names[os_style])
|
||||
== -1)
|
||||
return size;
|
||||
*flags |= FLAGS_DID_CORE_STYLE;
|
||||
}
|
||||
|
||||
switch (os_style) {
|
||||
@ -615,6 +617,7 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
|
||||
if (file_printf(ms, " (signal %u)",
|
||||
getu32(swap, signo)) == -1)
|
||||
return size;
|
||||
*flags |= FLAGS_DID_CORE;
|
||||
return size;
|
||||
}
|
||||
break;
|
||||
@ -629,11 +632,12 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
|
||||
* is in SunOS 5.x and Linux).
|
||||
*
|
||||
* Unfortunately, it's at a different offset
|
||||
* in varous OSes, so try multiple offsets.
|
||||
* in various OSes, so try multiple offsets.
|
||||
* If the characters aren't all printable,
|
||||
* reject it.
|
||||
*/
|
||||
for (i = 0; i < NOFFSETS; i++) {
|
||||
unsigned char *cname, *cp;
|
||||
size_t reloffset = prpsoffsets(i);
|
||||
size_t noffset = doff + reloffset;
|
||||
for (j = 0; j < 16; j++, noffset++,
|
||||
@ -681,9 +685,16 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
|
||||
/*
|
||||
* Well, that worked.
|
||||
*/
|
||||
if (file_printf(ms, ", from '%.16s'",
|
||||
&nbuf[doff + prpsoffsets(i)]) == -1)
|
||||
cname = (unsigned char *)
|
||||
&nbuf[doff + prpsoffsets(i)];
|
||||
for (cp = cname; *cp && isprint(*cp); cp++)
|
||||
continue;
|
||||
if (cp > cname)
|
||||
cp--;
|
||||
if (file_printf(ms, ", from '%.*s'",
|
||||
(int)(cp - cname), cname) == -1)
|
||||
return size;
|
||||
*flags |= FLAGS_DID_CORE;
|
||||
return size;
|
||||
|
||||
tryanother:
|
||||
@ -693,7 +704,6 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
*flags |= FLAGS_DID_CORE;
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -884,6 +894,8 @@ dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off,
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (file_printf(ms, ", %s linked%s", linking_style, shared_libraries)
|
||||
@ -935,6 +947,8 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
|
||||
|
||||
if (class == ELFCLASS32) {
|
||||
Elf32_Ehdr elfhdr;
|
||||
uint16_t type;
|
||||
|
||||
if (nbytes <= sizeof (Elf32_Ehdr))
|
||||
return 0;
|
||||
|
||||
@ -943,33 +957,36 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
|
||||
(void) memcpy(&elfhdr, buf, sizeof elfhdr);
|
||||
swap = (u.c[sizeof(int32_t) - 1] + 1) != elfhdr.e_ident[EI_DATA];
|
||||
|
||||
if (getu16(swap, elfhdr.e_type) == ET_CORE) {
|
||||
type = getu16(swap, elfhdr.e_type);
|
||||
switch (type) {
|
||||
#ifdef ELFCORE
|
||||
case ET_CORE:
|
||||
if (dophn_core(ms, class, swap, fd,
|
||||
(off_t)getu32(swap, elfhdr.e_phoff),
|
||||
getu16(swap, elfhdr.e_phnum),
|
||||
(size_t)getu16(swap, elfhdr.e_phentsize),
|
||||
fsize, &flags) == -1)
|
||||
return -1;
|
||||
#else
|
||||
;
|
||||
break;
|
||||
#endif
|
||||
} else {
|
||||
if (getu16(swap, elfhdr.e_type) == ET_EXEC) {
|
||||
if (dophn_exec(ms, class, swap,
|
||||
fd, (off_t)getu32(swap, elfhdr.e_phoff),
|
||||
getu16(swap, elfhdr.e_phnum),
|
||||
(size_t)getu16(swap, elfhdr.e_phentsize),
|
||||
fsize, &flags)
|
||||
== -1)
|
||||
return -1;
|
||||
}
|
||||
case ET_EXEC:
|
||||
case ET_DYN:
|
||||
if (dophn_exec(ms, class, swap,
|
||||
fd, (off_t)getu32(swap, elfhdr.e_phoff),
|
||||
getu16(swap, elfhdr.e_phnum),
|
||||
(size_t)getu16(swap, elfhdr.e_phentsize),
|
||||
fsize, &flags) == -1)
|
||||
return -1;
|
||||
if (doshn(ms, class, swap, fd,
|
||||
(off_t)getu32(swap, elfhdr.e_shoff),
|
||||
getu16(swap, elfhdr.e_shnum),
|
||||
(size_t)getu16(swap, elfhdr.e_shentsize),
|
||||
&flags) == -1)
|
||||
return -1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -97,6 +97,7 @@ typedef struct {
|
||||
|
||||
/* e_type */
|
||||
#define ET_EXEC 2
|
||||
#define ET_DYN 3
|
||||
#define ET_CORE 4
|
||||
|
||||
/* sh_type */
|
||||
@ -190,12 +191,6 @@ typedef struct {
|
||||
Elf64_Off sh_entsize;
|
||||
} Elf64_Shdr;
|
||||
|
||||
/* Notes used in ET_CORE */
|
||||
#define NT_PRSTATUS 1
|
||||
#define NT_PRFPREG 2
|
||||
#define NT_PRPSINFO 3
|
||||
#define NT_TASKSTRUCT 4
|
||||
|
||||
#define NT_NETBSD_CORE_PROCINFO 1
|
||||
|
||||
/* Note header in a PT_NOTE section */
|
||||
@ -211,10 +206,12 @@ typedef struct {
|
||||
Elf64_Word n_type;
|
||||
} Elf64_Nhdr;
|
||||
|
||||
/* Notes used in ET_CORE */
|
||||
#define NT_PRSTATUS 1
|
||||
#define NT_PRFPREG 2
|
||||
#define NT_PRPSINFO 3
|
||||
#define NT_PRXREG 4
|
||||
#define NT_TASKSTRUCT 4
|
||||
#define NT_PLATFORM 5
|
||||
#define NT_AUXV 6
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.99 2007/05/08 14:44:18 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.103 2007/12/27 16:35:59 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
private int match(struct magic_set *, struct magic *, uint32_t,
|
||||
@ -254,9 +254,10 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
break;
|
||||
}
|
||||
}
|
||||
firstline = 0;
|
||||
if (printed_something)
|
||||
if (printed_something) {
|
||||
firstline = 0;
|
||||
returnval = 1;
|
||||
}
|
||||
if ((ms->flags & MAGIC_CONTINUE) == 0 && printed_something) {
|
||||
return 1; /* don't keep searching */
|
||||
}
|
||||
@ -310,6 +311,8 @@ private int32_t
|
||||
mprint(struct magic_set *ms, struct magic *m)
|
||||
{
|
||||
uint64_t v;
|
||||
float vf;
|
||||
double vd;
|
||||
int64_t t = 0;
|
||||
char buf[512];
|
||||
union VALUETYPE *p = &ms->ms_value;
|
||||
@ -398,11 +401,8 @@ mprint(struct magic_set *ms, struct magic *m)
|
||||
t = ms->offset + m->vallen;
|
||||
}
|
||||
else {
|
||||
if (*m->value.s == '\0') {
|
||||
char *cp = strchr(p->s,'\n');
|
||||
if (cp)
|
||||
*cp = '\0';
|
||||
}
|
||||
if (*m->value.s == '\0')
|
||||
p->s[strcspn(p->s, "\n")] = '\0';
|
||||
if (file_printf(ms, m->desc, p->s) == -1)
|
||||
return -1;
|
||||
t = ms->offset + strlen(p->s);
|
||||
@ -445,6 +445,48 @@ mprint(struct magic_set *ms, struct magic *m)
|
||||
t = ms->offset + sizeof(uint64_t);
|
||||
break;
|
||||
|
||||
case FILE_FLOAT:
|
||||
case FILE_BEFLOAT:
|
||||
case FILE_LEFLOAT:
|
||||
vf = p->f;
|
||||
switch (check_fmt(ms, m)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 1:
|
||||
if (snprintf(buf, sizeof(buf), "%g", vf) < 0)
|
||||
return -1;
|
||||
if (file_printf(ms, m->desc, buf) == -1)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
if (file_printf(ms, m->desc, vf) == -1)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
t = ms->offset + sizeof(float);
|
||||
break;
|
||||
|
||||
case FILE_DOUBLE:
|
||||
case FILE_BEDOUBLE:
|
||||
case FILE_LEDOUBLE:
|
||||
vd = p->d;
|
||||
switch (check_fmt(ms, m)) {
|
||||
case -1:
|
||||
return -1;
|
||||
case 1:
|
||||
if (snprintf(buf, sizeof(buf), "%g", vd) < 0)
|
||||
return -1;
|
||||
if (file_printf(ms, m->desc, buf) == -1)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
if (file_printf(ms, m->desc, vd) == -1)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
t = ms->offset + sizeof(double);
|
||||
break;
|
||||
|
||||
case FILE_REGEX: {
|
||||
char *cp;
|
||||
int rval;
|
||||
@ -545,6 +587,35 @@ cvt_64(union VALUETYPE *p, const struct magic *m)
|
||||
DO_CVT(q, (uint64_t));
|
||||
}
|
||||
|
||||
#define DO_CVT2(fld, cast) \
|
||||
if (m->num_mask) \
|
||||
switch (m->mask_op & FILE_OPS_MASK) { \
|
||||
case FILE_OPADD: \
|
||||
p->fld += cast m->num_mask; \
|
||||
break; \
|
||||
case FILE_OPMINUS: \
|
||||
p->fld -= cast m->num_mask; \
|
||||
break; \
|
||||
case FILE_OPMULTIPLY: \
|
||||
p->fld *= cast m->num_mask; \
|
||||
break; \
|
||||
case FILE_OPDIVIDE: \
|
||||
p->fld /= cast m->num_mask; \
|
||||
break; \
|
||||
} \
|
||||
|
||||
private void
|
||||
cvt_float(union VALUETYPE *p, const struct magic *m)
|
||||
{
|
||||
DO_CVT2(f, (float));
|
||||
}
|
||||
|
||||
private void
|
||||
cvt_double(union VALUETYPE *p, const struct magic *m)
|
||||
{
|
||||
DO_CVT2(d, (double));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the byte order of the data we are looking at
|
||||
* While we're here, let's apply the mask operation
|
||||
@ -644,6 +715,36 @@ mconvert(struct magic_set *ms, struct magic *m)
|
||||
((p->hl[1]<<24)|(p->hl[0]<<16)|(p->hl[3]<<8)|(p->hl[2]));
|
||||
cvt_32(p, m);
|
||||
return 1;
|
||||
case FILE_FLOAT:
|
||||
cvt_float(p, m);
|
||||
return 1;
|
||||
case FILE_BEFLOAT:
|
||||
p->l = ((uint32_t)p->hl[0]<<24)|((uint32_t)p->hl[1]<<16)|
|
||||
((uint32_t)p->hl[2]<<8) |((uint32_t)p->hl[3]);
|
||||
cvt_float(p, m);
|
||||
return 1;
|
||||
case FILE_LEFLOAT:
|
||||
p->l = ((uint32_t)p->hl[3]<<24)|((uint32_t)p->hl[2]<<16)|
|
||||
((uint32_t)p->hl[1]<<8) |((uint32_t)p->hl[0]);
|
||||
cvt_float(p, m);
|
||||
return 1;
|
||||
case FILE_DOUBLE:
|
||||
cvt_double(p, m);
|
||||
return 1;
|
||||
case FILE_BEDOUBLE:
|
||||
p->q = ((uint64_t)p->hq[0]<<56)|((uint64_t)p->hq[1]<<48)|
|
||||
((uint64_t)p->hq[2]<<40)|((uint64_t)p->hq[3]<<32)|
|
||||
((uint64_t)p->hq[4]<<24)|((uint64_t)p->hq[5]<<16)|
|
||||
((uint64_t)p->hq[6]<<8) |((uint64_t)p->hq[7]);
|
||||
cvt_double(p, m);
|
||||
return 1;
|
||||
case FILE_LEDOUBLE:
|
||||
p->q = ((uint64_t)p->hq[7]<<56)|((uint64_t)p->hq[6]<<48)|
|
||||
((uint64_t)p->hq[5]<<40)|((uint64_t)p->hq[4]<<32)|
|
||||
((uint64_t)p->hq[3]<<24)|((uint64_t)p->hq[2]<<16)|
|
||||
((uint64_t)p->hq[1]<<8) |((uint64_t)p->hq[0]);
|
||||
cvt_double(p, m);
|
||||
return 1;
|
||||
case FILE_REGEX:
|
||||
case FILE_SEARCH:
|
||||
case FILE_DEFAULT:
|
||||
@ -730,13 +831,17 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
|
||||
offset);
|
||||
return -1;
|
||||
}
|
||||
for (/*EMPTY*/; src < esrc; src++, dst++) {
|
||||
for (/*EMPTY*/; src < esrc; src += 2, dst++) {
|
||||
if (dst < edst)
|
||||
*dst = *src++;
|
||||
*dst = *src;
|
||||
else
|
||||
break;
|
||||
if (*dst == '\0')
|
||||
*dst = ' ';
|
||||
if (*dst == '\0') {
|
||||
if (type == FILE_BESTRING16 ?
|
||||
*(src - 1) != '\0' :
|
||||
*(src + 1) != '\0')
|
||||
*dst = ' ';
|
||||
}
|
||||
}
|
||||
*edst = '\0';
|
||||
return 0;
|
||||
@ -1289,10 +1394,20 @@ mget(struct magic_set *ms, const unsigned char *s,
|
||||
case FILE_BELDATE:
|
||||
case FILE_LELDATE:
|
||||
case FILE_MELDATE:
|
||||
case FILE_FLOAT:
|
||||
case FILE_BEFLOAT:
|
||||
case FILE_LEFLOAT:
|
||||
if (nbytes < (offset + 4))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case FILE_DOUBLE:
|
||||
case FILE_BEDOUBLE:
|
||||
case FILE_LEDOUBLE:
|
||||
if (nbytes < (offset + 8))
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case FILE_STRING:
|
||||
case FILE_PSTRING:
|
||||
case FILE_SEARCH:
|
||||
@ -1395,6 +1510,8 @@ magiccheck(struct magic_set *ms, struct magic *m)
|
||||
{
|
||||
uint64_t l = m->value.q;
|
||||
uint64_t v;
|
||||
float fl, fv;
|
||||
double dl, dv;
|
||||
int matched;
|
||||
union VALUETYPE *p = &ms->ms_value;
|
||||
|
||||
@ -1436,6 +1553,72 @@ magiccheck(struct magic_set *ms, struct magic *m)
|
||||
v = p->q;
|
||||
break;
|
||||
|
||||
case FILE_FLOAT:
|
||||
case FILE_BEFLOAT:
|
||||
case FILE_LEFLOAT:
|
||||
fl = m->value.f;
|
||||
fv = p->f;
|
||||
switch (m->reln) {
|
||||
case 'x':
|
||||
matched = 1;
|
||||
break;
|
||||
|
||||
case '!':
|
||||
matched = fv != fl;
|
||||
break;
|
||||
|
||||
case '=':
|
||||
matched = fv == fl;
|
||||
break;
|
||||
|
||||
case '>':
|
||||
matched = fv > fl;
|
||||
break;
|
||||
|
||||
case '<':
|
||||
matched = fv < fl;
|
||||
break;
|
||||
|
||||
default:
|
||||
matched = 0;
|
||||
file_magerror(ms, "cannot happen with float: invalid relation `%c'", m->reln);
|
||||
return -1;
|
||||
}
|
||||
return matched;
|
||||
|
||||
case FILE_DOUBLE:
|
||||
case FILE_BEDOUBLE:
|
||||
case FILE_LEDOUBLE:
|
||||
dl = m->value.d;
|
||||
dv = p->d;
|
||||
switch (m->reln) {
|
||||
case 'x':
|
||||
matched = 1;
|
||||
break;
|
||||
|
||||
case '!':
|
||||
matched = dv != dl;
|
||||
break;
|
||||
|
||||
case '=':
|
||||
matched = dv == dl;
|
||||
break;
|
||||
|
||||
case '>':
|
||||
matched = dv > dl;
|
||||
break;
|
||||
|
||||
case '<':
|
||||
matched = dv < dl;
|
||||
break;
|
||||
|
||||
default:
|
||||
matched = 0;
|
||||
file_magerror(ms, "cannot happen with double: invalid relation `%c'", m->reln);
|
||||
return -1;
|
||||
}
|
||||
return matched;
|
||||
|
||||
case FILE_DEFAULT:
|
||||
l = 0;
|
||||
v = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user