Browse Source

Import upstream version 3.28

Christos Zoulas 25 years ago
parent
commit
83e702bf6f
56 changed files with 3375 additions and 875 deletions
  1. 29 26
      LEGAL.NOTICE
  2. 7 4
      Magdir/amanda
  3. 77 1
      Magdir/animation
  4. 0 1
      Magdir/apple
  5. 14 0
      Magdir/archive
  6. 11 2
      Magdir/audio
  7. 3 3
      Magdir/compress
  8. 56 5
      Magdir/database
  9. 5 0
      Magdir/diff
  10. 28 3
      Magdir/elf
  11. 16 0
      Magdir/filesystems
  12. 7 3
      Magdir/gimp
  13. 20 0
      Magdir/grace
  14. 28 28
      Magdir/hp
  15. 14 14
      Magdir/images
  16. 61 0
      Magdir/jpeg
  17. 1 1
      Magdir/karma
  18. 7 2
      Magdir/mach
  19. 31 0
      Magdir/mcrypt
  20. 11 3
      Magdir/msdos
  21. 25 4
      Magdir/netbsd
  22. 24 0
      Magdir/os2
  23. 15 0
      Magdir/palm
  24. 2 0
      Magdir/printer
  25. 21 14
      Magdir/sgml
  26. 18 12
      Magdir/sniffer
  27. 28 0
      Magdir/spectrum
  28. 5 1
      Magdir/varied.out
  29. 68 0
      Makefile.am
  30. 497 172
      Makefile.in
  31. 2 2
      Makefile.std
  32. 0 76
      PORTING
  33. 42 0
      acconfig.h
  34. 79 0
      acinclude.m4
  35. 216 0
      aclocal.m4
  36. 10 3
      apprentice.c
  37. 4 2
      ascmagic.c
  38. 7 5
      compress.c
  39. 55 0
      config.h.in
  40. 1305 259
      configure
  41. 58 3
      configure.in
  42. 29 9
      file.c
  43. 14 19
      file.h
  44. 60 13
      file.man
  45. 75 19
      fsmagic.c
  46. 6 10
      is_tar.c
  47. 0 0
      missing
  48. 0 0
      mkinstalldirs
  49. 1 2
      names.h
  50. 14 2
      patchlevel.h
  51. 16 15
      print.c
  52. 217 109
      readelf.c
  53. 33 19
      readelf.h
  54. 1 4
      softmagic.c
  55. 1 0
      stamp-h.in
  56. 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

+ 77 - 1
Magdir/animation

@@ -11,7 +11,83 @@
 #>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         &0xfff0         MP
+# MPEG 1.0
+>1      byte&0x08       =0x08           \b
+# Layer 3
+>>1     byte            &0x02           \b3
+>>>2    byte&0xf0       =0x10           \b,  32 kBits
+>>>2    byte&0xf0       =0x20           \b,  40 kBits
+>>>2    byte&0xf0       =0x30           \b,  48 kBits
+>>>2    byte&0xf0       =0x40           \b,  56 kBits
+>>>2    byte&0xf0       =0x50           \b,  64 kBits
+>>>2    byte&0xf0       =0x60           \b,  80 kBits
+>>>2    byte&0xf0       =0x70           \b,  96 kBits
+>>>2    byte&0xf0       =0x80           \b, 112 kBits
+>>>2    byte&0xf0       =0x90           \b, 128 kBits
+>>>2    byte&0xf0       =0xA0           \b, 160 kBits
+>>>2    byte&0xf0       =0xB0           \b, 192 kBits
+>>>2    byte&0xf0       =0xC0           \b, 224 kBits
+>>>2    byte&0xf0       =0xD0           \b, 256 kBits
+>>>2    byte&0xf0       =0xE0           \b, 320 kBits
+# Layer 2
+>>1     byte            &0x04           \b2
+>>>2    byte&0xf0       =0x10           \b,  32 kBits
+>>>2    byte&0xf0       =0x20           \b,  48 kBits
+>>>2    byte&0xf0       =0x30           \b,  56 kBits
+>>>2    byte&0xf0       =0x40           \b,  64 kBits
+>>>2    byte&0xf0       =0x50           \b,  80 kBits
+>>>2    byte&0xf0       =0x60           \b,  96 kBits
+>>>2    byte&0xf0       =0x70           \b, 112 kBits
+>>>2    byte&0xf0       =0x80           \b, 128 kBits
+>>>2    byte&0xf0       =0x90           \b, 160 kBits
+>>>2    byte&0xf0       =0xA0           \b, 192 kBits
+>>>2    byte&0xf0       =0xB0           \b, 224 kBits
+>>>2    byte&0xf0       =0xC0           \b, 256 kBits
+>>>2    byte&0xf0       =0xD0           \b, 320 kBits
+>>>2    byte&0xf0       =0xE0           \b, 384 kBits
+# 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.0
+>1      byte&0x08       =0x00           \b
+# Layer 3
+>>1     byte            &0x02           \b3
+# Layer 2
+>>1     byte            &0x04           \b2
+>>2     byte&0xf0       =0x10           \b,   8 kBits
+>>2     byte&0xf0       =0x20           \b,  16 kBits
+>>2     byte&0xf0       =0x30           \b,  24 kBits
+>>2     byte&0xf0       =0x40           \b,  32 kBits
+>>2     byte&0xf0       =0x50           \b,  40 kBits
+>>2     byte&0xf0       =0x60           \b,  48 kBits
+>>2     byte&0xf0       =0x70           \b,  56 kBits
+>>2     byte&0xf0       =0x80           \b,  64 kBits
+>>2     byte&0xf0       =0x90           \b,  80 kBits
+>>2     byte&0xf0       =0xA0           \b,  96 kBits
+>>2     byte&0xf0       =0xB0           \b, 112 kBits
+>>2     byte&0xf0       =0xC0           \b, 128 kBits
+>>2     byte&0xf0       =0xD0           \b, 144 kBits
+>>2     byte&0xf0       =0xE0           \b, 160 kBits
+# 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

