Browse Source

Merge upstream version 3.28, import Debian version 3.28-1

Nicolás Lichtmaier 25 years ago
parent
commit
04b4c5a4b1
77 changed files with 3840 additions and 1225 deletions
  1. 29 26
      LEGAL.NOTICE
  2. 7 4
      Magdir/amanda
  3. 83 1
      Magdir/animation
  4. 0 1
      Magdir/apple
  5. 12 4
      Magdir/archive
  6. 16 7
      Magdir/audio
  7. 0 111
      Magdir/audio.orig
  8. 18 0
      Magdir/communications
  9. 3 3
      Magdir/compress
  10. 56 5
      Magdir/database
  11. 5 0
      Magdir/diff
  12. 28 3
      Magdir/elf
  13. 34 16
      Magdir/filesystems
  14. 2 0
      Magdir/fonts
  15. 7 3
      Magdir/gimp
  16. 1 0
      Magdir/gnu
  17. 20 0
      Magdir/grace
  18. 28 28
      Magdir/hp
  19. 28 16
      Magdir/images
  20. 1 0
      Magdir/java
  21. 61 0
      Magdir/jpeg
  22. 1 1
      Magdir/karma
  23. 123 0
      Magdir/kleff
  24. 43 22
      Magdir/linux
  25. 7 2
      Magdir/mach
  26. 31 0
      Magdir/mcrypt
  27. 6 0
      Magdir/misctools
  28. 20 0
      Magdir/motorola
  29. 19 5
      Magdir/msdos
  30. 0 39
      Magdir/net
  31. 25 4
      Magdir/netbsd
  32. 1 0
      Magdir/octave
  33. 34 10
      Magdir/os2
  34. 15 0
      Magdir/palm
  35. 0 7
      Magdir/ppd
  36. 2 0
      Magdir/printer
  37. 28 14
      Magdir/sgml
  38. 18 12
      Magdir/sniffer
  39. 28 0
      Magdir/spectrum
  40. 1 0
      Magdir/ti-8x
  41. 5 1
      Magdir/varied.out
  42. 13 0
      Magdir/wordprocessors
  43. 79 0
      Makefile.am
  44. 529 177
      Makefile.in
  45. 2 2
      Makefile.std
  46. 0 76
      PORTING
  47. 3 3
      README
  48. 42 0
      acconfig.h
  49. 79 0
      acinclude.m4
  50. 207 0
      aclocal.m4
  51. 10 3
      apprentice.c
  52. 4 5
      ascmagic.c
  53. 7 5
      compress.c
  54. 55 15
      config.h.in
  55. 1069 281
      configure
  56. 57 5
      configure.in
  57. 1 1
      debian/control
  58. 5 4
      debian/README.debian
  59. 26 14
      debian/rules
  60. 35 13
      file.c
  61. 21 19
      file.h
  62. 68 19
      file.man
  63. 75 20
      fsmagic.c
  64. 6 10
      is_tar.c
  65. 1 1
      magic.man
  66. 49 34
      magic2mime
  67. 26 0
      magic2mime.man
  68. 190 0
      missing
  69. 40 0
      mkinstalldirs
  70. 1 2
      names.h
  71. 14 2
      patchlevel.h
  72. 16 18
      print.c
  73. 223 112
      readelf.c
  74. 33 19
      readelf.h
  75. 6 15
      softmagic.c
  76. 1 0
      stamp-h.in
  77. 1 5
      tar.h

+ 29 - 26
LEGAL.NOTICE

@@ -1,31 +1,34 @@
+$Id: LEGAL.NOTICE,v 1.11 1999/01/14 16:30:12 christos Exp $
 Copyright (c) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992, 1994, 1995.
-Software written by Ian F. Darwin and others; maintained by Christos Zoulas.
-$Id: LEGAL.NOTICE,v 1.9 1995/10/27 23:14:20 christos Exp $
-
-This software (or derivative software) may not be made subject to any 
-license which denies anyone permission to alter it and redistribute it 
-freely.  Derivative software must also still fall under this license.
+Software written by Ian F. Darwin and others;
+maintained 1994-1999 Christos Zoulas.
 
 This software is not subject to any export provision of the United States
 Department of Commerce, and may be exported to any country or planet.
 
-Permission is granted to anyone to use this software for any purpose on
-any computer system, and to alter it and redistribute it freely, subject
-to the following restrictions:
-
-1. The author is not responsible for the consequences of use of this
-   software, no matter how awful, even if they arise from flaws in it.
-
-2. The origin of this software must not be misrepresented, either by
-   explicit claim or by omission.  Since few users ever read sources,
-   credits must appear in the documentation.
-
-3. Altered versions must be plainly marked as such, and must not be
-   misrepresented as being the original software.  Since few users
-   ever read sources, credits must appear in the documentation.
-   Derivative works must also be marked as such, and credits must appear
-   in the documentation.
-
-4. This notice may not be removed or altered.
-
-
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice immediately at the beginning of the file, without modification,
+   this list of conditions, and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. All advertising materials mentioning features or use of this software
+   must display the following acknowledgement:
+   This product includes software developed by Ian F. Darwin and others.
+4. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+ 
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.

+ 7 - 4
Magdir/amanda

@@ -1,7 +1,10 @@
 #------------------------------------------------------------------------------
 # amanda:  file(1) magic for amanda file format
 #
-0       string          AMANDA:\ TAPESTART\ DATE     AMANDA dump header file,
->23     string          X
->>25    string          >\                           Unused %s
->23     string          >\                           DATE %s
+0	string	AMANDA:\ 		AMANDA 
+>8	string	TAPESTART\ DATE		tape header file,
+>>23	string	X
+>>>25	string	>\ 			Unused %s
+>>23	string	>\ 			DATE %s
+>8	string	FILE\ 			dump file,
+>>13	string	>\ 			DATE %s

+ 83 - 1
Magdir/animation

@@ -11,7 +11,89 @@
 #>4	beshort&0xfff0	x			(%d x
 #>5	beshort&0x0fff  x			%d)
 0	belong		0x000001ba		MPEG system stream data
-0	beshort&0xfff0	0xfff0			MPEG audio stream data
+# MPEG Audio (*.mpx)
+# from dreesen@math.fu-berlin.de
+0	beshort		&0xffe0		MPEG
+# MPEG 1.0
+>1	byte&0x08	=0x08		\b 1.0
+# Layer 3
+>>1	byte		&0x02		\b layer 3 audio stream data
+>>>2	byte&0xf0	=0x10		\b,  32 kBit/s
+>>>2	byte&0xf0	=0x20		\b,  40 kBit/s
+>>>2	byte&0xf0	=0x30		\b,  48 kBit/s
+>>>2	byte&0xf0	=0x40		\b,  56 kBit/s
+>>>2	byte&0xf0	=0x50		\b,  64 kBit/s
+>>>2	byte&0xf0	=0x60		\b,  80 kBit/s
+>>>2	byte&0xf0	=0x70		\b,  96 kBit/s
+>>>2	byte&0xf0	=0x80		\b, 112 kBit/s
+>>>2	byte&0xf0	=0x90		\b, 128 kBit/s
+>>>2	byte&0xf0	=0xA0		\b, 160 kBit/s
+>>>2	byte&0xf0	=0xB0		\b, 192 kBit/s
+>>>2	byte&0xf0	=0xC0		\b, 224 kBit/s
+>>>2	byte&0xf0	=0xD0		\b, 256 kBit/s
+>>>2	byte&0xf0	=0xE0		\b, 320 kBit/s
+# Layer 2
+>>1	byte		&0x04		\b layer 2 audio stream data
+>>>2	byte&0xf0	=0x10		\b,  32 kBit/s
+>>>2	byte&0xf0	=0x20		\b,  48 kBit/s
+>>>2	byte&0xf0	=0x30		\b,  56 kBit/s
+>>>2	byte&0xf0	=0x40		\b,  64 kBit/s
+>>>2	byte&0xf0	=0x50		\b,  80 kBit/s
+>>>2	byte&0xf0	=0x60		\b,  96 kBit/s
+>>>2	byte&0xf0	=0x70		\b, 112 kBit/s
+>>>2	byte&0xf0	=0x80		\b, 128 kBit/s
+>>>2	byte&0xf0	=0x90		\b, 160 kBit/s
+>>>2	byte&0xf0	=0xA0		\b, 192 kBit/s
+>>>2	byte&0xf0	=0xB0		\b, 224 kBit/s
+>>>2	byte&0xf0	=0xC0		\b, 256 kBit/s
+>>>2	byte&0xf0	=0xD0		\b, 320 kBit/s
+>>>2	byte&0xf0	=0xE0		\b, 384 kBit/s
+# freq
+>>2	byte&0x0C	=0x00		\b, 44.1 kHz
+>>2	byte&0x0C	=0x04		\b, 48 kHz
+>>2	byte&0x0C	=0x08		\b, 32 kHz
+# MPEG 2.5
+>1	byte&0x18	=0x00		\b 2.5
+# Layer 3
+>>1	byte		&0x02		\b layer 3 audio stream data
+# Layer 2
+>>1	byte		&0x04		\b layer 2 audio stream data
+# MPEG 2.0
+>1	byte&0x18	=0x10		\b 2.0
+# Layer 3
+>>1	byte		&0x02		\b layer 3 audio stream data
+# Layer 2
+>>1	byte		&0x04		\b layer 2 audio stream data
+>>2	byte&0xf0	=0x10		\b,  8 kBit/s
+>>2	byte&0xf0	=0x20		\b,  16 kBit/s
+>>2	byte&0xf0	=0x30		\b,  24 kBit/s
+>>2	byte&0xf0	=0x40		\b,  32 kBit/s
+>>2	byte&0xf0	=0x50		\b,  40 kBit/s
+>>2	byte&0xf0	=0x60		\b,  48 kBit/s
+>>2	byte&0xf0	=0x70		\b,  56 kBit/s
+>>2	byte&0xf0	=0x80		\b,  64 kBit/s
+>>2	byte&0xf0	=0x90		\b,  80 kBit/s
+>>2	byte&0xf0	=0xA0		\b,  96 kBit/s
+>>2	byte&0xf0	=0xB0		\b, 112 kBit/s
+>>2	byte&0xf0	=0xC0		\b, 128 kBit/s
+>>2	byte&0xf0	=0xD0		\b, 144 kBit/s
+>>2	byte&0xf0	=0xE0		\b, 160 kBit/s
+# freq
+>>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
+>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
 
 # FLI animation format
 4	leshort		0xAF11			FLI file

+ 0 - 1
Magdir/apple

@@ -4,7 +4,6 @@
 #
 0	string		FiLeStArTfIlEsTaRt	binscii (apple ][) text
 0	string		\x0aGL			Binary II (apple ][) data
-0	string		\x76\xff		Squeezed (apple ][) data
 0	string		NuFile			NuFile archive (apple ][) data
 0	string		N\xf5F\xe9l\xe5		NuFile archive (apple ][) data
 0	belong		0x00051600		AppleSingle encoded Macintosh file

+ 12 - 4
Magdir/archive

@@ -216,7 +216,15 @@
 10	string		#\ This\ is\ a\ shell\ archive	shell archive text
 
 #
-# Debian Packages, from Peter Tobias <tobias@server.et-inf.fho-emden.de>
-#0	string		0.9
-#>8	byte		0x0a		old Debian binary package
-#>>3	string		>\n		(format 0.9%s)
+# LBR. NB: May conflict with the questionable 
+#          "binary Computer Graphics Metafile" format.
+#
+0       string  \0\ \ \ \ \ \ \ \ \ \ \ \0\0    LBR archive data
+#
+# PMA (CP/M derivative of LHA)
+#
+2       string          -pm0-           PMarc archive data [pm0]
+2       string          -pm1-           PMarc archive data [pm1]
+2       string          -pm2-           PMarc archive data [pm2]
+2       string          -pms-           PMarc SFX archive (CP/M, DOS)
+5       string          -pc1-           PopCom compressed executable (CP/M)

+ 16 - 7
Magdir/audio

@@ -67,16 +67,17 @@
 >83	byte		1		(song)
 
 # Real Audio (Magic .ra\0375)
-0	belong		0x2e7261fd	realaudio sound file
+0	belong		0x2e7261fd	RealAudio sound file
+0	string		.RMF		RealMedia file
 
 # MTM/669/FAR/S3M/ULT/XM format checking [Aaron Eppert, aeppert@dialin.ind.net]
 # Oct 31, 1995
-0	string		MTM		MultiTracker Module sound data
-0	string		if		Composer 669 Module sound data
+0	string		MTM		MultiTracker Module sound file
+#0	string		if		Composer 669 Module sound data
 0	string		FAR		Module sound data
-#0	string		MAS_U		ULT(imate) Module sound data
+0	string		MAS_U		ULT(imate) Module sound data
 0x2c	string		SCRM		ScreamTracker III Module sound data
-#0	string		Extended Module	Extended Module sound data
+0	string		Extended Module	Extended Module sound data
 
 # Gravis UltraSound patches
 # From <ache@nagual.ru>
@@ -101,11 +102,19 @@
 1080	string	8CHN		8-channel Fasttracker module sound data
 1080	string	CD81		8-channel Oktalyzer module sound data
 1080	string	OKTA		8-channel Oktalyzer module sound data
-1082	string	CH
->1080	string	>/0		%.2s-channel Fasttracker "oktalyzer" module sound data
+#1082	string	CH
+#>1080	string	>/0		%.2s-channel Fasttracker "oktalyzer" module sound data
 1080	string	16CN		16-channel Taketracker module sound data
 1080	string	32CN		32-channel Taketracker module sound data
 
 # TOC sound files -Trevor Johnson <trevor@jpj.net>
 #
 0       string          TOC             TOC sound file
+
+# sidfiles <pooka@iki.fi>
+0	string		SIDPLAY\ INFOFILE	Sidplay info file
+0	string		PSID			PlaySID v2.2+ (AMIGA) sidtune
+>4	beshort		>0			w/ header v%d,
+>14	beshort		=1			single song,
+>14	beshort		>1			%d songs,
+>16	beshort		>0			default song: %d

+ 0 - 111
Magdir/audio.orig

@@ -1,111 +0,0 @@
-
-#------------------------------------------------------------------------------
-# audio:  file(1) magic for sound formats (see also "iff")
-#
-# Jan Nicolai Langfeldt (janl@ifi.uio.no), Dan Quinlan (quinlan@yggdrasil.com),
-# and others
-#
-
-# Sun/NeXT audio data
-0	string		.snd		Sun/NeXT audio data:
->12	belong		1		8-bit ISDN u-law,
->12	belong		2		8-bit linear PCM [REF-PCM],
->12	belong		3		16-bit linear PCM,
->12	belong		4		24-bit linear PCM,
->12	belong		5		32-bit linear PCM,
->12	belong		6		32-bit IEEE floating point,
->12	belong		7		64-bit IEEE floating point,
->12	belong		23		8-bit ISDN u-law compressed (CCITT G.721 ADPCM voice data encoding),
->12	belong		24		compressed (8-bit G.722 ADPCM)
->12	belong		25		compressed (3-bit G.723 ADPCM),
->12	belong		26		compressed (5-bit G.723 ADPCM),
->12	belong		27		8-bit A-law,
->20	belong		1		mono,
->20	belong		2		stereo,
->20	belong		4		quad,
->16	belong		>0		%d Hz
-
-# DEC systems (e.g. DECstation 5000) use a variant of the Sun/NeXT format
-# that uses little-endian encoding and has a different magic number
-0	lelong		0x0064732E	DEC audio data:
->12	lelong		1		8-bit ISDN u-law,
->12	lelong		2		8-bit linear PCM [REF-PCM],
->12	lelong		3		16-bit linear PCM,
->12	lelong		4		24-bit linear PCM,
->12	lelong		5		32-bit linear PCM,
->12	lelong		6		32-bit IEEE floating point,
->12	lelong		7		64-bit IEEE floating point,
->12	lelong		23		8-bit ISDN u-law compressed (CCITT G.721 ADPCM voice data encoding),
->20	lelong		1		mono,
->20	lelong		2		stereo,
->20	lelong		4		quad,
->16	lelong		>0		%d Hz
-
-# Creative Labs AUDIO stuff
-0	string	MThd			Standard MIDI data
->9 	byte	>0			(format %d)
->11	byte	>1			using %d tracks
-0	string	CTMF			Creative Music (CMF) data
-0	string	SBI			SoundBlaster instrument data
-0	string	Creative\ Voice\ File	Creative Labs voice data
-# is this next line right?  it came this way...
->19	byte	0x1A
->23	byte	>0			- version %d
->22	byte	>0			\b.%d
-
-# first entry is also the string "NTRK"
-0	belong		0x4e54524b	MultiTrack sound data
->4	belong		x		- version %ld
-
-# Extended MOD format (*.emd) (Greg Roelofs, newt@uchicago.edu); NOT TESTED
-# [based on posting 940824 by "Dirk/Elastik", husberg@lehtori.cc.tut.fi]
-0	string		EMOD		Extended MOD sound data,
->4	byte&0xf0	x		version %d
->4	byte&0x0f	x		\b.%d,
->45	byte		x		%d instruments
->83	byte		0		(module)
->83	byte		1		(song)
-
-# Real Audio (Magic .ra\0375)
-0	belong		0x2e7261fd	realaudio sound file
-
-# MTM/669/FAR/S3M/ULT/XM format checking [Aaron Eppert, aeppert@dialin.ind.net]
-# Oct 31, 1995
-0	string		MTM		MultiTracker Module sound file
-0	string		if		Composer 669 Module sound data
-0	string		FAR		Module sound data
-0	string		MAS_U		ULT(imate) Module sound data
-0x2c	string		SCRM		ScreamTracker III Module sound data
-0	string		Extended Module	Extended Module sound data
-
-# Gravis UltraSound patches
-# From <ache@nagual.ru>
-
-0	string		GF1PATCH110\0ID#000002\0	GUS patch
-0	string		GF1PATCH100\0ID#000002\0	Old GUS	patch
-
-#
-# Taken from loader code from mikmod version 2.14
-# by Steve McIntyre (stevem@chiark.greenend.org.uk)
-0	string	JN		extended 669 module data
-0	string	MAS_UTrack_V00
->14	string	>/0		ultratracker V1.%.1s module sound data
-0	string	UN05		MikMod UNI format module sound data
-0	string	Extended\ Module: Fasttracker II module sound data
-21	string	!SCREAM!	Screamtracker 2 module sound data
-1080	string	M.K.		4-channel Protracker module sound data
-1080	string	M!K!		4-channel Protracker module sound data
-1080	string	FLT4		4-channel Startracker module sound data
-1080	string	4CHN		4-channel Fasttracker module sound data
-1080	string	6CHN		6-channel Fasttracker module sound data
-1080	string	8CHN		8-channel Fasttracker module sound data
-1080	string	CD81		8-channel Oktalyzer module sound data
-1080	string	OKTA		8-channel Oktalyzer module sound data
-1082	string	CH
->1080	string	>/0		%.2s-channel Fasttracker "oktalyzer" module sound data
-1080	string	16CN		16-channel Taketracker module sound data
-1080	string	32CN		32-channel Taketracker module sound data
-
-# TOC sound files -Trevor Johnson <trevor@jpj.net>
-#
-0       string          TOC             TOC sound file

