summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2002-09-16 05:54:26 +0000
committerobrien <obrien@FreeBSD.org>2002-09-16 05:54:26 +0000
commit2ef757c3c642f5ce8353e106c1fbbd3cea2b14c1 (patch)
treebe5585d7b830cb36fbe379de5dc133810141410c
parent7860fd7670d66336ca32454f171db9c04eb45f02 (diff)
downloadFreeBSD-src-2ef757c3c642f5ce8353e106c1fbbd3cea2b14c1.zip
FreeBSD-src-2ef757c3c642f5ce8353e106c1fbbd3cea2b14c1.tar.gz
Virgin import of Christos Zoulas's FILE 3.39.
-rw-r--r--contrib/file/Magdir/acorn32
-rw-r--r--contrib/file/Magdir/adventure32
-rw-r--r--contrib/file/Magdir/amigaos29
-rw-r--r--contrib/file/Magdir/animation152
-rw-r--r--contrib/file/Magdir/archive6
-rw-r--r--contrib/file/Magdir/audio27
-rw-r--r--contrib/file/Magdir/cddb11
-rw-r--r--contrib/file/Magdir/commands20
-rw-r--r--contrib/file/Magdir/compress50
-rw-r--r--contrib/file/Magdir/cvs6
-rw-r--r--contrib/file/Magdir/database6
-rw-r--r--contrib/file/Magdir/dolby57
-rw-r--r--contrib/file/Magdir/editors4
-rw-r--r--contrib/file/Magdir/elf97
-rw-r--r--contrib/file/Magdir/filesystems83
-rw-r--r--contrib/file/Magdir/gringotts25
-rw-r--r--contrib/file/Magdir/hitachi-sh8
-rw-r--r--contrib/file/Magdir/human68k25
-rw-r--r--contrib/file/Magdir/images2
-rw-r--r--contrib/file/Magdir/impulse18
-rw-r--r--contrib/file/Magdir/linux66
-rw-r--r--contrib/file/Magdir/lisp15
-rw-r--r--contrib/file/Magdir/mcrypt61
-rw-r--r--contrib/file/Magdir/mlssa7
-rw-r--r--contrib/file/Magdir/nitpicker12
-rw-r--r--contrib/file/Magdir/perl18
-rw-r--r--contrib/file/Magdir/printer4
-rw-r--r--contrib/file/Magdir/pulsar12
-rw-r--r--contrib/file/Magdir/sendmail9
-rw-r--r--contrib/file/Magdir/tex56
-rw-r--r--contrib/file/Magdir/tgif6
-rw-r--r--contrib/file/Magdir/varied.out4
-rw-r--r--contrib/file/Magdir/vorbis45
-rw-r--r--contrib/file/Magdir/vxl13
-rw-r--r--contrib/file/Makefile.am191
-rw-r--r--contrib/file/Makefile.in11
-rw-r--r--contrib/file/Makefile.std8
-rw-r--r--contrib/file/README9
-rw-r--r--contrib/file/acconfig.h9
-rw-r--r--contrib/file/acinclude.m4182
-rw-r--r--contrib/file/aclocal.m4182
-rw-r--r--contrib/file/apprentice.c180
-rw-r--r--contrib/file/ascmagic.c62
-rw-r--r--contrib/file/compress.c191
-rw-r--r--contrib/file/config.h.in40
-rwxr-xr-xcontrib/file/configure676
-rw-r--r--contrib/file/configure.in24
-rw-r--r--contrib/file/file.c151
-rw-r--r--contrib/file/file.h121
-rw-r--r--contrib/file/file.man83
-rw-r--r--contrib/file/fsmagic.c9
-rw-r--r--contrib/file/is_tar.c16
-rw-r--r--contrib/file/magic.man56
-rw-r--r--contrib/file/magic.mime8
-rw-r--r--contrib/file/names.h4
-rw-r--r--contrib/file/patchlevel.h19
-rw-r--r--contrib/file/print.c60
-rw-r--r--contrib/file/readelf.c257
-rw-r--r--contrib/file/readelf.h24
-rw-r--r--contrib/file/softmagic.c161
60 files changed, 2781 insertions, 971 deletions
diff --git a/contrib/file/Magdir/acorn b/contrib/file/Magdir/acorn
new file mode 100644
index 0000000..ad89cc66
--- /dev/null
+++ b/contrib/file/Magdir/acorn
@@ -0,0 +1,32 @@
+#------------------------------------------------------------------------------
+# acorn: file(1) magic for files found on Acorn systems
+#
+
+# RISC OS Chunk File Format
+# From RISC OS Programmer's Reference Manual, Appendix D
+# We guess the file type from the type of the first chunk.
+0 lelong 0xc3cbc6c5 RISC OS Chunk data
+>12 string OBJ_ \b, AOF object
+>12 string LIB_ \b, ALF library
+
+# RISC OS AIF, contains "SWI OS_Exit" at offset 16.
+16 lelong 0xef000011 RISC OS AIF executable
+
+# RISC OS Draw files
+# From RISC OS Programmer's Reference Manual, Appendix E
+0 string Draw RISC OS Draw file data
+
+# RISC OS new format font files
+# From RISC OS Programmer's Reference Manual, Appendix E
+0 string FONT\0 RISC OS outline font data,
+>5 byte x version %d
+0 string FONT\1 RISC OS 1bpp font data,
+>5 byte x version %d
+0 string FONT\4 RISC OS 4bpp font data
+>5 byte x version %d
+
+# RISC OS Music files
+# From RISC OS Programmer's Reference Manual, Appendix E
+0 string Maestro\r RISC OS music file
+>8 byte x version %d
+
diff --git a/contrib/file/Magdir/adventure b/contrib/file/Magdir/adventure
index 38a5e33..864712f 100644
--- a/contrib/file/Magdir/adventure
+++ b/contrib/file/Magdir/adventure
@@ -4,11 +4,12 @@
#
# from Allen Garvin <earendil@faeryland.tamu-commerce.edu>
# Edited by Dave Chapeskie <dchapes@ddm.on.ca> Jun 28, 1998
+# Edited by Chris Chittleborough <cchittleborough@yahoo.com.au>, March 2002
#
# ALAN
# I assume there are other, lower versions, but these are the only ones I
# saw in the archive.
-0 beshort 0x0206 ALAN text adventure code data
+0 beshort 0x0206 ALAN game data
>2 byte <10 version 2.6%d
# Conflicts with too much other stuff!
@@ -34,6 +35,29 @@
#>18 string >\0 Serial %.6s)
# TADS (Text Adventure Development System)
-0 string TADS TADS game data
->13 string >\0 (ver. %.6s,
->22 string >\0 date %s)
+# All files are machine-independent (games compile to byte-code) and are tagged
+# with a version string of the form "V2.<digit>.<digit>\0" (but TADS 3 is
+# on the way).
+# Game files start with "TADS2 bin\n\r\032\0" then the compiler version.
+0 string TADS2\ bin TADS
+>9 belong !0x0A0D1A00 game data, CORRUPTED
+>9 belong 0x0A0D1A00
+>>13 string >\0 %s game data
+# Resource files start with "TADS2 rsc\n\r\032\0" then the compiler version.
+0 string TADS2\ rsc TADS
+>9 belong !0x0A0D1A00 resource data, CORRUPTED
+>9 belong 0x0A0D1A00
+>>13 string >\0 %s resource data
+# Some saved game files start with "TADS2 save/g\n\r\032\0", a little-endian
+# 2-byte length N, the N-char name of the game file *without* a NUL (darn!),
+# "TADS2 save\n\r\032\0" and the interpreter version.
+0 string TADS2\ save/g TADS
+>12 belong !0x0A0D1A00 saved game data, CORRUPTED
+>12 belong 0x0A0D1A00
+>>(16.s+32) string >\0 %s saved game data
+# Other saved game files start with "TADS2 save\n\r\032\0" and the interpreter
+# version.
+0 string TADS2\ save TADS
+>10 belong !0x0A0D1A00 saved game data, CORRUPTED
+>10 belong 0x0A0D1A00
+>>14 string >\0 %s saved game data
diff --git a/contrib/file/Magdir/amigaos b/contrib/file/Magdir/amigaos
index a4c3e82..a1be613 100644
--- a/contrib/file/Magdir/amigaos
+++ b/contrib/file/Magdir/amigaos
@@ -8,3 +8,32 @@
#
0 belong 0x000003f3 AmigaOS loadseg()ble executable/binary
0 belong 0x000003e7 AmigaOS object/library data
+#
+0 beshort 0xe310 Amiga Workbench
+>2 beshort 1
+>>48 byte 1 disk icon
+>>48 byte 2 drawer icon
+>>48 byte 3 tool icon
+>>48 byte 4 project icon
+>>48 byte 5 garbage icon
+>>48 byte 6 device icon
+>>48 byte 7 kickstart icon
+>>48 byte 8 workbench application icon
+>2 beshort >1 icon, vers. %d
+#
+# various sound formats from the Amiga
+# G=F6tz Waschk <waschk@informatik.uni-rostock.de>
+#
+0 string FC14 Future Composer 1.4 Module sound file
+0 string SMOD Future Composer 1.3 Module sound file
+0 string AON4artofnoise Art Of Noise Module sound file
+1 string MUGICIAN/SOFTEYES Mugician Module sound file
+58 string SIDMON\ II\ -\ THE Sidmon 2.0 Module sound file
+0 string Synth4.0 Synthesis Module sound file
+0 string ARP. The Holy Noise Module sound file
+0 string BeEp\0 JamCracker Module sound file
+0 string COSO\0 Hippel-COSO Module sound file
+26 string V.3 Brian Postma's Soundmon Module sound file v3
+26 string BPSM Brian Postma's Soundmon Module sound file v3
+26 string V.2 Brian Postma's Soundmon Module sound file v2
+
diff --git a/contrib/file/Magdir/animation b/contrib/file/Magdir/animation
index 6fa689f..56f25cf 100644
--- a/contrib/file/Magdir/animation
+++ b/contrib/file/Magdir/animation
@@ -15,75 +15,96 @@
# MPEG Audio (*.mpx)
# from dreesen@math.fu-berlin.de
-# XXX
-# This conflicts with the FF FE signature for UTF-16-encoded Unicode
-# text, which will be identified as an MP3 file. I don't have any MP3s
-# so I don't know how to (or even if it's possible to) change this to
-# tell the two apart. enf@pobox.com
+# MPEG 1.0 Layer 3
+0 beshort&0xfffe =0xfffa \bMP3
+>2 byte&0xf0 =0x10 \b, 32 kBits
+>2 byte&0xf0 =0x20 \b, 40 kBits
+>2 byte&0xf0 =0x30 \b, 48 kBits
+>2 byte&0xf0 =0x40 \b, 56 kBits
+>2 byte&0xf0 =0x50 \b, 64 kBits
+>2 byte&0xf0 =0x60 \b, 80 kBits
+>2 byte&0xf0 =0x70 \b, 96 kBits
+>2 byte&0xf0 =0x80 \b, 112 kBits
+>2 byte&0xf0 =0x90 \b, 128 kBits
+>2 byte&0xf0 =0xA0 \b, 160 kBits
+>2 byte&0xf0 =0xB0 \b, 192 kBits
+>2 byte&0xf0 =0xC0 \b, 224 kBits
+>2 byte&0xf0 =0xD0 \b, 256 kBits
+>2 byte&0xf0 =0xE0 \b, 320 kBits
+# freq
+>2 byte&0x0C =0x00 \b, 44.1 kHz
+>2 byte&0x0C =0x04 \b, 48 kHz
+>2 byte&0x0C =0x08 \b, 32 kHz
+# misc
+>3 byte&0xC0 =0x00 \b, Stereo
+>3 byte&0xC0 =0x40 \b, JStereo
+>3 byte&0xC0 =0x80 \b, Dual-Ch
+>3 byte&0xC0 =0xC0 \b, Mono
+#>1 byte&0x01 =0x00 \b, Error Protection
+#>2 byte&0x02 =0x02 \b, Padding
+#>2 byte&0x01 =0x01 \b, Private
+#>3 byte&0x08 =0x08 \b, Copyright
+#>3 byte&0x04 =0x04 \b, Original
+#>3 byte&0x03 1 \b, Emphasis 5
+#>3 byte&0x03 3 \b, Emphasis c
-0 beshort &0xfff0 MP
-# MPEG 1.0
->1 byte&0x08 =0x08 \b
-# Layer 3
->>1 byte &0x02 \b3
->>>2 byte&0xf0 =0x10 \b, 32 kBits
->>>2 byte&0xf0 =0x20 \b, 40 kBits
->>>2 byte&0xf0 =0x30 \b, 48 kBits
->>>2 byte&0xf0 =0x40 \b, 56 kBits
->>>2 byte&0xf0 =0x50 \b, 64 kBits
->>>2 byte&0xf0 =0x60 \b, 80 kBits
->>>2 byte&0xf0 =0x70 \b, 96 kBits
->>>2 byte&0xf0 =0x80 \b, 112 kBits
->>>2 byte&0xf0 =0x90 \b, 128 kBits
->>>2 byte&0xf0 =0xA0 \b, 160 kBits
->>>2 byte&0xf0 =0xB0 \b, 192 kBits
->>>2 byte&0xf0 =0xC0 \b, 224 kBits
->>>2 byte&0xf0 =0xD0 \b, 256 kBits
->>>2 byte&0xf0 =0xE0 \b, 320 kBits
-# Layer 2
->>1 byte &0x04 \b2
->>>2 byte&0xf0 =0x10 \b, 32 kBits
->>>2 byte&0xf0 =0x20 \b, 48 kBits
->>>2 byte&0xf0 =0x30 \b, 56 kBits
->>>2 byte&0xf0 =0x40 \b, 64 kBits
->>>2 byte&0xf0 =0x50 \b, 80 kBits
->>>2 byte&0xf0 =0x60 \b, 96 kBits
->>>2 byte&0xf0 =0x70 \b, 112 kBits
->>>2 byte&0xf0 =0x80 \b, 128 kBits
->>>2 byte&0xf0 =0x90 \b, 160 kBits
->>>2 byte&0xf0 =0xA0 \b, 192 kBits
->>>2 byte&0xf0 =0xB0 \b, 224 kBits
->>>2 byte&0xf0 =0xC0 \b, 256 kBits
->>>2 byte&0xf0 =0xD0 \b, 320 kBits
->>>2 byte&0xf0 =0xE0 \b, 384 kBits
+# MPEG 1.0 Layer 2
+0 beshort&0xfffe =0xfffc \bMP2
+>2 byte&0xf0 =0x10 \b, 32 kBits
+>2 byte&0xf0 =0x20 \b, 48 kBits
+>2 byte&0xf0 =0x30 \b, 56 kBits
+>2 byte&0xf0 =0x40 \b, 64 kBits
+>2 byte&0xf0 =0x50 \b, 80 kBits
+>2 byte&0xf0 =0x60 \b, 96 kBits
+>2 byte&0xf0 =0x70 \b, 112 kBits
+>2 byte&0xf0 =0x80 \b, 128 kBits
+>2 byte&0xf0 =0x90 \b, 160 kBits
+>2 byte&0xf0 =0xA0 \b, 192 kBits
+>2 byte&0xf0 =0xB0 \b, 224 kBits
+>2 byte&0xf0 =0xC0 \b, 256 kBits
+>2 byte&0xf0 =0xD0 \b, 320 kBits
+>2 byte&0xf0 =0xE0 \b, 384 kBits
# freq
->>2 byte&0x0C =0x00 \b, 44.1 kHz
->>2 byte&0x0C =0x04 \b, 48 kHz
->>2 byte&0x0C =0x08 \b, 32 kHz
+>2 byte&0x0C =0x00 \b, 44.1 kHz
+>2 byte&0x0C =0x04 \b, 48 kHz
+>2 byte&0x0C =0x08 \b, 32 kHz
+# misc
+>3 byte&0xC0 =0x00 \b, Stereo
+>3 byte&0xC0 =0x40 \b, JStereo
+>3 byte&0xC0 =0x80 \b, Dual-Ch
+>3 byte&0xC0 =0xC0 \b, Mono
+#>1 byte&0x01 =0x00 \b, Error Protection
+#>2 byte&0x02 =0x02 \b, Padding
+#>2 byte&0x01 =0x01 \b, Private
+#>3 byte&0x08 =0x08 \b, Copyright
+#>3 byte&0x04 =0x04 \b, Original
+#>3 byte&0x03 1 \b, Emphasis 5
+#>3 byte&0x03 3 \b, Emphasis c
+
# MPEG 2.0
->1 byte&0x08 =0x00 \b
+0 beshort&0xfff8 =0xfff0 MP
# Layer 3
->>1 byte &0x02 \b3
+>1 byte &0x02 \b3
# Layer 2
->>1 byte &0x04 \b2
->>2 byte&0xf0 =0x10 \b, 8 kBits
->>2 byte&0xf0 =0x20 \b, 16 kBits
->>2 byte&0xf0 =0x30 \b, 24 kBits
->>2 byte&0xf0 =0x40 \b, 32 kBits
->>2 byte&0xf0 =0x50 \b, 40 kBits
->>2 byte&0xf0 =0x60 \b, 48 kBits
->>2 byte&0xf0 =0x70 \b, 56 kBits
->>2 byte&0xf0 =0x80 \b, 64 kBits
->>2 byte&0xf0 =0x90 \b, 80 kBits
->>2 byte&0xf0 =0xA0 \b, 96 kBits
->>2 byte&0xf0 =0xB0 \b, 112 kBits
->>2 byte&0xf0 =0xC0 \b, 128 kBits
->>2 byte&0xf0 =0xD0 \b, 144 kBits
->>2 byte&0xf0 =0xE0 \b, 160 kBits
+>1 byte &0x04 \b2
+>2 byte&0xf0 =0x10 \b, 8 kBits
+>2 byte&0xf0 =0x20 \b, 16 kBits
+>2 byte&0xf0 =0x30 \b, 24 kBits
+>2 byte&0xf0 =0x40 \b, 32 kBits
+>2 byte&0xf0 =0x50 \b, 40 kBits
+>2 byte&0xf0 =0x60 \b, 48 kBits
+>2 byte&0xf0 =0x70 \b, 56 kBits
+>2 byte&0xf0 =0x80 \b, 64 kBits
+>2 byte&0xf0 =0x90 \b, 80 kBits
+>2 byte&0xf0 =0xA0 \b, 96 kBits
+>2 byte&0xf0 =0xB0 \b, 112 kBits
+>2 byte&0xf0 =0xC0 \b, 128 kBits
+>2 byte&0xf0 =0xD0 \b, 144 kBits
+>2 byte&0xf0 =0xE0 \b, 160 kBits
# freq
->>2 byte&0x0C =0x00 \b, 22.05 kHz
->>2 byte&0x0C =0x04 \b, 24 kHz
->>2 byte&0x0C =0x08 \b, 16 kHz
+>2 byte&0x0C =0x00 \b, 22.05 kHz
+>2 byte&0x0C =0x04 \b, 24 kHz
+>2 byte&0x0C =0x08 \b, 16 kHz
# misc
>3 byte&0xC0 =0x00 \b, Stereo
>3 byte&0xC0 =0x40 \b, JStereo
@@ -168,3 +189,8 @@
# Microsoft Advanced Streaming Format (ASF) <mpruett@sgi.com>
0 belong 0x3026b275 Microsoft ASF
+
+# MNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
+0 string \x8aMNG MNG video data,
+>4 belong !0x0d0a1a0a CORRUPTED,
+>4 belong 0x0d0a1a0a
diff --git a/contrib/file/Magdir/archive b/contrib/file/Magdir/archive
index 7e98240..ac3da71 100644
--- a/contrib/file/Magdir/archive
+++ b/contrib/file/Magdir/archive
@@ -250,3 +250,9 @@
>>14 beshort 0x677a (gzipped)
>>14 beshort !0x677a (not gzipped)
>13 string >3 version %s
+
+############################################################################
+# Parity archive reconstruction file, the 'par' file format now used on Usenet.
+0 string PAR\0 PARity archive data
+>48 leshort =0 - Index file
+>48 leshort >0 - file number %d
diff --git a/contrib/file/Magdir/audio b/contrib/file/Magdir/audio
index 65988f1..5a16971 100644
--- a/contrib/file/Magdir/audio
+++ b/contrib/file/Magdir/audio
@@ -136,9 +136,28 @@
# Audio Visual Research <mpruett@sgi.com>
0 string 2BIT Audio Visual Research file
-# From Felix von Leitner <leitner@fefe.de>
-0 string OggS Ogg-Vorbis compressed sound file
-
# SGI SoundTrack <mpruett@sgi.com>
0 string _SGI_SoundTrack SGI SoundTrack project file
-0 string ID3 mp3 file with ID3 2.0 tag
+# ID3 version 2 tags <waschk@informatik.uni-rostock.de>
+0 string ID3 MP3 file with ID3 version 2.
+>3 ubyte <0xff \b%d.
+>4 ubyte <0xff \b%d tag
+
+# NSF (NES sound file) magic
+0 string NESM\x1a NES Sound File
+>14 string >\0 ("%s" by
+>46 string >\0 %s, copyright
+>78 string >\0 %s),
+>5 byte x version %d,
+>6 byte x %d tracks,
+>122 byte&0x2 =1 dual PAL/NTSC
+>122 byte&0x1 =1 PAL
+>122 byte&0x1 =0 NTSC
+
+# Impuse tracker module (audio/x-it)
+0 string IMPM Impulse Tracker module sound data -
+>4 string >\0 "%s"
+
+# Imago Orpheus module (audio/x-imf)
+60 string IM10 Imago Orpheus module sound data -
+>0 string >\0 "%s"
diff --git a/contrib/file/Magdir/cddb b/contrib/file/Magdir/cddb
new file mode 100644
index 0000000..2ea97ee
--- /dev/null
+++ b/contrib/file/Magdir/cddb
@@ -0,0 +1,11 @@
+
+#------------------------------------------------------------------------------
+# CDDB: file(1) magic for CDDB(tm) format CD text data files
+#
+# From <steve@gracenote.com>
+#
+# This is the /etc/magic entry to decode datafiles as used by
+# CDDB-enabled CD player applications.
+#
+
+0 string/b #\040xmcd CDDB(tm) format CD text data
diff --git a/contrib/file/Magdir/commands b/contrib/file/Magdir/commands
index 3fe253a..a9dd089 100644
--- a/contrib/file/Magdir/commands
+++ b/contrib/file/Magdir/commands
@@ -27,16 +27,6 @@
0 string/b #!\ /usr/bin/awk awk script text executable
0 string BEGIN awk script text
-# For Larry Wall's perl language. The ``eval'' line recognizes an
-# outrageously clever hack for USG systems.
-# Keith Waclena <keith@cerberus.uchicago.edu>
-0 string/b #!\ /bin/perl perl script text executable
-0 string eval\ "exec\ /bin/perl perl script text
-0 string/b #!\ /usr/bin/perl perl script text executable
-0 string eval\ "exec\ /usr/bin/perl perl script text
-0 string/b #!\ /usr/local/bin/perl perl script text
-0 string eval\ "exec\ /usr/local/bin/perl perl script text executable
-
# AT&T Bell Labs' Plan 9 shell
0 string/b #!\ /bin/rc Plan 9 rc shell script text executable
@@ -60,3 +50,13 @@
>2 string >\0 %s script text executable
0 string #!\ script text executable
>3 string >\0 for %s
+
+# PHP scripts
+# Ulf Harnhammar <ulfh@update.uu.se>
+0 string/c =<?php PHP script text
+0 string =<?\n PHP script text
+0 string =<?\r PHP script text
+0 string/b #!\ /usr/local/bin/php PHP script text executable
+0 string/b #!\ /usr/bin/php PHP script text executable
+
+0 string Zend\x00 PHP script Zend Optimizer data
diff --git a/contrib/file/Magdir/compress b/contrib/file/Magdir/compress
index f4fe4a4..3da7f5f 100644
--- a/contrib/file/Magdir/compress
+++ b/contrib/file/Magdir/compress
@@ -14,28 +14,32 @@
>2 byte&0x1f x %d bits
# gzip (GNU zip, not to be confused with Info-ZIP or PKWARE zip archiver)
+# Edited by Chris Chittleborough <cchittleborough@yahoo.com.au>, March 2002
+# * Original filename is only at offset 10 if "extra field" absent
+# * Produce shorter output - notably, only report compression methods
+# other than 8 ("deflate", the only method defined in RFC 1952).
0 string \037\213 gzip compressed data
->2 byte <8 \b, reserved method,
->2 byte 8 \b, deflated,
->3 byte &0x01 ASCII,
->3 byte &0x02 continuation,
->3 byte &0x04 extra field,
->3 byte &0x08 original filename,
->>10 string x `%s',
->3 byte &0x10 comment,
->3 byte &0x20 encrypted,
->4 ledate x last modified: %s,
->8 byte 2 max compression,
->8 byte 4 max speed,
->9 byte =0x00 os: MS-DOS
->9 byte =0x01 os: Amiga
->9 byte =0x02 os: VMS
->9 byte =0x03 os: Unix
->9 byte =0x05 os: Atari
->9 byte =0x06 os: OS/2
->9 byte =0x07 os: MacOS
->9 byte =0x0A os: Tops/20
->9 byte =0x0B os: Win/32
+>2 byte <8 \b, reserved method
+>2 byte >8 \b, unknown method
+>3 byte &0x01 \b, ASCII
+>3 byte &0x02 \b, continuation
+>3 byte &0x04 \b, extra field
+>3 byte&0xC =0x08
+>>10 string x \b, was "%s"
+>9 byte =0x00 \b, from MS-DOS
+>9 byte =0x01 \b, from Amiga
+>9 byte =0x02 \b, from VMS
+>9 byte =0x03 \b, from Unix
+>9 byte =0x05 \b, from Atari
+>9 byte =0x06 \b, from OS/2
+>9 byte =0x07 \b, from MacOS
+>9 byte =0x0A \b, from Tops/20
+>9 byte =0x0B \b, from Win/32
+>3 byte &0x10 \b, comment
+>3 byte &0x20 \b, encrypted
+### >4 ledate x last modified: %s,
+>8 byte 2 \b, max compression
+>8 byte 4 \b, max speed
# packed data, Huffman (minimum redundancy) codes on a byte-by-byte basis
0 string \037\036 packed data
@@ -144,3 +148,7 @@
>>17 byte =0x0A os: Tops/20
>>17 byte =0x0B os: WinNT
>>17 byte =0x0E os: Win32
+
+# 4.3BSD-Quasijarus Strong Compression
+# http://minnie.tuhs.org/Quasijarus/compress.html
+0 string \037\241 Quasijarus strong compressed data
diff --git a/contrib/file/Magdir/cvs b/contrib/file/Magdir/cvs
new file mode 100644
index 0000000..2ce9a1a
--- /dev/null
+++ b/contrib/file/Magdir/cvs
@@ -0,0 +1,6 @@
+#------------------------------------------------------------------------------
+# file(1) magic for cvs(1) files
+# From Hendrik Scholz <hendrik@scholz.net>
+
+0 string /1\ :pserver: cvs password text file
+
diff --git a/contrib/file/Magdir/database b/contrib/file/Magdir/database
index 87ecac7..9d5fe19 100644
--- a/contrib/file/Magdir/database
+++ b/contrib/file/Magdir/database
@@ -72,3 +72,9 @@
# Round Robin Database Tool by Tobias Oetiker <oetiker@ee.ethz.ch>
0 string RRD RRDTool DB
>4 string x version %s
+#----------------------------------------------------------------------
+# ROOT: file(1) magic for ROOT databases
+#
+0 string root\0 ROOT file
+>4 belong x Version %d
+>33 belong x (Compression: %d)
diff --git a/contrib/file/Magdir/dolby b/contrib/file/Magdir/dolby
new file mode 100644
index 0000000..230f738
--- /dev/null
+++ b/contrib/file/Magdir/dolby
@@ -0,0 +1,57 @@
+# ATSC A/53 aka AC-3 aka Dolby Digital <ashitaka@gmx.at>
+# from http://www.atsc.org/standards/a_52a.pdf
+# corrections, additions, etc. are always welcome!
+#
+# syncword
+0 beshort 0x0b77 ATSC A/52 aka AC-3 aka Dolby Digital stream,
+# fscod
+>4 byte&0xc0 0x00 48 kHz,
+>4 byte&0xc0 0x40 44.1 kHz,
+>4 byte&0xc0 0x80 32 kHz,
+# is this one used for 96 kHz?
+>4 byte&0xc0 0xc0 reserved frequency,
+#
+>5 byte&7 = 0 \b, complete main (CM)
+>5 byte&7 = 1 \b, music and effects (ME)
+>5 byte&7 = 2 \b, visually impaired (VI)
+>5 byte&7 = 3 \b, hearing impaired (HI)
+>5 byte&7 = 4 \b, dialogue (D)
+>5 byte&7 = 5 \b, commentary (C)
+>5 byte&7 = 6 \b, emergency (E)
+# acmod
+>6 byte&0xe0 0x00 1+1 front,
+>6 byte&0xe0 0x20 1 front/0 rear,
+>6 byte&0xe0 0x40 2 front/0 rear,
+>6 byte&0xe0 0x60 3 front/0 rear,
+>6 byte&0xe0 0x80 2 front/1 rear,
+>6 byte&0xe0 0xa0 3 front/1 rear,
+>6 byte&0xe0 0xc0 2 front/2 rear,
+>6 byte&0xe0 0xe0 3 front/2 rear,
+# lfeon (these may be incorrect)
+>7 byte&0x40 0x00 LFE off,
+>7 byte&0x40 0x40 LFE on,
+#
+>4 byte&0x3e = 0x00 \b, 32 kbit/s
+>4 byte&0x3e = 0x02 \b, 40 kbit/s
+>4 byte&0x3e = 0x04 \b, 48 kbit/s
+>4 byte&0x3e = 0x06 \b, 56 kbit/s
+>4 byte&0x3e = 0x08 \b, 64 kbit/s
+>4 byte&0x3e = 0x0a \b, 80 kbit/s
+>4 byte&0x3e = 0x0c \b, 96 kbit/s
+>4 byte&0x3e = 0x0e \b, 112 kbit/s
+>4 byte&0x3e = 0x10 \b, 128 kbit/s
+>4 byte&0x3e = 0x12 \b, 160 kbit/s
+>4 byte&0x3e = 0x14 \b, 192 kbit/s
+>4 byte&0x3e = 0x16 \b, 224 kbit/s
+>4 byte&0x3e = 0x18 \b, 256 kbit/s
+>4 byte&0x3e = 0x1a \b, 320 kbit/s
+>4 byte&0x3e = 0x1c \b, 384 kbit/s
+>4 byte&0x3e = 0x1e \b, 448 kbit/s
+>4 byte&0x3e = 0x20 \b, 512 kbit/s
+>4 byte&0x3e = 0x22 \b, 576 kbit/s
+>4 byte&0x3e = 0x24 \b, 640 kbit/s
+# dsurmod (these may be incorrect)
+>6 beshort&0x0180 0x0000 Dolby Surround not indicated
+>6 beshort&0x0180 0x0080 not Dolby Surround encoded
+>6 beshort&0x0180 0x0100 Dolby Surround encoded
+>6 beshort&0x0180 0x0180 reserved Dolby Surround mode
diff --git a/contrib/file/Magdir/editors b/contrib/file/Magdir/editors
index c529d0d..7edbe8b 100644
--- a/contrib/file/Magdir/editors
+++ b/contrib/file/Magdir/editors
@@ -7,3 +7,7 @@
>4 string 1 CP 852
>4 string 2 KOI8-CS
>4 string >2 unknown encoding
+
+# Vi IMproved Encrypted file
+# by David Necas <yeti@physics.muni.cz>
+0 string VimCrypt~ Vim encrypted file data
diff --git a/contrib/file/Magdir/elf b/contrib/file/Magdir/elf
index 53a6bc9..a6c04ee 100644
--- a/contrib/file/Magdir/elf
+++ b/contrib/file/Magdir/elf
@@ -5,38 +5,45 @@
# We have to check the byte order flag to see what byte order all the
# other stuff in the header is in.
#
-# MIPS R3000 may also be for MIPS R2000.
# What're the correct byte orders for the nCUBE and the Fujitsu VPP500?
#
# updated by Daniel Quinlan (quinlan@yggdrasil.com)
0 string \177ELF ELF
>4 byte 0 invalid class
>4 byte 1 32-bit
-# only for MIPS
+# only for MIPS - in the future, the ABI field of e_flags should be used.
>>18 beshort 8
>>18 beshort 10
>>>36 belong &0x20 N32
>4 byte 2 64-bit
>5 byte 0 invalid byte order
>5 byte 1 LSB
-# only for MIPS R3000_BE
+# The official e_machine number for MIPS is now #8, regardless of endianness.
+# The second number (#10) will be deprecated later. For now, we still
+# say something if #10 is encountered, but only gory details for #8.
>>18 leshort 8
# only for 32-bit
>>>4 byte 1
->>>>36 lelong&0xf0000000 0x00000000 mips-1
->>>>36 lelong&0xf0000000 0x10000000 mips-2
->>>>36 lelong&0xf0000000 0x20000000 mips-3
->>>>36 lelong&0xf0000000 0x30000000 mips-4
->>>>36 lelong&0xf0000000 0x40000000 mips-5
->>>>36 lelong&0xf0000000 0x50000000 mips-6
+>>>>36 lelong&0xf0000000 0x00000000 MIPS-I
+>>>>36 lelong&0xf0000000 0x10000000 MIPS-II
+>>>>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
# only for 64-bit
>>>4 byte 2
->>>>48 lelong&0xf0000000 0x00000000 mips-1
->>>>48 lelong&0xf0000000 0x10000000 mips-2
->>>>48 lelong&0xf0000000 0x20000000 mips-3
->>>>48 lelong&0xf0000000 0x30000000 mips-4
->>>>48 lelong&0xf0000000 0x40000000 mips-5
->>>>48 lelong&0xf0000000 0x50000000 mips-6
+>>>>48 lelong&0xf0000000 0x00000000 MIPS-I
+>>>>48 lelong&0xf0000000 0x10000000 MIPS-II
+>>>>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
>>16 leshort 0 no file type,
>>16 leshort 1 relocatable,
>>16 leshort 2 executable,
@@ -44,21 +51,24 @@
# Core handling from Peter Tobias <tobias@server.et-inf.fho-emden.de>
# corrections by Christian 'Dr. Disk' Hechelmann <drdisk@ds9.au.s.shuttle.de>
>>16 leshort 4 core file
->>>(0x38+0xcc) string >\0 of '%s'
->>>(0x38+0x10) lelong >0 (signal %d),
+# Core file detection is not reliable.
+#>>>(0x38+0xcc) string >\0 of '%s'
+#>>>(0x38+0x10) lelong >0 (signal %d),
>>16 leshort &0xff00 processor-specific,
>>18 leshort 0 no machine,
>>18 leshort 1 AT&T WE32100 - invalid byte order,
>>18 leshort 2 SPARC - invalid byte order,
>>18 leshort 3 Intel 80386,
->>18 leshort 4 Motorola 68000 - invalid byte order,
+>>18 leshort 4 Motorola
+>>>36 lelong &0x01000000 68000 - invalid byte order,
+>>>36 lelong &0x00810000 CPU32 - invalid byte order,
+>>>36 lelong 0 68020 - invalid byte order,
>>18 leshort 5 Motorola 88000 - invalid byte order,
>>18 leshort 6 Intel 80486,
>>18 leshort 7 Intel 80860,
-# "officially" big endian, but binutils bfd only emits magic #8 for MIPS.
->>18 leshort 8 MIPS R3000_LE [bfd bug],
+>>18 leshort 8 MIPS,
>>18 leshort 9 Amdahl - invalid byte order,
->>18 leshort 10 MIPS R3000_LE,
+>>18 leshort 10 MIPS (deprecated),
>>18 leshort 11 RS6000 - invalid byte order,
>>18 leshort 15 PA-RISC - invalid byte order,
>>>50 leshort 0x0214 2.0
@@ -92,43 +102,52 @@
>>20 lelong 1 version 1
>>36 lelong 1 MathCoPro/FPU/MAU Required
>5 byte 2 MSB
-# only for MIPS R3000_BE
+# only for MIPS - see comment in little-endian section above.
>>18 beshort 8
# only for 32-bit
>>>4 byte 1
->>>>36 belong&0xf0000000 0x00000000 mips-1
->>>>36 belong&0xf0000000 0x10000000 mips-2
->>>>36 belong&0xf0000000 0x20000000 mips-3
->>>>36 belong&0xf0000000 0x30000000 mips-4
->>>>36 belong&0xf0000000 0x40000000 mips-5
->>>>36 belong&0xf0000000 0x50000000 mips-6
+>>>>36 belong&0xf0000000 0x00000000 MIPS-I
+>>>>36 belong&0xf0000000 0x10000000 MIPS-II
+>>>>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
# only for 64-bit
>>>4 byte 2
->>>>48 belong&0xf0000000 0x00000000 mips-1
->>>>48 belong&0xf0000000 0x10000000 mips-2
->>>>48 belong&0xf0000000 0x20000000 mips-3
->>>>48 belong&0xf0000000 0x30000000 mips-4
->>>>48 belong&0xf0000000 0x40000000 mips-5
->>>>48 belong&0xf0000000 0x50000000 mips-6
+>>>>48 belong&0xf0000000 0x00000000 MIPS-I
+>>>>48 belong&0xf0000000 0x10000000 MIPS-II
+>>>>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
>>16 beshort 0 no file type,
>>16 beshort 1 relocatable,
>>16 beshort 2 executable,
>>16 beshort 3 shared object,
>>16 beshort 4 core file,
->>>(0x38+0xcc) string >\0 of '%s'
->>>(0x38+0x10) belong >0 (signal %d),
+#>>>(0x38+0xcc) string >\0 of '%s'
+#>>>(0x38+0x10) belong >0 (signal %d),
>>16 beshort &0xff00 processor-specific,
>>18 beshort 0 no machine,
>>18 beshort 1 AT&T WE32100,
>>18 beshort 2 SPARC,
>>18 beshort 3 Intel 80386 - invalid byte order,
->>18 beshort 4 Motorola 68000,
+>>18 beshort 4 Motorola
+>>>36 belong &0x01000000 68000,
+>>>36 belong &0x00810000 CPU32,
+>>>36 belong 0 68020,
>>18 beshort 5 Motorola 88000,
>>18 beshort 6 Intel 80486 - invalid byte order,
>>18 beshort 7 Intel 80860,
->>18 beshort 8 MIPS R3000_BE,
+>>18 beshort 8 MIPS,
>>18 beshort 9 Amdahl,
->>18 beshort 10 MIPS R3000_LE - invalid byte order,
+>>18 beshort 10 MIPS (deprecated),
>>18 beshort 11 RS6000,
>>18 beshort 15 PA-RISC
>>>50 beshort 0x0214 2.0
diff --git a/contrib/file/Magdir/filesystems b/contrib/file/Magdir/filesystems
index 20600c6..1e6624c 100644
--- a/contrib/file/Magdir/filesystems
+++ b/contrib/file/Magdir/filesystems
@@ -25,7 +25,12 @@
>512 belong&077777777 0600407 \b, boot block present
0x1FE leshort 0xAA55 x86 boot sector
>2 string OSBS \b, OS/BS MBR
+# J\xf6rg Jenderek <joerg@pcialias.localnet>
>0x8C string Invalid\ partition\ table \b, MS-DOS MBR
+>0x9D string Invalid\ partition\ table \b, DR-DOS MBR, version 7.01 to 7.03
+>0x10F string Ung\201ltige\ Partitionstabelle \b, MS-DOS MBR, german version 4.10.1998, 4.10.2222
+>0x8B string Ung\201ltige\ Partitionstabelle \b, MS-DOS MBR, german version 5.00 to 4.00.950
+>0x145 string Default:\ F \b, FREE-DOS MBR
>0 string \0\0\0\0 \b, extended partition table
>0 leshort 0x3CEB \b, system
>>3 string >\0 %s
@@ -41,8 +46,17 @@
>>>>32 lelong x %d sectors
>0x200 lelong 0x82564557 \b, BSD disklabel
+# Solaris 7 FAT12 floppies J\xf6rg Jenderek <joerg@pcialias.localnet>
+>0 leshort 0x7AEB \b, system
+>>3 string >\0 %s
+>>0x36 string FAT \b, %s
+>>>0x39 string 12 (%s bit)
+
# Minix filesystems - Juan Cespedes <cespedes@debian.org>
0x410 leshort 0x137f Minix filesystem
+0x410 beshort 0x137f Minix filesystem (big endian),
+>0x402 beshort !0 \b, %d zones
+>0x1e string minix \b, bootable
0x410 leshort 0x138f Minix filesystem, 30 char names
0x410 leshort 0x2468 Minix filesystem, version 2
0x410 leshort 0x2478 Minix filesystem, version 2, 30 char names
@@ -116,3 +130,72 @@
>0x68 beshort x inosz=3D%d,
>0x64 beshort ^0x2004 v1 dirs)
>0x64 beshort &0x2004 v2 dirs)
+
+############################################################################
+# Minix-ST kernel floppy
+0x800 belong 0x46fc2700 Atari-ST Minix kernel image
+>19 string \240\5\371\5\0\011\0\2\0 \b, 720k floppy
+>19 string \320\2\370\5\0\011\0\1\0 \b, 360k floppy
+
+############################################################################
+# Hmmm, is this a better way of detecting _standard_ floppy images ?
+19 string \320\2\360\3\0\011\0\1\0 DOS floppy 360k
+>0x1FE leshort 0xAA55 \b, x86 hard disk boot sector
+19 string \240\5\371\3\0\011\0\2\0 DOS floppy 720k
+>0x1FE leshort 0xAA55 \b, x86 hard disk boot sector
+19 string \100\013\360\011\0\022\0\2\0 DOS floppy 1440k
+>0x1FE leshort 0xAA55 \b, x86 hard disk boot sector
+
+19 string \240\5\371\5\0\011\0\2\0 DOS floppy 720k, IBM
+>0x1FE leshort 0xAA55 \b, x86 hard disk boot sector
+19 string \100\013\371\5\0\011\0\2\0 DOS floppy 1440k, mkdosfs
+>0x1FE leshort 0xAA55 \b, x86 hard disk boot sector
+
+19 string \320\2\370\5\0\011\0\1\0 Atari-ST floppy 360k
+19 string \240\5\371\5\0\011\0\2\0 Atari-ST floppy 720k
+
+# Valid media descriptor bytes for MS-DOS:
+#
+# Byte Capacity Media Size and Type
+# -------------------------------------------------
+#
+# F0 2.88 MB 3.5-inch, 2-sided, 36-sector
+# F0 1.44 MB 3.5-inch, 2-sided, 18-sector
+# F9 720K 3.5-inch, 2-sided, 9-sector
+# F9 1.2 MB 5.25-inch, 2-sided, 15-sector
+# FD 360K 5.25-inch, 2-sided, 9-sector
+# FF 320K 5.25-inch, 2-sided, 8-sector
+# FC 180K 5.25-inch, 1-sided, 9-sector
+# FE 160K 5.25-inch, 1-sided, 8-sector
+# FE 250K 8-inch, 1-sided, single-density
+# FD 500K 8-inch, 2-sided, single-density
+# FE 1.2 MB 8-inch, 2-sided, double-density
+# F8 ----- Fixed disk
+#
+# FC xxxK Apricot 70x1x9 boot disk.
+#
+# Originally a bitmap:
+# xxxxxxx0 Not two sided
+# xxxxxxx1 Double sided
+# xxxxxx0x Not 8 SPT
+# xxxxxx1x 8 SPT
+# xxxxx0xx Not Removable drive
+# xxxxx1xx Removable drive
+# 11111xxx Must be one.
+#
+# But now it's rather random:
+# 111111xx Low density disk
+# 00 SS, Not 8 SPT
+# 01 DS, Not 8 SPT
+# 10 SS, 8 SPT
+# 11 DS, 8 SPT
+#
+# 11111001 Double density 3½ floppy disk, high density 5¼
+# 11110000 High density 3½ floppy disk
+# 11111000 Hard disk any format
+#
+
+# CDROM Filesystems
+32769 string CD001 ISO 9660 CD-ROM filesystem data
+37633 string CD001 ISO 9660 CD-ROM filesystem data (raw 2352 byte sectors)
+32776 string CDROM High Sierra CD-ROM filesystem data
diff --git a/contrib/file/Magdir/gringotts b/contrib/file/Magdir/gringotts
new file mode 100644
index 0000000..2d135f8
--- /dev/null
+++ b/contrib/file/Magdir/gringotts
@@ -0,0 +1,25 @@
+
+#------------------------------------------------------------------------------
+# gringotts: file(1) magic for Gringotts
+# http://devel.pluto.linux.it/projects/Gringotts/
+# author: Germano Rizzo <mano@pluto.linux.it>
+#GRG2????Y
+0 string GRG Gringotts data file
+>3 string 1 v.1, SERPENT crypt, SHA-256 hash, ZLib lvl.9
+>3 string 2 v.2,
+>>8 byte&0x70 0x00 RIJNDAEL-128 crypt,
+>>8 byte&0x70 0x10 SERPENT crypt,
+>>8 byte&0x70 0x20 TWOFISH crypt,
+>>8 byte&0x70 0x30 CAST-256 crypt,
+>>8 byte&0x70 0x40 SAFER+ crypt,
+>>8 byte&0x70 0x50 LOKI97 crypt,
+>>8 byte&0x70 0x60 3DES crypt,
+>>8 byte&0x70 0x70 RIJNDAEL-256 crypt,
+>>8 byte&0x08 0x00 SHA1 hash,
+>>8 byte&0x08 0x08 RIPEMD-160 hash,
+>>8 byte&0x04 0x00 ZLib
+>>8 byte&0x04 0x04 BZip2
+>>8 byte&0x03 0x00 lvl.0
+>>8 byte&0x03 0x01 lvl.3
+>>8 byte&0x03 0x02 lvl.6
+>>8 byte&0x03 0x03 lvl.9
diff --git a/contrib/file/Magdir/hitachi-sh b/contrib/file/Magdir/hitachi-sh
index 136c038..a096eeb 100644
--- a/contrib/file/Magdir/hitachi-sh
+++ b/contrib/file/Magdir/hitachi-sh
@@ -7,12 +7,12 @@
0 beshort 0x0500 Hitachi SH big-endian COFF
>18 beshort&0x0002 =0x0000 object
>18 beshort&0x0002 =0x0002 executable
->18 beshort&0x0008 =0x0000 \b, stripped
->18 beshort&0x0008 =0x0008 \b, not stripped
+>18 beshort&0x0008 =0x0008 \b, stripped
+>18 beshort&0x0008 =0x0000 \b, not stripped
#
0 leshort 0x0550 Hitachi SH little-endian COFF
>18 leshort&0x0002 =0x0000 object
>18 leshort&0x0002 =0x0002 executable
->18 leshort&0x0008 =0x0000 \b, stripped
->18 leshort&0x0008 =0x0008 \b, not stripped
+>18 leshort&0x0008 =0x0008 \b, stripped
+>18 leshort&0x0008 =0x0000 \b, not stripped
diff --git a/contrib/file/Magdir/human68k b/contrib/file/Magdir/human68k
new file mode 100644
index 0000000..0ac82a7
--- /dev/null
+++ b/contrib/file/Magdir/human68k
@@ -0,0 +1,25 @@
+
+#------------------------------------------------------------------------------
+# human68k: file(1) magic for Human68k (X680x0 DOS) binary formats
+
+0 string HU Human68k
+>68 string LZX LZX compressed
+>>72 string >\0 (version %s)
+>(8.L+74) string LZX LZX compressed
+>>(8.L+78) string >\0 (version %s)
+>60 belong >0 binded
+>(8.L+66) string #HUPAIR hupair
+>0 string HU X executable
+>(8.L+74) string #LIBCV1 - linked PD LIBC ver 1
+>4 belong >0 - base address 0x%x
+>28 belong >0 not stripped
+>32 belong >0 with debug information
+0 beshort 0x601a Human68k Z executable
+0 beshort 0x6000 Human68k object file
+0 belong 0xd1000000 Human68k ar binary archive
+0 belong 0xd1010000 Human68k ar ascii archive
+0 beshort 0x0068 Human68k lib archive
+4 string LZX Human68k LZX compressed
+>8 string >\0 (version %s)
+>4 string LZX R executable
+2 string #HUPAIR Human68k hupair R executable
diff --git a/contrib/file/Magdir/images b/contrib/file/Magdir/images
index c07fa0c..daddc41 100644
--- a/contrib/file/Magdir/images
+++ b/contrib/file/Magdir/images
@@ -79,7 +79,7 @@
>4 string 7a \b, version 8%s,
>4 string 9a \b, version 8%s,
>6 leshort >0 %hd x
->8 leshort >0 %hd,
+>8 leshort >0 %hd
#>10 byte &0x80 color mapped,
#>10 byte&0x07 =0x00 2 colors
#>10 byte&0x07 =0x01 4 colors
diff --git a/contrib/file/Magdir/impulse b/contrib/file/Magdir/impulse
new file mode 100644
index 0000000..64c14c3
--- /dev/null
+++ b/contrib/file/Magdir/impulse
@@ -0,0 +1,18 @@
+#------------------------------------------------------------------------------
+# impulse tracker: file(1) magic for Impulse Tracker data files
+#
+# From <collver1@attbi.com>
+# These are the /etc/magic entries to decode modules, instruments, and
+# samples in Impulse Tracker's native format.
+
+0 string IMPS Impulse Tracker Sample
+>18 byte &2 16 bit
+>18 byte ^2 8 bit
+>18 byte &4 stereo
+>18 byte ^4 mono
+0 string IMPI Impulse Tracker Instrument
+>28 leshort !0 ITv%x
+>30 byte !0 %d samples
+0 string IMPM Impulse Tracker Module
+>40 leshort !0 compatible w/ITv%x
+>42 leshort !0 created w/ITv%x
diff --git a/contrib/file/Magdir/linux b/contrib/file/Magdir/linux
index 295edd9..4db4958 100644
--- a/contrib/file/Magdir/linux
+++ b/contrib/file/Magdir/linux
@@ -58,6 +58,8 @@
>3 byte >0 8x%d
# Linux swap file, from Daniel Quinlan <quinlan@yggdrasil.com>
4086 string SWAP-SPACE Linux/i386 swap file
+# according to man page of mkswap (8) March 1999
+4086 string SWAPSPACE2 Linux/i386 swap file (new style)
# ECOFF magic for OSF/1 and Linux (only tested under Linux though)
#
# from Erik Troan (ewt@redhat.com) examining od dumps, so this
@@ -99,3 +101,67 @@
>0x1e9 string Loading from prehistoric times
# LSM entries - Nicolás Lichtmaier <nick@feedback.net.ar>
0 string Begin3 Linux Software Map entry text
+
+############################################################################
+# Linux kernel versions
+
+0 string \xb8\xc0\x07\x8e\xd8\xb8\x00\x90 Linux
+>497 leshort 0 x86 boot sector
+>>514 belong 0x8e of a kernel from the dawn of time!
+>>514 belong 0x908ed8b4 version 0.99-1.1.42
+>>514 belong 0x908ed8b8 for memtest86
+
+>497 leshort !0 x86 kernel
+>>504 leshort >0 RAMdisksize=%u KB
+>>502 leshort >0 swap=0x%X
+>>508 leshort >0 root=0x%X
+>>>498 leshort 1 \b-ro
+>>>498 leshort 0 \b-rw
+>>506 leshort 0xFFFF vga=normal
+>>506 leshort 0xFFFE vga=extended
+>>506 leshort 0xFFFD vga=ask
+>>506 leshort >0 vga=%d
+>>514 belong 0x908ed881 version 1.1.43-1.1.45
+>>514 belong 0x15b281cd
+>>>0xa8e belong 0x55AA5a5a version 1.1.46-1.2.13,1.3.0
+>>>0xa99 belong 0x55AA5a5a version 1.3.1,2
+>>>0xaa3 belong 0x55AA5a5a version 1.3.3-1.3.30
+>>>0xaa6 belong 0x55AA5a5a version 1.3.31-1.3.41
+>>>0xb2b belong 0x55AA5a5a version 1.3.42-1.3.45
+>>>0xaf7 belong 0x55AA5a5a version 1.3.46-1.3.72
+>>514 string HdrS
+>>>518 leshort >0x1FF
+>>>>529 byte 0 \b, zImage
+>>>>529 byte 1 \b, bzImage
+>>>>(526.s+0x200) string >\0 \b, version %s
+
+# Linux boot sector thefts.
+0 belong 0xb8c0078e Linux
+>0x1e6 belong 0x454c4b53 ELKS Kernel
+>0x1e6 belong !0x454c4b53 style boot sector
+
+############################################################################
+# Linux 8086 executable
+0 lelong&0xFF0000FF 0xC30000E9 Linux-Dev86 executable, headerless
+>5 string .
+>>4 string >\0 \b, libc version %s
+
+0 lelong&0xFF00FFFF 0x4000301 Linux-8086 executable
+>2 byte&0x01 !0 \b, unmapped zero page
+>2 byte&0x20 0 \b, impure
+>2 byte&0x20 !0
+>>2 byte&0x10 !0 \b, A_EXEC
+>2 byte&0x02 !0 \b, A_PAL
+>2 byte&0x04 !0 \b, A_NSYM
+>2 byte&0x08 !0 \b, A_STAND
+>2 byte&0x40 !0 \b, A_PURE
+>2 byte&0x80 !0 \b, A_TOVLY
+>28 long !0 \b, not stripped
+>37 string .
+>>36 string >\0 \b, libc version %s
+
+# 0 lelong&0xFF00FFFF 0x10000301 ld86 I80386 executable
+# 0 lelong&0xFF00FFFF 0xB000301 ld86 M68K executable
+# 0 lelong&0xFF00FFFF 0xC000301 ld86 NS16K executable
+# 0 lelong&0xFF00FFFF 0x17000301 ld86 SPARC executable
+
diff --git a/contrib/file/Magdir/lisp b/contrib/file/Magdir/lisp
index 4e6c926..11f33cd 100644
--- a/contrib/file/Magdir/lisp
+++ b/contrib/file/Magdir/lisp
@@ -3,17 +3,24 @@
# lisp: file(1) magic for lisp programs
#
# various lisp types, from Daniel Quinlan (quinlan@yggdrasil.com)
+
+# This is a guess, but a good one.
0 string ;; Lisp/Scheme program text
+
# Emacs 18 - this is always correct, but not very magical.
-0 string \012( byte-compiled Emacs-Lisp program data
+0 string \012( Emacs v18 byte-compiled Lisp data
# Emacs 19+ - ver. recognition added by Ian Springer
-0 string ;ELC byte-compiled Emacs-Lisp program data,
->4 byte >0 version %d
-#
+# Also applies to XEmacs 19+ .elc files; could tell them apart if we had regexp
+# support or similar - Chris Chittleborough <cchittleborough@yahoo.com.au>
+0 string ;ELC
+>4 byte >19
+>4 byte <32 Emacs/XEmacs v%d byte-compiled Lisp data
+
# Files produced by CLISP Common Lisp From: Bruno Haible <haible@ilog.fr>
0 string (SYSTEM::VERSION\040' CLISP byte-compiled Lisp program text
0 long 0x70768BD2 CLISP memory image data
0 long 0xD28B7670 CLISP memory image data, other endian
+
# Files produced by GNU gettext
0 long 0xDE120495 GNU-format message catalog data
0 long 0x950412DE GNU-format message catalog data
diff --git a/contrib/file/Magdir/mcrypt b/contrib/file/Magdir/mcrypt
index 6416104..e862f59 100644
--- a/contrib/file/Magdir/mcrypt
+++ b/contrib/file/Magdir/mcrypt
@@ -1,31 +1,36 @@
#------------------------------------------------------------------------------
# Mavroyanopoulos Nikos <nmav@hellug.gr>
# mcrypt: file(1) magic for mcrypt 2.2.x;
-0 string \0m\2 mcrypt 2.2 encrypted data,
->3 byte 0 algorithm: blowfish-448,
->3 byte 1 algorithm: DES,
->3 byte 2 algorithm: 3DES,
->3 byte 3 algorithm: 3-WAY,
->3 byte 4 algorithm: GOST,
->3 byte 6 algorithm: SAFER-SK64,
->3 byte 7 algorithm: SAFER-SK128,
->3 byte 8 algorithm: CAST-128,
->3 byte 9 algorithm: xTEA,
->3 byte 10 algorithm: TWOFISH-128,
->3 byte 11 algorithm: RC2,
->3 byte 12 algorithm: TWOFISH-192,
->3 byte 13 algorithm: TWOFISH-256,
->3 byte 14 algorithm: blowfish-128,
->3 byte 15 algorithm: blowfish-192,
->3 byte 16 algorithm: blowfish-256,
->3 byte 100 algorithm: RC6,
->3 byte 101 algorithm: IDEA,
->4 byte 0 mode: CBC,
->4 byte 1 mode: ECB,
->4 byte 2 mode: CFB,
->4 byte 3 mode: OFB,
->4 byte 4 mode: nOFB,
->5 byte 0 keymode: 8bit
->5 byte 1 keymode: 4bit
->5 byte 2 keymode: SHA-1 hash
->5 byte 3 keymode: MD5 hash
+0 string \0m\3 mcrypt 2.5 encrypted data,
+>4 string >\0 algorithm: %s,
+>>&1 leshort >0 keysize: %d bytes,
+>>>&0 string >\0 mode: %s,
+
+0 string \0m\2 mcrypt 2.2 encrypted data,
+>3 byte 0 algorithm: blowfish-448,
+>3 byte 1 algorithm: DES,
+>3 byte 2 algorithm: 3DES,
+>3 byte 3 algorithm: 3-WAY,
+>3 byte 4 algorithm: GOST,
+>3 byte 6 algorithm: SAFER-SK64,
+>3 byte 7 algorithm: SAFER-SK128,
+>3 byte 8 algorithm: CAST-128,
+>3 byte 9 algorithm: xTEA,
+>3 byte 10 algorithm: TWOFISH-128,
+>3 byte 11 algorithm: RC2,
+>3 byte 12 algorithm: TWOFISH-192,
+>3 byte 13 algorithm: TWOFISH-256,
+>3 byte 14 algorithm: blowfish-128,
+>3 byte 15 algorithm: blowfish-192,
+>3 byte 16 algorithm: blowfish-256,
+>3 byte 100 algorithm: RC6,
+>3 byte 101 algorithm: IDEA,
+>4 byte 0 mode: CBC,
+>4 byte 1 mode: ECB,
+>4 byte 2 mode: CFB,
+>4 byte 3 mode: OFB,
+>4 byte 4 mode: nOFB,
+>5 byte 0 keymode: 8bit
+>5 byte 1 keymode: 4bit
+>5 byte 2 keymode: SHA-1 hash
+>5 byte 3 keymode: MD5 hash
diff --git a/contrib/file/Magdir/mlssa b/contrib/file/Magdir/mlssa
new file mode 100644
index 0000000..21ab61e
--- /dev/null
+++ b/contrib/file/Magdir/mlssa
@@ -0,0 +1,7 @@
+
+#------------------------------------------------------------------------------
+# mlssa: file(1) magic for MLSSA datafiles
+#
+0 lelong 0xffffabcd MLSSA datafile,
+>4 leshort x algorithm %d,
+>10 lelong x %d samples
diff --git a/contrib/file/Magdir/nitpicker b/contrib/file/Magdir/nitpicker
new file mode 100644
index 0000000..c40daec
--- /dev/null
+++ b/contrib/file/Magdir/nitpicker
@@ -0,0 +1,12 @@
+#------------------------------------------------------------------------------
+# nitpicker: file(1) magic for Flowfiles.
+# From: Christian Jachmann <C.Jachmann@gmx.net> http://www.nitpicker.de
+0 string NPFF NItpicker Flow File
+>4 byte x V%d.
+>5 byte x %d
+>6 bedate x started: %s
+>10 bedate x stopped: %s
+>14 belong x Bytes: %u
+>18 belong x Bytes1: %u
+>22 belong x Flows: %u
+>26 belong x Pkts: %u
diff --git a/contrib/file/Magdir/perl b/contrib/file/Magdir/perl
new file mode 100644
index 0000000..28b6086
--- /dev/null
+++ b/contrib/file/Magdir/perl
@@ -0,0 +1,18 @@
+
+#------------------------------------------------------------------------------
+# perl: file(1) magic for Larry Wall's perl language.
+#
+# The ``eval'' line recognizes an outrageously clever hack for USG systems.
+# Keith Waclena <keith@cerberus.uchicago.edu>
+# Send additions to <perl5-porters@perl.org>
+0 string/b #!\ /bin/perl perl script text executable
+0 string eval\ "exec\ /bin/perl perl script text
+0 string/b #!\ /usr/bin/perl perl script text executable
+0 string eval\ "exec\ /usr/bin/perl perl script text
+0 string/b #!\ /usr/local/bin/perl perl script text
+0 string eval\ "exec\ /usr/local/bin/perl perl script text executable
+
+# a couple more, by me
+# XXX: christos matches
+#0 regex package Perl5 module source text (via regex)
+0 string package Perl5 module source text
diff --git a/contrib/file/Magdir/printer b/contrib/file/Magdir/printer
index c47ff3b..dfbd5b9 100644
--- a/contrib/file/Magdir/printer
+++ b/contrib/file/Magdir/printer
@@ -86,3 +86,7 @@
>45 string >0 face %
# From Jukka Ukkonen
0 string \033[K\002\0\0\017\033(a\001\0\001\033(g Canon Bubble Jet BJC formatted data
+
+# From <mike@flyn.org>
+# These are the /etc/magic entries to decode data sent to an Epson printer.
+0 string \x1B\x40\x1B\x28\x52\x08\x00\x00REMOTE1P Epson Stylus Color 460 data
diff --git a/contrib/file/Magdir/pulsar b/contrib/file/Magdir/pulsar
new file mode 100644
index 0000000..a4a5c21
--- /dev/null
+++ b/contrib/file/Magdir/pulsar
@@ -0,0 +1,12 @@
+
+#------------------------------------------------------------------------------
+# pulsar: file(1) magic for Pulsar POP3 daemon binary files
+#
+# http://pulsar.sourceforge.net
+# mailto:rok.papez@lugos.si
+#
+
+0 belong 0x1ee7f11e Pulsar POP3 daemon mailbox cache file.
+>4 ubelong x Version: %d.
+>8 ubelong x \b%d
+
diff --git a/contrib/file/Magdir/sendmail b/contrib/file/Magdir/sendmail
index 503ef89..7880ab5 100644
--- a/contrib/file/Magdir/sendmail
+++ b/contrib/file/Magdir/sendmail
@@ -8,3 +8,12 @@
>16 string >\0 - version %s
0 short 0x271c Sendmail frozen configuration
>16 string >\0 - version %s
+
+#------------------------------------------------------------------------------
+# sendmail: file(1) magic for sendmail m4(1) files
+#
+# From Hendrik Scholz <hendrik@scholz.net>
+# i.e. files in /usr/share/sendmail/cf/
+#
+0 string divert(-1)\n sendmail m4 text file
+
diff --git a/contrib/file/Magdir/tex b/contrib/file/Magdir/tex
index 79d5bba..be84ecc 100644
--- a/contrib/file/Magdir/tex
+++ b/contrib/file/Magdir/tex
@@ -37,6 +37,10 @@
0 string \\documentclass LaTeX 2e document text
0 string \\relax LaTeX auxiliary file
0 string \\contentsline LaTeX table of contents
+0 string %\ -*-latex-*- LaTeX document text
+
+# Tex document, from Hendrik Scholz <hendrik@scholz.net>
+0 string \\ifx TeX document text
# Index and glossary files
0 string \\indexentry LaTeX raw index file
@@ -44,4 +48,56 @@
0 string \\glossaryentry LaTeX raw glossary
0 string \\begin{theglossary} LaTeX sorted glossary
0 string This\ is\ makeindex Makeindex log file
+
# End of TeX
+
+#------------------------------------------------------------------------------
+# file(1) magic for BibTex text files
+# From Hendrik Scholz <hendrik@scholz.net>
+
+0 string @article{ BibTex text file
+0 string @book{ BibTex text file
+0 string @inbook{ BibTex text file
+0 string @incollection{ BibTex text file
+0 string @inproceedings{ BibTex text file
+0 string @manual{ BibTex text file
+0 string @misc{ BibTex text file
+0 string @preamble{ BibTex text file
+0 string @phdthesis{ BibTex text file
+0 string @techreport{ BibTex text file
+0 string @unpublished{ BibTex text file
+
+0 string @Article{ BibTex text file
+0 string @Book{ BibTex text file
+0 string @Inbook{ BibTex text file
+0 string @Incollection{ BibTex text file
+0 string @Inproceedings{ BibTex text file
+0 string @Manual{ BibTex text file
+0 string @Misc{ BibTex text file
+0 string @Preamble{ BibTex text file
+0 string @Phdthesis{ BibTex text file
+0 string @Techreport{ BibTex text file
+0 string @Unpublished{ BibTex text file
+
+0 string @ARTICLE{ BibTex text file
+0 string @BOOK{ BibTex text file
+0 string @INBOOK{ BibTex text file
+0 string @INCOLLECTION{ BibTex text file
+0 string @INPROCEEDINGS{ BibTex text file
+0 string @MANUAL{ BibTex text file
+0 string @MISC{ BibTex text file
+0 string @PREAMBLE{ BibTex text file
+0 string @PHDTHESIS{ BibTex text file
+0 string @TECHREPORT{ BibTex text file
+0 string @UNPUBLISHED{ BibTex text file
+
+73 string %%%\ \ BibTeX-file{ BibTex text file (with full header)
+
+73 string %%%\ \ @BibTeX-style-file{ BibTeX style text file (with full header)
+
+0 string %\ BibTeX\ standard\ bibliography\ BibTeX standard bibliography style text file
+
+0 string %\ BibTeX\ ` BibTeX custom bibliography style text file
+
+0 string @c\ @mapfile{ TeX font aliases text file
+
diff --git a/contrib/file/Magdir/tgif b/contrib/file/Magdir/tgif
new file mode 100644
index 0000000..a6ffe36
--- /dev/null
+++ b/contrib/file/Magdir/tgif
@@ -0,0 +1,6 @@
+#------------------------------------------------------------------------------
+# file(1) magic for tgif(1) files
+# From Hendrik Scholz <hendrik@scholz.net>
+
+0 string %TGIF\ 4 tgif version 4 object file
+
diff --git a/contrib/file/Magdir/varied.out b/contrib/file/Magdir/varied.out
index 03ca510..76322dd 100644
--- a/contrib/file/Magdir/varied.out
+++ b/contrib/file/Magdir/varied.out
@@ -26,3 +26,7 @@
# gnu gmon magic From: Eugen Dedu <dedu@ese-metz.fr>
0 string gmon GNU prof performance data
>4 long x - version %ld
+# From: Dave Pearson <davep@davep.org>
+# Harbour <URL:http://www.harbour-project.org/> HRB files.
+0 string \xc0HRB Harbour HRB file
+>4 short x version %d
diff --git a/contrib/file/Magdir/vorbis b/contrib/file/Magdir/vorbis
index 6e4efad..5e40842 100644
--- a/contrib/file/Magdir/vorbis
+++ b/contrib/file/Magdir/vorbis
@@ -4,6 +4,7 @@
#
# From Felix von Leitner <leitner@fefe.de>
# Extended by Beni Cherniavsky <cben@crosswinds.net>
+# Further extended by Greg Wooledge <greg@wooledge.org>
#
# Most (everything but the number of channels and bitrate) is commented
# out with `##' as it's not interesting to the average user. The most
@@ -29,34 +30,44 @@
>>>>48 string <\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \b,
# The above tests if at least one of these is specified:
>>>>>44 lelong !-1
->>>>>>44 lelong x >%lu
+# Vorbis RC2 has a bug which puts -1000 in the min/max bitrate fields
+# instead of -1.
+>>>>>>44 lelong !-1000
+>>>>>>>44 lelong x >%lu
>>>>>48 lelong !-1
>>>>>>48 lelong x ~%lu
>>>>>52 lelong !-1
->>>>>>52 lelong x <%lu
+>>>>>>52 lelong !-1000
+>>>>>>>52 lelong x <%lu
>>>>>48 string <\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff kbps
# -- Second vorbis header packet - the comments
->>>102 string \x03vorbis
# A kludge to read the vendor string. It's a counted string, not a
# zero-terminated one, so file(1) can't read it in a generic way.
# libVorbis is the only one existing currently, so I detect specifically
# it. The interesting value is the cvs date (8 digits decimal).
-##>>>>113 string/c Xiphophorus\ libVorbis\ I \b, created by: Xiphophorus libVorbis I
-##>>>>>137 string >00000000 %.8s
+# Post-RC1 Ogg files have the second header packet (and thus the version)
+# in a different place, so we must use an indirect offset.
+>>>(84.b+85) string \x03vorbis
+>>>>(84.b+96) string/c Xiphophorus\ libVorbis\ I \b, created by: Xiphophorus libVorbis I
+>>>>>(84.b+120) string >00000000 %.8s
# Map to beta version numbers:
-##>>>>>>137 string <20000508 (<beta1 - prepublic)
+>>>>>>(84.b+120) string <20000508 (<beta1 - prepublic)
+>>>>>>(84.b+120) string 20000508 (beta1/2)
+>>>>>>(84.b+120) string >20000508
+>>>>>>>(84.b+120) string <20001031 (beta2-3)
+>>>>>>(84.b+120) string 20001031 (beta3)
+>>>>>>(84.b+120) string >20001031
+>>>>>>>(84.b+120) string <20010225 (beta3-4)
+>>>>>>(84.b+120) string 20010225 (beta4)
+>>>>>>(84.b+120) string >20010225
+>>>>>>>(84.b+120) string <20010615 (beta4-RC1)
+>>>>>>(84.b+120) string 20010615 (RC1)
+>>>>>>(84.b+120) string 20010813 (RC2)
+>>>>>>(84.b+120) string 20010816 (RC2 - Garf tuned v1)
+>>>>>>(84.b+120) string 20011014 (RC2 - Garf tuned v2)
+>>>>>>(84.b+120) string 20011217 (pre-RC3 CVS)
+>>>>>>(84.b+120) string 20011231 (RC3)
# The string has not changed from beta1 to 2 - they are indistinguishable.
-##>>>>>>137 string 20000508 (beta1/2)
-##>>>>>>137 string >20000508
-##>>>>>>>137 string <20001031 (beta2-3)
-##>>>>>>137 string 20001031 (beta3)
-##>>>>>>137 string >20001031
-##>>>>>>>137 string <20010225 (beta3-4)
-##>>>>>>137 string 20010225 (beta4)
-##>>>>>>137 string >20010225
-##>>>>>>>137 string <20010615 (beta4-RC1)
-##>>>>>>137 string 20010615 (RC1)
-##>>>>>>137 string >20010615 (>RC1)
# Then come the comments, again length-counted (and number-counted).
# Some looping constructs and registers would allow reading them but now
# it's impossible. However we can print the number of comments present
diff --git a/contrib/file/Magdir/vxl b/contrib/file/Magdir/vxl
new file mode 100644
index 0000000..d3f5561
--- /dev/null
+++ b/contrib/file/Magdir/vxl
@@ -0,0 +1,13 @@
+
+#------------------------------------------------------------------------------
+# VXL: file(1) magic for VXL binary IO data files
+#
+# from Ian Scott <scottim@sf.net>
+#
+# VXL is a collection of C++ libraries for Computer Vision.
+# See the vsl chapter in the VXL Book for more info
+# http://www.isbe.man.ac.uk/public_vxl_doc/books/vxl/book.html
+# http:/vxl.sf.net
+
+2 lelong 0x472b2c4e VXL data file,
+>0 leshort >0 schema version no %d
diff --git a/contrib/file/Makefile.am b/contrib/file/Makefile.am
index 790951f..c26f6f9 100644
--- a/contrib/file/Makefile.am
+++ b/contrib/file/Makefile.am
@@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
bin_PROGRAMS = file
-data_DATA = magic magic.mime magic.mgc
+data_DATA = magic magic.mime magic.mgc magic.mime.mgc
MAGIC = @datadir@/magic
CPPFLAGS = -DMAGIC='"$(MAGIC)"'
@@ -23,7 +23,7 @@ file_SOURCES = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
EXTRA_DIST = LEGAL.NOTICE MAINT PORTING Makefile.std magic2mime \
Localstuff Header $(magic_FRAGMENTS) file.man magic.man
-CLEANFILES = $(man_MANS) magic magic.mgc
+CLEANFILES = $(man_MANS) magic magic.mgc magic.mime.mgc
magic: Header Localstuff $(magic_FRAGMENTS)
cat $(srcdir)/Header $(srcdir)/Localstuff > $@
@@ -39,6 +39,9 @@ magic: Header Localstuff $(magic_FRAGMENTS)
magic.mgc: magic file
./file -C -m magic
+magic.mime.mgc: magic.mime file
+ ./file -C -m $(srcdir)/magic.mime
+
file.1: Makefile file.man
@rm -f $@
sed -e s@__CSECTION__@1@g \
@@ -53,31 +56,159 @@ magic.${fsect}: Makefile magic.man
-e s@__VERSION__@${VERSION}@g \
-e s@__MAGIC__@${MAGIC}@g $(srcdir)/magic.man > $@
-magic_FRAGMENTS = Magdir/adi Magdir/adventure Magdir/allegro Magdir/alliant \
- Magdir/alpha Magdir/amanda Magdir/amigaos Magdir/animation \
- Magdir/apl Magdir/apple Magdir/applix Magdir/archive Magdir/asterix \
- Magdir/att3b Magdir/audio Magdir/blender Magdir/blit Magdir/bsdi \
- Magdir/c-lang Magdir/chi Magdir/cisco Magdir/claris Magdir/clipper \
- Magdir/commands Magdir/compress Magdir/console Magdir/convex \
- Magdir/database Magdir/diamond Magdir/diff Magdir/digital \
- Magdir/dump Magdir/elf Magdir/encore Magdir/epoc Magdir/filesystems \
- Magdir/flash Magdir/fonts Magdir/frame Magdir/freebsd Magdir/fsav \
- Magdir/gimp Magdir/gnu Magdir/grace Magdir/hp Magdir/ibm370 \
- Magdir/ibm6000 Magdir/iff Magdir/images Magdir/intel \
- Magdir/interleaf Magdir/island Magdir/ispell Magdir/java \
- Magdir/jpeg Magdir/karma Magdir/lecter Magdir/lex Magdir/lif \
- Magdir/linux Magdir/lisp Magdir/mach Magdir/macintosh Magdir/magic \
- Magdir/mail.news Magdir/maple Magdir/mathematica Magdir/mcrypt \
- Magdir/mime Magdir/mips Magdir/mirage Magdir/mkid Magdir/mmdf Magdir/modem \
- Magdir/motorola Magdir/msdos Magdir/msvc Magdir/ncr Magdir/netbsd \
- Magdir/netscape Magdir/news Magdir/octave Magdir/olf Magdir/os2 \
- Magdir/os9 Magdir/osf1 Magdir/palm Magdir/pbm Magdir/pdf Magdir/pdp \
- Magdir/pgp Magdir/pkgadd Magdir/plus5 Magdir/printer Magdir/project \
- Magdir/psdbms Magdir/pyramid Magdir/python Magdir/riff Magdir/rpm \
- Magdir/rtf Magdir/sc Magdir/sccs Magdir/sendmail Magdir/sequent \
- Magdir/sgml Magdir/sketch Magdir/sniffer Magdir/softquad Magdir/spectrum \
- Magdir/sun Magdir/teapot Magdir/terminfo Magdir/tex Magdir/ti-8x \
- Magdir/timezone Magdir/troff Magdir/typeset Magdir/unknown \
- Magdir/uuencode Magdir/varied.out Magdir/vax Magdir/vicar Magdir/visx \
- Magdir/vms Magdir/vmware Magdir/wordperfect Magdir/xdelta Magdir/xenix \
- Magdir/zilog Magdir/zyxel
+magic_FRAGMENTS = \
+Magdir/acorn \
+Magdir/adi \
+Magdir/adventure \
+Magdir/allegro \
+Magdir/alliant \
+Magdir/alpha \
+Magdir/amanda \
+Magdir/amigaos \
+Magdir/animation \
+Magdir/apl \
+Magdir/apple \
+Magdir/applix \
+Magdir/archive \
+Magdir/asterix \
+Magdir/att3b \
+Magdir/audio \
+Magdir/blender \
+Magdir/blit \
+Magdir/bsdi \
+Magdir/c-lang \
+Magdir/cddb \
+Magdir/chi \
+Magdir/cisco \
+Magdir/citrus \
+Magdir/claris \
+Magdir/clipper \
+Magdir/commands \
+Magdir/compress \
+Magdir/console \
+Magdir/convex \
+Magdir/ctags \
+Magdir/cvs \
+Magdir/database \
+Magdir/diamond \
+Magdir/diff \
+Magdir/digital \
+Magdir/dolby \
+Magdir/dump \
+Magdir/dyadic \
+Magdir/editors \
+Magdir/elf \
+Magdir/encore \
+Magdir/epoc \
+Magdir/filesystems \
+Magdir/flash \
+Magdir/fonts \
+Magdir/frame \
+Magdir/freebsd \
+Magdir/fsav \
+Magdir/gimp \
+Magdir/gnu \
+Magdir/grace \
+Magdir/gringotts \
+Magdir/hitachi-sh \
+Magdir/hp \
+Magdir/ibm370 \
+Magdir/ibm6000 \
+Magdir/iff \
+Magdir/images \
+Magdir/impulse \
+Magdir/intel \
+Magdir/interleaf \
+Magdir/island \
+Magdir/ispell \
+Magdir/java \
+Magdir/jpeg \
+Magdir/karma \
+Magdir/lecter \
+Magdir/lex \
+Magdir/lif \
+Magdir/linux \
+Magdir/lisp \
+Magdir/mach \
+Magdir/macintosh \
+Magdir/magic \
+Magdir/mail.news \
+Magdir/maple \
+Magdir/mathematica \
+Magdir/mcrypt \
+Magdir/mime \
+Magdir/mips \
+Magdir/mirage \
+Magdir/mkid \
+Magdir/mmdf \
+Magdir/mlssa \
+Magdir/modem \
+Magdir/motorola \
+Magdir/msdos \
+Magdir/msvc \
+Magdir/natinst \
+Magdir/ncr \
+Magdir/netbsd \
+Magdir/netscape \
+Magdir/news \
+Magdir/nitpicker \
+Magdir/octave \
+Magdir/olf \
+Magdir/os2 \
+Magdir/os9 \
+Magdir/osf1 \
+Magdir/palm \
+Magdir/parix \
+Magdir/pbm \
+Magdir/pdf \
+Magdir/pdp \
+Magdir/perl \
+Magdir/pgp \
+Magdir/pkgadd \
+Magdir/plus5 \
+Magdir/printer \
+Magdir/project \
+Magdir/psdbms \
+Magdir/pulsar \
+Magdir/pyramid \
+Magdir/python \
+Magdir/riff \
+Magdir/rpm \
+Magdir/rtf \
+Magdir/sc \
+Magdir/sccs \
+Magdir/sendmail \
+Magdir/sequent \
+Magdir/sgml \
+Magdir/sharc \
+Magdir/sketch \
+Magdir/smalltalk \
+Magdir/sniffer \
+Magdir/softquad \
+Magdir/spectrum \
+Magdir/sun \
+Magdir/sysex \
+Magdir/teapot \
+Magdir/terminfo \
+Magdir/tex \
+Magdir/tgif \
+Magdir/ti-8x \
+Magdir/timezone \
+Magdir/troff \
+Magdir/tuxedo \
+Magdir/typeset \
+Magdir/unknown \
+Magdir/uuencode \
+Magdir/varied.out \
+Magdir/vax \
+Magdir/vicar \
+Magdir/visx \
+Magdir/vms \
+Magdir/vmware \
+Magdir/vorbis \
+Magdir/vxl \
+Magdir/wordperfect \
+Magdir/xdelta \
+Magdir/xenix \
+Magdir/zilog \
+Magdir/zyxel
diff --git a/contrib/file/Makefile.in b/contrib/file/Makefile.in
index 7a27145..f61dafc 100644
--- a/contrib/file/Makefile.in
+++ b/contrib/file/Makefile.in
@@ -69,7 +69,7 @@ AUTOMAKE_OPTIONS = foreign no-dependencies
bin_PROGRAMS = file
-data_DATA = magic magic.mime magic.mgc
+data_DATA = magic magic.mime magic.mgc magic.mime.mgc
MAGIC = @datadir@/magic
CPPFLAGS = -DMAGIC='"$(MAGIC)"'
@@ -84,9 +84,9 @@ file_SOURCES = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c compress.c
EXTRA_DIST = LEGAL.NOTICE MAINT PORTING Makefile.std magic2mime Localstuff Header $(magic_FRAGMENTS) file.man magic.man
-CLEANFILES = $(man_MANS) magic magic.mgc
+CLEANFILES = $(man_MANS) magic magic.mgc magic.mime.mgc
-magic_FRAGMENTS = Magdir/adi Magdir/adventure Magdir/allegro Magdir/alliant Magdir/alpha Magdir/amanda Magdir/amigaos Magdir/animation Magdir/apl Magdir/apple Magdir/applix Magdir/archive Magdir/asterix Magdir/att3b Magdir/audio Magdir/blender Magdir/blit Magdir/bsdi Magdir/c-lang Magdir/chi Magdir/cisco Magdir/claris Magdir/clipper Magdir/commands Magdir/compress Magdir/console Magdir/convex Magdir/database Magdir/diamond Magdir/diff Magdir/digital Magdir/dump Magdir/elf Magdir/encore Magdir/epoc Magdir/filesystems Magdir/flash Magdir/fonts Magdir/frame Magdir/freebsd Magdir/fsav Magdir/gimp Magdir/gnu Magdir/grace Magdir/hp Magdir/ibm370 Magdir/ibm6000 Magdir/iff Magdir/images Magdir/intel Magdir/interleaf Magdir/island Magdir/ispell Magdir/java Magdir/jpeg Magdir/karma Magdir/lecter Magdir/lex Magdir/lif Magdir/linux Magdir/lisp Magdir/mach Magdir/macintosh Magdir/magic Magdir/mail.news Magdir/maple Magdir/mathematica Magdir/mcrypt Magdir/mime Magdir/mips Magdir/mirage Magdir/mkid Magdir/mmdf Magdir/modem Magdir/motorola Magdir/msdos Magdir/msvc Magdir/ncr Magdir/natinst Magdir/netbsd Magdir/netscape Magdir/news Magdir/octave Magdir/olf Magdir/os2 Magdir/os9 Magdir/osf1 Magdir/palm Magdir/pbm Magdir/pdf Magdir/pdp Magdir/pgp Magdir/pkgadd Magdir/plus5 Magdir/printer Magdir/project Magdir/psdbms Magdir/pyramid Magdir/python Magdir/riff Magdir/rpm Magdir/rtf Magdir/sc Magdir/sccs Magdir/sendmail Magdir/sequent Magdir/sgml Magdir/sketch Magdir/sniffer Magdir/softquad Magdir/spectrum Magdir/sun Magdir/teapot Magdir/terminfo Magdir/tex Magdir/ti-8x Magdir/timezone Magdir/troff Magdir/typeset Magdir/unknown Magdir/uuencode Magdir/varied.out Magdir/vax Magdir/vicar Magdir/visx Magdir/vms Magdir/vmware Magdir/wordperfect Magdir/xdelta Magdir/xenix Magdir/zilog Magdir/zyxel
+magic_FRAGMENTS = Magdir/acorn Magdir/adi Magdir/adventure Magdir/allegro Magdir/alliant Magdir/alpha Magdir/amanda Magdir/amigaos Magdir/animation Magdir/apl Magdir/apple Magdir/applix Magdir/archive Magdir/asterix Magdir/att3b Magdir/audio Magdir/blender Magdir/blit Magdir/bsdi Magdir/c-lang Magdir/cddb Magdir/chi Magdir/cisco Magdir/citrus Magdir/claris Magdir/clipper Magdir/commands Magdir/compress Magdir/console Magdir/convex Magdir/ctags Magdir/cvs Magdir/database Magdir/diamond Magdir/diff Magdir/digital Magdir/dolby Magdir/dump Magdir/dyadic Magdir/editors Magdir/elf Magdir/encore Magdir/epoc Magdir/filesystems Magdir/flash Magdir/fonts Magdir/frame Magdir/freebsd Magdir/fsav Magdir/gimp Magdir/gnu Magdir/grace Magdir/gringotts Magdir/hitachi-sh Magdir/hp Magdir/ibm370 Magdir/ibm6000 Magdir/iff Magdir/images Magdir/impulse Magdir/intel Magdir/interleaf Magdir/island Magdir/ispell Magdir/java Magdir/jpeg Magdir/karma Magdir/lecter Magdir/lex Magdir/lif Magdir/linux Magdir/lisp Magdir/mach Magdir/macintosh Magdir/magic Magdir/mail.news Magdir/maple Magdir/mathematica Magdir/mcrypt Magdir/mime Magdir/mips Magdir/mirage Magdir/mkid Magdir/mmdf Magdir/mlssa Magdir/modem Magdir/motorola Magdir/msdos Magdir/msvc Magdir/natinst Magdir/ncr Magdir/netbsd Magdir/netscape Magdir/news Magdir/nitpicker Magdir/octave Magdir/olf Magdir/os2 Magdir/os9 Magdir/osf1 Magdir/palm Magdir/parix Magdir/pbm Magdir/pdf Magdir/pdp Magdir/perl Magdir/pgp Magdir/pkgadd Magdir/plus5 Magdir/printer Magdir/project Magdir/psdbms Magdir/pulsar Magdir/pyramid Magdir/python Magdir/riff Magdir/rpm Magdir/rtf Magdir/sc Magdir/sccs Magdir/sendmail Magdir/sequent Magdir/sgml Magdir/sharc Magdir/sketch Magdir/smalltalk Magdir/sniffer Magdir/softquad Magdir/spectrum Magdir/sun Magdir/sysex Magdir/teapot Magdir/terminfo Magdir/tex Magdir/tgif Magdir/ti-8x Magdir/timezone Magdir/troff Magdir/tuxedo Magdir/typeset Magdir/unknown Magdir/uuencode Magdir/varied.out Magdir/vax Magdir/vicar Magdir/visx Magdir/vms Magdir/vmware Magdir/vorbis Magdir/vxl Magdir/wordperfect Magdir/xdelta Magdir/xenix Magdir/zilog Magdir/zyxel
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@@ -122,7 +122,7 @@ missing mkinstalldirs
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-TAR = gtar
+TAR = tar
GZIP_ENV = --best
SOURCES = $(file_SOURCES)
OBJECTS = $(file_OBJECTS)
@@ -520,6 +520,9 @@ magic: Header Localstuff $(magic_FRAGMENTS)
magic.mgc: magic file
./file -C -m magic
+magic.mime.mgc: magic.mime file
+ ./file -C -m $(srcdir)/magic.mime
+
file.1: Makefile file.man
@rm -f $@
sed -e s@__CSECTION__@1@g \
diff --git a/contrib/file/Makefile.std b/contrib/file/Makefile.std
index 47846d9..b930f04 100644
--- a/contrib/file/Makefile.std
+++ b/contrib/file/Makefile.std
@@ -1,6 +1,6 @@
# Makefile for file(1) cmd.
# Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE.
-# @(#)$Id: Makefile.std,v 1.12 2001/09/03 14:44:21 christos Exp $
+# @(#)$Id: Makefile.std,v 1.15 2002/07/03 18:57:52 christos Exp $
#
# This software is not subject to any license of the American Telephone
# and Telegraph Company or of the Regents of the University of California.
@@ -22,7 +22,7 @@
#
# 4. This notice may not be removed or altered.
#
-VERSION = 3.37
+VERSION = 3.39
SHELL = /bin/sh
#MAGIC = /etc/magic
MAGIC = /usr/local/etc/magic
@@ -71,10 +71,10 @@ LOCALOBJS = # localsrc/getopt.o localsrc/strtol.o \
LOCALINC = # localinc/*.h localinc/sys/*.h
SRCS = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
- compress.c is_tar.c readelf.c internat.c \
+ compress.c is_tar.c readelf.c \
print.c $(LOCALSRCS) $(LOCALINC)
OBJS = file.o apprentice.o fsmagic.o softmagic.o ascmagic.o \
- compress.o is_tar.o readelf.o internat.o \
+ compress.o is_tar.o readelf.o \
print.o $(LOCALOBJS)
HDRS = file.h names.h patchlevel.h readelf.h tar.h
diff --git a/contrib/file/README b/contrib/file/README
index d8e941b..1a0ff8d 100644
--- a/contrib/file/README
+++ b/contrib/file/README
@@ -1,5 +1,5 @@
** README for file(1) Command **
-@(#) $Id: README,v 1.25 2001/07/23 21:30:22 christos Exp $
+@(#) $Id: README,v 1.26 2002/05/16 18:45:56 christos Exp $
This is Release 3.x of Ian Darwin's (copyright but distributable)
file(1) command. This version is the standard "file" command for Linux,
@@ -8,7 +8,7 @@ file(1) command. This version is the standard "file" command for Linux,
UNIX is a trademark of UNIX System Laboratories.
The prime contributor to Release 3.8 was Guy Harris, who put in megachanges
-including byte-order independance.
+including byte-order independence.
The prime contributor to Release 3.0 was Christos Zoulas, who put
in hundreds of lines of source code changes, including his own
@@ -43,7 +43,7 @@ Makefile - read this next, adapt it as needed (particularly
the man page layouts), type "make" to compile,
"make try" to try it out against your old version.
Expect some diffs, particularly since your original
- file(1) may not grok the imbedded-space ("\ ") in
+ file(1) may not grok the embedded-space ("\ ") in
the current magic file, or may even not use the
magic file.
apprentice.c - parses /etc/magic to learn magic
@@ -61,9 +61,8 @@ magdir - directory of /etc/magic pieces
magdir/Makefile - ADJUST THIS FOR YOUR CONFIGURATION
names.h - header file for ascmagic.c
softmagic.c - 2nd set of tests, based on /etc/magic
-readelf.[ch] - Standalone elf parsing code.
+readelf.[ch] - Stand-alone elf parsing code.
compress.c - on-the-fly decompression.
-internat.c - recognize international `text' files.
print.c - print results, errors, warnings.
If your gzip sometimes fails to decompress things complaining about a short
diff --git a/contrib/file/acconfig.h b/contrib/file/acconfig.h
index b2d201d..7818191 100644
--- a/contrib/file/acconfig.h
+++ b/contrib/file/acconfig.h
@@ -13,12 +13,21 @@
/* Define if the `long long' type works. */
#undef HAVE_LONG_LONG
+/* Define if we have "tm_zone" in "struct tm". */
+#undef HAVE_TM_ZONE
+
+/* Define if we have a global "char * []" "tzname" variable. */
+#undef HAVE_TZNAME
+
/* Define if we have "tm_isdst" in "struct tm". */
#undef HAVE_TM_ISDST
/* Define if we have a global "int" variable "daylight". */
#undef HAVE_DAYLIGHT
+/* Define if we have a mkstemp */
+#undef HAVE_MKSTEMP
+
/* Define to `unsigned char' if standard headers don't define. */
#undef uint8_t
diff --git a/contrib/file/acinclude.m4 b/contrib/file/acinclude.m4
index 95990e5..79ecb0e 100644
--- a/contrib/file/acinclude.m4
+++ b/contrib/file/acinclude.m4
@@ -1,5 +1,5 @@
dnl cloned from autoconf 2.13 acspecific.m4
-AC_DEFUN(AC_C_LONG_LONG,
+AC_DEFUN([AC_C_LONG_LONG],
[AC_CACHE_CHECK(for long long, ac_cv_c_long_long,
[if test "$GCC" = yes; then
ac_cv_c_long_long=yes
@@ -14,23 +14,16 @@ if test $ac_cv_c_long_long = yes; then
fi
])
-dnl from autoconf 2.13 acgeneral.m4, with patch:
-dnl Date: Fri, 15 Jan 1999 05:52:41 -0800
-dnl Message-ID: <199901151352.FAA18237@shade.twinsun.com>
-dnl From: eggert@twinsun.com (Paul Eggert)
-dnl Subject: autoconf 2.13 AC_CHECK_TYPE doesn't allow shell vars
-dnl Newsgroups: gnu.utils.bug
-
dnl from autoconf 2.13 acspecific.m4, with changes to check for daylight
-AC_DEFUN(AC_STRUCT_TIMEZONE_DAYLIGHT,
+AC_DEFUN([AC_STRUCT_TIMEZONE_DAYLIGHT],
[AC_REQUIRE([AC_STRUCT_TM])dnl
AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;],
ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])
if test "$ac_cv_struct_tm_zone" = yes; then
- AC_DEFINE(HAVE_TM_ZONE)
+ AC_DEFINE(HAVE_TM_ZONE,1,[HAVE_TM_ZONE])
fi
AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
[AC_TRY_LINK(
@@ -42,7 +35,7 @@ extern char *tzname[]; /* RS6000 and others reject char **tzname. */
changequote([, ])dnl
[atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
if test $ac_cv_var_tzname = yes; then
- AC_DEFINE(HAVE_TZNAME)
+ AC_DEFINE(HAVE_TZNAME,1,[HAVE_TZNAME])
fi
AC_CACHE_CHECK([for tm_isdst in struct tm], ac_cv_struct_tm_isdst,
@@ -66,15 +59,27 @@ changequote([, ])dnl
fi
])
-dnl AC_CHECK_TYPE2(TYPE, DEFAULT)
-AC_DEFUN(AC_CHECK_TYPE2,
+dnl from autoconf 2.13 acgeneral.m4, with patch:
+dnl Date: Fri, 15 Jan 1999 05:52:41 -0800
+dnl Message-ID: <199901151352.FAA18237@shade.twinsun.com>
+dnl From: eggert@twinsun.com (Paul Eggert)
+dnl Subject: autoconf 2.13 AC_CHECK_TYPE doesn't allow shell vars
+dnl Newsgroups: gnu.utils.bug
+dnl
+dnl now include <stdint.h> if available
+
+dnl AC_CHECK_TYPE2_STDC(TYPE, DEFAULT)
+AC_DEFUN([AC_CHECK_TYPE2_STDC],
[AC_REQUIRE([AC_HEADER_STDC])dnl
+AC_REQUIRE([AC_HEADER_STDINT])dnl
AC_MSG_CHECKING(for $1)
AC_CACHE_VAL(ac_cv_type_$1,
[AC_EGREP_CPP(dnl
-changequote(<<,>>)dnl
-<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
-changequote([,]), [#include <sys/types.h>
+[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]],
+[#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
@@ -88,14 +93,12 @@ fi
])
dnl from autoconf 2.13 acgeneral.m4, with additional third argument
-dnl AC_CHECK_SIZEOF_INCLUDES(TYPE [, CROSS-SIZE, [INCLUDES]])
-AC_DEFUN(AC_CHECK_SIZEOF_INCLUDES,
-[changequote(<<, >>)dnl
-dnl The name to #define.
-define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
+dnl AC_CHECK_SIZEOF_INCLUDES(TYPE [, CROSS-SIZE [, INCLUDES]])
+AC_DEFUN([AC_CHECK_SIZEOF_INCLUDES],
+[dnl The name to #define.
+define([AC_TYPE_NAME], translit(sizeof_$1, [[[a-z *]]], [[[A-Z_P]]]))dnl
dnl The cache variable name.
-define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
-changequote([, ])dnl
+define([AC_CV_NAME], translit(ac_cv_sizeof_$1, [[[ *]]], [[[_p]]]))dnl
AC_MSG_CHECKING(size of $1)
AC_CACHE_VAL(AC_CV_NAME,
[AC_TRY_RUN([$3
@@ -114,11 +117,138 @@ undefine([AC_CV_NAME])dnl
])
dnl AC_CHECK_SIZEOF_STDC_HEADERS(TYPE [, CROSS_SIZE])
-AC_DEFUN(AC_CHECK_SIZEOF_STDC_HEADERS,
-[AC_CHECK_SIZEOF_INCLUDES($1, $2,
-[#include <sys/types.h>
+AC_DEFUN([AC_CHECK_SIZEOF_STDC_HEADERS],
+[AC_REQUIRE([AC_HEADER_STDC])dnl
+AC_REQUIRE([AC_HEADER_STDINT])dnl
+AC_CHECK_SIZEOF_INCLUDES($1, $2,
+[#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#include <sys/types.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif
])
])
+
+
+dnl AC_CHECK_TYPE_STDC(TYPE, DEFAULT)
+AC_DEFUN([AC_CHECK_TYPE_STDC],
+[AC_REQUIRE([AC_HEADER_STDC])dnl
+AC_REQUIRE([AC_HEADER_STDINT])dnl
+AC_MSG_CHECKING(for $1)
+AC_CACHE_VAL(ac_cv_type_$1,
+[AC_EGREP_CPP(dnl
+[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]],
+[#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
+AC_MSG_RESULT($ac_cv_type_$1)
+if test $ac_cv_type_$1 = no; then
+ AC_DEFINE($1, $2)
+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:
+dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
+
+dnl Written by Paul Eggert <eggert@twinsun.com>.
+
+dnl Internal subroutine of AC_SYS_LARGEFILE.
+dnl AC_SYS_LARGEFILE_TEST_INCLUDES
+AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES],
+ [[#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply "#define LARGE_OFF_T 9223372036854775807",
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+ ]])
+
+dnl Internal subroutine of AC_SYS_LARGEFILE.
+dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLU=
+DES, FUNCTION-BODY)
+AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE],
+ [AC_CACHE_CHECK([for $1 value needed for large files], $3,
+ [$3=no
+ AC_TRY_COMPILE([$5],
+ [$6],
+ ,
+ [AC_TRY_COMPILE([#define $1 $2]
+[$5]
+ ,
+ [$6],
+ [$3=$2])])])
+ if test "[$]$3" != no; then
+ AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
+ fi])
+
+AC_DEFUN([AC_SYS_LARGEFILE],
+ [AC_REQUIRE([AC_PROG_CC])
+ AC_ARG_ENABLE(largefile,
+ [ --disable-largefile omit support for large files])
+ if test "$enable_largefile" != no; then
+
+ AC_CACHE_CHECK([for special C compiler options needed for large files=
+],
+ ac_cv_sys_largefile_CC,
+ [ac_cv_sys_largefile_CC=no
+ if test "$GCC" != yes; then
+ # IRIX 6.2 and later do not support large files by default,
+ # so use the C compiler's -n32 option if that helps.
+ AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
+ [ac_save_CC="$CC"
+ CC="$CC -n32"
+ AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
+ ac_cv_sys_largefile_CC=' -n32')
+ CC="$ac_save_CC"])
+ fi])
+ if test "$ac_cv_sys_largefile_CC" != no; then
+ CC="$CC$ac_cv_sys_largefile_CC"
+ fi
+
+ AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
+ ac_cv_sys_file_offset_bits,
+ [Number of bits in a file offset, on hosts where this is settable.],
+ AC_SYS_LARGEFILE_TEST_INCLUDES)
+ AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
+ ac_cv_sys_large_files,
+ [Define for large files, on AIX-style hosts.],
+ AC_SYS_LARGEFILE_TEST_INCLUDES)
+ fi
+ ])
+
+AC_DEFUN([AC_FUNC_FSEEKO],
+ [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
+ ac_cv_sys_largefile_source,
+ [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
+ [#include <stdio.h>], [return !fseeko;])
+ # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
+ # in glibc 2.1.3, but that breaks too many other things.
+ # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
+
+ AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
+ [ac_cv_func_fseeko=no
+ AC_TRY_LINK([#include <stdio.h>],
+ [return fseeko && fseeko (stdin, 0, 0);],
+ [ac_cv_func_fseeko=yes])])
+ if test $ac_cv_func_fseeko != no; then
+ AC_DEFINE(HAVE_FSEEKO, 1,
+ [Define if fseeko (and presumably ftello) exists and is declared.])
+ fi])
+
diff --git a/contrib/file/aclocal.m4 b/contrib/file/aclocal.m4
index b8a4955..c8873bc 100644
--- a/contrib/file/aclocal.m4
+++ b/contrib/file/aclocal.m4
@@ -11,7 +11,7 @@ dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
dnl cloned from autoconf 2.13 acspecific.m4
-AC_DEFUN(AC_C_LONG_LONG,
+AC_DEFUN([AC_C_LONG_LONG],
[AC_CACHE_CHECK(for long long, ac_cv_c_long_long,
[if test "$GCC" = yes; then
ac_cv_c_long_long=yes
@@ -26,23 +26,16 @@ if test $ac_cv_c_long_long = yes; then
fi
])
-dnl from autoconf 2.13 acgeneral.m4, with patch:
-dnl Date: Fri, 15 Jan 1999 05:52:41 -0800
-dnl Message-ID: <199901151352.FAA18237@shade.twinsun.com>
-dnl From: eggert@twinsun.com (Paul Eggert)
-dnl Subject: autoconf 2.13 AC_CHECK_TYPE doesn't allow shell vars
-dnl Newsgroups: gnu.utils.bug
-
dnl from autoconf 2.13 acspecific.m4, with changes to check for daylight
-AC_DEFUN(AC_STRUCT_TIMEZONE_DAYLIGHT,
+AC_DEFUN([AC_STRUCT_TIMEZONE_DAYLIGHT],
[AC_REQUIRE([AC_STRUCT_TM])dnl
AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone,
[AC_TRY_COMPILE([#include <sys/types.h>
#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;],
ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])
if test "$ac_cv_struct_tm_zone" = yes; then
- AC_DEFINE(HAVE_TM_ZONE)
+ AC_DEFINE(HAVE_TM_ZONE,1,[HAVE_TM_ZONE])
fi
AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
[AC_TRY_LINK(
@@ -54,7 +47,7 @@ extern char *tzname[]; /* RS6000 and others reject char **tzname. */
changequote([, ])dnl
[atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])
if test $ac_cv_var_tzname = yes; then
- AC_DEFINE(HAVE_TZNAME)
+ AC_DEFINE(HAVE_TZNAME,1,[HAVE_TZNAME])
fi
AC_CACHE_CHECK([for tm_isdst in struct tm], ac_cv_struct_tm_isdst,
@@ -78,15 +71,27 @@ changequote([, ])dnl
fi
])
-dnl AC_CHECK_TYPE2(TYPE, DEFAULT)
-AC_DEFUN(AC_CHECK_TYPE2,
+dnl from autoconf 2.13 acgeneral.m4, with patch:
+dnl Date: Fri, 15 Jan 1999 05:52:41 -0800
+dnl Message-ID: <199901151352.FAA18237@shade.twinsun.com>
+dnl From: eggert@twinsun.com (Paul Eggert)
+dnl Subject: autoconf 2.13 AC_CHECK_TYPE doesn't allow shell vars
+dnl Newsgroups: gnu.utils.bug
+dnl
+dnl now include <stdint.h> if available
+
+dnl AC_CHECK_TYPE2_STDC(TYPE, DEFAULT)
+AC_DEFUN([AC_CHECK_TYPE2_STDC],
[AC_REQUIRE([AC_HEADER_STDC])dnl
+AC_REQUIRE([AC_HEADER_STDINT])dnl
AC_MSG_CHECKING(for $1)
AC_CACHE_VAL(ac_cv_type_$1,
[AC_EGREP_CPP(dnl
-changequote(<<,>>)dnl
-<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
-changequote([,]), [#include <sys/types.h>
+[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]],
+[#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
#include <stddef.h>
@@ -100,14 +105,12 @@ fi
])
dnl from autoconf 2.13 acgeneral.m4, with additional third argument
-dnl AC_CHECK_SIZEOF_INCLUDES(TYPE [, CROSS-SIZE, [INCLUDES]])
-AC_DEFUN(AC_CHECK_SIZEOF_INCLUDES,
-[changequote(<<, >>)dnl
-dnl The name to #define.
-define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
+dnl AC_CHECK_SIZEOF_INCLUDES(TYPE [, CROSS-SIZE [, INCLUDES]])
+AC_DEFUN([AC_CHECK_SIZEOF_INCLUDES],
+[dnl The name to #define.
+define([AC_TYPE_NAME], translit(sizeof_$1, [[[a-z *]]], [[[A-Z_P]]]))dnl
dnl The cache variable name.
-define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
-changequote([, ])dnl
+define([AC_CV_NAME], translit(ac_cv_sizeof_$1, [[[ *]]], [[[_p]]]))dnl
AC_MSG_CHECKING(size of $1)
AC_CACHE_VAL(AC_CV_NAME,
[AC_TRY_RUN([$3
@@ -126,15 +129,142 @@ undefine([AC_CV_NAME])dnl
])
dnl AC_CHECK_SIZEOF_STDC_HEADERS(TYPE [, CROSS_SIZE])
-AC_DEFUN(AC_CHECK_SIZEOF_STDC_HEADERS,
-[AC_CHECK_SIZEOF_INCLUDES($1, $2,
-[#include <sys/types.h>
+AC_DEFUN([AC_CHECK_SIZEOF_STDC_HEADERS],
+[AC_REQUIRE([AC_HEADER_STDC])dnl
+AC_REQUIRE([AC_HEADER_STDINT])dnl
+AC_CHECK_SIZEOF_INCLUDES($1, $2,
+[#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#include <sys/types.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif
])
])
+
+dnl AC_CHECK_TYPE_STDC(TYPE, DEFAULT)
+AC_DEFUN([AC_CHECK_TYPE_STDC],
+[AC_REQUIRE([AC_HEADER_STDC])dnl
+AC_REQUIRE([AC_HEADER_STDINT])dnl
+AC_MSG_CHECKING(for $1)
+AC_CACHE_VAL(ac_cv_type_$1,
+[AC_EGREP_CPP(dnl
+[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]],
+[#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
+AC_MSG_RESULT($ac_cv_type_$1)
+if test $ac_cv_type_$1 = no; then
+ AC_DEFINE($1, $2)
+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:
+dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
+
+dnl Written by Paul Eggert <eggert@twinsun.com>.
+
+dnl Internal subroutine of AC_SYS_LARGEFILE.
+dnl AC_SYS_LARGEFILE_TEST_INCLUDES
+AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES],
+ [[#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply "#define LARGE_OFF_T 9223372036854775807",
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+ ]])
+
+dnl Internal subroutine of AC_SYS_LARGEFILE.
+dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLU=
+DES, FUNCTION-BODY)
+AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE],
+ [AC_CACHE_CHECK([for $1 value needed for large files], $3,
+ [$3=no
+ AC_TRY_COMPILE([$5],
+ [$6],
+ ,
+ [AC_TRY_COMPILE([#define $1 $2]
+[$5]
+ ,
+ [$6],
+ [$3=$2])])])
+ if test "[$]$3" != no; then
+ AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
+ fi])
+
+AC_DEFUN([AC_SYS_LARGEFILE],
+ [AC_REQUIRE([AC_PROG_CC])
+ AC_ARG_ENABLE(largefile,
+ [ --disable-largefile omit support for large files])
+ if test "$enable_largefile" != no; then
+
+ AC_CACHE_CHECK([for special C compiler options needed for large files=
+],
+ ac_cv_sys_largefile_CC,
+ [ac_cv_sys_largefile_CC=no
+ if test "$GCC" != yes; then
+ # IRIX 6.2 and later do not support large files by default,
+ # so use the C compiler's -n32 option if that helps.
+ AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
+ [ac_save_CC="$CC"
+ CC="$CC -n32"
+ AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
+ ac_cv_sys_largefile_CC=' -n32')
+ CC="$ac_save_CC"])
+ fi])
+ if test "$ac_cv_sys_largefile_CC" != no; then
+ CC="$CC$ac_cv_sys_largefile_CC"
+ fi
+
+ AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
+ ac_cv_sys_file_offset_bits,
+ [Number of bits in a file offset, on hosts where this is settable.],
+ AC_SYS_LARGEFILE_TEST_INCLUDES)
+ AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
+ ac_cv_sys_large_files,
+ [Define for large files, on AIX-style hosts.],
+ AC_SYS_LARGEFILE_TEST_INCLUDES)
+ fi
+ ])
+
+AC_DEFUN([AC_FUNC_FSEEKO],
+ [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
+ ac_cv_sys_largefile_source,
+ [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
+ [#include <stdio.h>], [return !fseeko;])
+ # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
+ # in glibc 2.1.3, but that breaks too many other things.
+ # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
+
+ AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
+ [ac_cv_func_fseeko=no
+ AC_TRY_LINK([#include <stdio.h>],
+ [return fseeko && fseeko (stdin, 0, 0);],
+ [ac_cv_func_fseeko=yes])])
+ if test $ac_cv_func_fseeko != no; then
+ AC_DEFINE(HAVE_FSEEKO, 1,
+ [Define if fseeko (and presumably ftello) exists and is declared.])
+ fi])
+
+
# Do all the work for Automake. This macro actually does too much --
# some checks are only needed if your package does certain things.
# But this isn't really a big deal.
diff --git a/contrib/file/apprentice.c b/contrib/file/apprentice.c
index 5c78c5a..522945d 100644
--- a/contrib/file/apprentice.c
+++ b/contrib/file/apprentice.c
@@ -26,23 +26,19 @@
*/
#include "file.h"
-#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include <ctype.h>
-#include <errno.h>
-#ifdef QUICK
#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+#ifdef QUICK
#include <sys/mman.h>
#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.44 2001/08/01 14:03:19 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.49 2002/07/03 19:00:41 christos Exp $")
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
@@ -74,23 +70,20 @@ FILE_RCSID("@(#)$Id: apprentice.c,v 1.44 2001/08/01 14:03:19 christos Exp $")
#endif
-static int getvalue __P((struct magic *, char **));
-static int hextoint __P((int));
-static char *getstr __P((char *, char *, int, int *));
-static int parse __P((struct magic **, uint32 *, char *, int));
-static void eatsize __P((char **));
-static int apprentice_1 __P((const char *, int));
-static int apprentice_file __P((struct magic **, uint32 *,
- const char *, int));
-static void byteswap __P((struct magic *, uint32));
-static void bs1 __P((struct magic *));
-static uint16 swap2 __P((uint16));
-static uint32 swap4 __P((uint32));
-static char *mkdbname __P((const char *));
-static int apprentice_map __P((struct magic **, uint32 *,
- const char *, int));
-static int apprentice_compile __P((struct magic **, uint32 *,
- const char *, int));
+static int getvalue(struct magic *, char **);
+static int hextoint(int);
+static char *getstr(char *, char *, int, int *);
+static int parse(struct magic **, uint32_t *, char *, int);
+static void eatsize(char **);
+static int apprentice_1(const char *, int);
+static int apprentice_file(struct magic **, uint32_t *, const char *, int);
+static void byteswap(struct magic *, uint32_t);
+static void bs1(struct magic *);
+static uint16_t swap2(uint16_t);
+static uint32_t swap4(uint32_t);
+static char *mkdbname(const char *);
+static int apprentice_map(struct magic **, uint32_t *, const char *, int);
+static int apprentice_compile(struct magic **, uint32_t *, const char *, int);
static int maxmagic = 0;
@@ -101,12 +94,10 @@ const char *magicfile;
char *progname;
int lineno;
-int main __P((int, char *[]));
+int main(int, char *[]);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
int ret;
@@ -130,12 +121,10 @@ main(argc, argv)
* Handle one file.
*/
static int
-apprentice_1(fn, action)
- const char *fn;
- int action;
+apprentice_1(const char *fn, int action)
{
struct magic *magic = NULL;
- uint32 nmagic = 0;
+ uint32_t nmagic = 0;
struct mlist *ml;
int rv = -1;
@@ -180,10 +169,9 @@ apprentice_1(fn, action)
}
+/* const char *fn: list of magic files */
int
-apprentice(fn, action)
- const char *fn; /* list of magic files */
- int action;
+apprentice(const char *fn, int action)
{
char *p, *mfn;
int file_err, errs = -1;
@@ -221,13 +209,11 @@ apprentice(fn, action)
/*
* parse from a file
+ * const char *fn: name of magic file
*/
static int
-apprentice_file(magicp, nmagicp, fn, action)
- struct magic **magicp;
- uint32 *nmagicp;
- const char *fn; /* name of magic file */
- int action;
+apprentice_file(struct magic **magicp, uint32_t *nmagicp, const char *fn,
+ int action)
{
static const char hdr[] =
"cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
@@ -279,10 +265,8 @@ apprentice_file(magicp, nmagicp, fn, action)
/*
* extend the sign bit if the comparison is to be signed
*/
-uint32
-signextend(m, v)
- struct magic *m;
- uint32 v;
+uint32_t
+signextend(struct magic *m, uint32_t v)
{
if (!(m->flag & UNSIGNED))
switch(m->type) {
@@ -308,11 +292,13 @@ signextend(m, v)
case LONG:
case BELONG:
case LELONG:
- v = (int32) v;
+ v = (int32_t) v;
break;
case STRING:
case PSTRING:
break;
+ case REGEX:
+ break;
default:
magwarn("can't happen: m->type=%d\n",
m->type);
@@ -325,11 +311,7 @@ signextend(m, v)
* parse one line from magic file, put into magic[index++] if valid
*/
static int
-parse(magicp, nmagicp, l, action)
- struct magic **magicp;
- uint32 *nmagicp;
- char *l;
- int action;
+parse(struct magic **magicp, uint32_t *nmagicp, char *l, int action)
{
int i = 0;
struct magic *m;
@@ -479,6 +461,7 @@ parse(magicp, nmagicp, l, action)
#define NLDATE 5
#define NBELDATE 7
#define NLELDATE 7
+#define NREGEX 5
if (*l == 'u') {
++l;
@@ -534,6 +517,9 @@ parse(magicp, nmagicp, l, action)
} else if (strncmp(l, "leldate", NLELDATE)==0) {
m->type = LELDATE;
l += NLELDATE;
+ } else if (strncmp(l, "regex", NREGEX)==0) {
+ m->type = REGEX;
+ l += sizeof("regex");
} else {
magwarn("type %s invalid", l);
return -1;
@@ -679,9 +665,11 @@ GetDesc:
while ((m->desc[i++] = *l++) != '\0' && i<MAXDESC)
/* NULLBODY */;
+#ifndef COMPILE_ONLY
if (action == CHECK) {
mdump(m);
}
+#endif
++(*nmagicp); /* make room for next */
return 0;
}
@@ -692,13 +680,11 @@ GetDesc:
* just after the number read. Return 0 for success, non-zero for failure.
*/
static int
-getvalue(m, p)
- struct magic *m;
- char **p;
+getvalue(struct magic *m, char **p)
{
int slen;
- if (m->type == STRING || m->type == PSTRING) {
+ if (m->type == STRING || m->type == PSTRING || m->type == REGEX) {
*p = getstr(*p, m->value.s, sizeof(m->value.s), &slen);
m->vallen = slen;
} else
@@ -716,10 +702,7 @@ getvalue(m, p)
* Return updated scan pointer as function result.
*/
static char *
-getstr(s, p, plen, slen)
- char *s;
- char *p;
- int plen, *slen;
+getstr(char *s, char *p, int plen, int *slen)
{
char *origs = s, *origp = p;
char *pmax = p + plen - 1;
@@ -819,8 +802,7 @@ out:
/* Single hex char to int; -1 if not a hex char. */
static int
-hextoint(c)
- int c;
+hextoint(int c)
{
if (!isascii((unsigned char) c))
return -1;
@@ -838,10 +820,7 @@ hextoint(c)
* Print a string containing C character escapes.
*/
void
-showstr(fp, s, len)
- FILE *fp;
- const char *s;
- int len;
+showstr(FILE *fp, const char *s, int len)
{
char c;
@@ -897,8 +876,7 @@ showstr(fp, s, len)
* eatsize(): Eat the size spec from a number [eg. 10UL]
*/
static void
-eatsize(p)
- char **p;
+eatsize(char **p)
{
char *l = *p;
@@ -921,21 +899,19 @@ eatsize(p)
}
/*
- * handle an mmaped file.
+ * handle a compiled file.
*/
static int
-apprentice_map(magicp, nmagicp, fn, action)
- struct magic **magicp;
- uint32 *nmagicp;
- const char *fn;
- int action;
+apprentice_map(struct magic **magicp, uint32_t *nmagicp, const char *fn,
+ int action)
{
int fd;
struct stat st;
- uint32 *ptr;
- uint32 version;
+ uint32_t *ptr;
+ uint32_t version;
int needsbyteswap;
char *dbname = mkdbname(fn);
+ void *mm;
if (dbname == NULL)
return -1;
@@ -950,27 +926,28 @@ apprentice_map(magicp, nmagicp, fn, action)
}
#ifdef QUICK
- if ((*magicp = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
+ if ((mm = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FILE, fd, (off_t)0)) == MAP_FAILED) {
(void)fprintf(stderr, "%s: Cannot map `%s' (%s)\n",
progname, dbname, strerror(errno));
goto error;
}
#else
- if ((*magicp = malloc((size_t)st.st_size)) == NULL) {
+ if ((mm = malloc((size_t)st.st_size)) == NULL) {
(void) fprintf(stderr, "%s: Out of memory (%s).\n", progname,
strerror(errno));
goto error;
}
- if (read(fd, *magicp, (size_t)st.st_size) != (size_t)st.st_size) {
+ if (read(fd, mm, (size_t)st.st_size) != (size_t)st.st_size) {
(void) fprintf(stderr, "%s: Read failed (%s).\n", progname,
strerror(errno));
goto error;
}
#endif
+ *magicp = mm;
(void)close(fd);
fd = -1;
- ptr = (uint32 *) *magicp;
+ ptr = (uint32_t *) *magicp;
if (*ptr != MAGICNO) {
if (swap4(*ptr) != MAGICNO) {
(void)fprintf(stderr, "%s: Bad magic in `%s'\n",
@@ -999,11 +976,11 @@ apprentice_map(magicp, nmagicp, fn, action)
error:
if (fd != -1)
(void)close(fd);
- if (*magicp) {
+ if (mm) {
#ifdef QUICK
- (void)munmap(*magicp, (size_t)st.st_size);
+ (void)munmap(mm, (size_t)st.st_size);
#else
- free(*magicp);
+ free(mm);
#endif
} else {
*magicp = NULL;
@@ -1016,15 +993,12 @@ error:
* handle an mmaped file.
*/
static int
-apprentice_compile(magicp, nmagicp, fn, action)
- struct magic **magicp;
- uint32 *nmagicp;
- const char *fn;
- int action;
+apprentice_compile(struct magic **magicp, uint32_t *nmagicp, const char *fn,
+ int action)
{
int fd;
char *dbname = mkdbname(fn);
- static const uint32 ar[] = {
+ static const uint32_t ar[] = {
MAGICNO, VERSIONNO
};
@@ -1064,8 +1038,7 @@ apprentice_compile(magicp, nmagicp, fn, action)
* make a dbname
*/
char *
-mkdbname(fn)
- const char *fn;
+mkdbname(const char *fn)
{
static const char ext[] = ".mgc";
static char *buf = NULL;
@@ -1088,11 +1061,9 @@ mkdbname(fn)
* Byteswap an mmap'ed file if needed
*/
static void
-byteswap(magic, nmagic)
- struct magic *magic;
- uint32 nmagic;
+byteswap(struct magic *magic, uint32_t nmagic)
{
- uint32 i;
+ uint32_t i;
for (i = 0; i < nmagic; i++)
bs1(&magic[i]);
}
@@ -1100,13 +1071,12 @@ byteswap(magic, nmagic)
/*
* swap a short
*/
-static uint16
-swap2(sv)
- uint16 sv;
+static uint16_t
+swap2(uint16_t sv)
{
- uint16 rv;
- uint8 *s = (uint8 *) &sv;
- uint8 *d = (uint8 *) &rv;
+ uint16_t rv;
+ uint8_t *s = (uint8_t *) &sv;
+ uint8_t *d = (uint8_t *) &rv;
d[0] = s[1];
d[1] = s[0];
return rv;
@@ -1115,13 +1085,12 @@ swap2(sv)
/*
* swap an int
*/
-static uint32
-swap4(sv)
- uint32 sv;
+static uint32_t
+swap4(uint32_t sv)
{
- uint32 rv;
- uint8 *s = (uint8 *) &sv;
- uint8 *d = (uint8 *) &rv;
+ uint32_t rv;
+ uint8_t *s = (uint8_t *) &sv;
+ uint8_t *d = (uint8_t *) &rv;
d[0] = s[3];
d[1] = s[2];
d[2] = s[1];
@@ -1133,8 +1102,7 @@ swap4(sv)
* byteswap a single magic entry
*/
static
-void bs1(m)
- struct magic *m;
+void bs1(struct magic *m)
{
m->cont_level = swap2(m->cont_level);
m->offset = swap4(m->offset);
diff --git a/contrib/file/ascmagic.c b/contrib/file/ascmagic.c
index c2a2f95..cbbcbe8 100644
--- a/contrib/file/ascmagic.c
+++ b/contrib/file/ascmagic.c
@@ -35,7 +35,6 @@
*/
#include "file.h"
-#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <ctype.h>
@@ -46,7 +45,7 @@
#include "names.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: ascmagic.c,v 1.30 2001/07/26 13:15:49 christos Exp $")
+FILE_RCSID("@(#)$Id: ascmagic.c,v 1.32 2002/07/03 18:26:37 christos Exp $")
#endif /* lint */
typedef unsigned long unichar;
@@ -55,18 +54,17 @@ typedef unsigned long unichar;
#define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \
|| (x) == 0x85 || (x) == '\f')
-static int looks_ascii __P((const unsigned char *, int, unichar *, int *));
-static int looks_utf8 __P((const unsigned char *, int, unichar *, int *));
-static int looks_unicode __P((const unsigned char *, int, unichar *, int *));
-static int looks_latin1 __P((const unsigned char *, int, unichar *, int *));
-static int looks_extended __P((const unsigned char *, int, unichar *, int *));
-static void from_ebcdic __P((const unsigned char *, int, unsigned char *));
-static int ascmatch __P((const unsigned char *, const unichar *, int));
+static int looks_ascii(const unsigned char *, int, unichar *, int *);
+static int looks_utf8(const unsigned char *, int, unichar *, int *);
+static int looks_unicode(const unsigned char *, int, unichar *, int *);
+static int looks_latin1(const unsigned char *, int, unichar *, int *);
+static int looks_extended(const unsigned char *, int, unichar *, int *);
+static void from_ebcdic(const unsigned char *, int, unsigned char *);
+static int ascmatch(const unsigned char *, const unichar *, int);
+/* int nbytes: size actually read */
int
-ascmagic(buf, nbytes)
- unsigned char *buf;
- int nbytes; /* size actually read */
+ascmagic(unsigned char *buf, int nbytes)
{
int i;
char nbuf[HOWMANY+1]; /* one extra for terminating '\0' */
@@ -322,10 +320,7 @@ subtype_identified:
}
static int
-ascmatch(s, us, ulen)
- const unsigned char *s;
- const unichar *us;
- int ulen;
+ascmatch(const unsigned char *s, const unichar *us, int ulen)
{
size_t i;
@@ -420,11 +415,7 @@ static char text_chars[256] = {
};
static int
-looks_ascii(buf, nbytes, ubuf, ulen)
- const unsigned char *buf;
- int nbytes;
- unichar *ubuf;
- int *ulen;
+looks_ascii(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
{
int i;
@@ -443,11 +434,7 @@ looks_ascii(buf, nbytes, ubuf, ulen)
}
static int
-looks_latin1(buf, nbytes, ubuf, ulen)
- const unsigned char *buf;
- int nbytes;
- unichar *ubuf;
- int *ulen;
+looks_latin1(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
{
int i;
@@ -466,11 +453,7 @@ looks_latin1(buf, nbytes, ubuf, ulen)
}
static int
-looks_extended(buf, nbytes, ubuf, ulen)
- const unsigned char *buf;
- int nbytes;
- unichar *ubuf;
- int *ulen;
+looks_extended(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
{
int i;
@@ -489,11 +472,7 @@ looks_extended(buf, nbytes, ubuf, ulen)
}
int
-looks_utf8(buf, nbytes, ubuf, ulen)
- const unsigned char *buf;
- int nbytes;
- unichar *ubuf;
- int *ulen;
+looks_utf8(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
{
int i, n;
unichar c;
@@ -555,11 +534,7 @@ done:
}
static int
-looks_unicode(buf, nbytes, ubuf, ulen)
- const unsigned char *buf;
- int nbytes;
- unichar *ubuf;
- int *ulen;
+looks_unicode(const unsigned char *buf, int nbytes, unichar *ubuf, int *ulen)
{
int bigend;
int i;
@@ -676,10 +651,7 @@ unsigned char ebcdic_1047_to_8859[] = {
* Copy buf[0 ... nbytes-1] into out[], translating EBCDIC to ASCII.
*/
static void
-from_ebcdic(buf, nbytes, out)
- const unsigned char *buf;
- int nbytes;
- unsigned char *out;
+from_ebcdic(const unsigned char *buf, int nbytes, unsigned char *out)
{
int i;
diff --git a/contrib/file/compress.c b/contrib/file/compress.c
index 80d24e0..4e1219c 100644
--- a/contrib/file/compress.c
+++ b/contrib/file/compress.c
@@ -6,7 +6,6 @@
* using method, return sizeof new
*/
#include "file.h"
-#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -15,8 +14,12 @@
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
+#ifdef HAVE_LIBZ
+#include <zlib.h>
+#endif
+
#ifndef lint
-FILE_RCSID("@(#)$Id: compress.c,v 1.20 2001/07/22 21:04:15 christos Exp $")
+FILE_RCSID("@(#)$Id: compress.c,v 1.25 2002/07/03 18:26:37 christos Exp $")
#endif
@@ -41,14 +44,15 @@ static struct {
static int ncompr = sizeof(compr) / sizeof(compr[0]);
-static int uncompress __P((int, const unsigned char *, unsigned char **, int));
-static int swrite __P((int, const void *, size_t));
-static int sread __P((int, void *, size_t));
+static int swrite(int, const void *, size_t);
+static int sread(int, void *, size_t);
+static int uncompressbuf(int, const unsigned char *, unsigned char **, int);
+#ifdef HAVE_LIBZ
+static int uncompressgzipped(const unsigned char *, unsigned char **, int);
+#endif
int
-zmagic(buf, nbytes)
- unsigned char *buf;
- int nbytes;
+zmagic(const char *fname, unsigned char *buf, int nbytes)
{
unsigned char *newbuf;
int newsize;
@@ -58,11 +62,11 @@ zmagic(buf, nbytes)
if (nbytes < compr[i].maglen)
continue;
if (memcmp(buf, compr[i].magic, compr[i].maglen) == 0 &&
- (newsize = uncompress(i, buf, &newbuf, nbytes)) != 0) {
- tryit(newbuf, newsize, 1);
+ (newsize = uncompressbuf(i, buf, &newbuf, nbytes)) != 0) {
+ tryit(fname, newbuf, newsize, 1);
free(newbuf);
printf(" (");
- tryit(buf, nbytes, 0);
+ tryit(fname, buf, nbytes, 0);
printf(")");
return 1;
}
@@ -78,10 +82,7 @@ zmagic(buf, nbytes)
* `safe' write for sockets and pipes.
*/
static int
-swrite(fd, buf, n)
- int fd;
- const void *buf;
- size_t n;
+swrite(int fd, const void *buf, size_t n)
{
int rv;
size_t rn = n;
@@ -94,7 +95,7 @@ swrite(fd, buf, n)
return -1;
default:
n -= rv;
- buf = ((char *)buf) + rv;
+ buf = ((const char *)buf) + rv;
break;
}
while (n > 0);
@@ -106,10 +107,7 @@ swrite(fd, buf, n)
* `safe' read for sockets and pipes.
*/
static int
-sread(fd, buf, n)
- int fd;
- void *buf;
- size_t n;
+sread(int fd, void *buf, size_t n)
{
int rv;
size_t rn = n;
@@ -120,6 +118,8 @@ sread(fd, buf, n)
if (errno == EINTR)
continue;
return -1;
+ case 0:
+ return rn - n;
default:
n -= rv;
buf = ((char *)buf) + rv;
@@ -129,15 +129,150 @@ sread(fd, buf, n)
return rn;
}
+int
+pipe2file(int fd, void *startbuf, size_t nbytes)
+{
+ char buf[4096];
+ int r, tfd;
+
+ (void)strcpy(buf, "/tmp/file.XXXXXX");
+#ifndef HAVE_MKSTEMP
+ {
+ char *ptr = mktemp(buf);
+ tfd = open(ptr, O_RDWR|O_TRUNC|O_EXCL|O_CREAT, 0600);
+ r = errno;
+ (void)unlink(ptr);
+ errno = r;
+ }
+#else
+ tfd = mkstemp(buf);
+ r = errno;
+ (void)unlink(buf);
+ errno = r;
+#endif
+ if (tfd == -1) {
+ error("Can't create temporary file for pipe copy (%s)\n",
+ strerror(errno));
+ /*NOTREACHED*/
+ }
+
+ if (swrite(tfd, startbuf, nbytes) != nbytes)
+ r = 1;
+ else {
+ while ((r = sread(fd, buf, sizeof(buf))) > 0)
+ if (swrite(tfd, buf, r) != r)
+ break;
+ }
+
+ switch (r) {
+ case -1:
+ error("Error copying from pipe to temp file (%s)\n",
+ strerror(errno));
+ /*NOTREACHED*/
+ case 0:
+ break;
+ default:
+ error("Error while writing to temp file (%s)\n",
+ strerror(errno));
+ /*NOTREACHED*/
+ }
+
+ /*
+ * We duplicate the file descriptor, because fclose on a
+ * tmpfile will delete the file, but any open descriptors
+ * can still access the phantom inode.
+ */
+ if ((fd = dup2(tfd, fd)) == -1) {
+ error("Couldn't dup destcriptor for temp file(%s)\n",
+ strerror(errno));
+ /*NOTREACHED*/
+ }
+ (void)close(tfd);
+ if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) {
+ error("Couldn't seek on temp file (%s)\n", strerror(errno));
+ /*NOTREACHED*/
+ }
+ return fd;
+}
+
+#ifdef HAVE_LIBZ
+
+#define FHCRC (1 << 1)
+#define FEXTRA (1 << 2)
+#define FNAME (1 << 3)
+#define FCOMMENT (1 << 4)
+
+static int
+uncompressgzipped(const unsigned char *old, unsigned char **newch, int n)
+{
+ unsigned char flg = old[3];
+ int data_start = 10;
+ z_stream z;
+ int rc;
+
+ if (flg & FEXTRA)
+ data_start += 2 + old[data_start] + old[data_start + 1] * 256;
+ if (flg & FNAME) {
+ while(old[data_start])
+ data_start++;
+ data_start++;
+ }
+ if(flg & FCOMMENT) {
+ while(old[data_start])
+ data_start++;
+ data_start++;
+ }
+ if(flg & FHCRC)
+ data_start += 2;
+
+ if ((*newch = (unsigned char *)malloc(HOWMANY + 1)) == NULL) {
+ return 0;
+ }
+
+ z.next_in = (Bytef *)(old + data_start);
+ z.avail_in = n - data_start;
+ z.next_out = *newch;
+ z.avail_out = HOWMANY;
+ z.zalloc = Z_NULL;
+ z.zfree = Z_NULL;
+ z.opaque = Z_NULL;
+
+ rc = inflateInit2(&z, -15);
+ if (rc != Z_OK) {
+ (void) fprintf(stderr,"%s: zlib: %s\n", progname, z.msg);
+ return 0;
+ }
+
+ rc = inflate(&z, Z_SYNC_FLUSH);
+ if (rc != Z_OK && rc != Z_STREAM_END) {
+ fprintf(stderr,"%s: zlib: %s\n", progname, z.msg);
+ return 0;
+ }
+
+ n = z.total_out;
+ inflateEnd(&z);
+
+ /* let's keep the nul-terminate tradition */
+ (*newch)[n++] = '\0';
+
+ return n;
+}
+#endif
+
static int
-uncompress(method, old, newch, n)
- int method;
- const unsigned char *old;
- unsigned char **newch;
- int n;
+uncompressbuf(int method, const unsigned char *old, unsigned char **newch,
+ int n)
{
int fdin[2], fdout[2];
+ /* The buffer is NUL terminated, and we don't need that. */
+ n--;
+
+#ifdef HAVE_LIBZ
+ if (method == 2)
+ return uncompressgzipped(old,newch,n);
+#endif
+
if (pipe(fdin) == -1 || pipe(fdout) == -1) {
error("cannot create pipe (%s).\n", strerror(errno));
/*NOTREACHED*/
@@ -173,15 +308,17 @@ uncompress(method, old, newch, n)
}
(void) close(fdin[1]);
fdin[1] = -1;
- if ((*newch = (unsigned char *) malloc(n)) == NULL) {
+ if ((*newch = (unsigned char *) malloc(HOWMANY + 1)) == NULL) {
n = 0;
goto err;
}
- if ((n = sread(fdout[0], *newch, n)) <= 0) {
+ if ((n = sread(fdout[0], *newch, HOWMANY)) <= 0) {
free(*newch);
n = 0;
goto err;
}
+ /* NUL terminate, as every buffer is handled here. */
+ (*newch)[n++] = '\0';
err:
if (fdin[1] != -1)
(void) close(fdin[1]);
diff --git a/contrib/file/config.h.in b/contrib/file/config.h.in
index a1b6f37..aa05824 100644
--- a/contrib/file/config.h.in
+++ b/contrib/file/config.h.in
@@ -9,13 +9,6 @@
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
-/* Define if your struct tm has tm_zone. */
-#undef HAVE_TM_ZONE
-
-/* Define if you don't have tm_zone but do have the external array
- tzname. */
-#undef HAVE_TZNAME
-
/* Define if major, minor, and makedev are declared in <mkdev.h>. */
#undef MAJOR_IN_MKDEV
@@ -74,6 +67,9 @@
/* The number of bytes in a uint64_t. */
#define SIZEOF_UINT64_T 0
+/* Define if you have the mkstemp function. */
+#undef HAVE_MKSTEMP
+
/* Define if you have the mmap function. */
#undef HAVE_MMAP
@@ -83,18 +79,48 @@
/* Define if you have the strtoul function. */
#undef HAVE_STRTOUL
+/* Define if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
/* Define if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
+/* Define if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
/* Define if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
+/* Define if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* Define if you have the z library (-lz). */
+#undef HAVE_LIBZ
+
/* Name of package */
#undef PACKAGE
/* Version number of package */
#undef VERSION
+/* HAVE_TM_ZONE */
+#undef HAVE_TM_ZONE
+
+/* HAVE_TZNAME */
+#undef HAVE_TZNAME
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
diff --git a/contrib/file/configure b/contrib/file/configure
index bfa48ba..a258ab3 100755
--- a/contrib/file/configure
+++ b/contrib/file/configure
@@ -17,6 +17,8 @@ ac_help="$ac_help
--disable-elf-core disable ELF core file support"
ac_help="$ac_help
--enable-fsect-man5 enable file formats in man section 5"
+ac_help="$ac_help
+ --disable-largefile omit support for large files"
# Initialize some variables set by options.
# The variables have the same names as the options, with
@@ -558,7 +560,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:562: checking for a BSD compatible install" >&5
+echo "configure:564: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -611,7 +613,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
-echo "configure:615: checking whether build environment is sane" >&5
+echo "configure:617: checking whether build environment is sane" >&5
# Just in case
sleep 1
echo timestamp > conftestfile
@@ -668,7 +670,7 @@ test "$program_suffix" != NONE &&
test "$program_transform_name" = "" && program_transform_name="s,x,x,"
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:672: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:674: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -697,7 +699,7 @@ fi
PACKAGE=file
-VERSION=3.37
+VERSION=3.39
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
@@ -714,7 +716,7 @@ EOF
missing_dir=`cd $ac_aux_dir && pwd`
echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
-echo "configure:718: checking for working aclocal" >&5
+echo "configure:720: checking for working aclocal" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
@@ -727,7 +729,7 @@ else
fi
echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
-echo "configure:731: checking for working autoconf" >&5
+echo "configure:733: checking for working autoconf" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
@@ -740,7 +742,7 @@ else
fi
echo $ac_n "checking for working automake""... $ac_c" 1>&6
-echo "configure:744: checking for working automake" >&5
+echo "configure:746: checking for working automake" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
@@ -753,7 +755,7 @@ else
fi
echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
-echo "configure:757: checking for working autoheader" >&5
+echo "configure:759: checking for working autoheader" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
@@ -766,7 +768,7 @@ else
fi
echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
-echo "configure:770: checking for working makeinfo" >&5
+echo "configure:772: checking for working makeinfo" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
@@ -784,7 +786,7 @@ fi
echo $ac_n "checking for builtin ELF support""... $ac_c" 1>&6
-echo "configure:788: checking for builtin ELF support" >&5
+echo "configure:790: checking for builtin ELF support" >&5
# Check whether --enable-elf or --disable-elf was given.
if test "${enable_elf+set}" = set; then
enableval="$enable_elf"
@@ -810,7 +812,7 @@ fi
echo $ac_n "checking for ELF core file support""... $ac_c" 1>&6
-echo "configure:814: checking for ELF core file support" >&5
+echo "configure:816: checking for ELF core file support" >&5
# Check whether --enable-elf-core or --disable-elf-core was given.
if test "${enable_elf_core+set}" = set; then
enableval="$enable_elf_core"
@@ -836,7 +838,7 @@ fi
echo $ac_n "checking for file formats in man section 5""... $ac_c" 1>&6
-echo "configure:840: checking for file formats in man section 5" >&5
+echo "configure:842: checking for file formats in man section 5" >&5
# Check whether --enable-fsect-man5 or --disable-fsect-man5 was given.
if test "${enable_fsect_man5+set}" = set; then
enableval="$enable_fsect_man5"
@@ -869,7 +871,7 @@ fi
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:873: checking for $ac_word" >&5
+echo "configure:875: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -899,7 +901,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:903: checking for $ac_word" >&5
+echo "configure:905: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -950,7 +952,7 @@ fi
# Extract the first word of "cl", so it can be a program name with args.
set dummy cl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:954: checking for $ac_word" >&5
+echo "configure:956: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -982,7 +984,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:986: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:988: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -993,12 +995,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
-#line 997 "configure"
+#line 999 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:1002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1004: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -1024,12 +1026,12 @@ if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1028: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1030: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1033: checking whether we are using GNU C" >&5
+echo "configure:1035: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1038,7 +1040,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1042: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1044: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -1057,7 +1059,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1061: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1063: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1100,7 +1102,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1104: checking for a BSD compatible install" >&5
+echo "configure:1106: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1153,7 +1155,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:1157: checking whether ln -s works" >&5
+echo "configure:1159: checking whether ln -s works" >&5
if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1175,7 +1177,7 @@ fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1179: checking how to run the C preprocessor" >&5
+echo "configure:1181: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1190,13 +1192,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1194 "configure"
+#line 1196 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1200: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1202: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1207,13 +1209,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1211 "configure"
+#line 1213 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1217: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1219: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1224,13 +1226,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1228 "configure"
+#line 1230 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1234: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1236: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1255,12 +1257,12 @@ fi
echo "$ac_t""$CPP" 1>&6
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1259: checking for ANSI C header files" >&5
+echo "configure:1261: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1264 "configure"
+#line 1266 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -1268,7 +1270,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1272: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1274: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1285,7 +1287,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1289 "configure"
+#line 1291 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -1303,7 +1305,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 1307 "configure"
+#line 1309 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -1324,7 +1326,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
-#line 1328 "configure"
+#line 1330 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1335,7 +1337,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
-if { (eval echo configure:1339: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1341: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@@ -1359,19 +1361,19 @@ EOF
fi
echo $ac_n "checking whether sys/types.h defines makedev""... $ac_c" 1>&6
-echo "configure:1363: checking whether sys/types.h defines makedev" >&5
+echo "configure:1365: checking whether sys/types.h defines makedev" >&5
if eval "test \"`echo '$''{'ac_cv_header_sys_types_h_makedev'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1368 "configure"
+#line 1370 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
return makedev(0, 0);
; return 0; }
EOF
-if { (eval echo configure:1375: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_header_sys_types_h_makedev=yes
else
@@ -1389,17 +1391,17 @@ echo "$ac_t""$ac_cv_header_sys_types_h_makedev" 1>&6
if test $ac_cv_header_sys_types_h_makedev = no; then
ac_safe=`echo "sys/mkdev.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for sys/mkdev.h""... $ac_c" 1>&6
-echo "configure:1393: checking for sys/mkdev.h" >&5
+echo "configure:1395: checking for sys/mkdev.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1398 "configure"
+#line 1400 "configure"
#include "confdefs.h"
#include <sys/mkdev.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1403: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1405: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1427,17 +1429,17 @@ fi
if test $ac_cv_header_sys_mkdev_h = no; then
ac_safe=`echo "sys/sysmacros.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for sys/sysmacros.h""... $ac_c" 1>&6
-echo "configure:1431: checking for sys/sysmacros.h" >&5
+echo "configure:1433: checking for sys/sysmacros.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1436 "configure"
+#line 1438 "configure"
#include "confdefs.h"
#include <sys/sysmacros.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1441: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1443: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1465,12 +1467,12 @@ fi
fi
echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:1469: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:1471: checking for sys/wait.h that is POSIX.1 compatible" >&5
if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1474 "configure"
+#line 1476 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/wait.h>
@@ -1486,7 +1488,7 @@ wait (&s);
s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
; return 0; }
EOF
-if { (eval echo configure:1490: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1492: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_sys_wait_h=yes
else
@@ -1506,21 +1508,181 @@ EOF
fi
+for ac_hdr in stdint.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1516: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1521 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1526: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_hdr in fcntl.h locale.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1556: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1561 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1566: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_hdr in sys/mman.h sys/stat.h sys/types.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1596: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1601 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1606: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
for ac_hdr in unistd.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1514: checking for $ac_hdr" >&5
+echo "configure:1636: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1519 "configure"
+#line 1641 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1524: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1646: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_hdr in getopt.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1676: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1681 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1686: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1550,17 +1712,17 @@ for ac_hdr in locale.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1554: checking for $ac_hdr" >&5
+echo "configure:1716: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1559 "configure"
+#line 1721 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1564: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1726: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1586,21 +1748,21 @@ else
fi
done
-for ac_hdr in sys/mman.h
+for ac_hdr in stdint.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1594: checking for $ac_hdr" >&5
+echo "configure:1756: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1599 "configure"
+#line 1761 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1604: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1766: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1628,12 +1790,12 @@ done
echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1632: checking for working const" >&5
+echo "configure:1794: checking for working const" >&5
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1637 "configure"
+#line 1799 "configure"
#include "confdefs.h"
int main() {
@@ -1682,7 +1844,7 @@ ccp = (char const *const *) p;
; return 0; }
EOF
-if { (eval echo configure:1686: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1848: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
@@ -1703,12 +1865,12 @@ EOF
fi
echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:1707: checking for off_t" >&5
+echo "configure:1869: checking for off_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1712 "configure"
+#line 1874 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -1736,12 +1898,12 @@ EOF
fi
echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:1740: checking for size_t" >&5
+echo "configure:1902: checking for size_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1745 "configure"
+#line 1907 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -1769,12 +1931,12 @@ EOF
fi
echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6
-echo "configure:1773: checking for st_rdev in struct stat" >&5
+echo "configure:1935: checking for st_rdev in struct stat" >&5
if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1778 "configure"
+#line 1940 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -1782,7 +1944,7 @@ int main() {
struct stat s; s.st_rdev;
; return 0; }
EOF
-if { (eval echo configure:1786: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1948: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_st_rdev=yes
else
@@ -1803,12 +1965,12 @@ EOF
fi
echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:1807: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:1969: checking whether struct tm is in sys/time.h or time.h" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1812 "configure"
+#line 1974 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <time.h>
@@ -1816,7 +1978,7 @@ int main() {
struct tm *tp; tp->tm_sec;
; return 0; }
EOF
-if { (eval echo configure:1820: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1982: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm=time.h
else
@@ -1837,12 +1999,12 @@ EOF
fi
echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:1841: checking for tm_zone in struct tm" >&5
+echo "configure:2003: checking for tm_zone in struct tm" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1846 "configure"
+#line 2008 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_cv_struct_tm>
@@ -1850,7 +2012,7 @@ int main() {
struct tm tm; tm.tm_zone;
; return 0; }
EOF
-if { (eval echo configure:1854: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2016: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm_zone=yes
else
@@ -1870,12 +2032,12 @@ EOF
fi
echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:1874: checking for tzname" >&5
+echo "configure:2036: checking for tzname" >&5
if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1879 "configure"
+#line 2041 "configure"
#include "confdefs.h"
#include <time.h>
#ifndef tzname /* For SGI. */
@@ -1885,7 +2047,7 @@ int main() {
atoi(*tzname);
; return 0; }
EOF
-if { (eval echo configure:1889: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2051: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var_tzname=yes
else
@@ -1906,12 +2068,12 @@ EOF
fi
echo $ac_n "checking for tm_isdst in struct tm""... $ac_c" 1>&6
-echo "configure:1910: checking for tm_isdst in struct tm" >&5
+echo "configure:2072: checking for tm_isdst in struct tm" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm_isdst'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1915 "configure"
+#line 2077 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_cv_struct_tm>
@@ -1919,7 +2081,7 @@ int main() {
struct tm tm; tm.tm_isdst;
; return 0; }
EOF
-if { (eval echo configure:1923: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2085: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm_isdst=yes
else
@@ -1939,12 +2101,12 @@ EOF
fi
echo $ac_n "checking for daylight""... $ac_c" 1>&6
-echo "configure:1943: checking for daylight" >&5
+echo "configure:2105: checking for daylight" >&5
if eval "test \"`echo '$''{'ac_cv_var_daylight'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1948 "configure"
+#line 2110 "configure"
#include "confdefs.h"
#include <time.h>
#ifndef daylight /* In case IRIX #defines this, too */
@@ -1954,7 +2116,7 @@ int main() {
atoi(daylight);
; return 0; }
EOF
-if { (eval echo configure:1958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_var_daylight=yes
else
@@ -1975,14 +2137,234 @@ EOF
fi
+ # Check whether --enable-largefile or --disable-largefile was given.
+if test "${enable_largefile+set}" = set; then
+ enableval="$enable_largefile"
+ :
+fi
+
+ if test "$enable_largefile" != no; then
+
+ echo $ac_n "checking for special C compiler options needed for large files=
+""... $ac_c" 1>&6
+echo "configure:2151: checking for special C compiler options needed for large files=
+" >&5
+if eval "test \"`echo '$''{'ac_cv_sys_largefile_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_sys_largefile_CC=no
+ if test "$GCC" != yes; then
+ # IRIX 6.2 and later do not support large files by default,
+ # so use the C compiler's -n32 option if that helps.
+ cat > conftest.$ac_ext <<EOF
+#line 2161 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply "#define LARGE_OFF_T 9223372036854775807",
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:2177: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_save_CC="$CC"
+ CC="$CC -n32"
+ cat > conftest.$ac_ext <<EOF
+#line 2186 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply "#define LARGE_OFF_T 9223372036854775807",
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:2202: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_sys_largefile_CC=' -n32'
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ CC="$ac_save_CC"
+fi
+rm -f conftest*
+ fi
+fi
+
+echo "$ac_t""$ac_cv_sys_largefile_CC" 1>&6
+ if test "$ac_cv_sys_largefile_CC" != no; then
+ CC="$CC$ac_cv_sys_largefile_CC"
+ fi
+
+ echo $ac_n "checking for _FILE_OFFSET_BITS value needed for large files""... $ac_c" 1>&6
+echo "configure:2222: checking for _FILE_OFFSET_BITS value needed for large files" >&5
+if eval "test \"`echo '$''{'ac_cv_sys_file_offset_bits'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_sys_file_offset_bits=no
+ cat > conftest.$ac_ext <<EOF
+#line 2228 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply "#define LARGE_OFF_T 9223372036854775807",
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:2244: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ cat > conftest.$ac_ext <<EOF
+#line 2251 "configure"
+#include "confdefs.h"
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply "#define LARGE_OFF_T 9223372036854775807",
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:2269: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_sys_file_offset_bits=64
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_sys_file_offset_bits" 1>&6
+ if test "$ac_cv_sys_file_offset_bits" != no; then
+ cat >> confdefs.h <<EOF
+#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
+EOF
+
+ fi
+ echo $ac_n "checking for _LARGE_FILES value needed for large files""... $ac_c" 1>&6
+echo "configure:2289: checking for _LARGE_FILES value needed for large files" >&5
+if eval "test \"`echo '$''{'ac_cv_sys_large_files'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_sys_large_files=no
+ cat > conftest.$ac_ext <<EOF
+#line 2295 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply "#define LARGE_OFF_T 9223372036854775807",
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:2311: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ cat > conftest.$ac_ext <<EOF
+#line 2318 "configure"
+#include "confdefs.h"
+#define _LARGE_FILES 1
+#include <sys/types.h>
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply "#define LARGE_OFF_T 9223372036854775807",
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
+
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:2336: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_sys_large_files=1
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_sys_large_files" 1>&6
+ if test "$ac_cv_sys_large_files" != no; then
+ cat >> confdefs.h <<EOF
+#define _LARGE_FILES $ac_cv_sys_large_files
+EOF
+
+ fi
+ fi
+
+
echo $ac_n "checking for uint8_t""... $ac_c" 1>&6
-echo "configure:1980: checking for uint8_t" >&5
+echo "configure:2359: checking for uint8_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_uint8_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1985 "configure"
+#line 2364 "configure"
#include "confdefs.h"
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
@@ -2009,13 +2391,16 @@ EOF
fi
echo $ac_n "checking for uint16_t""... $ac_c" 1>&6
-echo "configure:2013: checking for uint16_t" >&5
+echo "configure:2395: checking for uint16_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_uint16_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2018 "configure"
+#line 2400 "configure"
#include "confdefs.h"
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
@@ -2042,13 +2427,16 @@ EOF
fi
echo $ac_n "checking for uint32_t""... $ac_c" 1>&6
-echo "configure:2046: checking for uint32_t" >&5
+echo "configure:2431: checking for uint32_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_uint32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2051 "configure"
+#line 2436 "configure"
#include "confdefs.h"
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
@@ -2074,9 +2462,8 @@ EOF
fi
-
echo $ac_n "checking for long long""... $ac_c" 1>&6
-echo "configure:2080: checking for long long" >&5
+echo "configure:2467: checking for long long" >&5
if eval "test \"`echo '$''{'ac_cv_c_long_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2087,13 +2474,13 @@ if test "$cross_compiling" = yes; then
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 2091 "configure"
+#line 2478 "configure"
#include "confdefs.h"
int main() {
long long foo = 0;
exit(sizeof(long long) < sizeof(long)); }
EOF
-if { (eval echo configure:2097: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2484: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_long_long=yes
else
@@ -2122,13 +2509,16 @@ else
long64='unsigned long';
fi
echo $ac_n "checking for uint64_t""... $ac_c" 1>&6
-echo "configure:2126: checking for uint64_t" >&5
+echo "configure:2513: checking for uint64_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_uint64_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2131 "configure"
+#line 2518 "configure"
#include "confdefs.h"
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
@@ -2158,7 +2548,7 @@ fi
echo $ac_n "checking size of uint8_t""... $ac_c" 1>&6
-echo "configure:2162: checking size of uint8_t" >&5
+echo "configure:2552: checking size of uint8_t" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_uint8_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2166,8 +2556,11 @@ else
ac_cv_sizeof_uint8_t=0
else
cat > conftest.$ac_ext <<EOF
-#line 2170 "configure"
+#line 2560 "configure"
#include "confdefs.h"
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
#include <sys/types.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
@@ -2182,7 +2575,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2186: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2579: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_uint8_t=`cat conftestval`
else
@@ -2203,7 +2596,7 @@ EOF
echo $ac_n "checking size of uint16_t""... $ac_c" 1>&6
-echo "configure:2207: checking size of uint16_t" >&5
+echo "configure:2600: checking size of uint16_t" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_uint16_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2211,8 +2604,11 @@ else
ac_cv_sizeof_uint16_t=0
else
cat > conftest.$ac_ext <<EOF
-#line 2215 "configure"
+#line 2608 "configure"
#include "confdefs.h"
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
#include <sys/types.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
@@ -2227,7 +2623,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2231: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_uint16_t=`cat conftestval`
else
@@ -2248,7 +2644,7 @@ EOF
echo $ac_n "checking size of uint32_t""... $ac_c" 1>&6
-echo "configure:2252: checking size of uint32_t" >&5
+echo "configure:2648: checking size of uint32_t" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_uint32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2256,8 +2652,11 @@ else
ac_cv_sizeof_uint32_t=0
else
cat > conftest.$ac_ext <<EOF
-#line 2260 "configure"
+#line 2656 "configure"
#include "confdefs.h"
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
#include <sys/types.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
@@ -2272,7 +2671,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2276: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2675: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_uint32_t=`cat conftestval`
else
@@ -2293,7 +2692,7 @@ EOF
echo $ac_n "checking size of uint64_t""... $ac_c" 1>&6
-echo "configure:2297: checking size of uint64_t" >&5
+echo "configure:2696: checking size of uint64_t" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_uint64_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2301,8 +2700,11 @@ else
ac_cv_sizeof_uint64_t=0
else
cat > conftest.$ac_ext <<EOF
-#line 2305 "configure"
+#line 2704 "configure"
#include "confdefs.h"
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
#include <sys/types.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
@@ -2317,7 +2719,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:2321: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_uint64_t=`cat conftestval`
else
@@ -2338,15 +2740,15 @@ EOF
-for ac_func in mmap strerror strtoul
+for ac_func in mmap strerror strtoul mkstemp
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2345: checking for $ac_func" >&5
+echo "configure:2747: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2350 "configure"
+#line 2752 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2369,7 +2771,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2775: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2394,6 +2796,54 @@ fi
done
+echo $ac_n "checking for gzopen in -lz""... $ac_c" 1>&6
+echo "configure:2801: checking for gzopen in -lz" >&5
+ac_lib_var=`echo z'_'gzopen | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lz $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2809 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char gzopen();
+
+int main() {
+gzopen()
+; return 0; }
+EOF
+if { (eval echo configure:2820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo z | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lz $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
trap '' 1 2 15
cat > confcache <<\EOF
# This file is a shell script that caches the results of configure
diff --git a/contrib/file/configure.in b/contrib/file/configure.in
index 9626ae6..2cd216e 100644
--- a/contrib/file/configure.in
+++ b/contrib/file/configure.in
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(file.c)
-AM_INIT_AUTOMAKE(file, 3.37)
+AM_INIT_AUTOMAKE(file, 3.39)
AM_CONFIG_HEADER(config.h)
AC_MSG_CHECKING(for builtin ELF support)
@@ -57,9 +57,13 @@ dnl Checks for headers
AC_HEADER_STDC
AC_HEADER_MAJOR
AC_HEADER_SYS_WAIT
+AC_HEADER_STDINT
+AC_CHECK_HEADERS(fcntl.h locale.h)
+AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h)
AC_CHECK_HEADERS(unistd.h)
+AC_CHECK_HEADERS(getopt.h)
AC_CHECK_HEADERS(locale.h)
-AC_CHECK_HEADERS(sys/mman.h)
+AC_CHECK_HEADERS(stdint.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@@ -67,12 +71,11 @@ AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_STRUCT_ST_RDEV
AC_STRUCT_TIMEZONE_DAYLIGHT
+AC_SYS_LARGEFILE
-dnl FIXME: only found in standard headers!
-AC_CHECK_TYPE(uint8_t, unsigned char)
-AC_CHECK_TYPE(uint16_t, unsigned short)
-AC_CHECK_TYPE(uint32_t, unsigned int)
-
+AC_CHECK_TYPE_STDC(uint8_t, unsigned char)
+AC_CHECK_TYPE_STDC(uint16_t, unsigned short)
+AC_CHECK_TYPE_STDC(uint32_t, unsigned int)
AC_C_LONG_LONG
if test $ac_cv_c_long_long = yes; then
long64='unsigned long long';
@@ -80,7 +83,7 @@ else
long64='unsigned long';
fi
dnl This needs a patch to autoconf 2.13 acgeneral.m4
-AC_CHECK_TYPE2(uint64_t, $long64)
+AC_CHECK_TYPE2_STDC(uint64_t, $long64)
AC_CHECK_SIZEOF_STDC_HEADERS(uint8_t, 0)
AC_CHECK_SIZEOF_STDC_HEADERS(uint16_t, 0)
@@ -88,6 +91,9 @@ AC_CHECK_SIZEOF_STDC_HEADERS(uint32_t, 0)
AC_CHECK_SIZEOF_STDC_HEADERS(uint64_t, 0)
dnl Checks for functions
-AC_CHECK_FUNCS(mmap strerror strtoul)
+AC_CHECK_FUNCS(mmap strerror strtoul mkstemp)
+
+dnl Checks for libraries
+AC_CHECK_LIB(z,gzopen)
AC_OUTPUT(Makefile)
diff --git a/contrib/file/file.c b/contrib/file/file.c
index 8f957e3..4779938 100644
--- a/contrib/file/file.c
+++ b/contrib/file/file.c
@@ -24,13 +24,12 @@
*
* 4. This notice may not be removed or altered.
*/
-#include <stdio.h>
+
+#include "file.h"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/param.h> /* for MAXPATHLEN */
-#include <sys/stat.h>
#include <fcntl.h> /* for open() */
#ifdef RESTORE_TIME
# if (__COHERENT__ >= 0x420)
@@ -50,13 +49,16 @@
#include <locale.h>
#endif
+#ifdef HAVE_GETOPT_H
+#include <getopt.h> /* for long options (is this portable?)*/
+#endif
+
#include <netinet/in.h> /* for byte swapping */
-#include "file.h"
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: file.c,v 1.59 2001/07/23 00:02:32 christos Exp $")
+FILE_RCSID("@(#)$Id: file.c,v 1.66 2002/07/03 19:00:41 christos Exp $")
#endif /* lint */
@@ -66,6 +68,11 @@ FILE_RCSID("@(#)$Id: file.c,v 1.59 2001/07/23 00:02:32 christos Exp $")
# define USAGE "Usage: %s [-bciknsvz] [-f namefile] [-m magicfiles] file...\n"
#endif
+#ifdef __EMX__
+static char *apptypeName = NULL;
+int os2_apptype (const char *fn, char *buf, int nb);
+#endif /* __EMX__ */
+
#ifndef MAGIC
# define MAGIC "/etc/magic"
#endif
@@ -96,32 +103,62 @@ char *progname; /* used throughout */
int lineno; /* line number in the magic file */
-static void unwrap __P((char *fn));
-static void usage __P((void));
+static void unwrap(char *fn);
+static void usage(void);
+#ifdef HAVE_GETOPT_H
+static void help(void);
+#endif
#if 0
-static int byteconv4 __P((int, int, int));
-static short byteconv2 __P((int, int, int));
+static int byteconv4(int, int, int);
+static short byteconv2(int, int, int);
#endif
-int main __P((int, char *[]));
+int main(int, char *[]);
/*
* main - parse arguments and handle options
*/
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char **argv)
{
int c;
int action = 0, didsomefiles = 0, errflg = 0, ret = 0, app = 0;
char *mime, *home, *usermagic;
struct stat sb;
+#define OPTSTRING "bcdf:ikm:nsvzCL"
+#ifdef HAVE_GETOPT_H
+ int longindex;
+ static 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'},
+ {"files-from", 1, 0, 'f'},
+ {"mime", 0, 0, 'i'},
+ {"keep-going", 0, 0, 'k'},
+#ifdef S_IFLNK
+ {"dereference", 0, 0, 'L'},
+#endif
+ {"magic-file", 1, 0, 'm'},
+ {"uncompress", 0, 0, 'z'},
+ {"no-buffer", 0, 0, 'n'},
+ {"special-files", 0, 0, 's'},
+ {"compile", 0, 0, 'C'},
+ {0, 0, 0, 0},
+ };
+#endif
#ifdef LC_CTYPE
setlocale(LC_CTYPE, ""); /* makes islower etc work for other langs */
#endif
+#ifdef __EMX__
+ /* sh-like wildcard expansion! Shouldn't hurt at least ... */
+ _wildcard(&argc, &argv);
+#endif
+
if ((progname = strrchr(argv[0], '/')) != NULL)
progname++;
else
@@ -142,8 +179,19 @@ main(argc, argv)
}
}
- while ((c = getopt(argc, argv, "bcdf:ikm:nsvzCL")) != EOF)
+#ifndef HAVE_GETOPT_H
+ while ((c = getopt(argc, argv, OPTSTRING)) != -1)
+#else
+ while ((c = getopt_long(argc, argv, OPTSTRING, long_options,
+ &longindex)) != -1)
+#endif
switch (c) {
+#ifdef HAVE_GETOPT_H
+ case 0 :
+ if (longindex == 1)
+ help();
+ break;
+#endif
case 'b':
++bflag;
break;
@@ -241,8 +289,7 @@ main(argc, argv)
* unwrap -- read a file of filenames, do each one.
*/
static void
-unwrap(fn)
- char *fn;
+unwrap(char *fn)
{
char buf[MAXPATHLEN];
FILE *f;
@@ -286,10 +333,7 @@ unwrap(fn)
* big_endian whether we are a big endian host
*/
static int
-byteconv4(from, same, big_endian)
- int from;
- int same;
- int big_endian;
+byteconv4(int from, int same, int big_endian)
{
if (same)
return from;
@@ -316,10 +360,7 @@ byteconv4(from, same, big_endian)
* Same as byteconv4, but for shorts
*/
static short
-byteconv2(from, same, big_endian)
- int from;
- int same;
- int big_endian;
+byteconv2(int from, int same, int big_endian)
{
if (same)
return from;
@@ -344,9 +385,7 @@ byteconv2(from, same, big_endian)
* process - process input file
*/
void
-process(inname, wid)
- const char *inname;
- int wid;
+process(const char *inname, int wid)
{
int fd = 0;
static const char stdname[] = "standard input";
@@ -400,7 +439,7 @@ process(inname, wid)
ckfputs(iflag ? "application/x-empty" : "empty", stdout);
else {
buf[nbytes++] = '\0'; /* null-terminate it */
- match = tryit(buf, nbytes, zflag);
+ match = tryit(inname, buf, nbytes, zflag);
}
#ifdef BUILTIN_ELF
@@ -446,12 +485,24 @@ process(inname, wid)
int
-tryit(buf, nb, zflag)
- unsigned char *buf;
- int nb, zflag;
+tryit(const char *fn, unsigned char *buf, int nb, int zfl)
{
+
+ /*
+ * The main work is done here!
+ * We have the file name and/or the data buffer to be identified.
+ */
+
+#ifdef __EMX__
+ /*
+ * Ok, here's the right place to add a call to some os-specific
+ * routine, e.g.
+ */
+ if (os2_apptype(fn, buf, nb) == 1)
+ return 'o';
+#endif
/* try compression stuff */
- if (zflag && zmagic(buf, nb))
+ if (zfl && zmagic(fn, buf, nb))
return 'z';
/* try tests in /etc/magic (or surrogate magic file) */
@@ -463,14 +514,46 @@ tryit(buf, nb, zflag)
return 'a';
/* abandon hope, all ye who remain here */
- ckfputs("data", stdout);
+ ckfputs(iflag ? "application/octet-stream" : "data", stdout);
return '\0';
}
static void
-usage()
+usage(void)
{
(void)fprintf(stderr, USAGE, progname);
(void)fprintf(stderr, "Usage: %s -C [-m magic]\n", progname);
+#ifdef HAVE_GETOPT_H
+ (void)fputs("Try `file --help' for more information.\n", stderr);
+#endif
exit(1);
}
+
+#ifdef HAVE_GETOPT_H
+static void
+help(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"
+" -f, --files-from FILE read the filenames to be examined from FILE\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"
+" -s, --special-files treat special (block/char devices) files as\n"
+" ordinary ones\n"
+" --help display this help and exit\n"
+" --version output version information and exit\n"
+);
+ exit(0);
+}
+#endif
diff --git a/contrib/file/file.h b/contrib/file/file.h
index 6800e2f..76bf806 100644
--- a/contrib/file/file.h
+++ b/contrib/file/file.h
@@ -1,6 +1,6 @@
/*
* file.h - definitions for file(1) program
- * @(#)$Id: file.h,v 1.37 2001/07/22 21:04:15 christos Exp $
+ * @(#)$Id: file.h,v 1.43 2002/07/03 18:57:52 christos Exp $
*
* Copyright (c) Ian F. Darwin, 1987.
* Written by Ian F. Darwin.
@@ -29,21 +29,28 @@
#ifndef __file_h__
#define __file_h__
+#ifndef __linux__
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+#define _FILE_OFFSET_BITS 64
+#endif
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-typedef int int32;
-typedef unsigned int uint32;
-typedef short int16;
-typedef unsigned short uint16;
-typedef char int8;
-typedef unsigned char uint8;
+#include <errno.h>
+#include <stdio.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+/* Do this here and now, because struct stat gets re-defined on solaris */
+#include <sys/stat.h>
#ifndef HOWMANY
-# define HOWMANY 16384 /* how much of the file to look at */
+# define HOWMANY 65536 /* how much of the file to look at */
#endif
-#define MAXMAGIS 1000 /* max entries in /etc/magic */
+#define MAXMAGIS 4096 /* max entries in /etc/magic */
#define MAXDESC 50 /* max leng of text description */
#define MAXstring 32 /* max leng of "string" types */
@@ -54,16 +61,16 @@ typedef unsigned char uint8;
#define COMPILE 2
struct magic {
- uint16 cont_level;/* level of ">" */
- uint8 nospflag; /* supress space character */
- uint8 flag;
+ uint16_t cont_level; /* level of ">" */
+ uint8_t nospflag; /* supress space character */
+ uint8_t flag;
#define INDIR 1 /* if '>(...)' appears, */
#define UNSIGNED 2 /* comparison is unsigned */
#define OFFADD 4 /* if '>&' appears, */
- uint8 reln; /* relation (0=eq, '>'=gt, etc) */
- uint8 vallen; /* length of string value, if any */
- uint8 type; /* int, short, long or string. */
- uint8 in_type; /* type of indirrection */
+ uint8_t reln; /* relation (0=eq, '>'=gt, etc) */
+ uint8_t vallen; /* length of string value, if any */
+ uint8_t type; /* int, short, long or string. */
+ uint8_t in_type; /* type of indirrection */
#define BYTE 1
#define SHORT 2
#define LONG 4
@@ -79,8 +86,9 @@ struct magic {
#define LDATE 14
#define BELDATE 15
#define LELDATE 16
- uint8 in_op; /* operator for indirection */
- uint8 mask_op; /* operator for mask */
+#define REGEX 17
+ uint8_t in_op; /* operator for indirection */
+ uint8_t mask_op; /* operator for mask */
#define OPAND 1
#define OPOR 2
#define OPXOR 3
@@ -90,19 +98,20 @@ struct magic {
#define OPDIVIDE 7
#define OPMODULO 8
#define OPINVERSE 0x80
- int32 offset; /* offset to magic number */
- int32 in_offset; /* offset from indirection */
+ int32_t offset; /* offset to magic number */
+ int32_t in_offset; /* offset from indirection */
union VALUETYPE {
- unsigned char b;
- unsigned short h;
- uint32 l;
+ uint8_t b;
+ uint16_t h;
+ uint32_t l;
char s[MAXstring];
- unsigned char hs[2]; /* 2 bytes of a fixed-endian "short" */
- unsigned char hl[4]; /* 4 bytes of a fixed-endian "long" */
+ char *buf;
+ uint8_t hs[2]; /* 2 bytes of a fixed-endian "short" */
+ uint8_t hl[4]; /* 4 bytes of a fixed-endian "long" */
} value; /* either number or string */
- uint32 mask; /* mask before comparison with value */
+ uint32_t mask; /* mask before comparison with value */
char desc[MAXDESC]; /* description */
-};
+} __attribute__((__packed__));
#define BIT(A) (1 << (A))
#define STRING_IGNORE_LOWERCASE BIT(0)
@@ -116,41 +125,31 @@ struct magic {
/* list of magic entries */
struct mlist {
struct magic *magic; /* array of magic entries */
- uint32 nmagic; /* number of entries in array */
+ uint32_t nmagic; /* number of entries in array */
struct mlist *next, *prev;
};
-#include <stdio.h> /* Include that here, to make sure __P gets defined */
-#include <errno.h>
-
-#ifndef __P
-# if defined(__STDC__) || defined(__cplusplus)
-# define __P(a) a
-# else
-# define __P(a) ()
-# define const
-# endif
-#endif
-
-extern int apprentice __P((const char *, int));
-extern int ascmagic __P((unsigned char *, int));
-extern void error __P((const char *, ...));
-extern void ckfputs __P((const char *, FILE *));
+extern int apprentice(const char *, int);
+extern int ascmagic(unsigned char *, int);
+extern void error(const char *, ...);
+extern void ckfputs(const char *, FILE *);
struct stat;
-extern int fsmagic __P((const char *, struct stat *));
-extern char *fmttime __P((long, int));
-extern int is_compress __P((const unsigned char *, int *));
-extern int is_tar __P((unsigned char *, int));
-extern void magwarn __P((const char *, ...));
-extern void mdump __P((struct magic *));
-extern void process __P((const char *, int));
-extern void showstr __P((FILE *, const char *, int));
-extern int softmagic __P((unsigned char *, int));
-extern int tryit __P((unsigned char *, int, int));
-extern int zmagic __P((unsigned char *, int));
-extern void ckfprintf __P((FILE *, const char *, ...));
-extern uint32 signextend __P((struct magic *, unsigned int32));
-extern void tryelf __P((int, unsigned char *, int));
+extern int fsmagic(const char *, struct stat *);
+extern char *fmttime(long, int);
+extern int is_compress(const unsigned char *, int *);
+extern int is_tar(unsigned char *, int);
+extern void magwarn(const char *, ...);
+extern void mdump(struct magic *);
+extern void process(const char *, int);
+extern void showstr(FILE *, const char *, int);
+extern int softmagic(unsigned char *, int);
+extern int tryit(const char *, unsigned char *, int, int);
+extern int zmagic(const char *, unsigned char *, int);
+extern void ckfprintf(FILE *, const char *, ...);
+extern uint32_t signextend(struct magic *, unsigned int32);
+extern void tryelf(int, unsigned char *, int);
+extern int pipe2file(int, void *, size_t);
+
extern char *progname; /* the program name */
extern const char *magicfile; /* name of the magic file */
@@ -164,8 +163,10 @@ extern int lflag; /* follow symbolic links? */
extern int sflag; /* read/analyze block special files? */
extern int iflag; /* Output types as mime-types */
+#ifdef NEED_GETOPT
extern int optind; /* From getopt(3) */
extern char *optarg;
+#endif
#ifndef HAVE_STRERROR
extern int sys_nerr;
@@ -182,13 +183,9 @@ extern char *sys_errlist[];
#define QUICK
#endif
-#ifdef __STDC__
#define FILE_RCSID(id) \
static const char *rcsid(const char *p) { \
return rcsid(p = id); \
}
-#else
-#define FILE_RCSID(id) static char rcsid[] = id;
-#endif
#endif /* __file_h__ */
diff --git a/contrib/file/file.man b/contrib/file/file.man
index fc18f12..de3e0a6 100644
--- a/contrib/file/file.man
+++ b/contrib/file/file.man
@@ -1,5 +1,5 @@
.TH FILE __CSECTION__ "Copyright but distributable"
-.\" $Id: file.man,v 1.39 2001/04/27 22:48:33 christos Exp $
+.\" $Id: file.man,v 1.42 2002/07/03 18:26:37 christos Exp $
.SH NAME
file
\- determine file type
@@ -13,16 +13,16 @@ file
.I namefile
]
[
-.B \-m
+.B \-m
.I magicfiles
]
.I file
-\&...
+\*[Am]...
.br
.B file
.B -C
[
-.B \-m
+.B \-m
magicfile ]
.SH DESCRIPTION
This manual page documents version __VERSION__ of the
@@ -54,7 +54,7 @@ Exceptions are well-known file formats (core files, tar archives)
that are known to contain binary data.
When modifying the file
.I __MAGIC__
-or the program itself,
+or the program itself,
.B "preserve these keywords" .
People depend on knowing that all the readable files in a directory
have the word ``text'' printed.
@@ -77,13 +77,13 @@ Any known file types appropriate to the system you are running on
implement them)
are intuited if they are defined in
the system header file
-.IR <sys/stat.h> .
+.IR \*[Lt]sys/stat.h\*[Gt] .
.PP
The magic number tests are used to check for files with data in
particular fixed formats.
The canonical example of this is a binary executable (compiled program)
.I a.out
-file, whose format is defined in
+file, whose format is defined in
.I a.out.h
and possibly
.I exec.h
@@ -97,7 +97,7 @@ offset into the file can usually be described in this way.
The information identifying these files is read from the compiled
magic file
.I __MAGIC__.mgc ,
-or
+or
.I __MAGIC__
if the compile file does not exist.
.PP
@@ -135,13 +135,13 @@ For example, the keyword
.B .br
indicates that the file is most likely a
.BR troff (1)
-input file, just as the keyword
+input file, just as the keyword
.B struct
indicates a C program.
These tests are less reliable than the previous
two groups, so they are performed last.
The language test routines also test for some miscellany
-(such as
+(such as
.BR tar (1)
archives).
.PP
@@ -154,7 +154,7 @@ Do not prepend filenames to output lines (brief mode).
.TP 8
.B \-c
Cause a checking printout of the parsed form of the magic file.
-This is usually used in conjunction with
+This is usually used in conjunction with
.B \-m
to debug a new magic file before installing it.
.TP 8
@@ -163,11 +163,11 @@ Write a magic.mgc output file that contains a pre-parsed version of
file.
.TP 8
.BI \-f " namefile"
-Read the names of the files to be examined from
+Read the names of the files to be examined from
.I namefile
-(one per line)
+(one per line)
before the argument list.
-Either
+Either
.I namefile
or at least one filename argument must be present;
to test the standard input, use ``\-'' as a filename argument.
@@ -250,22 +250,22 @@ can be used to set the default magic number files.
.SH STANDARDS CONFORMANCE
This program is believed to exceed the System V Interface Definition
of FILE(CMD), as near as one can determine from the vague language
-contained therein.
+contained therein.
Its behaviour is mostly compatible with the System V program of the same name.
This version knows more magic, however, so it will produce
-different (albeit more accurate) output in many cases.
+different (albeit more accurate) output in many cases.
.PP
-The one significant difference
+The one significant difference
between this version and System V
is that this version treats any white space
as a delimiter, so that spaces in pattern strings must be escaped.
For example,
.br
->10 string language impress\ (imPRESS data)
+\*[Gt]10 string language impress\ (imPRESS data)
.br
in an existing magic file would have to be changed to
.br
->10 string language\e impress (imPRESS data)
+\*[Gt]10 string language\e impress (imPRESS data)
.br
In addition, in this version, if a pattern string contains a backslash,
it must be escaped. For example
@@ -281,16 +281,16 @@ SunOS releases 3.2 and later from Sun Microsystems include a
.BR file (1)
command derived from the System V one, but with some extensions.
My version differs from Sun's only in minor ways.
-It includes the extension of the `&' operator, used as,
+It includes the extension of the `\*[Am]' operator, used as,
for example,
.br
->16 long&0x7fffffff >0 not stripped
+\*[Gt]16 long\*[Am]0x7fffffff \*[Gt]0 not stripped
.SH MAGIC DIRECTORY
The magic file entries have been collected from various sources,
mainly USENET, and contributed by various authors.
Christos Zoulas (address below) will collect additional
or corrected magic file entries.
-A consolidation of magic file entries
+A consolidation of magic file entries
will be distributed periodically.
.PP
The order of entries in the magic file is significant.
@@ -300,16 +300,19 @@ If your old
.B file
command uses a magic file,
keep the old magic file around for comparison purposes
-(rename it to
+(rename it to
.IR __MAGIC__.orig ).
.SH EXAMPLES
.nf
-$ file file.c file /dev/hda
+$ file file.c file /dev/{wd0a,hda}
file.c: C program text
-file: ELF 32-bit LSB executable, Intel 80386, version 1,
- dynamically linked, not stripped
-/dev/hda: block special
-
+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
@@ -323,30 +326,32 @@ $ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
/dev/hda9: empty
/dev/hda10: empty
-$ file -i file.c file /dev/hda
+$ 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, dynamically linked (uses shared libs),
+not stripped
/dev/hda: application/x-not-regular-file
+/dev/wd0a: application/x-not-regular-file
.fi
.SH HISTORY
-There has been a
+There has been a
.B file
-command in every \s-1UNIX\s0 since at least Research Version 6
-(man page dated January 16, 1975).
+command in every \s-1UNIX\s0 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
This program, based on the System V version,
-was written by Ian Darwin <ian@darwinsys.com>
+was written by Ian Darwin \*[Lt]ian@darwinsys.com\*[Gt]
without looking at anybody else's source code.
.PP
John Gilmore revised the code extensively, making it better than
the first version.
Geoff Collyer found several inadequacies
and provided some magic file entries.
-Contributions by the `&' operator by Rob McMahon, cudcv@warwick.ac.uk, 1989.
+Contributions by the `\*[Am]' operator by Rob McMahon, cudcv@warwick.ac.uk, 1989.
.PP
Guy Harris, guy@netapp.com, made many changes from 1993 to the present.
.PP
@@ -413,11 +418,11 @@ commands vs man page macros.
Regular expression support would make this easy.
.PP
The program doesn't grok \s-2FORTRAN\s0.
-It should be able to figure \s-2FORTRAN\s0 by seeing some keywords which
+It should be able to figure \s-2FORTRAN\s0 by seeing some keywords which
appear indented at the start of line.
Regular expression support would make this easy.
.PP
-The list of keywords in
+The list of keywords in
.I ascmagic
probably belongs in the Magic file.
This could be done by using some keyword like `*' for the offset value.
@@ -429,12 +434,12 @@ 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
-The program should provide a way to give an estimate
+The program should provide a way to give an estimate
of ``how good'' a guess is.
We end up removing guesses (e.g. ``From '' as first 5 chars of file) because
they are not as good as other guesses (e.g. ``Newsgroups:'' versus
``Return-Path:''). Still, if the others don't pan out, it should be
-possible to use the first guess.
+possible to use the first guess.
.PP
This program is slower than some vendors' file commands.
The new support for multiple character codes makes it even slower.
diff --git a/contrib/file/fsmagic.c b/contrib/file/fsmagic.c
index d6a900e..fc6a29b 100644
--- a/contrib/file/fsmagic.c
+++ b/contrib/file/fsmagic.c
@@ -26,10 +26,7 @@
*/
#include "file.h"
-#include <stdio.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -54,13 +51,11 @@
#undef HAVE_MAJOR
#ifndef lint
-FILE_RCSID("@(#)$Id: fsmagic.c,v 1.33 2000/08/05 17:36:48 christos Exp $")
+FILE_RCSID("@(#)$Id: fsmagic.c,v 1.36 2002/07/03 19:00:41 christos Exp $")
#endif /* lint */
int
-fsmagic(fn, sb)
- const char *fn;
- struct stat *sb;
+fsmagic(const char *fn, struct stat *sb)
{
int ret = 0;
diff --git a/contrib/file/is_tar.c b/contrib/file/is_tar.c
index 6c5b61c..de7a169 100644
--- a/contrib/file/is_tar.c
+++ b/contrib/file/is_tar.c
@@ -5,25 +5,25 @@
* Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
*
* @(#)list.c 1.18 9/23/86 Public Domain - gnu
- * $Id: is_tar.c,v 1.13 2000/08/05 17:36:48 christos Exp $
+ * $Id: is_tar.c,v 1.17 2002/07/03 18:26:38 christos Exp $
*
* Comments changed and some code/comments reformatted
* for file command by Ian Darwin.
*/
+#include "file.h"
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include "tar.h"
-#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: is_tar.c,v 1.13 2000/08/05 17:36:48 christos Exp $")
+FILE_RCSID("@(#)$Id: is_tar.c,v 1.17 2002/07/03 18:26:38 christos Exp $")
#endif
#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
-static int from_oct __P((int, char *)); /* Decode octal number */
+static int from_oct(int, char *); /* Decode octal number */
/*
* Return
@@ -32,9 +32,7 @@ static int from_oct __P((int, char *)); /* Decode octal number */
* 2 for Unix Std (POSIX) tar file.
*/
int
-is_tar(buf, nbytes)
- unsigned char *buf;
- int nbytes;
+is_tar(unsigned char *buf, int nbytes)
{
union record *header = (union record *)buf;
int i;
@@ -77,9 +75,7 @@ is_tar(buf, nbytes)
* Result is -1 if the field is invalid (all blank, or nonoctal).
*/
static int
-from_oct(digs, where)
- int digs;
- char *where;
+from_oct(int digs, char *where)
{
int value;
diff --git a/contrib/file/magic.man b/contrib/file/magic.man
index 5f6d062..81e5fb38 100644
--- a/contrib/file/magic.man
+++ b/contrib/file/magic.man
@@ -7,7 +7,7 @@ This manual page documents the format of the magic file as
used by the
.BR file (__CSECTION__)
command, version __VERSION__. The
-.B file
+.BR file
command identifies the type of a file using,
among other tests,
a test for whether the file begins with a certain
@@ -70,7 +70,7 @@ than UTC.
.RE
.PP
The numeric types may optionally be followed by
-.B &
+.B \*[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
@@ -87,17 +87,17 @@ may be preceded by a character indicating the operation to be performed.
It may be
.BR = ,
to specify that the value from the file must equal the specified value,
-.BR < ,
+.BR \*[Lt] ,
to specify that the value from the file must be less than the specified
value,
-.BR > ,
+.BR \*[Gt] ,
to specify that the value from the file must be greater than the specified
value,
-.BR & ,
-to specify that the value from the file must have set all of the bits
+.BR \*[Am] ,
+to specify that the value from the file must have set all of the bits
that are set in the specified value,
.BR ^ ,
-to specify that the value from the file must have clear any of the bits
+to specify that the value from the file must have clear any of the bits
that are set in the specified value, or
.BR x ,
to specify that any value will match. If the character is omitted,
@@ -113,34 +113,34 @@ is octal, and
is hexadecimal.
.IP
For string values, the byte string from the
-file must match the specified byte string.
+file must match the specified byte string.
The operators
.BR = ,
-.B <
+.B \*[Lt]
and
-.B >
+.B \*[Gt]
(but not
-.BR & )
+.BR \*[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
+.B \*[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 (3S)
+.BR printf (3)
format specification, the value from the file (with any specified masking
performed) is printed using the message as the format string.
.PP
Some file formats contain additional information which is to be printed
along with the file type. A line which begins with the character
-.B >
+.B \*[Gt]
indicates additional tests and messages to be printed. The number of
-.B >
+.B \*[Gt]
on the line indicates the level of the test; a line with no
-.B >
+.B \*[Gt]
at the beginning is considered to be at level 0.
Each line at level
.IB n \(pl1
@@ -156,7 +156,7 @@ line at level
.I n
terminates this.
If the first character following the last
-.B >
+.B \*[Gt]
is a
.B (
then the string after the parenthesis is interpreted as an indirect offset.
@@ -164,11 +164,11 @@ 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 ]).
-The value of
+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 [bslBSL]
+depending on the
+.B [bslBSL]
type specifier. The capitalized types interpret the number as a big endian
value, whereas the small letter versions interpet the number as a little
endian value. To that number the value of
@@ -179,13 +179,13 @@ if one is not specified is long.
Sometimes you do not know the exact offset as this depends on the length of
preceding fields. You can specify an offset relative to the end of the
last uplevel field (of course this may only be done for sublevel tests, i.e.
-test beginning with
-.B >
+test beginning with
+.B \*[Gt]
). Such a relative offset is specified using
-.B &
+.B \*[Am]
as a prefix to the offset.
.SH BUGS
-The formats
+The formats
.IR long ,
.IR belong ,
.IR lelong ,
@@ -197,7 +197,7 @@ The formats
and
.I ledate
are system-dependent; perhaps they should be specified as a number
-of bytes (2B, 4B, etc),
+of bytes (2B, 4B, etc),
since the files being recognized typically come from
a system on which the lengths are invariant.
.PP
@@ -210,13 +210,13 @@ indirect offsets.
.\" From: guy@sun.uucp (Guy Harris)
.\" Newsgroups: net.bugs.usg
.\" Subject: /etc/magic's format isn't well documented
-.\" Message-ID: <2752@sun.uucp>
+.\" Message-ID: \*[Lt]2752@sun.uucp\*[Gt]
.\" Date: 3 Sep 85 08:19:07 GMT
.\" Organization: Sun Microsystems, Inc.
.\" Lines: 136
-.\"
+.\"
.\" Here's a manual page for the format accepted by the "file" made by adding
.\" the changes I posted to the S5R2 version.
.\"
.\" Modified for Ian Darwin's version of the file command.
-.\" @(#)$Id: magic.man,v 1.17 2001/08/07 15:38:42 christos Exp $
+.\" @(#)$Id: magic.man,v 1.19 2002/07/03 18:26:38 christos Exp $
diff --git a/contrib/file/magic.mime b/contrib/file/magic.mime
index 836942a..f424970 100644
--- a/contrib/file/magic.mime
+++ b/contrib/file/magic.mime
@@ -94,10 +94,9 @@
0 belong 0x2e7261fd application/x-realaudio
# MPEG Layer 3 sound files
-# Modified the 11/20/97 at 15:59:04 by Christophe Prud'homme <christophe.prudhomme@asci.fr>
-0 belong 0xfffb audio/x-mp3
+0 beshort &0xffe0 audio/mpeg
#MP3 with ID3 tag
-0 string ID3 audio/x-mp3
+0 string ID3 audio/mpeg
# Ogg/Vorbis
0 string OggS audio/x-ogg
@@ -541,3 +540,6 @@
#PNG Image Format
0 string \x89PNG image/png
+
+# MNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
+0 string \x8aMNG video/x-mng
diff --git a/contrib/file/names.h b/contrib/file/names.h
index 856632a..ea4e85c 100644
--- a/contrib/file/names.h
+++ b/contrib/file/names.h
@@ -1,7 +1,7 @@
/*
* Names.h - names and types used by ascmagic in file(1).
* These tokens are here because they can appear anywhere in
- * the first HOWMANY bytes, while tokens in /etc/magic must
+ * the first HOWMANY bytes, while tokens in MAGIC must
* appear at fixed offsets into the file. Don't make HOWMANY
* too high unless you have a very fast CPU.
*
@@ -10,7 +10,7 @@
*
* See LEGAL.NOTICE
*
- * $Id: names.h,v 1.18 2000/08/05 17:36:49 christos Exp $
+ * $Id: names.h,v 1.19 2002/05/16 15:01:41 christos Exp $
*/
/*
diff --git a/contrib/file/patchlevel.h b/contrib/file/patchlevel.h
index f1e2464..de8d598 100644
--- a/contrib/file/patchlevel.h
+++ b/contrib/file/patchlevel.h
@@ -1,11 +1,26 @@
#define FILE_VERSION_MAJOR 3
-#define patchlevel 37
+#define patchlevel 39
/*
* Patchlevel file for Ian Darwin's MAGIC command.
- * $Id: patchlevel.h,v 1.37 2001/09/03 14:44:22 christos Exp $
+ * $Id: patchlevel.h,v 1.39 2002/07/03 18:57:52 christos Exp $
*
* $Log: patchlevel.h,v $
+ * Revision 1.39 2002/07/03 18:57:52 christos
+ * - ansify/c99ize
+ * - more magic
+ * - better COMPILE_ONLY support.
+ * - new magic files.
+ * - fix solaris compilation problems.
+ *
+ * Revision 1.38 2002/05/16 18:45:56 christos
+ * - pt_note elf additions from NetBSD
+ * - EMX os specific changes (Alexander Mai)
+ * - stdint.h detection, acconfig.h fixes (Maciej W. Rozycki, Franz Korntner)
+ * - regex file additions (Kim Cromie)
+ * - getopt_long support and misc cleanups (Michael Piefel)
+ * - many magic fixes and additions
+ *
* Revision 1.37 2001/09/03 14:44:22 christos
* daylight/tm_isdst detection
* magic fixes
diff --git a/contrib/file/print.c b/contrib/file/print.c
index b680399..38ca9d3 100644
--- a/contrib/file/print.c
+++ b/contrib/file/print.c
@@ -26,8 +26,6 @@
*/
#include "file.h"
-#include <stdio.h>
-#include <errno.h>
#include <string.h>
#ifdef __STDC__
# include <stdarg.h>
@@ -41,20 +39,20 @@
#include <time.h>
#ifndef lint
-FILE_RCSID("@(#)$Id: print.c,v 1.34 2001/08/07 16:01:26 christos Exp $")
+FILE_RCSID("@(#)$Id: print.c,v 1.38 2002/07/03 18:37:44 christos Exp $")
#endif /* lint */
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
+#ifndef COMPILE_ONLY
void
-mdump(m)
- struct magic *m;
+mdump(struct magic *m)
{
static const char *typ[] = { "invalid", "byte", "short", "invalid",
"long", "string", "date", "beshort",
"belong", "bedate", "leshort", "lelong",
"ledate", "pstring", "ldate", "beldate",
- "leldate" };
+ "leldate", "regex" };
static const char optyp[] = { '@', '&', '|', '^', '+', '-',
'*', '/', '%' };
(void) fputc('[', stderr);
@@ -110,6 +108,7 @@ mdump(m)
break;
case STRING:
case PSTRING:
+ case REGEX:
showstr(stderr, m->value.s, -1);
break;
case DATE:
@@ -129,15 +128,14 @@ mdump(m)
}
(void) fprintf(stderr, ",\"%s\"]\n", m->desc);
}
+#endif
/*
* ckfputs - fputs, but with error checking
* ckfprintf - fprintf, but with error checking
*/
void
-ckfputs(str, fil)
- const char *str;
- FILE *fil;
+ckfputs(const char *str, FILE *fil)
{
if (fputs(str,fil) == EOF)
error("write failed.\n");
@@ -145,23 +143,11 @@ ckfputs(str, fil)
/*VARARGS*/
void
-#ifdef __STDC__
ckfprintf(FILE *f, const char *fmt, ...)
-#else
-ckfprintf(va_alist)
- va_dcl
-#endif
{
va_list va;
-#ifdef __STDC__
+
va_start(va, fmt);
-#else
- FILE *f;
- const char *fmt;
- va_start(va);
- f = va_arg(va, FILE *);
- fmt = va_arg(va, const char *);
-#endif
(void) vfprintf(f, fmt, va);
if (ferror(f))
error("write failed.\n");
@@ -173,21 +159,11 @@ ckfprintf(va_alist)
*/
/*VARARGS*/
void
-#ifdef __STDC__
error(const char *f, ...)
-#else
-error(va_alist)
- va_dcl
-#endif
{
va_list va;
-#ifdef __STDC__
+
va_start(va, f);
-#else
- const char *f;
- va_start(va);
- f = va_arg(va, const char *);
-#endif
/* cuz we use stdout for most, stderr here */
(void) fflush(stdout);
@@ -200,21 +176,11 @@ error(va_alist)
/*VARARGS*/
void
-#ifdef __STDC__
magwarn(const char *f, ...)
-#else
-magwarn(va_alist)
- va_dcl
-#endif
{
va_list va;
-#ifdef __STDC__
+
va_start(va, f);
-#else
- const char *f;
- va_start(va);
- f = va_arg(va, const char *);
-#endif
/* cuz we use stdout for most, stderr here */
(void) fflush(stdout);
@@ -227,10 +193,9 @@ magwarn(va_alist)
}
+#ifndef COMPILE_ONLY
char *
-fmttime(v, local)
- long v;
- int local;
+fmttime(long v, int local)
{
char *pp, *rt;
time_t t = (time_t)v;
@@ -262,3 +227,4 @@ fmttime(v, local)
*rt = '\0';
return pp;
}
+#endif
diff --git a/contrib/file/readelf.c b/contrib/file/readelf.c
index 3c5c414..0ae8ef3 100644
--- a/contrib/file/readelf.c
+++ b/contrib/file/readelf.c
@@ -1,36 +1,31 @@
#include "file.h"
#ifdef BUILTIN_ELF
-#include <sys/types.h>
#include <string.h>
-#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#include <errno.h>
#include "readelf.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: readelf.c,v 1.17 2000/08/05 19:00:12 christos Exp $")
+FILE_RCSID("@(#)$Id: readelf.c,v 1.22 2002/07/03 18:26:38 christos Exp $")
#endif
#ifdef ELFCORE
-static void dophn_core __P((int, int, int, off_t, int, size_t));
+static void dophn_core(int, int, int, off_t, int, size_t);
#endif
-static void dophn_exec __P((int, int, int, off_t, int, size_t));
-static void doshn __P((int, int, int, off_t, int, size_t));
+static void dophn_exec(int, int, int, off_t, int, size_t);
+static void doshn(int, int, int, off_t, int, size_t);
-static uint16_t getu16 __P((int, int));
-static uint32_t getu32 __P((int, uint32_t));
-static uint64_t getu64 __P((int, uint64_t));
+static uint16_t getu16(int, uint16_t);
+static uint32_t getu32(int, uint32_t);
+static uint64_t getu64(int, uint64_t);
static uint16_t
-getu16(swap, value)
- int swap;
- uint16_t value;
+getu16(int swap, uint16_t value)
{
union {
uint16_t ui;
@@ -49,9 +44,7 @@ getu16(swap, value)
}
static uint32_t
-getu32(swap, value)
- int swap;
- uint32_t value;
+getu32(int swap, uint32_t value)
{
union {
uint32_t ui;
@@ -72,9 +65,7 @@ getu32(swap, value)
}
static uint64_t
-getu64(swap, value)
- int swap;
- uint64_t value;
+getu64(int swap, uint64_t value)
{
union {
uint64_t ui;
@@ -130,13 +121,7 @@ getu64(swap, value)
: prpsoffsets64[i])
static void
-doshn(class, swap, fd, off, num, size)
- int class;
- int swap;
- int fd;
- off_t off;
- int num;
- size_t size;
+doshn(int class, int swap, int fd, off_t off, int num, size_t size)
{
Elf32_Shdr sh32;
Elf64_Shdr sh64;
@@ -161,18 +146,17 @@ doshn(class, swap, fd, off, num, size)
* otherwise it's statically linked.
*/
static void
-dophn_exec(class, swap, fd, off, num, size)
- int class;
- int swap;
- int fd;
- off_t off;
- int num;
- size_t size;
+dophn_exec(int class, int swap, int fd, off_t off, int num, size_t size)
{
Elf32_Phdr ph32;
+ Elf32_Nhdr *nh32 = NULL;
Elf64_Phdr ph64;
+ Elf64_Nhdr *nh64 = NULL;
char *linking_style = "statically";
char *shared_libraries = "";
+ char nbuf[BUFSIZ];
+ int bufsize;
+ size_t offset, nameoffset;
if (lseek(fd, off, SEEK_SET) == -1)
error("lseek failed (%s).\n", strerror(errno));
@@ -188,6 +172,112 @@ dophn_exec(class, swap, fd, off, num, size)
case PT_INTERP:
shared_libraries = " (uses shared libs)";
break;
+ case PT_NOTE:
+ /*
+ * This is a PT_NOTE section; loop through all the notes
+ * in the section.
+ */
+ if (lseek(fd, (off_t) ph_offset, SEEK_SET) == -1)
+ error("lseek failed (%s).\n", strerror(errno));
+ bufsize = read(fd, nbuf, BUFSIZ);
+ if (bufsize == -1)
+ error(": " "read failed (%s).\n",
+ strerror(errno));
+ offset = 0;
+ for (;;) {
+ if (offset >= bufsize)
+ break;
+ if (class == ELFCLASS32)
+ nh32 = (Elf32_Nhdr *)&nbuf[offset];
+ else
+ nh64 = (Elf64_Nhdr *)&nbuf[offset];
+ offset += nh_size;
+
+ if (offset + nh_namesz >= bufsize) {
+ /*
+ * We're past the end of the buffer.
+ */
+ break;
+ }
+
+ nameoffset = offset;
+ offset += nh_namesz;
+ offset = ((offset + 3)/4)*4;
+
+ if (offset + nh_descsz >= bufsize)
+ break;
+
+ if (nh_namesz == 4 &&
+ strcmp(&nbuf[nameoffset], "GNU") == 0 &&
+ nh_type == NT_GNU_VERSION &&
+ nh_descsz == 16) {
+ uint32_t *desc =
+ (uint32_t *)&nbuf[offset];
+
+ printf(", for GNU/");
+ switch (getu32(swap, desc[0])) {
+ case GNU_OS_LINUX:
+ printf("Linux");
+ break;
+ case GNU_OS_HURD:
+ printf("Hurd");
+ break;
+ case GNU_OS_SOLARIS:
+ printf("Solaris");
+ break;
+ default:
+ printf("<unknown>");
+ }
+ printf(" %d.%d.%d",
+ getu32(swap, desc[1]),
+ getu32(swap, desc[2]),
+ getu32(swap, desc[3]));
+ }
+
+ if (nh_namesz == 7 &&
+ strcmp(&nbuf[nameoffset], "NetBSD") == 0 &&
+ nh_type == NT_NETBSD_VERSION &&
+ nh_descsz == 4) {
+ printf(", for NetBSD");
+ /*
+ * Version number is stuck at 199905,
+ * and hence is basically content-free.
+ */
+ }
+
+ if (nh_namesz == 8 &&
+ strcmp(&nbuf[nameoffset], "FreeBSD") == 0 &&
+ nh_type == NT_FREEBSD_VERSION &&
+ nh_descsz == 4) {
+ uint32_t desc = getu32(swap,
+ *(uint32_t *)&nbuf[offset]);
+ printf(", for FreeBSD");
+ /*
+ * Contents is __FreeBSD_version,
+ * whose relation to OS versions is
+ * defined by a huge table in the
+ * Porters' Handbook. Happily, the
+ * first three digits are the version
+ * number, at least in versions of
+ * FreeBSD that use this note.
+ */
+
+ printf(" %d.%d", desc / 100000,
+ desc / 10000 % 10);
+ if (desc / 1000 % 10 > 0)
+ printf(".%d",
+ desc / 1000 % 10);
+ }
+
+ if (nh_namesz == 8 &&
+ strcmp(&nbuf[nameoffset], "OpenBSD") == 0 &&
+ nh_type == NT_OPENBSD_VERSION &&
+ nh_descsz == 4) {
+ printf(", for OpenBSD");
+ /* Content of note is always 0 */
+ }
+ }
+ break;
}
}
printf(", %s linked%s", linking_style, shared_libraries);
@@ -230,25 +320,30 @@ size_t prpsoffsets64[] = {
* *do* have that binary, the debugger will probably tell you what
* signal it was.)
*/
+
+#define OS_STYLE_SVR4 0
+#define OS_STYLE_FREEBSD 1
+#define OS_STYLE_NETBSD 2
+
+static const char *os_style_names[] = {
+ "SVR4",
+ "FreeBSD",
+ "NetBSD",
+};
+
static void
-dophn_core(class, swap, fd, off, num, size)
- int class;
- int swap;
- int fd;
- off_t off;
- int num;
- size_t size;
+dophn_core(int class, int swap, int fd, off_t off, int num, size_t size)
{
Elf32_Phdr ph32;
- Elf32_Nhdr *nh32;
+ Elf32_Nhdr *nh32 = NULL;
Elf64_Phdr ph64;
- Elf64_Nhdr *nh64;
+ Elf64_Nhdr *nh64 = NULL;
size_t offset, nameoffset, noffset, reloffset;
unsigned char c;
int i, j;
char nbuf[BUFSIZ];
int bufsize;
- int is_freebsd;
+ int os_style = -1;
/*
* Loop through all the program headers.
@@ -283,7 +378,7 @@ dophn_core(class, swap, fd, off, num, size)
/*
* Check whether this note has the name "CORE" or
- * "FreeBSD".
+ * "FreeBSD", or "NetBSD-CORE".
*/
if (offset + nh_namesz >= bufsize) {
/*
@@ -310,17 +405,50 @@ dophn_core(class, swap, fd, off, num, size)
* doesn't include the terminating null in the
* name....
*/
- if ((nh_namesz == 4 &&
- strncmp(&nbuf[nameoffset], "CORE", 4) == 0) ||
- (nh_namesz == 5 &&
- strcmp(&nbuf[nameoffset], "CORE") == 0))
- is_freebsd = 0;
- else if ((nh_namesz == 8 &&
- strcmp(&nbuf[nameoffset], "FreeBSD") == 0))
- is_freebsd = 1;
- else
- continue;
- if (nh_type == NT_PRPSINFO) {
+ if (os_style == -1) {
+ if ((nh_namesz == 4 &&
+ strncmp(&nbuf[nameoffset],
+ "CORE", 4) == 0) ||
+ (nh_namesz == 5 &&
+ strcmp(&nbuf[nameoffset],
+ "CORE") == 0)) {
+ os_style = OS_STYLE_SVR4;
+ } else
+ if ((nh_namesz == 8 &&
+ strcmp(&nbuf[nameoffset],
+ "FreeBSD") == 0)) {
+ os_style = OS_STYLE_FREEBSD;
+ } else
+ if ((nh_namesz >= 11 &&
+ strncmp(&nbuf[nameoffset],
+ "NetBSD-CORE", 11) == 0)) {
+ os_style = OS_STYLE_NETBSD;
+ } else
+ continue;
+ printf(", %s-style", os_style_names[os_style]);
+ }
+
+ if (os_style == OS_STYLE_NETBSD &&
+ nh_type == NT_NETBSD_CORE_PROCINFO) {
+ uint32_t signo;
+
+ /*
+ * Extract the program name. It is at
+ * offset 0x7c, and is up to 32-bytes,
+ * including the terminating NUL.
+ */
+ printf(", from '%.31s'", &nbuf[offset + 0x7c]);
+
+ /*
+ * Extract the signal number. It is at
+ * offset 0x08.
+ */
+ memcpy(&signo, &nbuf[offset + 0x08],
+ sizeof(signo));
+ printf(" (signal %u)", getu32(swap, signo));
+ } else
+ if (os_style != OS_STYLE_NETBSD &&
+ nh_type == NT_PRPSINFO) {
/*
* Extract the program name. We assume
* it to be 16 characters (that's what it
@@ -399,19 +527,22 @@ dophn_core(class, swap, fd, off, num, size)
#endif
void
-tryelf(fd, buf, nbytes)
- int fd;
- unsigned char *buf;
- int nbytes;
+tryelf(int fd, unsigned char *buf, int nbytes)
{
union {
- int32 l;
- char c[sizeof (int32)];
+ int32_t l;
+ char c[sizeof (int32_t)];
} u;
int class;
int swap;
/*
+ * If we can't seek, it must be a pipe, socket or fifo.
+ */
+ if((lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))
+ fd = pipe2file(fd, buf, nbytes);
+
+ /*
* ELF executables have multiple section headers in arbitrary
* file locations and thus file(1) cannot determine it from easily.
* Instead we traverse thru all section headers until a symbol table
@@ -433,7 +564,7 @@ tryelf(fd, buf, nbytes)
u.l = 1;
(void) memcpy(&elfhdr, buf, sizeof elfhdr);
- swap = (u.c[sizeof(int32) - 1] + 1) != elfhdr.e_ident[5];
+ swap = (u.c[sizeof(int32_t) - 1] + 1) != elfhdr.e_ident[5];
if (getu16(swap, elfhdr.e_type) == ET_CORE)
#ifdef ELFCORE
@@ -470,7 +601,7 @@ tryelf(fd, buf, nbytes)
u.l = 1;
(void) memcpy(&elfhdr, buf, sizeof elfhdr);
- swap = (u.c[sizeof(int32) - 1] + 1) != elfhdr.e_ident[5];
+ swap = (u.c[sizeof(int32_t) - 1] + 1) != elfhdr.e_ident[5];
if (getu16(swap, elfhdr.e_type) == ET_CORE)
#ifdef ELFCORE
diff --git a/contrib/file/readelf.h b/contrib/file/readelf.h
index d0ae333..f7494de 100644
--- a/contrib/file/readelf.h
+++ b/contrib/file/readelf.h
@@ -1,6 +1,8 @@
+/* $NetBSD: readelf.h,v 1.9 2002/05/18 07:00:47 pooka Exp $ */
+
/*
* readelf.h
- * @(#)$Id: readelf.h,v 1.7 1999/02/14 17:16:11 christos Exp $
+ * @(#)Id: readelf.h,v 1.9 2002/05/16 18:45:56 christos Exp
*
* Provide elf data structures for non-elf machines, allowing file
* non-elf hosts to determine if an elf binary is stripped.
@@ -9,6 +11,10 @@
#ifndef __fake_elf_h__
#define __fake_elf_h__
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
typedef uint32_t Elf32_Addr;
typedef uint32_t Elf32_Off;
typedef uint16_t Elf32_Half;
@@ -166,6 +172,8 @@ typedef struct {
#define NT_PRPSINFO 3
#define NT_TASKSTRUCT 4
+#define NT_NETBSD_CORE_PROCINFO 1
+
/* Note header in a PT_NOTE section */
typedef struct elf_note {
Elf32_Word n_namesz; /* Name size */
@@ -186,4 +194,18 @@ typedef struct {
#define NT_PLATFORM 5
#define NT_AUXV 6
+/* Note types used in executables */
+/* NetBSD executables (name = "NetBSD") */
+#define NT_NETBSD_VERSION 1
+#define NT_NETBSD_EMULATION 2
+#define NT_FREEBSD_VERSION 1
+#define NT_OPENBSD_VERSION 1
+/* GNU executables (name = "GNU") */
+#define NT_GNU_VERSION 1
+
+/* GNU OS tags */
+#define GNU_OS_LINUX 0
+#define GNU_OS_HURD 1
+#define GNU_OS_SOLARIS 2
+
#endif
diff --git a/contrib/file/softmagic.c b/contrib/file/softmagic.c
index fc91615..891910c 100644
--- a/contrib/file/softmagic.c
+++ b/contrib/file/softmagic.c
@@ -25,39 +25,35 @@
* 4. This notice may not be removed or altered.
*/
-#include <stdio.h>
+#include "file.h"
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
-#include <sys/types.h>
+#include <regex.h>
-#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: softmagic.c,v 1.46 2001/07/23 00:02:32 christos Exp $")
+FILE_RCSID("@(#)$Id: softmagic.c,v 1.51 2002/07/03 18:26:38 christos Exp $")
#endif /* lint */
-static int match __P((struct magic *, uint32, unsigned char *, int));
-static int mget __P((union VALUETYPE *,
- unsigned char *, struct magic *, int));
-static int mcheck __P((union VALUETYPE *, struct magic *));
-static int32 mprint __P((union VALUETYPE *, struct magic *));
-static void mdebug __P((int32, char *, int));
-static int mconvert __P((union VALUETYPE *, struct magic *));
+static int match(struct magic *, uint32_t, unsigned char *, int);
+static int mget(union VALUETYPE *, unsigned char *, struct magic *, int);
+static int mcheck(union VALUETYPE *, struct magic *);
+static int32_t mprint(union VALUETYPE *, struct magic *);
+static void mdebug(int32_t, char *, int);
+static int mconvert(union VALUETYPE *, struct magic *);
extern int kflag;
/*
* softmagic - lookup one file in database
- * (already read from /etc/magic by apprentice.c).
+ * (already read from MAGIC by apprentice.c).
* Passed the name and FILE * of one file to be typed.
*/
/*ARGSUSED1*/ /* nbytes passed for regularity, maybe need later */
int
-softmagic(buf, nbytes)
- unsigned char *buf;
- int nbytes;
+softmagic(unsigned char *buf, int nbytes)
{
struct mlist *ml;
@@ -96,24 +92,20 @@ softmagic(buf, nbytes)
* so that higher-level continuations are processed.
*/
static int
-match(magic, nmagic, s, nbytes)
- struct magic *magic;
- uint32 nmagic;
- unsigned char *s;
- int nbytes;
+match(struct magic *magic, uint32_t nmagic, unsigned char *s, int nbytes)
{
int magindex = 0;
int cont_level = 0;
int need_separator = 0;
union VALUETYPE p;
- static int32 *tmpoff = NULL;
+ static int32_t *tmpoff = NULL;
static size_t tmplen = 0;
- int32 oldoff = 0;
+ int32_t oldoff = 0;
int returnval = 0; /* if a match is found it is set to 1*/
int firstline = 1; /* a flag to print X\n X\n- X */
if (tmpoff == NULL)
- if ((tmpoff = (int32 *) malloc(tmplen = 20)) == NULL)
+ if ((tmpoff = (int32_t *) malloc(tmplen = 20)) == NULL)
error("out of memory\n");
for (magindex = 0; magindex < nmagic; magindex++) {
@@ -144,7 +136,7 @@ match(magic, nmagic, s, nbytes)
need_separator = 1;
/* and any continuations that match */
if (++cont_level >= tmplen)
- if ((tmpoff = (int32 *) realloc(tmpoff,
+ if ((tmpoff = (int32_t *) realloc(tmpoff,
tmplen += 20)) == NULL)
error("out of memory\n");
while (magic[magindex+1].cont_level != 0 &&
@@ -191,7 +183,7 @@ match(magic, nmagic, s, nbytes)
*/
if (++cont_level >= tmplen)
if ((tmpoff =
- (int32 *) realloc(tmpoff,
+ (int32_t *) realloc(tmpoff,
tmplen += 20)) == NULL)
error("out of memory\n");
}
@@ -209,13 +201,11 @@ match(magic, nmagic, s, nbytes)
return returnval; /* This is hit if -k is set or there is no match */
}
-static int32
-mprint(p, m)
- union VALUETYPE *p;
- struct magic *m;
+static int32_t
+mprint(union VALUETYPE *p, struct magic *m)
{
- uint32 v;
- int32 t=0 ;
+ uint32_t v;
+ int32_t t=0 ;
switch (m->type) {
@@ -237,8 +227,8 @@ mprint(p, m)
case BELONG:
case LELONG:
v = signextend(m, p->l);
- (void) printf(m->desc, (uint32) v);
- t = m->offset + sizeof(int32);
+ (void) printf(m->desc, (uint32_t) v);
+ t = m->offset + sizeof(int32_t);
break;
case STRING:
@@ -271,6 +261,10 @@ mprint(p, m)
(void) printf(m->desc, fmttime(p->l, 0));
t = m->offset + sizeof(time_t);
break;
+ case REGEX:
+ (void) printf(m->desc, p->s);
+ t = m->offset + strlen(p->s);
+ break;
default:
error("invalid m->type (%d) in mprint().\n", m->type);
@@ -285,9 +279,7 @@ mprint(p, m)
* (unless you have a better idea)
*/
static int
-mconvert(p, m)
- union VALUETYPE *p;
- struct magic *m;
+mconvert(union VALUETYPE *p, struct magic *m)
{
switch (m->type) {
case BYTE:
@@ -445,7 +437,7 @@ mconvert(p, m)
case BELONG:
case BEDATE:
case BELDATE:
- p->l = (int32)
+ p->l = (int32_t)
((p->hl[0]<<24)|(p->hl[1]<<16)|(p->hl[2]<<8)|(p->hl[3]));
if (m->mask)
switch (m->mask_op&0x7F) {
@@ -512,7 +504,7 @@ mconvert(p, m)
case LELONG:
case LEDATE:
case LELDATE:
- p->l = (int32)
+ p->l = (int32_t)
((p->hl[3]<<24)|(p->hl[2]<<16)|(p->hl[1]<<8)|(p->hl[0]));
if (m->mask)
switch (m->mask_op&0x7F) {
@@ -544,6 +536,8 @@ mconvert(p, m)
if (m->mask_op & OPINVERSE)
p->l = ~p->l;
return 1;
+ case REGEX:
+ return 1;
default:
error("invalid type %d in mconvert().\n", m->type);
return 0;
@@ -552,10 +546,7 @@ mconvert(p, m)
static void
-mdebug(offset, str, len)
- int32 offset;
- char *str;
- int len;
+mdebug(int32_t offset, char *str, int len)
{
(void) fprintf(stderr, "mget @%d: ", offset);
showstr(stderr, (char *) str, len);
@@ -564,35 +555,40 @@ mdebug(offset, str, len)
}
static int
-mget(p, s, m, nbytes)
- union VALUETYPE* p;
- unsigned char *s;
- struct magic *m;
- int nbytes;
+mget(union VALUETYPE *p, unsigned char *s, struct magic *m, int nbytes)
{
- int32 offset = m->offset;
+ int32_t offset = m->offset;
- if (offset + sizeof(union VALUETYPE) <= nbytes)
+ if (m->type == REGEX) {
+ /*
+ * offset is interpreted as last line to search,
+ * (starting at 1), not as bytes-from start-of-file
+ */
+ char *last = NULL;
+ p->buf = s;
+ for (; offset && (s = strchr(s, '\n')) != NULL; offset--, s++)
+ last = s;
+ if (last != NULL)
+ *last = '\0';
+ } else if (offset + sizeof(union VALUETYPE) <= nbytes)
memcpy(p, s + offset, sizeof(union VALUETYPE));
else {
/*
* the usefulness of padding with zeroes eludes me, it
* might even cause problems
*/
- int32 have = nbytes - offset;
+ int32_t have = nbytes - offset;
memset(p, 0, sizeof(union VALUETYPE));
if (have > 0)
memcpy(p, s + offset, have);
}
-
if (debug) {
mdebug(offset, (char *) p, sizeof(union VALUETYPE));
mdump(m);
}
if (m->flag & INDIR) {
-
switch (m->in_type) {
case BYTE:
if (m->in_offset)
@@ -754,56 +750,56 @@ mget(p, s, m, nbytes)
if (m->in_offset)
switch (m->in_op&0x7F) {
case OPAND:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) &
m->in_offset;
break;
case OPOR:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) |
m->in_offset;
break;
case OPXOR:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) ^
m->in_offset;
break;
case OPADD:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) +
m->in_offset;
break;
case OPMINUS:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) -
m->in_offset;
break;
case OPMULTIPLY:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) *
m->in_offset;
break;
case OPDIVIDE:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) /
m->in_offset;
break;
case OPMODULO:
- offset = (int32)((p->hl[0]<<24)|
+ offset = (int32_t)((p->hl[0]<<24)|
(p->hl[1]<<16)|
(p->hl[2]<<8)|
(p->hl[3])) %
@@ -817,56 +813,56 @@ mget(p, s, m, nbytes)
if (m->in_offset)
switch (m->in_op&0x7F) {
case OPAND:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) &
m->in_offset;
break;
case OPOR:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) |
m->in_offset;
break;
case OPXOR:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) ^
m->in_offset;
break;
case OPADD:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) +
m->in_offset;
break;
case OPMINUS:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) -
m->in_offset;
break;
case OPMULTIPLY:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) *
m->in_offset;
break;
case OPDIVIDE:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) /
m->in_offset;
break;
case OPMODULO:
- offset = (int32)((p->hl[3]<<24)|
+ offset = (int32_t)((p->hl[3]<<24)|
(p->hl[2]<<16)|
(p->hl[1]<<8)|
(p->hl[0])) %
@@ -932,12 +928,10 @@ mget(p, s, m, nbytes)
}
static int
-mcheck(p, m)
- union VALUETYPE* p;
- struct magic *m;
+mcheck(union VALUETYPE *p, struct magic *m)
{
- uint32 l = m->value.l;
- uint32 v;
+ uint32_t l = m->value.l;
+ uint32_t v;
int matched;
if ( (m->value.s[0] == 'x') && (m->value.s[1] == '\0') ) {
@@ -971,7 +965,7 @@ mcheck(p, m)
case STRING:
case PSTRING:
- {
+ {
/*
* What we want here is:
* v = strncmp(m->value.s, p->s, m->vallen);
@@ -1016,6 +1010,21 @@ mcheck(p, m)
}
break;
}
+ case REGEX:
+ {
+ int rc;
+ regex_t rx;
+ char errmsg[512];
+
+ rc = regcomp(&rx, m->value.s, REG_EXTENDED|REG_NOSUB);
+ if (rc) {
+ regerror(rc, &rx, errmsg, sizeof(errmsg));
+ error("regex error %d, (%s)\n", rc, errmsg);
+ } else {
+ rc = regexec(&rx, p->buf, 0, 0, 0);
+ return !rc;
+ }
+ }
default:
error("invalid type %d in mcheck().\n", m->type);
return 0;/*NOTREACHED*/
@@ -1053,7 +1062,7 @@ mcheck(p, m)
v, l, matched);
}
else {
- matched = (int32) v > (int32) l;
+ matched = (int32_t) v > (int32_t) l;
if (debug)
(void) fprintf(stderr, "%d > %d = %d\n",
v, l, matched);
@@ -1068,7 +1077,7 @@ mcheck(p, m)
v, l, matched);
}
else {
- matched = (int32) v < (int32) l;
+ matched = (int32_t) v < (int32_t) l;
if (debug)
(void) fprintf(stderr, "%d < %d = %d\n",
v, l, matched);
OpenPOWER on IntegriCloud