Browse Source

Import upstream version 4.24

Christos Zoulas 11 years ago
parent
commit
003f293dc9
100 changed files with 3133 additions and 2085 deletions
  1. 1 0
      AUTHORS
  2. 1 1
      LEGAL.NOTICE
  3. 117 71
      ChangeLog
  4. 234 0
      INSTALL
  5. 2 3
      MAINT
  6. 2 5
      Makefile.am
  7. 14 20
      Makefile.in
  8. 1 0
      NEWS
  9. 0 0
      PORTING
  10. 10 5
      README
  11. 2 238
      acinclude.m4
  12. 0 29
      aclocal.m4
  13. 61 48
      config.h.in
  14. 940 797
      configure
  15. 122 0
      configure.ac
  16. 0 139
      configure.in
  17. 5 6
      doc/Makefile.in
  18. 53 102
      doc/file.man
  19. 10 3
      doc/libmagic.man
  20. 98 79
      doc/magic.man
  21. 10 0
      magic/Magdir/adventure
  22. 211 126
      magic/Magdir/animation
  23. 24 7
      magic/Magdir/apple
  24. 59 4
      magic/Magdir/archive
  25. 80 10
      magic/Magdir/audio
  26. 8 5
      magic/Magdir/c-lang
  27. 0 1
      magic/Magdir/c64
  28. 11 7
      magic/Magdir/cafebabe
  29. 1 2
      magic/Magdir/cddb
  30. 26 0
      magic/Magdir/clarion
  31. 29 8
      magic/Magdir/commands
  32. 27 12
      magic/Magdir/compress
  33. 1 1
      magic/Magdir/cracklib
  34. 1 2
      magic/Magdir/ctags
  35. 23 1
      magic/Magdir/database
  36. 5 6
      magic/Magdir/diff
  37. 38 0
      magic/Magdir/dump
  38. 50 0
      magic/Magdir/elf
  39. 18 0
      magic/Magdir/erlang
  40. 64 34
      magic/Magdir/filesystems
  41. 3 0
      magic/Magdir/flash
  42. 4 5
      magic/Magdir/fonts
  43. 1 0
      magic/Magdir/fortran
  44. 12 2
      magic/Magdir/frame
  45. 7 3
      magic/Magdir/fsav
  46. 7 11
      magic/Magdir/games
  47. 23 0
      magic/Magdir/gnome-keyring
  48. 4 0
      magic/Magdir/gnu
  49. 7 0
      magic/Magdir/gnumeric
  50. 48 29
      magic/Magdir/hp
  51. 3 0
      magic/Magdir/iff
  52. 77 18
      magic/Magdir/images
  53. 8 0
      magic/Magdir/inform
  54. 2 1
      magic/Magdir/java
  55. 6 0
      magic/Magdir/jpeg
  56. 10 0
      magic/Magdir/kde
  57. 4 5
      magic/Magdir/lex
  58. 10 9
      magic/Magdir/linux
  59. 13 10
      magic/Magdir/lisp
  60. 10 0
      magic/Magdir/llvm
  61. 15 0
      magic/Magdir/lua
  62. 12 0
      magic/Magdir/luks
  63. 73 59
      magic/Magdir/macintosh
  64. 13 1
      magic/Magdir/mail.news
  65. 7 0
      magic/Magdir/mathcad
  66. 2 2
      magic/Magdir/mathematica
  67. 12 0
      magic/Magdir/mercurial
  68. 3 2
      magic/Magdir/misctools
  69. 8 0
      magic/Magdir/mozilla
  70. 84 22
      magic/Magdir/msdos
  71. 1 1
      magic/Magdir/mup
  72. 6 0
      magic/Magdir/netware
  73. 13 0
      magic/Magdir/ole2compounddocs
  74. 2 3
      magic/Magdir/os2
  75. 1 1
      magic/Magdir/palm
  76. 2 1
      magic/Magdir/pdf
  77. 27 21
      magic/Magdir/perl
  78. 18 5
      magic/Magdir/pgp
  79. 1 0
      magic/Magdir/pkgadd
  80. 14 9
      magic/Magdir/printer
  81. 10 0
      magic/Magdir/revision
  82. 4 0
      magic/Magdir/riff
  83. 2 1
      magic/Magdir/rpm
  84. 8 5
      magic/Magdir/rtf
  85. 1 0
      magic/Magdir/sc
  86. 12 1
      magic/Magdir/scientific
  87. 3 0
      magic/Magdir/securitycerts
  88. 13 5
      magic/Magdir/sgi
  89. 29 16
      magic/Magdir/sgml
  90. 4 4
      magic/Magdir/sharc
  91. 1 2
      magic/Magdir/sketch
  92. 8 2
      magic/Magdir/softquad
  93. 8 3
      magic/Magdir/spectrum
  94. 37 23
      magic/Magdir/tex
  95. 21 17
      magic/Magdir/troff
  96. 3 4
      magic/Magdir/unicode
  97. 7 8
      magic/Magdir/uuencode
  98. 6 0
      magic/Magdir/varied.script
  99. 24 2
      magic/Magdir/vorbis
  100. 0 0
      magic/Magdir/wordprocessors

+ 1 - 0
AUTHORS

@@ -0,0 +1 @@
+See COPYING.

+ 1 - 1
LEGAL.NOTICE

@@ -1,4 +1,4 @@
-$File: LEGAL.NOTICE,v 1.15 2006/05/03 18:48:33 christos Exp $
+$File: COPYING,v 1.1 2008/02/05 19:08:11 christos Exp $
 Copyright (c) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992, 1994, 1995.
 Software written by Ian F. Darwin and others;
 maintained 1994- Christos Zoulas.

+ 117 - 71
ChangeLog

@@ -1,4 +1,50 @@
-2007-12-28 15:06 Christos Zoulas <christos@zoulas.com>
+	
+2008-03-27 16:16  Robert Byrnes  <byrnes@wildpumpkin.net>
+
+        * src/readelf.c (donote):
+	  ELF core file command name/line bug fixes and enhancements:
+
+	  Try larger offsets first to avoid false matches
+	  from earlier data that happen to look like strings;
+	  this primarily affected SunOS 5.x 32-bit Intel core files.
+
+	  Add support for command line (instead of just short name)
+	  for SunOS 5.x.
+
+	  Add information about NT_PSINFO for SunOS 5.x.
+
+	  Only trim whitespace from end of command line.
+
+2007-02-11 01:36 Reuben Thomas <rrt@sc3d.org>
+
+	* Change strength of ! from MULT to 0, as it matches almost
+		  anything (Reuben Thomas)
+
+	* Debian fixes (Reuben Thomas)
+
+2007-02-11 00:17 Reuben Thomas <rrt@sc3d.org>
+
+	* Clarify UTF-8 BOM message (Reuben Thomas)
+
+	* Add HTML comment to token list in names.h
+	
+2007-02-04 15:50 Christos Zoulas <christos@astron.com>
+
+	* Debian fixes (Reuben Thomas)
+
+2007-02-04 11:31 Christos Zoulas <christos@astron.com>
+
+	* !:mime annotations in magic files (Reuben Thomas)
+
+2007-01-29 15:35 Christos Zoulas <christos@astron.com>
+
+	* zero out utime/utimes structs (Gavin Atkinson)
+
+2007-01-26 13:45 Christos Zoulas <christos@astron.com>
+
+	* reduce writable data from Diego "Flameeyes" Petten
+
+2007-12-28 15:06 Christos Zoulas <christos@astron.com>
 
 	* strtof detection
 
@@ -6,7 +52,7 @@
 
 	* better mismatch version message
 
-2007-12-27 11:35 Christos Zoulas <christos@zoulas.com>
+2007-12-27 11:35 Christos Zoulas <christos@astron.com>
 
 	* bring back some fixes from OpenBSD
 
@@ -14,46 +60,46 @@
 
 	* fix gcc warnings
 
-2007-12-01 19:55 Christos Zoulas <christos@zoulas.com>
+2007-12-01 19:55 Christos Zoulas <christos@astron.com>
 
 	* make sure we have zlib.h and libz to compile the builtin
 	  decompress code
 
-2007-10-28 20:48 Christos Zoulas <christos@zoulas.com>
+2007-10-28 20:48 Christos Zoulas <christos@astron.com>
 
  	* float and double magic support (Behan Webster) 
 
-2007-10-28 20:48 Christos Zoulas <christos@zoulas.com>
+2007-10-28 20:48 Christos Zoulas <christos@astron.com>
 
 	* Convert fortran to a soft test (Reuben Thomas)
 
-2007-10-23  5:25 Christos Zoulas <christos@zoulas.com>
+2007-10-23  5:25 Christos Zoulas <christos@astron.com>
 
 	* Add --with-filename, and --no-filename (Reuben Thomas)
 
-2007-10-23  3:59 Christos Zoulas <christos@zoulas.com>
+2007-10-23  3:59 Christos Zoulas <christos@astron.com>
 
 	* Rest of the mime split (Reuben Thomas)
 
 	* Make usage message generated from the flags so that
 	  they stay consistent (Reuben Thomas)
 
-2007-10-20  3:06 Christos Zoulas <christos@zoulas.com>
+2007-10-20  3:06 Christos Zoulas <christos@astron.com>
 
 	* typo in comment, missing ifdef QUICK, remove unneeded code
 		(Charles Longeau)
 
-2007-10-17  3:33 Christos Zoulas <christos@zoulas.com>
+2007-10-17  3:33 Christos Zoulas <christos@astron.com>
 
 	* Fix problem printing -\012 in some entries
 
 	* Separate magic type and encoding flags (Reuben Thomas)
 
-2007-10-09  3:55 Christos Zoulas <christos@zoulas.com>
+2007-10-09  3:55 Christos Zoulas <christos@astron.com>
 
 	* configure fix for int64 and strndup (Reuben Thomas)
 
-2007-09-26  4:45 Christos Zoulas <christos@zoulas.com>
+2007-09-26  4:45 Christos Zoulas <christos@astron.com>
 
 	* Add magic_descriptor() function.
 
@@ -62,7 +108,7 @@
 
 	* Don't convert NUL's to spaces in {l,b}estring16 (Daniel Dawson)
 
-2007-08-19  6:30 Christos Zoulas <christos@zoulas.com>
+2007-08-19  6:30 Christos Zoulas <christos@astron.com>
 
 	* Make mime format consistent so that it can
 	  be easily parsed:
@@ -79,38 +125,38 @@
 
 	  This work was done by Reuben Thomas
 
-2007-05-24 10:00 Christos Zoulas <christos@zoulas.com>
+2007-05-24 10:00 Christos Zoulas <christos@astron.com>
 
 	* Fix another integer overflow (Colin Percival)
 