+ 18 - 0
Magdir/communications

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

+ 3 - 3
Magdir/compress

@@ -61,11 +61,11 @@
 
 # squeeze and crunch
 # Michael Haardt <michael@cantor.informatik.rwth-aachen.de>
-0	leshort		0xFF76		squeezed data,
+0	beshort		0x76FF		squeezed data,
 >4	string		x		original name %s
-0	leshort		0xFE76		crunched data,
+0	beshort		0x76FE		crunched data,
 >2	string		x		original name %s
-0	leshort		0xFD76		LZH compressed data,
+0	beshort		0x76FD		LZH compressed data,
 >2	string		x		original name %s
 
 # Freeze

+ 56 - 5
Magdir/database

@@ -12,10 +12,12 @@
 0	lelong	0x13579ace	GNU dbm 1.x or ndbm database, little endian
 0	string	GDBM		GNU dbm 2.x database
 #
-0	belong	0x061561	Berkeley DB Hash file
+0	belong	0x061561	Berkeley DB
+>4	belong	>2		1.86
+>4	belong	<3		1.85
+>8	belong	4321		Hash/Big Endian
+>8	belong	1234		Hash/Little Endian
 >4	belong	>0		(Version %d,
->8	belong	1234		Little Endian,
->8	belong	4321		Big Endian,
 >12	belong	x		Bucket Size %d,
 >16	belong	x		Bucket Shift %d,
 >20	belong	x		Directory Size %d,
@@ -30,15 +32,64 @@
 >56	belong	x		Number of Keys %d)
 #
 #
-0	belong	0x053162	Berkeley DB Btree file/Big Endian
+0	belong	0x053162	Berkeley DB 1.85/1.86 Btree/Big Endian
 >4	belong	>0		(Version %d,
 >8	belong	x		Page Size %d,
 >12	belong	x		Free Page %d,
 >16	belong	x		Number of Records %d,
 >20	belong	x		Flags 0x%x)
-0	lelong	0x053162	Berkeley DB Btree file/Little Endian
+0	lelong	0x053162	Berkeley DB 1.85/1.86 Btree/Little Endian
 >4	lelong	>0		(Version %d,
 >8	lelong	x		Page Size %d,
 >12	lelong	x		Free Page %d,
 >16	lelong	x		Number of Records %d,
 >20	lelong	x		Flags 0x%x)
+#
+#
+12	belong	0x061561	Berkeley DB 2.X Hash/Big Endian
+>16	belong	>0		(Version %d,
+>0	belong  x		Logical sequence number: file - %d,
+>4	belong  x		offset - %d,
+>20	belong	x		Bucket Size %d,
+>24	belong	x		Overflow Point %d,
+>28	belong	x		Last Freed %d,
+>32	belong	x		Max Bucket %d,
+>36	belong	x		High Mask 0x%x,
+>40	belong	x		Low Mask 0x%x,
+>44	belong	x		Fill Factor %d,
+>48	belong	x		Number of Keys %d)
+#
+# DB2.X formats from Khimenko Victor <khim@sch57.msk.ru>
+#
+12	lelong	0x061561	Berkeley DB 2.X Hash/Little Endian
+>16	lelong	>0		(Version %d,
+>0	lelong  x		Logical sequence number: file - %d,
+>4	lelong  x		offset - %d,
+>20	lelong	x		Bucket Size %d,
+>24	lelong	x		Overflow Point %d,
+>28	lelong	x		Last Freed %d,
+>32	lelong	x		Max Bucket %d,
+>36	lelong	x		High Mask 0x%x,
+>40	lelong	x		Low Mask 0x%x,
+>44	lelong	x		Fill Factor %d,
+>48	lelong	x		Number of Keys %d)
+#
+#
+12	belong	0x053162	Berkeley DB 2.X Btree/Big Endian
+>16	belong	>0		(Version %d, 
+>0	belong  x		Logical sequence number: file - %d,
+>4	belong  x		offset - %d,
+>20	belong	x		Page Size %d,
+>24	belong	x		Maxkey %d,
+>28	belong	x		Minkey %d,
+>32	belong	x		Free Page %d)
+#
+#
+12	lelong	0x053162	Berkeley DB 2.X Btree/Little Endian
+>16	lelong	>0		(Version %d,
+>0	lelong  x		Logical sequence number: file - %d,
+>4	lelong  x		offset - %d,
+>20	lelong	x		Page Size %d,
+>24	lelong	x		Maxkey %d,
+>28	lelong	x		Minkey %d,
+>32	lelong	x		Free Page %d)

+ 5 - 0
Magdir/diff

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

+ 28 - 3
Magdir/elf

@@ -12,6 +12,9 @@
 0	string		\177ELF		ELF
 >4	byte		0		invalid class
 >4	byte		1		32-bit
+# only for MIPS R3000_BE
+>>18	beshort		8
+>>>36   belong          &0x20           N32
 >4	byte		2		64-bit
 >5	byte		0		invalid byte order
 >5	byte		1		LSB
@@ -56,7 +59,7 @@
 >>18	leshort		47		Hitachi H8/300H,
 >>18	leshort		48		Hitachi H8S,
 >>18	leshort		49		Hitachi H8/500,
->>18	leshort		50		Intel Merced Processor,
+>>18	leshort		50		IA-64 (Intel 64 bit architecture)
 >>18	leshort		51		Stanford MIPS-X,
 >>18	leshort		52		Motorola Coldfire,
 >>18	leshort		53		Motorola M68HC12,
@@ -66,6 +69,24 @@
 >>36	lelong		1		MathCoPro/FPU/MAU Required
 >8	string		>\0		(%s)
 >5	byte		2		MSB
+# only for MIPS R3000_BE
+>>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
+# 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
 >>16	beshort		0		no file type,
 >>16	beshort		1		relocatable,
 >>16	beshort		2		executable,
@@ -90,6 +111,10 @@
 >>18	beshort		16		nCUBE,
 >>18	beshort		17		Fujitsu VPP500,
 >>18	beshort		18		SPARC32PLUS,
+>>>36	belong&0xffff00	&0x000100	V8+ Required,
+>>>36	belong&0xffff00	&0x000200	Sun UltraSPARC1 Extensions Required,
+>>>36	belong&0xffff00	&0x000400	HaL R1 Extensions Required,
+>>>36	belong&0xffff00	&0x000800	Sun UltraSPARC3 Extensions Required,
 >>18	beshort		20		PowerPC or cisco 4500,
 >>18	beshort		21		cisco 7500,
 >>18	beshort		24		cisco SVIP,
@@ -100,8 +125,8 @@
 >>18	beshort		39		Motorola RCE,
 >>18	beshort		40		Advanced RISC Machines ARM,
 >>18	beshort		41		Alpha,
->>18	leshort		42		Hitachi SH,
->>18	beshort		43		SPARC V9 - invalid byte order,
+>>18	beshort		42		Hitachi SH,
+>>18	beshort		43		SPARC V9,
 >>18	beshort		44		Siemens Tricore Embedded Processor,
 >>18	beshort		45		Argonaut RISC Core, Argonaut Technologies Inc.,
 >>18	beshort		46		Hitachi H8/300,

+ 34 - 16
Magdir/filesystems

@@ -24,22 +24,25 @@
 >0770	long		x		%ld blocks
 # Is there a boot block written 1 sector in?
 >512    belong&077777777	0600407	\b, boot block present
-0x1FE	leshort	0xAA55			x86 boot sector
->2	string	OSBS			\b, OS/BS MBR
->0x8C	string	Invalid\ partition\ table	\b, MS-DOS MBR
->0	string	\0\0\0\0		\b, extended partition table
->0	leshort 0x3CEB			\b, system
->>3	string	>\0			%s
->>0x36	string	FAT			\b, %s
->>>0x39	string	12			(%s bit)
->>>0x39	string	16			(%s bit)
->>>43	string		>NO\ NAME	label: %.11s,
->>>43	string		<NO\ NAME	label: %.11s,
->>>43	string		NO\ NAME	unlabeled,
->>>19	leshort		>0		%d sectors
->>>19	leshort		0		
->>>>32	lelong		x		%d sectors
->0x200	lelong	0x82564557		\b, BSD disklabel
+
+# Moved to linux.
+#0x1FE	leshort	0xAA55			x86 boot sector
+#>2	string	OSBS			\b, OS/BS MBR
+#>0x8C	string	Invalid\ partition\ table	\b, MS-DOS MBR
+#>0	string	\0\0\0\0		\b, extended partition table
+#>0	leshort 0x3CEB			\b, system
+#>>3	string	>\0			%s
+#>>0x36	string	FAT			\b, %s
+#>>>0x39	string	12			(%s bit)
+#>>>0x39	string	16			(%s bit)
+#>0x52	string	FAT32			\b, FAT (32 bit)
+#>>>43	string		>NO\ NAME	label: %.11s,
+#>>>43	string		<NO\ NAME	label: %.11s,
+#>>>43	string		NO\ NAME	unlabeled,
+#>>>19	leshort		>0		%d sectors
+#>>>19	leshort		0		
+#>>>>32	lelong		x		%d sectors
+#>0x200	lelong	0x82564557		\b, BSD disklabel
 
 # Minix filesystems - Juan Céspedes <cespedes@debian.org>
 0x410	leshort		0x137f		Minix filesystem
@@ -60,3 +63,18 @@
 >4	lelong&0xFFFFFF00	!0	unknown mode
 
 0x18b	string	OS/2	OS/2 Boot Manager
+
+9564	lelong		0x00011954	Unix Fast File system,
+>8404	string		x		last mounted on %s,
+>9504	ledate		x		last checkd at %s,
+>8224	ledate		x		last writen at %s,
+>8228	lelong		x		number of blocks %d,
+>8232	lelong		x		number of data blocks %d,
+>8236	lelong		x		number of cylinder groups %d,
+>8240	lelong		x		number of basic blocks %d,
+>8244	lelong		x		number of fragment blocks %d,
+>8248	lelong		x		minimum percentage of free blocks %d,
+>8252	lelong		x		rotational delay %dms,
+>8256	lelong		x		disk rotational speed %drps,
+>8320	lelong		0		TIME optimization
+>8320	lelong		1		SPACE optimization

+ 2 - 0
Magdir/fonts

@@ -46,3 +46,5 @@
 7	belong		0x00564944	DOS code page font data (from Linux?)
 4098	string		DOSFONT		DOSFONT2 encrypted font data
 
+# Windows fonts
+0	belong		0x00010000	MS Windows true type font

+ 7 - 3
Magdir/gimp

@@ -9,12 +9,16 @@
 #       by Spencer Kimball and Peter Mattis
 #       ('Bucky' LaDieu, nega@vt.edu)
 
-0       string          gimp\ xcf\ file GIMP XCF image data,
->14     belong          x               %ld x
->18     belong          x               %ld,
+0	string		gimp\ xcf	GIMP XCF image data,
+>9	string		file		version 0,
+>9	string		v		version
+>>10	string		>\0		%s,
+>14	belong		x		%lu x
+>18	belong		x		%lu,
 >22     belong          0               RGB Color
 >22     belong          1               Greyscale
 >22     belong          2               Indexed Color
+>22	belong		>2		Unknown Image Type.
 
 #------------------------------------------------------------------------------
 # XCF:  file(1) magic for the patterns used in the GIMP, developed

+ 1 - 0
Magdir/gnu

@@ -1,3 +1,4 @@
+
 #
 # GNU nlsutils message catalog file format
 #

+ 20 - 0
Magdir/grace

@@ -0,0 +1,20 @@
+
+#------------------------------------------------------------------------------
+# ACE/gr and Grace type files - PLEASE DO NOT REMOVE THIS LINE
+#
+# ACE/gr binary
+0	string	\000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003		old ACE/gr binary file
+>39	byte	>0			- version %c
+# ACE/gr ascii
+0	string	#\ xvgr\ parameter\ file	ACE/gr ascii file
+0	string	#\ xmgr\ parameter\ file	ACE/gr ascii file
+0	string	#\ ACE/gr\ parameter\ file	ACE/gr ascii file
+# Grace projects
+0	string	#\ Grace\ project\ file		Grace project file
+>23	string	@version\  			(version
+>>32	byte	>0 				%c
+>>33	string	>\0 				\b.%.2s
+>>35	string	>\0 				\b.%.2s)
+# ACE/gr fit description files
+0	string	#\ ACE/gr\ fit\ description\ 	ACE/gr fit description file
+# end of ACE/gr and Grace type files - PLEASE DO NOT REMOVE THIS LINE

+ 28 - 28
Magdir/hp

@@ -51,7 +51,7 @@
 #### PA-RISC 1.1
 0	belong 		0x02100106	PA-RISC1.1 relocatable object
 0	belong 		0x02100107	PA-RISC1.1 executable
->168	belong		&=0x00000004	dynamically linked
+>168	belong		&0x00000004	dynamically linked
 >(144)	belong		0x054ef630	dynamically linked
 >96	belong		>0		- not stripped
 
@@ -75,17 +75,17 @@
 0	belong		0x02140106	PA-RISC2.0 relocatable object
 
 0       belong		0x02140107	PA-RISC2.0 executable
->168	belong		&=0x00000004	dynamically linked
+>168	belong		&0x00000004	dynamically linked
 >(144)	belong		0x054ef630	dynamically linked
 >96	belong		>0		- not stripped
 
 0       belong		0x02140108	PA-RISC2.0 shared executable
->168	belong		&=0x00000004	dynamically linked
+>168	belong		&0x00000004	dynamically linked
 >(144)	belong		0x054ef630	dynamically linked
 >96	belong		>0		- not stripped
 
 0       belong		0x0214010b	PA-RISC2.0 demand-load executable
->168	belong		&=0x00000004	dynamically linked
+>168	belong		&0x00000004	dynamically linked
 >(144)	belong		0x054ef630	dynamically linked
 >96	belong		>0		- not stripped
 
@@ -205,30 +205,30 @@
 # addendum to /etc/magic with HP-48sx file-types by phk@data.fls.dk 1jan92
 0	string		HPHP48-		HP48 binary
 >7	byte		>0		- Rev %c
->8	short		0x1129		(ADR)
->8	short		0x3329		(REAL)
->8	short		0x5529		(LREAL)
->8	short		0x7729		(COMPLX)
->8	short		0x9d29		(LCOMPLX)
->8	short		0xbf29		(CHAR)
->8	short		0xe829		(ARRAY)
->8	short		0x0a2a		(LNKARRAY)
->8	short		0x2c2a		(STRING)
->8	short		0x4e2a		(HXS)
->8	short		0x742a		(LIST)
->8	short		0x962a		(DIR)
->8	short		0xb82a		(ALG)
->8	short		0xda2a		(UNIT)
->8	short		0xfc2a		(TAGGED)
->8	short		0x1e2b		(GROB)
->8	short		0x402b		(LIB)
->8	short		0x622b		(BACKUP)
->8	short		0x882b		(LIBDATA)
->8	short		0x9d2d		(PROG)
->8	short		0xcc2d		(CODE)
->8	short		0x482e		(GNAME)
->8	short		0x6d2e		(LNAME)
->8	short		0x922e		(XLIB)
+>8	beshort		0x1129		(ADR)
+>8	beshort		0x3329		(REAL)
+>8	beshort		0x5529		(LREAL)
+>8	beshort		0x7729		(COMPLX)
+>8	beshort		0x9d29		(LCOMPLX)
+>8	beshort		0xbf29		(CHAR)
+>8	beshort		0xe829		(ARRAY)
+>8	beshort		0x0a2a		(LNKARRAY)
+>8	beshort		0x2c2a		(STRING)
+>8	beshort		0x4e2a		(HXS)
+>8	beshort		0x742a		(LIST)
+>8	beshort		0x962a		(DIR)
+>8	beshort		0xb82a		(ALG)
+>8	beshort		0xda2a		(UNIT)
+>8	beshort		0xfc2a		(TAGGED)
+>8	beshort		0x1e2b		(GROB)
+>8	beshort		0x402b		(LIB)
+>8	beshort		0x622b		(BACKUP)
+>8	beshort		0x882b		(LIBDATA)
+>8	beshort		0x9d2d		(PROG)
+>8	beshort		0xcc2d		(CODE)
+>8	beshort		0x482e		(GNAME)
+>8	beshort		0x6d2e		(LNAME)
+>8	beshort		0x922e		(XLIB)
 0	string		%%HP:		HP48 text
 >6	string		T(0)		- T(0)
 >6	string		T(1)		- T(1)

+ 28 - 16
Magdir/images

@@ -6,8 +6,20 @@
 # additions by janl@ifi.uio.no as well as others. Jan also suggested
 # merging several one- and two-line files into here.
 #
-# little magic: PCX (first byte is 0x0a)
-# no magic: Targa
+
+# Targa - matches `povray', `ppmtotga' and `xv' outputs
+# by Philippe De Muyter <phdm@macqel.be>
+# at 2, byte ImgType must be 1, 2, 3, 9, 10 or 11
+# at 1, byte CoMapType must be 1 if ImgType is 1 or 9, 0 otherwise
+# at 3, leshort Index is 0 for povray, ppmtotga and xv outputs
+# `xv' recognizes only a subset of the following (RGB with pixelsize = 24)
+# `tgatoppm' recognizes a superset (Index may be anything)
+1	belong&0xfff7ffff	0x01010000	Targa image data - Map
+>2	byte&8			8		- RLE
+1	belong&0xfff7ffff	0x00020000	Targa image data - RGB
+>2	byte&8			8		- RLE
+1	belong&0xfff7ffff	0x00030000	Targa image data - Mono
+>2	byte&8			8		- RLE
 
 # PBMPLUS images
 # The next byte following the magic is always whitespace.
@@ -18,6 +30,10 @@
 0	string		P5		PGM "rawbits" image data
 0	string		P6		PPM "rawbits" image data
 
+# NITF is defined by United States MIL-STD-2500A
+0	string	NITF	National Imagery Transmission Format
+>25	string	>\0	dated %.14s
+
 # NIFF (Navy Interchange File Format, a modification of TIFF) images
 0	string		IIN1		NIFF image data
 
@@ -54,7 +70,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
@@ -118,19 +134,6 @@
 >29	byte		0		\b, normal resolution (204x98 DPI)
 >29	byte		1		\b, fine resolution (204x196 DPI)
 
-# JPEG images
-# SunOS 5.5.1 had
-#
-#	0	string		\377\330\377\340	JPEG file
-#	0	string		\377\330\377\356	JPG file
-#
-# both of which turn into "JPEG image data" here.
-#
-0	beshort		0xffd8		JPEG image data
->6	string		JFIF		\b, JFIF standard
-# HSI is Handmade Software's proprietary JPEG encoding scheme
-0	string		hsi1		JPEG image data, HSI proprietary
-
 # PC bitmaps (OS/2, Windoze BMP files)  (Greg Roelofs, newt@uchicago.edu)
 0	string		BM		PC bitmap data
 >14	leshort		12		\b, OS/2 1.x format
