Browse Source

Import upstream version 4.25

Christos Zoulas 13 years ago
parent
commit
0755f6a5d2
58 changed files with 2274 additions and 405 deletions
  1. 71 1
      ChangeLog
  2. 2 1
      Makefile.in
  3. 23 2
      README
  4. 34 0
      aclocal.m4
  5. 142 0
      compile
  6. 3 0
      config.h.in
  7. 163 37
      configure
  8. 2 1
      configure.ac
  9. 40 24
      magic/Magdir/animation
  10. 4 4
      magic/Magdir/archive
  11. 1 1
      magic/Magdir/audio
  12. 3 1
      magic/Magdir/cafebabe
  13. 26 21
      magic/Magdir/commands
  14. 2 2
      magic/Magdir/compress
  15. 6 6
      magic/Magdir/console
  16. 1 1
      magic/Magdir/database
  17. 5 0
      magic/Magdir/diff
  18. 18 9
      magic/Magdir/elf
  19. 38 0
      magic/Magdir/filesystems
  20. 2 2
      magic/Magdir/freebsd
  21. 0 2
      magic/Magdir/fsav
  22. 92 0
      magic/Magdir/games
  23. 4 0
      magic/Magdir/gimp
  24. 4 0
      magic/Magdir/gnu
  25. 33 10
      magic/Magdir/hp
  26. 28 16
      magic/Magdir/images
  27. 16 1
      magic/Magdir/linux
  28. 10 5
      magic/Magdir/lisp
  29. 8 1
      magic/Magdir/misctools
  30. 119 146
      magic/Magdir/msdos
  31. 7 7
      magic/Magdir/perl
  32. 6 4
      magic/Magdir/printer
  33. 1 1
      magic/Magdir/psion
  34. 1 1
      magic/Magdir/riff
  35. 10 0
      magic/Magdir/ruby
  36. 6 0
      magic/Magdir/sgml
  37. 3 1
      magic/Magdir/vorbis
  38. 15 0
      magic/Magdir/weak
  39. 115 0
      magic/Magdir/windows
  40. 9 1
      magic/Makefile.am
  41. 10 1
      magic/Makefile.in
  42. 5 1
      src/Makefile.am
  43. 13 5
      src/Makefile.in
  44. 170 52
      src/apprentice.c
  45. 1 2
      src/ascmagic.c
  46. 43 0
      src/asprintf.c
  47. 4 2
      src/elfclass.h
  48. 2 2
      src/file.c
  49. 21 11
      src/file.h
  50. 2 2
      src/fsmagic.c
  51. 15 7
      src/funcs.c
  52. 1 2
      src/magic.c
  53. 5 2
      src/patchlevel.h
  54. 177 5
      src/readelf.c
  55. 76 0
      src/readelf.h
  56. 638 0
      src/vasprintf.c
  57. 1 0
      tests/Makefile.am
  58. 17 2
      tests/Makefile.in

+ 71 - 1
ChangeLog

@@ -1,4 +1,74 @@
-	
+2008-07-02 11:15  Christos Zoulas  <christos@astron.com>
+
+	* add !:strength op to adjust magic strength (experimental)
+
+2008-06-16 21:41  Reuben Thomas  <rrt@sc3d.org>
+
+	* Fix automake error in configure.ac.
+
+	* Add MIME type for Psion Sketch files.
+
+2008-06-05 08:59  Christos Zoulas  <christos@astron.com>
+
+	* Don't print warnings about bad namesize in stripped
+	  binaries with PT_NOTE is still there, and the actual
+	  note is gone (Jakub Jelinek)
+
+2008-05-28 15:12  Robert Byrnes  <byrnes@wildpumpkin.net>
+
+	* magic/Magdir/elf:
+	  Note invalid byte order for little-endian SPARC32PLUS.
+	  Add SPARC V9 vendor extensions and memory model.
+
+	* src/elfclass.h:
+	  Pass target machine to doshn (for Solaris hardware capabilities).
+
+	* src/readelf.c (doshn):
+	  Add support for Solaris hardware/software capabilities.
+
+	* src/readelf.h:
+	  Ditto.
+
+	* src/vasprintf.c (dispatch):
+	  Add support for ll modifier.
+
+2008-05-16 10:25  Christos Zoulas  <christos@astron.com>
+
+	* Fix compiler warnings.
+
+	* remove stray printf, and fix a vprintf bug. (Martin Dorey)
+
+2008-05-06 00:13  Robert Byrnes  <byrnes@wildpumpkin.net>
+
+        * src/Makefile.am:
+	  Ensure that getopt_long and [v]asprintf are included in libmagic,
+	  as needed.
+
+	  Remove unnecessary EXTRA_DIST.
+
+        * src/Makefile.in:
+	  Rerun automake.
+
+        * src/vasprintf.c (dispatch):
+	  Fix variable precision bug: be sure to step past '*'.
+
+        * src/vasprintf.c (core):
+	  Remove unreachable code.
+
+        * src/apprentice.c (set_test_type):
+	  Add cast to avoid compiler warning.
+
+2008-04-22 23:45  Christos Zoulas  <christos@astron.com>
+
+	* Add magic submission guidelines (Abel Cheung)
+
+	* split msdos and windows magic (Abel Cheung)
+
+2008-04-04 11:00  Christos Zoulas  <christos@astron.com>
+
+        * >= <= is not supported, so fix the magic and warn about it.
+	  reported by: Thien-Thi Nguyen <ttn@gnuvola.org>
+
 2008-03-27 16:16  Robert Byrnes  <byrnes@wildpumpkin.net>
 
         * src/readelf.c (donote):

+ 2 - 1
Makefile.in

@@ -35,7 +35,8 @@ subdir = .
 DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
 	$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
-	config.guess config.sub depcomp install-sh ltmain.sh missing
+	compile 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.ac

+ 23 - 2
README

@@ -1,5 +1,5 @@
 ** README for file(1) Command **
-@(#) $File: README,v 1.39 2008/02/14 20:22:20 christos Exp $
+@(#) $File: README,v 1.40 2008/04/23 03:45:20 christos Exp $
 
 E-mail: christos@astron.com
 Mailing List: file@mx.gw.com
@@ -46,7 +46,7 @@ magic numbers assigned to all sorts of data files that
 are in reasonable circulation. Send your magic numbers,
 in magic(5) format please, to the maintainer, Christos Zoulas.
 
-LEGAL.NOTICE - read this first.
+COPYING - read this first.
 README - read this second (you are currently reading this file).
 PORTING - read this only if the program won't compile.
 Makefile - read this next, adapt it as needed (particularly
@@ -76,6 +76,27 @@ readelf.[ch] - Stand-alone elf parsing code.
 compress.c - on-the-fly decompression.
 print.c - print results, errors, warnings.
 
+------------------------------------------------------------------------------
+
+If you submit a new magic entry please make sure you read the following
+guidelines:
+
+- Initial match is preferably at least 32 bits long, and is a _unique_ match
+- If this is not feasible, use additional check
+- Match of <= 16 bits are not accepted
+- Delay printing string as much as possible, don't print output too early
+- Avoid printf arbitrary byte as string, which can be a source of
+  crash and buffer overflow
+
+- Provide complete information with entry:
+  * One line short summary
+  * Optional long description
+  * File extension, if applicable
+  * Full name and contact method (for discussion when entry has problem)
+  * Further reference, such as documentation of format
+
+------------------------------------------------------------------------------
+
 You can download the latest version of file from:
 
 	ftp://ftp.astron.com/pub/file/

+ 34 - 0
aclocal.m4

@@ -6737,6 +6737,40 @@ AC_MSG_RESULT([$_am_result])
 rm -f confinc confmf
 ])
 
+# Copyright (C) 1999, 2000, 2001, 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 5
+
+# AM_PROG_CC_C_O
+# --------------
+# Like AC_PROG_CC_C_O, but changed for automake.
+AC_DEFUN([AM_PROG_CC_C_O],
+[AC_REQUIRE([AC_PROG_CC_C_O])dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+ac_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
+if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+dnl Make sure AC_PROG_CC is never called again, or it will override our
+dnl setting of CC.
+m4_define([AC_PROG_CC],
+          [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])])
+])
+
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
 # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005

+ 142 - 0
compile

