Browse Source

Import upstream version 3.24

Christos Zoulas 23 years ago
parent
commit
4d593e3827
83 changed files with 3696 additions and 1297 deletions
  1. 2 2
      MAINT
  2. 2 2
      Magdir/Header
  3. 5 0
      Magdir/alpha
  4. 7 0
      Magdir/amanda
  5. 10 0
      Magdir/amigaos
  6. 5 1
      Magdir/animation
  7. 4 2
      Magdir/apple
  8. 12 13
      Magdir/archive
  9. 17 0
      Magdir/asterix
  10. 5 4
      Magdir/att3b
  11. 41 9
      Magdir/audio
  12. 7 0
      Magdir/bsdi
  13. 10 0
      Magdir/cisco
  14. 24 0
      Magdir/commands
  15. 29 9
      Magdir/compress
  16. 64 2
      Magdir/convex
  17. 12 10
      Magdir/database
  18. 41 0
      Magdir/digital
  19. 2 2
      Magdir/dump
  20. 38 16
      Magdir/elf
  21. 30 0
      Magdir/filesystems
  22. 10 0
      Magdir/fonts
  23. 1 0
      Magdir/frame
  24. 81 48
      Magdir/freebsd
  25. 62 23
      Magdir/hp
  26. 28 0
      Magdir/ibm370
  27. 2 1
      Magdir/ibm6000
  28. 17 1
      Magdir/images
  29. 1 1
      Magdir/intel
  30. 9 0
      Magdir/island
  31. 9 2
      Magdir/java
  32. 4 0
      Magdir/lecter
  33. 10 3
      Magdir/linux
  34. 8 0
      Magdir/lisp
  35. 79 0
      Magdir/macintosh
  36. 3 3
      Magdir/mail.news
  37. 7 0
      Magdir/mime
  38. 33 0
      Magdir/modem
  39. 99 7
      Magdir/msdos
  40. 30 13
      Magdir/netbsd
  41. 86 0
      Magdir/os9
  42. 7 0
      Magdir/osf1
  43. 21 2
      Magdir/printer
  44. 20 11
      Magdir/sgi
  45. 79 0
      Magdir/sniffer
  46. 21 0
      Magdir/sun
  47. 36 0
      Magdir/ti-8x
  48. 2 0
      Magdir/timezone
  49. 6 0
      Magdir/varied.out
  50. 26 0
      Magdir/vgetty
  51. 1 1
      Magdir/microsoft
  52. 33 31
      Makefile
  53. 11 8
      orig/Makefile
  54. 22 20
      README
  55. 7 12
      apprentice.c
  56. 9 7
      ascmagic.c
  57. 6 1
      compress.c
  58. 16 0
      config.h.in
  59. 1393 0
      configure
  60. 15 0
      configure.in
  61. 0 20
      file-3.20.1.lsm
  62. 39 62
      file.c
  63. 26 8
      file.h
  64. 13 9
      file.man
  65. 21 5
      fsmagic.c
  66. 238 0
      install-sh
  67. 82 0
      internat.c
  68. 6 6
      is_tar.c
  69. 68 0
      magic2mime
  70. 17 9
      names.h
  71. 0 61
      orig/Magdir_elf
  72. 0 26
      orig/Magdir_fonts
  73. 0 0
      orig/Magdir_freebsd
  74. 0 224
      orig/Magdir_images
  75. 0 35
      orig/Magdir_intel
  76. 0 73
      orig/Magdir_linux
  77. 0 79
      orig/README
  78. 0 365
      orig/file.man
  79. 42 2
      patchlevel.h
  80. 7 5
      print.c
  81. 315 0
      readelf.c
  82. 95 2
      readelf.h
  83. 50 39
      softmagic.c

+ 2 - 2
MAINT

@@ -1,4 +1,4 @@
-$Id: MAINT,v 1.2 1993/09/23 21:47:01 christos Exp $
+$Id: MAINT,v 1.3 1997/11/05 16:03:18 christos Exp $
 
 Maintenance notes:
 
@@ -30,4 +30,4 @@ your changed version.
 Thank you for your assistance and cooperation.
 
 Mark Moraes		Christos Zoulas
-moraes@deshaw.com	christos@deshaw.com
+moraes@deshaw.com	christos@astron.com

+ 2 - 2
Magdir/Header

@@ -1,5 +1,5 @@
 #! file
 # Magic data for file(1) command.
-# Machine-genererated from src/cmd/file/magdir/*; edit there only!
+# Machine-generated from src/cmd/file/magdir/*; edit there only!
 # Format is described in magic(files), where:
-# files is 4 on V7 and BSD, 4 on SV, and ?? in the SVID.
+# files is 5 on V7 and BSD, 4 on SV, and ?? in the SVID.

+ 5 - 0
Magdir/alpha

@@ -14,3 +14,8 @@
 >27	byte		x		- version %d
 >26	byte		x		.%d
 >28	byte		x		-%d
+
+# Basic recognition of Digital UNIX core dumps - Mike Bremford <mike@opac.bl.uk>
+#
+0	string		Core\001	Alpha COFF format core dump (Digital UNIX)
+>24	string		>\0		\b, from '%s'

+ 7 - 0
Magdir/amanda

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

+ 10 - 0
Magdir/amigaos

@@ -0,0 +1,10 @@
+#------------------------------------------------------------------------------
+# amigaos:  file(1) magic for AmigaOS binary formats:
+
+#
+# From ignatios@cs.uni-bonn.de (Ignatios Souvatzis)
+# Some formats are still missing: AmigaOS special IFF's, e.g.: FORM....CTLG
+# (the others should be seperate, anyway)
+#
+0	belong		0x000003f3	AmigaOS loadseg()ble executable/binary
+0	belong		0x000003e7	AmigaOS object/library data

+ 5 - 1
Magdir/animation

@@ -7,7 +7,11 @@
 # FLC, SGI, Apple originally from Daniel Quinlan (quinlan@yggdrasil.com)
 
 # MPEG animation format
-0	string		\000\000\001\263	MPEG file
+0	belong		0x000001b3		MPEG video stream data
+#>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
 
 # FLI animation format
 4	leshort		0xAF11			FLI file

+ 4 - 2
Magdir/apple

@@ -1,10 +1,12 @@
 
 #------------------------------------------------------------------------------
-# apple:  file(1) magic for Apple II file formats
+# apple:  file(1) magic for Apple file formats
 #
 0	string		FiLeStArTfIlEsTaRt	binscii (apple ][) text
 0	string		\x0aGL			Binary II (apple ][) data
 0	string		\x76\xff		Squeezed (apple ][) data
-0	string		SIT!			StuffIt (macintosh) text
 0	string		NuFile			NuFile archive (apple ][) data
 0	string		N\xf5F\xe9l\xe5		NuFile archive (apple ][) data
+0	belong		0x00051600		AppleSingle encoded Macintosh file
+0	belong		0x00051607		AppleDouble encoded Macintosh file
+

+ 12 - 13
Magdir/archive

@@ -27,6 +27,14 @@
 0	string		070701		ASCII cpio archive (SVR4 with no CRC)
 0	string		070702		ASCII cpio archive (SVR4 with CRC)
 
+# Debian package (needs to go before regular portable archives)
+#
+0	string		!<arch>\ndebian
+>8	string		debian-split	part of multipart Debian package
+>8	string		debian-binary	Debian binary package
+>68	string		>\n		(format %s)
+>136	ledate		x		created: %s
+
 # other archives
 0	long		0177555		very old archive
 0	short		0177555		very old PDP-11 archive
@@ -35,7 +43,7 @@
 0	long		0100554		apl workspace
 0	string		=<ar>		archive
 
-# MIPS archive (needs to go first)
+# MIPS archive (needs to go before regular portable archives)
 #
 0	string	!<arch>\n__________E	MIPS archive
 >20	string	U			with MIPS Ucode members
@@ -45,8 +53,6 @@
 >19	string	B			and an EB hash table
 >22	string	X			-- out of date
 
-0	string		!<arch>		archive
->8	string		__.SYMDEF	random library
 0	string		-h-		Software Tools format archive text
 
 #
@@ -56,11 +62,10 @@
 # 0	string		!<arch>		current ar archive
 # 0	long		0x213c6172	archive file
 #
-# and for SVR3.1 archives, we have:
+# and for SVR1 archives, we have:
 #
 # 0	string		\<ar>		System V Release 1 ar archive
 # 0	string		=<ar>		archive
-# 0	string		=<ar>		archive
 #
 # XXX - did Aegis really store shared libraries, breakpointed modules,
 # and absolute code program modules in the same format as new-style
@@ -68,8 +73,6 @@
 #
 0	string		!<arch>		current ar archive
 >8	string		__.SYMDEF	random library
->8	string		debian-split	part of multipart Debian package
->8	string		debian-binary	Debian binary package
 >0	belong		=65538		- pre SR9.5
 >0	belong		=65539		- post SR9.5
 >0	beshort		2		- object archive
@@ -98,14 +101,10 @@
 0	leshort		0177545		old PDP-11 archive
 >8	string		__.SYMDEF	random library
 #
-0	string		=<ar>		archive
-#
-# From "pdp":
+# From "pdp" (but why a 4-byte quantity?)
 #
 0	lelong		0x39bed		PDP-11 old archive
 0	lelong		0x39bee		PDP-11 4.0 archive
-#
-0	string		-h-		Software Tools format archive text
 
 # ARC archiver, from Daniel Quinlan (quinlan@yggdrasil.com)
 #
@@ -177,7 +176,7 @@
 2	string		-lz5-		LHarc 1.x archive data [lz5]
 #	[never seen any but the last; -lh4- reported in comp.compression:]
 2	string		-lzs-		LHa 2.x? archive data [lzs]
-2	string		-lh -		LHa 2.x? archive data [lh ]
+2	string		-lh\40-		LHa 2.x? archive data [lh ]
 2	string		-lhd-		LHa 2.x? archive data [lhd]
 2	string		-lh2-		LHa 2.x? archive data [lh2]
 2	string		-lh3-		LHa 2.x? archive data [lh3]

+ 17 - 0
Magdir/asterix

@@ -0,0 +1,17 @@
+
+#------------------------------------------------------------------------------
+# asterix:  file(1) magic for Aster*x; SunOS 5.5.1 gave the 4-character
+# strings as "long" - we assume they're just strings:
+# From: guy@netapp.com (Guy Harris)
+#
+0	string		*STA		Aster*x
+>7	string		WORD			Words Document
+>7	string		GRAP			Graphic
+>7	string		SPRE			Spreadsheet
+>7	string		MACR			Macro
+0	string		2278		Aster*x Version 2
+>29	byte		0x36			Words Document
+>29	byte		0x35			Graphic
+>29	byte		0x32			Spreadsheet
+>29	byte		0x38			Macro
+

+ 5 - 4
Magdir/att3b

@@ -7,11 +7,12 @@
 #
 # 3B20
 #
-0	beshort		0550		3b20 COFF executable
->12	belong		>0		not stripped
+# The 3B20 conflicts with SCCS.
+#0	beshort		0550		3b20 COFF executable
+#>12	belong		>0		not stripped
 #>22	beshort		>0		- version %ld
-0	beshort		0551		3b20 COFF executable (TV)
->12	belong		>0		not stripped
+#0	beshort		0551		3b20 COFF executable (TV)
+#>12	belong		>0		not stripped
 #>22	beshort		>0		- version %ld
 #
 # WE32K

+ 41 - 9
Magdir/audio

@@ -16,6 +16,10 @@
 >12	belong		6		32-bit IEEE floating point,
 >12	belong		7		64-bit IEEE floating point,
 >12	belong		23		8-bit ISDN u-law compressed (CCITT G.721 ADPCM voice data encoding),
+>12	belong		24		compressed (8-bit G.722 ADPCM)
+>12	belong		25		compressed (3-bit G.723 ADPCM),
+>12	belong		26		compressed (5-bit G.723 ADPCM),
+>12	belong		27		8-bit A-law,
 >20	belong		1		mono,
 >20	belong		2		stereo,
 >20	belong		4		quad,
@@ -54,14 +58,13 @@
 >4	belong		x		- version %ld
 
 # Microsoft WAVE format (*.wav)
-# [GRR 950115:  probably all of the shorts and longs should be leshort/lelong]
 0	string		RIFF		Microsoft RIFF
 >8	string		WAVE		\b, WAVE audio data
->>34	short		>0		\b, %d bit
->>22	short		=1		\b, mono
->>22	short		=2		\b, stereo
->>22	short		>2		\b, %d channels
->>24	long		>0		%d Hz
+>>34	leshort		>0		\b, %d bit
+>>22	leshort		=1		\b, mono
+>>22	leshort		=2		\b, stereo
+>>22	leshort		>2		\b, %d channels
+>>24	lelong		>0		%d Hz
 # AVI == Audio Video Interleave
 >8      string          AVI\            \b, AVI data
 
@@ -77,9 +80,6 @@
 # Real Audio (Magic .ra\0375)
 0	belong		0x2e7261fd	realaudio sound file
 
-# Real Audio (Magic .ra\0375)
-0	belong		0x2e7261fd	realaudio sound file
-
 # MTM/669/FAR/S3M/ULT/XM format checking [Aaron Eppert, aeppert@dialin.ind.net]
 # Oct 31, 1995
 0	string		MTM		MultiTracker Module sound file
@@ -88,3 +88,35 @@
 0	string		MAS_U		ULT(imate) Module sound data
 0x2c	string		SCRM		ScreamTracker III Module sound data
 0	string		Extended Module	Extended Module sound data