+ 14 - 0
Magdir/archive

@@ -214,3 +214,17 @@
 
 # Shell archives
 10	string		#\ This\ is\ a\ shell\ archive	shell archive text
+
+#
+# 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)

+ 11 - 2
Magdir/audio

@@ -67,12 +67,13 @@
 >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 file
-0	string		if		Composer 669 Module sound data
+#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
@@ -109,3 +110,11 @@
 # 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

+ 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,

+ 16 - 0
Magdir/filesystems

@@ -33,6 +33,7 @@
 >>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,
@@ -60,3 +61,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

+ 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

+ 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)

+ 14 - 14
Magdir/images

@@ -7,7 +7,20 @@
 # 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.
@@ -118,19 +131,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

+ 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

+ 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

+ 11 - 3
Magdir/msdos

@@ -87,6 +87,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
@@ -149,11 +150,15 @@
 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
+#
+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 +181,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

+ 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,

+ 24 - 0
Magdir/os2

@@ -21,3 +21,27 @@
 >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"

+ 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>

+ 21 - 14
Magdir/sgml

@@ -1,21 +1,28 @@
 
 #------------------------------------------------------------------------------
 # 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      \<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          XML document text
+0       string          \<?XML          XML document text
+0       string          \<?Xml          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)

+ 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'

+ 68 - 0
Makefile.am

@@ -0,0 +1,68 @@
+# don't enforce GNU packaging standards
+AUTOMAKE_OPTIONS = foreign no-dependencies
+
+bin_PROGRAMS = file
+
+data_DATA = magic
+
+MAGIC	 = @datadir@/magic
+CPPFLAGS = -DMAGIC='"$(MAGIC)"'
+
+man_MANS = file.1 magic.4
+
+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 Localstuff $(magic_FRAGMENTS)
+	cat $(srcdir)/Header $(srcdir)/Localstuff > $@
+	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__@4@g \
+	    -e s@__VERSION__@${VERSION}@g \
+	    -e s@__MAGIC__@${MAGIC}@g $(srcdir)/file.man > $@
+
+magic.4: Makefile magic.man
+	@rm -f $@
+	sed -e s@__CSECTION__@1@g \
+	    -e s@__FSECTION__@4@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

File diff suppressed because it is too large
+ 497 - 172
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)

+ 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
+])
+])

+ 216 - 0
aclocal.m4

@@ -0,0 +1,216 @@
+dnl aclocal.m4 generated automatically by aclocal 1.3
+
+dnl Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+dnl This Makefile.in 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([AM_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")
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION"))
+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])])
+
+
+# serial 1
+
+AC_DEFUN(AM_PROG_INSTALL,
+[AC_REQUIRE([AC_PROG_INSTALL])
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+AC_SUBST(INSTALL_SCRIPT)dnl
+])
+
+#
+# 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