@@ -0,0 +1,142 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand `-c -o'.
+
+scriptversion=2005-05-14.22
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand `-c -o'.
+Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file `INSTALL'.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "compile $scriptversion"
+    exit $?
+    ;;
+esac
+
+ofile=
+cfile=
+eat=
+
+for arg
+do
+  if test -n "$eat"; then
+    eat=
+  else
+    case $1 in
+      -o)
+	# configure might choose to run compile as `compile cc -o foo foo.c'.
+	# So we strip `-o arg' only if arg is an object.
+	eat=1
+	case $2 in
+	  *.o | *.obj)
+	    ofile=$2
+	    ;;
+	  *)
+	    set x "$@" -o "$2"
+	    shift
+	    ;;
+	esac
+	;;
+      *.c)
+	cfile=$1
+	set x "$@" "$1"
+	shift
+	;;
+      *)
+	set x "$@" "$1"
+	shift
+	;;
+    esac
+  fi
+  shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+  # If no `-o' option was seen then we might have been invoked from a
+  # pattern rule where we don't need one.  That is ok -- this is a
+  # normal compilation that the losing compiler can handle.  If no
+  # `.c' file was seen then we are probably linking.  That is also
+  # ok.
+  exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use `[/.-]' here to ensure that we don't use the same name
+# that we are using for the .o file.  Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
+while true; do
+  if mkdir "$lockdir" >/dev/null 2>&1; then
+    break
+  fi
+  sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+  mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+  mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:

+ 3 - 0
config.h.in

@@ -158,6 +158,9 @@
    <sysmacros.h>. */
 #undef MAJOR_IN_SYSMACROS
 
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+#undef NO_MINUS_C_MINUS_O
+
 /* Name of package */
 #undef PACKAGE
 

+ 163 - 37
configure

@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for file 4.24.
+# Generated by GNU Autoconf 2.61 for file 4.25.
 #
 # Report bugs to <christos@astron.com>.
 #
@@ -728,8 +728,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 # Identity of this package.
 PACKAGE_NAME='file'
 PACKAGE_TARNAME='file'
-PACKAGE_VERSION='4.24'
-PACKAGE_STRING='file 4.24'
+PACKAGE_VERSION='4.25'
+PACKAGE_STRING='file 4.25'
 PACKAGE_BUGREPORT='christos@astron.com'
 
 # Factoring default headers for most tests.
@@ -1394,7 +1394,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures file 4.24 to adapt to many kinds of systems.
+\`configure' configures file 4.25 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1464,7 +1464,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of file 4.24:";;
+     short | recursive ) echo "Configuration of file 4.25:";;
    esac
   cat <<\_ACEOF
 
@@ -1570,7 +1570,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-file configure 4.24
+file configure 4.25
 generated by GNU Autoconf 2.61
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1584,7 +1584,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by file $as_me 4.24, which was
+It was created by file $as_me 4.25, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   $ $0 $@
@@ -2274,7 +2274,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='file'
- VERSION='4.24'
+ VERSION='4.25'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3610,6 +3610,132 @@ else
 fi
 
 
+if test "x$CC" != xcc; then
+  { echo "$as_me:$LINENO: checking whether $CC and cc understand -c and -o together" >&5
+echo $ECHO_N "checking whether $CC and cc understand -c and -o together... $ECHO_C" >&6; }
+else
+  { echo "$as_me:$LINENO: checking whether cc understands -c and -o together" >&5
+echo $ECHO_N "checking whether cc understands -c and -o together... $ECHO_C" >&6; }
+fi
+set dummy $CC; ac_cc=`echo $2 |
+		      sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+# Make sure it works both with $CC and with simple cc.
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+rm -f conftest2.*
+if { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+   test -f conftest2.$ac_objext && { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); };
+then
+  eval ac_cv_prog_cc_${ac_cc}_c_o=yes
+  if test "x$CC" != xcc; then
+    # Test first that cc exists at all.
+    if { ac_try='cc -c conftest.$ac_ext >&5'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+      ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+      rm -f conftest2.*
+      if { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 test -f conftest2.$ac_objext && { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); };
+      then
+	# cc works too.
+	:
+      else
+	# cc exists but doesn't like -o.
+	eval ac_cv_prog_cc_${ac_cc}_c_o=no
+      fi
+    fi
+  fi
+else
+  eval ac_cv_prog_cc_${ac_cc}_c_o=no
+fi
+rm -f core conftest*
+
+fi
+if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define NO_MINUS_C_MINUS_O 1
+_ACEOF
+
+fi
+
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+ac_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+
+
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
 # incompatible versions:
@@ -4472,7 +4598,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 4475 "configure"' > conftest.$ac_ext
+  echo '#line 4601 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7218,11 +7344,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7221: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7347: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7225: \$? = $ac_status" >&5
+   echo "$as_me:7351: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -7480,11 +7606,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7483: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7609: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7487: \$? = $ac_status" >&5
+   echo "$as_me:7613: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -7542,11 +7668,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7545: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7671: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:7549: \$? = $ac_status" >&5
+   echo "$as_me:7675: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -9745,7 +9871,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 9748 "configure"
+#line 9874 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -9843,7 +9969,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 9846 "configure"
+#line 9972 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12087,11 +12213,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:12090: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:12216: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:12094: \$? = $ac_status" >&5
+   echo "$as_me:12220: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -12149,11 +12275,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:12152: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:12278: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:12156: \$? = $ac_status" >&5
+   echo "$as_me:12282: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -13485,7 +13611,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 13488 "configure"
+#line 13614 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13583,7 +13709,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 13586 "configure"
+#line 13712 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14468,11 +14594,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14471: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14597: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:14475: \$? = $ac_status" >&5
+   echo "$as_me:14601: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -14530,11 +14656,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:14533: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:14659: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:14537: \$? = $ac_status" >&5
+   echo "$as_me:14663: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -16647,11 +16773,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16650: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16776: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16654: \$? = $ac_status" >&5
+   echo "$as_me:16780: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -16909,11 +17035,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16912: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:17038: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16916: \$? = $ac_status" >&5
+   echo "$as_me:17042: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -16971,11 +17097,11 @@ else
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16974: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:17100: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:16978: \$? = $ac_status" >&5
+   echo "$as_me:17104: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -19174,7 +19300,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 19177 "configure"
+#line 19303 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -19272,7 +19398,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 19275 "configure"
+#line 19401 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -24159,7 +24285,7 @@ exec 6>&1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by file $as_me 4.24, which was
+This file was extended by file $as_me 4.25, which was
 generated by GNU Autoconf 2.61.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -24212,7 +24338,7 @@ Report bugs to <bug-autoconf@gnu.org>."
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-file config.status 4.24
+file config.status 4.25
 configured by $0, generated by GNU Autoconf 2.61,
   with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 

+ 2 - 1
configure.ac

@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(file, 4.24, christos@astron.com)
+AC_INIT(file, 4.25, christos@astron.com)
 AM_INIT_AUTOMAKE
 AM_CONFIG_HEADER(config.h)
 
@@ -51,6 +51,7 @@ AC_GNU_SOURCE
 
 dnl Checks for programs.
 AC_PROG_CC
+AM_PROG_CC_C_O
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_LIBTOOL

+ 40 - 24
magic/Magdir/animation

@@ -63,23 +63,23 @@
 
 # MPEG sequences
 # Scans for all common MPEG header start codes
-0        belong             0x00000001     JVT NAL sequence
->4       byte&0x1F          0x07           \b, H.264 video
+0	 belong		    0x00000001     
+>4	 byte&0x1F	    0x07	   JVT NAL sequence, H.264 video
 >>5      byte               66             \b, baseline
 >>5      byte               77             \b, main
 >>5      byte               88             \b, extended
 >>7      byte               x              \b @ L %u
-0        string             \000\000\001   MPEG sequence
->3       byte               0xBA
+0        belong&0xFFFFFF00  0x00000100     
+>3       byte               0xBA           MPEG sequence
 >>4      byte               &0x40          \b, v2, program multiplex
 >>4      byte               ^0x40          \b, v1, system multiplex
->3       byte               0xBB           \b, v1/2, multiplex (missing pack header)
->3       byte&0x1F          0x07           \b, H.264 video
+>3       byte               0xBB           MPEG sequence, v1/2, multiplex (missing pack header)
+>3       byte&0x1F          0x07           MPEG sequence, H.264 video
 >>4      byte               66             \b, baseline
 >>4      byte               77             \b, main
 >>4      byte               88             \b, extended
 >>6      byte               x              \b @ L %u
->3       byte               0xB0           \b, v4
+>3       byte               0xB0           MPEG sequence, v4
 >>5      belong             0x000001B5
 >>>9     byte               &0x80
 >>>>10   byte&0xF0          16             \b, video
@@ -148,7 +148,7 @@
 >>4      byte               251            \b, FGS @ L3
 >>4      byte               252            \b, FGS @ L4
 >>4      byte               253            \b, FGS @ L5
->3       byte               0xB5           \b, v4
+>3       byte               0xB5           MPEG sequence, v4
 >>4      byte               &0x80
 >>>5     byte&0xF0          16             \b, video (missing profile header)
 >>>5     byte&0xF0          32             \b, still texture (missing profile header)
@@ -158,7 +158,7 @@
 >>4      byte&0xF8          16             \b, still texture (missing profile header)
 >>4      byte&0xF8          24             \b, mesh (missing profile header)
 >>4      byte&0xF8          32             \b, face (missing profile header)
->3       byte               0xB3
+>3       byte               0xB3           MPEG sequence
 >>12     belong             0x000001B8     \b, v1, progressive Y'CbCr 4:2:0 video
 >>12     belong             0x000001B2     \b, v1, progressive Y'CbCr 4:2:0 video
 >>12     belong             0x000001B5     \b, v2,
@@ -276,7 +276,7 @@
 # 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
+0       beshort&0xFFFE  0xFFFA
 # rates
 >2      byte&0xF0       0x10           MPEG ADTS, layer III, v1,  32 kbps
 !:mime	audio/mpeg
@@ -361,6 +361,7 @@
 # updated by Joerg Jenderek
 # GRR the original test are too common for many DOS files, so test 32 <= kbits <= 448
 # GRR this test is still too general as it catches a BOM of UTF-16 files (0xFFFE)
+# FIXME: Almost all little endian UTF-16 text with BOM are clobbered by these entries
 #0	beshort&0xFFFE		0xFFFE	
 #>2	ubyte&0xF0	>0x0F		
 #>>2	ubyte&0xF0	<0xE1		MPEG ADTS, layer I, v1
@@ -616,22 +617,30 @@
 #0       beshort         0x4DE1         MPEG-4 LO-EP audio stream
 #!:mime	audio/x-mp4a-latm
 
-# FLI animation format
-4	leshort		0xAF11			FLI file
+# Summary: FLI animation format
+# Created by: Daniel Quinlan <quinlan@yggdrasil.com>
+# Modified by (1): Abel Cheung <abelcheung@gmail.com> (avoid over-generic detection)
+4	leshort		0xAF11
+# standard FLI always has 320x200 resolution and 8 bit color
+>8	leshort		320
+>>10	leshort		200
+>>>12	leshort		8			FLI animation, 320x200x8
 !:mime	video/x-fli
->6	leshort		x			- %d frames,
->8	leshort		x			width=%d pixels,
->10	leshort		x			height=%d pixels,
->12	leshort		x			depth=%d,
->16	leshort		x			ticks/frame=%d
-# FLC animation format
-4	leshort		0xAF12			FLC file
+>>>>6	leshort		x			\b, %d frames
+# frame speed is multiple of 1/70s
+>>>>16	leshort		x			\b, %d/70s per frame
+
+# Summary: FLC animation format
+# Created by: Daniel Quinlan <quinlan@yggdrasil.com>
+# Modified by (1): Abel Cheung <abelcheung@gmail.com> (avoid over-generic detection)
+4	leshort		0xAF12
+# standard FLC always use 8 bit color
+>12	leshort		8			FLC animation
 !:mime	video/x-flc
->6	leshort		x			- %d frames
->8	leshort		x			width=%d pixels,
->10	leshort		x			height=%d pixels,
->12	leshort		x			depth=%d,
->16	leshort		x			ticks/frame=%d
+>>8	leshort		x			\b, %d
+>>10	leshort		x			\bx%dx8
+>>6	uleshort	x			\b, %d frames
+>>16	uleshort	x			\b, %dms per frame
 
 # DL animation format
 # XXX - collision with most `mips' magic
@@ -712,6 +721,13 @@
 0	string/b	#VRML\ V2.0\ utf8	ISO/IEC 14772 VRML 97 file
 !:mime	model/vrml
 
+# X3D (Extensible 3D) [http://www.web3d.org/specifications/x3d-3.0.dtd]
+# From Michel Briand <michelbriand@free.fr>
+0	string		\<?xml\ version="
+!:strength +1
+>20	search/1000/cb  \<!DOCTYPE\ X3D		X3D (Extensible 3D) model xml text
+!:mime model/x3d
+
 #---------------------------------------------------------------------------
 # HVQM4: compressed movie format designed by Hudson for Nintendo GameCube
 # From Mark Sheppard <msheppard@climax.co.uk>, 2002-10-03

+ 4 - 4
magic/Magdir/archive

@@ -577,8 +577,10 @@
 !:mime	application/zip
 
 # OpenOffice.org / KOffice / StarOffice documents
+# Listed here because they ARE zip files
+#
 # From: Abel Cheung <abel@oaka.org>
-# Listed here because they are basically zip files
+>4	byte		0x14
 >>30	string		mimetype
 
 # KOffice (1.2 or above) formats
@@ -608,6 +610,7 @@
 >>>>>69	byte	!0x2e			presentation
 >>>>>69	string	.template		template
 >>>>62	string	math			Math document
+>>>>62	string	base			Database file
 
 # OpenDocument formats (for OpenOffice 2.x / StarOffice >= 8)
 # http://lists.oasis-open.org/archives/office/200505/msg00006.html
@@ -776,9 +779,6 @@
 0	lelong	0x10201A7A	Symbian installation file (Symbian OS 9.x)
 !:mime	x-epoc/x-sisx-app
 
-# Pack200 Java archives, http://jcp.org/en/jsr/detail?id=200
-0	belong	0xcafed00d	Pack200 Java archive
-
 # From "Nelson A. de Oliveira" <naoliv@gmail.com>
 0	string	MPQ\032		MoPaQ (MPQ) archive
 

+ 1 - 1
magic/Magdir/audio

@@ -273,7 +273,7 @@
 >22	belong&0x00ffffff	x		%d Hz,
 >18	beshort		=0			no loop,
 >18	beshort		=-1			loop,
->21	ubyte		<=127			note %d,
+>21	ubyte		<128			note %d,
 >22	byte		=0			replay 5.485 KHz
 >22	byte		=1			replay 8.084 KHz
 >22	byte		=2			replay 10.971 Khz

+ 3 - 1
magic/Magdir/cafebabe

@@ -21,5 +21,7 @@
 >>4	belong		1		Mach-O fat file with 1 architecture
 >>4	belong		>1
 >>>4	belong		<20		Mach-O fat file with %ld architectures
->2	beshort		0xd00d		JAR compressed with pack200
+>2	beshort		0xd00d		JAR compressed with pack200,
+>>5	byte		x		version %d.
+>>4	byte		x		\b%d
 !:mime	application/x-java-pack200

+ 26 - 21
magic/Magdir/commands

@@ -4,48 +4,48 @@
 #
 #0	string		:			shell archive or script for antique kernel text
 0	string/b	#!\ /bin/sh		POSIX shell script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 0	string/b	#!\ /bin/csh		C shell script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 # korn shell magic, sent by George Wu, gwu@clyde.att.com
 0	string/b	#!\ /bin/ksh		Korn shell script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 0	string/b 	#!\ /bin/tcsh		Tenex C shell script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 0	string/b 	#!\ /usr/local/tcsh	Tenex C shell script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 0	string/b	#!\ /usr/local/bin/tcsh	Tenex C shell script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 
 #
 # zsh/ash/ae/nawk/gawk magic from cameron@cs.unsw.oz.au (Cameron Simpson)
 0	string/b	#!\ /bin/zsh		Paul Falstad's zsh script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 0	string/b	#!\ /usr/bin/zsh	Paul Falstad's zsh script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 0	string/b	#!\ /usr/local/bin/zsh	Paul Falstad's zsh script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 0	string/b	#!\ /usr/local/bin/ash	Neil Brown's ash script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 0	string/b	#!\ /usr/local/bin/ae	Neil Brown's ae script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 0	string/b	#!\ /bin/nawk		new awk script text executable
-!:mime	application/x-nawk
+!:mime	text/x-nawk
 0	string/b	#!\ /usr/bin/nawk	new awk script text executable
-!:mime	application/x-nawk
+!:mime	text/x-nawk
 0	string/b	#!\ /usr/local/bin/nawk	new awk script text executable
-!:mime	application/x-nawk
+!:mime	text/x-nawk
 0	string/b	#!\ /bin/gawk		GNU awk script text executable
-!:mime	application/x-gawk
+!:mime	text/x-gawk
 0	string/b	#!\ /usr/bin/gawk	GNU awk script text executable
-!:mime	application/x-gawk
+!:mime	text/x-gawk
 0	string/b	#!\ /usr/local/bin/gawk	GNU awk script text executable
-!:mime	application/x-gawk
+!:mime	text/x-gawk
 #
 0	string/b	#!\ /bin/awk		awk script text executable
-!:mime	application/x-awk
+!:mime	text/x-awk
 0	string/b	#!\ /usr/bin/awk	awk script text executable
-!:mime	application/x-awk
+!:mime	text/x-awk
 # update to distinguish from *.vcf files
 # this is broken because postscript has /EBEGIN{ for example.
 #0	search/Bb	BEGIN {			awk script text
@@ -55,9 +55,9 @@
 
 # bash shell magic, from Peter Tobias (tobias@server.et-inf.fho-emden.de)
 0	string/b	#!\ /bin/bash	Bourne-Again shell script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 0	string/b	#!\ /usr/local/bin/bash	Bourne-Again shell script text executable
-!:mime	application/x-shellscript
+!:mime	text/x-shellscript
 
 # using env
 0	string		#!/usr/bin/env		a
@@ -68,10 +68,15 @@
 # PHP scripts
 # Ulf Harnhammar <ulfh@update.uu.se>
 0	search/1/c	=<?php			PHP script text
+!:mime	text/x-php
 0	search/1	=<?\n			PHP script text
+!:mime	text/x-php
 0	search/1	=<?\r			PHP script text
+!:mime	text/x-php
 0	search/1/b	#!\ /usr/local/bin/php	PHP script text executable
+!:mime	text/x-php
 0	search/1/b	#!\ /usr/bin/php	PHP script text executable
+!:mime	text/x-php
 
 0	string		Zend\x00		PHP script Zend Optimizer data
 

+ 2 - 2
magic/Magdir/compress

@@ -9,8 +9,8 @@
 # because it tries to uncompress it to figure out what's inside.
 
 # standard unix compress
-#0	string		\037\235	compress'd data
-#!:mime	application/x-compress
+0	string		\037\235	compress'd data
+!:mime	application/x-compress
 >2	byte&0x80	>0		block compressed
 >2	byte&0x1f	x		%d bits
 

+ 6 - 6
magic/Magdir/console

@@ -117,6 +117,12 @@
 #
 0 belong 0x37804012    V64 Nintendo 64 ROM dump
 
+# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
+# Nintendo .nds
+192	string	\044\377\256Qi\232	Nintendo DS Game ROM Image
+# Nintendo .gba
+0	string	\056\000\000\352$\377\256Qi	Nintendo Game Boy Advance ROM Image
+
 #------------------------------------------------------------------------------
 # msx: file(1) magic for MSX game cartridge dumps
 # Too simple - MPi
@@ -246,9 +252,3 @@
 >>>(0x18.l-26)	lelong		x	CRC32 0x%08x
 >>>(0x18.l-23)	string		x	"%s"
 
-# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
-# .w3g
-0	string Warcraft\ III\ recorded\ game	%s
-# .w3m
-0	string HM3W				Warcraft III map file
-

+ 1 - 1
magic/Magdir/database

@@ -234,7 +234,7 @@
 0	string		PGDMP		PostgreSQL custom database dump
 >5	byte		x		- v%d
 >6	byte		x		\b.%d
->5	beshort		<=0x100		\b-0
+>5	beshort		<0x101		\b-0
 >5	beshort		>0x100
 >>7	byte		x		\b-%d
 

+ 5 - 0
magic/Magdir/diff

@@ -2,8 +2,13 @@
 # diff:  file(1) magic for diff(1) output
 #
 0	search/1	diff\ 		diff output text
+!:mime	text/x-diff
 0	search/1	***\ 		diff output text
+!:mime	text/x-diff
 0	search/1	Only\ in\ 	diff output text
+!:mime	text/x-diff
 0	search/1	Common\ subdirectories:\ 	diff output text
+!:mime	text/x-diff
 
 0	search/1	Index:		RCS/CVS diff output text
+!:mime	text/x-diff

+ 18 - 9
magic/Magdir/elf

@@ -7,7 +7,12 @@
 #
 # What're the correct byte orders for the nCUBE and the Fujitsu VPP500?
 #
-# updated by Daniel Quinlan (quinlan@yggdrasil.com)
+# Created by: unknown
+# Modified by (1): Daniel Quinlan <quinlan@yggdrasil.com>
+# Modified by (2): Peter Tobias <tobias@server.et-inf.fho-emden.de> (core support)
+# Modified by (3): Christian 'Dr. Disk' Hechelmann <drdisk@ds9.au.s.shuttle.de> (fix of core support)
+# Modified by (4): <gerardo.cacciari@gmail.com> (VMS Itanium)
+# Modified by (5): Matthias Urlichs <smurf@debian.org> (Listing of many architectures)
 0	string		\177ELF		ELF
 >4	byte		0		invalid class
 >4	byte		1		32-bit
@@ -15,6 +20,7 @@
 >5	byte		0		invalid byte order
 >5	byte		1		LSB
 >>16	leshort		0		no file type,
+!:strength *2
 !:mime	application/octet-stream
 >>16	leshort		1		relocatable,
 !:mime	application/x-object
@@ -22,8 +28,6 @@
 !:mime	application/x-executable
 >>16	leshort		3		shared object,
 !:mime	application/x-sharedlib
-# Core handling from Peter Tobias <tobias@server.et-inf.fho-emden.de>
-# corrections by Christian 'Dr. Disk' Hechelmann <drdisk@ds9.au.s.shuttle.de>
 >>16	leshort		4		core file
 !:mime	application/x-coredump
 # Core file detection is not reliable.
@@ -79,7 +83,7 @@
 >>>48	leshort		&0x0008		(LP64),
 >>18	leshort		16		nCUBE,
 >>18	leshort		17		Fujitsu VPP500,
->>18	leshort		18		SPARC32PLUS,
+>>18	leshort		18		SPARC32PLUS - invalid byte order,
 >>18	leshort		20		PowerPC,
 >>18	leshort		22		IBM S/390,
 >>18	leshort		36		NEC V800,
@@ -210,10 +214,10 @@
 >>18	beshort		16		nCUBE,
 >>18	beshort		17		Fujitsu VPP500,
 >>18	beshort		18		SPARC32PLUS,
->>>36	belong&0xffff00	&0x000100	V8+ Required,
->>>36	belong&0xffff00	&0x000200	Sun UltraSPARC1 Extensions Required,
->>>36	belong&0xffff00	&0x000400	HaL R1 Extensions Required,
->>>36	belong&0xffff00	&0x000800	Sun UltraSPARC3 Extensions Required,
+>>>36	belong&0xffff00	0x000100	V8+ Required,
+>>>36	belong&0xffff00	0x000200	Sun UltraSPARC1 Extensions Required,
+>>>36	belong&0xffff00	0x000400	HaL R1 Extensions Required,
+>>>36	belong&0xffff00	0x000800	Sun UltraSPARC3 Extensions Required,
 >>18	beshort		20		PowerPC or cisco 4500,
 >>18	beshort		21		64-bit PowerPC or cisco 7500,
 >>18	beshort		22		IBM S/390,
@@ -228,6 +232,12 @@
 >>18	beshort		41		Alpha,
 >>18	beshort		42		Renesas SH,
 >>18	beshort		43		SPARC V9,
+>>>48	belong&0xffff00	0x000200	Sun UltraSPARC1 Extensions Required,
+>>>48	belong&0xffff00	0x000400	HaL R1 Extensions Required,
+>>>48	belong&0xffff00	0x000800	Sun UltraSPARC3 Extensions Required,
+>>>48	belong&0x3	0		total store ordering,
+>>>48	belong&0x3	1		partial store ordering,
+>>>48	belong&0x3	2		relaxed memory ordering,
 >>18	beshort		44		Siemens Tricore Embedded Processor,
 >>18	beshort		45		Argonaut RISC Core, Argonaut Technologies Inc.,
 >>18	beshort		46		Renesas H8/300,
@@ -270,7 +280,6 @@
 >>7	byte		10		(Tru64)
 >>7	byte		11		(Novell Modesto)
 >>7	byte		12		(OpenBSD)
-# VMS Itanium added by gerardo.cacciari@gmail.com
 >8      string          \2
 >>7     byte            13              (OpenVMS)
 >>7	byte		97		(ARM)

+ 38 - 0
magic/Magdir/filesystems

@@ -1266,6 +1266,34 @@
 >>>2         short   2048       AXP generated)
 >>>2         short   4096       I64 generated)
 