@@ -243,3 +246,12 @@
 
 # Visio drawings
 03000	string	Visio\ (TM)\ Drawing			%s
+
+# PSD (Adobe Photoshop bitmap) (Wolfram Kleff)
+0	string		8BPS	PSD image data (Adobe Photoshop bitmap)
+
+# PCX (should be reliable with a 2 byte header - Wolfram Kleff)
+0	beshort		0x0A00	PCX image data, version 2.5
+0	beshort		0x0A02	PCX image data, version 2.8 with palette
+0	beshort		0x0A03	PCX image data, version 2.8 without palette
+0	beshort		0x0A05	PCX image data, version 3.0

+ 1 - 0
Magdir/java

@@ -1,3 +1,4 @@
+
 #------------------------------------------------------------
 # Java ByteCode
 # From Larry Schwimmer (schwim@cs.stanford.edu)

+ 61 - 0
Magdir/jpeg

@@ -0,0 +1,61 @@
+
+#------------------------------------------------------------------------------
+# JPEG images
+# SunOS 5.5.1 had
+#
+#	0	string		\377\330\377\340	JPEG file
+#	0	string		\377\330\377\356	JPG file
+#
+# both of which turn into "JPEG image data" here.
+#
+0	beshort		0xffd8		JPEG image data
+>6	string		JFIF		\b, JFIF standard
+
+# The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06
+# in a vain attempt to add image size reporting for JFIF.  Note that these
+# tests are not fool-proof since some perfectly valid JPEGs are currently
+# impossible to specify in magic(4) format.
+# First, a little JFIF version info:
+>11	byte		x		\b %d.
+>12	byte		x		\b%02d
+# Next, the resolution or aspect ratio of the image:
+>13	byte		0		\b, aspect ratio
+>13	byte		1		\b, resolution (DPI)
+>13	byte		2		\b, resolution (DPCM)
+>14	beshort		x		\b X%d:
+>16	beshort		x		\bY%d
+#>4	beshort		x		\b, segment length %d
+# Next, show thumbnail info, if it exists:
+>18	byte		!0		\b, thumbnail %dx
+>>19	byte		x		\b%d
+# Here things get sticky.  We can do ONE MORE marker segment with
+# indirect addressing, and that's all.  It would be great if we could
+# do pointer arithemetic like in an assembler language.  Christos?
+# And if there was some sort of looping construct to do searches, plus a few
+# named accumulators, it would be even more effective...
+# At least we can show a comment if no other segments got inserted before:
+>(4.S+5)	byte		0xFE
+>>(4.S+8)	string		>\0		\b, "%s"
+#>(4.S+5)	byte		0xFE		\b, comment
+#>>(4.S+6)	beshort		x		\b length=%d
+#>>(4.S+8)	string		>\0		\b, "%s"
+# Or, we can show the encoding type (I've included only the three most common)
+# and image dimensions if we are lucky and the SOFn (image segment) is here:
+>(4.S+5)	byte		0xC0		\b, baseline
+>>(4.S+6)	byte		x		\b, precision %d
+>>(4.S+7)	beshort		x		\b, %dx
+>>(4.S+9)	beshort		x		\b%d
+>(4.S+5)	byte		0xC1		\b, extended sequential
+>>(4.S+6)	byte		x		\b, precision %d
+>>(4.S+7)	beshort		x		\b, %dx
+>>(4.S+9)	beshort		x		\b%d
+>(4.S+5)	byte		0xC2		\b, progressive
+>>(4.S+6)	byte		x		\b, precision %d
+>>(4.S+7)	beshort		x		\b, %dx
+>>(4.S+9)	beshort		x		\b%d
+# I've commented-out quantisation table reporting.  I doubt anyone cares yet.
+#>(4.S+5)	byte		0xDB		\b, quantisation table
+#>>(4.S+6)	beshort		x		\b length=%d
+
+# HSI is Handmade Software's proprietary JPEG encoding scheme
+0	string		hsi1		JPEG image data, HSI proprietary

+ 1 - 1
Magdir/karma

@@ -5,4 +5,4 @@
 # From <rgooch@atnf.csiro.au>
 
 0	string		KarmaRHD Version	Karma Data Structure Version
->16	long		x		%lu
+>16	belong		x		%lu

+ 123 - 0
Magdir/kleff

@@ -0,0 +1,123 @@
+--- animation~  Fri May 28 05:40:12 1999
++++ animation   Fri May 28 05:40:12 1999
+@@ -12,65 +12,71 @@
+ 0      belong          0x000001ba              MPEG system stream data
+ # MPEG Audio (*.mpx)
+ # from dreesen@math.fu-berlin.de
+-0       beshort         &0xfff0         MP
++0       beshort         &0xffe0         MPEG
+ # MPEG 1.0
+->1      byte&0x08       =0x08           \b
++>1      byte&0x08       =0x08           \b 1.0
+ # 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
++>>1     byte            &0x02           \b layer 3 audio stream data
++>>>2    byte&0xf0       =0x10           \b,  32 kBit/s
++>>>2    byte&0xf0       =0x20           \b,  40 kBit/s
++>>>2    byte&0xf0       =0x30           \b,  48 kBit/s
++>>>2    byte&0xf0       =0x40           \b,  56 kBit/s
++>>>2    byte&0xf0       =0x50           \b,  64 kBit/s
++>>>2    byte&0xf0       =0x60           \b,  80 kBit/s
++>>>2    byte&0xf0       =0x70           \b,  96 kBit/s
++>>>2    byte&0xf0       =0x80           \b, 112 kBit/s
++>>>2    byte&0xf0       =0x90           \b, 128 kBit/s
++>>>2    byte&0xf0       =0xA0           \b, 160 kBit/s
++>>>2    byte&0xf0       =0xB0           \b, 192 kBit/s
++>>>2    byte&0xf0       =0xC0           \b, 224 kBit/s
++>>>2    byte&0xf0       =0xD0           \b, 256 kBit/s
++>>>2    byte&0xf0       =0xE0           \b, 320 kBit/s
+ # 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
++>>1     byte            &0x04           \b layer 2 audio stream data
++>>>2    byte&0xf0       =0x10           \b,  32 kBit/s
++>>>2    byte&0xf0       =0x20           \b,  48 kBit/s
++>>>2    byte&0xf0       =0x30           \b,  56 kBit/s
++>>>2    byte&0xf0       =0x40           \b,  64 kBit/s
++>>>2    byte&0xf0       =0x50           \b,  80 kBit/s
++>>>2    byte&0xf0       =0x60           \b,  96 kBit/s
++>>>2    byte&0xf0       =0x70           \b, 112 kBit/s
++>>>2    byte&0xf0       =0x80           \b, 128 kBit/s
++>>>2    byte&0xf0       =0x90           \b, 160 kBit/s
++>>>2    byte&0xf0       =0xA0           \b, 192 kBit/s
++>>>2    byte&0xf0       =0xB0           \b, 224 kBit/s
++>>>2    byte&0xf0       =0xC0           \b, 256 kBit/s
++>>>2    byte&0xf0       =0xD0           \b, 320 kBit/s
++>>>2    byte&0xf0       =0xE0           \b, 384 kBit/s
+ # freq
+ >>2     byte&0x0C       =0x00           \b, 44.1 kHz
+ >>2     byte&0x0C       =0x04           \b, 48 kHz
+ >>2     byte&0x0C       =0x08           \b, 32 kHz
++# MPEG 2.5
++>1      byte&0x18       =0x00           \b 2.5
++# Layer 3
++>>1     byte            &0x02           \b layer 3 audio stream data
++# Layer 2
++>>1     byte            &0x04           \b layer 2 audio stream data
+ # MPEG 2.0
+->1      byte&0x08       =0x00           \b
++>1      byte&0x18       =0x10           \b 2.0
+ # Layer 3
+->>1     byte            &0x02           \b3
++>>1     byte            &0x02           \b layer 3 audio stream data
+ # 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           \b layer 2 audio stream data
++>>2     byte&0xf0       =0x10           \b,   8 kBit/s
++>>2     byte&0xf0       =0x20           \b,  16 kBit/s
++>>2     byte&0xf0       =0x30           \b,  24 kBit/s
++>>2     byte&0xf0       =0x40           \b,  32 kBit/s
++>>2     byte&0xf0       =0x50           \b,  40 kBit/s
++>>2     byte&0xf0       =0x60           \b,  48 kBit/s
++>>2     byte&0xf0       =0x70           \b,  56 kBit/s
++>>2     byte&0xf0       =0x80           \b,  64 kBit/s
++>>2     byte&0xf0       =0x90           \b,  80 kBit/s
++>>2     byte&0xf0       =0xA0           \b,  96 kBit/s
++>>2     byte&0xf0       =0xB0           \b, 112 kBit/s
++>>2     byte&0xf0       =0xC0           \b, 128 kBit/s
++>>2     byte&0xf0       =0xD0           \b, 144 kBit/s
++>>2     byte&0xf0       =0xE0           \b, 160 kBit/s
+ # freq
+ >>2     byte&0x0C       =0x00           \b, 22.05 kHz
+ >>2     byte&0x0C       =0x04           \b, 24 kHz

+ 43 - 22
Magdir/linux

@@ -75,30 +75,51 @@
 >8	long		>0		not stripped
 >8	long		0		stripped
 >23	leshort		>0		- version %ld.
-#
-# Linux kernel boot images, from Albert Cahalan <acahalan@cs.uml.edu>
-# and others such as Axel Kohlmeyer <akohlmey@rincewind.chemie.uni-ulm.de>
-# and Nicolás Lichtmaier <nick@debian.org>
-# All known start with: b8 c0 07 8e d8 b8 00 90 8e c0 b9 00 01 29 f6 29
-514		string	HdrS		Linux kernel
->518		leshort	>0
->>529		byte	0		zImage data,
->>529		byte	1		bzImage data,
->0x048c		byte	0x31
->>0x048c	string	x		version %s
->0x0493		byte	0x31
->>0x0493	string	x		version %s
->0x048c		byte	0x32
->>0x048c	string	x		version %s
->0x0493		byte	0x32
->>0x0493	string	x		version %s
->0x04df		byte	0x32
->>0x04df	string	x		version %s
->0x04fb		byte	0x32
->>0x04fb	string	x		version %s
+
+# Linux kernel boot images (i386 arch) (Wolfram Kleff)
+514	string		HdrS		Linux kernel
+>510	leshort		0xAA55		x86 boot executable
+>>518	leshort		0x201
+>>>529	byte		0		zImage,
+>>>529	byte		1		bzImage,
+>>>(526.s+0x200) string	>\0		version %s,
+>>498	leshort		1		RO-rootFS,
+>>498	leshort		0		RW-rootFS,
+>>508	leshort		>0		root_dev=0x%X,
+>>502	leshort		>0		swap_dev=0x%X,
+>>504	leshort		>0		RAMdisksize=%u KB,
+>>506	leshort		0xFFFF		Normal VGA
+>>506	leshort		0xFFFE		Extended VGA
+>>506	leshort		0xFFFD		Prompt for Videomode
+>>506	leshort		>0		Video mode=%d
+
 # This also matches new kernels, which were caught above by "HdrS".
 0		belong	0xb8c0078e	Linux kernel
 >0x1e3		string	Loading		version 1.3.79 or older
 >0x1e9		string	Loading		from prehistoric times
-# LSM entries - Nicolás Lichtmaier <nick@feedback.net.ar>
+
+# System.map files - Nicolás Lichtmaier <nick@debian.org>
+8	string	\ A\ _text	Linux kernel symbol map text
+
+# LSM entries - Nicolás Lichtmaier <nick@debian.org>
 0	string	Begin3	Linux Software Map entry text
+0	string	Begin4	Linux Software Map entry text (new format)
+
+# Moved from filesistems to be able to detect linux kernels.
+0x1FE	leshort	0xAA55			x86 boot sector
+>2	string	OSBS			\b, OS/BS MBR
+>0x8C	string	Invalid\ partition\ table	\b, MS-DOS MBR
+>0	string	\0\0\0\0		\b, extended partition table
+>0	leshort 0x3CEB			\b, system
+>>3	string	>\0			%s
+>>0x36	string	FAT			\b, %s
+>>>0x39	string	12			(%s bit)
+>>>0x39	string	16			(%s bit)
+>0x52	string	FAT32			\b, FAT (32 bit)
+>>>43	string		>NO\ NAME	label: %.11s,
+>>>43	string		<NO\ NAME	label: %.11s,
+>>>43	string		NO\ NAME	unlabeled,
+>>>19	leshort		>0		%d sectors
+>>>19	leshort		0		
+>>>>32	lelong		x		%d sectors
+>0x200	lelong	0x82564557		\b, BSD disklabel

+ 7 - 2
Magdir/mach

@@ -1,12 +1,12 @@
 #------------------------------------------------------------------------------
 # mach file description
 #
-0	belong		0xcafebabe	mach-o fat file
+0	belong		0xcafebabe	Mach-O fat file
 >4	belong		1		with 1 architecture
 >4	belong		>1
 >>4	belong		x		with %ld architectures		
 #
-0	belong		0xfeedface	mach-o
+0	belong		0xfeedface	Mach-O
 >12	belong		1		object
 >12	belong		2		executable
 >12	belong		3		shared library
@@ -22,6 +22,11 @@
 >4	belong		4		ns32032
 >4	belong		5		ns32332
 >4	belong		6		for m68k architecture
+# from NeXTstep 3.0 <mach/machine.h>
+# i.e. mc680x0_all, ignore
+# >>8	belong		1		(mc68030)
+>>8	belong		2		(mc68040)
+>>8	belong		3		(mc68030 only)
 >4	belong		7		i386
 >4	belong		8		mips
 >4	belong		9		ns32532

+ 31 - 0
Magdir/mcrypt

@@ -0,0 +1,31 @@
+#------------------------------------------------------------------------------
+# 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

+ 6 - 0
Magdir/misctools

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

+ 20 - 0
Magdir/motorola

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

+ 19 - 5
Magdir/msdos

@@ -5,6 +5,7 @@
 
 # .BAT files (Daniel Quinlan, quinlan@yggdrasil.com)
 0	string	@echo\ off	MS-DOS batch file text
+0	string	@ECHO\ OFF	MS-DOS batch file text
 
 # XXX - according to Microsoft's spec, at an offset of 0x3c in a
 # PE-format executable is the offset in the file of the PE header;
@@ -87,6 +88,7 @@
 >24	string	@		\b, OS/2 or MS Windows
 >>0xe7	string	LH/2\ Self-Extract	\b, %s
 >>0xe9	string	PKSFX2		\b, %s
+>>122	string	Windows\ self-extracting\ ZIP	\b, %s
 >0x1c	string	RJSX\xff\xff	\b, ARJ SFX
 >0x1c	string	diet\xf9\x9c	\b, diet compressed
 >0x1e	string	Copyright\ 1989-1990\ PKWARE\ Inc.	\b, PKSFX
@@ -141,19 +143,28 @@
 #
 
 #
-# Windows NT Registry files.
+# Windows Registry files.
 #
-0	string		regf		Windows NT Registry file
+0	string		regf		Windows NT registry file
+0	string		CREG		Windows 95 registry file
 
 # Popular applications
 2080	string	Microsoft\ Word\ 6.0\ Document	%s
 2080	string	Documento\ Microsoft\ Word\ 6 Spanish Microsoft Word 6 document data
 # Pawel Wiecek <coven@i17linuxb.ists.pwr.wroc.pl> (for polish Word)
-2112	string	MSWordDoc	Microsoft Word document data
+2112	string	MSWordDoc			Microsoft Word document data
 #
-0	belong	0x31be0000	Microsoft Word Document
+0	belong	0x31be0000			Microsoft Word Document
 #
-0       string  PO^Q`           Microsoft Word 6.0 Document
+0       string  PO^Q`				Microsoft Word 6.0 Document
+
+# I guess this is the one that works:
+# MS-Word Document (Wolfram Kleff)
+0	string	\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1	Microsoft Word document data
+
+0	string	\376\067\0\043			Microsoft Office Document
+0	string	\320\317\021\340\241\261	Microsoft Office Document
+0	string	\333\245-\0\0\0			Microsoft Office Document
 #
 2080	string	Microsoft\ Excel\ 5.0\ Worksheet	%s
 #
@@ -176,3 +187,6 @@
 
 # Help files
 0	string	?_\3\0		MS Windows Help Data
+
+# Microsoft CAB distribution format  Dale Worley <root@dworley.ny.mediaone.net>
+0	string		MSCF\000\000\000\000	Microsoft CAB file

+ 0 - 39
Magdir/net

@@ -1,39 +0,0 @@
-# These entries describe the file format of pcap data files
-# (for example from tcpdump). Peter Tobias <tobias@et-inf.fho-emden.de>
-
-0	lelong		0xa1b2c3d4	pcap data (little endian),
->4	leshort		x		version %d
->6	leshort		x		rev %d,
->16	lelong		x		snap length %d,
->20	lelong		0		no link-layer encapsulation
->20	lelong		1		Ethernet
->20	lelong		2		Ethernet (3MB)
->20	lelong		3		AX25
->20	lelong		4		ProNET
->20	lelong		5		CHAOS
->20	lelong		6		IEEE 802
->20	lelong		7		ARCNET
->20	lelong		8		SLIP
->20	lelong		9		PPP
->20	lelong		10		FDDI
->20	lelong		11		LLC/SNAP encapsulated ATM
->20	lelong		12		raw IP
-
-
-0	belong		0xa1b2c3d4	pcap data (big endian),
->4	beshort		x		version %d
->6	beshort		x		rev %d,
->16	belong		x		snap length %d,
->20	belong		0		no link-layer encapsulation
->20	belong		1		Ethernet
->20	belong		2		Ethernet (3MB)
->20	belong		3		AX25
->20	belong		4		ProNET
->20	belong		5		CHAOS
->20	belong		6		IEEE 802
->20	belong		7		ARCNET
->20	belong		8		SLIP
->20	belong		9		PPP
->20	belong		10		FDDI
->20	belong		11		LLC/SNAP encapsulated ATM
->20	belong		12		raw IP

+ 25 - 4
Magdir/netbsd

@@ -136,25 +136,46 @@
 0	belong&0377777777	042600507	NetBSD/pmax core
 >12	string			>\0		from '%s'
 
-0	belong&0377777777	043000413	NetBSD/vax demand paged
+0	belong&0377777777	043000413	NetBSD/vax 1k demand paged
 >0	byte			&0x80		
 >>20	lelong			<4096		shared library
 >>20	lelong			=4096		dynamically linked executable
 >>20	lelong			>4096		dynamically linked executable
 >0	byte			^0x80		executable
 >16	lelong			>0		not stripped
-0	belong&0377777777	043000410	NetBSD/vax pure
+0	belong&0377777777	043000410	NetBSD/vax 1k pure
 >0	byte			&0x80		dynamically linked executable
 >0	byte			^0x80		executable
 >16	lelong			>0		not stripped