-2007-03-26 13:58 Christos Zoulas <christos@zoulas.com>
+2007-03-26 13:58 Christos Zoulas <christos@astron.com>
 
 	* make sure that all of struct magic_set is initialized appropriately
 	  (Brett)
 
-2007-03-25 17:44 Christos Zoulas <christos@zoulas.com>
+2007-03-25 17:44 Christos Zoulas <christos@astron.com>
 
 	* reset left bytes in the buffer (Dmitry V. Levin)
 
 	* compilation failed with COMPILE_ONLY and ENABLE_CONDITIONALS
 	  (Peter Avalos)
 
-2007-03-15 10:51 Christos Zoulas <christos@zoulas.com>
+2007-03-15 10:51 Christos Zoulas <christos@astron.com>
 
 	* fix fortran and nroff reversed tests (Dmitry V. Levin)
 	
 	* fix exclude option (Dmitry V. Levin)
 
-2007-02-08 17:30 Christos Zoulas <christos@zoulas.com>
+2007-02-08 17:30 Christos Zoulas <christos@astron.com>
 
 	* fix integer underflow in file_printf which can lead to
 	  to exploitable heap overflow (Jean-Sebastien Guay-Lero)
 
-2007-02-05 11:35 Christos Zoulas <christos@zoulas.com>
+2007-02-05 11:35 Christos Zoulas <christos@astron.com>
 
 	* make socket/pipe reading more robust
 
-2007-01-25 16:01 Christos Zoulas <christos@zoulas.com>
+2007-01-25 16:01 Christos Zoulas <christos@astron.com>
 
 	* Centralize all the tests in file_buffer.
 
@@ -184,7 +230,7 @@
 
 	* make file.c compile with gcc warnings and pass lint
 
-2006-12-11 16:49 Christos Zoulas <christos@zoulas.com>
+2006-12-11 16:49 Christos Zoulas <christos@astron.com>
 
 	* fix byteswapping issue
 
@@ -193,7 +239,7 @@
 
 	* add a few missed cases in the strength routine
 
-2006-12-08 16:32 Christos Zoulas <christos@zoulas.com>
+2006-12-08 16:32 Christos Zoulas <christos@astron.com>
 
 	* store and print the line number of the magic
 	  entry for debugging.         
@@ -210,7 +256,7 @@
 	* propagate the error return from match to
 	  file_softmagic.
 
-2006-11-25 13:35 Christos Zoulas <christos@zoulas.com>
+2006-11-25 13:35 Christos Zoulas <christos@astron.com>
 	
 	* Don't store the current offset in the magic
 	  struct, because it needs to be restored and
@@ -221,12 +267,12 @@
 	  print it as an additional separator; print
 	  it as the only separator.
 
-2006-11-17 10:51 Christos Zoulas <christos@zoulas.com>
+2006-11-17 10:51 Christos Zoulas <christos@astron.com>
 
 	* Added a -0 option to print a '\0' separator
 	  Etienne Buira <etienne.buira@free.fr>
 
-2006-10-31 15:14 Christos Zoulas <christos@zoulas.com>
+2006-10-31 15:14 Christos Zoulas <christos@astron.com>
 
 	* Check offset before copying (Mike Frysinger)
 
@@ -242,7 +288,7 @@
 
 	* use calloc to initialize the ascii buffers (Jos van den Oever)
 
-2006-06-08 11:11 Christos Zoulas <christos@zoulas.com>
+2006-06-08 11:11 Christos Zoulas <christos@astron.com>
 
 	* QNX fixes (Mike Gorchak)
 
@@ -256,7 +302,7 @@
 
 	* Magic format function improvent (Karl Chen)
 
-2006-05-03 11:11 Christos Zoulas <christos@zoulas.com>
+2006-05-03 11:11 Christos Zoulas <christos@astron.com>
 
 	* Pick up some elf changes and some constant fixes from SUSE
 
@@ -264,13 +310,13 @@
 
 	* When keep going, don't print spurious newlines (Radek Vokál)
 
-2006-04-01 12:02 Christos Zoulas <christos@zoulas.com>
+2006-04-01 12:02 Christos Zoulas <christos@astron.com>
 
 	* Use calloc instead of malloc (Mike Frysinger)
 
 	* Fix configure script to detect wctypes.h (Mike Frysinger)
 
-2006-03-02 16:06 Christos Zoulas <christos@zoulas.com>
+2006-03-02 16:06 Christos Zoulas <christos@astron.com>
 
 	* Print empty if the file is (Mike Frysinger)
 
@@ -278,21 +324,21 @@
 
 	* Sort magic entries by strength [experimental]
 
-2005-11-29 13:26 Christos Zoulas <christos@zoulas.com>
+2005-11-29 13:26 Christos Zoulas <christos@astron.com>
 
 	* Use iswprint() to convert the output string.
 	    (Bastien Nocera)
 
-2005-10-31 8:54 Christos Zoulas <christos@zoulas.com>
+2005-10-31 8:54 Christos Zoulas <christos@astron.com>
 
 	* Fix regression where the core info was not completely processed
 	    (Radek Vokál)
 
-2005-10-20 11:15 Christos Zoulas <christos@zoulas.com>
+2005-10-20 11:15 Christos Zoulas <christos@astron.com>
 
 	* Middle Endian magic (Diomidis Spinellis)
 
-2005-10-17 11:15 Christos Zoulas <christos@zoulas.com>
+2005-10-17 11:15 Christos Zoulas <christos@astron.com>
 
 	* Open with O_BINARY for CYGWIN (Corinna Vinschen)
 
@@ -300,39 +346,39 @@
 
 	* Look for note sections in non executables.
 
-2005-09-20 13:33 Christos Zoulas <christos@zoulas.com>
+2005-09-20 13:33 Christos Zoulas <christos@astron.com>
 	
 	* Don't print SVR4 Style in core files multiple times
 	    (Radek Vokál)
 
-2005-08-27 04:09 Christos Zoulas <christos@zoulas.com>
+2005-08-27 04:09 Christos Zoulas <christos@astron.com>
 
 	* Cygwin changes Corinna Vinschen
 
-2005-08-18 09:53 Christos Zoulas <christos@zoulas.com>
+2005-08-18 09:53 Christos Zoulas <christos@astron.com>
 
 	* Remove erroreous mention of /etc/magic in the file man page
 	  This is gentoo bug 101639. (Mike Frysinger) 
 
 	* Cross-compile support and detection (Mike Frysinger) 
 
-2005-08-12 10:17 Christos Zoulas <christos@zoulas.com>
+2005-08-12 10:17 Christos Zoulas <christos@astron.com>
 
 	* Add -h flag and dereference symlinks if POSIXLY_CORRECT
 	  is set.
 
-2005-07-29 13:57 Christos Zoulas <christos@zoulas.com>
+2005-07-29 13:57 Christos Zoulas <christos@astron.com>
 
 	* Avoid search and regex buffer overflows (Kelledin)
 
-2005-07-12 11:48 Christos Zoulas <christos@zoulas.com>
+2005-07-12 11:48 Christos Zoulas <christos@astron.com>
 
 	* Provide stub implementations for {v,}nsprintf() for older
 	  OS's that don't have them.
 	* Change mbstate_t autoconf detection macro from AC_MBSTATE_T
 	  to AC_TYPE_MBSTATE_T.
 
-2005-06-25 11:48 Christos Zoulas <christos@zoulas.com>
+2005-06-25 11:48 Christos Zoulas <christos@astron.com>
 
 	* Dynamically allocate the string buffers and make the
 	  default read size 256K.
@@ -361,43 +407,43 @@
           With CRLF, the line length was not computed correctly, and even
           lines of length MAXLINELEN - 1 were treated as ``very long''.
 
-2004-12-07 14:15  Christos Zoulas  <christos@zoulas.com>
+2004-12-07 14:15  Christos Zoulas  <christos@astron.com>
 
 	* bzip2 needs a lot of input buffer space on some files
 	  before it can begin uncompressing. This makes file -z
 	  fail on some bz2 files. Fix it by giving it a copy of
 	  the file descriptor to read as much as it wants if we
-	  have access to it. <christos@zoulas.com>
+	  have access to it. <christos@astron.com>
 
-2004-11-24 12:39  Christos Zoulas  <christos@zoulas.com>
+2004-11-24 12:39  Christos Zoulas  <christos@astron.com>
 
 	* Stack smash fix, and ELF more conservative reading.
 	  Jakub Bogusz <qboosh@pld-linux.org>
 
-2004-11-20 18:50  Christos Zoulas  <christos@zoulas.com>
+2004-11-20 18:50  Christos Zoulas  <christos@astron.com>
 
 	* New FreeBSD version parsing code:
 	  Jon Noack <noackjr@alumni.rice.edu>
 
-	* Hackish support for ucs16 strings <christos@zoulas.com>
+	* Hackish support for ucs16 strings <christos@astron.com>
 
-2004-11-13 03:07  Christos Zoulas  <christos@zoulas.com>
+2004-11-13 03:07  Christos Zoulas  <christos@astron.com>
 
 	* print the file name and line number in syntax errors.
 
-2004 10-12 10:50  Christos Zoulas  <christos@zoulas.com>
+2004 10-12 10:50  Christos Zoulas  <christos@astron.com>
 
 	* Fix stack overwriting on 0 length strings: Tim Waugh
 	    <twaugh@redhat.com> Ned Ludd <solar@gentoo.org>
 
-2004-09-27 11:30  Christos Zoulas  <christos@zoulas.com>
+2004-09-27 11:30  Christos Zoulas  <christos@astron.com>
 
 	* Remove 3rd and 4th copyright clause; approved by Ian Darwin.
 
 	* Fix small memory leaks; caught by: Tamas Sarlos 
 	    <stamas@csillag.ilab.sztaki.hu>
 
-2004-07-24 16:33  Christos Zoulas  <christos@zoulas.com>
+2004-07-24 16:33  Christos Zoulas  <christos@astron.com>
 
 	* magic.mime update Danny Milosavljevic <danny.milo@gmx.net> 
 
@@ -407,19 +453,19 @@
 
   	* errors reading elf magic Jakub Bogusz <qboosh@pld-linux.org>
 
-2004-04-12 10:55  Christos Zoulas  <christos@zoulas.com>
+2004-04-12 10:55  Christos Zoulas  <christos@astron.com>
 
 	* make sure that magic formats match magic types during compilation
 
 	* fix broken sgi magic file
 
-2004-04-06 20:36  Christos Zoulas  <christos@zoulas.com>
+2004-04-06 20:36  Christos Zoulas  <christos@astron.com>
 
 	* detect present of mbstate_t Petter Reinholdtsen <pere@hungry.com>
 
 	* magic fixes
 