+
+# Gravis UltraSound patches
+# From <ache@nagual.ru>
+
+0	string		GF1PATCH110\0ID#000002\0	GUS patch
+0	string		GF1PATCH100\0ID#000002\0	Old GUS	patch
+
+#
+# Taken from loader code from mikmod version 2.14
+# by Steve McIntyre (stevem@chiark.greenend.org.uk)
+0	string	JN		extended 669 module data
+0	string	MAS_UTrack_V00
+>14	string	>/0		ultratracker V1.%.1s module sound data
+0	string	UN05		MikMod UNI format module sound data
+0	string	Extended\ Module: Fasttracker II module sound data
+21	string	!SCREAM!	Screamtracker 2 module sound data
+1080	string	M.K.		4-channel Protracker module sound data
+1080	string	M!K!		4-channel Protracker module sound data
+1080	string	FLT4		4-channel Startracker module sound data
+1080	string	4CHN		4-channel Fasttracker module sound data
+1080	string	6CHN		6-channel Fasttracker module sound data
+1080	string	8CHN		8-channel Fasttracker module sound data
+1080	string	CD81		8-channel Oktalyzer module sound data
+1080	string	OKTA		8-channel Oktalyzer module sound data
+1082	string	CH
+>1080	string	>/0		%.2s-channel Fasttracker "oktalyzer" module sound data
+1080	string	16CN		16-channel Taketracker module sound data
+1080	string	32CN		32-channel Taketracker module sound data
+
+# TOC sound files -Trevor Johnson <trevor@jpj.net>
+#
+0       string          TOC             TOC sound file

+ 7 - 0
Magdir/bsdi

@@ -0,0 +1,7 @@
+
+#------------------------------------------------------------------------------
+# bsdi:  file(1) magic for BSD/OS (from BSDI) objects
+#
+0	lelong			000000314	BSD/OS i386 compact demand paged executable
+>16	lelong			>0		not stripped
+>32	byte			0x6a		(uses shared libs)

+ 10 - 0
Magdir/cisco

@@ -0,0 +1,10 @@
+#------------------------------------------------------------------------------
+# cisco:  file(1) magic for cisco Systems routers
+#
+# Most cisco file-formats are covered by the generic elf code
+#
+# Microcode files are non-ELF, 0x8501 conflicts with NetBSD/alpha.
+0	belong&0xffffff00	0x85011400  cisco IOS microcode
+>7	string		>\0		    for '%s'
+0	belong&0xffffff00	0x8501cb00  cisco IOS experimental microcode
+>7	string		>\0		    for '%s'

+ 24 - 0
Magdir/commands

@@ -5,42 +5,58 @@
 0	string		:\ shell archive or commands for antique kernel text
 0	string		#!/bin/sh		Bourne shell script text
 0	string		#!\ /bin/sh		Bourne shell script text
+0	string		#!\	/bin/sh		Bourne shell script text
 0	string		#!/bin/csh		C shell script text
 0	string		#!\ /bin/csh		C shell script text
+0	string		#!\	/bin/csh	C shell script text
 # korn shell magic, sent by George Wu, gwu@clyde.att.com
 0	string		#!/bin/ksh		Korn shell script text
 0	string		#!\ /bin/ksh		Korn shell script text
+0	string		#!\	/bin/ksh	Korn shell script text
 0	string	 	#!/bin/tcsh		Tenex C shell script text
 0	string	 	#!\ /bin/tcsh		Tenex C shell script text
+0	string	 	#!\	/bin/tcsh	Tenex C shell script text
 0	string		#!/usr/local/tcsh	Tenex C shell script text
 0	string	 	#!\ /usr/local/tcsh	Tenex C shell script text
 0	string		#!/usr/local/bin/tcsh	Tenex C shell script text
 0	string		#!\ /usr/local/bin/tcsh	Tenex C shell script text
+0	string		#!\	/usr/local/bin/tcsh	Tenex C shell script text
 #
 # zsh/ash/ae/nawk/gawk magic from cameron@cs.unsw.oz.au (Cameron Simpson)
 0	string		#!/usr/local/bin/zsh	Paul Falstad's zsh
 0	string		#!\ /usr/local/bin/zsh	Paul Falstad's zsh
+0	string		#!\	/usr/local/bin/zsh	Paul Falstad's zsh
 0	string		#!/usr/local/bin/ash	Neil Brown's ash
 0	string		#!\ /usr/local/bin/ash	Neil Brown's ash
+0	string		#!\	/usr/local/bin/ash	Neil Brown's ash
 0	string		#!/usr/local/bin/ae	Neil Brown's ae
 0	string		#!\ /usr/local/bin/ae	Neil Brown's ae
+0	string		#!\	/usr/local/bin/ae	Neil Brown's ae
 0	string		#!/bin/nawk		new awk script text
 0	string		#!\ /bin/nawk		new awk script text
+0	string		#!\	/bin/nawk		new awk script text
 0	string		#!/usr/bin/nawk		new awk script text
 0	string		#!\ /usr/bin/nawk	new awk script text
+0	string		#!\	/usr/bin/nawk	new awk script text
 0	string		#!/usr/local/bin/nawk	new awk script text
 0	string		#!\ /usr/local/bin/nawk	new awk script text
+0	string		#!\	/usr/local/bin/nawk	new awk script text
 0	string		#!/bin/gawk		GNU awk script text
 0	string		#!\ /bin/gawk		GNU awk script text
+0	string		#!\	/bin/gawk		GNU awk script text
 0	string		#!/usr/bin/gawk		GNU awk script text
 0	string		#!\ /usr/bin/gawk	GNU awk script text
+0	string		#!\	/usr/bin/gawk	GNU awk script text
 0	string		#!/usr/local/bin/gawk	GNU awk script text
 0	string		#!\ /usr/local/bin/gawk	GNU awk script text
+0	string		#!\	/usr/local/bin/gawk	GNU awk script text
 #
 0	string		#!/bin/awk		awk commands text
 0	string		#!\ /bin/awk		awk commands text
+0	string		#!\	/bin/awk		awk commands text
 0	string		#!/usr/bin/awk		awk commands text
 0	string		#!\ /usr/bin/awk	awk commands text
+0	string		#!\	/usr/bin/awk	awk commands text
 0	string		BEGIN			awk commands text
 
 # For Larry Wall's perl language.  The ``eval'' line recognizes an
@@ -48,27 +64,35 @@
 #				Keith Waclena <keith@cerberus.uchicago.edu>
 0	string		#!/bin/perl			perl commands text
 0	string		#!\ /bin/perl			perl commands text
+0	string		#!\	/bin/perl		perl commands text
 0	string		eval\ "exec\ /bin/perl		perl commands text
 0	string		#!/usr/bin/perl			perl commands text
 0	string		#!\ /usr/bin/perl		perl commands text
+0	string		#!\	/usr/bin/perl		perl commands text
 0	string		eval\ "exec\ /usr/bin/perl	perl commands text
 0	string		#!/usr/local/bin/perl		perl commands text
 0	string		#!\ /usr/local/bin/perl		perl commands text
+0	string		#!\	/usr/local/bin/perl	perl commands text
 0	string		eval\ "exec\ /usr/local/bin/perl	perl commands text
 
 # AT&T Bell Labs' Plan 9 shell
 0	string		#!/bin/rc	Plan 9 rc shell script text
 0	string		#!\ /bin/rc	Plan 9 rc shell script text
+0	string		#!\	/bin/rc	Plan 9 rc shell script text
 
 # bash shell magic, from Peter Tobias (tobias@server.et-inf.fho-emden.de)
 0	string		#!/bin/bash	Bourne-Again shell script text
 0	string		#!\ /bin/bash	Bourne-Again shell script text
+0	string		#!\	/bin/bash	Bourne-Again shell script text
 0	string		#!/usr/local/bin/bash	Bourne-Again shell script text
 0	string		#!\ /usr/local/bin/bash	Bourne-Again shell script text
+0	string		#!\	/usr/local/bin/bash	Bourne-Again shell script text
 
 # generic shell magic
 0	string		#!\ /			a
 >3	string		>\0			%s script text
+0	string		#!\	/		a
+>3	string		>\0			%s script text
 0	string		#!/			a
 >2	string		>\0			%s script text
 0	string		#!\ 			commands text

+ 29 - 9
Magdir/compress

@@ -55,13 +55,18 @@
 0	string		\377\037	compacted data
 0	short		0145405		huf output
 
-# Squeeze and Crunch...
-# These numbers were gleaned from the Unix versions of the programs to
-# handle these formats.  Note that I can only uncrunch, not crunch, and
-# I didn't have a crunched file handy, so the crunch number is untested.
-#				Keith Waclena <keith@cerberus.uchicago.edu>
-0	leshort		0x76FF		squeezed data (CP/M, DOS)
-0	leshort		0x76FE		crunched data (CP/M, DOS)
+# bzip2
+0	string		BZh		bzip2 compressed data
+>3	byte		>47		\b, block size = %c00k
+
+# squeeze and crunch
+# Michael Haardt <michael@cantor.informatik.rwth-aachen.de>
+0	leshort		0xFF76		squeezed data,
+>4	string		x		original name %s
+0	leshort		0xFE76		crunched data,
+>2	string		x		original name %s
+0	leshort		0xFD76		LZH compressed data,
+>2	string		x		original name %s
 
 # Freeze
 0	string		\037\237	frozen file 2.1
@@ -79,8 +84,23 @@
 #
 # This will cause very short GSM files to be declared as data and
 # mismatches to be declared as data too!
-#0	byte&0xF0	0xd0	data
+#0	byte&0xF0	0xd0		data
 #>33	byte&0xF0	0xd0
 #>66	byte&0xF0	0xd0
 #>99	byte&0xF0	0xd0
-#>132	byte&0xF0	0xd0	GSM 06.10 compressed audio
+#>132	byte&0xF0	0xd0		GSM 06.10 compressed audio
+
+# bzip	a block-sorting file compressor
+#	by Julian Seward <sewardj@cs.man.ac.uk> and others
+#
+0	string		BZ		bzip compressed	data
+>2	byte		x		\b, version: %c
+>3	string		=1		\b, compression block size 100k
+>3	string		=2		\b, compression block size 200k
+>3	string		=3		\b, compression block size 300k
+>3	string		=4		\b, compression block size 400k
+>3	string		=5		\b, compression block size 500k
+>3	string		=6		\b, compression block size 600k
+>3	string		=7		\b, compression block size 700k
+>3	string		=8		\b, compression block size 800k
+>3	string		=9		\b, compression block size 900k

+ 64 - 2
Magdir/convex

@@ -1,7 +1,69 @@
-
 #------------------------------------------------------------------------------
 # convex:  file(1) magic for Convex boxes
 #
 # Convexes are big-endian.
 #
-0	long		0513		Convex executable
+# /*\
+#  * Below are the magic numbers and tests added for Convex.
+#  * Added at beginning, because they are expected to be used most.
+# \*/
+0	belong	0507	Convex old-style object
+>16	belong	>0	not stripped
+0	belong	0513	Convex old-style demand paged executable
+>16	belong	>0	not stripped
+0	belong	0515	Convex old-style pre-paged executable
+>16	belong	>0	not stripped
+0	belong	0517	Convex old-style pre-paged, non-swapped executable
+>16	belong	>0	not stripped
+0	belong	0x011257	Core file
+#
+# The following are a series of dump format magic numbers.  Each one
+# corresponds to a drastically different dump format.  The first on is
+# the original dump format on a 4.1 BSD or earlier file system.  The
+# second marks the change between the 4.1 file system and the 4.2 file
+# system.  The Third marks the changing of the block size from 1K
+# to 2K to be compatible with an IDC file system.  The fourth indicates
+# a dump that is dependent on Convex Storage Manager, because data in
+# secondary storage is not physically contained within the dump.
+# The restore program uses these number to determine how the data is
+# to be extracted.
+#
+24	belong	=60011	dump format, 4.1 BSD or earlier
+24	belong	=60012	dump format, 4.2 or 4.3 BSD without IDC
+24	belong	=60013	dump format, 4.2 or 4.3 BSD (IDC compatible)
+24	belong	=60014	dump format, Convex Storage Manager by-reference dump
+#
+# what follows is a bunch of bit-mask checks on the flags field of the opthdr.
+# If there is no `=' sign, assume just checking for whether the bit is set?
+#
+0	belong	0601		Convex SOFF
+>88	belong&0x000f0000	=0x00000000	c1
+>88	belong			&0x00010000	c2
+>88	belong			&0x00020000	c2mp
+>88	belong			&0x00040000	parallel
+>88	belong			&0x00080000	intrinsic
+>88	belong			&0x00000001	demand paged
+>88	belong			&0x00000002	pre-paged
+>88	belong			&0x00000004	non-swapped
+>88	belong			&0x00000008	POSIX
+#
+>84	belong			&0x80000000	executable
+>84	belong			&0x40000000	object
+>84	belong&0x20000000	=0		not stripped
+>84	belong&0x18000000	=0x00000000	native fpmode
+>84	belong&0x18000000	=0x10000000	ieee fpmode
+>84	belong&0x18000000	=0x18000000	undefined fpmode
+#
+0	belong			0605		Convex SOFF core
+#
+0	belong			0607		Convex SOFF checkpoint
+>88	belong&0x000f0000	=0x00000000	c1
+>88	belong			&0x00010000	c2
+>88	belong			&0x00020000	c2mp
+>88	belong			&0x00040000	parallel
+>88	belong			&0x00080000	intrinsic
+>88	belong			&0x00000008	POSIX
+#
+>84	belong&0x18000000	=0x00000000	native fpmode
+>84	belong&0x18000000	=0x10000000	ieee fpmode
+>84	belong&0x18000000	=0x18000000	undefined fpmode

+ 12 - 10
Magdir/database

@@ -17,16 +17,18 @@
 >8	belong	1234		Little Endian,
 >8	belong	4321		Big Endian,
 >12	belong	x		Bucket Size %d,