+# Summary: Oracle Clustered Filesystem
+# Created by: Aaron Botsis <redhat@digitalmafia.org>
+8	string		OracleCFS	Oracle Clustered Filesystem,
+>4	long		x		rev %d
+>0	long		x		\b.%d,
+>560	string		x		label: %.64s,
+>136	string		x		mountpoint: %.128s
+
+# Summary: Oracle ASM tagged volume
+# Created by: Aaron Botsis <redhat@digitalmafia.org>
+32	string		ORCLDISK	Oracle ASM Volume,
+>40	string		x		Disk Name: %0.12s
+32	string		ORCLCLRD	Oracle ASM Volume (cleared),
+>40	string		x		Disk Name: %0.12s
+
+# Oracle Clustered Filesystem - Aaron Botsis <redhat@digitalmafia.org>
+8	string		OracleCFS	Oracle Clustered Filesystem,
+>4	long		x		rev %d
+>0	long		x		\b.%d,
+>560	string		x		label: %.64s,
+>136	string		x		mountpoint: %.128s
+
+# Oracle ASM tagged volume - Aaron Botsis <redhat@digitalmafia.org>
+32	string		ORCLDISK	Oracle ASM Volume,
+>40	string		x		Disk Name: %0.12s
+32	string		ORCLCLRD	Oracle ASM Volume (cleared),
+>40	string		x		Disk Name: %0.12s
+
 # Compaq/HP RILOE floppy image
 # From: Dirk Jagdmann <doj@cubic.org>
 0	string	CPQRFBLO	Compaq/HP RILOE floppy image
@@ -1289,3 +1317,13 @@
 # really le32 operation,destination,payloadsize (but quite predictable)
 # 01 00 00 00 00 00 00 c0 00 02 00 00
 0	string		\1\0\0\0\0\0\0\300\0\2\0\0	Marvell Libertas firmware
+
+# From Eric Sandeen
+# GFS2
+0x10000         belong          0x01161970      GFS2 Filesystem
+>0x10024        belong          x               (blocksize %d,
+>0x10060        string          >\0             lockproto %s)
+
+# dvdisaster's .ecc
+# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
+0	string	*dvdisaster*	dvdisaster error correction file

+ 2 - 2
magic/Magdir/freebsd

@@ -128,10 +128,10 @@
 # What are you laughing about?
 0	lelong			011421044151	ld.so hints file (Little Endian
 >4	lelong			>0		\b, version %d)
->4	belong			<=0		\b)
+>4	belong			<1		\b)
 0	belong			011421044151	ld.so hints file (Big Endian
 >4	belong			>0		\b, version %d)
->4	belong			<=0		\b)
+>4	belong			<1		\b)
 
 #
 # Files generated by FreeBSD scrshot(1)/vidcontrol(1) utilities

+ 0 - 2
magic/Magdir/fsav

@@ -54,8 +54,6 @@
 >>>>>>>>37	string		x 	\b%-.1s
 >>>>>>>>>38	string		!:	
 >>>>>>>>>>38	string		x 	\b%-.1s
->>>>512	string		\037\213	\b, gzipped
->>>>769	string		ustar\0		\b, tarred
 >512	string		\037\213	\b, gzipped
 >769	string		ustar\0		\b, tarred
 

+ 92 - 0
magic/Magdir/games

@@ -151,3 +151,95 @@
 >4	lelong	x		containing %d lumps
 0	string	=PWAD		doom patch PWAD data
 >4	lelong	x		containing %d lumps