-2004-03-22 15:25  Christos Zoulas  <christos@zoulas.com>
+2004-03-22 15:25  Christos Zoulas  <christos@astron.com>
 
 	* Lots of mime fixes
 	  (Joerg Ostertag) <ostertag@rechengilde.de>
@@ -428,7 +474,7 @@
 	  (Edwin Groothuis) <edwin@mavetju.org>
 
 	* correct cleanup in all cases; don't just close the file.
-	  (Christos Zoulas) <christos@zoulas.com>
+	  (Christos Zoulas) <christos@astron.com>
 
 	* add gettext message catalogue support
 	  (Michael Piefel) <piefel@debian.org>
@@ -446,37 +492,37 @@
 	  or name and description note sizes. Reported by
 	  (Mikael Magnusson) <mmikael@comhem.se>
 
-2004-03-09 13:55  Christos Zoulas  <christos@zoulas.com>
+2004-03-09 13:55  Christos Zoulas  <christos@astron.com>
 
 	* Fix possible memory leak on error and add missing regfree
 	  (Dmitry V. Levin) <ldv@altlinux.org>
 
-2003-12-23 12:12  Christos Zoulas  <christos@zoulas.com>
+2003-12-23 12:12  Christos Zoulas  <christos@astron.com>
 
 	* fix -k flag (Maciej W. Rozycki)
 
-2003-11-18 14:10  Christos Zoulas  <christos@zoulas.com>
+2003-11-18 14:10  Christos Zoulas  <christos@astron.com>
 
 	* Try to give us much info as possible on corrupt elf files.
 	  (Willy Tarreau) <willy@w.ods.org>
 	* Updated python bindings (Brett Funderburg)
 	   <brettf@deepfile.com>
 
-2003-11-11 15:03  Christos Zoulas  <christos@zoulas.com>
+2003-11-11 15:03  Christos Zoulas  <christos@astron.com>
 
 	* Include file.h first, because it includes config.h
 	  breaks largefile test macros otherwise.
 	  (Paul Eggert <eggert@CS.UCLA.EDU> via
 	   Lars Hecking <lhecking@nmrc.ie>)
 
-2003-10-14 21:39  Christos Zoulas  <christos@zoulas.com>
+2003-10-14 21:39  Christos Zoulas  <christos@astron.com>
 
 	* Python bindings (Brett Funderburg) <brettf@deepfile.com>
 	* Don't lookup past the end of the buffer
 	  (Chad Hanson) <chanson@tcs-sec.com>
 	* Add MAGIC_ERROR and api on magic_errno()
 
-2003-10-08 12:40  Christos Zoulas  <christos@zoulas.com>
+2003-10-08 12:40  Christos Zoulas  <christos@astron.com>
 
 	* handle error conditions from compile as fatal
 	  (Antti Kantee) <pooka@netbsd.org>
@@ -486,32 +532,32 @@
 	* describe magic file handling
 	  (Bryan Henderson) <bryanh@giraffe-data.com>
 
-2003-09-12 15:09  Christos Zoulas  <christos@zoulas.com>
+2003-09-12 15:09  Christos Zoulas  <christos@astron.com>
 
 	* update magic files.
 	* remove largefile support from file.h; it breaks things on most OS's
 
-2003-08-10 10:25  Christos Zoulas  <christos@zoulas.com>
+2003-08-10 10:25  Christos Zoulas  <christos@astron.com>
 
 	* fix unmapping'ing of mmaped files.
 
-2003-07-10 12:03  Christos Zoulas  <christos@zoulas.com>
+2003-07-10 12:03  Christos Zoulas  <christos@astron.com>
 
 	* don't exit with -1 on error; always exit 1 (Marty Leisner)
 	* restore utimes code.
 
-2003-06-10 17:03  Christos Zoulas  <christos@zoulas.com>
+2003-06-10 17:03  Christos Zoulas  <christos@astron.com>
 
 	* make sure we don't access uninitialized memory.
 	* pass lint
 	* #ifdef __cplusplus in magic.h
 
-2003-05-25 19:23  Christos Zoulas  <christos@zoulas.com>
+2003-05-25 19:23  Christos Zoulas  <christos@astron.com>
 
 	* rename cvs magic file to revision to deal with
 	  case insensitive filesystems.
 
-2003-05-23 17:03  Christos Zoulas  <christos@zoulas.com>
+2003-05-23 17:03  Christos Zoulas  <christos@astron.com>
 
 	* documentation fixes from Michael Piefel <piefel@debian.org>
 	* magic fixes (various)
@@ -521,30 +567,30 @@
 	  close files
 	  Maciej W. Rozycki <macro@ds2.pg.gda.pl
 
-2003-04-21 20:12  Christos Zoulas  <christos@zoulas.com>
+2003-04-21 20:12  Christos Zoulas  <christos@astron.com>
 
 	* fix zsh magic
 
-2003-04-04 16:59  Christos Zoulas  <christos@zoulas.com>
+2003-04-04 16:59  Christos Zoulas  <christos@astron.com>
 
 	* fix operand sort order in string.
 
-2003-04-02 17:30  Christos Zoulas  <christos@zoulas.com>
+2003-04-02 17:30  Christos Zoulas  <christos@astron.com>
 
 	* cleanup namespace in magic.h
 
-2003-04-02 13:50  Christos Zoulas  <christos@zoulas.com>
+2003-04-02 13:50  Christos Zoulas  <christos@astron.com>
 
 	* Magic additions (Alex Ott)
 	* Fix bug that broke VPATH compilation (Peter Breitenlohner)
 
-2003-03-28 16:03  Christos Zoulas  <christos@zoulas.com>
+2003-03-28 16:03  Christos Zoulas  <christos@astron.com>
 
 	* remove packed attribute from magic struct.
 	* make the magic struct properly aligned.
 	* bump version number of compiled files to 2.
 
-2003-03-27 13:10  Christos Zoulas  <christos@zoulas.com>
+2003-03-27 13:10  Christos Zoulas  <christos@astron.com>
 
 	* separate tar detection and run it before softmagic.
 	* fix reversed symlink test.
@@ -552,7 +598,7 @@
 	* make separator a string instead of a char.
 	* update manual page and sort options.
 
-2003-03-26 11:00  Christos Zoulas  <christos@zoulas.com>
+2003-03-26 11:00  Christos Zoulas  <christos@astron.com>
 
 	* Pass lint
 	* make NULL in magic_file mean stdin

+ 234 - 0
INSTALL

@@ -0,0 +1,234 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+

+ 2 - 3
MAINT

@@ -1,4 +1,4 @@
-$File: MAINT,v 1.9 2007/01/19 21:15:27 christos Exp $
+$File: MAINT,v 1.10 2008/02/05 19:08:11 christos Exp $
 
 Maintenance notes:
 
@@ -41,5 +41,4 @@ ascmagic.c			file_ascmagic()
 readelf.c		file_tryelf()
 				"unknown"
 
-Christos Zoulas
-christos@astron.com
+Christos Zoulas (see README for email address)

+ 2 - 5
Makefile.am

@@ -1,6 +1,3 @@
-# don't enforce GNU packaging standards
-AUTOMAKE_OPTIONS = foreign no-dependencies
+EXTRA_DIST = MAINT
 
-EXTRA_DIST = LEGAL.NOTICE MAINT PORTING
-
-SUBDIRS = src magic doc python
+SUBDIRS = src magic tests doc python

+ 14 - 20
Makefile.in

@@ -34,20 +34,18 @@ host_triplet = @host@
 subdir = .
 DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
-	$(top_srcdir)/configure ChangeLog config.guess config.sub \
-	depcomp install-sh ltmain.sh missing mkinstalldirs
+	$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
+	config.guess config.sub depcomp install-sh ltmain.sh missing
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
  configure.lineno config.status.lineno
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES =
-depcomp =
-am__depfiles_maybe =
 SOURCES =
 DIST_SOURCES =
 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -112,7 +110,6 @@ LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 OBJEXT = @OBJEXT@
@@ -180,30 +177,27 @@ sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-
-# don't enforce GNU packaging standards
-AUTOMAKE_OPTIONS = foreign no-dependencies
-EXTRA_DIST = LEGAL.NOTICE MAINT PORTING
-SUBDIRS = src magic doc python
+EXTRA_DIST = MAINT
+SUBDIRS = src magic tests doc python
 all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
 .SUFFIXES:
 am--refresh:
 	@:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
-	      cd $(srcdir) && $(AUTOMAKE) --foreign  \
+	      echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
+	      cd $(srcdir) && $(AUTOMAKE) --gnu  \
 		&& exit 0; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  Makefile'; \
 	cd $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign  Makefile
+	  $(AUTOMAKE) --gnu  Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -218,9 +212,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	$(SHELL) ./config.status --recheck
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(srcdir) && $(AUTOCONF)
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
 
 config.h: stamp-h1
@@ -232,7 +226,7 @@ config.h: stamp-h1
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
 	@rm -f stamp-h1
 	cd $(top_builddir) && $(SHELL) ./config.status config.h
-$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
+$(srcdir)/config.h.in:  $(am__configure_deps) 
 	cd $(top_srcdir) && $(AUTOHEADER)
 	rm -f stamp-h1
 	touch $@

+ 1 - 0
NEWS

@@ -0,0 +1 @@
+See ChangeLog.

+ 0 - 0
PORTING


+ 10 - 5
README

@@ -1,5 +1,10 @@
 ** README for file(1) Command **
-@(#) $File: README,v 1.34 2006/05/03 18:48:33 christos Exp $
+@(#) $File: README,v 1.39 2008/02/14 20:22:20 christos Exp $
+
+E-mail: christos@astron.com
+Mailing List: file@mx.gw.com
+
+Phone: Do not even think of telephoning me about this program. Send cash first!
 
 This is Release 4.x of Ian Darwin's (copyright but distributable)
 file(1) command. This version is the standard "file" command for Linux,
@@ -71,6 +76,10 @@ readelf.[ch] - Stand-alone elf parsing code.
 compress.c - on-the-fly decompression.
 print.c - print results, errors, warnings.
 
+You can download the latest version of file from:
+
+	ftp://ftp.astron.com/pub/file/
+
 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
@@ -85,10 +94,6 @@ file, apply this patch [which is going to be in the next version of gzip]:
       }
       bytes_in += (ulg)insize;
 
-E-mail: christos@astron.com
-
-Phone: Do not even think of telephoning me about this program. Send cash first!
-
 Parts of this software were developed at SoftQuad Inc., developers
 of SGML/HTML/XML publishing software, in Toronto, Canada.
 SoftQuad was swallowed up by Corel in 2002

+ 2 - 238
acinclude.m4

@@ -1,19 +1,3 @@
-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 acspecific.m4, with changes to check for daylight
 
 AC_DEFUN([AC_STRUCT_TIMEZONE_DAYLIGHT],
@@ -43,7 +27,7 @@ AC_CACHE_CHECK([for tm_isdst in struct tm], ac_cv_struct_tm_isdst,
 #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_isdst;],
   ac_cv_struct_tm_isdst=yes, ac_cv_struct_tm_isdst=no)])
 if test "$ac_cv_struct_tm_isdst" = yes; then