-0	belong&0377777777	043000407	NetBSD/vax
+0	belong&0377777777	043000407	NetBSD/vax 1k
 >0	byte			&0x80		dynamically linked executable
 >0	byte			^0x80
 >>0	byte			&0x40		position independent
 >>20	lelong			!0		executable
 >>20	lelong			=0		object file
 >16	lelong			>0		not stripped
-0	belong&0377777777	043000507	NetBSD/vax core
+0	belong&0377777777	043000507	NetBSD/vax 1k core
+>12	string			>\0		from '%s'
+
+0	belong&0377777777	045400413	NetBSD/vax 4k demand paged
+>0	byte			&0x80		
+>>20	lelong			<4096		shared library
+>>20	lelong			=4096		dynamically linked executable
+>>20	lelong			>4096		dynamically linked executable
+>0	byte			^0x80		executable
+>16	lelong			>0		not stripped
+0	belong&0377777777	045400410	NetBSD/vax 4k pure
+>0	byte			&0x80		dynamically linked executable
+>0	byte			^0x80		executable
+>16	lelong			>0		not stripped
+0	belong&0377777777	045400407	NetBSD/vax 4k
+>0	byte			&0x80		dynamically linked executable
+>0	byte			^0x80
+>>0	byte			&0x40		position independent
+>>20	lelong			!0		executable
+>>20	lelong			=0		object file
+>16	lelong			>0		not stripped
+0	belong&0377777777	045400507	NetBSD/vax 4k core
 >12	string			>\0		from '%s'
 
 # NetBSD/alpha does not support (and has never supported) a.out objects,

+ 1 - 0
Magdir/octave

@@ -1,3 +1,4 @@
+
 #------------------------------------------------------------------------------
 # octave binary data file(1) magic, from Dirk Eddelbuettel <edd@debian.org>
 0	string		Octave-1-L	Octave binary data (little endian)

+ 34 - 10
Magdir/os2

@@ -11,13 +11,37 @@
 # OS/2 URL objects
 # Provided 1998/08/22 by
 # David Mediavilla <davidme.news@REMOVEIFNOTSPAMusa.net>
-0	string	http:			OS/2 URL object text
->5	string	>\			(WWW) <http:%s>
-0	string	mailto:			OS/2 URL object text
->7	string	>\			(email) <%s>
-0	string	news:			OS/2 URL object text
->5	string	>\			(Usenet) <%s>
-0	string	ftp:			OS/2 URL object text
->4	string	>\			(FTP) <ftp:%s>
-0	string	file:			OS/2 URL object text
->5	string	>\			(Local file) <%s>
+#0	string	http:			OS/2 URL object text
+#>5	string	>\			(WWW) <http:%s>
+#0	string	mailto:			OS/2 URL object text
+#>7	string	>\			(email) <%s>
+#0	string	news:			OS/2 URL object text
+#>5	string	>\			(Usenet) <%s>
+#0	string	ftp:			OS/2 URL object text
+#>4	string	>\			(FTP) <ftp:%s>
+#0	string	file:			OS/2 URL object text
+#>5	string	>\			(Local file) <%s>
+
+# >>>>> OS/2 INF/HLP <<<<<  (source: Daniel Dissett ddissett@netcom.com)
+# Carl Hauser (chauser.parc@xerox.com) and 
+# Marcus Groeber (marcusg@ph-cip.uni-koeln.de)
+# list the following header format in inf02a.doc:
+#
+#  int16 ID;           // ID magic word (5348h = "HS")
+#  int8  unknown1;     // unknown purpose, could be third letter of ID
+#  int8  flags;        // probably a flag word...
+#                      //  bit 0: set if INF style file
+#                      //  bit 4: set if HLP style file
+#                      // patching this byte allows reading HLP files
+#                      // using the VIEW command, while help files 
+#                      // seem to work with INF settings here as well.
+#  int16 hdrsize;      // total size of header
+#  int16 unknown2;     // unknown purpose
+# 
+0   string  HSP\x01\x9b\x00 OS/2 INF
+>107 string >0                      (%s)
+0   string  HSP\x10\x9b\x00     OS/2 HLP
+>107 string >0                      (%s)
+
+# OS/2 INI (this is a guess)
+0  string   \xff\xff\xff\xff\x14\0\0\0  OS/2 INI

+ 15 - 0
Magdir/palm

@@ -0,0 +1,15 @@
+
+#------------------------------------------------------------------------------
+# palm:  file(1) magic for PalmOS {.prc,.pdb}: applications, docfiles, and hacks
+#
+# Brian Lalor <blalor@hcirisc.cs.binghamton.edu>
+
+# appl
+60      belong                  0x6170706c      PalmOS application
+>0      string                  >\0             "%s"
+# TEXt
+60      belong                  0x54455874      AportisDoc file
+>0      string                  >\0             "%s"
+# HACK
+60      belong                  0x4841434b      HackMaster hack
+>0      string                  >\0             "%s"

+ 0 - 7
Magdir/ppd

@@ -1,7 +0,0 @@
-#------------------------------------------------------------------------------
-# ppd:  file(1) Adobe's PostScript Printer Description (PPD) files
-#       Yves Arrouye <arrouye@marin.fdn.fr>
-#
-0      string          *PPD-Adobe:    PPD file
->13    string          x              \b, ve
-

+ 2 - 0
Magdir/printer

@@ -17,6 +17,8 @@
 >>>16	string		EPS		- type %s
 >>>16	string		Query		- type %s
 >>>16	string		ExitServer	- type %s
+0	string		\033%-12345X%!PS	PostScript document
+
 
 # DOS EPS Binary File Header
 # From: Ed Sznyter <ews@Black.Market.NET>

+ 28 - 14
Magdir/sgml

@@ -1,21 +1,35 @@
 
 #------------------------------------------------------------------------------
 # sgml:  file(1) magic for Standard Generalized Markup Language
-
 # HyperText Markup Language (HTML) is an SGML document type,
 # from Daniel Quinlan (quinlan@yggdrasil.com)
-0	string		\<!DOCTYPE\ HTML	HTML document text
-0	string		\<!doctype\ html	HTML document text
-0	string		\<HEAD		HTML document text
-0	string		\<head		HTML document text
-0	string		\<TITLE		HTML document text
-0	string		\<title		HTML document text
-0	string		\<html		HTML document text
-0	string		\<HTML		HTML document text
+0   string      \<!DOCTYPE\ HTML    HTML document text
+0   string      \<!doctype\ html    HTML document text
+0   string	\<!DOCTYPE\ html    HTML document text
+0   string      \<HEAD      HTML document text
+0   string      \<head      HTML document text
+0   string      \<TITLE     HTML document text
+0   string      \<title     HTML document text
+0   string      \<html      HTML document text
+0   string      \<HTML      HTML document text
+
+# Extensible markup language (XML), a subset of SGML
+# from Marc Prud'hommeaux (marc@apocalypse.org)
+0	string		\<?xml\ version="	XML
+>15	string		>\0		%.3s document text
+>>23	string		\<xsl:stylesheet (XSL stylesheet)
+>>24	string		\<xsl:stylesheet (XSL stylesheet)
+0       string          \<?xml          XML document text
+>23	string		\<xsl:stylesheet XSL stylesheet text
+>24	string		\<xsl:stylesheet XSL stylesheet text
+0       string          \<?XML          broken XML document text
+0       string          \<?Xml          broken XML document text
 
 # SGML, mostly from rph@sq
-0	string		\<!DOCTYPE	exported SGML document text
-0	string		\<!doctype	exported SGML document text
-0	string		\<!SUBDOC	exported SGML subdocument text
-0	string		\<!subdoc	exported SGML subdocument text
-0	string		\<!--		exported SGML document text
+0   string      \<!DOCTYPE  exported SGML document text
+0   string      \<!doctype  exported SGML document text
+0   string      \<!SUBDOC   exported SGML subdocument text
+0   string      \<!subdoc   exported SGML subdocument text
+0   string      \<!--       exported SGML document text
+
+

+ 18 - 12
Magdir/sniffer

@@ -1,10 +1,10 @@
 
 #------------------------------------------------------------------------------
-# sniffer:  file(1) magic for packet captured files
+# sniffer:  file(1) magic for packet capture files
 #
 # From: guy@netapp.com (Guy Harris)
 #
-# Microsoft NetMon (packet capture/display program) capture files.
+# Microsoft Network Monitor capture files.
 #
 0	string		RTSS		NetMon capture file
 >4	byte		x		- version %d
@@ -16,28 +16,34 @@
 
 #
 # Network General Sniffer capture files.
+# Sorry, make that "Network Associates Sniffer capture files."
 #
 0	string		TRSNIFF\ data\ \ \ \ \032	Sniffer capture file
+>33	byte		2		(compressed)
 >23	leshort		x		- version %d
 >25	leshort		x		\b.%d
->33	byte		x		(Format %d,
->32	byte		0		Token ring)
->32	byte		1		Ethernet)
->32	byte		2		ARCNET)
->32	byte		3		StarLAN)
->32	byte		4		PC Network broadband)
->32	byte		5		LocalTalk)
->32	byte		6		Znet)
+>32	byte		0		(Token Ring)
+>32	byte		1		(Ethernet)
+>32	byte		2		(ARCNET)
+>32	byte		3		(StarLAN)
+>32	byte		4		(PC Network broadband)
+>32	byte		5		(LocalTalk)
+>32	byte		6		(Znet)
+>32	byte		7		(Internetwork Analyzer)
+>32	byte		9		(FDDI)
+>32	byte		10		(ATM)
 #
 # Cinco Networks NetXRay capture files.
+# Sorry, make that "Network General Sniffer Basic capture files."
+# Sorry, make that "Network Associates Sniffer Basic capture files."
 #
 0	string		XCP\0		NetXRay capture file
 >4	string		>\0		- version %s
 #
 # "libpcap" capture files.
 # (We call them "tcpdump capture file(s)" for now, as "tcpdump" is
-# the main program that uses that format, but there's also "tcpview",
-# and there may be others in the future.)
+# the main program that uses that format, but there are other programs
+# that use "libpcap", or that use the same capture file format.)
 #
 0	ubelong		0xa1b2c3d4	tcpdump capture file (big-endian)
 >4	beshort		x		- version %d

+ 28 - 0
Magdir/spectrum

@@ -0,0 +1,28 @@
+
+#------------------------------------------------------------------------------
+# spectrum:  file(1) magic for Spectrum emulator files.
+#
+# John Elliott <jce@seasip.demon.co.uk>
+
+#
+# Spectrum +3DOS header
+#
+0       string          PLUS3DOS\032    Spectrum +3 data
+>15     byte            0               - BASIC program
+>15     byte            1               - number array
+>15     byte            2               - character array
+>15     byte            3               - memory block
+>>16    belong          0x001B0040      (screen)
+>15     byte            4               - Tasword document
+>15     string          TAPEFILE        - ZXT tapefile
+#
+# Tape file. This assumes the .TAP starts with a Spectrum-format header,
+# which nearly all will.
+#
+0       string          \023\000\000    Spectrum .TAP data
+>4      string          x               "%-10.10s"
+>3      byte            0               - BASIC program
+>3      byte            1               - number array
+>3      byte            2               - character array
+>3      byte            3               - memory block
+>>14    belong          0x001B0040      (screen)

+ 1 - 0
Magdir/ti-8x

@@ -1,3 +1,4 @@
+
 # ------------------------------------------------------------------------
 # ti-8x: file(1) magic for the TI-8x and TI-92 Graphing Calculators.
 #

+ 5 - 1
Magdir/varied.out

@@ -15,7 +15,11 @@
 6	beshort		0407		unicos (cray) executable
 # Ultrix 4.3
 596	string		\130\337\377\377	Ultrix core file
->600	string		>\0	'%s'
+>600	string		>\0		from '%s'
 # BeOS and MAcOS PEF executables
 # From: hplus@zilker.net (Jon Watte)
 0	string		Joy!peffpwpc	header for PowerPC PEF executable
+#
+# ava assembler/linker Uros Platise <uros.platise@ijs.si>
+0       string          avaobj  AVR assembler object code
+>7      string          >\0     version '%s'

+ 13 - 0
Magdir/wordprocessors

@@ -0,0 +1,13 @@
+
+#------------------------------------------------------------------------------
+# wordprocessors:  file(1) magic fo word processors.
+#
+
+####### PWP file format used on Smith Corona Personal Word Processors:
+2	string	\040\040\040\040\040\040\040\040\040\040\040ML4D\040\'92	Smith Corona PWP
+>24	byte	2	\b, single spaced
+>24	byte	3	\b, 1.5 spaced
+>24	byte	4	\b, double spaced
+>25	byte	0x42	\b, letter
+>25	byte	0x54	\b, legal
+>26	byte	0x46	\b, A4

+ 79 - 0
Makefile.am

@@ -0,0 +1,79 @@
+# don't enforce GNU packaging standards
+AUTOMAKE_OPTIONS = foreign no-dependencies
+
+bin_PROGRAMS = file
+
+bin_SCRIPTS = magic2mime
+
+data_DATA = magic
+
+MAGIC	 = @datadir@/magic
+CPPFLAGS = -DMAGIC='"/etc/magic:$(MAGIC)"'
+
+man_MANS = file.1 magic.5 magic2mime.1
+
+file_SOURCES = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
+	compress.c is_tar.c readelf.c internat.c print.c \
+	file.h names.h patchlevel.h readelf.h tar.h
+
+EXTRA_DIST = LEGAL.NOTICE MAINT PORTING Makefile.std magic2mime \
+	Localstuff Header $(magic_FRAGMENTS) file.man magic.man
+
+CLEANFILES = $(man_MANS) magic
+
+magic: Header $(magic_FRAGMENTS)
+	cat $(srcdir)/Header > $@
+	for frag in $(magic_FRAGMENTS); do \
+	  if test -f $(srcdir)/$$frag; then \
+	    f=$(srcdir)/$$frag; \
+	  else \
+	    f=$$frag; \
+	  fi; \
+          cat $$f; \
+	done >> $@
+
+file.1:	Makefile file.man
+	@rm -f $@
+	sed -e s@__CSECTION__@1@g \
+	    -e s@__FSECTION__@5@g \
+	    -e s@__VERSION__@${VERSION}@g \
+	    -e s@__MAGIC__@${MAGIC}@g $(srcdir)/file.man > $@
+
+magic2mime.1: Makefile magic2mime.man
+	@rm -f $@
+	sed -e s@__CSECTION__@1@g \
+	    -e s@__FSECTION__@5@g \
+	    -e s@__VERSION__@${VERSION}@g \
+	    -e s@__MAGIC__@${MAGIC}@g $(srcdir)/magic2mime.man > $@
+
+magic.5: Makefile magic.man
+	@rm -f $@
+	sed -e s@__CSECTION__@1@g \
+	    -e s@__FSECTION__@5@g \
+	    -e s@__VERSION__@${VERSION}@g \
+	    -e s@__MAGIC__@${MAGIC}@g $(srcdir)/magic.man > $@
+
+magic_FRAGMENTS = Magdir/adventure 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/blit \
+Magdir/bsdi Magdir/c-lang Magdir/chi Magdir/cisco Magdir/clipper \
+Magdir/commands Magdir/compress Magdir/convex Magdir/database \
+Magdir/diamond Magdir/diff Magdir/digital Magdir/dump Magdir/elf \
+Magdir/encore Magdir/filesystems Magdir/flash Magdir/fonts Magdir/frame \
+Magdir/freebsd Magdir/gimp Magdir/gnu Magdir/hp Magdir/ibm370 \
+Magdir/ibm6000 Magdir/iff Magdir/images Magdir/intel Magdir/interleaf \
+Magdir/island Magdir/ispell Magdir/java Magdir/karma Magdir/lecter \
+Magdir/lex Magdir/lif Magdir/linux Magdir/lisp Magdir/mach Magdir/macintosh \
+Magdir/magic Magdir/mail.news Magdir/mime Magdir/mirage Magdir/mkid \
+Magdir/mmdf Magdir/modem Magdir/motorola Magdir/msdos Magdir/ncr \
+Magdir/netbsd Magdir/news Magdir/octave Magdir/olf Magdir/os2 Magdir/os9 \
+Magdir/osf1 Magdir/pbm Magdir/pdf Magdir/pdp Magdir/pgp Magdir/pkgadd \
+Magdir/plus5 Magdir/printer Magdir/psdbms Magdir/pyramid Magdir/riff \
+Magdir/rpm Magdir/rtf Magdir/sc Magdir/sccs Magdir/sendmail Magdir/sequent \
+Magdir/sgi Magdir/sgml Magdir/sniffer Magdir/softquad 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/wordperfect Magdir/xenix Magdir/zilog Magdir/zyxel \
+Magdir/communications Magdir/misctools Magdir/wordprocessors \
+Magdir/jpeg Magdir/grace Magdir/mcrypt Magdir/palm Magdir/spectrum

File diff suppressed because it is too large
+ 529 - 177
Makefile.in


+ 2 - 2
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.5 1998/09/12 13:17:52 christos Exp $
+# @(#)$Id: Makefile.std,v 1.6 1999/02/14 17:21:38 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.
@@ -21,7 +21,7 @@
 #    ever read sources, credits must appear in the documentation.
 #
 # 4. This notice may not be removed or altered.
-VERSION	= 3.26
+VERSION	= 3.27
 SHELL	= /bin/sh
 #MAGIC	= /etc/magic
 MAGIC	= /usr/local/etc/magic

+ 0 - 76
PORTING