+
+
+# Summary: Warcraft 3 save
+# Extension: .w3g
+# Created by: "Nelson A. de Oliveira" <naoliv@gmail.com>
+0	string		Warcraft\ III\ recorded\ game	%s
+
+
+# Summary: Warcraft 3 map
+# Extension: .w3m
+# Created by: "Nelson A. de Oliveira" <naoliv@gmail.com>
+0	string		HM3W		Warcraft III map file
+
+
+# Summary: SGF Smart Game Format
+# Extension: .sgf
+# Reference: http://www.red-bean.com/sgf/
+# Created by: Eduardo Sabbatella <eduardo_sabbatella@yahoo.com.ar>
+# Modified by (1): Abel Cheung (regex, more game format)
+# FIXME: Some games don't have GM (game type)
+0	regex		\\(;.*GM\\[[0-9]{1,2}\\]	Smart Game Format
+>2	search/0x200	GM[
+>>&0	string		1]	(Go)
+>>&0	string		2]	(Othello)
+>>&0	string		3]	(chess)
+>>&0	string		4]	(Gomoku+Renju)
+>>&0	string		5]	(Nine Men's Morris)
+>>&0	string		6]	(Backgammon)
+>>&0	string		7]	(Chinese chess)
+>>&0	string		8]	(Shogi)
+>>&0	string		9]	(Lines of Action)
+>>&0	string		10]	(Ataxx)
+>>&0	string		11]	(Hex)
+>>&0	string		12]	(Jungle)
+>>&0	string		13]	(Neutron)
+>>&0	string		14]	(Philosopher's Football)
+>>&0	string		15]	(Quadrature)
+>>&0	string		16]	(Trax)
+>>&0	string		17]	(Tantrix)
+>>&0	string		18]	(Amazons)
+>>&0	string		19]	(Octi)
+>>&0	string		20]	(Gess)
+>>&0	string		21]	(Twixt)
+>>&0	string		22]	(Zertz)
+>>&0	string		23]	(Plateau)
+>>&0	string		24]	(Yinsh)
+>>&0	string		25]	(Punct)
+>>&0	string		26]	(Gobblet)
+>>&0	string		27]	(hive)
+>>&0	string		28]	(Exxit)
+>>&0	string		29]	(Hnefatal)
+>>&0	string		30]	(Kuba)
+>>&0	string		31]	(Tripples)
+>>&0	string		32]	(Chase)
+>>&0	string		33]	(Tumbling Down)
+>>&0	string		34]	(Sahara)
+>>&0	string		35]	(Byte)
+>>&0	string		36]	(Focus)
+>>&0	string		37]	(Dvonn)
+>>&0	string		38]	(Tamsk)
+>>&0	string		39]	(Gipf)
+>>&0	string		40]	(Kropki)
+
+
+# Summary: Civilization 4 video
+# Extension: .bik
+# Created by: Abel Cheung <abelcheung@gmail.com>
+0	string	BIKi	Civilization 4 Video
+
+
+##############################################
+# NetImmerse/Gamebryo game engine entries
+
+# Summary: Gamebryo game engine file
+# Extension: .nif, .kf
+# Created by: Abel Cheung <abelcheung@gmail.com>
+0		string		Gamebryo\ File\ Format,\ Version\ 	Gamebryo game engine file
+>&0		regex		[0-9a-z.]+				\b, version %s
+
+# Summary: Gamebryo game engine file
+# Extension: .kfm
+# Created by: Abel Cheung <abelcheung@gmail.com>
+0		string		;Gamebryo\ KFM\ File\ Version\ 		Gamebryo game engine animation File
+>&0		regex		[0-9a-z.]+				\b, version %s
+
+# Summary: NetImmerse game engine file
+# Extension .nif
+# Created by: Abel Cheung <abelcheung@gmail.com>
+0		string		NetImmerse\ File\ Format,\ Versio		
+>&0		string		n\ 					NetImmerse game engine file
+>>&0		regex		[0-9a-z.]+				\b, version %s
+

+ 4 - 0
magic/Magdir/gimp

@@ -34,3 +34,7 @@
 #       ('Bucky' LaDieu, nega@vt.edu)
 
 20      string          GIMP            GIMP brush data
+
+# GIMP Curves File
+# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
+0	string	#\040GIMP\040Curves\040File	GIMP curve file

+ 4 - 0
magic/Magdir/gnu

@@ -36,3 +36,7 @@
 0	string	\0LOCATE	GNU findutils locate database data
 >7	string	>\0		\b, format %s
 >7	string	02		\b (frcode)
+
+# Files produced by GNU gettext
+0	long	0xDE120495		GNU-format message catalog data
+0	long	0x950412DE		GNU-format message catalog data

+ 33 - 10
magic/Magdir/hp

@@ -201,10 +201,13 @@
 0	string		msgcat01	HP NLS message catalog,
 >8	long		>0		%d messages
 
-# addendum to /etc/magic with HP-48sx file-types by phk@data.fls.dk 1jan92
-0	string		HPHP4		HP
->5	string		8		48 binary
->5	string		9		49 binary
+# Summary: HP-48/49 calculator
+# Created by: phk@data.fls.dk
+# Modified by (1): AMAKAWA Shuhei <sa264@cam.ac.uk>
+# Modified by (2): Samuel Thibault <samuel.thibault@ens-lyon.org> (HP49 support)
+0	string		HPHP		HP
+>4	string		48		48 binary
+>4	string		49		49 binary
 >7	byte		>64		- Rev %c
 >8	leshort		0x2911		(ADR)
 >8	leshort		0x2933		(REAL)
@@ -231,7 +234,7 @@
 >8	leshort		0x2e6d		(LNAME)
 >8	leshort		0x2e92		(XLIB)
 
-0	search/1	%%HP:		HP text
+0	string		%%HP:		HP text
 >6	string		T(0)		- T(0)
 >6	string		T(1)		- T(1)
 >6	string		T(2)		- T(2)
@@ -242,9 +245,31 @@
 >14	string		F(.)		F(.);
 >14	string		F(,)		F(,);
 
-0	string		HP3		HP
->3	string		8		38
->3	string		9		39
+
+# Summary: HP-38/39 calculator
+# Created by: Samuel Thibault <samuel.thibault@ens-lyon.org>
+0	string		HP3
+>3	string		8		HP 38
+>3	string		9		HP 39
+>4	string		Bin		binary
+>4	string		Asc		ASCII
+>7	string		A		(Directory List)
+>7	string		B		(Zaplet)
+>7	string		C		(Note)
+>7	string		D		(Program)
+>7	string		E		(Variable)
+>7	string		F		(List)
+>7	string		G		(Matrix)
+>7	string		H		(Library)
+>7	string		I		(Target List)
+>7	string		J		(ASCII Vector specification)
+>7	string		K		(wildcard)
+
+# Summary: HP-38/39 calculator
+# Created by: Samuel Thibault <samuel.thibault@ens-lyon.org>
+0	string		HP3
+>3	string		8		HP 38
+>3	string		9		HP 39
 >4	string		Bin		binary
 >4	string		Asc		ASCII
 >7	string		A		(Directory List)
@@ -409,6 +434,4 @@
 >>>>>>>>>0xC4	belong	33		- received SIGXCPU
 >>>>>>>>>0xC4	belong	34		- received SIGXFSZ
 
-# From: AMAKAWA Shuhei <sa264@cam.ac.uk>
-#0	string	HPHP49-			HP49 binary
 

+ 28 - 16
magic/Magdir/images

@@ -75,11 +75,9 @@
 #
 # 137 P N G \r \n ^Z \n [4-byte length] H E A D [HEAD data] [HEAD crc] ...
 #
-0	string		\x89PNG		PNG image data,
+0	string		\x89PNG\x0d\x0a\x1a\x0a		PNG image
 !:mime	image/png
->4	belong		!0x0d0a1a0a	CORRUPTED,
->4	belong		0x0d0a1a0a
->>16	belong		x		%ld x
+>>16	belong		x		\b, %ld x
 >>20	belong		x		%ld,
 >>24	byte		x		%d-bit
 >>25	byte		0		grayscale,
@@ -90,7 +88,6 @@
 #>>26	byte		0		deflate/32K,
 >>28	byte		0		non-interlaced
 >>28	byte		1		interlaced
-1	string		PNG		PNG image data, CORRUPTED
 
 # possible GIF replacements; none yet released!
 # (Greg Roelofs, newt@uchicago.edu)
@@ -160,9 +157,6 @@
 
 # CGM image files
 0	string		BEGMF		clear text Computer Graphics Metafile
-# XXX - questionable magic
-#0	beshort&0xffe0	0x0020		binary Computer Graphics Metafile
-#0	beshort		0x3020		character Computer Graphics Metafile
 
 # MGR bitmaps  (Michael Haardt, u31b3hs@pool.informatik.rwth-aachen.de)
 0	string	yz	MGR bitmap, modern format, 8-bit aligned
@@ -184,15 +178,22 @@
 
 
 # PC bitmaps (OS/2, Windows BMP files)  (Greg Roelofs, newt@uchicago.edu)
-0	string		BM		PC bitmap data
+0	string		BM
+>14	leshort		12		PC bitmap, OS/2 1.x format
 !:mime	image/x-ms-bmp
->14	leshort		12		\b, OS/2 1.x format
 >>18	leshort		x		\b, %d x
 >>20	leshort		x		%d
->14	leshort		64		\b, OS/2 2.x format
+>14	leshort		64		PC bitmap, OS/2 2.x format
+!:mime	image/x-ms-bmp
 >>18	leshort		x		\b, %d x
 >>20	leshort		x		%d
->14	leshort		40		\b, Windows 3.x format
+>14	leshort		40		PC bitmap, Windows 3.x format
+!:mime	image/x-ms-bmp
+>>18	lelong		x		\b, %d x
+>>22	lelong		x		%d x
+>>28	leshort		x		%d
+>14	leshort		128		PC bitmap, Windows NT/2000 format
+!:mime	image/x-ms-bmp
 >>18	lelong		x		\b, %d x
 >>22	lelong		x		%d x
 >>28	leshort		x		%d
@@ -292,7 +293,6 @@
 
 # other images
 0	string	This\ is\ a\ BitMap\ file	Lisp Machine bit-array-file
-#0	string		=!!		Bennet Yee's "face" format
 
 # From SunOS 5.5.1 "/etc/magic" - appeared right before Sun raster image
 # stuff.
@@ -539,10 +539,18 @@
 # http://www.dalibor.cz/minolta/raw_file_format.htm
 0	string	\000MRM			Minolta Dimage camera raw image data
 
-# From: stephane.loeuillet@tiscali.f
-# http://www.djvuzone.org/
-0	string	AT&TFORM		DjVu Image file
+# Summary: DjVu image / document
+# Extension: .djvu
+# Reference: http://djvu.org/docs/DjVu3Spec.djvu
+# Submitted by: Stephane Loeuillet <stephane.loeuillet@tiscali.fr>
+# Modified by (1): Abel Cheung <abelcheung@gmail.com>
+0	string	AT&TFORM
 !:mime	image/vnd.djvu
+>12	string	DJVM		DjVu multiple page document
+>12	string	DJVU		DjVu image or single page document
+>12	string	DJVI		DjVu shared document
+>12	string	THUM		DjVu page thumbnails
+
 
 # From Marc Espie
 0	lelong	20000630		OpenEXR image data
@@ -588,3 +596,7 @@
 0	string	\xed\xfe\xda\xbe	Cytovision FLEX file
 0	string	\xed\xab\xed\xfe	Cytovision FLEX file
 0	string	\xad\xfd\xea\xad	Cytovision RATS file
+
+# Wavelet Scalar Quantization format used in gray-scale fingerprint images
+# From Tano M Fotang <mfotang@quanteq.com>
+0	string	\xff\xa0\xff\xa8\x00	Wavelet Scalar Quantization image data

+ 16 - 1
magic/Magdir/linux

@@ -83,7 +83,7 @@
 # Linux kernel boot images (i386 arch) (Wolfram Kleff)
 514	string		HdrS		Linux kernel
 >510	leshort		0xAA55		x86 boot executable
->>518	leshort		>=0x200
+>>518	leshort		>0x1ff
 >>529	byte		0		zImage,
 >>>529	byte		1		bzImage,
 >>>(526.s+0x200) string	>\0		version %s,
@@ -231,6 +231,14 @@
 0x618		 string	LVM2\ 001	LVM2 (Linux Logical Volume Manager)
 >(0x614.l+0x600) string	>\0		, UUID: %s
 
+# LVM snapshot
+# from Jason Farrel
+0	string	SnAp	LVM Snapshot (CopyOnWrite store)
+>4	lelong	!0	- valid,
+>4	lelong	0	- invalid,
+>8	lelong	x	version %d,
+>12	lelong	x	chunk_size %d
+
 # SE Linux policy database
 0	lelong	0xf97cff8c		SE Linux policy
 >16	lelong	x			v%d