-  AC_DEFINE(HAVE_TM_ISDST)
+  AC_DEFINE(HAVE_TM_ISDST,1,[HAVE_TM_ISDST])
 fi
 AC_CACHE_CHECK(for daylight, ac_cv_var_daylight,
 [AC_TRY_LINK(
@@ -55,226 +39,6 @@ extern int daylight;
 changequote([, ])dnl
 [atoi(daylight);], ac_cv_var_daylight=yes, ac_cv_var_daylight=no)])
   if test $ac_cv_var_daylight = yes; then
-    AC_DEFINE(HAVE_DAYLIGHT)
+    AC_DEFINE(HAVE_DAYLIGHT,1,[HAVE_DAYLIGHT])
   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
-dnl now include <stdint.h> if available
-
-dnl AC_CHECK_TYPE2_STDC(TYPE, DEFAULT)
-AC_DEFUN([AC_CHECK_TYPE2_STDC],
-[AC_REQUIRE([AC_HEADER_STDC])dnl
-AC_REQUIRE([AC_HEADER_STDINT])dnl
-AC_MSG_CHECKING(for $1)
-AC_CACHE_VAL(ac_cv_type_$1,
-[AC_EGREP_CPP(dnl
-[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]],
-[#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif], 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],
-[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
-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_REQUIRE([AC_HEADER_STDC])dnl
-AC_REQUIRE([AC_HEADER_STDINT])dnl
-AC_CHECK_SIZEOF_INCLUDES($1, $2,
-[#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#endif
-])
-])
-
-
-dnl AC_CHECK_TYPE_STDC(TYPE, DEFAULT)
-AC_DEFUN([AC_CHECK_TYPE_STDC],
-[AC_REQUIRE([AC_HEADER_STDC])dnl
-AC_REQUIRE([AC_HEADER_STDINT])dnl
-AC_MSG_CHECKING(for $1)
-AC_CACHE_VAL(ac_cv_type_$1,
-[AC_EGREP_CPP(dnl
-[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]],
-[#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
-AC_MSG_RESULT($ac_cv_type_$1)
-if test $ac_cv_type_$1 = no; then
-  AC_DEFINE($1, $2)
-fi
-])
-
-dnl AC_HEADER_STDINT
-AC_DEFUN([AC_HEADER_STDINT], [AC_CHECK_HEADERS(stdint.h)])
-
-dnl By default, many hosts won't let programs access large files;
-dnl one must use special compiler options to get large-file access to work.
-dnl For more details about this brain damage please see:
-dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
-
-dnl Written by Paul Eggert <eggert@twinsun.com>.
-
-dnl Internal subroutine of AC_SYS_LARGEFILE.
-dnl AC_SYS_LARGEFILE_TEST_INCLUDES
-AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES],
-  [[#include <sys/types.h>
-    /* Check that off_t can represent 2**63 - 1 correctly.
-       We can't simply "#define LARGE_OFF_T 9223372036854775807",
-       since some C++ compilers masquerading as C compilers
-       incorrectly reject 9223372036854775807.  */
-#   define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
-    int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
-			&& LARGE_OFF_T % 2147483647 == 1)
-		       ? 1 : -1];
-  ]])
-
-dnl Internal subroutine of AC_SYS_LARGEFILE.
-dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLU=
-DES, FUNCTION-BODY)
-AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE],
-  [AC_CACHE_CHECK([for $1 value needed for large files], $3,
-     [$3=no
-      AC_TRY_COMPILE([$5],
-	[$6],
-	,
-	[AC_TRY_COMPILE([#define $1 $2]
-[$5]
-	   ,
-	   [$6],
-	   [$3=$2])])])
-   if test "[$]$3" != no; then
-     AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
-   fi])
-
-AC_DEFUN([AC_SYS_LARGEFILE],
-  [AC_REQUIRE([AC_PROG_CC])
-   AC_ARG_ENABLE(largefile,
-     [  --disable-largefile     omit support for large files])
-   if test "$enable_largefile" != no; then
-
-     AC_CACHE_CHECK([for special C compiler options needed for large files=
-],
-       ac_cv_sys_largefile_CC,
-       [ac_cv_sys_largefile_CC=no
-        if test "$GCC" != yes; then
-	  # IRIX 6.2 and later do not support large files by default,
-	  # so use the C compiler's -n32 option if that helps.
-	  AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
-	    [ac_save_CC="$CC"
-	     CC="$CC -n32"
-	     AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
-	       ac_cv_sys_largefile_CC=' -n32')
-	     CC="$ac_save_CC"])
-        fi])
-     if test "$ac_cv_sys_largefile_CC" != no; then
-       CC="$CC$ac_cv_sys_largefile_CC"
-     fi
-
-     AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
-       ac_cv_sys_file_offset_bits,
-       [Number of bits in a file offset, on hosts where this is settable.],
-       AC_SYS_LARGEFILE_TEST_INCLUDES)
-     AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
-       ac_cv_sys_large_files,
-       [Define for large files, on AIX-style hosts.],
-       AC_SYS_LARGEFILE_TEST_INCLUDES)
-   fi
-  ])
-
-AC_DEFUN([AC_FUNC_FSEEKO],
-  [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
-     ac_cv_sys_largefile_source,
-     [Define to make fseeko visible on some hosts (e.g. glibc 2.2).],
-     [#include <stdio.h>], [return !fseeko;])
-   # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
-   # in glibc 2.1.3, but that breaks too many other things.
-   # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
-
-   AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
-     [ac_cv_func_fseeko=no
-      AC_TRY_LINK([#include <stdio.h>],
-        [return fseeko && fseeko (stdin, 0, 0);],
-	[ac_cv_func_fseeko=yes])])
-   if test $ac_cv_func_fseeko != no; then
-     AC_DEFINE(HAVE_FSEEKO, 1,
-       [Define if fseeko (and presumably ftello) exists and is declared.])
-   fi])
-
-# From Paul Eggert.
-
-# BeOS 5 has <wchar.h> but does not define mbstate_t,
-# so you can't declare an object of that type.
-# Check for this incompatibility with Standard C.
-
-# Include stdlib.h first, because otherwise this test would fail on Linux
-# (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits
-# a syntax error in wchar.h due to the use of undefined __int32_t.
-AC_DEFUN([AC_MBSTATE_T],
-  [
-   AC_CHECK_HEADERS(stdlib.h)
-  
-   AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
-    [AC_TRY_COMPILE([
-#if HAVE_STDLIB_H 
-# include <stdlib.h>
-#endif
-#include <wchar.h>],
-      [mbstate_t x; return sizeof x;],
-      ac_cv_type_mbstate_t=yes,
-      ac_cv_type_mbstate_t=no)])
-   if test $ac_cv_type_mbstate_t = no; then
-     AC_DEFINE(mbstate_t, int,
-               [Define to a type if <wchar.h> does not define.])
-   fi])
-
-

+ 0 - 29
aclocal.m4

@@ -6685,35 +6685,6 @@ fi
 rmdir .tst 2>/dev/null
 AC_SUBST([am__leading_dot])])
 
-# Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
-# From Jim Meyering
-
-# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 4
-
-AC_DEFUN([AM_MAINTAINER_MODE],
-[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
-  dnl maintainer-mode is disabled by default
-  AC_ARG_ENABLE(maintainer-mode,
-[  --enable-maintainer-mode  enable make rules and dependencies not useful
-			  (and sometimes confusing) to the casual installer],
-      USE_MAINTAINER_MODE=$enableval,
-      USE_MAINTAINER_MODE=no)
-  AC_MSG_RESULT([$USE_MAINTAINER_MODE])
-  AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
-  MAINT=$MAINTAINER_MODE_TRUE
-  AC_SUBST(MAINT)dnl
-]
-)
-
-AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
-
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
 # Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.

+ 61 - 48
config.h.in

@@ -1,12 +1,15 @@
-/* config.h.in.  Generated from configure.in by autoheader.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
 
-/* Use the builtin ELF recognition code */
+/* Define in built-in ELF support is used */
 #undef BUILTIN_ELF
 
-/* Recognize ELF core files */
+/* Define for ELF core file support */
 #undef ELFCORE
 
-/* */
+/* Define to 1 if you have the `asprintf' function. */
+#undef HAVE_ASPRINTF
+
+/* HAVE_DAYLIGHT */
 #undef HAVE_DAYLIGHT
 
 /* Define to 1 if you have the <dlfcn.h> header file. */
@@ -15,12 +18,18 @@
 /* Define to 1 if you have the <fcntl.h> header file. */
 #undef HAVE_FCNTL_H
 
-/* Define to 1 if you have the <getopt.h> header file. */
-#undef HAVE_GETOPT_H
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#undef HAVE_FSEEKO
 
 /* Define to 1 if you have the `getopt_long' function. */
 #undef HAVE_GETOPT_LONG
 
+/* Define to 1 if the system has the type `int32_t'. */
+#undef HAVE_INT32_T
+
+/* Define to 1 if the system has the type `int64_t'. */
+#undef HAVE_INT64_T
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -33,9 +42,6 @@
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
-/* */
-#undef HAVE_LONG_LONG
-
 /* Define to 1 if you have the `mbrtowc' function. */
 #undef HAVE_MBRTOWC
 
@@ -51,9 +57,6 @@
 /* Define to 1 if you have the `mmap' function. */
 #undef HAVE_MMAP
 
-/* Define to 1 if you have the `snprintf' function. */
-#undef HAVE_SNPRINTF
-
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
@@ -81,10 +84,6 @@
 /* Define to 1 if `st_rdev' is member of `struct stat'. */
 #undef HAVE_STRUCT_STAT_ST_RDEV
 
-/* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use
-   `HAVE_STRUCT_STAT_ST_RDEV' instead. */
-#undef HAVE_ST_RDEV
-
 /* Define to 1 if you have the <sys/mman.h> header file. */
 #undef HAVE_SYS_MMAN_H
 
@@ -103,7 +102,7 @@
 /* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
 #undef HAVE_SYS_WAIT_H
 
-/* */
+/* HAVE_TM_ISDST */
 #undef HAVE_TM_ISDST
 
 /* HAVE_TM_ZONE */
@@ -112,6 +111,18 @@
 /* HAVE_TZNAME */
 #undef HAVE_TZNAME
 