@@ -1,76 +0,0 @@
-Portability of the new file(1) command.
-@(#) $Id: PORTING,v 1.11 1993/09/23 21:47:23 christos Exp $
-
-Read this file only if the program doesn't compile on your system.
-
-This release has been around UNIX; it has been compiled and tested
-in the following environments:
-
-SunOS sqarc 4.1.1 8 sun4
-	No problems.
-ULTRIX squint 4.2 0 RISC
-	No problems.
-A/UX sqmac 3.0a9 SVR22 mc68020
-	No problems.
-AIX sqibm 2 3 000XXXXXX100
-	Had weird "make" problems making "magic" file automatically; just
-	built it by hand. Your mileage may vary.
-SCO sqwang 3.2 2 i386
-	Compiles fine; their weird make can't handle "[a-z]*" as a dependancy,
-	so build magic by hand. Runs fine.
-sqzme sqzme 3.1.1 3 3B2
-	The 3B2 SVR3 needed a few tweaks as well as COPTS = -Ilocalinc
-	in order to compile.
-
-This version, reluctanly, includes <stdlib.h>, which won't exist
-on older systems or those that aren't even close to the ANSI C
-standard. There is a null "stdlib.h", and some other bogus headers,
-in subdirectory "localinc"; if you get complaints about missing
-stdlib.h and others, uncomment the line with COPTS=-Ilocalinc
-in the Makefile, and try again.
-
-You must have either <stdarg.h> or the older <varargs.h>, otherwise you'll
-have to butcher some routines in print.c.
-
-Beyond that, I have tried to make a program that doesn't need any
-command-line defines (-D) to specify what version of UNIX is in use,
-by using the definitions available in the system #include
-files. For example, the lstat(2) call is normally found in
-4BSD systems, but might be grafted into some other variant
-of UNIX. If it's done right (ie., using the same definitions),
-my program will compile and work correctly. Look at the #ifdefs
-to see how it's done. 
-
-I've also tried to include source for all the non-portable library routines
-I used (getopt, str*).   Non-portable here means `not in every
-reasonably standard UNIX out there: V7, System V, 4BSD'.
-These are in subdirectory "localsrc", and not used unless you
-need them; again, see the Makefile.
-
-There is one area that just might cause problems. On System
-V, they moved the definition of major() and minor() out of
-<sys/types.h> into <sys/sysmacros.h>.  Hence, if major isn't
-defined after including types.h, I automatically include sys/sysmacros.h.
-This will work for 99% of the systems out there. ONLY if you
-have a system in which  neither types.h nor sysmacros.h defines
-`major' will this automatic include fail (I hope). On such
-systems, you will get a compilation error in trying to compile
-a warning message. Please do the following: 
-
-	1) change the appropriate #include at the start of fsmagic.c
-and	2) let me know the name of the system, the release number,
-	   and the name of the header file that *does* include
-	   this "standard" definition.
-
-If you are running the old Ritchie PDP-11 C compiler or
-some other compiler that doesn't know about `void', you will have
-to include `-Dvoid=int' in the variable COPTS in the Makefile.
-
-Other than this, there should be no portability problems,
-but one never knows these days. Please let me know of any
-other problems you find porting to a UNIX system. I don't much
-care about non-UNIX systems but will collect widely-used magic 
-numbers for them as well as for UNIX systems.
-
-Mark Moraes and Christos Zoulas
-(address in README)

+ 3 - 3
README

@@ -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,7 +61,7 @@ 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.

+ 42 - 0
acconfig.h

@@ -0,0 +1,42 @@
+/* Autoheader needs me */
+#define PACKAGE "file"
+
+/* Autoheader needs me */
+#define VERSION "3.27"
+
+/* Define if builtin ELF support is enabled.  */
+#undef BUILTIN_ELF
+
+/* Define if ELF core file support is enabled.  */
+#undef ELFCORE
+
+/* Define if the `long long' type works.  */
+#undef HAVE_LONG_LONG
+
+/* Define to `unsigned char' if standard headers don't define.  */
+#undef uint8_t
+
+/* Define to `unsigned short' if standard headers don't define.  */
+#undef uint16_t
+
+/* Define to `unsigned int' if standard headers don't define.  */
+#undef uint32_t
+
+/* Define to `unsigned long long', if available, or `unsigned long', if
+   standard headers don't define.  */
+#undef uint64_t
+
+/* FIXME: These have to be added manually because autoheader doesn't know
+   about AC_CHECK_SIZEOF_INCLUDES.  */
+
+/* The number of bytes in a uint8_t.  */
+#define SIZEOF_UINT8_T 0
+
+/* The number of bytes in a uint16_t.  */
+#define SIZEOF_UINT16_T 0
+
+/* The number of bytes in a uint32_t.  */
+#define SIZEOF_UINT32_T 0
+
+/* The number of bytes in a uint64_t.  */
+#define SIZEOF_UINT64_T 0

+ 79 - 0
acinclude.m4

@@ -0,0 +1,79 @@
+dnl cloned from autoconf 2.13 acspecific.m4
+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
+else
+AC_TRY_RUN([int main() {
+long long foo = 0;
+exit(sizeof(long long) < sizeof(long)); }],
+ac_cv_c_long_long=yes, ac_cv_c_long_long=no)
+fi])
+if test $ac_cv_c_long_long = yes; then
+  AC_DEFINE(HAVE_LONG_LONG)
+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 AC_CHECK_TYPE2(TYPE, DEFAULT)
+AC_DEFUN(AC_CHECK_TYPE2,
+[AC_REQUIRE([AC_HEADER_STDC])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>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif], eval "ac_cv_type_$1=yes", eval "ac_cv_type_$1=no")])dnl
+if eval "test \"`echo '$ac_cv_type_'$1`\" = yes"; then
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+  AC_DEFINE_UNQUOTED($1, $2)
+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 The cache variable name.
+define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
+changequote([, ])dnl
+AC_MSG_CHECKING(size of $1)
+AC_CACHE_VAL(AC_CV_NAME,
+[AC_TRY_RUN([$3
+#include <stdio.h>
+main()
+{
+  FILE *f=fopen("conftestval", "w");
+  if (!f) exit(1);
+  fprintf(f, "%d\n", sizeof($1));
+  exit(0);
+}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl
+AC_MSG_RESULT($AC_CV_NAME)
+AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
+undefine([AC_TYPE_NAME])dnl
+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>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+])
+])

+ 207 - 0
aclocal.m4

@@ -0,0 +1,207 @@
+dnl aclocal.m4 generated automatically by aclocal 1.4
+
+dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+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_CACHE_CHECK(for long long, ac_cv_c_long_long,
+[if test "$GCC" = yes; then
+  ac_cv_c_long_long=yes
+else
+AC_TRY_RUN([int main() {
+long long foo = 0;
+exit(sizeof(long long) < sizeof(long)); }],
+ac_cv_c_long_long=yes, ac_cv_c_long_long=no)
+fi])
+if test $ac_cv_c_long_long = yes; then
+  AC_DEFINE(HAVE_LONG_LONG)
+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 AC_CHECK_TYPE2(TYPE, DEFAULT)
+AC_DEFUN(AC_CHECK_TYPE2,
+[AC_REQUIRE([AC_HEADER_STDC])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>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif], eval "ac_cv_type_$1=yes", eval "ac_cv_type_$1=no")])dnl
+if eval "test \"`echo '$ac_cv_type_'$1`\" = yes"; then
+  AC_MSG_RESULT(yes)
+else
+  AC_MSG_RESULT(no)
+  AC_DEFINE_UNQUOTED($1, $2)
+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 The cache variable name.
+define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
+changequote([, ])dnl
+AC_MSG_CHECKING(size of $1)
+AC_CACHE_VAL(AC_CV_NAME,
+[AC_TRY_RUN([$3
+#include <stdio.h>
+main()
+{
+  FILE *f=fopen("conftestval", "w");
+  if (!f) exit(1);
+  fprintf(f, "%d\n", sizeof($1));
+  exit(0);
+}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl
+AC_MSG_RESULT($AC_CV_NAME)
+AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
+undefine([AC_TYPE_NAME])dnl
+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>
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+])
+])
+
+# 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.
+
+# serial 1
+
+dnl Usage:
+dnl AM_INIT_AUTOMAKE(package,version, [no-define])
+
+AC_DEFUN(AM_INIT_AUTOMAKE,
+[AC_REQUIRE([AC_PROG_INSTALL])
+PACKAGE=[$1]
+AC_SUBST(PACKAGE)
+VERSION=[$2]
+AC_SUBST(VERSION)
+dnl test to see if srcdir already configured
+if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
+  AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+fi
+ifelse([$3],,
+AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
+AC_REQUIRE([AM_SANITY_CHECK])
+AC_REQUIRE([AC_ARG_PROGRAM])
+dnl FIXME This is truly gross.
+missing_dir=`cd $ac_aux_dir && pwd`
+AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
+AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
+AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
+AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
+AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
+AC_REQUIRE([AC_PROG_MAKE_SET])])
+
+#
+# Check to make sure that the build environment is sane.
+#
+
+AC_DEFUN(AM_SANITY_CHECK,
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftestfile
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
+   if test "[$]*" = "X"; then
+      # -L didn't work.
+      set X `ls -t $srcdir/configure conftestfile`
+   fi
+   if test "[$]*" != "X $srcdir/configure conftestfile" \
+      && test "[$]*" != "X conftestfile $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+alias in your environment])
+   fi
+
+   test "[$]2" = conftestfile
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+rm -f conftest*
+AC_MSG_RESULT(yes)])
+
+dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
+dnl The program must properly implement --version.
+AC_DEFUN(AM_MISSING_PROG,
+[AC_MSG_CHECKING(for working $2)
+# 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.
+if ($2 --version) < /dev/null > /dev/null 2>&1; then
+   $1=$2
+   AC_MSG_RESULT(found)
+else
+   $1="$3/missing $2"
+   AC_MSG_RESULT(missing)
+fi
+AC_SUBST($1)])
+
+# Like AC_CONFIG_HEADER, but automatically create stamp file.
+
+AC_DEFUN(AM_CONFIG_HEADER,
+[AC_PREREQ([2.12])
+AC_CONFIG_HEADER([$1])
+dnl When config.status generates a header, we must update the stamp-h file.
+dnl This file resides in the same directory as the config header
+dnl that is generated.  We must strip everything past the first ":",
+dnl and everything past the last "/".
+AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
+ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
+<<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
+<<am_indx=1
+for am_file in <<$1>>; do
+  case " <<$>>CONFIG_HEADERS " in
+  *" <<$>>am_file "*<<)>>
+    echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
+    ;;
+  esac
+  am_indx=`expr "<<$>>am_indx" + 1`
+done<<>>dnl>>)
+changequote([,]))])
+

+ 10 - 3
apprentice.c

@@ -36,7 +36,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.28 1998/09/12 13:17:52 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.29 1999/10/31 22:23:03 christos Exp $")
 #endif	/* lint */
 
 #define	EATAB {while (isascii((unsigned char) *l) && \
@@ -185,7 +185,7 @@ int *ndx, check;
 	struct magic *m;
 	char *t, *s;
 
