Browse Source

Import upstream version 5.13

Christos Zoulas 6 years ago
parent
commit
42450514c2
74 changed files with 2460 additions and 1433 deletions
  1. 34 0
      ChangeLog
  2. 11 8
      README
  3. 6 0
      config.h.in
  4. 248 24
      configure
  5. 3 2
      configure.ac
  6. 15 10
      doc/file.man
  7. 20 3
      doc/libmagic.man
  8. 97 14
      doc/magic.man
  9. 251 480
      install-sh
  10. 2 2
      magic/Magdir/animation
  11. 46 0
      magic/Magdir/aout
  12. 82 78
      magic/Magdir/archive
  13. 8 8
      magic/Magdir/assembler
  14. 2 2
      magic/Magdir/audio
  15. 3 13
      magic/Magdir/bsdi
  16. 12 12
      magic/Magdir/cafebabe
  17. 2 2
      magic/Magdir/commands
  18. 3 3
      magic/Magdir/console
  19. 2 10
      magic/Magdir/database
  20. 15 15
      magic/Magdir/digital
  21. 198 41
      magic/Magdir/filesystems
  22. 2 2
      magic/Magdir/fonts
  23. 35 2
      magic/Magdir/gnome-keyring
  24. 241 0
      magic/Magdir/gpt
  25. 4 1
      magic/Magdir/hitachi-sh
  26. 2 1
      magic/Magdir/ibm6000
  27. 51 0
      magic/Magdir/icc
  28. 2 2
      magic/Magdir/images
  29. 2 2
      magic/Magdir/intel
  30. 11 1
      magic/Magdir/java
  31. 2 2
      magic/Magdir/jpeg
  32. 5 4
      magic/Magdir/linux
  33. 11 3
      magic/Magdir/llvm
  34. 2 1
      magic/Magdir/lua
  35. 182 107
      magic/Magdir/mach
  36. 3 3
      magic/Magdir/mail.news
  37. 2 2
      magic/Magdir/maple
  38. 2 2
      magic/Magdir/matroska
  39. 3 65
      magic/Magdir/mips
  40. 1 11
      magic/Magdir/misctools
  41. 2 2
      magic/Magdir/msdos
  42. 6 4
      magic/Magdir/msooxml
  43. 2 2
      magic/Magdir/natinst
  44. 4 6
      magic/Magdir/netbsd
  45. 2 2
      magic/Magdir/revision
  46. 3 3
      magic/Magdir/riff
  47. 10 17
      magic/Magdir/rpm
  48. 69 2
      magic/Magdir/sgi
  49. 60 104
      magic/Magdir/sniffer
  50. 9 2
      magic/Magdir/sql
  51. 37 30
      magic/Magdir/sun
  52. 23 24
      magic/Magdir/unknown
  53. 5 13
      magic/Magdir/vax
  54. 2 2
      magic/Magdir/wordprocessors
  55. 2 2
      magic/Magdir/wsdl
  56. 4 1
      magic/Magdir/xilinx
  57. 2 2
      magic/Magdir/xwindows
  58. 5 2
      magic/Makefile.am
  59. 5 2
      magic/Makefile.in
  60. 7 0
      src/Makefile.am
  61. 19 5
      src/Makefile.in
  62. 282 136
      src/apprentice.c
  63. 2 3
      src/cdf.c
  64. 2 1
      src/elfclass.h
  65. 6 1
      src/file.c
  66. 14 13
      src/file.h
  67. 40 32
      src/fsmagic.c
  68. 1 1
      src/getline.c
  69. 7 1
      src/magic.c
  70. 3 0
      src/magic.h
  71. 107 0
      src/magic.h.in
  72. 14 0
      src/pread.c
  73. 52 60
      src/readelf.c
  74. 29 20
      src/softmagic.c

+ 34 - 0
ChangeLog

@@ -1,3 +1,37 @@
+2013-02-18  10:39  Christos Zoulas <christos@zoulas.com>
+
+	* add elf reading of debug info to determine if file is stripped
+	  (Jan Kaluza)
+	* use pread()
+
+2013-01-25  18:05  Christos Zoulas <christos@zoulas.com>
+
+	* change mime description size from 64 to 80 to accommodate OOXML.
+
+2013-01-11  14:50  Christos Zoulas <christos@zoulas.com>
+
+	* Warn about inconsistent continuation levels.
+	* Change fsmagic to add a space after it prints.
+
+2013-01-10  21:00  Christos Zoulas <christos@zoulas.com>
+
+	* Make getline public so that file can link against it.
+	  Perhaps it is better to rename it, or hide it differently.
+	  Fixes builds on platforms that do not provide it.
+	  
+2013-01-07  16:30  Christos Zoulas <christos@zoulas.com>
+
+	* Add SuS d{,1,2,4,8}, u{,1,2,4,8} and document
+	  what long, int, short, etc is (Guy Harris)
+
+2013-01-06  11:20  Christos Zoulas <christos@zoulas.com>
+
+	* add magic_version function and constant
+	* Redo memory allocation and de-allocation.
+	  (prevents double frees on non mmap platforms)
+	* Fix bug with name/use having to do with passing
+	  found state from the parent to the child and back.
+
 2012-12-19   8:47  Christos Zoulas <christos@zoulas.com>
 
 	* Only print elf capabilities for archs we know (Jan Kaluza)

+ 11 - 8
README

@@ -1,5 +1,5 @@
 ** README for file(1) Command **