+/* Define to 1 if the system has the type `uint16_t'. */
+#undef HAVE_UINT16_T
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#undef HAVE_UINT32_T
+
+/* Define to 1 if the system has the type `uint64_t'. */
+#undef HAVE_UINT64_T
+
+/* Define to 1 if the system has the type `uint8_t'. */
+#undef HAVE_UINT8_T
+
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
@@ -124,8 +135,8 @@
 /* Define to 1 if you have the <utime.h> header file. */
 #undef HAVE_UTIME_H
 
-/* Define to 1 if you have the `vsnprintf' function. */
-#undef HAVE_VSNPRINTF
+/* Define to 1 if you have the `vasprintf' function. */
+#undef HAVE_VASPRINTF
 
 /* Define to 1 if you have the <wchar.h> header file. */
 #undef HAVE_WCHAR_H
@@ -165,20 +176,8 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
-/* */
-#undef SIZEOF_INT64_T
-
-/* */
-#undef SIZEOF_UINT16_T
-
-/* */
-#undef SIZEOF_UINT32_T
-
-/* */
-#undef SIZEOF_UINT64_T
-
-/* */
-#undef SIZEOF_UINT8_T
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
 
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
@@ -197,18 +196,15 @@
 # undef _GNU_SOURCE
 #endif
 
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+#undef _LARGEFILE_SOURCE
+
 /* Define for large files, on AIX-style hosts. */
 #undef _LARGE_FILES
 
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
-/* */
-#undef int32_t
-
-/* */
-#undef int64_t
-
 /* Define to a type if <wchar.h> does not define. */
 #undef mbstate_t
 
@@ -218,14 +214,31 @@
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
 
-/* */
-#undef uint16_t
 
-/* */
-#undef uint32_t
-
-/* */
-#undef uint64_t
+#ifndef HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+#ifndef HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+#ifndef HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+#ifndef HAVE_INT32_T
+typedef int int32_t;
+#endif
+#ifndef HAVE_UINT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+#endif
+#ifndef HAVE_INT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef long long int64_t;
+#else
+typedef long int64_t;
+#endif
+#endif
 
-/* */
-#undef uint8_t

File diff suppressed because it is too large
+ 940 - 797
configure


+ 122 - 0
configure.ac

@@ -0,0 +1,122 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(file, 4.24, christos@astron.com)
+AM_INIT_AUTOMAKE
+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], 1, [Define if built-in ELF support is used])
+else
+  AC_MSG_RESULT(no)
+fi], [
+  # enable by default
+  AC_MSG_RESULT(yes)
+  AC_DEFINE([BUILTIN_ELF], 1, [Define in built-in ELF support is used])
+])
+
+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], 1, [Define for ELF core file support])
+else
+  AC_MSG_RESULT(no)
+fi], [
+  # enable by default
+  AC_MSG_RESULT(yes)
+  AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
+])
+
+AC_MSG_CHECKING(for file formats in man section 5)
+AC_ARG_ENABLE(fsect-man5,
+[  --enable-fsect-man5      enable file formats in man section 5],
+[if test "${enableval}" = yes; then
+  AC_MSG_RESULT(yes)
+  fsect=5
+else
+  AC_MSG_RESULT(no)
+  fsect=4
+fi], [
+  # disable by default
+  AC_MSG_RESULT(no)
+  fsect=4
+])
+AC_SUBST(fsect)
+AM_CONDITIONAL(FSECT5, test x$fsect = x5)
+AC_GNU_SOURCE
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_LIBTOOL
+
+dnl Checks for headers
+AC_HEADER_STDC
+AC_HEADER_MAJOR
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h)
+AC_CHECK_HEADERS(utime.h wchar.h wctype.h limits.h)
+AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
+AC_CHECK_HEADERS(zlib.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+AC_CHECK_MEMBERS([struct stat.st_rdev])
+
+AC_STRUCT_TIMEZONE_DAYLIGHT
+AC_SYS_LARGEFILE
+AC_FUNC_FSEEKO
+AC_TYPE_MBSTATE_T
+
+AC_CHECK_TYPES([uint8_t, uint16_t, uint32_t, int32_t, uint64_t, int64_t])
+AC_CHECK_SIZEOF(long long)
+AH_BOTTOM([
+#ifndef HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+#ifndef HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+#ifndef HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+#ifndef HAVE_INT32_T
+typedef int int32_t;
+#endif
+#ifndef HAVE_UINT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+#endif
+#ifndef HAVE_INT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef long long int64_t;
+#else
+typedef long int64_t;
+#endif
+#endif
+])
+
+dnl Checks for functions
+AC_CHECK_FUNCS(mmap strerror strndup strtoul mbrtowc mkstemp utimes utime wcwidth strtof)
+
+dnl Provide implementation of some required functions if necessary
+AC_REPLACE_FUNCS(getopt_long asprintf vasprintf)
+
+dnl Checks for libraries
+AC_CHECK_LIB(z,gzopen)
+
+dnl See if we are cross-compiling
+AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
+
+AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile])
+AC_OUTPUT

+ 0 - 139
configure.in