-#define ALLOC_INCR	20
+#define ALLOC_INCR	200
 	if (nd+1 >= maxmagic){
 	    maxmagic += ALLOC_INCR;
 	    if ((magic = (struct magic *) realloc(magic, 
@@ -294,7 +294,10 @@ int *ndx, check;
 	}
 
 	/* get type, skip it */
-	if (strncmp(l, "byte", NBYTE)==0) {
+	if (strncmp(l, "char", NBYTE)==0) {	/* HP/UX compat */
+		m->type = BYTE;
+		l += NBYTE;
+	} else if (strncmp(l, "byte", NBYTE)==0) {
 		m->type = BYTE;
 		l += NBYTE;
 	} else if (strncmp(l, "short", NSHORT)==0) {
@@ -349,6 +352,10 @@ int *ndx, check;
 	case '=':
   		m->reln = *l;
   		++l;
+		if (*l == '=') {
+		   /* HP compat: ignore &= etc. */
+		   ++l;
+		}
 		break;
 	case '!':
 		if (m->type != STRING) {

+ 4 - 5
ascmagic.c

@@ -26,20 +26,19 @@
  * 4. This notice may not be removed or altered.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "file.h"
 #include <stdio.h>
 #include <string.h>
 #include <memory.h>
 #include <ctype.h>
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#include "file.h"
+#endif
 #include "names.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$Id: ascmagic.c,v 1.23 1998/06/27 13:23:39 christos Exp $");
+FILE_RCSID("@(#)$Id: ascmagic.c,v 1.24 1999/02/14 17:16:00 christos Exp $")
 #endif	/* lint */
 
 			/* an optimisation over plain strcmp() */

+ 7 - 5
compress.c

@@ -1,4 +1,3 @@
-
 /*
  * compress routines:
  *	zmagic() - returns 0 if not recognized, uncompresses and prints
@@ -6,20 +5,23 @@
  *	uncompress(method, old, n, newch) - uncompress old into new, 
  *					    using method, return sizeof new
  */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "file.h"
+#ifdef __CYGWIN__
+#include <errno.h>
 #endif
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <string.h>
+#include <errno.h>
 #include <sys/types.h>
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
 #endif
-#include "file.h"
 #ifndef lint
-FILE_RCSID("@(#)$Id: compress.c,v 1.12 1998/06/27 13:57:23 christos Exp $")
+FILE_RCSID("@(#)$Id: compress.c,v 1.14 1999/10/31 22:23:03 christos Exp $")
 #endif
 
 

+ 55 - 15
config.h.in

@@ -9,6 +9,12 @@
 /* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
 #undef HAVE_SYS_WAIT_H
 
+/* Define if major, minor, and makedev are declared in <mkdev.h>.  */
+#undef MAJOR_IN_MKDEV
+
+/* Define if major, minor, and makedev are declared in <sysmacros.h>.  */
+#undef MAJOR_IN_SYSMACROS
+
 /* Define to `long' if <sys/types.h> doesn't define.  */
 #undef off_t
 
@@ -18,18 +24,52 @@
 /* Define if you have the ANSI C header files.  */
 #undef STDC_HEADERS
 
-/* The number of bytes in a int.  */
-#undef SIZEOF_INT
-
-/* The number of bytes in a long.  */
-#undef SIZEOF_LONG
-
-#if(SIZEOF_INT==4)
-typedef int int32;
-typedef unsigned int uint32;
-#elif(SIZEOF_LONG==4)
-typedef long int32;
-typedef unsigned long uint32;
-#else
-#error "Can't find 32 bit types!!"
-#endif
+/* Define if builtin ELF support is enabled.  */
+#undef BUILTIN_ELF
+
+/* Define if ELF core file support is enabled.  */
+#undef ELFCORE
+
+/* Define if the `long long' type works.  */
+#undef HAVE_LONG_LONG
+
+/* Define to `unsigned char' if standard headers don't define.  */
+#undef uint8_t
+
+/* Define to `unsigned short' if standard headers don't define.  */
+#undef uint16_t
+
+/* Define to `unsigned int' if standard headers don't define.  */
+#undef uint32_t
+
+/* Define to `unsigned long long', if available, or `unsigned long', if
+   standard headers don't define.  */
+#undef uint64_t
+
+/* The number of bytes in a uint8_t.  */
+#define SIZEOF_UINT8_T 0
+
+/* The number of bytes in a uint16_t.  */
+#define SIZEOF_UINT16_T 0
+
+/* The number of bytes in a uint32_t.  */
+#define SIZEOF_UINT32_T 0
+
+/* The number of bytes in a uint64_t.  */
+#define SIZEOF_UINT64_T 0
+
+/* Define if you have the strerror function.  */
+#undef HAVE_STRERROR
+
+/* Define if you have the strtoul function.  */
+#undef HAVE_STRTOUL
+
+/* Define if you have the <unistd.h> header file.  */
+#undef HAVE_UNISTD_H
+
+/* Name of package */
+#undef PACKAGE
+
+/* Version number of package */
+#undef VERSION
+

File diff suppressed because it is too large
+ 1069 - 281
configure


+ 57 - 5
configure.in

@@ -1,21 +1,73 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_INIT(file.c)
-AC_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(file, 3.27)
+AM_CONFIG_HEADER(config.h)
+
+AC_MSG_CHECKING(for builtin ELF support)
+AC_ARG_ENABLE(elf,
+[  --disable-elf            disable builtin ELF support],
+[if test "${enableval}" = yes; then
+  AC_MSG_RESULT(yes)
+  AC_DEFINE(BUILTIN_ELF)
+else
+  AC_MSG_RESULT(no)
+fi], [
+  # enable by default
+  AC_MSG_RESULT(yes)
+  AC_DEFINE(BUILTIN_ELF)
+])
+
+AC_MSG_CHECKING(for ELF core file support)
+AC_ARG_ENABLE(elf-core,
+[  --disable-elf-core       disable ELF core file support],
+[if test "${enableval}" = yes; then
+  AC_MSG_RESULT(yes)
+  AC_DEFINE(ELFCORE)
+else
+  AC_MSG_RESULT(no)
+fi], [
+  # enable by default
+  AC_MSG_RESULT(yes)
+  AC_DEFINE(ELFCORE)
+])
 
 dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LN_S
 
+dnl Checks for headers
+AC_HEADER_STDC
+AC_HEADER_MAJOR
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS(unistd.h)
+
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
 AC_STRUCT_ST_RDEV
-AC_CHECK_SIZEOF(int,4)
-AC_CHECK_SIZEOF(long,4)
 
-dnl Checks for headers
-AC_HEADER_SYS_WAIT
+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_C_LONG_LONG
+if test $ac_cv_c_long_long = yes; then
+  long64='unsigned long long';
+else
+  long64='unsigned long';
+fi
+dnl This needs a patch to autoconf 2.13 acgeneral.m4
+AC_CHECK_TYPE2(uint64_t, $long64)
+
+AC_CHECK_SIZEOF_STDC_HEADERS(uint8_t, 0)
+AC_CHECK_SIZEOF_STDC_HEADERS(uint16_t, 0)
+AC_CHECK_SIZEOF_STDC_HEADERS(uint32_t, 0)
+AC_CHECK_SIZEOF_STDC_HEADERS(uint64_t, 0)
+
+dnl Checks for functions
+AC_CHECK_FUNCS(strerror strtoul)
 
 AC_OUTPUT(Makefile)

+ 1 - 1
debian/control

@@ -2,7 +2,7 @@ Source: file
 Section: utils
 Priority: standard
 Maintainer: Nicolás Lichtmaier <nick@debian.org>
-Standards-Version: 2.4.0.0
+Standards-Version: 3.1.0
 
 Package: file
 Architecture: any

+ 5 - 4
debian/README.debian

@@ -1,8 +1,9 @@
-This is Debian Linux's prepackaged version of file, a program to
-determine file type using "magic" numbers.
-
 This package was assembled by Nicolás Lichtmaier <nick@feedback.net.ar> with
-sources from ftp://ftp.astron.com/pub/file/file-3.26.tar.gz .
+sources from ftp://ftp.astron.com/pub/file/file-3.27.tar.gz .
 
 This package was previously maintained by Darren Stalder <torin@daft.com>
 and Bill Mitchell <mitchell@debian.org>.
+
+
+Upstream copyright and license information:
+

+ 26 - 14
debian/rules

@@ -4,7 +4,8 @@ package=file
 
 build:
 	$(checkdir)
-	./configure --prefix=/usr
+	./configure --prefix=/usr '--datadir=$${prefix}/share/misc' \
+		'--mandir=$${prefix}/share/man'
 	make
 	touch build
 
@@ -12,11 +13,12 @@ clean:
 	$(checkdir)
 	rm -f build changelog.tmp debian/copyright
 	if [ -r Makefile ]; then \
-		make clean; \
+		make distclean; \
 	fi
 	rm -f config.{log,cache,status} Makefile
-	rm -f `find . -name "*~"`
+	find . -name "*~" | xargs rm -f
 	rm -rf debian/tmp debian/files* core debian/substvars
+	dh_clean
 
 binary-indep:	checkroot build
 	$(checkdir)
@@ -27,17 +29,27 @@ binary-indep:	checkroot build
 binary-arch:	checkroot build
 	$(checkdir)
 	rm -rf debian/tmp
-	install -d debian/tmp/usr/bin debian/tmp/etc debian/tmp/usr/man/man1 debian/tmp/usr/man/man5
-	make install prefix=`pwd`/debian/tmp/usr INSTALL="/usr/bin/install -p" DESTDIR=`pwd`/debian/tmp
-
-	ln patchlevel.h changelog.tmp
-	ln LEGAL.NOTICE debian/copyright
-	debstd changelog.tmp README
-	rm -f changelog.tmp debian/copyright
-	dpkg-gencontrol
-	chown -R root.root debian/tmp
-	chmod -R go=rX debian/tmp
-	dpkg --build debian/tmp ..
+	install -d debian/tmp/usr/bin debian/tmp/etc debian/tmp/usr/share/man/man1 debian/tmp/usr/share/man/man5
+	make install prefix=`pwd`/debian/tmp/usr \
+		INSTALL="/usr/bin/install -p" # DESTDIR=`pwd`/debian/tmp
+	install -m644 -p magic.local `pwd`/debian/tmp/etc/magic
+
+	cat debian/copyright-prolog LEGAL.NOTICE > debian/copyright
+
+	dh_installdirs
+	dh_installdocs README
+	dh_installchangelogs patchlevel.h
+	dh_installmanpages
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_shlibdeps
+	dh_gencontrol
+	dh_installdeb
+	dh_md5sums
+	dh_builddeb
+
+	rm -f debian/copyright
 
 define checkdir
 	test -f debian/rules

+ 35 - 13
file.c

@@ -24,8 +24,9 @@
  *
  * 4. This notice may not be removed or altered.
  */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "file.h"
+#ifdef __CYGWIN__
+#include <errno.h>
 #endif
 #include <stdio.h>
 #include <stdlib.h>
@@ -45,35 +46,42 @@
 #  endif
 # endif
 #endif
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>	/* for read() */
+#endif
+
 #include <getopt.h>	/* for long options (is this portable?)*/
 
 #include <netinet/in.h>		/* for byte swapping */
 
 #include "patchlevel.h"
-#include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$Id: file.c,v 1.42 1998/09/12 13:17:52 christos Exp $")
+FILE_RCSID("@(#)$Id: file.c,v 1.47 1999/10/31 22:23:03 christos Exp $")
 #endif	/* lint */
 
 
 #ifdef S_IFLNK
-# define USAGE  "Usage: %s [-vbczL] [-f namefile] [-m magicfiles] file...\n"
+# define USAGE  "Usage: %s [-bcnvzL] [-f namefile] [-m magicfiles] file...\n"
 #else
-# define USAGE  "Usage: %s [-vbcz] [-f namefile] [-m magicfiles] file...\n"
+# define USAGE  "Usage: %s [-bcnvz] [-f namefile] [-m magicfiles] file...\n"
 #endif
 
 #ifndef MAGIC
 # define MAGIC "/etc/magic"
 #endif
 
+#ifndef MAXPATHLEN
+#define	MAXPATHLEN	512
+#endif
+
 int 			/* Global command-line options 		*/
 	debug = 0, 	/* debugging 				*/
 	lflag = 0,	/* follow Symlinks (BSD only) 		*/
 	bflag = 0,	/* brief output format	 		*/
-	zflag = 0;	/* follow (uncompress) compressed files */
-
+	zflag = 0,	/* follow (uncompress) compressed files */
+	sflag = 0,	/* read block special files		*/
+	nobuffer = 0;   /* Do not buffer stdout */
 int			/* Misc globals				*/
 	nmagic = 0;	/* number of valid magic[]s 		*/
 
@@ -108,6 +116,9 @@ Determine file type of FILEs.
                                before installing it
   -f, --files-from FILE      read the filenames to be examined from FILE
   -L, --dereference          causes symlinks to be followed
+  -n, --no-buffer            do not buffer output
+  -s, --special-files        treat special (block/char devices) files as
+                             ordinary ones
       --help                 display this help and exit
       --version              output version information and exit");
 	exit(0);
@@ -118,8 +129,8 @@ Determine file type of FILEs.
  */
 int
 main(argc, argv)
-int argc;
-char *argv[];
+	int argc;
+	char *argv[];
 {
 	int c,longindex;
 	int check = 0, didsomefiles = 0, errflg = 0, ret = 0, app = 0;
@@ -136,6 +147,8 @@ char *argv[];
 #endif
 		{"magic-file", 1, 0, 'm'},
 		{"uncompress", 0, 0, 'z'},
+		{"no-buffer", 0, 0, 'n'},
+		{"special-files", 0, 0, 's'},
 		{0, 0, 0, 0},
 	};
 	if ((progname = strrchr(argv[0], '/')) != NULL)
@@ -146,15 +159,16 @@ char *argv[];
 	if (!(magicfile = getenv("MAGIC")))
 		magicfile = MAGIC;
 
-	while ((c = getopt_long(argc, argv, "vbcdf:Lm:z",long_options,&longindex)) != EOF)
+	while ((c = getopt_long(argc, argv, "bcdnf:m:svzL",long_options,&longindex)) != EOF)
 		switch (c) {
 		case 0 :
 			if (longindex==1)
 				help();
 			break;
 		case 'v':
-			(void) fprintf(stdout, "%s-%d.%d\n", progname,
-				       FILE_VERSION_MAJOR, patchlevel);
+  			(void) fprintf(stdout, "%s-"VERSION"\n", progname);
+			(void) fprintf(stdout, "magic data from %s\n",
+				       magicfile);
 			return 1;
 		case 'b':
 			++bflag;
@@ -162,6 +176,9 @@ char *argv[];
 		case 'c':
 			++check;
 			break;
+		case 'n':
+			++nobuffer;
+			break;
 		case 'd':
 			++debug;
 			break;
@@ -186,6 +203,9 @@ char *argv[];
 		case 'z':
 			zflag++;
 			break;
+		case 's':
+			sflag++;
+			break;
 		case '?':
 		default:
 			errflg++;
@@ -258,6 +278,8 @@ char *fn;
 	while (fgets(buf, MAXPATHLEN, f) != NULL) {
 		buf[strlen(buf)-1] = '\0';
 		process(buf, wid);
+		if(nobuffer)
+			(void) fflush(stdout);
 	}
 
 	(void) fclose(f);

+ 21 - 19
file.h

@@ -1,6 +1,6 @@
 /*
  * file.h - definitions for file(1) program
- * @(#)$Id: file.h,v 1.27 1998/06/27 13:57:23 christos Exp $
+ * @(#)$Id: file.h,v 1.29 1999/02/14 17:16:06 christos Exp $
  *
  * Copyright (c) Ian F. Darwin, 1987.
  * Written by Ian F. Darwin.
@@ -29,8 +29,15 @@
 #ifndef __file_h__
 #define __file_h__
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+typedef int int32;
+typedef unsigned int uint32;
+
 #ifndef HOWMANY
-# define HOWMANY 8192		/* how much of the file to look at */
+# define HOWMANY 16384		/* how much of the file to look at */
 #endif
 #define MAXMAGIS 1000		/* max entries in /etc/magic */
 #define MAXDESC	50		/* max leng of text description */
@@ -43,12 +50,12 @@ struct magic {
 #define ADD	4		/* if '>&' appears,  */
 	short cont_level;	/* level of ">" */
 	struct {
-		char type;	/* byte short long */
+		unsigned char type;	/* byte short long */
 		int32 offset;	/* offset from indirection */
 	} in;
 	int32 offset;		/* offset to magic number */
 	unsigned char reln;	/* relation (0=eq, '>'=gt, etc) */
-	char type;		/* int, short, long or string. */
+	unsigned char type;	/* int, short, long or string. */
 	char vallen;		/* length of string value, if any */
 #define 			BYTE	1
 #define				SHORT	2
@@ -78,7 +85,7 @@ struct magic {
 #include <stdio.h>	/* Include that here, to make sure __P gets defined */
 
 #ifndef __P
-# if __STDC__ || __cplusplus
+# if defined(__STDC__) || defined(__cplusplus)
 #  define __P(a) a
 # else
 #  define __P(a) ()
@@ -104,7 +111,7 @@ extern int   zmagic		__P((unsigned char *, int));
 extern void  ckfprintf		__P((FILE *, const char *, ...));
 extern uint32 signextend	__P((struct magic *, unsigned int32));
 extern int internatmagic	__P((unsigned char *, int));
-extern void tryelf		__P((int, char *, int));
+extern void tryelf		__P((int, unsigned char *, int));
 
 
 extern int errno;		/* Some unixes don't define this..	*/
@@ -120,31 +127,22 @@ extern int nmagic;		/* number of valid magic[]s 		*/
 extern int debug;		/* enable debugging?			*/
 extern int zflag;		/* process compressed files?		*/
 extern int lflag;		/* follow symbolic links?		*/
+extern int sflag;		/* read/analyze block special files?	*/
 
 #if 0
 extern int optind;		/* From getopt(3)			*/
 extern char *optarg;
 #endif
 
-#if defined(sun) || defined(__sun__) || defined (__sun)
-# if defined(__svr4) || defined (__SVR4) || defined(__svr4__)
-#  define SOLARIS
-# else
-#  define SUNOS
-# endif
-#endif
-
-
-#if !defined(__STDC__) || defined(SUNOS) || defined(__convex__)
+#ifndef HAVE_STRERROR
 extern int sys_nerr;
 extern char *sys_errlist[];
 #define strerror(e) \
 	(((e) >= 0 && (e) < sys_nerr) ? sys_errlist[(e)] : "Unknown error")
-#define strtoul(a, b, c)	strtol(a, b, c)
 #endif
 
-#ifndef MAXPATHLEN
-#define	MAXPATHLEN	512
+#ifndef HAVE_STRTOUL
+#define strtoul(a, b, c)	strtol(a, b, c)
 #endif
 
 #ifdef __STDC__
@@ -156,4 +154,8 @@ static const char *rcsid(const char *p) { \
 #define FILE_RCSID(id) static char *rcsid[] = id;
 #endif
 
+#ifdef __CHECKER__
+#undef getc
+#endif
+
 #endif /* __file_h__ */

+ 68 - 19
file.man

@@ -1,12 +1,12 @@
 .TH FILE __CSECTION__ "November 1997" "Debian/GNU Linux" "Copyrighted but distributable"
-.\" $Id: file.man,v 1.31 1998/02/15 23:18:53 christos Exp $
+.\" $Id: file.man,v 1.33 1999/02/14 17:16:07 christos Exp $
 .SH NAME
 file
 \- determine file type
 .SH SYNOPSIS
 .B file
 [
-.B \-vbczL
+.B \-bcnsvzL
 ]
 [
 .B \-f
@@ -42,10 +42,9 @@ or
 meaning anything else (data is usually `binary' or non-printable).
 Exceptions are well-known file formats (core files, tar archives)
 that are known to contain binary data.
-When modifying the file
-.I __MAGIC__
-or the program itself, 
-.B "preserve these keywords" .
+When adding local definitions to
+.IR /etc/magic ,
+.BR "preserve these keywords" .
 People depend on knowing that all the readable files in a directory
 have the word ``text'' printed.
 Don't do as Berkeley did \- change ``shell commands text''
@@ -78,8 +77,8 @@ that the file is a binary executable, and which of several types thereof.
 The concept of `magic number' has been applied by extension to data files.
 Any file with some invariant identifier at a small fixed
 offset into the file can usually be described in this way.
-The information in these files is read from the magic file
-.I __MAGIC__.
+The information in these files is read by default from the magic files
+.IR /etc/magic " and " __MAGIC__ .
 .PP
 If an argument appears to be an
 .SM ASCII 
@@ -103,14 +102,7 @@ The language test routines also test for some miscellany
 .BR tar (1)
 archives) and determine whether an unknown file should be
 labelled as `ascii text' or `data'. 
-.SS OPTIONS
-.TP
-.I "\-m, \-\-magic-file list"
-Specify an alternate list of files containing magic numbers.
-This can be a single file, or a colon-separated list of files.
-.TP
-.I "\-z, \-\-uncompress"
-Try to look inside compressed files.
+.SH OPTIONS
 .TP 8
 .I "\-b, \-\-brief"
 Do not prepend filenames to output lines.
@@ -130,11 +122,43 @@ Either
 .I namefile
 or at least one filename argument must be present;
 to test the standard input, use ``-'' as a filename argument.
+.TP
+.I "\-m, \-\-magic-file list"
+Specify an alternate list of files containing magic numbers.
+This can be a single file, or a colon-separated list of files.
+.TP 8
+.I "\-n, \-\-no-buffer"
+Force stdout to be flushed after check a file. This is only useful if
+checking a list of files. It is intended to be used by programs want
+filetype output from a pipe.
+.TP
+.I "\-z, \-\-uncompress"
+Try to look inside compressed files.
 .TP 8
 .I "\-L, \-\-dereference"
 This option causes symlinks to be followed, as the like-named option in
 .BR ls (1).
-(on systems that support symbolic links).
+.TP 8
+.I "\-s, \-\-special-files"
+Normally,
+.B file
+only attempts to read and determine the type of argument files which
+.BR stat (2)
+reports are ordinary files.
+This prevents problems, because reading special files may have peculiar
+consequences.
+Specifying the
+.BR \-s
+option causes
+.B file
+to also read argument files which are block or character special files.
+This is useful for determining the filesystem types of the data in raw
+disk partitions, which are block special files.
+This option also causes
+.B file
+to disregard the file size as reported by
+.BR stat (2)
+since on some systems it reports a zero size for raw disk partitions.
 .TP
 .I "\-\-help"
 Print a help message and exit.
@@ -142,8 +166,12 @@ Print a help message and exit.
 .I "\-\-version"
 Print version information and exit.
 .SH FILES
+.TP
 .I __MAGIC__
-\- default list of magic numbers
+Default list of magic numbers.
+.TP
+.I /etc/magic
+Local additions to magic wisdom.
 .SH ENVIRONMENT
 The environment variable
 .B MAGIC
@@ -203,6 +231,27 @@ will be distributed periodically.
 The order of entries in the magic file is significant.
 Depending on what system you are using, the order that
 they are put together may be incorrect.
+.SH EXAMPLES
+.nf
+$ file file.c file /dev/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 -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
+/dev/hda:   x86 boot sector
+/dev/hda1:  Linux/i386 ext2 filesystem
+/dev/hda2:  x86 boot sector
+/dev/hda3:  x86 boot sector, extended partition table
+/dev/hda4:  Linux/i386 ext2 filesystem
+/dev/hda5:  Linux/i386 swap file
+/dev/hda6:  Linux/i386 swap file
+/dev/hda7:  Linux/i386 swap file
+/dev/hda8:  Linux/i386 swap file
+/dev/hda9:  empty
+/dev/hda10: empty
+.fi
 .SH HISTORY
 There has been a 
 .B file
@@ -248,7 +297,7 @@ the process running
 .RE
 .PP
 Changes by Ian Darwin and various authors including
-Christos Zoulas (christos@astron.com), 1990-1997.
+Christos Zoulas (christos@astron.com), 1990-1999.
 .SH LEGAL NOTICE
 Copyright (c) Ian F. Darwin, Toronto, Canada,
 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993.

+ 75 - 20
fsmagic.c

@@ -25,36 +25,39 @@
  * 4. This notice may not be removed or altered.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "file.h"
+#ifdef __CYGWIN__
+#include <errno.h>
 #endif
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <stdlib.h>
-#include "file.h"
-#ifndef major
-# if defined(__SVR4) || defined(_SVR4_SOURCE)
-#  include <sys/mkdev.h>
-# endif
+/* Since major is a function on SVR4, we can't use `ifndef major'.  */
+#ifdef MAJOR_IN_MKDEV
+# include <sys/mkdev.h>
+# define HAVE_MAJOR
 #endif
-#ifndef	major			/* if `major' not defined in types.h, */
-#include <sys/sysmacros.h>	/* try this one. */
+#ifdef MAJOR_IN_SYSMACROS
+# include <sys/sysmacros.h>
+# define HAVE_MAJOR
 #endif
-#ifndef	major	/* still not defined? give up, manual intervention needed */
-		/* If cc tries to compile this, read and act on it. */
-		/* On most systems cpp will discard it automatically */
-		Congratulations, you have found a portability bug.
-		Please grep /usr/include/sys and edit the above #include 
-		to point at the file that defines the "major" macro.
-#endif	/*major*/
-
-#include "file.h"
+#ifdef major			/* Might be defined in sys/types.h.  */
+# define HAVE_MAJOR
+#endif
+  
+#ifndef HAVE_MAJOR
+# define major(dev)  (((dev) >> 8) & 0xff)
+# define minor(dev)  ((dev) & 0xff)
+#endif
+#undef HAVE_MAJOR
 
 #ifndef	lint
-FILE_RCSID("@(#)$Id: fsmagic.c,v 1.27 1998/06/27 13:23:39 christos Exp $")
+FILE_RCSID("@(#)$Id: fsmagic.c,v 1.30 1999/10/31 22:23:03 christos Exp $")
 #endif	/* lint */
 
 int
@@ -83,36 +86,79 @@ struct stat *sb;
 		return 1;
 	}
 
+#ifdef S_ISUID
 	if (sb->st_mode & S_ISUID) ckfputs("setuid ", stdout);
+#endif
+#ifdef S_ISGID
 	if (sb->st_mode & S_ISGID) ckfputs("setgid ", stdout);
+#endif
+#ifdef S_ISVTX
 	if (sb->st_mode & S_ISVTX) ckfputs("sticky ", stdout);
+#endif
 	
 	switch (sb->st_mode & S_IFMT) {
 	case S_IFDIR:
 		ckfputs("directory", stdout);
 		return 1;
+#ifdef S_IFCHR
 	case S_IFCHR:
+		/* 
+		 * If -s has been specified, treat character special files
+		 * like ordinary files.  Otherwise, just report that they
+		 * are block special files and go on to the next file.
+		 */
+		if (sflag)
+			break;
 #ifdef HAVE_ST_RDEV
+# ifdef dv_unit
+		(void) printf("character special (%d/%d/%d)",
+			major(sb->st_rdev),
+			dv_unit(sb->st_rdev),
+			dv_subunit(sb->st_rdev));
+# else
 		(void) printf("character special (%ld/%ld)",
 			(long) major(sb->st_rdev), (long) minor(sb->st_rdev));
+# endif
 #else
 		(void) printf("character special");
 #endif
 		return 1;
+#endif
+#ifdef S_IFBLK
 	case S_IFBLK:
+		/* 
+		 * If -s has been specified, treat block special files
+		 * like ordinary files.  Otherwise, just report that they
+		 * are block special files and go on to the next file.
+		 */
+		if (sflag)
+			break;
 #ifdef HAVE_ST_RDEV
+# ifdef dv_unit
+		(void) printf("block special (%d/%d/%d)",
+			major(sb->st_rdev),
+			dv_unit(sb->st_rdev),
+			dv_subunit(sb->st_rdev));
+# else
 		(void) printf("block special (%ld/%ld)",
 			(long) major(sb->st_rdev), (long) minor(sb->st_rdev));
+# endif
 #else
 		(void) printf("block special");
 #endif
 		return 1;
+#endif
 	/* TODO add code to handle V7 MUX and Blit MUX files */
 #ifdef	S_IFIFO
 	case S_IFIFO:
 		ckfputs("fifo (named pipe)", stdout);
 		return 1;
 #endif
+#ifdef	S_IFDOOR
+	case S_IFDOOR:
+		ckfputs("door", stdout);
+		return 1;
+#endif
 #ifdef	S_IFLNK
 	case S_IFLNK:
 		{
@@ -181,8 +227,17 @@ struct stat *sb;
 
 	/*
 	 * regular file, check next possibility
+	 *
+	 * If stat() tells us the file has zero length, report here that
+	 * the file is empty, so we can skip all the work of opening and 
+	 * reading the file.
+	 * But if the -s option has been given, we skip this optimization,
+	 * since on some systems, stat() reports zero size for raw disk
+	 * partitions.  (If the block special device really has zero length,
+	 * the fact that it is empty will be detected and reported correctly
+	 * when we read the file.)
 	 */
-	if (sb->st_size == 0) {
+	if (!sflag && sb->st_size == 0) {
 		ckfputs("empty", stdout);
 		return 1;
 	}

+ 6 - 10
is_tar.c

@@ -2,10 +2,10 @@
  * is_tar() -- figure out whether file is a tar archive.
  *
  * Stolen (by the author!) from the public domain tar program:
- * Pubic Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
+ * 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.10 1998/06/27 13:23:39 christos Exp $
+ * $Id: is_tar.c,v 1.12 1999/02/14 17:16:08 christos Exp $
  *
  * Comments changed and some code/comments reformatted
  * for file command by Ian Darwin.
@@ -21,16 +21,12 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$Id: is_tar.c,v 1.10 1998/06/27 13:23:39 christos Exp $")
+FILE_RCSID("@(#)$Id: is_tar.c,v 1.12 1999/02/14 17:16:08 christos Exp $")
 #endif
 
 #define	isodigit(c)	( ((c) >= '0') && ((c) <= '7') )
 
-#if	defined(__STDC__) || defined(__cplusplus)
-static int from_oct(int, char*);	/* Decode octal number */
-#else
-static int from_oct();
-#endif
+static int from_oct __P((int, char *));	/* Decode octal number */
 
 /*
  * Return 
@@ -90,7 +86,7 @@ from_oct(digs, where)
 {
 	register int	value;
 
-	while (isspace(*where)) {		/* Skip spaces */
+	while (isspace((unsigned char)*where)) {		/* Skip spaces */
 		where++;
 		if (--digs <= 0)
 			return -1;		/* All blank field */
@@ -101,7 +97,7 @@ from_oct(digs, where)
 		--digs;
 	}
 
-	if (digs > 0 && *where && !isspace(*where))
+	if (digs > 0 && *where && !isspace((unsigned char)*where))
 		return -1;			/* Ended on non-space/nul */
 
 	return value;

+ 1 - 1
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 (__CSECTION__)
 command identifies the type of a file using,
 among other tests,
 a test for whether the file begins with a certain

+ 49 - 34
magic2mime

@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#! /usr/bin/perl -w
 # -*- PERL -*-
 # $Id: magic2mime,v 1.1 1998/02/15 23:18:53 christos Exp $
 # Copyright (c) 1996, 1997 vax@linkdead.paranoia.com (VaX#n8)
@@ -19,50 +19,65 @@
 @mapping =
 (
 	# defaults
-    'data', 'application/octet-stream',
-    'text', 'text/plain',
+    'data' => 'application/octet-stream',
+    'text' => 'text/plain',
 	# more specific
-	'^Rich Text Format data', 'text/richtext',
-	'^HTML document text', 'text/html',
-	'^exported SGML document text', 'text/sgml',
-	'mail text', 'message/rfc822',
-	'news text', 'message/news',
-	'^PostScript document text', 'application/postscript',
-	'^BinHex binary text', 'application/mac-binhex40',
-	'^Zip archive data', 'application/zip',
-	'^Microsoft Word', 'application/msword',
-	'^PGP key', 'application/pgp-keys',
-	'^PGP encrypted', 'application/pgp-encrypted',
-	'^PGP armored data signature', 'application/pgp-signature',
-    '^JPEG image', 'image/jpeg',
-    '^GIF image', 'image/gif',
-	'^PNG image', 'image/png',
-    '^TIFF image', 'image/tiff',
-	'Computer Graphics Metafile', 'image/cgf',
-	'^Sun/NeXT audio data', 'audio/basic',
-    '^MPEG', 'video/mpeg',
-    '^Apple QuickTime movie', 'video/quicktime',
+	'^Rich Text Format data' => 'text/richtext',
+	'^HTML document text' => 'text/html',
+	'^exported SGML document text' => 'text/sgml',
+	'mail text' => 'message/rfc822',
+	'news text' => 'message/news',
+	'^PostScript document text.*type EPS' => 'image/eps',
+	'^PostScript document text' => 'application/postscript',
+	'^PDF document' => 'application/pdf',
+	'^Rich Text Format' => 'application/rtf',
+	'^TeX DVI file' => 'application/x-dvi',
+	'^BinHex binary text' => 'application/mac-binhex40',
+	'^Zip archive data' => 'application/zip',
+	'Microsoft Word[ 0-9.]*document data' => 'application/msword',
+	'^PGP key' => 'application/pgp-keys',
+	'^PGP encrypted' => 'application/pgp-encrypted',
+	'^PGP armored data signature' => 'application/pgp-signature',
+    '^JPEG image' => 'image/jpeg',
+    '^GIF image' => 'image/gif',
+	'^PNG image' => 'image/png',
+    '^TIFF image' => 'image/tiff',
+	'Computer Graphics Metafile' => 'image/cgf',
+	'^Sun/NeXT audio data' => 'audio/basic',
+    '^MPEG.*layer 3 audio' => 'audio/mpeg',
+    '^MPEG' => 'video/mpeg',
+    '^Apple QuickTime movie' => 'video/quicktime',
+    '^X pixmap image' => 'image/x-xpixmap',
 	# made up by me
-    '^bitmap', 'image/x-bitmap',
-    '^PC bitmap data, Windows 3.x format', 'image/x-msw3bmp',
-    '^FLI', 'video/x-fli',
-    '^FLC', 'video/x-flc',
-    'AVI data', 'video/x-avi',
-    'WAVE', 'audio/x-wav',
-    'VOC', 'audio/x-voc',
+    '^bitmap' => 'image/x-bitmap',
+    '^PC bitmap data, Windows 3.x format' => 'image/x-msw3bmp',
+    '^FLI' => 'video/x-fli',
+    '^FLC' => 'video/x-flc',
+    'AVI data' => 'video/x-avi',
+    'WAVE' => 'audio/x-wav',
+    'VOC' => 'audio/x-voc',
+	'Debian binary package' => 'application/x-debian-package',
+	'compiled Java class data' => 'application/x-java',
+	'MPEG.*audio stream data' => 'audio/mpeg',
+	'Standard MIDI data' => 'audio/midi',
 );
 
-local($mimetype,$index,$regexp);
+my($mimetype,$index,$found);
 while (<>)
   {
     chop;
     $index = $#mapping - 1;
-    while ($index > -1 && !defined($mimetype))
+    $found = 0;
+    $mimetype = "application/octet-stream";
+    while ($index > -1 && !$found)
       {
-         $mimetype = $mapping[$index + 1] if (/$mapping[$index]/);
+         if(/$mapping[$index]/)
+         {
+		$mimetype = $mapping[$index + 1];
+		$found=1;
+         }
          $index -= 2;
       }
     print "$mimetype\n";
-	undef $mimetype; # hack
   }
 0;

+ 26 - 0
magic2mime.man

@@ -0,0 +1,26 @@
+.\" Manpage written by Nicolás Lichtmaier <nick@debian.org>
+.TH FILE __CSECTION__ "January 1999" "Debian/GNU Linux"
+.SH NAME
+file \- determine file type
+.SH SYNOPSIS
+.B magic2mime
+.SH DESCRIPTION
+This manual page documents version __VERSION__ of the
+.B magic2mime
+command.
+.PP
+This command receives the output of the
+.BR file (__CSECTION__)
+command and outputs a posible mime type for the data described;
+e. g.:
+.nf
+.nr 5i
+file -b files... | magic2mime.
+.fi
+.SH SEE ALSO
+.BR file (__CSECTION__)
+.br
+.SH BUGS
+This program depends on exact output from the
+.BR file (__CSECTION__)
+command.

+ 190 - 0
missing

@@ -0,0 +1,190 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+case "$1" in
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing - GNU libit 0.0"
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+  aclocal)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`acinclude.m4' or \`configure.in'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`configure.in'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`acconfig.h' or \`configure.in'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case "$f" in
+      *:*) touch_files="$touch_files "`echo "$f" |
+				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+	   sed 's/\.am$/.in/' |
+	   while read f; do touch "$f"; done
+    ;;
+
+  bison|yacc)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+	case "$LASTARG" in
+	*.y)
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" y.tab.c
+	    fi
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" y.tab.h
+	    fi
+	  ;;
+	esac
+    fi
+    if [ ! -f y.tab.h ]; then
+	echo >y.tab.h
+    fi
+    if [ ! -f y.tab.c ]; then
+	echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex|flex)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+	case "$LASTARG" in
+	*.l)
+	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" lex.yy.c
+	    fi
+	  ;;
+	esac
+    fi
+    if [ ! -f lex.yy.c ]; then
+	echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  makeinfo)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+    fi
+    touch $file
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+         system.  You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequirements for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0

+ 40 - 0
mkinstalldirs

@@ -0,0 +1,40 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+# $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $
+
+errstatus=0
+
+for file
+do
+   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+   shift
+
+   pathcomp=
+   for d
+   do
+     pathcomp="$pathcomp$d"
+     case "$pathcomp" in
+       -* ) pathcomp=./$pathcomp ;;
+     esac
+
+     if test ! -d "$pathcomp"; then
+        echo "mkdir $pathcomp"
+
+        mkdir "$pathcomp" || lasterr=$?
+
+        if test ! -d "$pathcomp"; then
+  	  errstatus=$lasterr
+        fi
+     fi
+
+     pathcomp="$pathcomp/"
+   done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here

+ 1 - 2
names.h

@@ -10,7 +10,7 @@
  *
  * See LEGAL.NOTICE
  *
- * $Id: names.h,v 1.15 1998/09/12 13:17:52 christos Exp $
+ * $Id: names.h,v 1.16 1999/01/13 15:44:08 christos Exp $
  */
 
 /* these types are used to index the table 'types': keep em in sync! */
@@ -104,7 +104,6 @@ static struct names {
 	{"double",	L_C},
 	{"extern",	L_C},
 	{"float",	L_C},
-	{"real",	L_C},
 	{"struct",	L_C},
 	{"union",	L_C},
 	{"CFLAGS",	L_MAKE},

+ 14 - 2
patchlevel.h

@@ -1,11 +1,23 @@
 #define	FILE_VERSION_MAJOR	3
-#define	patchlevel		26
+#define	patchlevel		28
 
 /*
  * Patchlevel file for Ian Darwin's MAGIC command.
- * $Id: patchlevel.h,v 1.26 1998/09/12 13:19:39 christos Exp $
+ * $Id: patchlevel.h,v 1.28 1999/10/31 22:11:48 christos Exp $
  *
  * $Log: patchlevel.h,v $
+ * Revision 1.28  1999/10/31 22:11:48  christos
+ * - add "char" type for compatibility with HP/UX
+ * - recognize HP/UX syntax &=n etc.
+ * - include errno.h for CYGWIN
+ * - conditionalize the S_IS* macros
+ * - revert the SHT_DYNSYM test that broke the linux stripped binaries test
+ * - lots of Magdir changes
+ *
+ * Revision 1.27  1999/02/14 17:21:41  christos
+ * Automake support and misc cleanups from Rainer Orth
+ * Enable reading character and block special files from Dale R. Worley
+ *
  * Revision 1.26  1998/09/12 13:19:39  christos
  * - add support for bi-endian indirect offsets (Richard Verhoeven)
  * - add recognition for bcpl (Joseph Myers)

+ 16 - 18
print.c

@@ -25,23 +25,22 @@
  * 4. This notice may not be removed or altered.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "file.h"
 #include <stdio.h>
 #include <string.h>
-#if __STDC__
+#ifdef __STDC__
 # include <stdarg.h>
 #else
 # include <varargs.h>
 #endif
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <time.h>
-#include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$Id: print.c,v 1.26 1998/06/27 13:57:23 christos Exp $")
+FILE_RCSID("@(#)$Id: print.c,v 1.29 1999/10/31 22:23:04 christos Exp $")
 #endif  /* lint */
 
 #define SZOF(a)	(sizeof(a) / sizeof(a[0]))
@@ -60,15 +59,14 @@ struct magic *m;
 
 	if (m->flag & INDIR)
 		(void) fprintf(stderr, "(%s,%d),",
-			       (m->in.type >= 0 && m->in.type < SZOF(typ)) ? 
-					typ[(unsigned char) m->in.type] :
-					"*bad*",
+			       /* Note: in.type is unsigned */
+			       (m->in.type < SZOF(typ)) ? 
+					typ[m->in.type] : "*bad*",
 			       m->in.offset);
 
 	(void) fprintf(stderr, " %s%s", (m->flag & UNSIGNED) ? "u" : "",
-		       (m->type >= 0 && m->type < SZOF(typ)) ? 
-				typ[(unsigned char) m->type] : 
-				"*bad*");
+		       /* Note: type is unsigned */
+		       (m->type < SZOF(typ)) ? typ[m->type] : "*bad*");
 	if (m->mask != ~((uint32)0))
 		(void) fprintf(stderr, " & %.8x", m->mask);
 
@@ -125,7 +123,7 @@ ckfputs(str, fil)
 
 /*VARARGS*/
 void
-#if __STDC__
+#ifdef __STDC__
 ckfprintf(FILE *f, const char *fmt, ...)
 #else
 ckfprintf(va_alist)
@@ -133,7 +131,7 @@ ckfprintf(va_alist)
 #endif
 {
 	va_list va;
-#if __STDC__
+#ifdef __STDC__
 	va_start(va, fmt);
 #else
 	FILE *f;
@@ -153,7 +151,7 @@ ckfprintf(va_alist)
  */
 /*VARARGS*/
 void
-#if __STDC__
+#ifdef __STDC__
 error(const char *f, ...)
 #else
 error(va_alist)
@@ -161,7 +159,7 @@ error(va_alist)
 #endif
 {
 	va_list va;
-#if __STDC__
+#ifdef __STDC__
 	va_start(va, f);
 #else
 	const char *f;
@@ -180,7 +178,7 @@ error(va_alist)
 
 /*VARARGS*/
 void
-#if __STDC__
+#ifdef __STDC__
 magwarn(const char *f, ...)
 #else
 magwarn(va_alist)
@@ -188,7 +186,7 @@ magwarn(va_alist)
 #endif
 {
 	va_list va;
-#if __STDC__
+#ifdef __STDC__
 	va_start(va, f);
 #else
 	const char *f;

+ 223 - 112
readelf.c

@@ -1,3 +1,4 @@
+#include "file.h"
 
 #ifdef BUILTIN_ELF
 #ifdef HAVE_CONFIG_H
@@ -8,47 +9,148 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <errno.h>
 
 #include "readelf.h"
-#include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$Id: readelf.c,v 1.9 1998/09/12 13:21:01 christos Exp $")
+FILE_RCSID("@(#)$Id: readelf.c,v 1.11 1999/10/31 22:23:04 christos Exp $")
 #endif
 
 #ifdef	ELFCORE
-static void dophn_core __P((int, off_t, int, size_t, char *));
+static void dophn_core __P((int, int, int, off_t, int, size_t));
 #endif
-static void dophn_exec __P((int, off_t, int, size_t, char *));
-static void doshn __P((int, off_t, int, size_t, char *));
+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 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(swap, value)
+	int swap;
+	uint16_t value;
+{
+	union {
+		uint16_t ui;
+		char c[2];
+	} retval, tmpval;
+
+	if (swap) {
+		tmpval.ui = value;
+
+		retval.c[0] = tmpval.c[1];
+		retval.c[1] = tmpval.c[0];
+		
+		return retval.ui;
+	} else
+		return value;
+}
+
+static uint32_t
+getu32(swap, value)
+	int swap;
+	uint32_t value;
+{
+	union {
+		uint32_t ui;
+		char c[4];
+	} retval, tmpval;
+
+	if (swap) {
+		tmpval.ui = value;
+
+		retval.c[0] = tmpval.c[3];
+		retval.c[1] = tmpval.c[2];
+		retval.c[2] = tmpval.c[1];
+		retval.c[3] = tmpval.c[0];
+		
+		return retval.ui;
+	} else
+		return value;
+}
+
+static uint64_t
+getu64(swap, value)
+	int swap;
+	uint64_t value;
+{
+	union {
+		uint64_t ui;
+		char c[8];
+	} retval, tmpval;
+
+	if (swap) {
+		tmpval.ui = value;
+
+		retval.c[0] = tmpval.c[7];
+		retval.c[1] = tmpval.c[6];
+		retval.c[2] = tmpval.c[5];
+		retval.c[3] = tmpval.c[4];
+		retval.c[4] = tmpval.c[3];
+		retval.c[5] = tmpval.c[2];
+		retval.c[6] = tmpval.c[1];
+		retval.c[7] = tmpval.c[0];
+		
+		return retval.ui;
+	} else
+		return value;
+}
+
+#define sh_addr		(class == ELFCLASS32		\
+			 ? (void *) &sh32		\
+			 : (void *) &sh64)
+#define shs_type	(class == ELFCLASS32		\
+			 ? getu32(swap, sh32.sh_type)	\
+			 : getu32(swap, sh64.sh_type))
+#define ph_addr		(class == ELFCLASS32		\
+			 ? (void *) &ph32		\
+			 : (void *) &ph64)
+#define ph_type		(class == ELFCLASS32		\
+			 ? getu32(swap, ph32.p_type)	\
+			 : getu32(swap, ph64.p_type))
+#define ph_offset	(class == ELFCLASS32		\
+			 ? getu32(swap, ph32.p_offset)	\
+			 : getu64(swap, ph64.p_offset))
+#define nh_size		(class == ELFCLASS32		\
+			 ? sizeof *nh32			\
+			 : sizeof *nh64)
+#define nh_type		(class == ELFCLASS32		\
+			 ? getu32(swap, nh32->n_type)	\
+			 : getu32(swap, nh64->n_type))
+#define nh_namesz	(class == ELFCLASS32		\
+			 ? getu32(swap, nh32->n_namesz)	\
+			 : getu32(swap, nh64->n_namesz))
+#define nh_descsz	(class == ELFCLASS32		\
+			 ? getu32(swap, nh32->n_descsz)	\
+			 : getu32(swap, nh64->n_descsz))
+#define prpsoffsets(i)	(class == ELFCLASS32		\
+			 ? prpsoffsets32[i]		\
+			 : prpsoffsets64[i])
 
 static void