-@(#) $File: README,v 1.44 2011/03/24 13:03:39 rrt Exp $
+@(#) $File: README,v 1.45 2013/01/11 16:51:01 christos Exp $
 
 Mailing List: file@mx.gw.com
 Bug tracker: http://bugs.gw.com/
@@ -68,15 +68,19 @@ src/apprentice.c - parses /etc/magic to learn magic
 src/apptype.c - used for OS/2 specific application type magic
 src/asprintf.c - replacement for OS's that don't have it.
 src/ascmagic.c - third & last set of tests, based on hardwired assumptions.
+src/asctime_r.c - for systems that don't have it.
+src/asprintf.c - for systems that don't have it.
 src/cdf.c - parser for Microsoft Compound Document Files
 src/cdf_time.c - time converter for CDF.
 src/compress.c - handles decompressing files to look inside.
+src/ctime_r.c - for systems that don't have it.
 src/encoding.c - handles unicode encodings
 src/file.c - the main program
 src/file.h - header file
 src/fsmagic.c - first set of tests the program runs, based on filesystem info
 src/funcs.c - utilility functions
-src/getopt_long.c - used for OS/2 specific application type magic
+src/getopt_long.c - for systems that don't have it.
+src/getline.c - for systems that don't have it.
 src/is_tar.c, tar.h - knows about tarchives (courtesy John Gilmore).
 src/names.h - header file for ascmagic.c
 src/magic.c - the libmagic api
@@ -84,14 +88,13 @@ src/print.c - print results, errors, warnings.
 src/readcdf.c - CDF wrapper.
 src/readelf.[ch] - Stand-alone elf parsing code.
 src/softmagic.c - 2nd set of tests, based on /etc/magic
-src/strlcat.c - used for OS/2 specific application type magic
-src/strlcpy.c - used for OS/2 specific application type magic
-src/vasprintf.c - used for OS/2 specific application type magic
-doc/file.1 - man page for the command
-doc/magic.4 - man page for the magic file, courtesy Guy Harris.
+src/strlcat.c - for systems that don't have it.
+src/strlcpy.c - for systems that don't have it.
+src/vasprintf.c - for systems that don't have it.
+doc/file.man - man page for the command
+doc/magic.man - man page for the magic file, courtesy Guy Harris.
 	Install as magic.4 on USG and magic.5 on V7 or Berkeley; cf Makefile.
 Magdir - directory of /etc/magic pieces
-
 ------------------------------------------------------------------------------
 
 If you submit a new magic entry please make sure you read the following

+ 6 - 0
config.h.in

@@ -89,6 +89,9 @@
 /* Define to 1 if you have a working `mmap' system call. */
 #undef HAVE_MMAP
 
+/* Define to 1 if you have the `pread' function. */
+#undef HAVE_PREAD
+
 /* Define to 1 if you have the <stddef.h> header file. */
 #undef HAVE_STDDEF_H
 
@@ -243,6 +246,9 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
+
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
 

+ 248 - 24
configure

@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for file 5.12.
+# Generated by GNU Autoconf 2.68 for file 5.13.
 #
 # Report bugs to <christos@astron.com>.
 #
@@ -709,8 +709,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='file'
 PACKAGE_TARNAME='file'
-PACKAGE_VERSION='5.12'
-PACKAGE_STRING='file 5.12'
+PACKAGE_VERSION='5.13'
+PACKAGE_STRING='file 5.13'
 PACKAGE_BUGREPORT='christos@astron.com'
 PACKAGE_URL=''
 
@@ -1442,7 +1442,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 5.12 to adapt to many kinds of systems.
+\`configure' configures file 5.13 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1512,7 +1512,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of file 5.12:";;
+     short | recursive ) echo "Configuration of file 5.13:";;
    esac
   cat <<\_ACEOF
 
@@ -1618,7 +1618,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-file configure 5.12
+file configure 5.13
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2267,11 +2267,189 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_find_intX_t
+
+# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
+# --------------------------------------------
+# Tries to find the compile-time value of EXPR in a program that includes
+# INCLUDES, setting VAR accordingly. Returns whether the value could be
+# computed
+ac_fn_c_compute_int ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if test "$cross_compiling" = yes; then
+    # Depending upon the size, compute the lo and hi bounds.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid; break
+else
+  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
+			if test $ac_lo -le $ac_mid; then
+			  ac_lo= ac_hi=
+			  break
+			fi
+			as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=$ac_mid; break
+else
+  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
+			if test $ac_mid -le $ac_hi; then
+			  ac_lo= ac_hi=
+			  break
+			fi
+			as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  ac_lo= ac_hi=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid
+else
+  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in #((
+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
+'') ac_retval=1 ;;
+esac
+  else
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+static long int longval () { return $2; }
+static unsigned long int ulongval () { return $2; }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    return 1;
+  if (($2) < 0)
+    {
+      long int i = longval ();
+      if (i != ($2))
+	return 1;
+      fprintf (f, "%ld", i);
+    }
+  else
+    {
+      unsigned long int i = ulongval ();
+      if (i != ($2))
+	return 1;
+      fprintf (f, "%lu", i);
+    }
+  /* Do not output a trailing newline, as this causes \r\n confusion
+     on some platforms.  */
+  return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
+else
+  ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+  fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_compute_int
 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 5.12, which was
+It was created by file $as_me 5.13, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -3089,7 +3267,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='file'
- VERSION='5.12'
+ VERSION='5.13'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -5896,13 +6074,13 @@ if ${lt_cv_nm_interface+:} false; then :
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:5899: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:6077: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5902: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:6080: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5905: output\"" >&5)
+  (eval echo "\"\$as_me:6083: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -7096,7 +7274,7 @@ ia64-*-hpux*)
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 7099 "configure"' > conftest.$ac_ext
+  echo '#line 7277 "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -8356,11 +8534,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8359: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8537: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8363: \$? = $ac_status" >&5
+   echo "$as_me:8541: \$? = $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.
@@ -8695,11 +8873,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8698: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8876: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8702: \$? = $ac_status" >&5
+   echo "$as_me:8880: \$? = $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.
@@ -8800,11 +8978,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8803: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8981: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8807: \$? = $ac_status" >&5
+   echo "$as_me:8985: \$? = $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
@@ -8855,11 +9033,11 @@ else
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8858: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:9036: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8862: \$? = $ac_status" >&5
+   echo "$as_me:9040: \$? = $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
@@ -11222,7 +11400,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11225 "configure"
+#line 11403 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11318,7 +11496,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11321 "configure"
+#line 11499 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12705,6 +12883,39 @@ _ACEOF
 ;;
 esac
 
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5
+$as_echo_n "checking size of long long... " >&6; }
+if ${ac_cv_sizeof_long_long+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_long_long" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (long long)
+See \`config.log' for more details" "$LINENO" 5; }
+   else
+     ac_cv_sizeof_long_long=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5
+$as_echo "$ac_cv_sizeof_long_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
+_ACEOF
+
+
 
 
 
@@ -13307,6 +13518,19 @@ esac
 
 fi
 
+ac_fn_c_check_func "$LINENO" "pread" "ac_cv_func_pread"
+if test "x$ac_cv_func_pread" = xyes; then :
+  $as_echo "#define HAVE_PREAD 1" >>confdefs.h
+
+else
+  case " $LIBOBJS " in
+  *" pread.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS pread.$ac_objext"
+ ;;
+esac
+
+fi
+
 
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzopen in -lz" >&5
@@ -13962,7 +14186,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=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 5.12, which was
+This file was extended by file $as_me 5.13, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14028,7 +14252,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-file config.status 5.12
+file config.status 5.13
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 

+ 3 - 2
configure.ac

@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT([file],[5.12],[christos@astron.com])
+AC_INIT([file],[5.13],[christos@astron.com])
 AM_INIT_AUTOMAKE([subdir-objects foreign])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
@@ -107,6 +107,7 @@ AC_TYPE_UINT32_T
 AC_TYPE_INT32_T
 AC_TYPE_UINT64_T
 AC_TYPE_INT64_T
+AC_CHECK_SIZEOF(long long)
 AC_FUNC_MMAP
 AC_FUNC_FORK
 AC_FUNC_MBRTOWC
@@ -139,7 +140,7 @@ dnl Checks for functions
 AC_CHECK_FUNCS(strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof)
 
 dnl Provide implementation of some required functions if necessary
-AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r)
+AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r pread)
 
 dnl Checks for libraries
 AC_CHECK_LIB(z,gzopen)

+ 15 - 10
doc/file.man

@@ -1,4 +1,4 @@
-.\" $File: file.man,v 1.101 2012/11/01 04:31:53 christos Exp $
+.\" $File: file.man,v 1.102 2013/01/04 15:39:22 christos Exp $
 .Dd October 25, 2012
 .Dt FILE __CSECTION__
 .Os
@@ -557,16 +557,20 @@ or the mailing list at
 .Sh TODO
 .Pp
 Fix output so that tests for MIME and APPLE flags are not needed all
-over the place, and actual output is only done in one place. This
-needs a design. Suggestion: push possible outputs on to a list, then
-pick the last-pushed (most specific, one hopes) value at the end, or
-use a default if the list is empty. This should not slow down evaluation.
+over the place, and actual output is only done in one place.
+This needs a design.
+Suggestion: push possible outputs on to a list, then pick the
+last-pushed (most specific, one hopes) value at the end, or
+use a default if the list is empty.
+This should not slow down evaluation.
 .Pp
-Continue to squash all magic bugs. See Debian BTS for a good source.
+Continue to squash all magic bugs.
+See Debian BTS for a good source.
 .Pp
 Store arbitrarily long strings, for example for %s patterns, so that
-they can be printed out. Fixes Debian bug #271672. Would require more
-complex store/load code in apprentice.
+they can be printed out.
+Fixes Debian bug #271672.
+Would require more complex store/load code in apprentice.
 .Pp
 Add syntax for relative offsets after current level (Debian bug #466037).
 .Pp
@@ -579,8 +583,9 @@ Add an option to print URLs for the sources of the file descriptions.
 .Pp
 Combine script searches and add a way to map executable names to MIME
 types (e.g. have a magic value for !:mime which causes the resulting
-string to be looked up in a table). This would avoid adding the same
-magic repeatedly for each new hash-bang interpreter.
+string to be looked up in a table).
+This would avoid adding the same magic repeatedly for each new
+hash-bang interpreter.
 .Pp
 Fix
 .Dq name

+ 20 - 3
doc/libmagic.man

@@ -1,4 +1,4 @@
-.\" $File: libmagic.man,v 1.26 2011/12/19 17:49:31 christos Exp $
+.\" $File: libmagic.man,v 1.27 2013/01/06 20:56:52 christos Exp $
 .\"
 .\" Copyright (c) Christos Zoulas 2003.
 .\" All Rights Reserved.
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd December 19, 2011
+.Dd January 6, 2012
 .Dt LIBMAGIC 3
 .Os
 .Sh NAME
@@ -37,7 +37,9 @@
 .Nm magic_setflags ,
 .Nm magic_check ,
 .Nm magic_compile ,
-.Nm magic_load
+.Nm magic_list ,
+.Nm magic_load ,
+.Nm magic_version
 .Nd Magic number recognition library
 .Sh LIBRARY
 .Lb libmagic
@@ -67,6 +69,8 @@
 .Fn magic_list "magic_t cookie" "const char *filename"
 .Ft int
 .Fn magic_load "magic_t cookie" "const char *filename"
+.Ft int
+.Fn magic_version "void"
 .Sh DESCRIPTION
 These functions
 operate on the magic database file
@@ -246,6 +250,16 @@ If that variable is not set, the default database file name is __MAGIC__.
 adds
 .Dq .mgc
 to the database filename as appropriate.
+.Pp
+The
+.Fn magic_version
+command returns the version number of this library which is compiled into
+the shared library using the constant
+.Dv MAGIC_VERSION
+from
+.In magic.h .
+This can be used by client programs to verify that the version they compile
+against is the same as the version that they run against.
 .Sh RETURN VALUES
 The function
 .Fn magic_open
@@ -276,6 +290,9 @@ function returns a textual description of the errors of the above
 functions, or
 .Dv NULL
 if there was no error.
+The
+.Fn magic_version
+always returns the version number of the library.
 Finally,
 .Fn magic_setflags
 returns \-1 on systems that don't support

+ 97 - 14
doc/magic.man

@@ -1,5 +1,5 @@
-.\" $File: magic.man,v 1.76 2012/11/07 20:29:27 christos Exp $
-.Dd November 7, 2012
+.\" $File: magic.man,v 1.78 2013/01/09 13:04:30 christos Exp $
+.Dd January 7, 2013
 .Dt MAGIC __FSECTION__
 .Os
 .\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems.
@@ -265,6 +265,67 @@ This is intended to be used with the test
 no other matches.
 .El
 .Pp
+For compatibility with the Single
+.Ux
+Standard, the type specifiers
+.Dv dC
+and
+.Dv d1
+are equivalent to
+.Dv byte ,
+the type specifiers
+.Dv uC
+and
+.Dv u1
+are equivalent to
+.Dv ubyte ,
+the type specifiers
+.Dv dS
+and
+.Dv d2
+are equivalent to
+.Dv short ,
+the type specifiers
+.Dv uS
+and
+.Dv u2
+are equivalent to
+.Dv ushort ,
+the type specifiers
+.Dv dI ,
+.Dv dL ,
+and
+.Dv d4
+are equivalent to
+.Dv long ,
+the type specifiers
+.Dv uI ,
+.Dv uL ,
+and
+.Dv u4
+are equivalent to
+.Dv ulong ,
+the type specifier
+.Dv d8
+is equivalent to
+.Dv quad ,
+the type specifier
+.Dv u8
+is equivalent to
+.Dv uquad ,
+and the type specifier
+.Dv s
+is equivalent to
+.Dv string .
+In addition, the type specifier
+.Dv dQ
+is equivalent to
+.Dv quad
+and the type specifier
+.Dv uQ
+is equivalent to
+.Dv uquad .
+.Pp
 Each top-level magic pattern (see below for an explanation of levels)
 is classified as text or binary according to the types used.
 Types
@@ -570,19 +631,41 @@ The formats
 .Dv melong ,
 .Dv short ,
 .Dv beshort ,
-.Dv leshort ,
-.Dv date ,
-.Dv bedate ,
-.Dv medate ,
-.Dv ledate ,
-.Dv beldate ,
-.Dv leldate ,
 and
-.Dv meldate
-are system-dependent; perhaps they should be specified as a number
-of bytes (2B, 4B, etc),
-since the files being recognized typically come from
-a system on which the lengths are invariant.
+.Dv leshort
+do not depend on the length of the C data types
+.Dv short
+and
+.Dv long
+on the platform, even though the Single
+.Ux
+Specification implies that they do.  However, as OS X Mountain Lion has
+passed the Single
+.Ux
+Specification validation suite, and supplies a version of
+.Xr file __CSECTION__
+in which they do not depend on the sizes of the C data types and that is
+built for a 64-bit environment in which
+.Dv long
+is 8 bytes rather than 4 bytes, presumably the validation suite does not
+test whether, for example
+.Dv long
+refers to an item with the same size as the C data type
+.Dv long .
+There should probably be
+.Dv type
+names
+.Dv int8 ,
+.Dv uint8 ,
+.Dv int16 ,
+.Dv uint16 ,
+.Dv int32 ,
+.Dv uint32 ,
+.Dv int64 ,
+and
+.Dv uint64 ,
+and specified-byte-order variants of them,
+to make it clearer that those types have specified widths.
 .\"
 .\" From: guy@sun.uucp (Guy Harris)
 .\" Newsgroups: net.bugs.usg

+ 251 - 480
install-sh

@@ -1,38 +1,23 @@
 #!/bin/sh
-# install - install a program, script, or datafile
-
-scriptversion=2009-04-28.21; # UTC
-
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
 #
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
+# $NetBSD: install-sh.in,v 1.5 2010/10/08 19:57:05 tez Exp $
+# This script now also installs multiple files, but might choke on installing
+# multiple files with spaces in the file names.
 #
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
 #
+# Copyright 1991 by the Massachusetts Institute of Technology
 #
-# FSF changes to this file are in the public domain.
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission.  M.I.T. makes no representations about the
+# suitability of this software for any purpose.  It is provided "as is"
+# without express or implied warranty.
 #
 # Calling this script install-sh is preferred over install.sh, to prevent
 # `make' implicit rules from creating a file called install from it
@@ -41,480 +26,266 @@ scriptversion=2009-04-28.21; # UTC
 # This script is compatible with the BSD install script, but was written
 # from scratch.
 
-nl='
-'
-IFS=" ""	$nl"
-
 # set DOITPROG to echo to test this script
 
 # Don't use :- since 4.3BSD and earlier shells don't like it.
-doit=${DOITPROG-}
-if test -z "$doit"; then
-  doit_exec=exec
-else
-  doit_exec=$doit
-fi
-
-# Put in absolute file names if you don't have them in your path;
-# or use environment vars.
-
-chgrpprog=${CHGRPPROG-chgrp}
-chmodprog=${CHMODPROG-chmod}
-chownprog=${CHOWNPROG-chown}
-cmpprog=${CMPPROG-cmp}
-cpprog=${CPPROG-cp}
-mkdirprog=${MKDIRPROG-mkdir}
-mvprog=${MVPROG-mv}
-rmprog=${RMPROG-rm}
-stripprog=${STRIPPROG-strip}
-
-posix_glob='?'
-initialize_posix_glob='
-  test "$posix_glob" != "?" || {
-    if (set -f) 2>/dev/null; then
-      posix_glob=
-    else
-      posix_glob=:
-    fi
-  }
-'
-
-posix_mkdir=
-
-# Desired mode of installed file.
-mode=0755
-
-chgrpcmd=
-chmodcmd=$chmodprog
-chowncmd=
-mvcmd=$mvprog
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+awkprog="${AWKPROG-awk}"
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+instcmd="$cpprog"
+pathcompchmodcmd="$chmodprog 755"
+chmodcmd="$chmodprog 755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+stripflags=""
 rmcmd="$rmprog -f"
-stripcmd=
-
-src=
-dst=
-dir_arg=
-dst_arg=
-
-copy_on_change=false
-no_target_directory=
-
-usage="\
-Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
-   or: $0 [OPTION]... SRCFILES... DIRECTORY
-   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
-   or: $0 [OPTION]... -d DIRECTORIES...
-
-In the 1st form, copy SRCFILE to DSTFILE.
-In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
-In the 4th, create DIRECTORIES.
-
-Options:
-     --help     display this help and exit.
-     --version  display version info and exit.
-
-  -c            (ignored)
-  -C            install only if different (preserve the last data modification time)
-  -d            create directories instead of installing files.
-  -g GROUP      $chgrpprog installed files to GROUP.
-  -m MODE       $chmodprog installed files to MODE.
-  -o USER       $chownprog installed files to USER.
-  -s            $stripprog installed files.
-  -t DIRECTORY  install into DIRECTORY.
-  -T            report an error if DSTFILE is a directory.
+mvcmd="$mvprog"
+src=""
+msrc=""
+dst=""
+dir_arg=""
+suffix=""
+suffixfmt=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+	-b) suffix=".old"
+	    shift
+	    continue;;
+
+	-B) suffixfmt="$2"
+	    shift
+	    shift
+	    continue;;
+
+	-c) instcmd="$cpprog"
+	    shift
+	    continue;;
+
+	-d) dir_arg=true
+	    shift
+	    continue;;
+
+	-m) chmodcmd="$chmodprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-o) chowncmd="$chownprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-g) chgrpcmd="$chgrpprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-s) stripcmd="$stripprog"
+	    shift
+	    continue;;
+
+	-S) stripcmd="$stripprog"
+	    stripflags="-S $2 $stripflags"
+	    shift
+	    shift
+	    continue;;
+
+	*)  if [ x"$msrc" = x ]
+	    then
+		msrc="$dst"
+	    else
+		msrc="$msrc $dst"
+	    fi
+	    src="$dst"
+	    dst="$1"
+	    shift
+	    continue;;
+    esac
+done
 