@@ -1,139 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT
-AC_CONFIG_SRCDIR([src/file.c])
-AM_INIT_AUTOMAKE(file, 4.23)
-AM_CONFIG_HEADER([config.h])
-AM_MAINTAINER_MODE
-
-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)
-])
-
-AC_MSG_CHECKING(for file formats in man section 5)
-AC_ARG_ENABLE(fsect-man5,
-[  --enable-fsect-man5      enable file formats in man section 5],
-[if test "${enableval}" = yes; then
-  AC_MSG_RESULT(yes)
-  fsect=5
-else
-  AC_MSG_RESULT(no)
-  fsect=4
-fi], [
-  # disable by default
-  AC_MSG_RESULT(no)
-  fsect=4
-])
-AC_SUBST(fsect)
-AM_CONDITIONAL(FSECT5, test x$fsect = x5)
-AC_GNU_SOURCE
-
-dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_INSTALL
-AC_PROG_LN_S
-AC_PROG_LIBTOOL
-
-dnl Templates for autoheader
-AH_TEMPLATE([BUILTIN_ELF],
-	    [Use the builtin ELF recognition code])
-AH_TEMPLATE([ELFCORE],
-	    [Recognize ELF core files])
-AH_TEMPLATE([HAVE_DAYLIGHT], [])
-AH_TEMPLATE([HAVE_LONG_LONG], [])
-AH_TEMPLATE([HAVE_TM_ISDST], [])
-AH_TEMPLATE([SIZEOF_UINT16_T], [])
-AH_TEMPLATE([SIZEOF_UINT32_T], [])
-AH_TEMPLATE([SIZEOF_INT64_T], [])
-AH_TEMPLATE([SIZEOF_UINT64_T], [])
-AH_TEMPLATE([SIZEOF_UINT8_T], [])
-AH_TEMPLATE([int32_t], [])
-AH_TEMPLATE([uint16_t], [])
-AH_TEMPLATE([uint32_t], [])
-AH_TEMPLATE([int64_t], [])
-AH_TEMPLATE([uint64_t], [])
-AH_TEMPLATE([uint8_t], [])
-
-dnl Checks for headers
-AC_HEADER_STDC
-AC_HEADER_MAJOR
-AC_HEADER_SYS_WAIT
-AC_HEADER_STDINT
-AC_CHECK_HEADERS(fcntl.h locale.h stdint.h inttypes.h unistd.h getopt.h)
-AC_CHECK_HEADERS(utime.h wchar.h wctype.h limits.h)
-AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
-AC_CHECK_HEADERS(zlib.h)
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_TYPE_OFF_T
-AC_TYPE_SIZE_T
-AC_DIAGNOSE([obsolete],[AC_STRUCT_ST_RDEV:
-	your code should no longer depend upon `HAVE_ST_RDEV', but
-	`HAVE_STRUCT_STAT_ST_RDEV'.  Remove this warning and
-	the `AC_DEFINE' when you adjust the code.])
-AC_CHECK_MEMBERS([struct stat.st_rdev],[AC_DEFINE(HAVE_ST_RDEV, 1,
-			    [Define to 1 if your `struct stat' has `st_rdev'.
-			     Deprecated, use `HAVE_STRUCT_STAT_ST_RDEV'
-			     instead.])])
-
-AC_STRUCT_TIMEZONE_DAYLIGHT
-AC_SYS_LARGEFILE
-AC_TYPE_MBSTATE_T
-
-AC_CHECK_TYPE_STDC(uint8_t, unsigned char)
-AC_CHECK_TYPE_STDC(uint16_t, unsigned short)
-AC_CHECK_TYPE_STDC(uint32_t, unsigned int)
-AC_CHECK_TYPE_STDC(int32_t, int)
-AC_C_LONG_LONG
-if test $ac_cv_c_long_long = yes; then
-  ulong64='unsigned long long';
-  long64='long long';
-else
-  ulong64='unsigned long';
-  long64='long';
-fi
-dnl This needs a patch to autoconf 2.13 acgeneral.m4
-AC_CHECK_TYPE2_STDC(uint64_t, $ulong64)
-AC_CHECK_TYPE2_STDC(int64_t, $long64)
-
-AC_CHECK_SIZEOF_STDC_HEADERS(uint8_t, 0)
-AC_CHECK_SIZEOF_STDC_HEADERS(uint16_t, 0)
-AC_CHECK_SIZEOF_STDC_HEADERS(uint32_t, 0)
-AC_CHECK_SIZEOF_STDC_HEADERS(int64_t, 0)
-AC_CHECK_SIZEOF_STDC_HEADERS(uint64_t, 0)
-
-dnl Checks for functions
-AC_CHECK_FUNCS(mmap strerror strndup strtoul mbrtowc mkstemp getopt_long utimes utime wcwidth snprintf vsnprintf strtof)
-
-dnl Checks for libraries
-AC_CHECK_LIB(z,gzopen)
-
-dnl See if we are cross-compiling
-AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
-
-AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile doc/Makefile python/Makefile])
-AC_OUTPUT

+ 5 - 6
doc/Makefile.in

@@ -35,10 +35,10 @@ subdir = doc
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.in
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 SOURCES =
@@ -91,7 +91,6 @@ LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
 OBJEXT = @OBJEXT@
@@ -168,7 +167,7 @@ CLEANFILES = $(man_MANS)
 all: all-am
 
 .SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -193,9 +192,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure:  $(am__configure_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 
 mostlyclean-libtool:

+ 53 - 102
doc/file.man

@@ -1,5 +1,5 @@
-.\" $File: file.man,v 1.66 2007/10/23 19:58:59 christos Exp $
-.Dd January 8, 2007
+.\" $File: file.man,v 1.73 2008/02/19 17:58:00 rrt Exp $
+.Dd February 19, 2008
 .Dt FILE __CSECTION__
 .Os
 .Sh NAME
@@ -8,8 +8,8 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl bchikLnNprsvz
-.Op Fl mime-type
-.Op Fl mime-encoding
+.Op Fl -mime-type
+.Op Fl -mime-encoding
 .Op Fl f Ar namefile
 .Op Fl F Ar separator
 .Op Fl m Ar magicfiles
@@ -17,6 +17,8 @@
 .Nm
 .Fl C
 .Op Fl m Ar magicfile
+.Nm
+.Op Fl -help
 .Sh DESCRIPTION
 This manual page documents version __VERSION__ of the
 .Nm
@@ -25,7 +27,7 @@ command.
 .Nm
 tests each argument in an attempt to classify it.
 There are three sets of tests, performed in this order:
-filesystem tests, magic number tests, and language tests.
+filesystem tests, magic tests, and language tests.
 The
 .Em first
 test that succeeds causes the file type to be printed.
@@ -49,11 +51,9 @@ meaning anything else (data is usually
 or non-printable).
 Exceptions are well-known file formats (core files, tar archives)
 that are known to contain binary data.
-When modifying the file
-.Pa __MAGIC__
-or the program itself, make sure to
+When modifying magic files or the program itself, make sure to
 .Em "preserve these keywords" .
-People depend on knowing that all the readable files in a directory
+Users depend on knowing that all the readable files in a directory
 have the word 
 .Dq text
 printed.
@@ -61,12 +61,6 @@ Don't do as Berkeley did and change
 .Dq shell commands text
 to 
 .Dq shell script .
-Note that the file
-.Pa __MAGIC__
-is built mechanically from a large number of small files in
-the subdirectory
-.Pa Magdir
-in the source distribution of this program.
 .Pp
 The filesystem tests are based on examining the return from a
 .Xr stat 2
@@ -80,7 +74,7 @@ are intuited if they are defined in
 the system header file
 .In sys/stat.h .
 .Pp
-The magic number tests are used to check for files with data in
+The magic tests are used to check for files with data in
 particular fixed formats.
 The canonical example of this is a binary executable (compiled program)
 .Dv a.out
@@ -97,22 +91,20 @@ near the beginning of the file that tells the
 .Dv UNIX operating system
 that the file is a binary executable, and which of several types thereof.
 The concept of a
-.Sq "magic number"
+.Sq "magic"
 has been applied by extension to data files.
 Any file with some invariant identifier at a small fixed
 offset into the file can usually be described in this way.
 The information identifying these files is read from the compiled
 magic file
 .Pa __MAGIC__.mgc ,
-or 
+or the files in the directory
 .Pa __MAGIC__
-if the compile file does not exist. In addition
-.Nm
-will look in
-.Pa $HOME/.magic.mgc ,
+if the compiled file does not exist. In addition, if
+.Pa $HOME/.magic.mgc
 or
 .Pa $HOME/.magic
-for magic entries.
+exists, it will be used in preference to the system magic files.
 .Pp
 If a file does not match any of the entries in the magic file,
 it is examined to see if it seems to be a text file.
@@ -145,9 +137,9 @@ Once
 has determined the character set used in a text-type file,
 it will
 attempt to determine in what language the file is written.
-The language tests look for particular strings (cf
+The language tests look for particular strings (cf.
 .In names.h
-that can appear anywhere in the first few blocks of a file.
+) that can appear anywhere in the first few blocks of a file.
 For example, the keyword
 .Em .br
 indicates that the file is most likely a
@@ -163,7 +155,8 @@ The language test routines also test for some miscellany
 archives).
 .Pp
 Any file that cannot be identified as having been written
-in any of the character sets listed above is simply said to be ``data''.
+in any of the character sets listed above is simply said to be
+.Dq data .
 .Sh OPTIONS
 .Bl -tag -width indent
 .It Fl b , -brief
@@ -176,7 +169,7 @@ flag to debug a new magic file before installing it.
 .It Fl C , -compile
 Write a
 .Pa magic.mgc
-output file that contains a pre-parsed version of the magic file.
+output file that contains a pre-parsed version of the magic file or directory.
 .It Fl e , -exclude Ar testname
 Exclude the test named in
 .Ar testname
@@ -239,12 +232,18 @@ file.
 (See
 .Dq FILES
 section, below).
-.It Fl -mime-type ,  -mime-encoding
+.It Fl -mime-type , -mime-encoding
 Like
 .Fl i ,
 but print only the specified element(s).
 .It Fl k , -keep-going
-Don't stop at the first match, keep going.
+Don't stop at the first match, keep going. Subsequent matches will be
+have the string
+.Dq "\[rs]012\- "
+prepended.
+(If you want a newline, see the
+.Dq "\-r"
+option.)
 .It Fl L , -dereference
 option causes symlinks to be followed, as the like-named option in
 .Xr ls 1
@@ -253,16 +252,9 @@ This is the default if the environment variable
 .Dv POSIXLY_CORRECT
 is defined.
 .It Fl m , -magic-file Ar list
-Specify an alternate list of files containing magic numbers.
-This can be a single file, or a colon-separated list of files.
-If a compiled magic file is found alongside, it will be used instead.
-With the
-.Fl i
-or 
-.Fl "mime"
-option, the program adds
-.Dq .mime
-to each file name.
+Specify an alternate list of files and directories containing magic.
+This can be a single item, or a colon-separated list.
+If a compiled magic file is found alongside a file or directory, it will be used instead.
 .It Fl n , -no-buffer
 Force stdout to be flushed after checking each file.
 This is only useful if checking a list of files.
@@ -316,38 +308,27 @@ the output. This does not affect the separator which is still printed.
 Print a help message and exit.
 .El
 .Sh FILES
-.Bl -tag -width __MAGIC__.mime.mgc -compact
+.Bl -tag -width __MAGIC__.mgc -compact
 .It Pa __MAGIC__.mgc
-Default compiled list of magic numbers
+Default compiled list of magic.
 .It Pa __MAGIC__
-Default list of magic numbers
-.It Pa __MAGIC__.mime.mgc
-Default compiled list of magic numbers, used to output mime types when
-the 
-.Fl i
-option is specified.
-.It Pa __MAGIC__.mime
-Default list of magic numbers, used to output mime types when the 
-.Fl i
-option is specified.
+Directory containing default magic files.
 .El
 .Sh ENVIRONMENT
 The environment variable
 .Dv MAGIC
-can be used to set the default magic number file name.
+can be used to set the default magic file name.
 If that variable is set, then
 .Nm
 will not attempt to open
 .Pa $HOME/.magic .
 .Nm
 adds
-.Dq .mime
-and/or
 .Dq .mgc
 to the value of this variable as appropriate.
 The environment variable
 .Dv POSIXLY_CORRECT
-controls (on systems that support symbolic links), if
+controls (on systems that support symbolic links), whether
 .Nm
 will attempt to follow symlinks or not. If set, then
 .Nm
@@ -361,7 +342,8 @@ options.
 .Xr magic __FSECTION__ ,
 .Xr strings 1 ,
 .Xr od 1 ,
-.Xr hexdump 1
+.Xr hexdump 1,
+.Xr file 1posix
 .Sh STANDARDS CONFORMANCE
 This program is believed to exceed the System V Interface Definition
 of FILE(CMD), as near as one can determine from the vague language
@@ -465,7 +447,7 @@ command in every
 .Dv UNIX since at least Research Version 4
 (man page dated November, 1973).
 The System V version introduced one significant major change:
-the external list of magic number types.
+the external list of magic types.
 This slowed the program down slightly but made it a lot more flexible.
 .Pp
 This program, based on the System V version,
@@ -486,17 +468,23 @@ Christos Zoulas (christos@astron.com).
 Altered by Chris Lowth, chris@lowth.com, 2000:
 Handle the 
 .Fl i
-option to output mime type strings and using an alternative
+option to output mime type strings, using an alternative
 magic file and internal logic.
 .Pp
 Altered by Eric Fischer (enf@pobox.com), July, 2000,
 to identify character codes and attempt to identify the languages
 of non-ASCII files.
 .Pp
-The list of contributors to the "Magdir" directory (source for the
-.Pa __MAGIC__
-file) is too long to include here.
+Altered by Reuben Thomas (rrt@sc3d.org), 2007 to 2008, to improve MIME
+support and merge MIME and non-MIME magic, support directories as well
+as files of magic, apply many bug fixes and improve the build system.
+.Pp
+The list of contributors to the
+.Dq magic
+directory (magic files)
+is too long to include here.
 You know who you are; thank you.
+Many contributors are listed in the source files.
 .Sh LEGAL NOTICE
 Copyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999.
 Covered by the standard Berkeley Software Distribution copyright; see the file
@@ -510,17 +498,10 @@ were written by John Gilmore from his public-domain
 .Xr tar 1
 program, and are not covered by the above license.
 .Sh BUGS
+.Pp
 There must be a better way to automate the construction of the Magic
 file from all the glop in Magdir.
 What is it?
-.\" Compilation support has been done
-.\" Better yet, the magic file should be compiled into binary (say,
-.\" .Xr ndbm 3
-.\" or, better yet, fixed-length
-.\" .Dv ASCII
-.\" strings for use in heterogenous network environments) for faster startup.
-.\" Then the program would run as fast as the Version 7 program of the same
-.\" name, with the flexibility of the System V version.
 .Pp
 .Nm
 uses several algorithms that favor speed over accuracy,
@@ -530,31 +511,6 @@ files.
 .Pp
 The support for text files (primarily for programming languages)
 is simplistic, inefficient and requires recompilation to update.
-.\" Else support has been done
-.\" There should be an
-.\" .Dv else
-.\" clause to follow a series of continuation lines.
-.\" .Pp
-.\" Regular expression support has been done
-.\" The magic file and keywords should have regular expression support.
-Their use of
-.Dv ASCII TAB
-as a field delimiter is ugly and makes
-it hard to edit the files, but is entrenched.
-.Pp
-It might be advisable to allow upper-case letters in keywords
-for e.g.,
-.Xr troff 1
-commands vs man page macros.
-Regular expression support would make this easy.
-.Pp
-The program doesn't grok 
-.Dv FORTRAN .
-It should be able to figure
-.Dv FORTRAN
-by seeing some keywords which 
-appear indented at the start of line.
-Regular expression support would make this easy.
 .Pp
 The list of keywords in 
 .Dv ascmagic
@@ -563,11 +519,6 @@ This could be done by using some keyword like
 .Sq *
 for the offset value.
 .Pp
-.\" Sorting has been done.
-.\" Another optimization would be to sort
-.\" the magic file so that we can just run down all the
-.\" tests for the first byte, first word, first long, etc, once we
-.\" have fetched it.
 Complain about conflicts in the magic file entries.
 Make a rule that the magic entries sort based on file offset rather
 than position within the magic file?
@@ -587,10 +538,10 @@ versus
 Still, if the others don't pan out, it should be possible to use the
 first guess.  
 .Pp
-This program is slower than some vendors' file commands.
-The new support for multiple character codes makes it even slower.
-.Pp
 This manual page, and particularly this section, is too long.
+.Sh RETURN CODE
+.Nm
+returns 0 on success, and non-zero on error.
 .Sh AVAILABILITY
 You can obtain the original author's latest version by anonymous FTP
 on

+ 10 - 3
doc/libmagic.man

@@ -1,3 +1,4 @@
+.\" $File: libmagic.man,v 1.18 2008/02/28 22:24:46 rrt Exp $
 .\"
 .\" Copyright (c) Christos Zoulas 2003.
 .\" All Rights Reserved.
@@ -164,7 +165,7 @@ bytes size.
 .Pp
 The
 .Fn magic_setflags
-function, sets the 
+function sets the 
 .Ar flags
 described above. Note that using both MIME flags together can also
 return extra information on the charset.
@@ -185,7 +186,9 @@ separated list of database files passed in as
 or NULL for the default database. It returns 0 on success and -1 on
 failure. The compiled files created are named from the
 .Xr basename 1
-of each file argument with ".mgc" appended to it.
+of each file argument with
+.Dq .mgc
+appended to it.
 .Pp
 The
 .Fn magic_load
@@ -199,7 +202,11 @@ The default database file is named by the MAGIC environment variable.  If
 that variable is not set, the default database file name is __MAGIC__.
 .Pp
 .Fn magic_load
-adds ".mime" and/or ".mgc" to the database filename as appropriate.
+adds
+.Dq .mime
+and/or
+.Dq .mgc
+to the database filename as appropriate.
 .Sh RETURN VALUES
 The function
 .Fn magic_open

+ 98 - 79
doc/magic.man

@@ -1,11 +1,11 @@
-.\" $File: magic.man,v 1.39 2007/11/08 00:31:37 christos Exp $
+.\" $File: magic.man,v 1.56 2008/03/01 22:21:48 rrt Exp $
 .Dd January 10, 2007
 .Dt MAGIC __FSECTION__
 .Os
-.\" install as magic.4 on USG, magic.5 on V7 or Berkeley systems.
+.\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems.
 .Sh NAME
 .Nm magic
-.Nd file command's magic number file
+.Nd file command's magic pattern file
 .Sh DESCRIPTION
 This manual page documents the format of the magic file as
 used by the
@@ -15,18 +15,17 @@ The
 .Xr file __CSECTION__
 command identifies the type of a file using,
 among other tests,
-a test for whether the file begins with a certain
-.Dq "magic number" .
+a test for whether the file contains certain
+.Dq "magic patterns" .
 The file
 .Pa __MAGIC__
-specifies what magic numbers are to be tested for,
-what message to print if a particular magic number is found,
+specifies what patterns are to be tested for, what message or
+MIME type to print if a particular pattern is found,
 and additional information to extract from the file.
 .Pp
 Each line of the file specifies a test to be performed.
 A test compares the data starting at a particular offset
-in the file with a 1-byte, 2-byte, or 4-byte numeric value or
-a string.
+in the file with a byte value, a string or a numeric value.
 If the test succeeds, a message is printed.
 The line consists of the following fields:
 .Bl -tag -width ".Dv message"
@@ -40,15 +39,15 @@ The possible values are:
 .It Dv byte
 A one-byte value.
 .It Dv short
-A two-byte value (on most systems) in this machine's native byte order.
+A two-byte value in this machine's native byte order.
 .It Dv long
-A four-byte value (on most systems) in this machine's native byte order.
+A four-byte value in this machine's native byte order.
 .It Dv quad
-An eight-byte value (on most systems) in this machine's native byte order.
+An eight-byte value in this machine's native byte order.
 .It Dv float
-A 32-bit (on most systems) single precision IEEE floating point number in this machine's native byte order.
+A 32-bit single precision IEEE floating point number in this machine's native byte order.
 .It Dv double
-A 64-bit (on most systems) double precision IEEE floating point number in this machine's native byte order.
+A 64-bit double precision IEEE floating point number in this machine's native byte order.
 .It Dv string
 A string of bytes.
 The string type specification can be optionally followed
@@ -69,10 +68,10 @@ Finally the
 .Dq c
 flag, specifies case insensitive matching: lowercase
 characters in the magic match both lower and upper case characters in the
-targer, whereas upper case characters in the magic, only much uppercase
+target, whereas upper case characters in the magic only match uppercase
 characters in the target.
 .It Dv pstring
-A pascal style string where the first byte is interpreted as the an
+A Pascal-style string where the first byte is interpreted as the an
 unsigned length.
 The string is not NUL terminated.
 .It Dv date
@@ -86,106 +85,119 @@ local time rather than UTC.
 An eight-byte value interpreted as a UNIX-style date, but interpreted as
 local time rather than UTC.
 .It Dv beshort
-A two-byte value (on most systems) in big-endian byte order.
+A two-byte value in big-endian byte order.
 .It Dv belong
-A four-byte value (on most systems) in big-endian byte order.
+A four-byte value in big-endian byte order.
 .It Dv bequad
-An eight-byte value (on most systems) in big-endian byte order.
+An eight-byte value in big-endian byte order.
 .It Dv befloat
-A 32-bit (on most systems) single precision IEEE floating point number in big-endian byte order.
+A 32-bit single precision IEEE floating point number in big-endian byte order.
 .It Dv bedouble
-A 64-bit (on most systems) double precision IEEE floating point number in big-endian byte order.
+A 64-bit double precision IEEE floating point number in big-endian byte order.
 .It Dv bedate
-A four-byte value (on most systems) in big-endian byte order,
+A four-byte value in big-endian byte order,
 interpreted as a Unix date.
 .It Dv beqdate
-An eight-byte value (on most systems) in big-endian byte order,
+An eight-byte value in big-endian byte order,
 interpreted as a Unix date.
 .It Dv beldate
-A four-byte value (on most systems) in big-endian byte order,
+A four-byte value in big-endian byte order,
 interpreted as a UNIX-style date, but interpreted as local time rather
 than UTC.
 .It Dv beqldate
-An eight-byte value (on most systems) in big-endian byte order,
+An eight-byte value in big-endian byte order,
 interpreted as a UNIX-style date, but interpreted as local time rather
 than UTC.
 .It Dv bestring16
 A two-byte unicode (UCS16) string in big-endian byte order.
 .It Dv leshort
-A two-byte value (on most systems) in little-endian byte order.
+A two-byte value in little-endian byte order.
 .It Dv lelong
-A four-byte value (on most systems) in little-endian byte order.
+A four-byte value in little-endian byte order.
 .It Dv lequad
-An eight-byte value (on most systems) in little-endian byte order.
+An eight-byte value in little-endian byte order.
 .It Dv lefloat
-A 32-bit (on most systems) single precision IEEE floating point number in little-endian byte order.
+A 32-bit single precision IEEE floating point number in little-endian byte order.
 .It Dv ledouble
-A 64-bit (on most systems) double precision IEEE floating point number in little-endian byte order.
+A 64-bit double precision IEEE floating point number in little-endian byte order.
 .It Dv ledate
-A four-byte value (on most systems) in little-endian byte order,
+A four-byte value in little-endian byte order,
 interpreted as a UNIX date.
 .It Dv leqdate
-An eight-byte value (on most systems) in little-endian byte order,
+An eight-byte value in little-endian byte order,
 interpreted as a UNIX date.
 .It Dv leldate
-A four-byte value (on most systems) in little-endian byte order,
+A four-byte value in little-endian byte order,
 interpreted as a UNIX-style date, but interpreted as local time rather
 than UTC.
 .It Dv leqldate
-An eight-byte value (on most systems) in little-endian byte order,
+An eight-byte value in little-endian byte order,
 interpreted as a UNIX-style date, but interpreted as local time rather
 than UTC.
 .It Dv lestring16
 A two-byte unicode (UCS16) string in little-endian byte order.
 .It Dv melong
-A four-byte value (on most systems) in middle-endian (PDP-11) byte order.
+A four-byte value in middle-endian (PDP-11) byte order.
 .It Dv medate
-A four-byte value (on most systems) in middle-endian (PDP-11) byte order,
+A four-byte value in middle-endian (PDP-11) byte order,
 interpreted as a UNIX date.
 .It Dv meldate
-A four-byte value (on most systems) in middle-endian (PDP-11) byte order,
+A four-byte value in middle-endian (PDP-11) byte order,
 interpreted as a UNIX-style date, but interpreted as local time rather
 than UTC.
 .It Dv regex
 A regular expression match in extended POSIX regular expression syntax
-(much like egrep).
-The type specification can be optionally followed by /[cse]*.
+(like egrep). Regular expressions can take exponential time to
+process, and their performance is hard to predict, so their use is
+discouraged. When used in production environments, their performance
+should be carefully checked. The type specification can be optionally
+followed by
+.Dv /[c][s] .
 The
 .Dq c
 flag makes the match case insensitive, while the
 .Dq s
-or
-.Dq e
-flags update the offset to the starting or ending offsets of the
-match (only one should be used).
-By default, regex does not update the offset.
-The regular expression is always tested against the first
+flag update the offset to the start offset of the match, rather than the end.
+The regular expression is tested against line
+.Dv N + 1
+onwards, where
 .Dv N
-lines, where
-.Dv N
-is the given offset, thus it
-is only useful for (single-byte encoded) text.
+is the given offset.
+Line endings are assumed to be in the machine's native format.
 .Dv ^
 and
 .Dv $
-will match the beginning and end of individual lines, respectively,
+match the beginning and end of individual lines, respectively,
 not beginning and end of file.
 .It Dv search
-A literal string search starting at the given offset.
-It must be followed by
-.Dv \*[Lt]number\*[Gt]
-which specifies how many matches shall be attempted (the range).
-This is suitable for searching larger binary expressions with variable
-offsets, using
+A literal string search starting at the given offset. The same
+modifier flags can be used as for string patterns. The modifier flags
+(if any) must be followed by
+.Dv /number
+the range, that is, the number of positions at which the match will be
+attempted, starting from the start offset. This is suitable for
+searching larger binary expressions with variable offsets, using
 .Dv \e
-escapes for special characters.
+escapes for special characters. The offset works as for regex.
 .It Dv default
-This is intended to be used with the text
-.Dv x
+This is intended to be used with the test
+.Em x
 (which is always true) and a message that is to be used if there are
 no other matches.
 .El
-.El
+.Pp
+Each top-level magic pattern (see below for an explanation of levels)
+is classified as text or binary according to the types used. Types
+.Dq regex
+and
+.Dq search
+are classified as text tests, unless non-printable characters are used
+in the pattern. All other tests are classified as binary. A top-level
+pattern is considered to be a test text when all its patterns are text
+patterns; otherwise, it is considered to be a binary pattern. When
+matching a file, binary patterns are tried first; if no match is
+found, and the file looks like text, then its encoding is determined
+and the text patterns are tried.
 .Pp
 The numeric types may optionally be followed by
 .Dv \*[Am]
@@ -195,7 +207,6 @@ numeric value before any comparisons are done.
 Prepending a
 .Dv u
 to the type indicates that ordered comparisons should be unsigned.
-.Bl -tag -width ".Dv message"
 .It Dv test
 The value to be compared with the value from the file.
 If the type is
@@ -232,12 +243,8 @@ Operators
 and
 .Dv ~
 don't work with floats and doubles.
-For all tests except
-.Em string
-and
-.Em regex ,
-operation
-.Dv !
+The operator
+.Dv !\&
 specifies that the line matches if the test does
 .Em not
 succeed.
@@ -250,8 +257,8 @@ is octal, and
 .Dv 0x13
 is hexadecimal.
 .Pp
-For string values, the byte string from the
-file must match the specified byte string.
+For string values, the string from the
+file must match the specified string.
 The operators
 .Dv = ,
 .Dv \*[Lt]
@@ -262,10 +269,10 @@ and
 can be applied to strings.
 The length used for matching is that of the string argument
 in the magic file.
-This means that a line can match any string, and
-then presumably print that string, by doing
+This means that a line can match any non-empty string (usually used to
+then print the string), with
 .Em \*[Gt]\e0
-(because all strings are greater than the null string).
+(because all non-empty strings are greater than the empty string).
 .Pp
 The special test
 .Em x
@@ -276,11 +283,24 @@ If the string contains a
 .Xr printf 3
 format specification, the value from the file (with any specified masking
 performed) is printed using the message as the format string.
-If the string begins with ``\\b'', the message printed is the
-remainder of the string with no whitespace added before it: multiple
-matches are normally separated by a single space.
+If the string begins with
+.Dq \eb ,
+the message printed is the remainder of the string with no whitespace
+added before it: multiple matches are normally separated by a single
+space.
 .El
 .Pp
+A MIME type is given on a separate line, which must be the next
+non-blank or comment line after the magic line that identifies the
+file type, and has the following format:
+.Bd -literal -offset indent 
+!:mime	MIMETYPE
+.Ed
+.Pp
+i.e. the literal string
+.Dq !:mime
+followed by the MIME type.
+.Pp
 Some file formats contain additional information which is to be printed
 along with the file type or need additional tests to determine the true
 file type.
@@ -350,13 +370,13 @@ That way variable length structures can be examined:
 \*[Gt]\*[Gt](0x3c.l)  string  LX\e0\e0  LX executable (OS/2)
 .Ed
 .Pp
-This strategy of examining has one drawback: You must make sure that
+This strategy of examining has a drawback: You must make sure that
 you eventually print something, or users may get empty output (like, when
 there is neither PE\e0\e0 nor LE\e0\e0 in the above example)
 .Pp
-If this indirect offset cannot be used as-is, there are simple calculations
+If this indirect offset cannot be used directly, simple calculations are
 possible: appending
-.Em [+-*/%\*[Am]|^]\*[Lt]number\*[Gt]
+.Em [+-*/%\*[Am]|^]number
 inside parentheses allows one to modify
 the value read from the file before it is used as an offset:
 .Bd -literal -offset indent
@@ -468,4 +488,3 @@ a system on which the lengths are invariant.
 .\" the changes I posted to the S5R2 version.
 .\"
 .\" Modified for Ian Darwin's version of the file command.
-.\" @(#)$Id: magic.man,v 1.39 2007/11/08 00:31:37 christos Exp $

+ 10 - 0
magic/Magdir/adventure

@@ -73,3 +73,13 @@
 >10	belong	 0x0A0D1A00
 >>14	string	>\0		%s saved game data
 
+# Danny Milosavljevic <danny.milo@gmx.net>
+# this are adrift (adventure game standard) game files, extension .taf
+# depending on version magic continues with 0x93453E6139FA (V 4.0)
+# 0x9445376139FA (V 3.90)
+# 0x9445366139FA (V 3.80)
+# this is from source (http://www.adrift.org.uk/) and I have some taf
+# files, and checked them.
+#0	belong	0x3C423FC9
+#>4	belong	0x6A87C2CF	Adrift game file
+#!:mime	application/x-adrift

+ 211 - 126
magic/Magdir/animation

@@ -8,37 +8,58 @@
 
 # SGI and Apple formats
 0	string		MOVI		Silicon Graphics movie file
+!:mime	video/x-sgi-movie
 4       string          moov            Apple QuickTime
+!:mime	video/quicktime
 >12     string          mvhd            \b movie (fast start)
 >12     string          mdra            \b URL
 >12     string          cmov            \b movie (fast start, compressed header)
 >12     string          rmra            \b multiple URLs
 4       string          mdat            Apple QuickTime movie (unoptimized)
-4       string          wide            Apple QuickTime movie (unoptimized)
-4       string          skip            Apple QuickTime movie (modified)
-4       string          free            Apple QuickTime movie (modified)
+!:mime	video/quicktime
+#4       string          wide            Apple QuickTime movie (unoptimized)
+#!:mime	video/quicktime
+#4       string          skip            Apple QuickTime movie (modified)
+#!:mime	video/quicktime
+#4       string          free            Apple QuickTime movie (modified)
+#!:mime	video/quicktime
 4       string          idsc            Apple QuickTime image (fast start)
-4       string          idat            Apple QuickTime image (unoptimized)
+!:mime	image/x-quicktime
+#4       string          idat            Apple QuickTime image (unoptimized)
+#!:mime	image/x-quicktime
 4       string          pckg            Apple QuickTime compressed archive
+!:mime	application/x-quicktime-player
 4	string/B	jP		JPEG 2000 image
+!:mime	image/jp2
 4	string		ftyp		ISO Media
 >8	string		isom		\b, MPEG v4 system, version 1
+!:mime	video/mp4
 >8	string		iso2		\b, MPEG v4 system, part 12 revision
 >8	string		mp41		\b, MPEG v4 system, version 1
+!:mime	video/mp4
 >8	string		mp42		\b, MPEG v4 system, version 2
+!:mime	video/mp4
 >8	string		mp7t		\b, MPEG v4 system, MPEG v7 XML
 >8	string		mp7b		\b, MPEG v4 system, MPEG v7 binary XML
 >8	string/B	jp2		\b, JPEG 2000
+!:mime	image/jp2
 >8	string		3gp		\b, MPEG v4 system, 3GPP
+!:mime	video/3gpp
 >>11	byte		4		\b v4 (H.263/AMR GSM 6.10)
 >>11	byte		5		\b v5 (H.263/AMR GSM 6.10)
 >>11	byte		6		\b v6 (ITU H.264/AMR GSM 6.10)
 >8	string		mmp4		\b, MPEG v4 system, 3GPP Mobile
+!:mime	video/mp4
 >8	string		avc1		\b, MPEG v4 system, 3GPP JVT AVC
+!:mime	video/3gpp
 >8	string/B	M4A		\b, MPEG v4 system, iTunes AAC-LC
+!:mime	audio/mp4
+>8	string/B	M4V		\b, MPEG v4 system, iTunes AVC-LC
+!:mime	video/mp4
 >8	string/B	M4P		\b, MPEG v4 system, iTunes AES encrypted
 >8	string/B	M4B		\b, MPEG v4 system, iTunes bookmarked
 >8	string/B	qt		\b, Apple QuickTime movie
+!:mime	video/quicktime
 
 # MPEG sequences
 # Scans for all common MPEG header start codes
@@ -48,7 +69,7 @@
 >>5      byte               77             \b, main
 >>5      byte               88             \b, extended
 >>7      byte               x              \b @ L %u
-0        belong&0xFFFFFF00  0x00000100     MPEG sequence
+0        string             \000\000\001   MPEG sequence
 >3       byte               0xBA
 >>4      byte               &0x40          \b, v2, program multiplex
 >>4      byte               ^0x40          \b, v1, system multiplex
@@ -252,22 +273,39 @@
 # modified to fully support MPEG ADTS
 
 # MP3, M1A
-0       beshort&0xFFFE  0xFFFA         MPEG ADTS, layer III, v1
+# modified by Joerg Jenderek
+# GRR the original test are too common for many DOS files
+# so don't accept as MP3 until we've tested the rate
+0       beshort&0xFFFE
 # rates
->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
+>2      byte&0xF0       0x10           MPEG ADTS, layer III, v1,  32 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0x20           MPEG ADTS, layer III, v1,  40 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0x30           MPEG ADTS, layer III, v1,  48 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0x40           MPEG ADTS, layer III, v1,  56 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0x50           MPEG ADTS, layer III, v1,  64 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0x60           MPEG ADTS, layer III, v1,  80 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0x70           MPEG ADTS, layer III, v1,  96 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0x80           MPEG ADTS, layer III, v1, 112 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0x90           MPEG ADTS, layer III, v1, 128 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0xA0           MPEG ADTS, layer III, v1, 160 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0xB0           MPEG ADTS, layer III, v1, 192 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0xC0           MPEG ADTS, layer III, v1, 224 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0xD0           MPEG ADTS, layer III, v1, 256 kbps
+!:mime	audio/mpeg
+>2      byte&0xF0       0xE0           MPEG ADTS, layer III, v1, 320 kbps
+!:mime	audio/mpeg
 # timing
 >2      byte&0x0C       0x00           \b, 44.1 kHz
 >2      byte&0x0C       0x04           \b, 48 kHz
@@ -288,20 +326,20 @@
 # MP2, M1A
 0       beshort&0xFFFE  0xFFFC         MPEG ADTS, layer II, v1
 # rates
->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
+>2      byte&0xF0       0x10           \b,  32 kbps
+>2      byte&0xF0       0x20           \b,  48 kbps
+>2      byte&0xF0       0x30           \b,  56 kbps
+>2      byte&0xF0       0x40           \b,  64 kbps
+>2      byte&0xF0       0x50           \b,  80 kbps
+>2      byte&0xF0       0x60           \b,  96 kbps
+>2      byte&0xF0       0x70           \b, 112 kbps
+>2      byte&0xF0       0x80           \b, 128 kbps
+>2      byte&0xF0       0x90           \b, 160 kbps
+>2      byte&0xF0       0xA0           \b, 192 kbps