-doshn(fd, off, num, size, buf)
+doshn(class, swap, fd, off, num, size)
+	int class;
+	int swap;
 	int fd;
 	off_t off;
 	int num;
 	size_t size;
-	char *buf;
 {
-	/*
-	 * This works for both 32-bit and 64-bit ELF formats,
-	 * because it looks only at the "sh_type" field, which is
-	 * always 32 bits, and is preceded only by the "sh_name"
-	 * field which is also always 32 bits, and because it uses
-	 * the shdr size from the ELF header rather than using
-	 * the size of an "Elf32_Shdr".
-	 */
-	Elf32_Shdr *sh = (Elf32_Shdr *) buf;
+	Elf32_Shdr sh32;
+	Elf64_Shdr sh64;
 
 	if (lseek(fd, off, SEEK_SET) == -1)
-		error("lseek failed (%m).\n");
+		error("lseek failed (%s).\n", strerror(errno));
 
 	for ( ; num; num--) {
-		if (read(fd, buf, size) == -1)
-			error("read failed (%m).\n");
-		if (sh->sh_type == SHT_SYMTAB) {
+		if (read(fd, sh_addr, size) == -1)
+			error("read failed (%s).\n", strerror(errno));
+		if (shs_type == SHT_SYMTAB /* || shs_type == SHT_DYNSYM */) {
 			(void) printf (", not stripped");
 			return;
 		}
@@ -62,15 +164,16 @@ doshn(fd, off, num, size, buf)
  * otherwise it's statically linked.
  */
 static void
-dophn_exec(fd, off, num, size, buf)
+dophn_exec(class, swap, fd, off, num, size)
+	int class;
+	int swap;
 	int fd;
 	off_t off;
 	int num;
 	size_t size;
-	char *buf;
 {
-	/* I am not sure if this works for 64 bit elf formats */
-	Elf32_Phdr *ph = (Elf32_Phdr *) buf;
+	Elf32_Phdr ph32;
+	Elf64_Phdr ph64;
 	char *linking_style = "statically";
 	char *shared_libraries = "";
 
@@ -78,10 +181,10 @@ dophn_exec(fd, off, num, size, buf)
 		error("lseek failed (%s).\n", strerror(errno));
 
   	for ( ; num; num--) {
-  		if (read(fd, buf, size) == -1)
+  		if (read(fd, ph_addr, size) == -1)
   			error("read failed (%s).\n", strerror(errno));
 
-		switch (ph->p_type) {
+		switch (ph_type) {
 		case PT_DYNAMIC:
 			linking_style = "dynamically";
 			break;
@@ -94,12 +197,19 @@ dophn_exec(fd, off, num, size, buf)
 }
 
 #ifdef ELFCORE
-size_t	prpsoffsets[] = {
+size_t	prpsoffsets32[] = {
 	84,		/* SunOS 5.x */
 	32,		/* Linux */
 };
 
-#define	NOFFSETS	(sizeof prpsoffsets / sizeof prpsoffsets[0])
+size_t	prpsoffsets64[] = {
+       120,		/* SunOS 5.x, 64-bit */
+};
+
+#define	NOFFSETS32	(sizeof prpsoffsets32 / sizeof prpsoffsets32[0])
+#define NOFFSETS64	(sizeof prpsoffsets64 / sizeof prpsoffsets64[0])
+
+#define NOFFSETS	(class == ELFCLASS32 ? NOFFSETS32 : NOFFSETS64)
 
 /*
  * Look through the program headers of an executable image, searching
@@ -113,19 +223,18 @@ size_t	prpsoffsets[] = {
  * containing the start of the command line for that program.
  */
 static void
-dophn_core(fd, off, num, size, buf)
+dophn_core(class, swap, fd, off, num, size)
+	int class;
+	int swap;
 	int fd;
 	off_t off;
 	int num;
 	size_t size;
-	char *buf;
 {
-	/*
-	 * This doesn't work for 64-bit ELF, as the "p_offset" field is
-	 * 64 bits in 64-bit ELF.
-	 */
-	Elf32_Phdr *ph = (Elf32_Phdr *) buf;
-	Elf32_Nhdr *nh;
+	Elf32_Phdr ph32;
+	Elf32_Nhdr *nh32;
+	Elf64_Phdr ph64;
+	Elf64_Nhdr *nh64;
 	size_t offset, noffset, reloffset;
 	unsigned char c;
 	int i, j;
@@ -134,32 +243,35 @@ dophn_core(fd, off, num, size, buf)
 
 	for ( ; num; num--) {
 		if (lseek(fd, off, SEEK_SET) == -1)
-			error("lseek failed (%m).\n");
-		if (read(fd, buf, size) == -1)
-			error("read failed (%m).\n");
+			error("lseek failed (%s).\n", strerror(errno));
+		if (read(fd, ph_addr, size) == -1)
+			error("read failed (%s).\n", strerror(errno));
 		off += size;
-		if (ph->p_type != PT_NOTE)
+		if (ph_type != PT_NOTE)
 			continue;
-		if (lseek(fd, ph->p_offset, SEEK_SET) == -1)
-			error("lseek failed (%m).\n");
+		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 (%m).\n");
+			error("read failed (%s).\n", strerror(errno));
 		offset = 0;
 		for (;;) {
 			if (offset >= bufsize)
 				break;
-			nh = (Elf32_Nhdr *)&nbuf[offset];
-			offset += sizeof *nh;
+			if (class == ELFCLASS32)
+				nh32 = (Elf32_Nhdr *)&nbuf[offset];
+			else
+				nh64 = (Elf64_Nhdr *)&nbuf[offset];
+			offset += nh_size;
 
 			/*
 			 * If this note isn't an NT_PRPSINFO note, it's
 			 * not what we're looking for.
 			 */
-			if (nh->n_type != NT_PRPSINFO) {
-				offset += nh->n_namesz;
+			if (nh_type != NT_PRPSINFO) {
+				offset += nh_namesz;
 				offset = ((offset + 3)/4)*4;
-				offset += nh->n_descsz;
+				offset += nh_descsz;
 				offset = ((offset + 3)/4)*4;
 				continue;
 			}
@@ -167,16 +279,16 @@ dophn_core(fd, off, num, size, buf)
 			/*
 			 * Make sure this note has the name "CORE".
 			 */
-			if (offset + nh->n_namesz >= bufsize) {
+			if (offset + nh_namesz >= bufsize) {
 				/*
 				 * We're past the end of the buffer.
 				 */
 				break;
 			}
-			if (nh->n_namesz != 5
+			if (nh_namesz != 5
 			    || strcmp(&nbuf[offset], "CORE") != 0)
 				continue;
-			offset += nh->n_namesz;
+			offset += nh_namesz;
 			offset = ((offset + 3)/4)*4;
 
 			/*
@@ -190,7 +302,7 @@ dophn_core(fd, off, num, size, buf)
 			 * it.
 			 */
 			for (i = 0; i < NOFFSETS; i++) {
-				reloffset = prpsoffsets[i];
+				reloffset = prpsoffsets(i);
 				noffset = offset + reloffset;
 				for (j = 0; j < 16;
 				    j++, noffset++, reloffset++) {
@@ -208,7 +320,7 @@ dophn_core(fd, off, num, size, buf)
 					 * are, this obviously isn't
 					 * the right offset.
 					 */
-					if (reloffset >= nh->n_descsz)
+					if (reloffset >= nh_descsz)
 						goto tryanother;
 
 					c = nbuf[noffset];
@@ -220,13 +332,13 @@ dophn_core(fd, off, num, size, buf)
 				 * Well, that worked.
 				 */
 				printf(", from '%.16s'",
-				    &nbuf[offset + prpsoffsets[i]]);
+				    &nbuf[offset + prpsoffsets(i)]);
 				return;
 
 			tryanother:
 				;
 			}
-			offset += nh->n_descsz;
+			offset += nh_descsz;
 			offset = ((offset + 3)/4)*4;
 		}
 	}
@@ -236,13 +348,15 @@ dophn_core(fd, off, num, size, buf)
 void
 tryelf(fd, buf, nbytes)
 	int fd;
-	char *buf;
+	unsigned char *buf;
 	int nbytes;
 {
 	union {
 		int32 l;
 		char c[sizeof (int32)];
 	} u;
+	int class;
+	int swap;
 
 	/*
 	 * ELF executables have multiple section headers in arbitrary
@@ -256,7 +370,9 @@ tryelf(fd, buf, nbytes)
 	    return;
 
 
-	if (buf[4] == ELFCLASS32) {
+	class = buf[4];
+
+	if (class == ELFCLASS32) {
 		Elf32_Ehdr elfhdr;
 		if (nbytes <= sizeof (Elf32_Ehdr))
 			return;
@@ -264,36 +380,36 @@ tryelf(fd, buf, nbytes)
 
 		u.l = 1;
 		(void) memcpy(&elfhdr, buf, sizeof elfhdr);
-		/*
-		 * If the system byteorder does not equal the
-		 * object byteorder then don't test.
-		 * XXX - we could conceivably fix up the "dophn_XXX()" and
-		 * "doshn()" routines to extract stuff in the right
-		 * byte order....
-		 */
-		if ((u.c[sizeof(long) - 1] + 1) == elfhdr.e_ident[5]) {
-			if (elfhdr.e_type == ET_CORE) 
+		swap = (u.c[sizeof(long) - 1] + 1) != elfhdr.e_ident[5];
+
+		if (getu16(swap, elfhdr.e_type) == ET_CORE) 
 #ifdef ELFCORE
-				dophn_core(fd, elfhdr.e_phoff, elfhdr.e_phnum, 
-				      elfhdr.e_phentsize, buf);
+			dophn_core(class, swap,
+				   fd,
+				   getu32(swap, elfhdr.e_phoff),
+				   getu16(swap, elfhdr.e_phnum), 
+				   getu16(swap, elfhdr.e_phentsize));
 #else
-				;
+			;
 #endif
-			else {
-				if (elfhdr.e_type == ET_EXEC) {
-					dophn_exec(fd,
-						   elfhdr.e_phoff,
-						   elfhdr.e_phnum, 
-						   elfhdr.e_phentsize, buf);
-				}
-				doshn(fd, elfhdr.e_shoff, elfhdr.e_shnum,
-				      elfhdr.e_shentsize, buf);
+		else {
+			if (getu16(swap, elfhdr.e_type) == ET_EXEC) {
+				dophn_exec(class, swap,
+					   fd,
+					   getu32(swap, elfhdr.e_phoff),
+					   getu16(swap, elfhdr.e_phnum), 
+					   getu16(swap, elfhdr.e_phentsize));
 			}
+			doshn(class, swap,
+			      fd,
+			      getu32(swap, elfhdr.e_shoff),
+			      getu16(swap, elfhdr.e_shnum),
+			      getu16(swap, elfhdr.e_shentsize));
 		}
 		return;
 	}
 
-        if (buf[4] == ELFCLASS64) {
+        if (class == ELFCLASS64) {
 		Elf64_Ehdr elfhdr;
 		if (nbytes <= sizeof (Elf64_Ehdr))
 			return;
@@ -301,49 +417,44 @@ tryelf(fd, buf, nbytes)
 
 		u.l = 1;
 		(void) memcpy(&elfhdr, buf, sizeof elfhdr);
+		swap = (u.c[sizeof(long) - 1] + 1) != elfhdr.e_ident[5];
 
-		/*
-		 * If the system byteorder does not equal the
-		 * object byteorder then don't test.
-		 * XXX - we could conceivably fix up the "dophn_XXX()" and
-		 * "doshn()" routines to extract stuff in the right
-		 * byte order....
-		 */
-		if ((u.c[sizeof(long) - 1] + 1) == elfhdr.e_ident[5]) {
-			if (elfhdr.e_type == ET_CORE) 
+		if (getu16(swap, elfhdr.e_type) == ET_CORE) 
 #ifdef ELFCORE
-				dophn_core(fd,
-#ifndef __GNUC__
-					   elfhdr.e_phoff[1],
+			dophn_core(class, swap,
+				   fd,
+#ifdef USE_ARRAY_FOR_64BIT_TYPES
+				   getu32(swap, elfhdr.e_phoff[1]),
 #else
-					   elfhdr.e_phoff,
+				   getu64(swap, elfhdr.e_phoff),
 #endif
-					   elfhdr.e_phnum, 
-					   elfhdr.e_phentsize, buf);
+				   getu16(swap, elfhdr.e_phnum), 
+				   getu16(swap, elfhdr.e_phentsize));
 #else
-				;
+			;
 #endif
-			else
-			{
-				if (elfhdr.e_type == ET_EXEC) {
-					dophn_exec(fd,
-#ifndef __GNUC__
-						   elfhdr.e_phoff[1],
+		else
+		{
+			if (getu16(swap, elfhdr.e_type) == ET_EXEC) {
+				dophn_exec(class, swap,
+					   fd,
+#ifdef USE_ARRAY_FOR_64BIT_TYPES
+					   getu32(swap, elfhdr.e_phoff[1]),
 #else
-						   elfhdr.e_phoff,
+					   getu64(swap, elfhdr.e_phoff),
 #endif
-						   elfhdr.e_phnum, 
-						   elfhdr.e_phentsize, buf);
-				}
-				doshn(fd,
-#ifndef __GNUC__
-				      elfhdr.e_shoff[1],
+					   getu16(swap, elfhdr.e_phnum), 
+					   getu16(swap, elfhdr.e_phentsize));
+			}
+			doshn(class, swap,
+			      fd,
+#ifdef USE_ARRAY_FOR_64BIT_TYPES
+			      getu32(swap, elfhdr.e_shoff[1]),
 #else
-				      elfhdr.e_shoff,
+			      getu64(swap, elfhdr.e_shoff),
 #endif
-				      elfhdr.e_shnum,
-				      elfhdr.e_shentsize, buf);
-			}
+			      getu16(swap, elfhdr.e_shnum),
+			      getu16(swap, elfhdr.e_shentsize));
 		}
 		return;
 	}

+ 33 - 19
readelf.h

@@ -1,6 +1,6 @@
 /*
  * readelf.h 
- * @(#)$Id: readelf.h,v 1.6 1998/09/12 13:21:01 christos Exp $
+ * @(#)$Id: readelf.h,v 1.7 1999/02/14 17:16:11 christos Exp $
  *
  * Provide elf data structures for non-elf machines, allowing file
  * non-elf hosts to determine if an elf binary is stripped.
@@ -9,23 +9,25 @@
 #ifndef __fake_elf_h__
 #define __fake_elf_h__
 
-typedef unsigned int	Elf32_Addr;
-typedef unsigned int	Elf32_Off;
-typedef unsigned short	Elf32_Half;
-typedef unsigned int	Elf32_Word;
-typedef unsigned char	Elf32_Char;
-
-#ifdef __GNUC__
-typedef	unsigned long long Elf64_Addr;
-typedef	unsigned long long Elf64_Off;
+typedef uint32_t	Elf32_Addr;
+typedef uint32_t	Elf32_Off;
+typedef uint16_t	Elf32_Half;
+typedef uint32_t	Elf32_Word;
+typedef uint8_t		Elf32_Char;
+
+#if SIZEOF_UINT64_T != 8
+#define USE_ARRAY_FOR_64BIT_TYPES
+typedef	uint32_t 	Elf64_Addr[2];
+typedef	uint32_t 	Elf64_Off[2];
+typedef uint32_t 	Elf64_Xword[2];
 #else
-/* XXX: We need 64 bit numbers here */
-typedef unsigned int	Elf64_Addr[2];
-typedef unsigned int	Elf64_Off[2];
+typedef	uint64_t 	Elf64_Addr;
+typedef	uint64_t 	Elf64_Off;
+typedef uint64_t 	Elf64_Xword;
 #endif
-typedef unsigned short	Elf64_Half;
-typedef unsigned int	Elf64_Word;
-typedef unsigned char	Elf64_Char;
+typedef uint16_t	Elf64_Half;
+typedef uint32_t	Elf64_Word;
+typedef uint8_t		Elf64_Char;
 
 #define EI_NIDENT	16
 
@@ -70,6 +72,7 @@ typedef struct {
 /* sh_type */
 #define SHT_SYMTAB	2
 #define SHT_NOTE	7
+#define SHT_DYNSYM	11
 
 /* elf type */
 #define ELFDATANONE	0		/* e_ident[EI_DATA] */
@@ -111,6 +114,17 @@ typedef struct {
     Elf32_Word	p_align;
 } Elf32_Phdr;
 
+typedef struct {
+    Elf64_Word	p_type;
+    Elf64_Word	p_flags;
+    Elf64_Off	p_offset;
+    Elf64_Addr	p_vaddr;
+    Elf64_Addr	p_paddr;
+    Elf64_Xword	p_filesz;
+    Elf64_Xword	p_memsz;
+    Elf64_Xword	p_align;
+} Elf64_Phdr;
+
 #define	PT_NULL		0		/* p_type */
 #define	PT_LOAD		1
 #define	PT_DYNAMIC	2
@@ -154,9 +168,9 @@ typedef struct {
 
 /* Note header in a PT_NOTE section */
 typedef struct elf_note {
-  Elf32_Word	n_namesz;	/* Name size */
-  Elf32_Word	n_descsz;	/* Content size */
-  Elf32_Word	n_type;		/* Content type */
+    Elf32_Word	n_namesz;	/* Name size */
+    Elf32_Word	n_descsz;	/* Content size */
+    Elf32_Word	n_type;		/* Content type */
 } Elf32_Nhdr;
 
 typedef struct {

+ 6 - 15
softmagic.c

@@ -25,19 +25,16 @@
  * 4. This notice may not be removed or altered.
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "file.h"
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <time.h>
 #include <sys/types.h>
 
-#include "file.h"
-
 #ifndef	lint
-FILE_RCSID("@(#)$Id: softmagic.c,v 1.38 1998/09/12 13:21:01 christos Exp $")
+FILE_RCSID("@(#)$Id: softmagic.c,v 1.39 1999/02/14 17:16:12 christos Exp $")
 #endif	/* lint */
 
 static int match	__P((unsigned char *, int));
@@ -234,15 +231,9 @@ struct magic *m;
 			t = m->offset + strlen(m->value.s);
 		}
 		else {
-#ifdef DEBUG_BUG_22854
-			if (*m->value.s == '\0') {
-#else
-                       if (*m->value.s == '\n') {
-#endif
-				char *cp = strchr(p->s,'\n');
-				if (cp)
-					*cp = '\0';
-			}
+			char *cp = strchr(p->s,'\n');
+			if (cp)
+				*cp = '\0';
 			(void) printf(m->desc, p->s);
 			t = m->offset + strlen(p->s);
 		}

+ 1 - 0
stamp-h.in

@@ -0,0 +1 @@
+timestamp

+ 1 - 5
tar.h

@@ -5,7 +5,7 @@
  *
  * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
  *
- * $Id: tar.h,v 1.4 1998/06/27 13:57:23 christos Exp $ # checkin only
+ * $Id: tar.h,v 1.5 1999/01/13 15:44:10 christos Exp $ # checkin only
  */
 
 /*
@@ -172,10 +172,6 @@ TAR_EXTERN char		read_error_flag;
  * Declarations of functions available to the world.
  */
 /*LINTLIBRARY*/
-union record *findrec();
-void userec();
-union record *endofrecs();
-void anno();
 #define	 annorec(stream, msg)	anno(stream, msg, 0)	/* Cur rec */
 #define	annofile(stream, msg)	anno(stream, msg, 1)	/* Saved rec */
 #endif