->16	belong	x		Directory Size %d,
->20	belong	x		Segment Size %d,
->24	belong	x		Segment Shift %d,
->28	belong	x		Overflow Point %d,
->32	belong	x		Last Freed %d,
->36	belong	x		Max Bucket %d,
->40	belong	x		High Mask 0x%x,
->44	belong	x		Low Mask 0x%x,
->48	belong	x		Fill Factor %d,
->52	belong	x		Number of Keys %d)
+>16	belong	x		Bucket Shift %d,
+>20	belong	x		Directory Size %d,
+>24	belong	x		Segment Size %d,
+>28	belong	x		Segment Shift %d,
+>32	belong	x		Overflow Point %d,
+>36	belong	x		Last Freed %d,
+>40	belong	x		Max Bucket %d,
+>44	belong	x		High Mask 0x%x,
+>48	belong	x		Low Mask 0x%x,
+>52	belong	x		Fill Factor %d,
+>56	belong	x		Number of Keys %d)
+#
 #
 0	belong	0x053162	Berkeley DB Btree file
 >4	belong	>0		(Version %d,

+ 41 - 0
Magdir/digital

@@ -0,0 +1,41 @@
+#  Digital UNIX - Info
+#
+0	string	!<arch>\n________64E	Alpha archive
+>22	string	X			-- out of date
+#
+# Alpha COFF Based Executables
+# The stripped stuff really needs to be an 8 byte (64 bit) compare,
+# but this works
+0	leshort		0x183		COFF format alpha
+>22	leshort&020000	&010000		sharable library,
+>22	leshort&020000	^010000		dynamically linked,
+>24	leshort		0410		pure
+>24	leshort		0413		demand paged
+>8	lelong		>0		executable or object module, not stripped
+>8	lelong		0
+>>12	lelong		0		executable or object module, stripped
+>>12	lelong		>0		executable or object module, not stripped
+>27     byte            >0              - version %d.
+>26     byte            >0              %d-
+>28     leshort         >0              %d
+#
+# The next is incomplete, we could tell more about this format,
+# but its not worth it.
+0	leshort		0x188	Alpha compressed COFF
+0	leshort		0x18f	Alpha u-code object
+#
+#
+# Some other interesting Digital formats,
+0	string	\377\377\177		ddis/ddif
+0	string	\377\377\174		ddis/dots archive
+0	string	\377\377\176		ddis/dtif table data
+0	string	\033c\033		LN03 output
+0	long	04553207		X image
+#
+0	string	!<PDF>!\n		profiling data file
+#
+# Locale data tables (MIPS and Alpha).
+#
+0	short		0x0501		locale data table
+>6	short		0x24		for MIPS
+>6	short		0x40		for Alpha

+ 2 - 2
Magdir/dump

@@ -43,8 +43,8 @@
 >888	belong	>0		Flags %x
 
 24	lelong	60012		new-fs dump file (little endian),
->4	ledate	x		Previous dump %s,
->8	ledate	x		This dump %s,
+>4	ledate	x		This dump %s,
+>8	ledate	x		Previous dump %s,
 >12	lelong	>0		Volume %ld,
 >692	lelong	0		Level zero, type:
 >692	lelong	>0		Level %d, type:

+ 38 - 16
Magdir/elf

@@ -5,8 +5,8 @@
 # We have to check the byte order flag to see what byte order all the
 # other stuff in the header is in.
 #
-# Byte order is probably big-endian for MIPS RS3000 and Amdahl.
-# MIPS RS3000 may also be for MIPS RS2000.
+# MIPS R3000 may also be for MIPS R2000.
+# What're the correct byte orders for the nCUBE and the Fujitsu VPP500?
 #
 # updated by Daniel Quinlan (quinlan@yggdrasil.com)
 0	string		\177ELF		ELF
@@ -20,42 +20,64 @@
 >>16	leshort		2		executable,
 >>16	leshort		3		shared object,
 # Core handling from Peter Tobias <tobias@server.et-inf.fho-emden.de>
+# corrections by Christian 'Dr. Disk' Hechelmann <drdisk@ds9.au.s.shuttle.de>
 >>16	leshort		4		core file
->>>576  string          >\0             of '%s'
->>>400  lelong          >0              (signal %d),
+>>>(0x38+0xcc) string	>\0		of '%s'
+>>>(0x38+0x10) lelong	>0		(signal %d),
 >>16	leshort		&0xff00		processor-specific,
 >>18	leshort		0		no machine,
 >>18	leshort		1		AT&T WE32100 - invalid byte order,
 >>18	leshort		2		SPARC - invalid byte order,
->>18	leshort		3		Intel 386,
+>>18	leshort		3		Intel 80386,
 >>18	leshort		4		Motorola 68000 - invalid byte order,
 >>18	leshort		5		Motorola 88000 - invalid byte order,
->>18	leshort		6		Intel 486,
->>18	leshort		7		Intel 860,
->>18	leshort		8		MIPS RS3000,
->>18	leshort		9		Amdahl,
+>>18	leshort		6		Intel 80486,
+>>18	leshort		7		Intel 80860,
+>>18	leshort		8		MIPS R3000_BE - invalid byte order,
+>>18	leshort		9		Amdahl - invalid byte order,
+>>18	leshort		10		MIPS R3000_LE,
+>>18	leshort		11		RS6000 - invalid byte order,
+>>18	leshort		15		PA-RISC - invalid byte order,
+>>18	leshort		16		nCUBE,
+>>18	leshort		17		VPP500,
+>>18	leshort		18		SPARC32PLUS,
+>>18	leshort		20		PowerPC,
+>>18	leshort		0x9026		Alpha,
 >>20	lelong		0		invalid version
 >>20	lelong		1		version 1
 >>36	lelong		1		MathCoPro/FPU/MAU Required
+>8	string		>\0		(%s)
 >5	byte		2		MSB
 >>16	beshort		0		no file type,
 >>16	beshort		1		relocatable,
 >>16	beshort		2		executable,
 >>16	beshort		3		shared object,
 >>16	beshort		4		core file,
->>>576	string		>\0		of '%s'
->>>400	lelong		>0		(signal %d),
+>>>(0x38+0xcc) string	>\0		of '%s'
+>>>(0x38+0x10) belong	>0		(signal %d),
 >>16	beshort		&0xff00		processor-specific,
 >>18	beshort		0		no machine,
 >>18	beshort		1		AT&T WE32100,
 >>18	beshort		2		SPARC,
->>18	beshort		3		Intel 386 - invalid byte order,
+>>18	beshort		3		Intel 80386 - invalid byte order,
 >>18	beshort		4		Motorola 68000,
 >>18	beshort		5		Motorola 88000,
->>18	beshort		6		Intel 486 - invalid byte order,
->>18	beshort		7		Intel 860,
->>18	beshort		8		MIPS RS3000,
->>18	leshort		9		Amdahl,
+>>18	beshort		6		Intel 80486 - invalid byte order,
+>>18	beshort		7		Intel 80860,
+>>18	beshort		8		MIPS R3000_BE,
+>>18	beshort		9		Amdahl,
+>>18	beshort		10		MIPS R3000_LE - invalid byte order,
+>>18	beshort		11		RS6000,
+>>18	beshort		15		PA-RISC,
+>>18	beshort		16		nCUBE,
+>>18	beshort		17		VPP500,
+>>18	beshort		18		SPARC32PLUS,
+>>18	beshort		20		PowerPC or cisco 4500,
+>>18	beshort		21		cisco 7500,
+>>18	beshort		24		cisco SVIP,
+>>18	beshort		25		cisco 7200,
+>>18	beshort		36		cisco 12000,
+>>18	beshort		0x9026		Alpha,
 >>20	belong		0		invalid version
 >>20	belong		1		version 1
 >>36	belong		1		MathCoPro/FPU/MAU Required

+ 30 - 0
Magdir/filesystems

@@ -4,3 +4,33 @@
 #
 0x438	leshort	0xEF53			Linux/i386 ext2 filesystem
 0	string	\366\366\366\366	PC formatted floppy with no filesystem
+# Sun disk labels
+# From /usr/include/sun/dklabel.h:
+0774	beshort		0xdabe		Sun disk label
+>0	string		x		'%s
+>>31  	string		>\0		\b%s
+>>>63  	string		>\0		\b%s
+>>>>95 	string		>\0		\b%s
+>0	string		x		\b'
+>0734	short		>0		%d rpm,
+>0736	short		>0		%d phys cys,
+>0740	short		>0		%d alts/cyl,
+>0746	short		>0		%d interleave,
+>0750	short		>0		%d data cyls,
+>0752	short		>0		%d alt cyls,
+>0754	short		>0		%d heads/partition,
+>0756	short		>0		%d sectors/track,
+>0764	long		>0		start cyl %ld,
+>0770	long		x		%ld blocks
+# Is there a boot block written 1 sector in?
+>512    belong&077777777	0600407	\b, boot block present
+0x1FE	leshort	0xAA55			x86 boot sector
+>2	string	OSBS			\b, OS/BS MBR
+>0x8C	string	Invalid\ partition\ table	\b, MS-DOS MBR
+>0	string	\0\0\0\0		\b, extended partition table
+>0	leshort 0x3CEB			\b, system
+>>3	string	>\0			%s
+>>0x36	string	FAT			\b, %s
+>>>0x39	string	12			(%s bit)
+>>>0x39	string	16			(%s bit)
+>0x200	lelong	0x82564557		\b, BSD disklabel

+ 10 - 0
Magdir/fonts

@@ -25,6 +25,15 @@
 >12	byte		0x0a			\b, MSB first
 0	string		D1.0\015		X11 Speedo font data
 
+#------------------------------------------------------------------------------
+# FIGlet fonts and controlfiles
+# From figmagic supplied with Figlet version 2.2
+# "David E. O'Brien" <obrien@FreeBSD.ORG>
+0	string		flf		FIGlet font
+>3	string		>2a		version %-2.2s
+0	string		flc		FIGlet controlfile
+>3	string		>2a		version %-2.2s
+
 # libGrx graphics lib fonts, from Albert Cahalan (acahalan@cs.uml.edu)
 # Used with djgpp (DOS Gnu C++), sometimes Linux or Turbo C++
 0	belong		0x14025919	libGrx font data,
@@ -36,3 +45,4 @@
 7	belong		0x00454741	DOS code page font data
 7	belong		0x00564944	DOS code page font data (from Linux?)
 4098	string		DOSFONT		DOSFONT2 encrypted font data
+

+ 1 - 0
Magdir/frame

@@ -6,6 +6,7 @@
 # copyright, but this file is "published" as witness the following:
 #
 0	string		\<MakerFile	FrameMaker document
+>11	string		5.0		 (5.0
 >11	string		4.0		 (4.0
 >11	string		3.0		 (3.0
 >11	string		2.0		 (2.0

+ 81 - 48
Magdir/freebsd

@@ -1,6 +1,79 @@
-# the following are for BSD/i386 (FreeBSD, NetBSD, etc.)
 
-0	lelong&0377777777	041400407	BSD/i386
+#------------------------------------------------------------------------------
+# freebsd:  file(1) magic for FreeBSD objects
+#
+# All new-style FreeBSD magic numbers are in host byte order (i.e.,
+# little-endian on x86).
+#
+# XXX - this comes from the file "freebsd" in a recent FreeBSD version of
+# "file"; it, and the NetBSD stuff in "netbsd", appear to use different
+# schemes for distinguishing between executable images, shared libraries,
+# and object files.
+#
+# FreeBSD says:
+#
+#    Regardless of whether it's pure, demand-paged, or none of the
+#    above:
+#
+#	if the entry point is < 4096, then it's a shared library if
+#	the "has run-time loader information" bit is set, and is
+#	position-independent if the "is position-independent" bit
+#	is set;
+#
+#	if the entry point is >= 4096 (or >4095, same thing), then it's
+#	an executable, and is dynamically-linked if the "has run-time
+#	loader information" bit is set.
+#
+# On x86, NetBSD says:
+#
+#    If it's neither pure nor demand-paged:
+#
+#	if it has the "has run-time loader information" bit set, it's
+#	a dynamically-linked executable;
+#
+#	if it doesn't have that bit set, then:
+#
+#	    if it has the "is position-independent" bit set, it's
+#	    position-independent;
+#
+#	    if the entry point is non-zero, it's an executable, otherwise
+#	    it's an object file.
+#
+#    If it's pure:
+#
+#	if it has the "has run-time loader information" bit set, it's
+#	a dynamically-linked executable, otherwise it's just an
+#	executable.
+#
+#    If it's demand-paged:
+#
+#	if it has the "has run-time loader information" bit set,
+#	then:
+#
+#	    if the entry point is < 4096, it's a shared library;
+#
+#	    if the entry point is = 4096 or > 4096 (i.e., >= 4096),
+#	    it's a dynamically-linked executable);
+#
+#	if it doesn't have the "has run-time loader information" bit
+#	set, then it's just an executable.
+#
+# (On non-x86, NetBSD does much the same thing, except that it uses
+# 8192 on 68K - except for "68k4k", which is presumably "68K with 4K
+# pages - SPARC, and MIPS, presumably because Sun-3's and Sun-4's
+# had 8K pages; dunno about MIPS.)
+#
+# I suspect the two will differ only in perverse and uninteresting cases
+# ("shared" libraries that aren't demand-paged and whose pages probably
+# won't actually be shared, executables with entry points <4096).
+#
+# I leave it to those more familiar with FreeBSD and NetBSD to figure out
+# what the right answer is (although using ">4095", FreeBSD-style, is
+# probably better than separately checking for "=4096" and ">4096",
+# NetBSD-style).  (The old "netbsd" file analyzed FreeBSD demand paged
+# executables using the NetBSD technique.)
+#
+0	lelong&0377777777	041400407	FreeBSD/i386
 >20	lelong			<4096
 >>3	byte&0xC0		&0x80		shared library
 >>3	byte&0xC0		0x40		PIC object
@@ -10,7 +83,7 @@
 >>3	byte&0x80		0x00		executable
 >16	lelong			>0		not stripped
 
-0	lelong&0377777777	041400410	BSD/i386 pure
+0	lelong&0377777777	041400410	FreeBSD/i386 pure
 >20	lelong			<4096
 >>3	byte&0xC0		&0x80		shared library
 >>3	byte&0xC0		0x40		PIC object
@@ -20,7 +93,7 @@
 >>3	byte&0x80		0x00		executable
 >16	lelong			>0		not stripped
 
-0	lelong&0377777777	041400413	BSD/i386 demand paged
+0	lelong&0377777777	041400413	FreeBSD/i386 demand paged
 >20	lelong			<4096
 >>3	byte&0xC0		&0x80		shared library
 >>3	byte&0xC0		0x40		PIC object
@@ -30,7 +103,7 @@
 >>3	byte&0x80		0x00		executable
 >16	lelong			>0		not stripped
 
-0	lelong&0377777777	041400314	BSD/i386 compact demand paged
+0	lelong&0377777777	041400314	FreeBSD/i386 compact demand paged
 >20	lelong			<4096
 >>3	byte&0xC0		&0x80		shared library
 >>3	byte&0xC0		0x40		PIC object
@@ -40,46 +113,6 @@
 >>3	byte&0x80		0x00		executable
 >16	lelong			>0		not stripped
 
-0	belong&0377777777	041400407	BSD/i386
->20	belong			<4096
->>0	byte&0xC0		&0x80		shared library
->>0	byte&0xC0		0x40		PIC object
->>0	byte&0xC0		0x00		object
->20	belong			>4095
->>0	byte&0x80		0x80		dynamically linked executable
->>0	byte&0x80		0x00		executable
->16	belong			>0		not stripped
-
-0	belong&0377777777	041400410	BSD/i386 pure
->20	belong			<4096
->>0	byte&0xC0		&0x80		shared library
->>0	byte&0xC0		0x40		PIC object
->>0	byte&0xC0		0x00		object
->20	belong			>4095
->>0	byte&0x80		0x80		dynamically linked executable
->>0	byte&0x80		0x00		executable
->16	belong			>0		not stripped
-
-0	belong&0377777777	041400413	BSD/i386 demand paged
->20	belong			<4096
->>0	byte&0xC0		&0x80		shared library
->>0	byte&0xC0		0x40		PIC object
->>0	byte&0xC0		0x00		object
->20	belong			>4095
->>0	byte&0x80		0x80		dynamically linked executable
->>0	byte&0x80		0x00		executable
->16	belong			>0		not stripped
-
-0	belong&0377777777	041400314	BSD/i386 compact demand paged
->20	belong			<4096
->>0	byte&0xC0		&0x80		shared library
->>0	byte&0xC0		0x40		PIC object
->>0	byte&0xC0		0x00		object
->20	belong			>4095
->>0	byte&0x80		0x80		dynamically linked executable
->>0	byte&0x80		0x00		executable
->16	belong			>0		not stripped
-
 # XXX gross hack to identify core files
 # cores start with a struct tss; we take advantage of the following:
 # byte 7:     highest byte of the kernel stack pointer, always 0xfe
@@ -88,10 +121,10 @@
 #      28:    low order byte of the current PTD entry, always 0 since the
 #             PTD is page-aligned
 #
-7	string	\357\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0	BSD i386 a.out core file
->1031	string	>\0	from "%s"
+7	string	\357\020\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0	FreeBSD/i386 a.out core file
+>1039	string	>\0	from '%s'
 
 # /var/run/ld.so.hints
 # What are you laughing about?
-0	lelong			011421044151	BSD ld.so hints file
+0	lelong			011421044151	ld.so hints file
 >4	lelong			>0		(version %d)

+ 62 - 23
Magdir/hp

@@ -6,12 +6,6 @@
 # applied to the "TML" stuff; I'm assuming the Apollo stuff is
 # big-endian as it was mostly 68K-based.
 #
-# HP-PA is big-endian, so it (and "800", which is *also* HP-PA-based; I
-# assume "HPPA-RISC1.1" really means "HP-PA Version 1.1", which first
-# showed up in the 700 series, although later 800 series machines are,
-# I think, based on the PA7100 which implements HP-PA 1.1) are flagged
-# as big-endian.
-#
 # I think the 500 series was the old stack-based machines, running a
 # UNIX environment atop the "SUN kernel"; dunno whether it was
 # big-endian or little-endian.
@@ -21,10 +15,23 @@
 # HP magic is useful for reference, but using "long" magic is a better
 # practice in order to avoid collisions.
 #
+# Guy Harris (guy@netapp.com): some additions to this list came from
+# HP-UX 10.0's "/usr/include/sys/unistd.h" (68030, 68040, PA-RISC 1.1,
+# 1.2, and 2.0).  The 1.2 and 2.0 stuff isn't in the HP-UX 10.0
+# "/etc/magic", though, except for the "archive file relocatable library"
+# stuff, and the 68030 and 68040 stuff isn't there at all - are they not
+# used in executables, or have they just not yet updated "/etc/magic"
+# completely?
+#
 # 0	beshort		200		hp200 (68010) BSD binary
 # 0	beshort		300		hp300 (68020+68881) BSD binary
 # 0	beshort		0x20c		hp200/300 HP-UX binary
-# 0	beshort		0x20b		hp800 HP-UX binary
+# 0	beshort		0x20d		hp400 (68030) HP-UX binary
+# 0	beshort		0x20e		hp400 (68040?) HP-UX binary
+# 0	beshort		0x20b		PA-RISC1.0 HP-UX binary
+# 0	beshort		0x210		PA-RISC1.1 HP-UX binary
+# 0	beshort		0x211		PA-RISC1.2 HP-UX binary
+# 0	beshort		0x214		PA-RISC2.0 HP-UX binary
 
 #
 # The "misc" stuff needs a byte order; the archives look suspiciously
@@ -41,49 +48,82 @@
 0       long            01702407010     TML 1032 byte-order format
 0       long            01003405017     TML 2301 byte-order format
 0       long            01602007412     TML 3210 byte-order format
-#### HPPA
-0	belong 		0x02100106	HPPA-RISC1.1 relocatable object
-0	belong 		0x02100107	HPPA-RISC1.1 executable
+#### PA-RISC 1.1
+0	belong 		0x02100106	PA-RISC1.1 relocatable object
+0	belong 		0x02100107	PA-RISC1.1 executable
+>168	belong		&=0x00000004	dynamically linked
 >(144)	belong		0x054ef630	dynamically linked
 >96	belong		>0		- not stripped
 
-0	belong 		0x02100108	HPPA-RISC1.1 shared executable
+0	belong 		0x02100108	PA-RISC1.1 shared executable
+>168	belong&0x4	0x4		dynamically linked
 >(144)	belong		0x054ef630	dynamically linked
 >96	belong		>0		- not stripped
 
-0	belong 		0x0210010b	HPPA-RISC1.1 demand-load executable
+0	belong 		0x0210010b	PA-RISC1.1 demand-load executable
+>168	belong&0x4	0x4		dynamically linked
 >(144)	belong		0x054ef630	dynamically linked
 >96	belong		>0		- not stripped
 
-0	belong 		0x0210010e	HPPA-RISC1.1 shared library
+0	belong 		0x0210010e	PA-RISC1.1 shared library
 >96	belong		>0		- not stripped
 
-0	belong 		0x0210010d	HPPA-RISC1.1 dynamic load library
+0	belong 		0x0210010d	PA-RISC1.1 dynamic load library
+>96	belong		>0		- not stripped
+
+#### PA-RISC 2.0
+0	belong		0x02140106	PA-RISC2.0 relocatable object
+
+0       belong		0x02140107	PA-RISC2.0 executable
+>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
+>(144)	belong		0x054ef630	dynamically linked
+>96	belong		>0		- not stripped
+
+0       belong		0x0214010b	PA-RISC2.0 demand-load executable
+>168	belong		&=0x00000004	dynamically linked
+>(144)	belong		0x054ef630	dynamically linked
+>96	belong		>0		- not stripped
+
+0       belong		0x0214010e	PA-RISC2.0 shared library
+>96	belong		>0		- not stripped
+
+0       belong		0x0214010d	PA-RISC2.0 dynamic load library
 >96	belong		>0		- not stripped
 
 #### 800
-0	belong 		0x020b0106	HP s800 relocatable object
+0	belong 		0x020b0106	PA-RISC1.0 relocatable object
 
-0	belong 		0x020b0107	HP s800 executable
+0	belong 		0x020b0107	PA-RISC1.0 executable
+>168	belong&0x4	0x4		dynamically linked
 >(144)	belong		0x054ef630	dynamically linked
 >96	belong		>0		- not stripped
 
-0	belong 		0x020b0108	HP s800 shared executable
+0	belong 		0x020b0108	PA-RISC1.0 shared executable
+>168	belong&0x4	0x4		dynamically linked
 >(144)	belong		0x054ef630	dynamically linked
 >96	belong		>0		- not stripped
 
-0	belong 		0x020b010b	HP s800 demand-load executable
+0	belong 		0x020b010b	PA-RISC1.0 demand-load executable
+>168	belong&0x4	0x4		dynamically linked
 >(144)	belong		0x054ef630	dynamically linked
 >96	belong		>0		- not stripped
 
-0	belong 		0x020b010e	HP s800 shared library
+0	belong 		0x020b010e	PA-RISC1.0 shared library
 >96	belong		>0		- not stripped
 
-0	belong 		0x020b010d	HP s800 dynamic load library
+0	belong 		0x020b010d	PA-RISC1.0 dynamic load library
 >96	belong		>0		- not stripped
 
 0	belong		0x213c6172	archive file
->68	belong 		0x020b0619	- HP s800 relocatable library
+>68	belong 		0x020b0619	- PA-RISC1.0 relocatable library
+>68	belong	 	0x02100619	- PA-RISC1.1 relocatable library
+>68	belong 		0x02110619	- PA-RISC1.2 relocatable library
+>68	belong 		0x02140619	- PA-RISC2.0 relocatable library
 
 #### 500
 0	long		0x02080106	HP s500 relocatable executable
@@ -156,7 +196,7 @@
 
 0	string		IMGfile	CIS 	compimg HP Bitmapfile
 # XXX - see "lif"
-0	short		0x8000		lif file
+#0	short		0x8000		lif file
 0	long		0x020c010c	compiled Lisp
 
 0	string		msgcat01	HP NLS message catalog,
@@ -209,4 +249,3 @@
 >2	beshort		0407		impure binary
 >2	beshort		0410		read-only binary
 >2	beshort		0413		demand paged binary
-

+ 28 - 0
Magdir/ibm370

@@ -4,7 +4,35 @@
 #
 # "ibm370" said that 0x15d == 0535 was "ibm 370 pure executable".
 # What the heck *is* "USS/370"?
+# AIX 4.1's "/etc/magic" has
 #
+#	0	short		0535		370 sysV executable 
+#	>12	long		>0		not stripped
+#	>22	short		>0		- version %d
+#	>30	long		>0		- 5.2 format
+#	0	short		0530		370 sysV pure executable 
+#	>12	long		>0		not stripped
+#	>22	short		>0		- version %d
+#	>30	long		>0		- 5.2 format
+#
+# instead of the "USS/370" versions of the same magic numbers.
+#
+0	beshort		0537		370 XA sysV executable 
+>12	belong		>0		not stripped
+>22	beshort		>0		- version %d
+>30	belong		>0		- 5.2 format
+0	beshort		0532		370 XA sysV pure executable 
+>12	belong		>0		not stripped
+>22	beshort		>0		- version %d
+>30	belong		>0		- 5.2 format
+0	beshort		054001		370 sysV pure executable
+>12	belong		>0		not stripped
+0	beshort		055001		370 XA sysV pure executable
+>12	belong		>0		not stripped
+0	beshort		056401		370 sysV executable
+>12	belong		>0		not stripped
+0	beshort		057401		370 XA sysV executable
+>12	belong		>0		not stripped
 0       beshort		0531		SVR2 executable (Amdahl-UTS)
 >12	belong		>0		not stripped
 >24     belong		>0		- version %ld

+ 2 - 1
Magdir/ibm6000

@@ -12,5 +12,6 @@
 0	beshort		0x0104		shared library
 0	beshort		0x0105		ctab data
 0	beshort		0xfe04		structured file
-0	string		0xabcdef	message catalog
+0	string		0xabcdef	AIX message catalog
+0	belong		0x000001f9	AIX compiled message catalog
 0	string		\<aiaff>	archive

+ 17 - 1
Magdir/images

@@ -30,10 +30,11 @@
 # PNG [Portable Network Graphics, or "PNG's Not GIF"] images
 # (Greg Roelofs, newt@uchicago.edu)
 # (Albert Cahalan, acahalan@cs.uml.edu)
+#
 # 137 P N G \r \n ^Z \n [4-byte length] H E A D [HEAD data] [HEAD crc] ...
 #
 0	string		\x89PNG		PNG image data,
->4	belong		!0x0d0a1a0a	CORRUPTED
+>4	belong		!0x0d0a1a0a	CORRUPTED,
 >4	belong		0x0d0a1a0a
 >>16	belong		x		%ld x
 >>20	belong		x		%ld,
@@ -118,6 +119,13 @@
 >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
@@ -224,3 +232,11 @@
 # other images
 0	string	This\ is\ a\ BitMap\ file	Lisp Machine bit-array-file
 0	string		!!		Bennet Yee's "face" format
+
+# From SunOS 5.5.1 "/etc/magic" - appeared right before Sun raster image
+# stuff.
+#
+0	beshort		0x1010		PEX Binary Archive
+
+# Visio drawings
+03000	string	Visio\ (TM)\ Drawing			%s

+ 1 - 1
Magdir/intel

@@ -30,6 +30,6 @@
 >12	lelong		>0		not stripped
 #>22	leshort		>0		- version %ld
 # SGI labeled the next entry as "iAPX 386 executable" --Dan Quinlan
-0	leshort		=0514		386 COFF executable
+0	leshort		=0514		80386 COFF executable
 >12	lelong		>0		not stripped
 >22	leshort		>0		- version %ld

+ 9 - 0
Magdir/island

@@ -0,0 +1,9 @@
+
+#------------------------------------------------------------------------------
+# island:  file(1) magic for IslandWite/IslandDraw, from SunOS 5.5.1
+# "/etc/magic":
+# From: guy@netapp.com (Guy Harris)
+#
+4	string		pgscriptver	IslandWrite document
+13	string		DrawFile	IslandDraw document
+

+ 9 - 2
Magdir/java

@@ -1,4 +1,11 @@
 #------------------------------------------------------------
 # Java ByteCode
-0	belong		0xcafebabe
->4	belong		0x0003002d	Java bytecode
+# From Larry Schwimmer (schwim@cs.stanford.edu)
+0	belong		0xcafebabe	compiled Java class data,
+>6	beshort x	version %d.
+>4	beshort x	\b%d
+#------------------------------------------------------------
+# Java serialization
+# From Martin Pool (m.pool@pharos.com.au)
+0	beshort		0xaced		Java serialization data
+>2	beshort		>0x0004		\b, version %d

+ 4 - 0
Magdir/lecter

@@ -0,0 +1,4 @@
+#------------------------------------------------------------------------------
+# DEC SRC Virtual Paper: Lectern files
+# Karl M. Hegbloom <karlheg@inetarena.com>
+0	string	lect	DEC SRC Virtual Paper Lectern file

+ 10 - 3
Magdir/linux

@@ -24,7 +24,7 @@
 0	string		\007\001\000	Linux/i386 object file
 >20	lelong		>0x1020		\b, DLL library
 # message catalogs, from Mitchum DSouza <m.dsouza@mrc-apu.cam.ac.uk>
-0	string		*nazgul*	compiled message catalog
+0	string		*nazgul*	Linux compiled message catalog
 >8	lelong		>0		\b, version %ld
 # core dump file, from Bill Reynolds <bill@goshawk.lanl.gov>
 216	lelong		0421		Linux/i386 core file
@@ -37,7 +37,7 @@
 #
 # Debian Packages, from Peter Tobias <tobias@server.et-inf.fho-emden.de>
 0	string		0.9
->8	byte		0x0a		Debian Binary Package
+>8	byte		0x0a		old Debian Binary Package
 >>3	byte		>0		\b, created by dpkg 0.9%c
 >>4	byte		>0		pl%c
 # PSF fonts, from H. Peter Anvin <hpa@yggdrasil.com>
@@ -63,9 +63,10 @@
 >8	long		>0		not stripped
 >8	long		0		stripped
 >23	leshort		>0		- version %ld.
-
+#
 # Linux kernel boot images, from Albert Cahalan <acahalan@cs.uml.edu>
 # and others such as Axel Kohlmeyer <akohlmey@rincewind.chemie.uni-ulm.de>
+# and Nicolas Lichtmaier <nick@debian.org>
 # All known start with: b8 c0 07 8e d8 b8 00 90 8e c0 b9 00 01 29 f6 29
 514		string	HdrS		Linux kernel
 >518		leshort	>0
@@ -79,7 +80,13 @@
 >>0x048c	string	x		version %s
 >0x0493		byte	0x32
 >>0x0493	string	x		version %s
+>0x04df		byte	0x32
+>>0x04df	string	x		version %s
+>0x04fb		byte	0x32
+>>0x04fb	string	x		version %s
 # This also matches new kernels, which were caught above by "HdrS".
 0		belong	0xb8c0078e	Linux kernel
 >0x1e3		string	Loading		version 1.3.79 or older
 >0x1e9		string	Loading		from prehistoric times
+# LSM entries - Nicolas Lichtmaier <nick@feedback.com.ar>
+0	string	Begin3	Linux Software Map entry text

+ 8 - 0
Magdir/lisp

@@ -8,3 +8,11 @@
 0	string	\012(			byte-compiled Emacs-Lisp program data
 # Emacs 19
 0	string	;ELC\023\000\000\000	byte-compiled Emacs-Lisp program data
+#
+# Files produced by CLISP Common Lisp From: Bruno Haible <haible@ilog.fr>
+0	string	(SYSTEM::VERSION\040'	CLISP byte-compiled Lisp program text
+0	long	0x70768BD2		CLISP memory image data
+0	long	0xD28B7670		CLISP memory image data, other endian
+# Files produced by GNU gettext
+0	long	0xDE120495		GNU-format message catalog data
+0	long	0x950412DE		GNU-format message catalog data

+ 79 - 0
Magdir/macintosh

@@ -0,0 +1,79 @@
+
+#------------------------------------------------------------------------------
+# macintosh description
+#
+# BinHex is the Macintosh ASCII-encoded file format (see also "apple")
+# Daniel Quinlan, quinlan@yggdrasil.com
+11	string	must\ be\ converted\ with\ BinHex	BinHex binary text
+>41	string	x					\b, version %.3s
+
+# Stuffit archives are the de facto standard of compression for Macintosh
+# files obtained from most archives. (franklsm@tuns.ca)
+0	string		SIT!			StuffIt Archive (data)
+>2	string		x			: %s
+65	string		SIT!			StuffIt Archive (rsrc + data)
+>2	string		x			: %s
+0	string		SITD			StuffIt Deluxe (data)
+>2	string		x			: %s
+65	string		SITD			StuffIt Deluxe (rsrc + data)
+>2	string		x			: %s
+0	string		Seg			StuffIt Deluxe Segment (data)
+>2	string		x			: %s
+65	string		Seg			StuffIt Deluxe Segment (rsrc + data)
+>2	string		x			: %s
+
+# Macintosh Applications and Installation binaries (franklsm@tuns.ca)
+0	string		APPL			Macintosh Application (data)
+>2	string		x			: %s
+65	string		APPL			Macintosh Application (rsrc + data)
+>2	string		x			: %s
+
+# Macintosh System files (franklsm@tuns.ca)
+0	string		zsys			Macintosh System File (data)
+65	string		zsys			Macintosh System File(rsrc + data)
+0	string		FNDR			Macintosh Finder (data)
+65	string		FNDR			Macintosh Finder(rsrc + data)
+0	string		libr			Macintosh Library (data)
+>2	string		x			: %s
+65	string		libr			Macintosh Library(rsrc + data)
+>2	string		x			: %s
+0	string		shlb			Macintosh Shared Library (data)
+>2	string		x			: %s
+65	string		shlb			Macintosh Shared Library(rsrc + data)
+>2	string		x			: %s
+0	string		cdev			Macintosh Control Panel (data)
+>2	string		x			: %s
+65	string		cdev			Macintosh Control Panel(rsrc + data)
+>2	string		x			: %s
+0	string		INIT			Macintosh Extension (data)
+>2	string		x			: %s
+65	string		INIT			Macintosh Extension(rsrc + data)
+>2	string		x			: %s
+0	string		FFIL			Macintosh Truetype Font (data)
+>2	string		x			: %s
+65	string		FFIL			Macintosh Truetype Font(rsrc + data)
+>2	string		x			: %s
+0	string		LWFN			Macintosh Postscript Font (data)
+>2	string		x			: %s
+65	string		LWFN			Macintosh Postscript Font(rsrc + data)
+>2	string		x			: %s
+
+# Additional Macintosh Files (franklsm@tuns.ca)
+
+0	string		PACT			Macintosh Compact Pro Archive (data)
+>2	string		x			: %s
+65	string		PACT			Macintosh Compact Pro Archive(rsrc + data)
+>2	string		x			: %s
+0	string		ttro			Macintosh TeachText File (data)
+>2	string		x			: %s
+65	string		ttro			Macintosh TeachText File(rsrc + data)
+>2	string		x			: %s
+0	string		TEXT			Macintosh TeachText File (data)
+>2	string		x			: %s
+65	string		TEXT			Macintosh TeachText File(rsrc + data)
+>2	string		x			: %s
+0	string		PDF			Macintosh PDF File (data)
+>2	string		x			: %s
+65	string		PDF			Macintosh PDF File(rsrc + data)
+>2	string		x			: %s
+

+ 3 - 3
Magdir/mail.news

@@ -16,6 +16,6 @@
 0	string		From:		news or mail text
 0	string		Article 	saved news text
 0	string		BABYL		Emacs RMAIL text
-0	string		Received:	RFC 822 mail message
-0	string		MIME-Version:	MIME entity
-0	string		Content-	MIME entity
+0	string		Received:	RFC 822 mail text
+0	string		MIME-Version:	MIME entity text
+#0	string		Content-	MIME entity text

+ 7 - 0
Magdir/mime

@@ -0,0 +1,7 @@
+#------------------------------------------------------------------------------
+# mime:  file(1) magic for MIME encoded files
+#
+0	string		Content-Type:\
+>14	string		>\0		%s
+0	string		Content-Type:
+>13	string		>\0		%s

+ 33 - 0
Magdir/modem

@@ -0,0 +1,33 @@
+#------------------------------------------------------------------------------
+# modem:  file(1) magic for modem programs
+#
+# From: Florian La Roche <florian@knorke.saar.de>
+4	string		Research,	Digifax-G3-File
+>29	byte		1		, fine resolution
+>29	byte		0		, normal resolution
+
+0	short		0x0100		raw G3 data, byte-padded
+0	short		0x1400		raw G3 data
+#
+# Magic data for vgetty voice formats
+# (Martin Seine & Marc Eberhard)
+
+#
+# raw modem data version 1
+#
+0    string    RMD1      raw modem data
+>4   string    >\0       (%s /
+>20  short     >0        compression type 0x%04x)
+
+#
+# portable voice format 1
+#
+0    string    PVF1\n         portable voice format
+>5   string    >\0       (binary %s)
+
+#
+# portable voice format 2
+#
+0    string    PVF2\n         portable voice format
+>5   string >\0          (ascii %s)
+

+ 99 - 7
Magdir/msdos

@@ -6,10 +6,85 @@
 # .BAT files (Daniel Quinlan, quinlan@yggdrasil.com)
 0	string	@echo\ off	MS-DOS batch file text
 
+# XXX - according to Microsoft's spec, at an offset of 0x3c in a
+# PE-format executable is the offset in the file of the PE header;
+# unfortunately, that's a little-endian offset, and there's no way
+# to specify an indirect offset with a specified byte order.
+# So, for now, we assume the standard MS-DOS stub, which puts the
+# PE header at 0x80 = 128.
+#
+# Required OS version and subsystem version were 4.0 on some NT 3.51
+# executables built with Visual C++ 4.0, so it's not clear that
+# they're interesting.  The user version was 0.0, but there's
+# probably some linker directive to set it.  The linker version was
+# 3.0, except for one ".exe" which had it as 4.20 (same damn linker!).
+#
+128	string		PE\0\0	MS Windows PE
+>150	leshort&0x0100	>0	32-bit
+>132	leshort		0x0	unknown processor
+>132	leshort		0x14c	Intel 80386
+>132	leshort		0x166	MIPS R4000
+>132	leshort		0x184	Alpha
+>132	leshort		0x268	Motorola 68000
+>132	leshort		0x1f0	PowerPC
+>132	leshort		0x290	PA-RISC
+>148	leshort		>27
+>>220	leshort		0	unknown subsystem
+>>220	leshort		1	native
+>>220	leshort		2	GUI
+>>220	leshort		3	console
+>>220	leshort		7	POSIX
+>150	leshort&0x2000	=0	executable
+#>>136	ledate		x	stamp %s,
+>>150	leshort&0x0001	>0	not relocatable
+#>>150	leshort&0x0004	=0	with line numbers,
+#>>150	leshort&0x0008	=0	with local symbols,
+#>>150	leshort&0x0200	=0	with debug symbols,
+>>150	leshort&0x1000	>0	system file
+#>>148	leshort		>0
+#>>>154	byte		x	linker %d
+#>>>155	byte		x	\b.%d,
+#>>148	leshort		>27
+#>>>192	leshort		x	requires OS %d
+#>>>194	leshort		x	\b.%d,
+#>>>196	leshort		x	user version %d
+#>>>198	leshort		x	\b.%d,
+#>>>200	leshort		x	subsystem version %d
+#>>>202	leshort		x	\b.%d,
+>150	leshort&0x2000	>0	DLL
+#>>136	ledate		x	stamp %s,
+>>150	leshort&0x0001	>0	not relocatable
+#>>150	leshort&0x0004	=0	with line numbers,
+#>>150	leshort&0x0008	=0	with local symbols,
+#>>150	leshort&0x0200	=0	with debug symbols,
+>>150	leshort&0x1000	>0	system file
+#>>148	leshort		>0
+#>>>154	byte		x	linker %d
+#>>>155	byte		x	\b.%d,
+#>>148	leshort		>27
+#>>>192	leshort		x	requires OS %d
+#>>>194	leshort		x	\b.%d,
+#>>>196	leshort		x	user version %d
+#>>>198	leshort		x	\b.%d,
+#>>>200	leshort		x	subsystem version %d
+#>>>202	leshort		x	\b.%d,
+0	leshort		0x14c	MS Windows COFF Intel 80386 object file
+#>4	ledate		x	stamp %s
+0	leshort		0x166	MS Windows COFF MIPS R4000 object file
+#>4	ledate		x	stamp %s
+0	leshort		0x184	MS Windows COFF Alpha object file
+#>4	ledate		x	stamp %s
+0	leshort		0x268	MS Windows COFF Motorola 68000 object file
+#>4	ledate		x	stamp %s
+0	leshort		0x1f0	MS Windows COFF PowerPC object file
+#>4	ledate		x	stamp %s
+0	leshort		0x290	MS Windows COFF PA-RISC object file
+#>4	ledate		x	stamp %s
+
 # .EXE formats (Greg Roelofs, newt@uchicago.edu)
 #
 0	string	MZ		MS-DOS executable (EXE)
->24	string	@		\b, OS/2 or Windows
+>24	string	@		\b, OS/2 or MS Windows
 >1638	string	-lh5-		\b, LHa SFX archive v2.13S
 >7195	string	Rar!		\b, RAR self-extracting archive
 #
@@ -55,19 +130,36 @@
 #0	byte		0xf0		MS-DOS program library data
 #
 
+#
+# Windows NT Registry files.
+#
+0	string		regf		Windows NT Registry file
+
 # Popular applications
 2080	string	Microsoft\ Word\ 6.0\ Document	%s
+2080	string	Documento\ Microsoft\ Word\ 6 Spanish Microsoft Word 6 document data
+# Pawel Wiecek <coven@i17linuxb.ists.pwr.wroc.pl> (for polish Word)
+2112	string	MSWordDoc	Microsoft Word document data
 #
 0	belong	0x31be0000	Microsoft Word Document
 #
+0       string  PO^Q`           Microsoft Word 6.0 Document
+#
 2080	string	Microsoft\ Excel\ 5.0\ Worksheet	%s
 #
+# Pawel Wiecek <coven@i17linuxb.ists.pwr.wroc.pl> (for polish Excel)
+2114	string	Biff5		Microsoft Excel 5.0 Worksheet
+#
 0	belong	0x00001a00	Lotus 1-2-3
->4	belong	0x00100400	wk3 document
->4	belong	0x02100400	wk4 document
->4	belong	0x07800100	fm3 or fmb document
->4	belong	0x07800000	fm3 or fmb document
+>4	belong	0x00100400	wk3 document data
+>4	belong	0x02100400	wk4 document data
+>4	belong	0x07800100	fm3 or fmb document data
+>4	belong	0x07800000	fm3 or fmb document data
 #
 0	belong	0x00000200 	Lotus 1-2-3
->4	belong	0x06040600	wk1 document
->4	belong	0x06800200	fmt document
+>4	belong	0x06040600	wk1 document data
+>4	belong	0x06800200	fmt document data
+
+# WordPerfect documents - Trevor Johnson <trevor@jpj.net>
+#
+1       string          WPC             WordPerfect document

+ 30 - 13
Magdir/netbsd

@@ -4,19 +4,6 @@
 #
 # All new-style magic numbers are in network byte order.
 #
-0	lelong			000000413	386BSD demand paged executable
->16	lelong			>0		not stripped
-0	lelong			000000314	BSDI demand paged executable
->16	lelong			>0		not stripped
->32	byte			0x6a		(uses shared libs)
-
-0	lelong&077777777	041400314	FreeBSD/i386 demand paged
->3	byte			&0x80
->>20	lelong			<4096		shared library
->>20	lelong			=4096		dynamically linked executable
->>20	lelong			>4096		dynamically linked executable
->3	byte			^0x80		executable
->16	lelong			>0		not stripped
 
 0	lelong			000000407	NetBSD little-endian object file
 >16	lelong			>0		not stripped
@@ -170,6 +157,15 @@
 0	belong&0377777777	043000507	NetBSD/vax core
 >12	string			>\0		from '%s'
 
+# NetBSD/alpha does not support (and has never supported) a.out objects,
+# so no rules are provided for them.  NetBSD/alpha ELF objects are 
+# dealt with in "elf".
+0	lelong		0x00070185		ECOFF NetBSD/alpha binary
+>10	leshort		0x0001			not stripped
+>10	leshort		0x0000			stripped
+0	belong&0377777777	043200507	NetBSD/alpha core
+>12	string			>\0		from '%s'
+
 0	belong&0377777777	043400413	NetBSD/mips demand paged
 >0	byte			&0x80		
 >>20	belong			<8192		shared library
@@ -190,3 +186,24 @@
 >16	belong			>0		not stripped
 0	belong&0377777777	043400507	NetBSD/mips core
 >12	string			>\0		from '%s'
+
+0	belong&0377777777	043600413	NetBSD/arm32 demand paged
+>0	byte			&0x80
+>>20	lelong			<8192		shared library
+>>20	lelong			=8192		dynamically linked executable
+>>20	lelong			>8192		dynamically linked executable
+>0	byte			^0x80		executable
+>16	lelong			>0		not stripped
+0	belong&0377777777	043600410	NetBSD/arm32 pure
+>0	byte			&0x80		dynamically linked executable
+>0	byte			^0x80		executable
+>16	lelong			>0		not stripped
+0	belong&0377777777	043600407	NetBSD/arm32
+>0	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	043600507	NetBSD/arm32 core
+>12	string			>\0		from '%s'

+ 86 - 0
Magdir/os9

@@ -0,0 +1,86 @@
+#
+#	$NetBSD: os9,v 1.2 1997/01/09 20:19:04 tls Exp $
+#
+# Copyright (c) 1996 Ignatios Souvatzis. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, 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 Ignatios Souvatzis for
+#      the NetBSD project.
+# 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 ``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 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.
+#
+#
+#
+# OS9/6809 module descriptions:
+#
+0	beshort		0x87CD	OS9/6809 module:
+#
+>6	byte&0x0f	0x00	non-executable
+>6	byte&0x0f	0x01	machine language
+>6	byte&0x0f	0x02	BASIC I-code
+>6	byte&0x0f	0x03	P-code
+>6	byte&0x0f	0x04	C I-code
+>6	byte&0x0f	0x05	COBOL I-code
+>6	byte&0x0f	0x06	FORTRAN I-code
+#
+>6	byte&0xf0	0x10	program executable
+>6	byte&0xf0	0x20	subroutine
+>6	byte&0xf0	0x30	multi-module
+>6	byte&0xf0	0x40	data module
+#
+>6	byte&0xf0	0xC0	system module
+>6	byte&0xf0	0xD0	file manager
+>6	byte&0xf0	0xE0	device driver
+>6	byte&0xf0	0xF0	device descriptor
+#
+# OS9/m68k stuff (to be continued)
+#
+0	beshort		0x4AFC	OS9/68K module:
+#
+# attr
+>14	byte&0x80	0x80	re-entrant
+>14	byte&0x40	0x40	ghost
+>14	byte&0x20	0x20	system-state
+#
+# lang:
+#
+>13	byte		1	machine language
+>13	byte		2	BASIC I-code
+>13	byte		3	P-code
+>13	byte		4	C I-code
+>13	byte		5	COBOL I-code
+>13	byte		6	Fortran I-code
+#
+#
+# type:
+#
+>12	byte		1	program executable
+>12	byte		2	subroutine
+>12	byte		3	multi-module
+>12	byte		4	data module
+>12	byte		11	trap library
+>12	byte		12	system module
+>12	byte		13	file manager
+>12	byte		14	device driver
+>12	byte		15	device descriptor

+ 7 - 0
Magdir/osf1

@@ -0,0 +1,7 @@
+#
+# Mach magic number info
+#
+0	long		0xefbe	OSF/Rose object
+# I386 magic number info
+#
+0	short		0565	i386 COFF object

+ 21 - 2
Magdir/printer

@@ -18,10 +18,29 @@
 >>>16	string		Query		- type %s
 >>>16	string		ExitServer	- type %s
 
+# Adobe's PostScript Printer Description (PPD) files
+#       Yves Arrouye <arrouye@marin.fdn.fr>
+#
+0      string          *PPD-Adobe:    PPD file
+>13    string          x              \b, ve
+
+# HP Printer Job Language
+0	string		\033%-12345X@PJL	HP Printer Job Language data
 # HP Printer Job Language
+# The header found on Win95 HP plot files is the "Silliest Thing possible" 
+# (TM)
+# Every driver puts the language at some random position, with random case
+# (LANGUAGE and Language)
+# For example the LaserJet 5L driver puts the "PJL ENTER LANGUAGE" in line 10
+# From: Uwe Bonnes <bon@elektron.ikp.physik.th-darmstadt.de>
+# 
 0	string		\033%-12345X@PJL	HP Printer Job Language data
->15	string		\ ENTER\ LANGUAGE\ =
->31	string		PostScript		Postscript
+>&0	string		>\0			%s			
+>>&0	string		>\0			%s			
+>>>&0	string		>\0			%s		
+>>>>&0	string		>\0			%s		
+#>15	string		\ ENTER\ LANGUAGE\ =
+#>31	string		PostScript		PostScript
 
 # HP Printer Control Language, Daniel Quinlan (quinlan@yggdrasil.com)
 0	string		\033E\033	HP PCL printer data

+ 20 - 11
Magdir/sgi

@@ -1,12 +1,16 @@
 
 #------------------------------------------------------------------------------
 # sgi:  file(1) magic for Silicon Graphics (MIPS, IRIS, IRIX, etc.)
-#
+#                         Dec Ultrix (MIPS)
 # all of SGI's *current* machines and OSes run in big-endian mode on the
 # MIPS machines, as far as I know.
 #
 # XXX - what is the blank "-" line?
 #
+# kbd file definitions
+0	string	kbd!map		kbd map file
+>8	byte	>0		Ver %d:
+>10	short	>0		with %d table(s)
 0	belong	0407		old SGI 68020 executable
 0	belong	0410		old SGI 68020 pure executable
 0	beshort	0x8765		disk quotas file
@@ -47,8 +51,8 @@
 >20	beshort	05401		(paged)
 >8	belong	>0		not stripped
 >8	belong	0		stripped
->22	byte	x		- version %d
->23	byte	x		.%ld
+>23	byte	x		- version %d
+>22	byte	x		.%ld
 #
 0	beshort	0x6201		MIPSEL-LE COFF executable
 >20	beshort	03401		(impure)
@@ -56,8 +60,8 @@
 >20	beshort	05401		(paged)
 >8	belong	>0		not stripped
 >8	belong	0		stripped
->22	byte	x		- version %ld
->23	byte	x		.%ld
+>23	byte	x		- version %ld
+>22	byte	x		.%ld
 #
 # MIPS 2 additions
 #
@@ -86,7 +90,7 @@
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >23	byte	x		- version %ld
->23	byte	x		.%ld
+>22	byte	x		.%ld
 #
 0	beshort	0x6601		MIPSEL-LE MIPS-II COFF executable
 >20	beshort	03401		(impure)
@@ -95,7 +99,7 @@
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >23	byte	x		- version %ld
->23	byte	x		.%ld
+>22	byte	x		.%ld
 #
 # MIPS 3 additions
 #
@@ -124,7 +128,7 @@
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >23	byte	x		- version %ld
->23	byte	x		.%ld
+>22	byte	x		.%ld
 #
 0	beshort	0x4201		MIPSEL-LE MIPS-III COFF executable
 >20	beshort	03401		(impure)
@@ -133,7 +137,7 @@
 >8	belong	>0		not stripped
 >8	belong	0		stripped
 >23	byte	x		- version %ld
->23	byte	x		.%ld
+>22	byte	x		.%ld
 #
 0	beshort	0x180		MIPSEB Ucode
 0	beshort	0x182		MIPSEL Ucode
@@ -145,6 +149,10 @@
 0	belong	0xdeadad40	IRIX 64-bit core dump
 >4	belong	1		of
 >16	string	>\0		'%s'
+# N32bit core file
+0       belong	0xbabec0bb	IRIX N32 core dump
+>4      belong	1               of
+>16     string	>\0             '%s'
 # New style crash dump file
 0	string	\x43\x72\x73\x68\x44\x75\x6d\x70	IRIX vmcore dump of
 >36	string	>\0					'%s'
@@ -152,12 +160,13 @@
 0	string	SGIAUDIT	SGI Audit file
 >8	byte	x		- version %d
 >9	byte	x		.%ld
-# Are these three SGI-based file types or general ones?
+#
 0	string	WNGZWZSC	Wingz compiled script
 0	string	WNGZWZSS	Wingz spreadsheet
 0	string	WNGZWZHP	Wingz help file
 #
-0	string	\#Inventor V	IRIS Inventor file
+0	string	\#Inventor V	IRIS Inventor 1.0 file
+0	string	\#Inventor V2	Open Inventor 2.0 file
 # XXX - I don't know what next thing is!  It is likely to be an image
 # (or movie) format
 0	string	glfHeadMagic();		GLF_TEXT

+ 79 - 0
Magdir/sniffer

@@ -0,0 +1,79 @@
+
+#------------------------------------------------------------------------------
+# sniffer:  file(1) magic for packet captured files
+#
+# From: guy@netapp.com (Guy Harris)
+#
+# Microsoft NetMon (packet capture/display program) capture files.
+#
+0	string		RTSS		NetMon capture file
+>4	byte		x		- version %d
+>5	byte		x		\b.%d
+>6	leshort		0		(Unknown)
+>6	leshort		1		(Ethernet)
+>6	leshort		2		(Token Ring)
+>6	leshort		3		(FDDI)
+
+#
+# Network General Sniffer capture files.
+#
+0	string		TRSNIFF\ data\ \ \ \ \032	Sniffer capture file
+>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)
+#
+# Cinco Networks NetXRay 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.)
+#
+0	ubelong		0xa1b2c3d4	tcpdump capture file (big-endian)
+>4	beshort		x		- version %d
+>6	beshort		x		\b.%d
+>20	belong		0		(No link-layer encapsulation
+>20	belong		1		(Ethernet
+>20	belong		2		(3Mb Ethernet
+>20	belong		3		(AX.25
+>20	belong		4		(ProNET
+>20	belong		5		(CHAOS
+>20	belong		6		(IEEE 802.x network
+>20	belong		7		(ARCNET
+>20	belong		8		(SLIP
+>20	belong		9		(PPP
+>20	belong		10		(FDDI
+>20	belong		11		(RFC 1483 ATM
+>20	belong		12		(raw IP
+>20	belong		13		(BSD/OS SLIP
+>20	belong		14		(BSD/OS PPP
+>16	belong		x		\b, capture length %d)
+0	ulelong		0xa1b2c3d4	tcpdump capture file (little-endian)
+>4	leshort		x		- version %d
+>6	leshort		x		\b.%d
+>20	lelong		0		(No link-layer encapsulation
+>20	lelong		1		(Ethernet
+>20	lelong		2		(3Mb Ethernet
+>20	lelong		3		(AX.25
+>20	lelong		4		(ProNET
+>20	lelong		5		(CHAOS
+>20	lelong		6		(IEEE 802.x network
+>20	lelong		7		(ARCNET
+>20	lelong		8		(SLIP
+>20	lelong		9		(PPP
+>20	lelong		10		(FDDI
+>20	lelong		11		(RFC 1483 ATM
+>20	lelong		12		(raw IP
+>20	lelong		13		(BSD/OS SLIP
+>20	lelong		14		(BSD/OS PPP
+>16	lelong		x		\b, capture length %d)

+ 21 - 0
Magdir/sun

@@ -84,3 +84,24 @@
 >>128	string		>\0		from '%s'
 >4	belong		456		(SPARC 4.x BCP)
 >>152	string		>\0		from '%s'
+# Sun SunPC
+0	long		0xfa33c08e	SunPC 4.0 Hard Disk
+0	string		#SUNPC_CONFIG	SunPC 4.0 Properties Values
+# Sun snoop (see RFC 1761, which describes the capture file format).
+#
+0	string		snoop		Snoop capture file
+>8	belong		>0		- version %ld
+>12	belong		0		(IEEE 802.3)
+>12	belong		1		(IEEE 802.4)
+>12	belong		2		(IEEE 802.5)
+>12	belong		3		(IEEE 802.6)
+>12	belong		4		(Ethernet)
+>12	belong		5		(HDLC)
+>12	belong		6		(Character synchronous)
+>12	belong		7		(IBM channel-to-channel adapter)
+>12	belong		8		(FDDI)
+>12	belong		9		(Unknown)
+# Sun KCMS
+36	string		acsp		Kodak Color Management System, ICC Profile
+
+

+ 36 - 0
Magdir/ti-8x

@@ -0,0 +1,36 @@
+# ------------------------------------------------------------------------
+# ti-8x: file(1) magic for the TI-8x and TI-92 Graphing Calculators.
+#
+# From: Ryan McGuire (rmcguire@freenet.columbus.oh.us).
+#
+# NOTE: This list is not complete.
+#
+# Magic Numbers for the TI-82
+#
+0               string          **TI82**        TI-82 Graphing Calculator
+>0x000037       byte            0x0B            TI-BASIC Group/Program File.
+#
+# Magic Numbers for the TI-83
+#
+0               string          **TI83**        TI-83 Graphing Calculator
+>0x000037       byte            0x0B            TI-BASIC Group/Program File.
+#
+# Magic Numbers for the TI-85
+#
+0               string          **TI85**        TI-85 Graphing Calculator
+>11             string          Backup          Backup File.
+>0x000032       string          ZS4             - ZShell Version 4 File.
+>0x000032       string          ZS3             - ZShell Version 3 File.
+>0x00000B       string          GDatabase       Graphics Database.
+>0x00003B       byte            0x12            TI-BASIC Group/Program File.
+#
+# Magic Numbers for the TI-92
+#
+0               string          **TI92**        TI-92 Graphing Calculator
+>0x000058       byte            0x12            TI-BASIC Group File.
+>0x000012       string          Function        Function.
+>0x000048       byte            0x12            TI-BASIC Program.
+# Files for the TI-80 and TI-81 are pretty rare. I'm not going to put the
+# program/group magic numbers in here because I cannot find any.
+0               string          **TI80**        TI-80 Graphing Calculator File.
+0               string          **TI81**        TI-81 Graphing Calculator File.

+ 2 - 0
Magdir/timezone

@@ -4,6 +4,8 @@
 #
 # from Daniel Quinlan (quinlan@yggdrasil.com)
 # this should work on Linux, SunOS, and maybe others
+# Added new official magic number for recent versions of the Olson code
+0	string	TZif	timezone data
 0	string	\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0	timezone data
 0	string	\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2\0	timezone data
 0	string  \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0	timezone data

+ 6 - 0
Magdir/varied.out

@@ -13,3 +13,9 @@
 0	beshort		0160007		amd 29k coff archive
 # Cray
 6	beshort		0407		unicos (cray) executable
+# Ultrix 4.3
+596	string		\130\337\377\377	Ultrix core file
+>600	string		>\0	'%s'
+# BeOS and MAcOS PEF executables
+# From: hplus@zilker.net (Jon Watte)
+0	string		Joy!peffpwpc	header for PowerPC PEF executable

+ 26 - 0
Magdir/vgetty

@@ -0,0 +1,26 @@
+#
+# Magic data for vgetty voice formats
+# (Martin Seine & Marc Eberhard)
+#
+
+#
+# raw modem data version 1
+#
+
+0    string    RMD1      raw modem data
+>4   string    >\0       (%s /
+>20  short     >0        compression type 0x%04x)
+
+#
+# portable voice format 1
+#
+
+0    string    PVF1\n         portable voice format
+>5   string    >\0       (binary %s)
+
+#
+# portable voice format 2
+#
+
+0    string    PVF2\n         portable voice format
+>5   string >\0          (ascii %s)

+ 1 - 1
Magdir/microsoft

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# microsoft:  file(1) magic for Microsoft Xenix
+# xenix:  file(1) magic for Microsoft Xenix
 #
 # "Middle model" stuff, and "Xenix 8086 relocatable or 80286 small
 # model" lifted from "magic.xenix", with comment "derived empirically;

+ 33 - 31
Makefile

@@ -1,6 +1,6 @@
 # Makefile for file(1) cmd. 
 # Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE.
-# @(#)$Id: Makefile,v 1.51 1996/06/22 22:05:07 christos Exp $
+# @(#)$Id: Makefile.in,v 1.3 1998/02/15 23:21:17 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,30 +21,26 @@
 #    ever read sources, credits must appear in the documentation.
 #
 # 4. This notice may not be removed or altered.
-
-# Optimized for Linux because sunsite.unc.edu, tsx-11.mit.edu,
-# ftp.redhat.com, ftp.funet.fi, and other Linux sites never get
-# a copy uploaded to them. Most still had 3.15 + a patch at the
-# time of this hack.  --  Albert Cahalan <acahalan@cs.uml.edu>
-
-# Was 3.20, number changed as requested.
-VERSION	= 3.20.1
+VERSION	= 3.24
 SHELL	= /bin/sh
-MAGIC	= /etc/magic
-#MAGIC	= /usr/local/etc/magic
-
-DEFS	= -DMAGIC='"$(MAGIC)"' # -Dvoid=int
-CC	= gcc
-COPTS	= -s -O2 -fno-strength-reduce -fomit-frame-pointer
-CFLAGS	= $(COPTS) $(DEFS)
-LDFLAGS	= $(COPTS) # -Bstatic	# older gdb couldn't handle shared libs
-
+#MAGIC	= /etc/magic
+prefix = @prefix@
+INSTALLCMD = @INSTALL@
+MAGICDIR = @datadir@
+MAGIC	= $(MAGICDIR)/magic
+DEFS	= -DMAGIC='"$(MAGIC)"' -DBUILTIN_ELF -DHAVE_CONFIG_H
+CPPFLAGS = $(DEFS)
+CC	= @CC@
+#COPTS	= -O -g		# newer compilers allow both; else drop -O
+# For truly antique environments, use this for (dummy) include files:
+#COPTS	= -O # -Ilocalinc
+#CFLAGS	= $(COPTS) $(DEFS)
+CFLAGS = @CFLAGS@
+#LDFLAGS	= $(COPTS) # -Bstatic	# older gdb couldn't handle shared libs
 SHAR	= bundle
 OFILE	= /usr/bin/file		# old or distributed version, for comparison
-
 # Where new binary lives; typically /usr/local (BSD), /usr/lbin (USG).
-BINDIR	= /usr/bin
-
+BINDIR	= @exec_prefix@/bin
 # For installing our man pages; 
 # MANCxxx is manual section for Commands, MANFxxx is section for file formats.
 # MANxDIR is directory names; MANxEXT is the filename extention. Usual values:
@@ -63,10 +59,10 @@ BINDIR	= /usr/bin
 # MANCDIR			/usr/man/local/man1
 # MANCEXT			1
 
-MANCDIR	= /usr/local/man/man1
+MANCDIR	= @mandir@/man1
 MANCEXT	= 1
-MANFDIR	= /usr/local/man/man5
-MANFEXT	= 5
+MANFDIR	= @mandir@/man4
+MANFEXT	= 4
 
 # There are no system-dependant configuration options (except maybe CFLAGS).
 # Uncomment any of these that is missing from your "standard" library.
@@ -79,14 +75,16 @@ LOCALOBJS = # localsrc/getopt.o localsrc/strtol.o \
 LOCALINC = # localinc/*.h localinc/sys/*.h
 
 SRCS = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
-	compress.c is_tar.c \
+	compress.c is_tar.c readelf.c internat.c \
 	print.c $(LOCALSRCS) $(LOCALINC)
 OBJS = file.o apprentice.o fsmagic.o softmagic.o ascmagic.o \
-	compress.o is_tar.o \
+	compress.o is_tar.o readelf.o internat.o \
 	print.o $(LOCALOBJS)
+HDRS = file.h names.h patchlevel.h readelf.h tar.h
 
-ALLSRC = LEGAL.NOTICE README MAINT PORTING $(SRCS) *.h \
-	 Makefile file.man magic.man 
+AUTOSRC=configure configure.in install-sh config.h.in Makefile.in
+ALLSRC = LEGAL.NOTICE README MAINT PORTING $(SRCS) $(HDRS) \
+	 Makefile.std file.man magic.man magic2mime $(AUTOSRC)
 ALLMAGIC =   Magdir/Makefile Magdir/Localstuff Magdir/Header Magdir/[a-z]*
 
 all:		file magic file.${MANCEXT} magic.${MANFEXT}
@@ -112,8 +110,11 @@ ascmagic.o:	names.h
 compress.o apprentice.o ascmagic.o file.o fsmagic.o print.o softmagic.o: file.h
 
 install:	file magic
-		cp file	$(BINDIR)/file
-		cp magic $(MAGIC)
+		-mkdir $(BINDIR) $(MAGICDIR) $(MANCDIR) $(MANFDIR)
+		$(INSTALLCMD) file	$(BINDIR)/file
+		$(INSTALLCMD) magic $(MAGIC)
+		$(INSTALLCMD) file.${MANCEXT} $(MANCDIR)/file.$(MANCEXT)
+		$(INSTALLCMD) magic.${MANFEXT} $(MANFDIR)/magic.$(MANFEXT)
 
 install.man: file.${MANCEXT} magic.${MANFEXT}
 		cp file.${MANCEXT} $(MANCDIR)/file.$(MANCEXT)
@@ -121,7 +122,8 @@ install.man: file.${MANCEXT} magic.${MANFEXT}
 
 clean:
 		rm -f *.o core file magic lint dist.* MANIFEST \
-		      magic.${MANFEXT} file.${MANCEXT}
+		      magic.${MANFEXT} file.${MANCEXT} \
+		      config.h config.status config.cache config.log
 clobber:
 		cd tst; $(MAKE) clean
 

+ 11 - 8
orig/Makefile

@@ -1,6 +1,6 @@
 # Makefile for file(1) cmd. 
 # Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE.
-# @(#)$Id: Makefile,v 1.51 1996/06/22 22:05:07 christos Exp $
+# @(#)$Id: Makefile.std,v 1.3 1998/02/15 23:21:17 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,11 +21,11 @@
 #    ever read sources, credits must appear in the documentation.
 #
 # 4. This notice may not be removed or altered.
-VERSION	= 3.20
+VERSION	= 3.24
 SHELL	= /bin/sh
 #MAGIC	= /etc/magic
 MAGIC	= /usr/local/etc/magic
-DEFS	= -DMAGIC='"$(MAGIC)"' # -Dvoid=int
+DEFS	= -DMAGIC='"$(MAGIC)"' -DBUILTIN_ELF # -Dvoid=int
 CC	= cc
 COPTS	= -O -g		# newer compilers allow both; else drop -O
 # For truly antique environments, use this for (dummy) include files:
@@ -70,14 +70,16 @@ LOCALOBJS = # localsrc/getopt.o localsrc/strtol.o \
 LOCALINC = # localinc/*.h localinc/sys/*.h
 
 SRCS = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
-	compress.c is_tar.c \
+	compress.c is_tar.c readelf.c internat.c \
 	print.c $(LOCALSRCS) $(LOCALINC)
 OBJS = file.o apprentice.o fsmagic.o softmagic.o ascmagic.o \
-	compress.o is_tar.o \
+	compress.o is_tar.o readelf.o internat.o \
 	print.o $(LOCALOBJS)
+HDRS = file.h names.h patchlevel.h readelf.h tar.h
 
-ALLSRC = LEGAL.NOTICE README MAINT PORTING $(SRCS) *.h \
-	 Makefile file.man magic.man 
+AUTOSRC=configure configure.in install-sh config.h.in Makefile.in
+ALLSRC = LEGAL.NOTICE README MAINT PORTING $(SRCS) $(HDRS) \
+	 Makefile.std file.man magic.man magic2mime $(AUTOSRC)
 ALLMAGIC =   Magdir/Makefile Magdir/Localstuff Magdir/Header Magdir/[a-z]*
 
 all:		file magic file.${MANCEXT} magic.${MANFEXT}
@@ -112,7 +114,8 @@ install.man: file.${MANCEXT} magic.${MANFEXT}
 
 clean:
 		rm -f *.o core file magic lint dist.* MANIFEST \
-		      magic.${MANFEXT} file.${MANCEXT}
+		      magic.${MANFEXT} file.${MANCEXT} \
+		      config.h config.status config.cache config.log
 clobber:
 		cd tst; $(MAKE) clean
 

+ 22 - 20
README

@@ -1,21 +1,9 @@
 ** README for file(1) Command **
-@(#) $Id: README,v 1.20 1993/09/23 21:47:01 christos Exp $
-
-This is release 3.20.1 of the file(1) command for Linux. It was hacked
-out of version 3.20 (Ian Darwin and Christos Zoulas) by Albert Cahalan
-because the default compiler options were poor and because they refused
-to upload it to any Linux archive site. Linux archives ended up with
-version 3.15 + a patch to fix a bug. (Linux users: please help keep the
-archives updated. Remember to use the C compiler options I put in the
-Makefile, increase the version by 0.0.1 as requested, and add yourself
-to the documentation as requested. Archive sites include sunsite.unc.edu,
-tsx-11.mit.edu, ftp.funet.fi, and ftp.redhat.com) <acahalan@cs.uml.edu>
+@(#) $Id: README,v 1.22 1997/11/05 16:03:18 christos Exp $
 
 This is Release 3.x of Ian Darwin's (copyright but distributable)
-file(1) command.  Release 3.x is scheduled for inclusion in the
-4.4 BSD (Berkeley Software Distribution) of UNIX-like
-software, and is the standard "file" command for Linux, 386bsd,
-and other systems. (See "patchlevel.h" for the exact release number).
+file(1) command. This version is the standard "file" command for Linux,
+*BSD, and other systems. (See "patchlevel.h" for the exact release number).
 
 UNIX is a trademark of UNIX System Laboratories.
 
@@ -68,17 +56,31 @@ magic.4 - man page for the magic file, courtesy Guy Harris.
 file.c - main program
 file.h - header file
 fsmagic.c - first set of tests the program runs, based on filesystem info
-is_tar.c - knows about tarchives (courtesy John Gilmore).
+is_tar.c, tar.h - knows about tarchives (courtesy John Gilmore).
 magdir - directory of /etc/magic pieces
 	magdir/Makefile - ADJUST THIS FOR YOUR CONFIGURATION
 names.h - header file for ascmagic.c
 softmagic.c - 2nd set of tests, based on /etc/magic
-strtok.c, getopt.c - in case you them (courtesy of Henry Spencer).
-strtol.c, strchr.c - in case you need them - public domain.
-tst - simple test suite, built from tst/Makefile
+readelf.[ch] - Standalone elf parsing code.
+compress.c - on-the-fly decompression.
+internat.c - recognize international `text' files.
+print.c - print results, errors, warnings.
 
+If your gzip sometimes fails to decompress things complaining about a short
+file, apply this patch [which is going to be in the next version of gzip]:
+*** -   Tue Oct 29 02:06:35 1996
+--- util.c      Sun Jul 21 21:51:38 1996
+*** 106,111 ****
+--- 108,114 ----
+  
+      if (insize == 0) {
+        if (eof_ok) return EOF;
++       flush_window();
+        read_error();
+      }
+      bytes_in += (ulg)insize;
 
-E-mail: christos@deshaw.com, moraes@deshaw.com
+E-mail: christos@astron.com, moraes@deshaw.com
 
 Phone: Do not even think of telephoning me about this program. Send cash first!
 

+ 7 - 12
apprentice.c

@@ -34,7 +34,7 @@
 
 #ifndef	lint
 static char *moduleid = 
-	"@(#)$Id: apprentice.c,v 1.24 1996/06/22 22:04:22 christos Exp $";
+	"@(#)$Id: apprentice.c,v 1.25 1997/01/15 17:23:24 christos Exp $";
 #endif	/* lint */
 
 #define	EATAB {while (isascii((unsigned char) *l) && \
@@ -133,10 +133,10 @@ int check;			/* non-zero? checking-only run. */
 /*
  * extend the sign bit if the comparison is to be signed
  */
-unsigned long
+uint32
 signextend(m, v)
 struct magic *m;
-unsigned long v;
+uint32 v;
 {
 	if (!(m->flag & UNSIGNED))
 		switch(m->type) {
@@ -159,7 +159,7 @@ unsigned long v;
 		case LONG:
 		case BELONG:
 		case LELONG:
-			v = (long) v;
+			v = (int32) v;
 			break;
 		case STRING:
 			break;
@@ -495,21 +495,16 @@ int	plen, *slen;
 				*p++ = (char)val;
 				break;
 
-			/* \x and up to 3 hex digits */
+			/* \x and up to 2 hex digits */
 			case 'x':
 				val = 'x';	/* Default if no digits */
 				c = hextoint(*s++);	/* Get next char */
 				if (c >= 0) {
 					val = c;
 					c = hextoint(*s++);
-					if (c >= 0) {
+					if (c >= 0)
 						val = (val << 4) + c;
-						c = hextoint(*s++);
-						if (c >= 0) {
-							val = (val << 4) + c;
-						} else
-							--s;
-					} else
+					else
 						--s;
 				} else
 					--s;

+ 9 - 7
ascmagic.c

@@ -28,6 +28,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <memory.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -36,7 +37,7 @@
 
 #ifndef	lint
 static char *moduleid = 
-	"@(#)$Id: ascmagic.c,v 1.20 1995/05/20 22:09:21 christos Exp $";
+	"@(#)$Id: ascmagic.c,v 1.22 1998/02/15 23:18:53 christos Exp $";
 #endif	/* lint */
 
 			/* an optimisation over plain strcmp() */
@@ -88,6 +89,13 @@ int nbytes;	/* size actually read */
 		return 1;
 	}
 
+
+	/* Make sure we are dealing with ascii text before looking for tokens */
+	for (i = 0; i < nbytes; i++) {
+		if (!isascii(buf[i]))
+			return 0;	/* not all ASCII */
+	}
+
 	/* look for tokens from names.h - this is expensive! */
 	/* make a copy of the buffer here because strtok() will destroy it */
 	s = (unsigned char*) memcpy(nbuf, buf, nbytes);
@@ -106,12 +114,6 @@ int nbytes;	/* size actually read */
 		}
 	}
 
-
-	for (i = 0; i < nbytes; i++) {
-		if (!isascii(buf[i]))
-			return 0;	/* not all ASCII */
-	}
-
 	/* all else fails, but it is ASCII... */
 	ckfputs("ASCII text", stdout);
 	if (has_escapes) {

+ 6 - 1
compress.c

@@ -4,13 +4,18 @@
  *		   information if recognized
  *	uncompress(method, old, n, newch) - uncompress old into new, 
  *					    using method, return sizeof new
- * $Id: compress.c,v 1.9 1995/05/20 22:09:21 christos Exp $
+ * $Id: compress.c,v 1.10 1998/02/15 23:18:53 christos Exp $
  */
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
+#endif
 
 #include "file.h"
 

+ 16 - 0
config.h.in

@@ -0,0 +1,16 @@
+/* config.h.in.  Generated automatically from configure.in by autoheader.  */
+
+/* Define to empty if the keyword does not work.  */
+#undef const
+
+/* Define if your struct stat has st_rdev.  */
+#undef HAVE_ST_RDEV
+
+/* Define to `long' if <sys/types.h> doesn't define.  */
+#undef off_t
+
+/* Define to `unsigned' if <sys/types.h> doesn't define.  */
+#undef size_t
+
+/* Define if you have the ANSI C header files.  */
+#undef STDC_HEADERS

File diff suppressed because it is too large
+ 1393 - 0
configure


+ 15 - 0
configure.in

@@ -0,0 +1,15 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(file.c)
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_LN_S
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+AC_STRUCT_ST_RDEV
+
+AC_OUTPUT(Makefile config.h)

+ 0 - 20
file-3.20.1.lsm

@@ -1,20 +0,0 @@
-Begin3
-Title:          file(1): C sources
-Version:        3.20.1
-Entered-date:   29JUL96
-Description:    These are the sources to Darwin's file(1) utility and master
-                magic(4) file, now maintained by Christos Zoulas. The file(1)
-                utility is used to determine the types of various files;
-                file prints a one-line summary for each argument it is given.
-Keywords:       /etc/magic file identify magic /usr/bin/file source
-Author:         ian@sq.com (Ian F. Darwin)
-Maintained-by:  acahalan@cs.uml.edu (Albert Cahalan)
-                christos@ee.cornell.edu (Christos Zoulas)
-                moraes@deshaw.com (Mark Moraes)
-Primary-site:   sunsite.unc.edu pub/Linux/utils/file
-                70kB file-3.20.1.tgz
-Alternate-site: tsx-11.mit.edu
-Original-site:  ftp.deshaw.com /pub/file
-Platforms:      Linux
-Copying-policy: Free and copyrighted
-End

+ 39 - 62
file.c

@@ -26,7 +26,7 @@
  */
 #ifndef	lint
 static char *moduleid = 
-	"@(#)$Id: file.c,v 1.35 1996/06/22 22:04:22 christos Exp $";
+	"@(#)$Id: file.c,v 1.39 1998/02/15 23:18:53 christos Exp $";
 #endif	/* lint */
 
 #include <stdio.h>
@@ -37,22 +37,25 @@ static char *moduleid =
 #include <sys/stat.h>
 #include <fcntl.h>	/* for open() */
 #if (__COHERENT__ >= 0x420)
-#include <sys/utime.h>
+# include <sys/utime.h>
 #else
-#include <utime.h>
+# ifdef USE_UTIMES
+#  include <sys/time.h>
+# else
+#  include <utime.h>
+# endif
 #endif
 #include <unistd.h>	/* for read() */
 
-#include "readelf.h"
 #include <netinet/in.h>		/* for byte swapping */
 
 #include "patchlevel.h"
 #include "file.h"
 
 #ifdef S_IFLNK
-# define USAGE  "Usage: %s [-vczL] [-f namefile] [-m magicfiles] file...\n"
+# define USAGE  "Usage: %s [-vbczL] [-f namefile] [-m magicfiles] file...\n"
 #else
-# define USAGE  "Usage: %s [-vcz] [-f namefile] [-m magicfiles] file...\n"
+# define USAGE  "Usage: %s [-vbcz] [-f namefile] [-m magicfiles] file...\n"
 #endif
 
 #ifndef MAGIC
@@ -62,6 +65,7 @@ static char *moduleid =
 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 */
 
 int			/* Misc globals				*/
@@ -76,8 +80,10 @@ int lineno;		/* line number in the magic file	*/
 
 
 static void	unwrap		__P((char *fn));
+#if 0
 static int	byteconv4	__P((int, int, int));
 static short	byteconv2	__P((int, int, int));
+#endif
 
 /*
  * main - parse arguments and handle options
@@ -98,12 +104,15 @@ char *argv[];
 	if (!(magicfile = getenv("MAGIC")))
 		magicfile = MAGIC;
 
-	while ((c = getopt(argc, argv, "vcdf:Lm:z")) != EOF)
+	while ((c = getopt(argc, argv, "vbcdf:Lm:z")) != EOF)
 		switch (c) {
 		case 'v':
 			(void) fprintf(stdout, "%s-%d.%d\n", progname,
 				       FILE_VERSION_MAJOR, patchlevel);
 			return 1;
+		case 'b':
+			++bflag;
+			break;
 		case 'c':
 			++check;
 			break;
@@ -208,6 +217,7 @@ char *fn;
 }
 
 
+#if 0
 /*
  * byteconv4
  * Input:
@@ -270,6 +280,7 @@ byteconv2(from, same, big_endian)
   else
     return ntohs(from);		/* msb -> lsb conversion on lsb */
 }
+#endif
 
 /*
  * process - process input file
@@ -282,7 +293,6 @@ int wid;
 	int	fd = 0;
 	static  const char stdname[] = "standard input";
 	unsigned char	buf[HOWMANY+1];	/* one extra for terminating '\0' */
-	struct utimbuf  utbuf;
 	struct stat	sb;
 	int nbytes = 0;	/* number of bytes read from a datafile */
 	char match = '\0';
@@ -296,7 +306,7 @@ int wid;
 		inname = stdname;
 	}
 
-	if (wid > 0)
+	if (wid > 0 && !bflag)
 	     (void) printf("%s:%*s ", inname, 
 			   (int) (wid - strlen(inname)), "");
 
@@ -335,67 +345,30 @@ int wid;
 		match = tryit(buf, nbytes, zflag);
 	}
 
-	/*
-	 * ELF executables have multiple section headers in arbitrary
-	 * file locations and thus file(1) cannot determine it from easily.
-	 * Instead we traverse thru all section headers until a symbol table
-	 * one is found or else the binary is stripped.
-	 */
-
-	if (match == 's' && nbytes > sizeof (Elf32_Ehdr) &&
-	    buf[EI_MAG0] == ELFMAG0 &&
-	    buf[EI_MAG1] == ELFMAG1 &&
-	    buf[EI_MAG2] == ELFMAG2 &&
-	    buf[EI_MAG3] == ELFMAG3) {
-
-		union {
-			int l;
-			char c[sizeof (int)];
-		} u;
-
-		Elf32_Ehdr elfhdr;
-		int stripped = 1;
-		int be,same;
-		short shnum;
-
-		u.l = 1;
-		(void) memcpy(&elfhdr, buf, sizeof elfhdr);
-
-		/*
-		 * If the system byteorder does not equal the object byteorder
-		 * then need to do byte-swapping.
-		 */
-		be = u.c[sizeof(int) - 1] == 1; /* are we big endian? */
-		same = (u.c[sizeof(int) - 1] + 1) == elfhdr.e_ident[5];
-				/* are we the same endianness? */;
-
-		if (lseek(fd, byteconv4(elfhdr.e_shoff,same,be), SEEK_SET)<0)
-			error("lseek failed (%s).\n", strerror(errno));
-
-		for (shnum = byteconv2(elfhdr.e_shnum,same,be);
-		     shnum; shnum--) {
-		    if (read(fd, buf,
-			     byteconv2(elfhdr.e_shentsize,same,be))<0)
-			error("read failed (%s).\n", strerror(errno));
-		    if (byteconv4(((Elf32_Shdr *)buf)->sh_type,same,be)
-			== SHT_SYMTAB) {
-			stripped = 0;
-			break;
-		    }
-		}
-		if (stripped)
-		    (void) printf (", stripped");
-		else
-		    (void) printf (", not stripped");
-	}
+#ifdef BUILTIN_ELF
+	if (match == 's' && nbytes > 5)
+		tryelf(fd, buf, nbytes);
+#endif
 
 	if (inname != stdname) {
+#ifdef RESTORE_TIME
 		/*
 		 * Try to restore access, modification times if read it.
 		 */
+# ifdef USE_UTIMES
+		struct timeval  utsbuf[2];
+		utsbuf[0].tv_sec = sb.st_atime;
+		utsbuf[1].tv_sec = sb.st_mtime;
+
+		(void) utimes(inname, utsbuf); /* don't care if loses */
+# else
+		struct utimbuf  utbuf;