-Environment variables override the default commands:
-  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
-  RMPROG STRIPPROG
-"
+if [ x"$dir_arg" = x ]
+then
+	dstisfile=""
+	if [ ! -d "$dst" ]
+	then
+		if [ x"$msrc" = x"$src" ]
+		then
+			dstisfile=true
+		else
+			echo "install: destination is not a directory"
+			exit 1
+		fi
+	fi
+else
+	msrc="$msrc $dst"
+fi
 
-while test $# -ne 0; do
-  case $1 in
-    -c) ;;
+if [ x"$msrc" = x ]
+then
+	echo "install: no destination specified"
+	exit 1
+fi      
 
-    -C) copy_on_change=true;;
+for srcarg in $msrc; do
 
-    -d) dir_arg=true;;
+if [ x"$dir_arg" != x ]; then
 
-    -g) chgrpcmd="$chgrpprog $2"
-	shift;;
+	dstarg="$srcarg"
+else
+	dstarg="$dst"
+
+# Waiting for this to be detected by the "$instcmd $srcarg $dsttmp" command
+# might cause directories to be created, which would be especially bad 
+# if $src (and thus $dsttmp) contains '*'.
+
+	if [ -f "$srcarg" ]
+	then
+		doinst="$instcmd"
+	elif [ -d "$srcarg" ]
+	then
+		echo "install: $srcarg: not a regular file"
+		exit 1
+	elif [ "$srcarg" = "/dev/null" ]
+	then
+		doinst="$cpprog"
+	else
+		echo "install:  $srcarg does not exist"
+		exit 1
+	fi
+	
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
 
-    --help) echo "$usage"; exit $?;;
+	if [ -d "$dstarg" ]
+	then
+		dstarg="$dstarg"/`basename "$srcarg"`
+	fi
+fi
 
-    -m) mode=$2
-	case $mode in
-	  *' '* | *'	'* | *'
-'*	  | *'*'* | *'?'* | *'['*)
-	    echo "$0: invalid mode: $mode" >&2
-	    exit 1;;
-	esac
-	shift;;
+## this sed command emulates the dirname command
+dstdir=`echo "$dstarg" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
 
-    -o) chowncmd="$chownprog $2"
-	shift;;
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
 
-    -s) stripcmd=$stripprog;;
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='	
+'
+IFS="${IFS-${defaultIFS}}"
 
-    -t) dst_arg=$2
-	shift;;
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
 
-    -T) no_target_directory=true;;
+pathcomp=''
 
-    --version) echo "$0 $scriptversion"; exit $?;;
+while [ $# -ne 0 ] ; do
+	pathcomp="${pathcomp}${1}"
+	shift
 
-    --)	shift
-	break;;
+	if [ ! -d "${pathcomp}" ] ;
+        then
+		$doit $mkdirprog "${pathcomp}"
+        	if [ x"$chowncmd" != x ]; then $doit $chowncmd "${pathcomp}"; else true ; fi &&
+        	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "${pathcomp}"; else true ; fi &&
+        	if [ x"$pathcompchmodcmd" != x ]; then $doit $pathcompchmodcmd "${pathcomp}"; else true ; fi
 
-    -*)	echo "$0: invalid option: $1" >&2
-	exit 1;;
+	else
+		true
+	fi
 
-    *)  break;;
-  esac
-  shift
+	pathcomp="${pathcomp}/"
 done
-
-if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
-  # When -d is used, all remaining arguments are directories to create.
-  # When -t is used, the destination is already specified.
-  # Otherwise, the last argument is the destination.  Remove it from $@.
-  for arg
-  do
-    if test -n "$dst_arg"; then
-      # $@ is not empty: it contains at least $arg.
-      set fnord "$@" "$dst_arg"
-      shift # fnord
-    fi
-    shift # arg
-    dst_arg=$arg
-  done
-fi
-
-if test $# -eq 0; then
-  if test -z "$dir_arg"; then
-    echo "$0: no input file specified." >&2
-    exit 1
-  fi
-  # It's OK to call `install-sh -d' without argument.
-  # This can happen when creating conditional directories.
-  exit 0
 fi
 
-if test -z "$dir_arg"; then
-  trap '(exit $?); exit' 1 2 13 15
-
-  # Set umask so as not to create temps with too-generous modes.
-  # However, 'strip' requires both read and write access to temps.
-  case $mode in
-    # Optimize common cases.
-    *644) cp_umask=133;;
-    *755) cp_umask=22;;
-
-    *[0-7])
-      if test -z "$stripcmd"; then
-	u_plus_rw=
-      else
-	u_plus_rw='% 200'
-      fi
-      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
-    *)
-      if test -z "$stripcmd"; then
-	u_plus_rw=
-      else
-	u_plus_rw=,u+rw
-      fi
-      cp_umask=$mode$u_plus_rw;;
-  esac
-fi
-
-for src
-do
-  # Protect names starting with `-'.
-  case $src in
-    -*) src=./$src;;
-  esac
-
-  if test -n "$dir_arg"; then
-    dst=$src
-    dstdir=$dst
-    test -d "$dstdir"
-    dstdir_status=$?
-  else
-
-    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
-    # might cause directories to be created, which would be especially bad
-    # if $src (and thus $dsttmp) contains '*'.
-    if test ! -f "$src" && test ! -d "$src"; then
-      echo "$0: $src does not exist." >&2
-      exit 1
-    fi
-
-    if test -z "$dst_arg"; then
-      echo "$0: no destination specified." >&2
-      exit 1
-    fi
-
-    dst=$dst_arg
-    # Protect names starting with `-'.
-    case $dst in
-      -*) dst=./$dst;;
-    esac
-
-    # If destination is a directory, append the input filename; won't work
-    # if double slashes aren't ignored.
-    if test -d "$dst"; then
-      if test -n "$no_target_directory"; then
-	echo "$0: $dst_arg: Is a directory" >&2
-	exit 1
-      fi
-      dstdir=$dst
-      dst=$dstdir/`basename "$src"`
-      dstdir_status=0
-    else
-      # Prefer dirname, but fall back on a substitute if dirname fails.
-      dstdir=`
-	(dirname "$dst") 2>/dev/null ||
-	expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	     X"$dst" : 'X\(//\)[^/]' \| \
-	     X"$dst" : 'X\(//\)$' \| \
-	     X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
-	echo X"$dst" |
-	    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)[^/].*/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\/\)$/{
-		   s//\1/
-		   q
-		 }
-		 /^X\(\/\).*/{
-		   s//\1/
-		   q
-		 }
-		 s/.*/./; q'
-      `
-
-      test -d "$dstdir"
-      dstdir_status=$?
-    fi
-  fi
-
-  obsolete_mkdir_used=false
-
-  if test $dstdir_status != 0; then
-    case $posix_mkdir in
-      '')
-	# Create intermediate dirs using mode 755 as modified by the umask.
-	# This is like FreeBSD 'install' as of 1997-10-28.
-	umask=`umask`
-	case $stripcmd.$umask in
-	  # Optimize common cases.
-	  *[2367][2367]) mkdir_umask=$umask;;
-	  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
-	  *[0-7])
-	    mkdir_umask=`expr $umask + 22 \
-	      - $umask % 100 % 40 + $umask % 20 \
-	      - $umask % 10 % 4 + $umask % 2
-	    `;;
-	  *) mkdir_umask=$umask,go-w;;
-	esac
-
-	# With -d, create the new directory with the user-specified mode.
-	# Otherwise, rely on $mkdir_umask.
-	if test -n "$dir_arg"; then
-	  mkdir_mode=-m$mode
+	if [ x"$dir_arg" != x ]
+	then
+		if [ -d "$dstarg" ]; then
+			true
+		else
+			$doit $mkdirprog "$dstarg" &&
+
+			if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dstarg"; else true ; fi &&
+			if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dstarg"; else true ; fi &&
+			if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dstarg"; else true ; fi
+		fi
 	else
-	  mkdir_mode=
+
+		if [ x"$dstisfile" = x ]
+		then
+			file=$srcarg
+		else
+			file=$dst
+		fi
+
+		dstfile=`basename "$file"`
+		dstfinal="$dstdir/$dstfile"
+
+# Make a temp file name in the proper directory.
+
+		dsttmp=$dstdir/#inst.$$#
+
+# Make a backup file name in the proper directory.
+		case x$suffixfmt in
+		*%*)	suffix=`echo x |
+			$awkprog -v bname="$dstfinal" -v fmt="$suffixfmt" '
+			{ cnt = 0;
+			  do {
+				sfx = sprintf(fmt, cnt++);
+				name = bname sfx;
+			  } while (system("test -f " name) == 0);
+			  print sfx; }' -`;;
+		x)	;;
+		*)	suffix="$suffixfmt";;
+		esac
+		dstbackup="$dstfinal$suffix"
+
+# Move or copy the file name to the temp name
+
+		$doit $doinst $srcarg "$dsttmp" &&
+
+		trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+		if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else true;fi &&
+		if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else true;fi &&
+		if [ x"$stripcmd" != x ]; then $doit $stripcmd $stripflags "$dsttmp"; else true;fi &&
+		if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else true;fi &&
+
+# Now rename the file to the real destination.
+
+		if [ x"$suffix" != x ] && [ -f "$dstfinal" ]
+		then
+			$doit $mvcmd "$dstfinal" "$dstbackup"
+		else
+			$doit $rmcmd -f "$dstfinal"
+		fi &&
+		$doit $mvcmd "$dsttmp" "$dstfinal"
 	fi
 
-	posix_mkdir=false
-	case $umask in
-	  *[123567][0-7][0-7])
-	    # POSIX mkdir -p sets u+wx bits regardless of umask, which
-	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
-	    ;;
-	  *)
-	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
-	    if (umask $mkdir_umask &&
-		exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
-	    then
-	      if test -z "$dir_arg" || {
-		   # Check for POSIX incompatibilities with -m.
-		   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
-		   # other-writeable bit of parent directory when it shouldn't.
-		   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
-		   ls_ld_tmpdir=`ls -ld "$tmpdir"`
-		   case $ls_ld_tmpdir in
-		     d????-?r-*) different_mode=700;;
-		     d????-?--*) different_mode=755;;
-		     *) false;;
-		   esac &&
-		   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
-		     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
-		     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
-		   }
-		 }
-	      then posix_mkdir=:
-	      fi
-	      rmdir "$tmpdir/d" "$tmpdir"
-	    else
-	      # Remove any dirs left behind by ancient mkdir implementations.
-	      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
-	    fi
-	    trap '' 0;;
-	esac;;
-    esac
+done &&
 