@@ -33,7 +33,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) && \
@@ -182,7 +182,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, 
@@ -291,7 +291,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) {
@@ -346,6 +349,10 @@ int *ndx, check;
 	case '=':
   		m->reln = *l;
   		++l;
+		if (*l == '=') {
+		   /* HP compat: ignore &= etc. */
+		   ++l;
+		}
 		break;
 	case '!':
 		if (m->type != STRING) {

+ 4 - 2
ascmagic.c

@@ -26,17 +26,19 @@
  * 4. This notice may not be removed or altered.
  */
 
+#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

@@ -5,19 +5,21 @@
  *	uncompress(method, old, n, newch) - uncompress old into new, 
  *					    using method, return sizeof new
  */
+#include "file.h"
+#ifdef __CYGWIN__
+#include <errno.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#include <string.h>
-#ifdef HAVE_CONFIG_H
-#include "config.h"
 #endif
+#include <string.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 - 0
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
 
@@ -17,3 +23,52 @@
 
 /* Define if you have the ANSI C header files.  */
 #undef STDC_HEADERS
+
+/* 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
+
+/* 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

File diff suppressed because it is too large
+ 1305 - 259
configure


+ 58 - 3
configure.in

@@ -1,18 +1,73 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_INIT(file.c)
+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
 
-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 config.h)
+AC_OUTPUT(Makefile)

+ 29 - 9
file.c

@@ -24,6 +24,10 @@
  *
  * 4. This notice may not be removed or altered.
  */
+#include "file.h"
+#ifdef __CYGWIN__
+#include <errno.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -42,34 +46,40 @@
 #  endif
 # endif
 #endif
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>	/* for read() */
+#endif
 
 #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 		*/
 
@@ -94,8 +104,8 @@ int main __P((int, char *[]));
  */
 int
 main(argc, argv)
-int argc;
-char *argv[];
+	int argc;
+	char *argv[];
 {
 	int c;
 	int check = 0, didsomefiles = 0, errflg = 0, ret = 0, app = 0;
@@ -108,11 +118,13 @@ char *argv[];
 	if (!(magicfile = getenv("MAGIC")))
 		magicfile = MAGIC;
 
-	while ((c = getopt(argc, argv, "vbcdf:Lm:z")) != EOF)
+	while ((c = getopt(argc, argv, "bcdnf:m:svzL")) != EOF)
 		switch (c) {
 		case 'v':
 			(void) fprintf(stdout, "%s-%d.%d\n", progname,
 				       FILE_VERSION_MAJOR, patchlevel);
+			(void) fprintf(stdout, "magic file from %s\n",
+				       magicfile);
 			return 1;
 		case 'b':
 			++bflag;
@@ -120,6 +132,9 @@ char *argv[];
 		case 'c':
 			++check;
 			break;
+		case 'n':
+			++nobuffer;
+			break;
 		case 'd':
 			++debug;
 			break;
@@ -144,6 +159,9 @@ char *argv[];
 		case 'z':
 			zflag++;
 			break;
+		case 's':
+			sflag++;
+			break;
 		case '?':
 		default:
 			errflg++;
@@ -215,6 +233,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);

+ 14 - 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,11 +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 */
@@ -46,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
@@ -80,7 +84,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) ()
@@ -106,7 +110,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..	*/
@@ -122,29 +126,20 @@ 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?	*/
 
 extern int optind;		/* From getopt(3)			*/
 extern char *optarg;
 
-#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__

+ 60 - 13
file.man

@@ -1,12 +1,12 @@
 .TH FILE __CSECTION__ "Copyright 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
@@ -105,16 +105,6 @@ archives) and determine whether an unknown file should be
 labelled as `ascii text' or `data'. 
 .SH OPTIONS
 .TP 8
-.B \-v
-Print the version of the program and exit.
-.TP 8
-.B \-m list
-Specify an alternate list of files containing magic numbers.
-This can be a single file, or a colon-separated list of files.
-.TP 8
-.B \-z
-Try to look inside compressed files.
-.TP 8
 .B \-b
 Do not prepend filenames to output lines (brief mode).
 .TP 8
@@ -134,10 +124,46 @@ Either
 or at least one filename argument must be present;
 to test the standard input, use ``-'' as a filename argument.
 .TP 8
+.B \-m list
+Specify an alternate list of files containing magic numbers.
+This can be a single file, or a colon-separated list of files.
+.TP 8
+.B \-n
+Force stdout to be flushed after 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 8
+.B \-v
+Print the version of the program and exit.
+.TP 8
+.B \-z
+Try to look inside compressed files.
+.TP 8
 .B \-L
 option causes symlinks to be followed, as the like-named option in
 .BR ls (1).
 (on systems that support symbolic links).
+.TP 8
+.B \-s
+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.
 .SH FILES
 .I __MAGIC__
 \- default list of magic numbers
@@ -206,6 +232,27 @@ command uses a magic file,
 keep the old magic file around for comparison purposes
 (rename it to 
 .IR __MAGIC__.orig ).
+.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
@@ -251,7 +298,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 - 19
fsmagic.c

@@ -25,35 +25,39 @@
  * 4. This notice may not be removed or altered.
  */
 
+#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>
-#ifdef HAVE_CONFIG_H
-#include "config.h"
+/* 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 defined(__SVR4) || defined(_SVR4_SOURCE)
-#  include <sys/mkdev.h>
-# endif
+#ifdef MAJOR_IN_SYSMACROS
+# include <sys/sysmacros.h>
+# define HAVE_MAJOR
 #endif
-#ifndef	major			/* if `major' not defined in types.h, */
-#include <sys/sysmacros.h>	/* try this one. */
+#ifdef major			/* Might be defined in sys/types.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"
+  
+#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
@@ -82,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 +228,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.
@@ -18,16 +18,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 
@@ -87,7 +83,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 */
@@ -98,7 +94,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;

+ 0 - 0
missing


+ 0 - 0
mkinstalldirs


+ 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 - 15
print.c

@@ -25,21 +25,23 @@
  * 4. This notice may not be removed or altered.
  */
 
+#include "file.h"
 #include <stdio.h>
 #include <errno.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]))
@@ -58,15 +60,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);
 