@@ -247,3 +255,10 @@
 >72	string	x		%s]
 >168	string	x		UUID: %s
 
+
+# Summary: Xen saved domain file
+# Created by: Radek Vokal <rvokal@redhat.com>
+0	string		LinuxGuestRecord	Xen saved domain
+>20	search/256	(name			
+>>&1	string		x			(name %s)
+

+ 10 - 5
magic/Magdir/lisp

@@ -12,12 +12,19 @@
 #>2	search/2048	\r		Windows INF file
 
 0	search/256	(if\ 			Lisp/Scheme program text
+!:mime	text/x-lisp
 0	search/256	(setq\ 			Lisp/Scheme program text
+!:mime	text/x-lisp
 0	search/256	(defvar\ 		Lisp/Scheme program text
+!:mime	text/x-lisp
 0	search/256	(defparam\ 		Lisp/Scheme program text
+!:mime	text/x-lisp
 0	search/256	(defun\  		Lisp/Scheme program text
+!:mime	text/x-lisp
 0	search/256	(autoload\ 		Lisp/Scheme program text
+!:mime	text/x-lisp
 0	search/256	(custom-set-variables\ 	Lisp/Scheme program text
+!:mime	text/x-lisp
 
 # Emacs 18 - this is always correct, but not very magical.
 0	string	\012(			Emacs v18 byte-compiled Lisp data
@@ -31,14 +38,12 @@
 !:mime	application/x-elc		
 
 # Files produced by CLISP Common Lisp From: Bruno Haible <haible@ilog.fr>
-0	string	(SYSTEM::VERSION\040'	CLISP byte-compiled Lisp program
+0	string	(SYSTEM::VERSION\040'	CLISP byte-compiled Lisp program (pre 2004-03-27)
+0	string	(|SYSTEM|::|VERSION|\040'	CLISP byte-compiled Lisp program text
+
 0	long	0x70768BD2		CLISP memory image data
 0	long	0xD28B7670		CLISP memory image data, other endian
 
-# Files produced by GNU gettext
-0	long	0xDE120495		GNU-format message catalog data
-0	long	0x950412DE		GNU-format message catalog data
-
 #.com and .bin for MIT scheme 
 0	string	\372\372\372\372	MIT scheme (library?)
 

+ 8 - 1
magic/Magdir/misctools

@@ -10,5 +10,12 @@
 4	string	gtktalog		GNOME Catalogue (gtktalog)
 >13	string	>\0			version %s
 
-# From: Tomasz Trojanowski <tomek@uninet.com.pl>
+# Summary: Libtool library file
+# Extension: .la
+# Submitted by: Tomasz Trojanowski <tomek@uninet.com.pl>
 0	search/80	.la\ -\ a\ libtool\ library\ file	libtool library file
+
+# Summary: Libtool object file
+# Extension: .lo
+# Submitted by: Abel Cheung <abelcheung@gmail.com>
+0	search/80	.lo\ -\ a\ libtool\ object\ file	libtool object file

+ 119 - 146
magic/Magdir/msdos

@@ -7,9 +7,13 @@
 # updated by Joerg Jenderek
 0	string	@			
 >1	string/cB	\ echo\ off	MS-DOS batch file text
+!:mime	text/x-msdos-batch
 >1	string/cB	echo\ off	MS-DOS batch file text
+!:mime	text/x-msdos-batch
 >1	string/cB	rem\ 		MS-DOS batch file text
+!:mime	text/x-msdos-batch
 >1	string/cB	set\ 		MS-DOS batch file text
+!:mime	text/x-msdos-batch
 
 
 # OS/2 batch files are REXX. the second regex is a bit generic, oh well
@@ -39,14 +43,15 @@
 #
 # Required OS version and subsystem version were 4.0 on some NT 3.51
 # executables built with Visual C++ 4.0, so it's not clear that
-# they're interesting.  The user version was 0.0, but there's
+# they're interesting.	The user version was 0.0, but there's
 # probably some linker directive to set it.  The linker version was
 # 3.0, except for one ".exe" which had it as 4.20 (same damn linker!).
 #
 # many of the compressed formats were extraced from IDARC 1.23 source code
 #
-0	string	MZ		MS-DOS executable
+0	string	MZ
 !:mime	application/x-dosexec
+>0x18  leshort <0x40 MS-DOS executable
 >0 string MZ\0\0\0\0\0\0\0\0\0\0PE\0\0 \b, PE for MS Windows
 >>&18	leshort&0x2000	>0	(DLL)
 >>&88	leshort		0	(unknown subsystem)
@@ -72,27 +77,35 @@
 !:mime	application/zip
 
 >0x18  leshort >0x3f
->>(0x3c.l) string PE\0\0 PE 
+>>(0x3c.l) string PE\0\0 PE
+>>>(0x3c.l+25) byte		1 \b32 executable
+>>>(0x3c.l+25) byte		2 \b32+ executable
 # hooray, there's a DOS extender using the PE format, with a valid PE
 # executable inside (which just prints a message and exits if run in win)
->>>(8.s*16) string 32STUB for MS-DOS, 32rtm DOS extender
->>>(8.s*16) string !32STUB for MS Windows
->>>>(0x3c.l+22)	leshort&0x2000	>0	(DLL)
->>>>(0x3c.l+92)	leshort		0	(unknown subsystem)
->>>>(0x3c.l+92)	leshort		1	(native)
->>>>(0x3c.l+92)	leshort		2	(GUI)
->>>>(0x3c.l+92)	leshort		3	(console)
->>>>(0x3c.l+92)	leshort		7	(POSIX)
->>>>(0x3c.l+4)	leshort		0x0	unknown processor
->>>>(0x3c.l+4)	leshort		0x14c	Intel 80386
->>>>(0x3c.l+4)	leshort		0x166	MIPS R4000
->>>>(0x3c.l+4)	leshort		0x184	Alpha
->>>>(0x3c.l+4)	leshort		0x268	Motorola 68000
->>>>(0x3c.l+4)	leshort		0x1f0	PowerPC
->>>>(0x3c.l+4)	leshort		0x290	PA-RISC
->>>>(0x3c.l+22)	leshort&0x0100	>0	32-bit
->>>>(0x3c.l+22)	leshort&0x1000	>0	system file
->>>>(0x3c.l+232)	lelong	>0	Mono/.Net assembly
+>>>(0x3c.l+92)	leshort		<10
+>>>>(8.s*16) string 32STUB for MS-DOS, 32rtm DOS extender
+>>>>(8.s*16) string !32STUB for MS Windows
+>>>>>(0x3c.l+22)	leshort&0x2000	>0	(DLL)
+>>>>>(0x3c.l+92)	leshort		0	(unknown subsystem)
+>>>>>(0x3c.l+92)	leshort		1	(native)
+>>>>>(0x3c.l+92)	leshort		2	(GUI)
+>>>>>(0x3c.l+92)	leshort		3	(console)
+>>>>>(0x3c.l+92)	leshort		7	(POSIX)
+>>>(0x3c.l+92)	leshort		10	(EFI application)
+>>>(0x3c.l+92)	leshort		11	(EFI boot service driver)
+>>>(0x3c.l+92)	leshort		12	(EFI runtime driver)
+>>>(0x3c.l+92)	leshort		13	(XBOX)
+>>>(0x3c.l+4)	leshort		0x0	unknown processor
+>>>(0x3c.l+4)	leshort		0x14c	Intel 80386
+>>>(0x3c.l+4)	leshort		0x166	MIPS R4000
+>>>(0x3c.l+4)	leshort		0x184	Alpha
+>>>(0x3c.l+4)	leshort		0x268	Motorola 68000
+>>>(0x3c.l+4)	leshort		0x1f0	PowerPC
+>>>(0x3c.l+4)	leshort		0x290	PA-RISC
+>>>(0x3c.l+4)	leshort		0x200	Intel Itanium
+>>>(0x3c.l+22)	leshort&0x0100	>0	32-bit
+>>>(0x3c.l+22)	leshort&0x1000	>0	system file
+>>>(0x3c.l+232) lelong	>0	Mono/.Net assembly
 
 >>>>(0x3c.l+0xf8)	string		UPX0 \b, UPX compressed
 >>>>(0x3c.l+0xf8)	search/0x140	PEC2 \b, PECompact2 compressed
@@ -121,6 +134,8 @@
 >>>>&(0x3c.l+0xf8)	search/0x100	SharedD \b, Microsoft Installer self-extracting archive
 >>>>0x30		string		Inno \b, InnoSetup self-extracting archive
 
+>>(0x3c.l) string !PE\0\0 MS-DOS executable
+
 >>(0x3c.l)		string		NE \b, NE
 >>>(0x3c.l+0x36)	byte		0 (unknown OS)
 >>>(0x3c.l+0x36)	byte		1 for OS/2 1.x
@@ -182,7 +197,7 @@
 >>>(4.s*512)	leshort !0x014c \b, MZ for MS-DOS
 # header data too small for extended executable
 >2		long	!0
->>0x18		leshort	<0x40
+>>0x18		leshort <0x40
 >>>(4.s*512)	leshort !0x014c
 
 >>>>&(2.s-514)	string	!LE
@@ -212,31 +227,31 @@
 
 # .EXE formats (Greg Roelofs, newt@uchicago.edu)
 #
->0x35   string  \x8e\xc0\xb9\x08\x00\xf3\xa5\x4a\x75\xeb\x8e\xc3\x8e\xd8\x33\xff\xbe\x30\x00\x05 \b, aPack compressed
+>0x35	string	\x8e\xc0\xb9\x08\x00\xf3\xa5\x4a\x75\xeb\x8e\xc3\x8e\xd8\x33\xff\xbe\x30\x00\x05 \b, aPack compressed
 >0xe7	string	LH/2\ Self-Extract \b, %s
 >0x1c	string	diet \b, diet compressed
 >0x1c	string	LZ09 \b, LZEXE v0.90 compressed
 >0x1c	string	LZ91 \b, LZEXE v0.91 compressed
->0x1c   string  tz \b, TinyProg compressed
+>0x1c	string	tz \b, TinyProg compressed
 >0x1e	string	PKLITE \b, %s compressed
->0x64   string  W\ Collis\0\0 \b, Compack compressed
+>0x64	string	W\ Collis\0\0 \b, Compack compressed
 >0x24	string	LHa's\ SFX \b, LHa self-extracting archive
 !:mime	application/x-lha
 >0x24	string	LHA's\ SFX \b, LHa self-extracting archive
 !:mime	application/x-lha
->0x24   string  \ $ARX \b, ARX self-extracting archive
->0x24   string  \ $LHarc \b, LHarc self-extracting archive
->0x20   string  SFX\ by\ LARC \b, LARC self-extracting archive
+>0x24	string	\ $ARX \b, ARX self-extracting archive
+>0x24	string	\ $LHarc \b, LHarc self-extracting archive
+>0x20	string	SFX\ by\ LARC \b, LARC self-extracting archive
 >1638	string	-lh5- \b, LHa self-extracting archive v2.13S
->0x17888 string	Rar! \b, RAR self-extracting archive
->0x40   string aPKG \b, aPackage self-extracting archive
+>0x17888 string Rar! \b, RAR self-extracting archive
+>0x40	string aPKG \b, aPackage self-extracting archive
 
->32      string AIN
->>35     string 2              \b, AIN 2.x compressed
->>35     string <2             \b, AIN 1.x compressed
->>35     string >2             \b, AIN 1.x compressed
->28      string UC2X           \b, UCEXE compressed
->28      string WWP\           \b, WWPACK compressed
+>32	 string AIN
+>>35	 string 2		\b, AIN 2.x compressed
+>>35	 string <2		\b, AIN 1.x compressed
+>>35	 string >2		\b, AIN 1.x compressed
+>28	 string UC2X		\b, UCEXE compressed
+>28	 string WWP\  		\b, WWPACK compressed
 
 # skip to the end of the exe
 >(4.s*512)	long	x 
@@ -263,15 +278,15 @@
 
 # TELVOX Teleinformatica CODEC self-extractor for OS/2:
 >49801	string	\x79\xff\x80\xff\x76\xff	\b, CODEC archive v3.21
->>49824	leshort		=1			\b, 1 file
->>49824	leshort		>1			\b, %u files
+>>49824 leshort		=1			\b, 1 file
+>>49824 leshort		>1			\b, %u files
 
 # .COM formats (Daniel Quinlan, quinlan@yggdrasil.com)
 # Uncommenting only the first two lines will cover about 2/3 of COM files,
 # but it isn't feasible to match all COM files since there must be at least
 # two dozen different one-byte "magics".
 #0	byte		0xe9		DOS executable (COM)
-#>0x1FE	leshort		0xAA55		\b, boot code
+#>0x1FE leshort		0xAA55		\b, boot code
 >6	string		SFX\ of\ LHarc	(%s)
 0	belong	0xffffffff		DOS executable (device driver)
 #CMD640X2.SYS
@@ -297,22 +312,22 @@
 #0	byte		0x8c		DOS executable (COM)
 # 0xeb conflicts with "sequent" magic
 #0	byte		0xeb		DOS executable (COM)
-#>0x1FE	leshort		0xAA55		\b, boot code
+#>0x1FE leshort		0xAA55		\b, boot code
 #>85	string		UPX		\b, UPX compressed
 #>4	string		\ $ARX		\b, ARX self-extracting archive
 #>4	string		\ $LHarc	\b, LHarc self-extracting archive
-#>0x20e	string		SFX\ by\ LARC	\b, LARC self-extracting archive
+#>0x20e string		SFX\ by\ LARC	\b, LARC self-extracting archive
 #0	byte		0xb8		COM executable
 # modified by Joerg Jenderek
->1	lelong          !0x21cd4cff	for DOS
+>1	lelong		!0x21cd4cff	for DOS
 # http://syslinux.zytor.com/comboot.php
 # (32-bit COMBOOT) programs *.C32 contain 32-bit code and run in flat-memory 32-bit protected mode
 # start with assembler instructions mov eax,21cd4cffh
->1	lelong          0x21cd4cff	(32-bit COMBOOT)
+>1	lelong		0x21cd4cff	(32-bit COMBOOT)
 0	string	\x81\xfc		
 >4	string	\x77\x02\xcd\x20\xb9	
->>36	string	UPX! 			FREE-DOS executable (COM), UPX compressed
-252	string Must\ have\ DOS\ version	DR-DOS executable (COM)
+>>36	string	UPX!			FREE-DOS executable (COM), UPX compressed
+252	string Must\ have\ DOS\ version DR-DOS executable (COM)
 # GRR search is not working
 #2	search/28	\xcd\x21	COM executable for MS-DOS
 #WHICHFAT.cOM
@@ -349,14 +364,6 @@
 #0	byte		0xf0		MS-DOS program library data
 #
 
-#
-# Windows Registry files.
-# updated by Joerg Jenderek
-0	string		regf		Windows NT/XP registry file
-0	string		CREG		Windows 95/98/ME registry file
-0	string		SHCC3		Windows 3.1 registry file
-
-
 # AAF files:
 # <stuartc@rd.bbc.co.uk> Stuart Cunningham
 0	string	\320\317\021\340\241\261\032\341AAFB\015\000OM\006\016\053\064\001\001\001\377			AAF legacy file using MS Structured Storage
@@ -378,7 +385,7 @@
 0	belong	0x31be0000			Microsoft Word Document
 !:mime	application/msword
 #
-0       string  PO^Q`				Microsoft Word 6.0 Document
+0	string	PO^Q`				Microsoft Word 6.0 Document
 !:mime	application/msword
 #
 0	string	\376\067\0\043			Microsoft Office Document
@@ -410,7 +417,7 @@
 >4	belong	0x07800100	fm3 or fmb document data
 >4	belong	0x07800000	fm3 or fmb document data
 #
-0	belong	0x00000200 	Lotus 1-2-3
+0	belong	0x00000200	Lotus 1-2-3
 !:mime	application/x-123
 >4	belong	0x06040600	wk1 document data
 >4	belong	0x06800200	fmt document data
@@ -420,24 +427,21 @@
 !:mime	application/vnd.lotus-wordpro
 
 
-# Help files
-0	string	?_\3\0		MS Windows Help Data
-
-#  DeIsL1.isu what this is I don't know
-0	string	\161\250\000\000\001\002	DeIsL1.isu whatever that is
+# Summary: Script used by InstallScield to uninstall applications
+# Extension: .isu
+# Submitted by: unknown
+# Modified by (1): Abel Cheung <abelcheung@gmail.com> (replace useless entry)
+0		string		\x71\xa8\x00\x00\x01\x02
+>12		string		Stirling\ Technologies,		InstallShield Uninstall Script
 
 # Winamp .avs
-#0	string	Nullsoft\ AVS\ Preset\ \060\056\061\032	A plug in for Winamp ms-windows Freeware media player
+#0	string	Nullsoft\ AVS\ Preset\ \060\056\061\032 A plug in for Winamp ms-windows Freeware media player
 0	string	Nullsoft\ AVS\ Preset\ 	Winamp plug in
 
-# Hyper terminal:
-0	string	HyperTerminal\ 	hyperterm
->15	string	1.0\ --\ HyperTerminal\ data\ file	MS-windows Hyperterminal
-
 # Windows Metafont .WMF
-0       string  \327\315\306\232        ms-windows metafont .wmf
-0       string  \002\000\011\000        ms-windows metafont .wmf
-0       string  \001\000\011\000        ms-windows metafont .wmf
+0	string	\327\315\306\232	ms-windows metafont .wmf
+0	string	\002\000\011\000	ms-windows metafont .wmf
+0	string	\001\000\011\000	ms-windows metafont .wmf
 
 #tz3 files whatever that is (MS Works files)
 0	string	\003\001\001\004\070\001\000\000	tz3 ms-works file
@@ -457,16 +461,6 @@
 0	string	MDIF\032\000\010\000\000\000\372\046\100\175\001\000\001\036\001\000 MS Windows special zipped file
 
 
-# Windows help file FTG FTS
-0	string	\164\146\115\122\012\000\000\000\001\000\000\000	MS Windows help cache
-
-# grp old windows 3.1 group files
-0 string  \120\115\103\103	MS Windows 3.1 group files
-
-
-# lnk files windows symlinks
-0	string	\114\000\000\000\001\024\002\000\000\000\000\000\300\000\000\000\000\000\000\106	MS Windows shortcut
-
 #ico files
 0	string	\102\101\050\000\000\000\056\000\000\000\000\000\000\000	Icon for MS Windows
 
@@ -493,18 +487,27 @@
 # then there is a copyright notice
 
 
-# recycled/info the windows trash bin index
-9	string	\000\000\000\030\001\000\000\000 MS Windows recycled bin info
+# Windows Recycle Bin record file (named INFO2)
+# By Abel Cheung (abelcheung AT gmail dot com)
+# Version 4 always has 280 bytes (0x118) per record, version 5 has 800 bytes
+# Since Vista uses another structure, INFO2 structure probably won't change
+# anymore. Detailed analysis in:
+# http://www.cybersecurityinstitute.biz/downloads/INFO2.pdf
+0	lelong		0x00000004
+>12	lelong		0x00000118	Windows Recycle Bin INFO2 file (Win98 or below)
+
+0	lelong		0x00000005
+>12	lelong		0x00000320	Windows Recycle Bin INFO2 file (Win2k - WinXP)
 
 
 ##### put in Either Magic/font or Magic/news
-# Acroread or something  files wrongly identified as G3  .pfm
+# Acroread or something	 files wrongly identified as G3	 .pfm
 # these have the form \000 \001 any? \002 \000 \000
 # or \000 \001 any? \022 \000 \000
-#0	string  \000\001 pfm?
-#>3	string  \022\000\000Copyright\  yes
-#>3	string  \002\000\000Copyright\  yes
-#>3	string  >\0     oops, not a font file. Cancel that.
+#0	string	\000\001 pfm?
+#>3	string	\022\000\000Copyright\	yes
+#>3	string	\002\000\000Copyright\	yes
+#>3	string	>\0	oops, not a font file. Cancel that.
 #it clashes with ttf files so put it lower down.
 
 # From Doug Lee via a FreeBSD pr
@@ -552,7 +555,7 @@
 !:mime	application/vnd.ms-tnef
 
 # HtmlHelp files (.chm)
-0	string  ITSF\003\000\000\000\x60\000\000\000\001\000\000\000	MS Windows HtmlHelp Data
+0	string	ITSF\003\000\000\000\x60\000\000\000\001\000\000\000	MS Windows HtmlHelp Data
 
 # GFA-BASIC (Wolfram Kleff)
 2	string		GFA-BASIC3	GFA-BASIC 3 data
@@ -567,8 +570,8 @@
 
 # InstallShield Cabinet files
 0	string		ISc(		InstallShield Cabinet archive data
->5	byte&0xf0	=0x60 		version 6,
->5	byte&0xf0	!0x60 		version 4/5,
+>5	byte&0xf0	=0x60		version 6,
+>5	byte&0xf0	!0x60		version 4/5,
 >(12.l+40)	lelong	x		%u files
 
 # Windows CE package files
@@ -582,57 +585,27 @@
 >20	lelong		10004		\b, Hitachi SH3E
 >20	lelong		10005		\b, Hitachi SH4
 >20	lelong		70001		\b, ARM 7TDMI
->52	leshort		1 		\b, 1 file
->52	leshort		>1 		\b, %u files
->56	leshort		1 		\b, 1 registry entry
->56	leshort		>1 		\b, %u registry entries
-
-# Outlook Personal Folders
-0	lelong	0x4E444221	Microsoft Outlook binary email folder
->10	leshort 0x0e		(Outlook <=2002)
->10	leshort 0x17		(Outlook >=2003)
-
-
-# From: Dirk Jagdmann <doj@cubic.org>
-0	lelong	0x00035f3f	Windows 3.x help file
-
-# Christophe Monniez
-0	string	Client\ UrlCache\ MMF 	Microsoft Internet Explorer Cache File
->20	string	>\0			Version %s
-0	string	\xCF\xAD\x12\xFE	Microsoft Outlook Express DBX File
->4	byte	=0xC5			Message database
->4	byte	=0xC6			Folder database
->4	byte	=0xC7			Accounts informations
->4	byte	=0x30			Offline database
+>52	leshort		1		\b, 1 file
+>52	leshort		>1		\b, %u files
+>56	leshort		1		\b, 1 registry entry
+>56	leshort		>1		\b, %u registry entries
 
 
 # Windows Enhanced Metafile (EMF)
 # See msdn.microsoft.com/archive/en-us/dnargdi/html/msdn_enhmeta.asp 
-# for further information. Note that "0 lelong 1" should be true i.e.
-# the first double word in the file should be 1. With the extended
-# syntax available by some file commands you could write:
-# 0 lelong 1
-# &40 ulelong 0x464D4520 Windows Enhanced Metafile (EMF) image data
-#40	ulelong 0x464D4520	Windows Enhanced Metafile (EMF) image data
-#>44	ulelong x		version 0x%x.
-# If the description has a length greater than zero, it exists and is 
-# found at offset (*64).
-#>64	ulelong >0		Description available at offset 0x%x
-#>>60	ulelong	>0		(length 0x%x)
-# Note it would be better to print out the description, which is found 
-# as below. Unfortunately the following only prints out the first couple
-# of characters instead of all the "description length"
-# number of characters -- indicated by the ulelong at offset 60.
-#>>(64.l)  lestring16 >0 Description: %15.15s
+# for further information.
+0	ulelong 1
+>40	string	\ EMF		Windows Enhanced Metafile (EMF) image data
+>>44	ulelong x		version 0x%x
 
 # From: Alex Beregszaszi <alex@fsn.hu>
 0	string	COWD		VMWare3
->4	byte	3	 	disk image
+>4	byte	3		disk image
 >>32	lelong	x		(%d/
 >>36	lelong	x		\b%d/
 >>40	lelong	x		\b%d)
->4	byte	2	 	undoable disk image
->>32	string  >\0		(%s)
+>4	byte	2		undoable disk image
+>>32	string	>\0		(%s)
 
 0	string	VMDK		 VMware4 disk image
 0	string	KDMV		 VMware4 disk image
@@ -642,39 +615,39 @@
 # Lines written by Friedrich Schwittay (f.schwittay@yousable.de)
 # Made by reading sources and doing trial and error on existing
 # qcow files
-0       string  QFI     Qemu Image, Format: Qcow
+0	string	QFI	Qemu Image, Format: Qcow
 
 # Uncomment the following line to display Magic (only used for debugging
 # this magic number)
-#>0     string  x       , Magic: %s
+#>0	string	x	, Magic: %s
 
 # There are currently 2 Versions: "1" and "2"
 # I do not use Version 2 and therefor branch here
 # but can assure: it works (tested on both versions)
 # Also my Qemu 0.9.0 which uses this Version 2 refuses
 # to start in its bios
->0x04   belong  2       , Version: 2
->0x04   belong  1       , Version: 1
+>0x04	belong	2	, Version: 2
+>0x04	belong	1	, Version: 1
 
 # Using the existence of the Backing File Offset to Branch or not
 # to read Backing File Information
->>0xc    belong  >0      , Backing File( Offset: %lu
->>>(0xc.L)       string >\0     , Path: %s
+>>0xc	 belong	 >0	 , Backing File( Offset: %lu
+>>>(0xc.L)	 string >\0	, Path: %s
 
 # Didn't get the trick here how qemu stores the "Size" at this Position
 # There is actually something stored but nothing makes sense
 # The header in the sources talks about it
-#>>>16   lelong  x       , Size: %lu
+#>>>16	 lelong	 x	 , Size: %lu
 
 # Modification time of the Backing File
 # Really useful if you want to know if your backing
 # file is still usable together with this image
->>>20    bedate x       , Mtime: %s )
+>>>20	 bedate x	, Mtime: %s )
 
 # Don't know how to calculate in Magicfiles
 # Also: this Information is not reliably
-#       stored in image-files
->>24     lelong  x       , Disk Size could be: %d * 256 bytes
+#	stored in image-files
+>>24	 lelong	 x	 , Disk Size could be: %d * 256 bytes
 
 0	string	QEVM		QEMU's suspend to disk image
 
@@ -688,14 +661,14 @@
 # False positive with PPT (also currently this string is too long)
 #0	string	\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E\x00\x03\x00\xFE\xFF\x09\x00\x06	Microsoft Installer
 0	string	\320\317\021\340\241\261\032\341	Microsoft Office Document
-#>48	byte	0x1B	                                Excel Document
-#!:mime	application/vnd.ms-excel
+#>48	byte	0x1B					Excel Document
+#!:mime application/vnd.ms-excel
 >546	string	bjbj			Microsoft Word Document
 !:mime	application/msword
 >546	string	jbjb			Microsoft Word Document
 !:mime	application/msword
 
-0       string	\224\246\056		Microsoft Word Document
+0	string	\224\246\056		Microsoft Word Document
 !:mime	application/msword
 
 512	string	R\0o\0o\0t\0\ \0E\0n\0t\0r\0y	Microsoft Word Document
@@ -709,19 +682,19 @@
 >48	string x			version %.3s
 
 # Type: Microsoft DirectDraw Surface
-# URL:  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/DDSFileReference/ddsfileformat.asp
+# URL:	http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/DDSFileReference/ddsfileformat.asp
 # From: Morten Hustveit <morten@debian.org>
-0	string	DDS\040\174\000\000\000	Microsoft DirectDraw Surface (DDS),
+0	string	DDS\040\174\000\000\000 Microsoft DirectDraw Surface (DDS),
 >16	lelong	>0			%hd x
 >12	lelong	>0			%hd,
 >84	string	x			%.4s
 
 # Type: Microsoft Document Imaging Format (.mdi)
-# URL:  http://en.wikipedia.org/wiki/Microsoft_Document_Imaging_Format
+# URL:	http://en.wikipedia.org/wiki/Microsoft_Document_Imaging_Format
 # From: Daniele Sempione <scrows@oziosi.org>
 0	short	0x5045			Microsoft Document Imaging Format
 
 # MS eBook format (.lit)
-0	string  ITOLITLS		Microsoft Reader eBook Data
+0	string	ITOLITLS		Microsoft Reader eBook Data
 >8	lelong	x			\b, version %u
 !:mime					application/x-ms-reader

+ 7 - 7
magic/Magdir/perl

@@ -5,19 +5,19 @@
 # Keith Waclena <keith@cerberus.uchicago.edu>
 # Send additions to <perl5-porters@perl.org>
 0	search/1/b	#!\ /bin/perl			Perl script text executable
-!:mime	application/x-perl
+!:mime	text/x-perl
 0	search/1	eval\ "exec\ /bin/perl		Perl script text
-!:mime	application/x-perl
+!:mime	text/x-perl
 0	search/1/b	#!\ /usr/bin/perl		Perl script text executable
-!:mime	application/x-perl
+!:mime	text/x-perl
 0	search/1	eval\ "exec\ /usr/bin/perl	Perl script text
-!:mime	application/x-perl
+!:mime	text/x-perl
 0	search/1/b	#!\ /usr/local/bin/perl		Perl script text executable
-!:mime	application/x-perl
+!:mime	text/x-perl
 0	search/1	eval\ "exec\ /usr/local/bin/perl	Perl script text
-!:mime	application/x-perl
+!:mime	text/x-perl
 0	search/1	eval\ '(exit\ $?0)'\ &&\ eval\ 'exec	Perl script text
-!:mime	application/x-perl
+!:mime	text/x-perl
 
 
 # by Dmitry V. Levin and Alexey Tourbin

+ 6 - 4
magic/Magdir/printer

@@ -35,11 +35,13 @@
 >>>20   long            >0              TIFF starts at byte %d
 >>>>24  long            >0              length %d
 
-# Adobe's PostScript Printer Description (PPD) files
-#       Yves Arrouye <arrouye@marin.fdn.fr>
+# Summary: Adobe's PostScript Printer Description File
+# Extension: .ppd
+# Reference: http://partners.adobe.com/public/developer/en/ps/5003.PPD_Spec_v4.3.pdf, Section 3.8
+# Submitted by: Yves Arrouye <arrouye@marin.fdn.fr>
 #
-0      string          *PPD-Adobe:    PPD file
->13    string          x              \b, ve
+0	string		*PPD-Adobe:\x20	PPD file
+>&0	string		x		\b, version %s
 
 # HP Printer Job Language
 0	string		\033%-12345X@PJL	HP Printer Job Language data

+ 1 - 1
magic/Magdir/psion

@@ -1,4 +1,3 @@
-
 #------------------------------------------------------------------------------
 # psion:  file(1) magic for Psion handhelds data
 # from: Peter Breitenlohner <peb@mppmu.mpg.de>
@@ -11,6 +10,7 @@
 >4	lelong		0x1000006A	application information file
 >4	lelong		0x1000006D
 >>8	lelong		0x1000007D	sketch image
+!:mime image/x-psion-sketch
 >>8	lelong		0x1000007E	voice note
 >>8	lelong		0x1000007F	word file
 >>8	lelong		0x10000085	OPL program

+ 1 - 1
magic/Magdir/riff

@@ -135,7 +135,7 @@
 >>>>>>>(104.l+132)      string/c        xvid    XviD
 >>>>>>>(104.l+132)	string/c	h264	H.264
 >>>>>>>(104.l+132)      string/c        wmv3    Windows Media Video 9
->>>>>>>(104.l+132)      string/c        h264    X.264
+>>>>>>>(104.l+132)      string/c        h264    X.264 or H.264
 >>>>>>>(104.l+132)      lelong  0
 ##>>>>>>>(104.l+132)      string  x       (%.4s)
 # skip past first (video) LIST

+ 10 - 0
magic/Magdir/ruby

@@ -0,0 +1,10 @@
+#------------------------------------------------------------------------------
+# ruby:  file(1) magic for Lua scripting language
+# URL:  http://www.ruby-lang.org/
+# From: Reuben Thomas <rrt@sc3d.org>
+
+# Ruby scripts
+0	search/1/b	#!\ /usr/bin/ruby	Ruby script text executable
+0	search/1/b	#!\ /usr/local/bin/ruby	Ruby script text executable
+0	search/1	#!/usr/bin/env\ ruby	Ruby script text executable
+0	search/1	#!\ /usr/bin/env\ ruby	Ruby script text executable

+ 6 - 0
magic/Magdir/sgml

@@ -25,14 +25,20 @@
 # Extensible markup language (XML), a subset of SGML
 # from Marc Prud'hommeaux (marc@apocalypse.org)
 0	search/1/cb	\<?xml			XML document text
+!:mime	application/xml
 0	string		\<?xml\ version\ "	XML
+!:mime	application/xml
 0	string		\<?xml\ version="	XML
+!:mime	application/xml
 0	string		\<?xml\ version='	XML
+!:mime	application/xml
 >15	search/1	>\0			%.3s document text
 >>23	search/1	\<xsl:stylesheet	(XSL stylesheet)
 >>24	search/1	\<xsl:stylesheet	(XSL stylesheet)
 0	search/1/b	\<?xml			XML document text
+!:mime	application/xml
 0	search/1/b	\<?XML			broken XML document text
+!:mime	application/xml
 
 
 # SGML, mostly from rph@sq

+ 3 - 1
magic/Magdir/vorbis

@@ -17,9 +17,11 @@
 # to be made relative to the search). In any case, if the file has ID3
 # tags, the ID3 information will be printed, not the Ogg information,
 # so until that's fixed, this doesn't matter.
+# FIXME[2]: Disable the above for now, since search assumes text mode.
 #
 # --- Ogg Framing ---
-0		search/1000	OggS		Ogg data
+#0		search/1000	OggS		Ogg data
+0		string	OggS		Ogg data
 !:mime		application/ogg
 >4		byte		!0		UNKNOWN REVISION %u
 ##>4		byte		0		revision 0

+ 15 - 0
magic/Magdir/weak

@@ -0,0 +1,15 @@
+#------------------------------------------------------------------------------
+# weak:  file(1) magic for very weak magic entries, disabled by default
+#
+# These entries are so weak that they might interfere identification of
+# other formats. Example include:
+# - Only identify for 1 or 2 bytes
+# - Match against very wide range of values
+# - Match against generic word in some spoken languages (e.g. English)
+
+# Summary: Computer Graphics Metafile
+# Extension: .cgm
+#0	beshort&0xffe0	0x0020		binary Computer Graphics Metafile
+#0	beshort		0x3020		character Computer Graphics Metafile
+
+#0	string		=!!		Bennet Yee's "face" format

+ 115 - 0
magic/Magdir/windows

@@ -0,0 +1,115 @@
+
+#------------------------------------------------------------------------------
+# windows:  file(1) magic for Microsoft Windows
+#
+# This file is mainly reserved for files where programs
+# using them are run almost always on MS Windows 3.x or
+# above, or files only used exclusively in Windows OS,
+# where there is no better category to allocate for.
+# For example, even though WinZIP almost run on Windows
+# only, it is better to treat them as "archive" instead.
+# For format usable in DOS, such as generic executable
+# format, please specify under "msdos" file.
+#
+
+
+# Summary: Outlook Express DBX file
+# Extension: .dbx
+# Created by: Christophe Monniez
+0	string	\xCF\xAD\x12\xFE	MS Outlook Express DBX file
+>4	byte	=0xC5			\b, message database
+>4	byte	=0xC6			\b, folder database
+>4	byte	=0xC7			\b, account information
+>4	byte	=0x30			\b, offline database
+
+
+# Summary: Windows crash dump
+# Extension: .dmp
+# Created by: Andreas Schuster (http://computer.forensikblog.de/)
+# Reference (1): http://computer.forensikblog.de/en/2008/02/64bit_magic.html
+# Modified by (1): Abel Cheung (Avoid match with first 4 bytes only)
+0	string		PAGE		
+>4	string		DUMP		MS Windows 32bit crash dump
+>>0x05c	byte            0		\b, no PAE
+>>0x05c	byte            1		\b, PAE
+>>0xf88	lelong		1		\b, full dump
+>>0xf88	lelong		2		\b, kernel dump
+>>0xf88	lelong		3		\b, small dump
+>>0x068	lelong		x		\b, %ld pages
+>4	string		DU64		MS Windows 64bit crash dump
+>>0xf98	lelong		1		\b, full dump
+>>0xf98	lelong		2		\b, kernel dump
+>>0xf98	lelong		3		\b, small dump
+>>0x090	lequad		x		\b, %lld pages
+
+
+# Summary: Vista Event Log
+# Extension: .evtx
+# Created by: Andreas Schuster (http://computer.forensikblog.de/)
+# Reference (1): http://computer.forensikblog.de/en/2007/05/some_magic.html
+0	string		ElfFile\0	MS Windows Vista Event Log
+>0x2a	leshort		x		\b, %d chunks
+>>0x10	lelong		x		\b (no. %d in use)
+>0x18	lelong		>1		\b, next record no. %d
+>0x18	lelong		=1		\b, empty
+>0x78	lelong		&1		\b, DIRTY
+>0x78	lelong		&2		\b, FULL
+
+
+# Summary: Windows 3.1 group files
+# Extension: .grp
+# Created by: unknown
+0	string		\120\115\103\103	MS Windows 3.1 group files
+
+
+# Summary: Old format help files
+# Extension: .hlp
+# Created by: Dirk Jagdmann <doj@cubic.org>
+0	lelong		0x00035f3f		MS Windows 3.x help file
+
+
+# Summary: Hyper terminal
+# Extension: .ht
+# Created by: unknown
+0	string		HyperTerminal\ 
+>15	string		1.0\ --\ HyperTerminal\ data\ file	MS Windows HyperTerminal profile
+
+
+# Summary: Windows shortcut
+# Extension: .lnk
+# Created by: unknown
+0	string		\114\0\0\0\001\024\002\0\0\0\0\0\300\0\0\0\0\0\0\106	MS Windows shortcut
+
+
+# Summary: Outlook Personal Folders
+# Created by: unknown
+0	lelong		0x4E444221	Microsoft Outlook email folder
+>10	leshort		0x0e		(<=2002)
+>10	leshort		0x17		(>=2003)
+
+
+# Summary: Windows help cache
+# Created by: unknown
+0	string		\164\146\115\122\012\000\000\000\001\000\000\000	MS Windows help cache
+
+
+# Summary: IE cache file
+# Created by: Christophe Monniez
+0	string	Client\ UrlCache\ MMF 	Internet Explorer cache file
+>20	string	>\0			version %s
+
+
+# Summary: Registry files
+# Created by: unknown
+# Modified by (1): Joerg Jenderek
+0	string		regf		MS Windows registry file, NT/2000 or above
+0	string		CREG		MS Windows 95/98/ME registry file
+0	string		SHCC3		MS Windows 3.1 registry file
+
+
+# Summary: Windows Registry text
+# Extension: .reg
+# Submitted by: Abel Cheung <abelcheung@gmail.com>
+0	string		REGEDIT4\r\n\r\n	Windows Registry text (Win95 or above)
+0	string		Windows\ Registry\ Editor\ 
+>&0	string		Version\ 5.00\r\n\r\n	Windows Registry text (Win2K or above)

+ 9 - 1
magic/Makefile.am

@@ -1,3 +1,6 @@
+#
+# $File: Makefile.am,v 1.41 2008/06/17 17:49:11 christos Exp $
+#
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_FRAGMENT_DIR = $(top_srcdir)/magic/$(MAGIC_FRAGMENT_BASE)
 
@@ -160,6 +163,7 @@ $(MAGIC_FRAGMENT_DIR)/revision \
 $(MAGIC_FRAGMENT_DIR)/riff \
 $(MAGIC_FRAGMENT_DIR)/rpm \
 $(MAGIC_FRAGMENT_DIR)/rtf \
+$(MAGIC_FRAGMENT_DIR)/ruby \
 $(MAGIC_FRAGMENT_DIR)/sc \
 $(MAGIC_FRAGMENT_DIR)/sccs \
 $(MAGIC_FRAGMENT_DIR)/scientific \
@@ -201,6 +205,8 @@ $(MAGIC_FRAGMENT_DIR)/vms \
 $(MAGIC_FRAGMENT_DIR)/vmware \
 $(MAGIC_FRAGMENT_DIR)/vorbis \
 $(MAGIC_FRAGMENT_DIR)/vxl \
+$(MAGIC_FRAGMENT_DIR)/weak \
+$(MAGIC_FRAGMENT_DIR)/windows \
 $(MAGIC_FRAGMENT_DIR)/wordprocessors \
 $(MAGIC_FRAGMENT_DIR)/xdelta \
 $(MAGIC_FRAGMENT_DIR)/xenix \
@@ -217,10 +223,12 @@ CLEANFILES = ${MAGIC}
 # the target's magic file
 if IS_CROSS_COMPILE
 FILE_COMPILE = file
+FILE_COMPILE_DEP =
 else
 FILE_COMPILE = $(top_builddir)/src/file
+FILE_COMPILE_DEP = $(FILE_COMPILE)
 endif
 
-${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE)
+${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP)
 	$(FILE_COMPILE) -C -m $(MAGIC_FRAGMENT_DIR)
 	@mv $(MAGIC_FRAGMENT_BASE).mgc $@

+ 10 - 1
magic/Makefile.in

@@ -160,6 +160,10 @@ sysconfdir = @sysconfdir@
 target_alias = @target_alias@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
+
+#
+# $File: Makefile.am,v 1.41 2008/06/17 17:49:11 christos Exp $
+#
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_FRAGMENT_DIR = $(top_srcdir)/magic/$(MAGIC_FRAGMENT_BASE)
 pkgdata_DATA = magic.mgc
@@ -320,6 +324,7 @@ $(MAGIC_FRAGMENT_DIR)/revision \
 $(MAGIC_FRAGMENT_DIR)/riff \
 $(MAGIC_FRAGMENT_DIR)/rpm \
 $(MAGIC_FRAGMENT_DIR)/rtf \
+$(MAGIC_FRAGMENT_DIR)/ruby \
 $(MAGIC_FRAGMENT_DIR)/sc \
 $(MAGIC_FRAGMENT_DIR)/sccs \
 $(MAGIC_FRAGMENT_DIR)/scientific \
@@ -361,6 +366,8 @@ $(MAGIC_FRAGMENT_DIR)/vms \
 $(MAGIC_FRAGMENT_DIR)/vmware \
 $(MAGIC_FRAGMENT_DIR)/vorbis \
 $(MAGIC_FRAGMENT_DIR)/vxl \
+$(MAGIC_FRAGMENT_DIR)/weak \
+$(MAGIC_FRAGMENT_DIR)/windows \
 $(MAGIC_FRAGMENT_DIR)/wordprocessors \
 $(MAGIC_FRAGMENT_DIR)/xdelta \
 $(MAGIC_FRAGMENT_DIR)/xenix \
@@ -377,6 +384,8 @@ CLEANFILES = ${MAGIC}
 # FIXME: Build file natively as well so that it can be used to compile
 # the target's magic file
 @IS_CROSS_COMPILE_TRUE@FILE_COMPILE = file
+@IS_CROSS_COMPILE_FALSE@FILE_COMPILE_DEP = $(FILE_COMPILE)
+@IS_CROSS_COMPILE_TRUE@FILE_COMPILE_DEP = 
 all: all-am
 
 .SUFFIXES:
@@ -566,7 +575,7 @@ uninstall-am: uninstall-pkgdataDATA
 	uninstall uninstall-am uninstall-pkgdataDATA
 
 
-${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE)
+${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP)
 	$(FILE_COMPILE) -C -m $(MAGIC_FRAGMENT_DIR)
 	@mv $(MAGIC_FRAGMENT_BASE).mgc $@
 # Tell versions [3.59,3.63) of GNU make to not export all variables.

+ 5 - 1
src/Makefile.am

@@ -1,17 +1,21 @@
 MAGIC = $(pkgdatadir)/magic
 lib_LTLIBRARIES = libmagic.la
 include_HEADERS = magic.h
-EXTRA_DIST = getopt_long.c
 
 bin_PROGRAMS = file
 
 AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"'
+AM_CFLAGS = -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
+    -Wmissing-declarations -Wredundant-decls -Wnested-externs \
+    -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
+    -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter
 
 libmagic_la_SOURCES = magic.c apprentice.c softmagic.c ascmagic.c \
 	compress.c is_tar.c readelf.c print.c fsmagic.c \
 	funcs.c file.h names.h patchlevel.h readelf.h tar.h apptype.c \
 	file_opts.h elfclass.h
 libmagic_la_LDFLAGS = -no-undefined -version-info 1:0:0
+libmagic_la_LIBADD = $(LTLIBOBJS)
 
 file_SOURCES = file.c
 file_LDADD = libmagic.la

+ 13 - 5
src/Makefile.in

@@ -37,7 +37,7 @@ host_triplet = @host@
 bin_PROGRAMS = file$(EXEEXT)
 subdir = src
 DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in
+	$(srcdir)/Makefile.in asprintf.c getopt_long.c vasprintf.c
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
 	$(top_srcdir)/configure.ac
@@ -56,7 +56,7 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
 	"$(DESTDIR)$(includedir)"
 libLTLIBRARIES_INSTALL = $(INSTALL)
 LTLIBRARIES = $(lib_LTLIBRARIES)
-libmagic_la_LIBADD =
+libmagic_la_DEPENDENCIES = $(LTLIBOBJS)
 am_libmagic_la_OBJECTS = magic.lo apprentice.lo softmagic.lo \
 	ascmagic.lo compress.lo is_tar.lo readelf.lo print.lo \
 	fsmagic.lo funcs.lo apptype.lo
@@ -197,14 +197,19 @@ top_srcdir = @top_srcdir@
 MAGIC = $(pkgdatadir)/magic
 lib_LTLIBRARIES = libmagic.la
 include_HEADERS = magic.h
-EXTRA_DIST = getopt_long.c
 AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"'
+AM_CFLAGS = -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
+    -Wmissing-declarations -Wredundant-decls -Wnested-externs \
+    -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
+    -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter
+
 libmagic_la_SOURCES = magic.c apprentice.c softmagic.c ascmagic.c \
 	compress.c is_tar.c readelf.c print.c fsmagic.c \
 	funcs.c file.h names.h patchlevel.h readelf.h tar.h apptype.c \
 	file_opts.h elfclass.h
 
 libmagic_la_LDFLAGS = -no-undefined -version-info 1:0:0
+libmagic_la_LIBADD = $(LTLIBOBJS)
 file_SOURCES = file.c
 file_LDADD = libmagic.la
 all: all-am
@@ -307,6 +312,9 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asprintf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt_long.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vasprintf.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/apprentice.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/apptype.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascmagic.Plo@am__quote@
@@ -477,7 +485,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
 	clean-libtool mostlyclean-am
 
 distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
+	-rm -rf $(DEPDIR) ./$(DEPDIR)
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
@@ -511,7 +519,7 @@ install-ps: install-ps-am
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
+	-rm -rf $(DEPDIR) ./$(DEPDIR)
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 

+ 170 - 52
src/apprentice.c

@@ -49,7 +49,7 @@
 #include <dirent.h>
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.132 2008/03/28 18:19:30 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.137 2008/07/02 15:22:47 christos Exp $")
 #endif	/* lint */
 
 #define	EATAB {while (isascii((unsigned char) *l) && \
@@ -95,8 +95,6 @@ private const char *getstr(struct magic_set *, const char *, char *, int,
     int *, int);
 private int parse(struct magic_set *, struct magic_entry **, uint32_t *,
     const char *, size_t, int);
-private int parse_mime(struct magic_set *, struct magic_entry **, uint32_t *,
-    const char *);
 private void eatsize(const char **);
 private int apprentice_1(struct magic_set *, const char *, int, struct mlist *);
 private size_t apprentice_magic_strength(const struct magic *);
@@ -116,13 +114,27 @@ private int apprentice_compile(struct magic_set *, struct magic **, uint32_t *,
 private int check_format_type(const char *, int);
 private int check_format(struct magic_set *, struct magic *);
 private int get_op(char);
+private int parse_mime(struct magic_set *, struct magic_entry *, const char *);
+private int parse_strength(struct magic_set *, struct magic_entry *,
+    const char *);
+
 
 private size_t maxmagic = 0;
 private size_t magicsize = sizeof(struct magic);
 
 private const char usg_hdr[] = "cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
-private const char mime_marker[] = "!:mime";
-private const size_t mime_marker_len = sizeof(mime_marker) - 1;
+
+private struct {
+	const char *name;
+	size_t len;
+	int (*fun)(struct magic_set *, struct magic_entry *, const char *);
+} bang[] = {
+#define	DECLARE_FIELD(name) { # name, sizeof(# name) - 1, parse_ ## name }
+	DECLARE_FIELD(mime),
+	DECLARE_FIELD(strength),
+#undef	DECLARE_FIELD
+	{ NULL, 0, NULL }
+};
 
 #ifdef COMPILE_ONLY
 
@@ -387,6 +399,8 @@ apprentice_magic_strength(const struct magic *m)
 
 	switch (m->type) {
 	case FILE_DEFAULT:	/* make sure this sorts last */
+		if (m->factor_op != FILE_FACTOR_OP_NONE)
+			abort();
 		return 0;
 
 	case FILE_BYTE:
@@ -484,6 +498,24 @@ apprentice_magic_strength(const struct magic *m)
 	if (val == 0)	/* ensure we only return 0 for FILE_DEFAULT */
 		val = 1;
 
+	switch (m->factor_op) {
+	case FILE_FACTOR_OP_NONE:
+		break;
+	case FILE_FACTOR_OP_PLUS:
+		val += m->factor;