-    if
-      $posix_mkdir && (
-	umask $mkdir_umask &&
-	$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
-      )
-    then :
-    else
-
-      # The umask is ridiculous, or mkdir does not conform to POSIX,
-      # or it failed possibly due to a race condition.  Create the
-      # directory the slow way, step by step, checking for races as we go.
-
-      case $dstdir in
-	/*) prefix='/';;
-	-*) prefix='./';;
-	*)  prefix='';;
-      esac
-
-      eval "$initialize_posix_glob"
-
-      oIFS=$IFS
-      IFS=/
-      $posix_glob set -f
-      set fnord $dstdir
-      shift
-      $posix_glob set +f
-      IFS=$oIFS
-
-      prefixes=
-
-      for d
-      do
-	test -z "$d" && continue
-
-	prefix=$prefix$d
-	if test -d "$prefix"; then
-	  prefixes=
-	else
-	  if $posix_mkdir; then
-	    (umask=$mkdir_umask &&
-	     $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
-	    # Don't fail if two instances are running concurrently.
-	    test -d "$prefix" || exit 1
-	  else
-	    case $prefix in
-	      *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
-	      *) qprefix=$prefix;;
-	    esac
-	    prefixes="$prefixes '$qprefix'"
-	  fi
-	fi
-	prefix=$prefix/
-      done
-
-      if test -n "$prefixes"; then
-	# Don't fail if two instances are running concurrently.
-	(umask $mkdir_umask &&
-	 eval "\$doit_exec \$mkdirprog $prefixes") ||
-	  test -d "$dstdir" || exit 1
-	obsolete_mkdir_used=true
-      fi
-    fi
-  fi
-
-  if test -n "$dir_arg"; then
-    { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
-    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
-    { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
-      test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
-  else
-
-    # Make a couple of temp file names in the proper directory.
-    dsttmp=$dstdir/_inst.$$_
-    rmtmp=$dstdir/_rm.$$_
-
-    # Trap to clean up those temp files at exit.
-    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
-
-    # Copy the file name to the temp name.
-    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
-
-    # and set any options; do chmod last to preserve setuid bits.
-    #
-    # If any of these fail, we abort the whole thing.  If we want to
-    # ignore errors from any of these, just make sure not to ignore
-    # errors from the above "$doit $cpprog $src $dsttmp" command.
-    #
-    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
-    { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
-    { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
-    { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
-
-    # If -C, don't bother to copy if it wouldn't change the file.
-    if $copy_on_change &&
-       old=`LC_ALL=C ls -dlL "$dst"	2>/dev/null` &&
-       new=`LC_ALL=C ls -dlL "$dsttmp"	2>/dev/null` &&
-
-       eval "$initialize_posix_glob" &&
-       $posix_glob set -f &&
-       set X $old && old=:$2:$4:$5:$6 &&
-       set X $new && new=:$2:$4:$5:$6 &&
-       $posix_glob set +f &&
-
-       test "$old" = "$new" &&
-       $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
-    then
-      rm -f "$dsttmp"
-    else
-      # Rename the file to the real destination.
-      $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
-
-      # The rename failed, perhaps because mv can't rename something else
-      # to itself, or perhaps because mv is so ancient that it does not
-      # support -f.
-      {
-	# Now remove or move aside any old file at destination location.
-	# We try this two ways since rm can't unlink itself on some
-	# systems and the destination file might be busy for other
-	# reasons.  In this case, the final cleanup might fail but the new
-	# file should still install successfully.
-	{
-	  test ! -f "$dst" ||
-	  $doit $rmcmd -f "$dst" 2>/dev/null ||
-	  { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
-	    { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
-	  } ||
-	  { echo "$0: cannot unlink or rename $dst" >&2
-	    (exit 1); exit 1
-	  }
-	} &&
-
-	# Now rename the file to the real destination.
-	$doit $mvcmd "$dsttmp" "$dst"
-      }
-    fi || exit 1
-
-    trap '' 0
-  fi
-done
 
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
-# End:
+exit 0

+ 2 - 2
magic/Magdir/animation

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: animation,v 1.46 2012/08/26 10:43:05 christos Exp $
+# $File: animation,v 1.47 2013/02/06 14:18:52 christos Exp $
 # animation:  file(1) magic for animation/movie formats
 #
 # animation formats
@@ -751,7 +751,7 @@
 >0	byte		x		GameCube movie,
 >0x34	ubeshort	x		%d x
 >0x36	ubeshort	x		%d,
->0x26	ubeshort	x		%dµs,
+>0x26	ubeshort	x		%dus,
 >0x42	ubeshort	0		no audio
 >0x42	ubeshort	>0		%dHz audio
 

+ 46 - 0
magic/Magdir/aout

@@ -0,0 +1,46 @@
+
+#------------------------------------------------------------------------------
+# $File: aout,v 1.1 2013/01/09 22:37:23 christos Exp $
+# aout:  file(1) magic for a.out executable/object/etc entries that
+# handle executables on multiple platforms.
+#
+
+#
+# Little-endian 32-bit-int a.out, merged from bsdi (for BSD/OS, from
+# BSDI), netbsd, and vax (for UNIX/32V and BSD)
+#
+# XXX - is there anything we can look at to distinguish BSD/OS 386 from
+# NetBSD 386 from various VAX binaries?  The BSD/OS shared library flag
+# works only for binaries using shared libraries.  Grabbing the entry
+# point from the a.out header, using it to find the first code executed
+# in the program, and looking at that might help.
+#
+0	lelong		0407		a.out little-endian 32-bit executable
+>16	lelong		>0		not stripped
+>32	byte		0x6a		(uses BSD/OS shared libs)
+
+0	lelong		0410		a.out little-endian 32-bit pure executable
+>16	lelong		>0		not stripped
+>32	byte		0x6a		(uses BSD/OS shared libs)
+
+0	lelong		0413		a.out little-endian 32-bit demand paged pure executable
+>16	lelong		>0		not stripped
+>32	byte		0x6a		(uses BSD/OS shared libs)
+
+#
+# Big-endian 32-bit-int a.out, merged from sun (for old 68010 SunOS a.out),
+# mips (for old 68020(!) SGI a.out), and netbsd (for old big-endian a.out).
+#
+# XXX - is there anything we can look at to distinguish old SunOS 68010
+# from old 68020 IRIX from old NetBSD?  Again, I guess we could look at
+# the first instruction or instructions in the program.
+#
+0	belong		0407		a.out big-endian 32-bit executable
+>16	belong		>0		not stripped
+
+0	belong		0410		a.out big-endian 32-bit pure executable
+>16	belong		>0		not stripped
+
+0	belong		0413		a.out big-endian 32-bit demand paged executable
+>16	belong		>0		not stripped
+

+ 82 - 78
magic/Magdir/archive

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: archive,v 1.73 2012/11/09 22:59:30 christos Exp $
+# $File: archive,v 1.79 2013/02/08 17:24:06 christos Exp $
 # archive:  file(1) magic for archive formats (see also "msdos" for self-
 #           extracting compressed archives)
 #
@@ -36,7 +36,60 @@
 0	string		070701		ASCII cpio archive (SVR4 with no CRC)
 0	string		070702		ASCII cpio archive (SVR4 with CRC)
 
-# Debian package (needs to go before regular portable archives)
+#
+# Various archive formats used by various versions of the "ar"
+# command.
+#
+
+#
+# Original UNIX archive formats.
+# They were written with binary values in host byte order, and
+# the magic number was a host "int", which might have been 16 bits
+# or 32 bits.  We don't say "PDP-11" or "VAX", as there might have
+# been ports to little-endian 16-bit-int or 32-bit-int platforms
+# (x86?) using some of those formats; if none existed, feel free
+# to use "PDP-11" for little-endian 16-bit and "VAX" for little-endian
+# 32-bit.  There might have been big-endian ports of that sort as
+# well.
+#
+0	leshort		0177555		very old 16-bit-int little-endian archive
+0	beshort		0177555		very old 16-bit-int big-endian archive
+0	lelong		0177555		very old 32-bit-int little-endian archive
+0	belong		0177555		very old 32-bit-int big-endian archive
+
+0	leshort		0177545		old 16-bit-int little-endian archive
+>2	string		__.SYMDEF	random library
+0	beshort		0177545		old 16-bit-int big-endian archive
+>2	string		__.SYMDEF	random library
+0	lelong		0177545		old 32-bit-int little-endian archive
+>4	string		__.SYMDEF	random library
+0	belong		0177545		old 32-bit-int big-endian archive
+>4	string		__.SYMDEF	random library
+
+#
+# From "pdp" (but why a 4-byte quantity?)
+#
+0	lelong		0x39bed		PDP-11 old archive
+0	lelong		0x39bee		PDP-11 4.0 archive
+
+#
+# XXX - what flavor of APL used this, and was it a variant of
+# some ar archive format?  It's similar to, but not the same
+# as, the APL workspace magic numbers in pdp.
+#
+0	long		0100554		apl workspace
+
+#
+# System V Release 1 portable(?) archive format.
+#
+0	string		=<ar>		System V Release 1 ar archive
+!:mime	application/x-archive
+
+#
+# Debian package; it's in the portable archive format, and needs to go
+# before the entry for regular portable archives, as it's recognized as
+# a portable archive whose first member has a name beginning with
+# "debian".
 #
 0	string		=!<arch>\ndebian
 !:mime	application/x-debian-package
@@ -53,23 +106,14 @@
 #>84	string		gz		\b, uses gzip compression
 #>136	ledate		x		created: %s
 
-0	string		=!<thin>\n	thin archive with
->68	belong		0		no symbol entries
->68	belong		1		%d symbol entry
->68	belong		>1		%d symbol entries
-
-# other archives
-0	long		0177555		very old archive
-0	short		0177555		very old PDP-11 archive
-0	long		0177545		old archive
-0	short		0177545		old PDP-11 archive
-0	long		0100554		apl workspace
-0	string		=<ar>		archive
-!:mime	application/x-archive
-
-# MIPS archive (needs to go before regular portable archives)
+#
+# MIPS archive; they're in the portable archive format, and need to go
+# before the entry for regular portable archives, as it's recognized as
+# a portable archive whose first member has a name beginning with
+# "__________E".
 #
 0	string	=!<arch>\n__________E	MIPS archive
+!:mime	application/x-archive
 >20	string	U			with MIPS Ucode members
 >21	string	L			with MIPSEL members
 >21	string	B			with MIPSEB members
@@ -80,56 +124,20 @@
 0	search/1	-h-		Software Tools format archive text
 
 #
-# XXX - why are there multiple <ar> thingies?  Note that 0x213c6172 is
-# "!<ar", so, for new-style (4.xBSD/SVR2andup) archives, we have:
-#
-# 0	string		=!<arch>		current ar archive
-# 0	long		0x213c6172	archive file
-#
-# and for SVR1 archives, we have:
-#
-# 0	string		\<ar>		System V Release 1 ar archive
-# 0	string		=<ar>		archive
-#
-# XXX - did Aegis really store shared libraries, breakpointed modules,
-# and absolute code program modules in the same format as new-style
-# "ar" archives?
+# BSD/SVR2-and-later portable archive formats.
 #
 0	string		=!<arch>		current ar archive
 !:mime	application/x-archive
 >8	string		__.SYMDEF	random library
->0	belong		=65538		- pre SR9.5
->0	belong		=65539		- post SR9.5
->0	beshort		2		- object archive
->0	beshort		3		- shared library module
->0	beshort		4		- debug break-pointed module
->0	beshort		5		- absolute code program module
-0	string		\<ar>		System V Release 1 ar archive
-0	string		=<ar>		archive
-#
-# XXX - from "vax", which appears to collect a bunch of byte-swapped
-# thingies, to help you recognize VAX files on big-endian machines;
-# with "leshort", "lelong", and "string", that's no longer necessary....
-#
-0	belong		0x65ff0000	VAX 3.0 archive
-0	belong		0x3c61723e	VAX 5.0 archive
-#
-0	long		0x213c6172	archive file
-0	lelong		0177555		very old VAX archive
-0	leshort		0177555		very old PDP-11 archive
-#
-# XXX - "pdp" claims that 0177545 can have an __.SYMDEF member and thus
-# be a random library (it said 0xff65 rather than 0177545).
-#
-0	lelong		0177545		old VAX archive
->8	string		__.SYMDEF	random library
-0	leshort		0177545		old PDP-11 archive
->8	string		__.SYMDEF	random library
+>68	string		__.SYMDEF\ SORTED	random library
+
 #
-# From "pdp" (but why a 4-byte quantity?)
+# "Thin" archive, as can be produced by GNU ar.
 #
-0	lelong		0x39bed		PDP-11 old archive
-0	lelong		0x39bee		PDP-11 4.0 archive
+0	string		=!<thin>\n	thin archive with
+>68	belong		0		no symbol entries
+>68	belong		1		%d symbol entry
+>68	belong		>1		%d symbol entries
 
 # ARC archiver, from Daniel Quinlan (quinlan@yggdrasil.com)
 #
@@ -189,7 +197,10 @@
 # SAR
 3	string	LH5 SAR archive data
 # BSArc/BS2
-0	string	\212\3SB \0 BSArc/BS2 archive data
+0	string	\212\3SB\020\0	BSArc/BS2 archive data
+# Bethesda Softworks Archive (Oblivion)
+0	string	BSA\0 		BSArc archive data
+>4	lelong	x		version %d
 # MAR
 2	string	=-ah MAR archive data
 # ACB
@@ -214,7 +225,7 @@
 # AMGC
 0	string	\xad6" AMGC archive data
 # NuLIB
-0	string	NõFélå NuLIB archive data
+0	string	N\xc3\xb5F\xc3\xa9lx\xc3\xa5 NuLIB archive data
 # PakLeo
 0	string	LEOLZW PAKLeo archive data
 # ChArc
@@ -226,7 +237,7 @@
 # Freeze
 0	string	\x1f\x9f\x4a\x10\x0a Freeze archive data
 # KBoom
-0	string	¨MP¨ KBoom archive data
+0	string	\xc2\xa8MP\xc2\xa8 KBoom archive data
 # NSQ, must go after CDC Codec
 0	string	\x76\xff NSQ archive data
 # DPA
@@ -264,7 +275,7 @@
 # MP3 (archiver, not lossy audio compression)
 0	string	MP3\x1a MP3-Archiver archive data
 # ZET
-0	string	OZÝ ZET archive data
+0	string	OZ\xc3\x9d ZET archive data
 # TSComp
 0	string	\x65\x5d\x13\x8c\x08\x01\x03\x00 TSComp archive data
 # ARQ
@@ -295,7 +306,7 @@
 # Xtreme
 0	string	ULEB\0 Xtreme archive data
 # Pack Magic
-0	string	@â\1\0 Pack Magic archive data
+0	string	@\xc3\xa2\1\0 Pack Magic archive data
 # BTS
 0	belong&0xfeffffff	0x1a034465 BTS archive data
 # ELI 5750
@@ -431,7 +442,7 @@
 # XPack Data
 0	string	xpa XPack archive data
 # XPack Single Data
-0	string	Í\ jm XPack single archive data
+0	string	\xc3\x8d\ jm XPack single archive data
 
 # TODO: missing due to unknown magic/magic at end of file:
 #DWC
@@ -666,11 +677,10 @@
 !:mime	application/vnd.oasis.opendocument.image-template
 
 #  EPUB (OEBPS) books using OCF (OEBPS Container Format)
-#    From: Adam Buchbinder <adam.buchbinder@gmail.com>
 #    http://www.idpf.org/ocf/ocf1.0/download/ocf10.htm, section 4.
-#    (mimetype contains "application/epub+zip")
->>50	string	epub+zip		EPUB ebook data
-!:mime	application/epub+zip
+#    From: Ralf Brown <ralf.brown@gmail.com>
+>0x1E	string	mimetypeapplication/epub+zip	EPUB document
+!:mime application/epub+zip
 
 #  Catch other ZIP-with-mimetype formats
 #	In a ZIP file, the bytes immediately after a member's contents are
@@ -895,14 +905,8 @@
 #   archive must be an uncompressed file called 'mimetype' with contents
 #   'application/epub+zip'
 
-# start by checking that this is a ZIP archive, then check for the
-#   proper mimetype file
-# From: Ralf Brown <ralf.brown@gmail.com>
-0	string	PK\003\004
->0x1E	string	mimetypeapplication/epub+zip	EPUB document
-!:mime application/epub+zip
 
-# From: "Michał Górny" <mgorny@gentoo.org>
+# From: "Michael Gorny" <mgorny@gentoo.org>
 # ZPAQ: http://mattmahoney.net/dc/zpaq.html
 0	string	zPQ	ZPAQ stream
 >3	byte	x	\b, level %d

+ 8 - 8
magic/Magdir/assembler

@@ -1,18 +1,18 @@
 #------------------------------------------------------------------------------
-# $File: assembler,v 1.2 2012/10/31 18:41:42 christos Exp $
+# $File: assembler,v 1.4 2013/01/04 23:31:11 christos Exp $
 # make:  file(1) magic for assembler source
 #
-0	regex	\^[\020\t]*\.asciiz\?		assembler source text
+0	regex	\^[\020\t]*\\.asciiz		assembler source text
 !:mime	text/x-asm
-0	regex	\^[\020\t]*\.byte		assembler source text
+0	regex	\^[\020\t]*\\.byte		assembler source text
 !:mime	text/x-asm
-0	regex	\^[\020\t]*\.even		assembler source text
+0	regex	\^[\020\t]*\\.even		assembler source text
 !:mime	text/x-asm
-0	regex	\^[\020\t]*\.globl		assembler source text
+0	regex	\^[\020\t]*\\.globl		assembler source text
 !:mime	text/x-asm
-0	regex	\^[\020\t]*\.text		assembler source text
+0	regex	\^[\020\t]*\\.text		assembler source text
 !:mime	text/x-asm
-0	regex	\^[\020\t]*\.file		assembler source text
+0	regex	\^[\020\t]*\\.file		assembler source text
 !:mime	text/x-asm
-0	regex	\^[\020\t]*\.type		assembler source text
+0	regex	\^[\020\t]*\\.type		assembler source text
 !:mime	text/x-asm

+ 2 - 2
magic/Magdir/audio

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: audio,v 1.65 2012/10/31 13:38:40 christos Exp $
+# $File: audio,v 1.66 2013/02/06 14:18:52 christos Exp $
 # audio:  file(1) magic for sound formats (see also "iff")
 #
 # Jan Nicolai Langfeldt (janl@ifi.uio.no), Dan Quinlan (quinlan@yggdrasil.com),
@@ -512,7 +512,7 @@
 >>12		ulelong		x		\b, sample rate %d
 
 # adlib sound files
-# From Gürkan Sengün <gurkan@linuks.mine.nu>, http://www.linuks.mine.nu
+# From Gurkan Sengun <gurkan@linuks.mine.nu>, http://www.linuks.mine.nu
 0    	string		RAWADATA	RdosPlay RAW
 
 1068	string		RoR		AMUSIC Adlib Tracker

+ 3 - 13
magic/Magdir/bsdi

@@ -1,25 +1,15 @@
 
 #------------------------------------------------------------------------------
-# $File: bsdi,v 1.5 2009/09/19 16:28:08 christos Exp $
+# $File: bsdi,v 1.6 2013/01/09 22:37:24 christos Exp $
 # bsdi:  file(1) magic for BSD/OS (from BSDI) objects
+# Some object/executable formats use the same magic numbers as are used
+# in other OSes; those are handled by entries in aout.
 #
 
 0	lelong		0314		386 compact demand paged pure executable
 >16	lelong		>0		not stripped
 >32	byte		0x6a		(uses shared libs)
 
-0	lelong		0407		386 executable
->16	lelong		>0		not stripped
->32	byte		0x6a		(uses shared libs)
-
-0	lelong		0410		386 pure executable
->16	lelong		>0		not stripped
->32	byte		0x6a		(uses shared libs)
-
-0	lelong		0413		386 demand paged pure executable
->16	lelong		>0		not stripped
->32	byte		0x6a		(uses shared libs)
-
 # same as in SunOS 4.x, except for static shared libraries
 0	belong&077777777	0600413		sparc demand paged
 >0	byte		&0x80

+ 12 - 12
magic/Magdir/cafebabe

@@ -1,13 +1,13 @@
 
 #------------------------------------------------------------------------------
-# $File: cafebabe,v 1.10 2012/10/31 16:32:01 christos Exp $
+# $File: cafebabe,v 1.12 2013/01/11 16:45:23 christos Exp $
 # Cafe Babes unite!
 #
-# Since Java bytecode and Mach-O fat-files have the same magic number, the test
-# must be performed in the same "magic" sequence to get both right.  The long
-# at offset 4 in a mach-O fat file tells the number of architectures; the short at
-# offset 4 in a Java bytecode file is the JVM minor version and the
-# short at offset 6 is the JVM major version.  Since there are only 
+# Since Java bytecode and Mach-O universal binaries have the same magic number,
+# the test must be performed in the same "magic" sequence to get both right.
+# The long at offset 4 in a Mach-O universal binary tells the number of
+# architectures; the short at offset 4 in a Java bytecode file is the JVM minor
+# version and the short at offset 6 is the JVM major version.  Since there are only 
 # only 18 labeled Mach-O architectures at current, and the first released 
 # Java class format was version 43.0, we can safely choose any number
 # between 18 and 39 to test the number of architectures against
@@ -30,14 +30,14 @@
 >>4	belong		0x0032		(Java 1.6)
 
 0	belong		0xcafed00d	JAR compressed with pack200,
->>5	byte		x		version %d.
->>4	byte		x		\b%d
+>5	byte		x		version %d.
+>4	byte		x		\b%d
 !:mime	application/x-java-pack200
 
 
 0	belong		0xcafed00d	JAR compressed with pack200,
->>5	byte		x		version %d.
->>4	byte		x		\b%d
+>5	byte		x		version %d.
+>4	byte		x		\b%d
 !:mime	application/x-java-pack200
 
 ### JAVA END ###
@@ -64,10 +64,10 @@
 >0	belong		x		\b]
 
 0	belong		0xcafebabe
->4	belong		1		Mach-O fat file with 1 architecture:
+>4	belong		1		Mach-O universal binary with 1 architecture:
 >>8	use		mach-o
 >4	belong		>1
->>4	belong		<20		Mach-O fat file with %ld architectures:
+>>4	belong		<20		Mach-O universal binary with %ld architectures:
 >>>8	use		mach-o
 >>>28	use		mach-o
 >>>4	belong		>2

+ 2 - 2
magic/Magdir/commands

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: commands,v 1.43 2012/06/21 01:08:56 christos Exp $
+# $File: commands,v 1.45 2013/02/06 14:18:52 christos Exp $
 # commands:  file(1) magic for various shells and interpreters
 #
 #0	string/w	:			shell archive or script for antique kernel text
@@ -80,7 +80,7 @@
 !:strength + 10
 !:mime	text/x-php
 # Smarty compiled template, http://www.smarty.net/
-# Elan Ruusamäe <glen@delfi.ee>
+# Elan Ruusamae <glen@delfi.ee>
 0	string	=<?php\ /*\ Smarty\ version	Smarty compiled template
 >24	regex	[0-9.]+				\b, version %s
 !:mime	text/x-php

+ 3 - 3
magic/Magdir/console

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: console,v 1.18 2010/09/20 19:19:17 rrt Exp $
+# $File: console,v 1.19 2013/02/06 14:18:52 christos Exp $
 # Console game magic
 # Toby Deshane <hac@shoelace.digivill.net>
 #    ines:  file(1) magic for Marat's iNES Nintendo Entertainment System
@@ -137,7 +137,7 @@
 >113	string	x		(%s)
 
 #------------------------------------------------------------------------------
-# Microsoft Xbox executables .xbe (Esa Hyytiä <ehyytia@cc.hut.fi>)
+# Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@cc.hut.fi>)
 0       string          XBEH            XBE, Microsoft Xbox executable
 # probabilistic checks whether signed or not
 >0x0004 ulelong =0x0
@@ -177,7 +177,7 @@
 # From: Serge van den Boom <svdb@stack.nl>
 0	string		\x01ZZZZZ\x01	3DO "Opera" file system
 
-# From Gürkan Sengün <gurkan@linuks.mine.nu>, www.linuks.mine.nu
+# From Gurkan Sengun <gurkan@linuks.mine.nu>, www.linuks.mine.nu
 0	string		GBS		Nintendo Gameboy Music/Audio Data
 12	string		GameBoy\ Music\ Module	Nintendo Gameboy Music Module
 

+ 2 - 10
magic/Magdir/database

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: database,v 1.30 2012/08/26 10:23:30 christos Exp $
+# $File: database,v 1.32 2013/02/06 14:18:52 christos Exp $
 # database:  file(1) magic for various databases
 #
 # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
@@ -271,14 +271,6 @@
 >48	lequad		x			\b, rnum=%lld
 >56	lequad		x			\b, fsiz=%lld
 
-# G-IR database made by gobject-introspect toolset,
-# http://live.gnome.org/GObjectIntrospection
-0	string		GOBJ\nMETADATA\r\n\032	G-IR binary database
->16	byte		x			\b, v%d
->17	byte		x			\b.%d
->20	leshort		x			\b, %d entries
->22	leshort		x			\b/%d local
-
 # Type:	QDBM Quick Database Manager
 # From:	Benoit Sibaud <bsibaud@april.org>
 0	string		\\[depot\\]\n\f		Quick Database Manager, little endian
@@ -290,7 +282,7 @@
 0	string		ToKyO\ CaBiNeT\n	TokyoCabinet database
 >14	string		x			(version %s)
 
-# From:  Stéphane Blondon http://www.yaal.fr
+# From:  Stephane Blondon http://www.yaal.fr
 # Database file for Zope (done by FileStorage)
 0	string		FS21	Zope Object Database File Storage (data)
 # Cache file for the database of Zope (done by ClientStorage)

+ 15 - 15
magic/Magdir/digital

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: digital,v 1.10 2011/05/03 01:44:17 christos Exp $
+# $File: digital,v 1.11 2013/01/11 16:45:23 christos Exp $
 #  Digital UNIX - Info
 #
 0	string	=!<arch>\n________64E	Alpha archive
@@ -8,20 +8,20 @@
 #
 
 0	leshort		0603
->>24	leshort		0410		COFF format alpha pure
->>24	leshort		0413		COFF format alpha demand paged
->>>22	leshort&030000	!020000		executable
->>>22	leshort&020000	!0		dynamically linked
->>>16	lelong		!0		not stripped
->>>16	lelong		0		stripped
->>>27	byte		x		- version %d
->>>26	byte		x		\b.%d
->>>28	byte		x		\b-%d
->>24	leshort		0407		COFF format alpha object
->>>22	leshort&030000	020000		shared library
->>>27	byte		x		- version %d
->>>26	byte		x		\b.%d
->>>28	byte		x		\b-%d
+>24	leshort		0410		COFF format alpha pure
+>24	leshort		0413		COFF format alpha demand paged
+>>22	leshort&030000	!020000		executable
+>>22	leshort&020000	!0		dynamically linked
+>>16	lelong		!0		not stripped
+>>16	lelong		0		stripped
+>>27	byte		x		- version %d
+>>26	byte		x		\b.%d
+>>28	byte		x		\b-%d
+>24	leshort		0407		COFF format alpha object
+>>22	leshort&030000	020000		shared library
+>>27	byte		x		- version %d
+>>26	byte		x		\b.%d
+>>28	byte		x		\b-%d
 
 # Basic recognition of Digital UNIX core dumps - Mike Bremford <mike@opac.bl.uk>
 #

+ 198 - 41
magic/Magdir/filesystems

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: filesystems,v 1.69 2012/12/18 17:28:43 christos Exp $
+# $File: filesystems,v 1.76 2013/02/18 18:45:41 christos Exp $
 # filesystems:  file(1) magic for different filesystems
 #
 0	string	\366\366\366\366	PC formatted floppy with no filesystem
@@ -61,7 +61,7 @@
 # for any allowed sector sizes
 30		search/481	\x55\xAA	
 # to display x86 boot sector (40) before old one (strength=50), SYSLINUX MBR (?) and DOS BPB information (71) like in previous file version
-!:strength +40
+!:strength +30
 # for sector sizes < 512 Bytes
 >11		uleshort	<512		
 >>(11.s-2)	uleshort	0xAA55		x86 boot sector
@@ -73,8 +73,155 @@
 # to display information (51) before DOS BPB (strength=71) and after DOS floppy (120) like in old file version
 !:strength +21
 >2	string	OSBS			\b, OS/BS MBR
-# J\xf6rg Jenderek <joerg dot jenderek at web dot de>
->0x8C	string	Invalid\ partition\ table	\b, MS-DOS MBR
+# added by Joerg Jenderek at Feb 2013 according to http://thestarman.pcministry.com/asm/mbr/
+# and http://en.wikipedia.org/wiki/Master_Boot_Record
+# test for nearly all MS-DOS Master Boot Record initial program loader (IPL) is now done by 
+# characteristic assembler instructions: xor ax,ax;mov ss,ax;mov sp,7c00
+>0	search/2	\x33\xc0\x8e\xd0\xbc\x00\x7c	MS-MBR
+# Microsoft Windows 95A and early ( http://thestarman.pcministry.com/asm/mbr/STDMBR.htm )
+# assembler instructions: mov si,sp;push ax;pop es;push ax;pop ds;sti;cld
+>>8	ubequad		0x8bf45007501ffbfc		
+# http://thestarman.pcministry.com/asm/mbr/200MBR.htm
+>>>0x16	ubyte		0xF3				\b,DOS 2
+>>>>219	regex		Author\ -\ 			Author:
+# found "David Litton" , "A Pehrsson  "
+>>>>>&0	string		x				"%s"
+>>>0x16	ubyte		0xF2				
+# NEC MS-DOS 3.30 Rev. 3 . See http://thestarman.pcministry.com/asm/mbr/DOS33MBR.htm
+# assembler instructions: mov di,077c;cmp word ptrl[di],a55a;jnz
+>>>>0x22	ubequad	0xbf7c07813d5aa575		\b,NEC 3.3
+# version MS-DOS 3.30 til MS-Windows 95A (WinVer=4.00.1111)
+>>>>0x22	default	x				\b,D0S version 3.3-7.0
+# error messages are printed by assembler instructions: mov si,06nn;...;int 10 (0xBEnn06;...)
+# where nn is string offset varying for different languages
+# "Invalid partition table"				nn=0x8b for english version
+>>>>>(0x49.b)	string		Invalid\ partition\ table		english
+>>>>>(0x49.b)	string		Ung\201ltige\ Partitionstabelle		german
+>>>>>(0x49.b)	string		Table\ de\ partition\ invalide		french
+>>>>>(0x49.b)	string		Tabela\ de\ parti\207ao\ inv\240lida	portuguese
+>>>>>(0x49.b)	string		Tabla\ de\ partici\242n\ no\ v\240lida	spanish
+>>>>>(0x49.b)	string		Tavola\ delle\ partizioni\ non\ valida	italian
+>>>>>0x49	ubyte		>0			at offset 0x%x
+>>>>>>(0x49.b)	string		>\0			"%s"
+# "Error loading operating system"			nn=0xa3 for english version
+# "Fehler beim Laden des Betriebssystems"		nn=0xa7 for german version
+# "Erreur en chargeant syst\212me d'exploitation"	nn=0xa7 for french version
+# "Erro na inicializa\207ao do sistema operacional"	nn=0xa7 for portuguese Brazilian version
+# "Error al cargar sistema operativo"			nn=0xa8 for spanish version
+# "Errore durante il caricamento del sistema operativo"	nn=0xae for italian version
+>>>>>0x74	ubyte		>0			at offset 0x%x
+>>>>>>(0x74.b)	string		>\0			"%s"
+# "Missing operating system"				nn=0xc2 for english version
+# "Betriebssystem fehlt"				nn=0xcd for german version
+# "Syst\212me d'exploitation absent"			nn=0xd2 for french version
+# "Sistema operacional nao encontrado"			nn=0xd4 for portuguese Brazilian version
+# "Falta sistema operativo"				nn=0xca for spanish version
+# "Sistema operativo mancante"				nn=0xe2 for italian version
+>>>>>0x79	ubyte		>0			at offset 0x%x
+>>>>>>(0x79.b)	string		>\0			"%s"
+# Microsoft Windows 95B to XP (http://thestarman.pcministry.com/asm/mbr/95BMEMBR.htm)
+# assembler instructions: push ax;pop es;push  ax;pop ds;cld;mov si,7c1b
+>>8	ubequad		0x5007501ffcbe1b7c		
+# assembler instructions: rep;movsb;retf;mov si,07be;mov cl,04
+>>>24		ubequad	0xf3a4cbbebe07b104		9M
+# "Invalid partition table"				nn=0x10F for english version
+# "Ungültige Partitionstabelle"				nn=0x10F for german version
+# "Table de partition erronée"				nn=0x10F for french version
+# "\216\257\245\340\240\346\250\256\255\255\240\357 \341\250\341\342\245\254\240 \255\245 \255\240\251\244\245\255\240"	nn=0x10F for russian version
+>>>>(0x3C.b+0x0FF)	string	Invalid\ partition\ table		english
+>>>>(0x3C.b+0x0FF)	string	Ung\201ltige\ Partitionstabelle		german
+>>>>(0x3C.b+0x0FF)	string	Table\ de\ partition\ erron\202e	french
+>>>>(0x3C.b+0x0FF)	string	\215\245\257\340\240\242\250\253\354\255\240\357\ \342\240\241\253\250\346\240	russian
+>>>>0x3C		ubyte	x			at offset 0x%x+0xFF
+>>>>(0x3C.b+0x0FF)	string	>\0			"%s"
+# "Error loading operating system"			nn=0x127 for english version
+# "Fehler beim Laden des Betriebssystems"		nn=0x12b for german version
+# "Erreur lors du chargement du système d'exploitation"	nn=0x12a for french version
+# "\216\350\250\241\252\240 \257\340\250 \247\240\243\340\343\247\252\245 \256\257\245\340\240\346\250\256\255\255\256\251 \341\250\341\342\245\254\353"	nn=0x12d for russian version
+>>>>0xBD		ubyte	x			at offset 0x1%x
+>>>>(0xBD.b+0x100)	string	>\0			"%s"
+# "Missing operating system"				nn=0x146 for english version
+# "Betriebssystem fehlt"				nn=0x151 for german version
+# "Système d'exploitation manquant"			nn=0x15e for french version
+# "\216\257\245\340\240\346\250\256\255\255\240\357 \341\250\341\342\245\254\240 \255\245 \255\240\251\244\245\255\240"	nn=0x156 for russian version
+>>>>0xA9		ubyte	x			at offset 0x1%x
+>>>>(0xA9.b+0x100)	string	>\0			"%s"
+# http://thestarman.pcministry.com/asm/mbr/Win2kmbr.htm
+# assembler instructions: rep;movsb;retf;mov BP,07be;mov cl,04
+>>>24		ubequad	0xf3a4cbbdbe07b104		XP
+# where xxyyzz are lower bits from offsets of error messages varying for different languages
+>>>>0x1B4	ubelong&0x00FFFFFF	0x002c4463	english
+>>>>0x1B4	ubelong&0x00FFFFFF	0x002c486e	german
+# "Invalid partition table"				xx=0x12C for english version
+# "Ungültige Partitionstabelle"				xx=0x12C for german version
+>>>>0x1b5	ubyte		>0			at offset 0x1%x
+>>>>(0x1b5.b+0x100)	string	>\0			"%s"
+# "Error loading operating system"			yy=0x144 for english version
+# "Fehler beim Laden des Betriebssystems"		yy=0x148 for german version
+>>>>0x1b6	ubyte		>0			at offset 0x1%x
+>>>>(0x1b6.b+0x100)	string	>\0			"%s"
+# "Missing operating system"				zz=0x163 for english version
+# "Betriebssystem nicht vorhanden"			zz=0x16e for german version
+>>>>0x1b7	ubyte		>0			at offset 0x1%x
+>>>>(0x1b7.b+0x100)	string	>\0			"%s"
+# Microsoft Windows Vista or 7
+# assembler instructions: ..;mov ds,ax;mov si,7c00;mov di,..00
+>>8	ubequad		0xc08ed8be007cbf00		
+# Microsoft Windows Vista (http://thestarman.pcministry.com/asm/mbr/VistaMBR.htm)
+# assembler instructions: jnz 0729;cmp ebx,"TCPA"
+>>>0xEC		ubequad	0x753b6681fb544350		Vista
+# where xxyyzz are lower bits from offsets of error messages varying for different languages
+>>>>0x1B4	ubelong&0x00FFFFFF	0x00627a99	english
+#>>>>0x1B4	ubelong&0x00FFFFFF	?		german
+# "Invalid partition table"				xx=0x162 for english version
+# "Ungültige Partitionstabelle"				xx=0x1?? for german version
+>>>>0x1b5	ubyte		>0			at offset 0x1%x
+>>>>(0x1b5.b+0x100)	string	>\0			"%s"
+# "Error loading operating system"			yy=0x17a for english version
+# "Fehler beim Laden des Betriebssystems"		yy= 0x1?? for german version
+>>>>0x1b6	ubyte		>0			at offset 0x1%x
+>>>>(0x1b6.b+0x100)	string	>\0			"%s"
+# "Missing operating system"				zz=0x199 for english version
+# "Betriebssystem nicht vorhanden"			zz=0x1?? for german version
+>>>>0x1b7	ubyte		>0			at offset 0x1%x
+>>>>(0x1b7.b+0x100)	string	>\0			"%s"
+# Microsoft Windows 7 (http://thestarman.pcministry.com/asm/mbr/W7MBR.htm)
+# assembler instructions: cmp ebx,"TCPA";cmp
+>>>0xEC		ubequad	0x6681fb5443504175		Windows 7
+# where xxyyzz are lower bits from offsets of error messages varying for different languages
+>>>>0x1B4	ubelong&0x00FFFFFF	0x00637b9a	english
+#>>>>0x1B4	ubelong&0x00FFFFFF	?		german
+# "Invalid partition table"				xx=0x163 for english version
+# "Ungültige Partitionstabelle"				xx=0x1?? for german version
+>>>>0x1b5	ubyte		>0			at offset 0x1%x
+>>>>(0x1b5.b+0x100)	string	>\0			"%s"
+# "Error loading operating system"			yy=0x17b for english version
+# "Fehler beim Laden des Betriebssystems"		yy=0x1?? for german version
+>>>>0x1b6	ubyte		>0			at offset 0x1%x
+>>>>(0x1b6.b+0x100)	string	>\0			"%s"
+# "Missing operating system"				zz=0x19a for english version
+# "Betriebssystem nicht vorhanden"			zz=0x1?? for german version
+>>>>0x1b7	ubyte		>0			at offset 0x1%x
+>>>>(0x1b7.b+0x100)	string	>\0			"%s"
+# http://thestarman.pcministry.com/asm/mbr/Win2kmbr.htm#DiskSigs
+# http://en.wikipedia.org/wiki/MBR_disk_signature#ID
+>>0x1b8	ulelong		>0				\b, disk signature 0x%-.4x
+# driveID/timestamp for Win 95B,98,98SE and ME. See http://thestarman.pcministry.com/asm/mbr/mystery.htm
+>>0xDA	uleshort		0			
+>>>0xDC 	ulelong		>0			\b, created
+# physical drive number (0x80-0xFF) when the Windows wrote that byte to the drive
+>>>>0xDC	ubyte		x			with driveID 0x%x
+# hours, minutes and seconds 
+>>>>0xDf	ubyte		x			at %x
+>>>>0xDe	ubyte		x			\b:%x
+>>>>0xDd	ubyte		x			\b:%x
+# special case for Microsoft MS-DOS 3.21 spanish
+# assembler instructions: cli;mov $0x30,%ax;mov %ax,%ss;mov 
+>0	ubequad		0xfab830008ed0bc00		
+# assembler instructions: $0x1f00,%sp;mov $0x80cb,%di;add %cl,(%bx,%si);in (%dx),%ax;mov 
+>>8	ubequad		0x1fbfcb800008ed8		MS-MBR,D0S version 3.21 spanish
+# Microsoft MBR IPL end
+
 # dr-dos with some upper-, lowercase variants
 >0x9D	string	Invalid\ partition\ table$	
 >>181	string	No\ Operating\ System$		
@@ -93,30 +240,9 @@
 >>>>>>358	string	Press\ any\ key\ to\ continue.\n\r$	
 >>>>>>>387	string	Copyright\ (c)\ 1984,1998	
 >>>>>>>>411	string	Caldera\ Inc.\0		\b, DR-DOS MBR (IBMBIO.LDR)
->0x10F	string	Ung\201ltige\ Partitionstabelle	\b, MS-DOS MBR, german version 4.10.1998, 4.10.2222
->>0x1B8	ubelong	>0				\b, Serial 0x%-.4x
->0x8B	string	Ung\201ltige\ Partitionstabelle	\b, MS-DOS MBR, german version 5.00 to 4.00.950
->271	string	Invalid\ partition\ table\0		
->>295	string	Error\ loading\ operating\ system\0	
->>>326	string	Missing\ operating\ system\0		\b, mbr
 #
->139	string	Invalid\ partition\ table\0		
->>163	string	Error\ loading\ operating\ system\0	
->>>194	string	Missing\ operating\ system\0		\b, Microsoft Windows XP mbr
-# http://www.heise.de/ct/05/09/006/ page 184
-#HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices\DosDevices\?:=Serial4Bytes+8Bytes
->>>>0x1B8	ulelong	>0				\b,Serial 0x%-.4x
->300	string	Invalid\ partition\ table\0	
->>324	string	Error\ loading\ operating\ system\0
->>>355	string	Missing\ operating\ system\0		\b, Microsoft Windows XP MBR
-#??>>>389	string	Invalid\ system\ disk		
->>>>0x1B8	ulelong	>0				\b, Serial 0x%-.4x
->300	string	Ung\201ltige\ Partitionstabelle
-#split string to avoid error: String too long
->>328	string	Fehler\ beim\ Laden\ 	
->>>346	string	des\ Betriebssystems	
->>>>366	string	Betriebssystem\ nicht\ vorhanden	\b, Microsoft Windows XP MBR (german)
->>>>>0x1B8	ulelong	>0				\b, Serial 0x%-.4x
+# tests for different MS-DOS Master Boot Records (MBR) moved and merged
+#
 #>0x145	string	Default:\ F				\b, FREE-DOS MBR
 #>0x14B	string	Default:\ F				\b, FREE-DOS 1.0 MBR
 >0x145	search/7	Default:\ F			\b, FREE-DOS MBR
@@ -290,7 +416,7 @@
 >242	string	Bootsector\ from\ C.H.\ Hochst\204	
 # http://freecode.com/projects/dosfstools	dosfstools-n.m/src/mkdosfs.c
 # updated by Joerg Jenderek at Nov 2012. Use search directive with offset instead of string
-# skip name "C.H. Hochstätter" partly because it is sometimes written without umlaut
+# skip name "C.H. Hochstaetter" partly because it is sometimes written without umlaut
 >242	search/127	Bootsector\ from\ C.H.\ Hochst			
 >>278	search/127	No\ Systemdisk.\ Booting\ from\ harddisk	
 # followed by variants with point,CR-NL or NL-CR
@@ -1184,7 +1310,17 @@
 #>>>>>>>>>80	ulelong		=0		\b, checksum 0x%x=0 (usual)
 >>>>>>>>>0x258	ulelong&0x00009090	=0x00009090	
 >>>>>>>>>>&-92		indirect	x	\b; contains 
-### DOS boot sector end
+# For 2nd NTFS sector added by Joerg Jenderek at Jan 2013
+# http://thestarman.pcministry.com/asm/mbr/NTFSbrHexEd.htm
+# unused assembler instructions JMP y2;NOP;NOP
+0x056		ulelong&0xFFFF0FFF	0x909002EB	
+# unicode loadername terminated by CTRL-D
+>(0.s*2)	ulelong&0xFFFFFF00	0x00040000		
+# loadernames are NTLDR,CMLDR,PELDR,$LDR$ or BOOTMGR
+>>0x002		lestring16	x	Microsoft Windows XP/VISTA bootloader %-5.5s
+>>0x12		string		$	
+>>>0x0c		lestring16	x	\b%-2.2s
+### DOS,NTFS boot sectors end
 
 9564	lelong		0x00011954	Unix Fast File system [v1] (little-endian),
 >8404	string		x		last mounted on %s,
@@ -1351,32 +1487,40 @@
 # Minix filesystems - Juan Cespedes <cespedes@debian.org>
 0x410	leshort		0x137f
 !:strength / 2
->0x402	beshort		< 100		Minix filesystem, V1, %d zones
+>0x402	beshort		< 100
+>0x402	beshort		> -1		Minix filesystem, V1, %d zones
 >0x1e	string		minix		\b, bootable
 0x410	beshort		0x137f
 !:strength / 2
->0x402	beshort		< 100		Minix filesystem, V1 (big endian), %d zones
+>0x402	beshort		< 100
+>0x402	beshort		> -1		Minix filesystem, V1 (big endian), %d zones
 >0x1e	string		minix		\b, bootable
 0x410	leshort		0x138f
 !:strength / 2
->0x402	beshort		< 100		Minix filesystem, V1, 30 char names, %d zones
+>0x402	beshort		< 100
+>0x402	beshort		> -1		Minix filesystem, V1, 30 char names, %d zones
 >0x1e	string		minix		\b, bootable
 0x410	beshort		0x138f
 !:strength / 2
->0x402	beshort		< 100		Minix filesystem, V1, 30 char names (big endian), %d zones
+>0x402	beshort		< 100
+>0x402	beshort		> -1		Minix filesystem, V1, 30 char names (big endian), %d zones
 >0x1e	string		minix		\b, bootable
 0x410	leshort		0x2468
->0x402	beshort		< 100		Minix filesystem, V2, %d zones
+>0x402	beshort		< 100
+>>0x402	beshort		> -1		Minix filesystem, V2, %d zones
 >0x1e	string		minix		\b, bootable
 0x410	beshort		0x2468
->0x402	beshort		< 100		Minix filesystem, V2 (big endian), %d zones
+>0x402	beshort		< 100
+>0x402	beshort		> -1		Minix filesystem, V2 (big endian), %d zones
 >0x1e	string		minix		\b, bootable
 
 0x410	leshort		0x2478
->0x402	beshort		< 100		Minix filesystem, V2, 30 char names, %d zones
+>0x402	beshort		< 100
+>0x402	beshort		> -1		Minix filesystem, V2, 30 char names, %d zones
 >0x1e	string		minix		\b, bootable
 0x410	leshort		0x2478
->0x402	beshort		< 100		Minix filesystem, V2, 30 char names, %d zones
+>0x402	beshort		< 100
+>0x402	beshort		> -1		Minix filesystem, V2, 30 char names, %d zones
 >0x1e	string		minix		\b, bootable
 0x410	beshort		0x2478
 >0x402	beshort		!0		Minix filesystem, V2, 30 char names (big endian), %d zones
@@ -1454,8 +1598,8 @@
 #        10	SS, 8 SPT
 #        11	DS, 8 SPT
 #
-#  11111001	Double density 3½ floppy disk, high density 5¼
-#  11110000	High density 3½ floppy disk
+#  11111001	Double density 3 1/2 floppy disk, high density 5 1/4
+#  11110000	High density 3 1/2 floppy disk
 #  11111000	Hard disk any format
 #
 
@@ -1642,8 +1786,6 @@
 >28 leshort >3
 >>8	ledate	x	created: %s
 
-0	string		td\000		floppy image data (TeleDisk)
-
 # AFS Dump Magic
 # From: Ty Sarna <tsarna@sarna.org> 
 0       string                  \x01\xb3\xa1\x13\x22    AFS Dump
@@ -1820,3 +1962,18 @@
 >60	lelong	x		\b address of last segment written 0x%x,
 >64	lelong	x		\b address of next segment to write 0x%x,
 >68	lelong	x		\b address of current segment written 0x%x
+
+0	string	td\000		floppy image data (TeleDisk, compressed)
+0	string	TD\000		floppy image data (TeleDisk)
+
+0	string	CQ\024		floppy image data (CopyQM, 
+>16	leshort	x		%d sectors, 
+>18	leshort	x		%d heads.)
+
+0	string	ACT\020Apricot\020disk\020image\032\004	floppy image data (ApriDisk)
+
+0	beshort	0xAA58		floppy image data (IBM SaveDskF, old)
+0	beshort	0xAA59		floppy image data (IBM SaveDskF)
+0	beshort	0xAA5A		floppy image data (IBM SaveDskF, compressed)
+
+0	string	\074CPM_Disk\076	disk image data (YAZE)

+ 2 - 2
magic/Magdir/fonts

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: fonts,v 1.24 2012/08/26 10:32:10 christos Exp $
+# $File: fonts,v 1.25 2013/02/06 14:18:52 christos Exp $
 # fonts:  file(1) magic for font data
 #
 0	search/1	FONT		ASCII vfont text
@@ -75,7 +75,7 @@
 0	string		OTTO		OpenType font data
 !:mime application/vnd.ms-opentype
 
-# Gürkan Sengün <gurkan@linuks.mine.nu>, www.linuks.mine.nu 
+# Gurkan Sengun <gurkan@linuks.mine.nu>, www.linuks.mine.nu 
 0	string		SplineFontDB:	Spline Font Database 
 !:mime application/vnd.font-fontforge-sfd
 >14	string		x		version %s

+ 35 - 2
magic/Magdir/gnome-keyring

@@ -1,7 +1,8 @@
 
 #------------------------------------------------------------------------------
-# $File: gnome-keyring,v 1.3 2012/06/21 01:19:51 christos Exp $
-# GNOME keyring
+# $File: gnome,v 1.3 2013/02/05 15:20:47 christos Exp $
+# GNOME related files
+
 # Contributed by Josh Triplett
 # FIXME: Could be simplified if pstring supported two-byte counts
 0         string   GnomeKeyring\n\r\0\n GNOME keyring
@@ -24,3 +25,35 @@
 >>>>>>&24 ubelong  x                    \b, hash iterations %u
 >>>>>>&28 ubequad  x                    \b, salt %llu
 >>>>>>&52 ubelong  x                    \b, %u item(s)
+
+# From: Alex Beregszaszi <alex@fsn.hu>
+4	string	gtktalog		GNOME Catalogue (gtktalog)
+>13	string	>\0			version %s
+
+# Summary: GStreamer binary registry
+# Extension: .bin
+# Submitted by: Josh Triplett <josh@joshtriplett.org>
+0	belong	0xc0def00d		GStreamer binary registry
+>4	string	x			\b, version %s
+
+# GVariant Database file
+# By Elan Ruusamae <glen@delfi.ee>
+# https://github.com/GNOME/gvdb/blob/master/gvdb-format.h
+# It's always "GVariant", it's byte swapped on incompatible archs
+# See https://github.com/GNOME/gvdb/blob/master/gvdb-builder.c
+# file_builder_serialise()
+# http://developer.gnome.org/glib/2.34/glib-GVariant.html#GVariant
+0	string	GVariant	GVariant Database file,
+# version is never filled. probably future extension
+>8	lelong	x		version %d
+# not sure are these usable, so commented out
+#>>16	lelong	x		start %d,
+#>>>20	lelong	x		end %d
+
+# G-IR database made by gobject-introspect toolset,
+# http://live.gnome.org/GObjectIntrospection
+0	string		GOBJ\nMETADATA\r\n\032	G-IR binary database
+>16	byte		x			\b, v%d
+>17	byte		x			\b.%d
+>20	leshort		x			\b, %d entries
+>22	leshort		x			\b/%d local

+ 241 - 0
magic/Magdir/gpt

@@ -0,0 +1,241 @@
+
+#------------------------------------------------------------------------------
+# $File: gpt,v 1.1 2013/02/18 18:31:09 christos Exp $
+#
+# GPT Partition table patterns.
+# Author: Rogier Goossens (goossens.rogier@gmail.com)
+# Note that a GPT-formatted disk must contain an MBR as well.
+#
+
+# The initial segment (up to >>>>>>>>422) was copied from the X86
+# partition table code (aka MBR).
+# This is kept separate, so that MBR partitions are not reported as well.
+# (use -k if you do want them as well)
+
+# First, detect the MBR partiton table
+# If more than one GPT protective MBR partition exists, don't print anything
+# (the other MBR detection code will then just print the MBR partition table)
+0x1FE			leshort		0xAA55
+>3			string		!MS
+>>3			string		!SYSLINUX
+>>>3			string		!MTOOL
+>>>>3			string		!NEWLDR
+>>>>>5			string		!DOS
+# not FAT (32 bit)
+>>>>>>82		string		!FAT32
+#not Linux kernel
+>>>>>>>514		string		!HdrS
+#not BeOS
+>>>>>>>>422		string		!Be\ Boot\ Loader
+# GPT with protective MBR entry in partition 1 (only)
+>>>>>>>>>450		ubyte		0xee
+>>>>>>>>>>466		ubyte		!0xee
+>>>>>>>>>>>482		ubyte		!0xee
+>>>>>>>>>>>>498		ubyte		!0xee
+#>>>>>>>>>>>>>446	use		gpt-mbr-partition
+>>>>>>>>>>>>>(454.l*8192)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>0			use		gpt-mbr-type
+>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>0			ubyte		x		of 8192 bytes		
+>>>>>>>>>>>>>(454.l*8192)	string		!EFI\ PART
+>>>>>>>>>>>>>>(454.l*4096)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>0		ubyte		x		of 4096 bytes
+>>>>>>>>>>>>>>(454.l*4096)	string		!EFI\ PART
+>>>>>>>>>>>>>>>(454.l*2048)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>0		ubyte		x		of 2048 bytes
+>>>>>>>>>>>>>>>(454.l*2048)	string		!EFI\ PART
+>>>>>>>>>>>>>>>>(454.l*1024)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>>0		ubyte		x		of 1024 bytes
+>>>>>>>>>>>>>>>>(454.l*1024)	string		!EFI\ PART
+>>>>>>>>>>>>>>>>>(454.l*512)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>>>0		ubyte		x		of 512 bytes
+# GPT with protective MBR entry in partition 2 (only)
+>>>>>>>>>450		ubyte		!0xee
+>>>>>>>>>>466		ubyte		0xee
+>>>>>>>>>>>482		ubyte		!0xee
+>>>>>>>>>>>>498		ubyte		!0xee
+#>>>>>>>>>>>>>462	use		gpt-mbr-partition
+>>>>>>>>>>>>>(470.l*8192)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>0			use		gpt-mbr-type
+>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>0			ubyte		x		of 8192 bytes		
+>>>>>>>>>>>>>(470.l*8192)	string		!EFI\ PART
+>>>>>>>>>>>>>>(470.l*4096)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>0		ubyte		x		of 4096 bytes
+>>>>>>>>>>>>>>(470.l*4096)	string		!EFI\ PART
+>>>>>>>>>>>>>>>(470.l*2048)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>0		ubyte		x		of 2048 bytes
+>>>>>>>>>>>>>>>(470.l*2048)	string		!EFI\ PART
+>>>>>>>>>>>>>>>>(470.l*1024)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>>0		ubyte		x		of 1024 bytes
+>>>>>>>>>>>>>>>>(470.l*1024)	string		!EFI\ PART
+>>>>>>>>>>>>>>>>>(470.l*512)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>>>0		ubyte		x		of 512 bytes
+# GPT with protective MBR entry in partition 3 (only)
+>>>>>>>>>450		ubyte		!0xee
+>>>>>>>>>>466		ubyte		!0xee
+>>>>>>>>>>>482		ubyte		0xee
+>>>>>>>>>>>>498		ubyte		!0xee
+#>>>>>>>>>>>>>478	use		gpt-mbr-partition
+>>>>>>>>>>>>>(486.l*8192)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>0			use		gpt-mbr-type
+>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>0			ubyte		x		of 8192 bytes		
+>>>>>>>>>>>>>(486.l*8192)	string		!EFI\ PART
+>>>>>>>>>>>>>>(486.l*4096)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>0		ubyte		x		of 4096 bytes
+>>>>>>>>>>>>>>(486.l*4096)	string		!EFI\ PART
+>>>>>>>>>>>>>>>(486.l*2048)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>0		ubyte		x		of 2048 bytes
+>>>>>>>>>>>>>>>(486.l*2048)	string		!EFI\ PART
+>>>>>>>>>>>>>>>>(486.l*1024)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>>0		ubyte		x		of 1024 bytes
+>>>>>>>>>>>>>>>>(486.l*1024)	string		!EFI\ PART
+>>>>>>>>>>>>>>>>>(486.l*512)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>>>0		ubyte		x		of 512 bytes
+# GPT with protective MBR entry in partition 4 (only)
+>>>>>>>>>450		ubyte		!0xee
+>>>>>>>>>>466		ubyte		!0xee
+>>>>>>>>>>>482		ubyte		!0xee
+>>>>>>>>>>>>498		ubyte		0xee
+#>>>>>>>>>>>>>494	use		gpt-mbr-partition
+>>>>>>>>>>>>>(502.l*8192)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>0			use		gpt-mbr-type
+>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>0			ubyte		x		of 8192 bytes		
+>>>>>>>>>>>>>(502.l*8192)	string		!EFI\ PART
+>>>>>>>>>>>>>>(502.l*4096)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>0		ubyte		x		of 4096 bytes
+>>>>>>>>>>>>>>(502.l*4096)	string		!EFI\ PART
+>>>>>>>>>>>>>>>(502.l*2048)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>0		ubyte		x		of 2048 bytes
+>>>>>>>>>>>>>>>(502.l*2048)	string		!EFI\ PART
+>>>>>>>>>>>>>>>>(502.l*1024)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>>0		ubyte		x		of 1024 bytes
+>>>>>>>>>>>>>>>>(502.l*1024)	string		!EFI\ PART
+>>>>>>>>>>>>>>>>>(502.l*512)	string		EFI\ PART	GPT partition table
+>>>>>>>>>>>>>>>>>>0		use		gpt-mbr-type
+>>>>>>>>>>>>>>>>>>&-8		use		gpt-table
+>>>>>>>>>>>>>>>>>>0		ubyte		x		of 512 bytes
+
+# The following code does GPT detection and processing, including
+# sector size detection.
+# It has to be duplicated above because the top-level pattern
+# (i.e. not called using 'use') must print *something* for file
+# to count it as a match. Text only printed in named patterns is
+# not counted, and causes file to continue, and try and match
+# other patterns.
+#
+# Unfortunately, when assuming sector sizes >=16k, if the sector size
+# happens to be 512 instead, we may find confusing data after the GPT
+# table...  If the GPT table has less than 128 entries, this may even
+# happen for assumed sector sizes as small as 4k
+# This could be solved by checking for the presence of the backup GPT
+# header as well, but that makes the logic extremely complex
+##0		name		gpt-mbr-partition
+##>(8.l*8192)	string		EFI\ PART
+##>>(8.l*8192)	use		gpt-mbr-type
+##>>&-8		use		gpt-table
+##>>0		ubyte		x		of 8192 bytes		
+##>(8.l*8192)	string		!EFI\ PART
+##>>(8.l*4096)	string		EFI\ PART	GPT partition table
+##>>>0		use		gpt-mbr-type
+##>>>&-8		use		gpt-table
+##>>>0		ubyte		x		of 4096 bytes
+##>>(8.l*4096)	string		!EFI\ PART
+##>>>(8.l*2048)	string		EFI\ PART	GPT partition table