@@ -123,7 +124,7 @@ ckfputs(str, fil)
 
 /*VARARGS*/
 void
-#if __STDC__
+#ifdef __STDC__
 ckfprintf(FILE *f, const char *fmt, ...)
 #else
 ckfprintf(va_alist)
@@ -131,7 +132,7 @@ ckfprintf(va_alist)
 #endif
 {
 	va_list va;
-#if __STDC__
+#ifdef __STDC__
 	va_start(va, fmt);
 #else
 	FILE *f;
@@ -151,7 +152,7 @@ ckfprintf(va_alist)
  */
 /*VARARGS*/
 void
-#if __STDC__
+#ifdef __STDC__
 error(const char *f, ...)
 #else
 error(va_alist)
@@ -159,7 +160,7 @@ error(va_alist)
 #endif
 {
 	va_list va;
-#if __STDC__
+#ifdef __STDC__
 	va_start(va, f);
 #else
 	const char *f;
@@ -178,7 +179,7 @@ error(va_alist)
 
 /*VARARGS*/
 void
-#if __STDC__
+#ifdef __STDC__
 magwarn(const char *f, ...)
 #else
 magwarn(va_alist)
@@ -186,7 +187,7 @@ magwarn(va_alist)
 #endif
 {
 	va_list va;
-#if __STDC__
+#ifdef __STDC__
 	va_start(va, f);
 #else
 	const char *f;

+ 217 - 109
readelf.c

@@ -1,3 +1,4 @@
+#include "file.h"
 
 #ifdef BUILTIN_ELF
 #include <sys/types.h>
@@ -5,50 +6,148 @@
 #include <stdio.h>
 #include <ctype.h>
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif
 #include <errno.h>
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
 #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 (%s).\n", strerror(errno));
 
 	for ( ; num; num--) {
-		if (read(fd, buf, size) == -1)
+		if (read(fd, sh_addr, size) == -1)
 			error("read failed (%s).\n", strerror(errno));
-		if (sh->sh_type == SHT_SYMTAB) {
+		if (shs_type == SHT_SYMTAB /* || shs_type == SHT_DYNSYM */) {
 			(void) printf (", not stripped");
 			return;
 		}
@@ -62,15 +161,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 +178,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 +194,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 +220,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;
@@ -135,12 +241,12 @@ dophn_core(fd, off, num, size, buf)
 	for ( ; num; num--) {
 		if (lseek(fd, off, SEEK_SET) == -1)
 			error("lseek failed (%s).\n", strerror(errno));
-		if (read(fd, buf, size) == -1)
+		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)
+		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)
@@ -149,17 +255,20 @@ dophn_core(fd, off, num, size, buf)
 		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 +276,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 +299,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 +317,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 +329,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 +345,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 +367,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 +377,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 +414,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 {

+ 1 - 4
softmagic.c

@@ -31,13 +31,10 @@
 #include <time.h>
 #include <sys/types.h>
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
 #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));

+ 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