Browse Source

Import upstream version 5.12

Christos Zoulas 12 years ago
parent
commit
6c202eae67
82 changed files with 4831 additions and 2791 deletions
  1. 33 0
      ChangeLog
  2. 8 5
      Makefile.in
  3. 13 3
      TODO
  4. 1 12
      aclocal.m4
  5. 91 50
      config.h.in
  6. 1649 1242
      configure
  7. 23 43
      configure.ac
  8. 6 3
      doc/Makefile.in
  9. 34 5
      doc/file.man
  10. 37 4
      doc/magic.man
  11. 480 251
      install-sh
  12. 77 0
      m4/visibility.m4
  13. 9 5
      magic/Magdir/adventure
  14. 4 1
      magic/Magdir/amigaos
  15. 4 8
      magic/Magdir/animation
  16. 47 1
      magic/Magdir/apple
  17. 19 8
      magic/Magdir/archive
  18. 10 6
      magic/Magdir/assembler
  19. 2 1
      magic/Magdir/audio
  20. 6 6
      magic/Magdir/c-lang
  21. 43 5
      magic/Magdir/cafebabe
  22. 5 5
      magic/Magdir/claris
  23. 4 1
      magic/Magdir/commands
  24. 1 3
      magic/Magdir/convex
  25. 8 0
      magic/Magdir/cubemap
  26. 19 45
      magic/Magdir/cups
  27. 6 1
      magic/Magdir/database
  28. 13 2
      magic/Magdir/diff
  29. 2 1
      magic/Magdir/dolby
  30. 34 72
      magic/Magdir/dump
  31. 159 237
      magic/Magdir/elf
  32. 10 1
      magic/Magdir/epoc
  33. 429 178
      magic/Magdir/filesystems
  34. 9 1
      magic/Magdir/fonts
  35. 2 1
      magic/Magdir/fortran
  36. 13 1
      magic/Magdir/geo
  37. 2 2
      magic/Magdir/gnome-keyring
  38. 16 1
      magic/Magdir/gnu
  39. 8 1
      magic/Magdir/ibm6000
  40. 116 22
      magic/Magdir/images
  41. 17 0
      magic/Magdir/javascript
  42. 15 2
      magic/Magdir/jpeg
  43. 20 0
      magic/Magdir/keepass
  44. 8 3
      magic/Magdir/linux
  45. 112 65
      magic/Magdir/mach
  46. 7 0
      magic/Magdir/macos
  47. 2 1
      magic/Magdir/mail.news
  48. 4 10
      magic/Magdir/matroska
  49. 41 2
      magic/Magdir/msdos
  50. 6 3
      magic/Magdir/perl
  51. 14 0
      magic/Magdir/pwsafe
  52. 6 1
      magic/Magdir/python
  53. 15 3
      magic/Magdir/sgml
  54. 16 4
      magic/Magdir/sql
  55. 16 0
      magic/Magdir/uterus
  56. 46 3
      magic/Magdir/windows
  57. 5 1
      magic/Magdir/wordprocessors
  58. 7 1
      magic/Makefile.am
  59. 13 4
      magic/Makefile.in
  60. 6 3
      python/Makefile.in
  61. 1 1
      src/Makefile.am
  62. 22 14
      src/Makefile.in
  63. 466 202
      src/apprentice.c
  64. 2 2
      src/ascmagic.c
  65. 19 0
      src/asctime_r.c
  66. 4 4
      src/cdf.c
  67. 1 1
      src/cdf.h
  68. 8 9
      src/cdf_time.c
  69. 17 16
      src/compress.c
  70. 19 0
      src/ctime_r.c
  71. 38 6
      src/file.c
  72. 39 7
      src/file.h
  73. 1 1
      src/file_opts.h
  74. 30 27
      src/fsmagic.c
  75. 2 2
      src/funcs.c
  76. 40 74
      src/magic.c
  77. 30 12
      src/print.c
  78. 20 10
      src/readcdf.c
  79. 28 7
      src/readelf.c
  80. 180 41
      src/softmagic.c
  81. 19 4
      src/vasprintf.c
  82. 17 11
      tests/Makefile.in

+ 33 - 0
ChangeLog

@@ -1,3 +1,36 @@
+2012-12-19   8:47  Christos Zoulas <christos@zoulas.com>
+
+	* Only print elf capabilities for archs we know (Jan Kaluza)
+
+2012-10-30  19:14  Christos Zoulas <christos@zoulas.com>
+
+	* Add "name" and "use" file types in order to look
+	  inside mach-o files.
+
+2012-09-06  10:40  Christos Zoulas <christos@zoulas.com>
+
+	* make --version exit 0 (Matthew Schultz)
+	* add string/T (Jan Kaluza)
+
+2012-08-09  2:15  Christos Zoulas <christos@zoulas.com>
+
+	* add z and t modifiers for our own vasprintf
+	* search for $HOME/.magic.mgc if it is there first
+	* fix reads from a pipe, and preserve errno
+
+2012-05-15  13:12  Christos Zoulas <christos@zoulas.com>
+
+	* use ctime_r, asctime_r
+
+2012-04-06  17:18  Christos Zoulas <christos@zoulas.com>
+
+	* Fixes for indirect offsets to handle apple disk formats
+
+2012-04-03  18:26  Christos Zoulas <christos@zoulas.com>
+
+	* Add windows date field types
+	* More info for windows shortcuts (incomplete)
+
 2012-02-20  17:33  Christos Zoulas <christos@zoulas.com>
 
 	* Fix CDF parsing issues found by CERT's fuzzing tool (Will Dormann)

+ 8 - 5
Makefile.in

@@ -42,7 +42,8 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+	$(top_srcdir)/m4/visibility.m4 $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -122,6 +123,7 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
+CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -136,6 +138,7 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
+HAVE_VISIBILITY = @HAVE_VISIBILITY@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -239,15 +242,15 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
-	      echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
-	      $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
+	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
+	      $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
 		&& exit 0; \
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu Makefile
+	  $(AUTOMAKE) --foreign Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \

+ 13 - 3
TODO

@@ -1,6 +1,16 @@
-TODOs live in the TODO section of doc/file.man (i.e. file(1)). They
-are more visible there, so please add any further TODOs to that file,
-not here.
+Most TODOs live in the TODO section of doc/file.man (i.e. file(1)).
+They are more visible there, so please add any further TODOs to that
+file, not here. More speculative material can live here.
 
 (This change was made when Reuben Thomas noticed that all the bugs
 listed in the BUGS section of the man page had been fixed!)
+
+---
+
+It would be nice to simplify file considerably. For example,
+reimplement the apprentice and non-pattern magic methods in Python,
+and compile the magic patterns to a giant regex (or something similar)
+so that only a small amount of C is needed (because fast execution is
+typically only required for soft magic, not the more detailed
+information given by hard-wired routines). In this regard, note that
+hplip, which is BSD-licensed, has a magic reimplementation in Python.

+ 1 - 12
aclocal.m4

@@ -406,18 +406,6 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
      [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
 ])
 
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 8
-
-# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
-AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
-
 # Do all the work for Automake.                             -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
@@ -1028,4 +1016,5 @@ m4_include([m4/ltoptions.m4])
 m4_include([m4/ltsugar.m4])
 m4_include([m4/ltversion.m4])
 m4_include([m4/lt~obsolete.m4])
+m4_include([m4/visibility.m4])
 m4_include([acinclude.m4])

+ 91 - 50
config.h.in

@@ -1,14 +1,23 @@
 /* config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
 /* Define in built-in ELF support is used */
 #undef BUILTIN_ELF
 
 /* Define for ELF core file support */
 #undef ELFCORE
 
+/* Define to 1 if you have the `asctime_r' function. */
+#undef HAVE_ASCTIME_R
+
 /* Define to 1 if you have the `asprintf' function. */
 #undef HAVE_ASPRINTF
 
+/* Define to 1 if you have the `ctime_r' function. */
+#undef HAVE_CTIME_R
+
 /* HAVE_DAYLIGHT */
 #undef HAVE_DAYLIGHT
 
@@ -44,11 +53,8 @@
 /* Define to 1 if you have the `getopt_long' function. */
 #undef HAVE_GETOPT_LONG
 
-/* Define to 1 if the system has the type `int32_t'. */
-#undef HAVE_INT32_T
-
-/* Define to 1 if the system has the type `int64_t'. */
-#undef HAVE_INT64_T
+/* Define to 1 if you have the `getpagesize' function. */
+#undef HAVE_GETPAGESIZE
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
@@ -65,7 +71,7 @@
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
-/* Define to 1 if you have the `mbrtowc' function. */
+/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
 #undef HAVE_MBRTOWC
 
 /* Define to 1 if <wchar.h> declares mbstate_t. */
@@ -74,14 +80,17 @@
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
+/* Define to 1 if you have the `mkostemp' function. */
+#undef HAVE_MKOSTEMP
+
 /* Define to 1 if you have the `mkstemp' function. */
 #undef HAVE_MKSTEMP
 
-/* Define to 1 if you have the `mmap' function. */
+/* Define to 1 if you have a working `mmap' system call. */
 #undef HAVE_MMAP
 
-/* Define to 1 if the system has the type `pid_t'. */
-#undef HAVE_PID_T
+/* Define to 1 if you have the <stddef.h> header file. */
+#undef HAVE_STDDEF_H
 
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
@@ -128,6 +137,9 @@
 /* Define to 1 if you have the <sys/mman.h> header file. */
 #undef HAVE_SYS_MMAN_H
 
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
@@ -152,18 +164,6 @@
 /* HAVE_TZNAME */
 #undef HAVE_TZNAME
 
-/* Define to 1 if the system has the type `uint16_t'. */
-#undef HAVE_UINT16_T
-
-/* Define to 1 if the system has the type `uint32_t'. */
-#undef HAVE_UINT32_T
-
-/* Define to 1 if the system has the type `uint64_t'. */
-#undef HAVE_UINT64_T
-
-/* Define to 1 if the system has the type `uint8_t'. */
-#undef HAVE_UINT8_T
-
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
@@ -179,6 +179,16 @@
 /* Define to 1 if you have the `vasprintf' function. */
 #undef HAVE_VASPRINTF
 
+/* Define to 1 if you have the `vfork' function. */
+#undef HAVE_VFORK
+
+/* Define to 1 if you have the <vfork.h> header file. */
+#undef HAVE_VFORK_H
+
+/* Define to 1 or 0, depending whether the compiler supports simple visibility
+   declarations. */
+#undef HAVE_VISIBILITY
+
 /* Define to 1 if you have the <wchar.h> header file. */
 #undef HAVE_WCHAR_H
 
@@ -188,6 +198,12 @@
 /* Define to 1 if you have the `wcwidth' function. */
 #undef HAVE_WCWIDTH
 
+/* Define to 1 if `fork' works. */
+#undef HAVE_WORKING_FORK
+
+/* Define to 1 if `vfork' works. */
+#undef HAVE_WORKING_VFORK
+
 /* Define to 1 if you have the <zlib.h> header file. */
 #undef HAVE_ZLIB_H
 
@@ -227,9 +243,6 @@
 /* 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
 
@@ -261,6 +274,18 @@
 /* Version number of package */
 #undef VERSION
 
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+#  undef WORDS_BIGENDIAN
+# endif
+#endif
+
 /* Number of bits in a file offset, on hosts where this is settable. */
 #undef _FILE_OFFSET_BITS
 
@@ -280,43 +305,59 @@
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
 
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT32_T
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT64_T
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT8_T
+
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
 
+/* Define to the type of a signed integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#undef int32_t
+
+/* Define to the type of a signed integer type of width exactly 64 bits if
+   such a type exists and the standard includes do not define it. */
+#undef int64_t
+
 /* Define to a type if <wchar.h> does not define. */
 #undef mbstate_t
 
 /* Define to `long int' if <sys/types.h> does not define. */
 #undef off_t
 
+/* Define to `int' if <sys/types.h> does not define. */
+#undef pid_t
+
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
 
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint16_t
 
-#ifndef HAVE_UINT8_T
-typedef unsigned char uint8_t;
-#endif
-#ifndef HAVE_UINT16_T
-typedef unsigned short uint16_t;
-#endif
-#ifndef HAVE_UINT32_T
-typedef unsigned int uint32_t;
-#endif
-#ifndef HAVE_INT32_T
-typedef int int32_t;
-#endif
-#ifndef HAVE_UINT64_T
-#if SIZEOF_LONG_LONG == 8
-typedef unsigned long long uint64_t;
-#else
-typedef unsigned long uint64_t;
-#endif
-#endif
-#ifndef HAVE_INT64_T
-#if SIZEOF_LONG_LONG == 8
-typedef long long int64_t;
-#else
-typedef long int64_t;
-#endif
-#endif
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint32_t
+
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint64_t
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint8_t
 
+/* Define as `fork' if `vfork' does not work. */
+#undef vfork

File diff suppressed because it is too large
+ 1649 - 1242
configure


+ 23 - 43
configure.ac

@@ -1,9 +1,9 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(file, 5.11, christos@astron.com)
-AM_INIT_AUTOMAKE()
+AC_INIT([file],[5.12],[christos@astron.com])
+AM_INIT_AUTOMAKE([subdir-objects foreign])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
-AM_CONFIG_HEADER(config.h)
+AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_MACRO_DIR([m4])
 
 AC_MSG_CHECKING(for builtin ELF support)
@@ -66,21 +66,22 @@ AC_SUBST(fsect)
 AM_CONDITIONAL(FSECT5, test x$fsect = x5)
 
 AC_SUBST(WARNINGS)
-AC_GNU_SOURCE
 
 dnl Checks for programs.
-AC_PROG_CC
+AC_PROG_CC_STDC
+AC_USE_SYSTEM_EXTENSIONS
 AM_PROG_CC_C_O
+AC_C_BIGENDIAN
 AC_PROG_INSTALL
 AC_PROG_LN_S
-AC_PROG_LIBTOOL
-
+LT_INIT([disable-static pic-only])
+gl_VISIBILITY
 dnl Checks for headers
 AC_HEADER_STDC
 AC_HEADER_MAJOR
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h)
-AC_CHECK_HEADERS(utime.h wchar.h wctype.h limits.h)
+AC_CHECK_HEADERS(stddef.h utime.h wchar.h wctype.h limits.h)
 AC_CHECK_HEADERS(getopt.h err.h)
 AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
 AC_CHECK_HEADERS(zlib.h)
@@ -91,45 +92,24 @@ AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
 AC_CHECK_MEMBERS([struct stat.st_rdev])
 
-AC_STRUCT_TM
-AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.tm_zone])
+AC_CHECK_MEMBERS([struct tm.tm_gmtoff])
+AC_STRUCT_TIMEZONE
 AC_STRUCT_TIMEZONE_DAYLIGHT
 AC_SYS_LARGEFILE
 AC_FUNC_FSEEKO
 AC_TYPE_MBSTATE_T
 
 AC_STRUCT_OPTION_GETOPT_H
-
-AC_CHECK_TYPES([pid_t, uint8_t, uint16_t, uint32_t, int32_t, uint64_t, int64_t])
-AC_CHECK_SIZEOF(long long)
-AH_BOTTOM([
-#ifndef HAVE_UINT8_T
-typedef unsigned char uint8_t;
-#endif
-#ifndef HAVE_UINT16_T
-typedef unsigned short uint16_t;
-#endif
-#ifndef HAVE_UINT32_T
-typedef unsigned int uint32_t;
-#endif
-#ifndef HAVE_INT32_T
-typedef int int32_t;
-#endif
-#ifndef HAVE_UINT64_T
-#if SIZEOF_LONG_LONG == 8
-typedef unsigned long long uint64_t;
-#else
-typedef unsigned long uint64_t;
-#endif
-#endif
-#ifndef HAVE_INT64_T
-#if SIZEOF_LONG_LONG == 8
-typedef long long int64_t;
-#else
-typedef long int64_t;
-#endif
-#endif
-])
+AC_TYPE_PID_T
+AC_TYPE_UINT8_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_INT32_T
+AC_TYPE_UINT64_T
+AC_TYPE_INT64_T
+AC_FUNC_MMAP
+AC_FUNC_FORK
+AC_FUNC_MBRTOWC
 
 AC_MSG_CHECKING(for gcc compiler warnings)
 AC_ARG_ENABLE(warnings,
@@ -156,10 +136,10 @@ else
 fi])
 
 dnl Checks for functions
-AC_CHECK_FUNCS(mmap strerror strndup strtoul mbrtowc mkstemp utimes utime wcwidth strtof fork)
+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)
+AC_REPLACE_FUNCS(getopt_long asprintf vasprintf strlcpy strlcat getline ctime_r asctime_r)
 
 dnl Checks for libraries
 AC_CHECK_LIB(z,gzopen)

+ 6 - 3
doc/Makefile.in

@@ -38,7 +38,8 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+	$(top_srcdir)/m4/visibility.m4 $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -95,6 +96,7 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
+CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -109,6 +111,7 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
+HAVE_VISIBILITY = @HAVE_VISIBILITY@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -217,9 +220,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu doc/Makefile
+	  $(AUTOMAKE) --foreign doc/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \

+ 34 - 5
doc/file.man

@@ -1,5 +1,5 @@
-.\" $File: file.man,v 1.98 2011/12/08 12:12:46 rrt Exp $
-.Dd October 17, 2011
+.\" $File: file.man,v 1.101 2012/11/01 04:31:53 christos Exp $
+.Dd October 25, 2012
 .Dt FILE __CSECTION__
 .Os
 .Sh NAME
@@ -259,8 +259,16 @@ prepended.
 (If you want a newline, see the
 .Fl r
 option.)
+The magic pattern with the highest strength (see the
+.Fl l
+option) comes first.
 .It Fl l , Fl Fl list
-Print information about the strength of each magic pattern.
+Shows a list of patterns and their strength sorted descending by
+.Xr magic 4
+strength
+which is used for the matching (see also the
+.Fl k
+option).
 .It Fl L , Fl Fl dereference
 option causes symlinks to be followed, as the like-named option in
 .Xr ls 1
@@ -268,8 +276,6 @@ option causes symlinks to be followed, as the like-named option in
 This is the default if the environment variable
 .Ev POSIXLY_CORRECT
 is defined.
-.It Fl l
-Shows sorted patterns list in the order which is used for the matching.
 .It Fl m , Fl Fl magic-file Ar magicfiles
 Specify an alternate list of files and directories containing magic.
 This can be a single item, or a colon-separated list.
@@ -570,6 +576,29 @@ Add a zip library so we can peek inside Office2007 documents to
 figure out what they are.
 .Pp
 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.
+.Pp
+Fix
+.Dq name
+and
+.Dq use
+to check for consistency at compile time (duplicate 
+.Dq name ,
+.Dq use
+pointing to undefined
+.Dq name
+).
+Make 
+.Dq name
+/
+.Dq use 
+more efficient by keeping a sorted list of names.
+Special-case ^ to flip endianness in the parser so that it does not
+have to be escaped, and document it.
 .Sh AVAILABILITY
 You can obtain the original author's latest version by anonymous FTP
 on

+ 37 - 4
doc/magic.man

@@ -1,5 +1,5 @@
-.\" $File: magic.man,v 1.71 2011/12/07 11:58:24 rrt Exp $
-.Dd April 20, 2011
+.\" $File: magic.man,v 1.76 2012/11/07 20:29:27 christos Exp $
+.Dd November 7, 2012
 .Dt MAGIC __FSECTION__
 .Os
 .\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems.
@@ -51,7 +51,7 @@ A 64-bit double precision IEEE floating point number in this machine's native by
 .It Dv string
 A string of bytes.
 The string type specification can be optionally followed
-by /[WwcCtb]*.
+by /[WwcCtbT]*.
 The
 .Dq W
 flag compacts whitespace in the target, which must
@@ -85,8 +85,12 @@ The
 flag forces the test to be done for text files, while the
 .Dq b
 flag forces the test to be done for binary files.
+The
+.Dq T
+flag causes the string to be trimmed, i.e. leading and trailing whitespace
+is deleted before the string is printed.
 .It Dv pstring
-A Pascal-style string where the first byte/short/int is interpreted as the an
+A Pascal-style string where the first byte/short/int is interpreted as the
 unsigned length.
 The length defaults to byte and can be specified as a modifier.
 The following modifiers are supported:
@@ -121,6 +125,8 @@ local time rather than UTC.
 .It Dv qldate
 An eight-byte value interpreted as a UNIX-style date, but interpreted as
 local time rather than UTC.
+.It Dv qwdate
+An eight-byte value interpreted as a Windows-style date.
 .It Dv beid3
 A 32-bit ID3 length in big-endian byte order.
 .It Dv beshort
@@ -147,6 +153,9 @@ than UTC.
 An eight-byte value in big-endian byte order,
 interpreted as a UNIX-style date, but interpreted as local time rather
 than UTC.
+.It Dv beqwdate
+An eight-byte value in big-endian byte order,
+interpreted as a Windows-style date.
 .It Dv bestring16
 A two-byte unicode (UCS16) string in big-endian byte order.
 .It Dv leid3
@@ -175,6 +184,9 @@ than UTC.
 An eight-byte value in little-endian byte order,
 interpreted as a UNIX-style date, but interpreted as local time rather
 than UTC.
+.It Dv leqwdate
+An eight-byte value in little-endian byte order,
+interpreted as a Windows-style date.
 .It Dv lestring16
 A two-byte unicode (UCS16) string in little-endian byte order.
 .It Dv melong
@@ -188,6 +200,27 @@ interpreted as a UNIX-style date, but interpreted as local time rather
 than UTC.
 .It Dv indirect
 Starting at the given offset, consult the magic database again.
+.It Dv name
+Define a
+.Dq named
+magic instance that can be called from another
+.Dv use
+magic entry, like a subroutine call.
+Named instance direct magic offsets are relative to the offset of the
+previous matched entry, but indirect offsets are relative to the beginning
+of the file as usual.
+Named magic entries always match.
+.It Dv use
+Recursively call the named magic starting from the current offset.
+If the name of the referenced begins with a
+.Dv ^
+then the endianness of the magic is switched; if the magic mentioned
+.Dv leshort
+for example,
+it is treated as
+.Dv beshort
+and vice versa.
+This is useful to avoid duplicating the rules for different endianness.
 .It Dv regex
 A regular expression match in extended POSIX regular expression syntax
 (like egrep).

+ 480 - 251
install-sh

@@ -1,23 +1,38 @@
 #!/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.
 #
-# $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.
+# Copyright (C) 1994 X Consortium
 #
-# install - install a program, script, or datafile
-# This comes from X11R5 (mit/util/scripts/install.sh).
+# 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:
+#
+# 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.
 #
-# Copyright 1991 by the Massachusetts Institute of Technology
 #
-# 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.
+# FSF changes to this file are in the public domain.
 #
 # Calling this script install-sh is preferred over install.sh, to prevent
 # `make' implicit rules from creating a file called install from it
@@ -26,266 +41,480 @@
 # 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-}"
-
-
-# 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"
-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
-
-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
+doit=${DOITPROG-}
+if test -z "$doit"; then
+  doit_exec=exec
 else
-	msrc="$msrc $dst"
+  doit_exec=$doit
 fi
 
-if [ x"$msrc" = x ]
-then
-	echo "install: no destination specified"
-	exit 1
-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
+  }
+'
 
-for srcarg in $msrc; do
+posix_mkdir=
 
-if [ x"$dir_arg" != x ]; then
+# Desired mode of installed file.
+mode=0755
 
-	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
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
 
-	if [ -d "$dstarg" ]
-	then
-		dstarg="$dstarg"/`basename "$srcarg"`
-	fi
-fi
+src=
+dst=
+dir_arg=
+dst_arg=
 
-## this sed command emulates the dirname command
-dstdir=`echo "$dstarg" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+copy_on_change=false
+no_target_directory=
 
-# Make sure that the destination directory exists.
-#  this part is taken from Noah Friedman's mkinstalldirs script
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
 
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='	
-'
-IFS="${IFS-${defaultIFS}}"
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
 
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
+Options:
+     --help     display this help and exit.
+     --version  display version info and exit.
 
-pathcomp=''
+  -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.
 
-while [ $# -ne 0 ] ; do
-	pathcomp="${pathcomp}${1}"
-	shift
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+  RMPROG STRIPPROG
+"
 
-	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
+while test $# -ne 0; do
+  case $1 in
+    -c) ;;
 
-	else
-		true
-	fi
+    -C) copy_on_change=true;;
 
-	pathcomp="${pathcomp}/"
+    -d) dir_arg=true;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+	shift;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) mode=$2
+	case $mode in
+	  *' '* | *'	'* | *'
+'*	  | *'*'* | *'?'* | *'['*)
+	    echo "$0: invalid mode: $mode" >&2
+	    exit 1;;
+	esac
+	shift;;
+
+    -o) chowncmd="$chownprog $2"
+	shift;;
+
+    -s) stripcmd=$stripprog;;
+
+    -t) dst_arg=$2
+	shift;;
+
+    -T) no_target_directory=true;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    --)	shift
+	break;;
+
+    -*)	echo "$0: invalid option: $1" >&2
+	exit 1;;
+
+    *)  break;;
+  esac
+  shift
 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 [ 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
+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 [ 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"
+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
+	else
+	  mkdir_mode=
 	fi
 
-done &&
+	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
 
+    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
 
-exit 0
+# 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:

+ 77 - 0
m4/visibility.m4

@@ -0,0 +1,77 @@
+# visibility.m4 serial 4 (gettext-0.18.2)
+dnl Copyright (C) 2005, 2008, 2010-2012 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl Tests whether the compiler supports the command-line option
+dnl -fvisibility=hidden and the function and variable attributes
+dnl __attribute__((__visibility__("hidden"))) and
+dnl __attribute__((__visibility__("default"))).
+dnl Does *not* test for __visibility__("protected") - which has tricky
+dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
+dnl MacOS X.
+dnl Does *not* test for __visibility__("internal") - which has processor
+dnl dependent semantics.
+dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
+dnl "really only recommended for legacy code".
+dnl Set the variable CFLAG_VISIBILITY.
+dnl Defines and sets the variable HAVE_VISIBILITY.
+
+AC_DEFUN([gl_VISIBILITY],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  CFLAG_VISIBILITY=
+  HAVE_VISIBILITY=0
+  if test -n "$GCC"; then
+    dnl First, check whether -Werror can be added to the command line, or
+    dnl whether it leads to an error because of some other option that the
+    dnl user has put into $CC $CFLAGS $CPPFLAGS.
+    AC_MSG_CHECKING([whether the -Werror option is usable])
+    AC_CACHE_VAL([gl_cv_cc_vis_werror], [
+      gl_save_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS -Werror"
+      AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM([[]], [[]])],
+        [gl_cv_cc_vis_werror=yes],
+        [gl_cv_cc_vis_werror=no])
+      CFLAGS="$gl_save_CFLAGS"])
+    AC_MSG_RESULT([$gl_cv_cc_vis_werror])
+    dnl Now check whether visibility declarations are supported.
+    AC_MSG_CHECKING([for simple visibility declarations])
+    AC_CACHE_VAL([gl_cv_cc_visibility], [
+      gl_save_CFLAGS="$CFLAGS"
+      CFLAGS="$CFLAGS -fvisibility=hidden"
+      dnl We use the option -Werror and a function dummyfunc, because on some
+      dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
+      dnl "visibility attribute not supported in this configuration; ignored"
+      dnl at the first function definition in every compilation unit, and we
+      dnl don't want to use the option in this case.
+      if test $gl_cv_cc_vis_werror = yes; then
+        CFLAGS="$CFLAGS -Werror"
+      fi
+      AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
+             extern __attribute__((__visibility__("default"))) int exportedvar;
+             extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
+             extern __attribute__((__visibility__("default"))) int exportedfunc (void);
+             void dummyfunc (void) {}
+           ]],
+           [[]])],
+        [gl_cv_cc_visibility=yes],
+        [gl_cv_cc_visibility=no])
+      CFLAGS="$gl_save_CFLAGS"])
+    AC_MSG_RESULT([$gl_cv_cc_visibility])
+    if test $gl_cv_cc_visibility = yes; then
+      CFLAG_VISIBILITY="-fvisibility=hidden"
+      HAVE_VISIBILITY=1
+    fi
+  fi
+  AC_SUBST([CFLAG_VISIBILITY])
+  AC_SUBST([HAVE_VISIBILITY])
+  AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY],
+    [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
+])

+ 9 - 5
magic/Magdir/adventure

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: adventure,v 1.13 2010/12/31 16:32:54 christos Exp $
+# $File: adventure,v 1.14 2012/06/21 01:32:26 christos Exp $
 # adventure: file(1) magic for Adventure game files
 #
 # from Allen Garvin <earendil@faeryland.tamu-commerce.edu>
@@ -33,10 +33,14 @@
 #
 0	ubyte			>0
 >0	ubyte			<9
->>16	belong&0xfe00f0f0	0x3030	Infocom game data
->>>0	ubyte			x	(Z-machine %d,
->>>>2	ubeshort		x	Release %d /
->>>>18	string			>\0	Serial %.6s)
+>>16	belong&0xfe00f0f0	0x3030
+>>>0	ubyte			< 10
+>>>>2	ubeshort		< 10
+>>>>>18	regex			[0-9][0-9][0-9][0-9][0-9][0-9]
+>>>>>>0	ubyte			< 10	Infocom (Z-machine %d,
+>>>>>>>2	ubeshort	< 10 	Release %d /
+>>>>>>>>18	string		>\0	Serial %.6s)
+!:strength + 40
 
 #------------------------------------------------------------------------------
 # Glulx:  file(1) magic for Glulx binaries.

+ 4 - 1
magic/Magdir/amigaos

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: amigaos,v 1.14 2009/09/19 16:28:07 christos Exp $
+# $File: amigaos,v 1.15 2012/06/21 01:13:59 christos Exp $
 # amigaos:  file(1) magic for AmigaOS binary formats:
 
 #
@@ -63,3 +63,6 @@
 # From: Alex Beregszaszi <alex@fsn.hu>
 0	string		LZX		LZX compressed archive (Amiga)
 
+# From: Przemek Kramarczyk <pkramarczyk@gmail.com>
+0	string 		.KEY		AmigaDOS script
+0	string 		.key		AmigaDOS script

+ 4 - 8
magic/Magdir/animation

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: animation,v 1.45 2011/09/06 11:00:06 christos Exp $
+# $File: animation,v 1.46 2012/08/26 10:43:05 christos Exp $
 # animation:  file(1) magic for animation/movie formats
 #
 # animation formats
@@ -688,10 +688,6 @@
 # iso 13818 transport stream
 #
 # from Oskar Schirmer <schirmer@scara.com> Feb 3, 2001 (ISO 13818.1)
-# (the following is a little bit restrictive and works fine for a stream
-#  that starts with PAT properly. it won't work for stream data, that is
-#  cut from an input device data right in the middle, but this shouldn't
-#  disturb)
 # syncbyte      8 bit	0x47
 # error_ind     1 bit	-
 # payload_start 1 bit	1
@@ -699,9 +695,9 @@
 # PID          13 bit	0x0000
 # scrambling    2 bit	-
 # adaptfld_ctrl 2 bit	1 or 3
-# conti_count   4 bit	0
-0	belong&0xFF5FFF1F	0x47400010	MPEG transport stream data
->188	byte			!0x47		CORRUPTED
+# conti_count   4 bit	-
+0	belong&0xFF5FFF10	0x47400010
+>188	byte			0x47		MPEG transport stream data
 
 # DIF digital video file format <mpruett@sgi.com>
 0	belong&0xffffff00	0x1f070000      DIF

+ 47 - 1
magic/Magdir/apple

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: apple,v 1.24 2010/11/25 15:00:12 christos Exp $
+# $File: apple,v 1.26 2012/12/27 15:43:23 christos Exp $
 # apple:  file(1) magic for Apple file formats
 #
 0	search/1/t	FiLeStArTfIlEsTaRt	binscii (apple ][) text
@@ -249,3 +249,49 @@
 # From: "Nelson A. de Oliveira" <naoliv@gmail.com>
 # .vdi
 4	string innotek\ VirtualBox\ Disk\ Image %s
+
+# Apple disk partition stuff, strengthen the magic using byte 4
+0	beshort	0x4552
+>4	byte	0			Apple Driver Map
+>>2	beshort	x			\b, blocksize %d
+>>4	belong	x			\b, blockcount %d
+>>10	beshort	x			\b, devtype %d
+>>12	beshort	x			\b, devid %d
+>>20	beshort x			\b, descriptors %d
+# Assume 	8 partitions each at a multiple of the sector size.
+# We could glean this from the partition descriptors, but they are empty!?!?
+>>(2.S*1)	indirect		\b, contains[@0x%x]: 
+>>(2.S*2)	indirect		\b, contains[@0x%x]: 
+>>(2.S*3)	indirect		\b, contains[@0x%x]: 
+>>(2.S*4)	indirect		\b, contains[@0x%x]: 
+>>(2.S*5)	indirect		\b, contains[@0x%x]: 
+>>(2.S*6)	indirect		\b, contains[@0x%x]: 
+>>(2.S*7)	indirect		\b, contains[@0x%x]: 
+>>(2.S*8)	indirect		\b, contains[@0x%x]: 
+
+# Yes, the 3rd and 4th bytes are reserved, but we use them to make the
+# magic stronger.
+0	belong	0x504d0000		Apple Partition Map
+>4	belong	x			\b, map block count %d
+>8	belong	x			\b, start block %d
+>12	belong	x			\b, block count %d
+>16	string >0			\b, name %s
+>48	string >0			\b, type %s
+>124	string >0			\b, processor %s
+>140	string >0			\b, boot arguments %s
+>92	belong	& 1			\b, valid
+>92	belong	& 2			\b, allocated
+>92	belong	& 4			\b, in use
+>92	belong	& 8			\b, has boot info
+>92	belong	& 16			\b, readable
+>92	belong	& 32			\b, writable
+>92	belong	& 64			\b, pic boot code
+>92	belong	& 128			\b, chain compatible driver
+>92	belong	& 256			\b, real driver
+>92	belong	& 512			\b, chain driver
+>92	belong	& 1024			\b, mount at startup
+>92	belong	& 2048			\b, is the startup partition
+
+#http://wiki.mozilla.org/DS_Store_File_Format`
+#http://en.wikipedia.org/wiki/.DS_Store
+0	string	\0\0\0\1Bud1\0		Apple Desktop Services Store

+ 19 - 8
magic/Magdir/archive

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: archive,v 1.70 2011/10/26 15:44:47 christos Exp $
+# $File: archive,v 1.73 2012/11/09 22:59:30 christos Exp $
 # archive:  file(1) magic for archive formats (see also "msdos" for self-
 #           extracting compressed archives)
 #
@@ -53,6 +53,11 @@
 #>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
@@ -571,6 +576,7 @@
 !:mime	application/zip
 
 # Zip archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu)
+0	string		PK\005\006	Zip archive data (empty)
 0	string		PK\003\004
 
 # Specialised zip formats which start with a member named 'mimetype'
@@ -684,16 +690,21 @@
 >>>38		regex	[!-OQ-~]+		Zip data (MIME type "%s"?)
 !:mime	application/zip
 
+# Java Jar files
+>(26.s+30)	leshort	0xcafe		Java Jar file data (zip)
+!:mime	application/jar
+
 # Generic zip archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu)
 #   Next line excludes specialized formats:
->26    string          !\x8\0\0\0mimetype	Zip archive data
+>(26.s+30)	leshort	!0xcafe
+>>26    string          !\x8\0\0\0mimetype	Zip archive data
 !:mime	application/zip
->>4	byte		0x09		\b, at least v0.9 to extract
->>4	byte		0x0a		\b, at least v1.0 to extract
->>4	byte		0x0b		\b, at least v1.1 to extract
->>4	byte		0x14		\b, at least v2.0 to extract
->>4	byte		0x2d		\b, at least v3.0 to extract
->>0x161	string		WINZIP		\b, WinZIP self-extracting
+>>>4	byte		0x09		\b, at least v0.9 to extract
+>>>4	byte		0x0a		\b, at least v1.0 to extract
+>>>4	byte		0x0b		\b, at least v1.1 to extract
+>>>4	byte		0x14		\b, at least v2.0 to extract
+>>>4	byte		0x2d		\b, at least v3.0 to extract
+>>>0x161	string		WINZIP		\b, WinZIP self-extracting
 
 # StarView Metafile
 # From Pierre Ducroquet <pinaraf@pinaraf.info>

+ 10 - 6
magic/Magdir/assembler

@@ -1,14 +1,18 @@
 #------------------------------------------------------------------------------
-# $File: assembler,v 1.1 2011/12/08 12:12:46 rrt Exp $
+# $File: assembler,v 1.2 2012/10/31 18:41:42 christos Exp $
 # make:  file(1) magic for assembler source
 #
-0	regex	\^\.asciiz\?	assembler source text
+0	regex	\^[\020\t]*\.asciiz\?		assembler source text
 !:mime	text/x-asm
-0	regex	\^\.byte		assembler source text
+0	regex	\^[\020\t]*\.byte		assembler source text
 !:mime	text/x-asm
-0	regex	\^\.even		assembler source text
+0	regex	\^[\020\t]*\.even		assembler source text
 !:mime	text/x-asm
-0	regex	\^\.globl		assembler source text
+0	regex	\^[\020\t]*\.globl		assembler source text
 !:mime	text/x-asm
-0	regex	\^\.text		assembler source text
+0	regex	\^[\020\t]*\.text		assembler source text
+!:mime	text/x-asm
+0	regex	\^[\020\t]*\.file		assembler source text
+!:mime	text/x-asm
+0	regex	\^[\020\t]*\.type		assembler source text
 !:mime	text/x-asm

+ 2 - 1
magic/Magdir/audio

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: audio,v 1.64 2012/02/20 16:37:34 christos Exp $
+# $File: audio,v 1.65 2012/10/31 13:38:40 christos Exp $
 # audio:  file(1) magic for sound formats (see also "iff")
 #
 # Jan Nicolai Langfeldt (janl@ifi.uio.no), Dan Quinlan (quinlan@yggdrasil.com),
@@ -571,6 +571,7 @@
 
 # musepak support From: "Jiri Pejchal" <jiri.pejchal@gmail.com>
 0       string          MP+     Musepack audio
+!:mime	audio/x-musepack
 >3      byte            255     \b, SV pre8
 >3      byte&0xF        0x6     \b, SV 6
 >3      byte&0xF        0x8     \b, SV 8

+ 6 - 6
magic/Magdir/c-lang

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: c-lang,v 1.16 2011/12/09 08:02:16 rrt Exp $
+# $File: c-lang,v 1.17 2012/04/28 21:20:26 christos Exp $
 # c-lang:  file(1) magic for C and related languages programs
 #
 
@@ -30,19 +30,19 @@
 # C++
 # The strength of these rules is increased so they beat the C rules above
 0	regex	\^template	C++ source text
-!:strength + 10
+!:strength + 5
 !:mime	text/x-c++
 0	regex	\^virtual		C++ source text
-!:strength + 10
+!:strength + 5
 !:mime	text/x-c++
 0	regex	\^class		C++ source text
-!:strength + 10
+!:strength + 5
 !:mime	text/x-c++
 0	regex	\^public:		C++ source text
-!:strength + 10
+!:strength + 5
 !:mime	text/x-c++
 0	regex	\^private:		C++ source text
-!:strength + 10
+!:strength + 5
 !:mime	text/x-c++
 
 # From: Mikhail Teterin <mi@aldan.algebra.com> 

+ 43 - 5
magic/Magdir/cafebabe

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: cafebabe,v 1.8 2009/09/19 16:28:08 christos Exp $
+# $File: cafebabe,v 1.10 2012/10/31 16:32:01 christos Exp $
 # Cafe Babes unite!
 #
 # Since Java bytecode and Mach-O fat-files have the same magic number, the test
@@ -14,6 +14,7 @@
 # (and use as a hack). Let's not use 18, because the Mach-O people
 # might add another one or two as time goes by...
 #
+### JAVA START ###
 0	belong		0xcafebabe
 !:mime	application/x-java-applet
 >4	belong		>30		compiled Java class data,
@@ -28,13 +29,50 @@
 >>4	belong		0x0031		(Java 1.5)
 >>4	belong		0x0032		(Java 1.6)
 
+0	belong		0xcafed00d	JAR compressed with pack200,
+>>5	byte		x		version %d.
+>>4	byte		x		\b%d
+!:mime	application/x-java-pack200
 
-0	belong		0xcafebabe
->4	belong		1		Mach-O fat file with 1 architecture
->4	belong		>1
->>4	belong		<20		Mach-O fat file with %ld architectures
 
 0	belong		0xcafed00d	JAR compressed with pack200,
 >>5	byte		x		version %d.
 >>4	byte		x		\b%d
 !:mime	application/x-java-pack200
+
+### JAVA END ###
+### MACH-O START ###
+
+# 16777216 = 0x01000000
+0	name		mach-o		\b [ 
+>0	belong		0xffffffff	\bAny
+>0	belong		1		\bVax
+>0	belong		6		\bMC680x0
+>0	belong		7		\bI386
+>0	belong		8		\bMIPS
+>0	belong		10		\bMC98000
+>0	belong		11		\bHPPA
+>0	belong		12		\bARM
+>0	belong		13		\bMC88000
+>0	belong		14		\bSPARC
+>0	belong		15		\bI860
+>0	belong		16		\bALPHA
+>0	belong		17		\bPOWERPC
+>0	belong		16777223	\bX86_64
+>0	belong		16777233	\bPOWERPC64
+>&(8.L)	indirect			: 
+>0	belong		x		\b]
+
+0	belong		0xcafebabe
+>4	belong		1		Mach-O fat file with 1 architecture:
+>>8	use		mach-o
+>4	belong		>1
+>>4	belong		<20		Mach-O fat file with %ld architectures:
+>>>8	use		mach-o
+>>>28	use		mach-o
+>>>4	belong		>2
+>>>>48	use		mach-o
+>>>>>4	belong		>3
+>>>>>68	use		mach-o
+
+### MACH-O END ###

+ 5 - 5
magic/Magdir/claris

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: claris,v 1.5 2009/09/19 16:28:08 christos Exp $
+# $File: claris,v 1.6 2012/06/20 21:19:05 christos Exp $
 # claris:  file(1) magic for claris
 # "H. Nanosecond" <aldomel@ix.netcom.com>
 # Claris Works a word processor, etc.
@@ -11,10 +11,10 @@
 #*
 #0001000 #010 250 377 377 377 377 000 213 000 230 000 021 002 377 014 000
 #null to byte 1000 octal
-514	string	\377\377\377\377\000	Claris clip art?
->0	string	\0\0\0\0\0\0\0\0\0\0\0\0\0	yes.
-514	string	\377\377\377\377\001	Claris clip art?
->0	string	\0\0\0\0\0\0\0\0\0\0\0\0\0	yes.
+514	string	\377\377\377\377\000
+>0	string	\0\0\0\0\0\0\0\0\0\0\0\0\0	Claris clip art
+514	string	\377\377\377\377\001
+>0	string	\0\0\0\0\0\0\0\0\0\0\0\0\0	Claris clip art
 
 # Claris works files
 # .cwk

+ 4 - 1
magic/Magdir/commands

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: commands,v 1.42 2011/12/05 23:14:02 rrt Exp $
+# $File: commands,v 1.43 2012/06/21 01:08:56 christos Exp $
 # commands:  file(1) magic for various shells and interpreters
 #
 #0	string/w	:			shell archive or script for antique kernel text
@@ -67,14 +67,17 @@
 # PHP scripts
 # Ulf Harnhammar <ulfh@update.uu.se>
 0	search/1/c	=<?php			PHP script text
+!:strength + 10
 !:mime	text/x-php
 0	search/1	=<?\n			PHP script text
 !:mime	text/x-php
 0	search/1	=<?\r			PHP script text
 !:mime	text/x-php
 0	search/1/w	#!\ /usr/local/bin/php	PHP script text executable
+!:strength + 10
 !:mime	text/x-php
 0	search/1/w	#!\ /usr/bin/php	PHP script text executable
+!:strength + 10
 !:mime	text/x-php
 # Smarty compiled template, http://www.smarty.net/
 # Elan Ruusamäe <glen@delfi.ee>

+ 1 - 3
magic/Magdir/convex

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: convex,v 1.7 2009/09/19 16:28:08 christos Exp $
+# $File: convex,v 1.8 2012/10/03 23:44:43 christos Exp $
 # convex:  file(1) magic for Convex boxes
 #
 # Convexes are big-endian.
@@ -30,8 +30,6 @@
 # The restore program uses these number to determine how the data is
 # to be extracted.
 #
-24	belong	=60011	dump format, 4.1 BSD or earlier
-24	belong	=60012	dump format, 4.2 or 4.3 BSD without IDC
 24	belong	=60013	dump format, 4.2 or 4.3 BSD (IDC compatible)
 24	belong	=60014	dump format, Convex Storage Manager by-reference dump
 #

+ 8 - 0
magic/Magdir/cubemap

@@ -0,0 +1,8 @@
+
+#------------------------------------------------------------------------------
+# $File: cubemap,v 1.1 2012/06/06 13:03:20 christos Exp $
+# file(1) magic(5) data for cubemaps  Martin Erik Werner <martinerikwerner@gmail.com>
+#
+0	string	ACMP	Map file for the AssaultCube FPS game
+0	string	CUBE	Map file for cube and cube2 engine games
+0	string	MAPZ)	Map file for the Blood Frontier/Red Eclipse FPS games

+ 19 - 45
magic/Magdir/cups

@@ -1,55 +1,12 @@
 
 #------------------------------------------------------------------------------
-# $File: cups,v 1.1 2011/11/10 18:59:54 christos Exp $
+# $File: cups,v 1.2 2012/11/02 21:50:29 christos Exp $
 # Cups: file(1) magic for the cups raster file format
 # From: Laurent Martelli <martellilaurent@gmail.com>
 # http://www.cups.org/documentation.php/spec-raster.html
 #
 
-# Cups Raster image format, Big Endian
-0	string		RaS		
-!:mime	application/vnd.cups-raster
->3	string		t		Cups Raster version 1, Big Endian
->3	string		2		Cups Raster version 2, Big Endian
->3	string		3		Cups Raster version 3, Big Endian
->280	belong		x		\b, %d
->284	belong		x		\bx%d dpi
->376	belong		x		\b, %dx
->380	belong		x		\b%d pixels
->388	belong		x		%d bits/color
->392	belong		x		%d bits/pixel
->400	belong		0		ColorOrder=Chunky
->400	belong		1		ColorOrder=Banded
->400	belong		2		ColorOrder=Planar
->404	belong		0		ColorSpace=gray
->404	belong		1		ColorSpace=RGB
->404	belong		2		ColorSpace=RGBA
->404	belong		3		ColorSpace=black
->404	belong		4		ColorSpace=CMY
->404	belong		5		ColorSpace=YMC
->404	belong		6		ColorSpace=CMYK
->404	belong		7		ColorSpace=YMCK
->404	belong		8		ColorSpace=KCMY
->404	belong		9		ColorSpace=KCMYcm
->404	belong		10		ColorSpace=GMCK
->404	belong		11		ColorSpace=GMCS
->404	belong		12		ColorSpace=WHITE
->404	belong		13		ColorSpace=GOLD
->404	belong		14		ColorSpace=SILVER
->404	belong		15		ColorSpace=CIE XYZ
->404	belong		16		ColorSpace=CIE Lab
->404	belong		17		ColorSpace=RGBW
->404	belong		18		ColorSpace=sGray
->404	belong		19		ColorSpace=sRGB
->404	belong		20		ColorSpace=AdobeRGB
-
-
-# Cups Raster image format, Little Endian
-1	string		SaR		
->0	string		t		Cups Raster version 1, Little Endian
->0	string		2		Cups Raster version 2, Little Endian
->0	string		3		Cups Raster version 3, Little Endian
-!:mime	application/vnd.cups-raster
+0	name		cups-be
 >280	lelong		x		\b, %d
 >284	lelong		x		\bx%d dpi
 >376	lelong		x		\b, %dx
@@ -80,3 +37,20 @@
 >404	lelong		18		ColorSpace=sGray
 >404	lelong		19		ColorSpace=sRGB
 >404	lelong		20		ColorSpace=AdobeRGB
+
+# Cups Raster image format, Big Endian
+0	string		RaS		
+>3	string		t		Cups Raster version 1, Big Endian
+>3	string		2		Cups Raster version 2, Big Endian
+>3	string		3		Cups Raster version 3, Big Endian
+!:mime	application/vnd.cups-raster
+>0	use		^cups-be
+
+
+# Cups Raster image format, Little Endian
+1	string		SaR		
+>0	string		t		Cups Raster version 1, Little Endian
+>0	string		2		Cups Raster version 2, Little Endian
+>0	string		3		Cups Raster version 3, Little Endian
+!:mime	application/vnd.cups-raster
+>0	use		\^cups-be

+ 6 - 1
magic/Magdir/database

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: database,v 1.28 2011/09/16 19:40:40 christos Exp $
+# $File: database,v 1.30 2012/08/26 10:23:30 christos Exp $
 # database:  file(1) magic for various databases
 #
 # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
@@ -203,6 +203,8 @@
 # MS Access database
 4	string	Standard\ Jet\ DB	Microsoft Access Database
 !:mime	application/x-msaccess
+4	string	Standard\ ACE\ DB	Microsoft Access Database
+!:mime	application/x-msaccess
 
 # TDB database from Samba et al - Martin Pool <mbp@samba.org>
 0	string	TDB\ file		TDB database
@@ -293,3 +295,6 @@
 0	string		FS21	Zope Object Database File Storage (data)
 # Cache file for the database of Zope (done by ClientStorage)
 0	string		ZEC3	Zope Object Database Client Cache File (data)
+
+# IDA (Interactive Disassembler) database
+0	string		IDA1	IDA (Interactive Disassembler) database

+ 13 - 2
magic/Magdir/diff

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: diff,v 1.12 2010/12/07 16:52:52 christos Exp $
+# $File: diff,v 1.14 2012/09/16 23:08:54 christos Exp $
 # diff:  file(1) magic for diff(1) output
 #
 0	search/1	diff\ 		diff output text
@@ -16,7 +16,7 @@
 !:mime	text/x-diff
 
 # bsdiff:  file(1) magic for bsdiff(1) output
-0	string/t		BSDIFF40	bsdiff(1) patch file
+0	string/b		BSDIFF40	bsdiff(1) patch file
 
 
 # unified diff
@@ -27,3 +27,14 @@
 >>>>&0	search/1 @@	unified diff output text
 !:mime	text/x-diff
 !:strength + 90
+
+# librsync -- the library for network deltas
+#
+# Copyright (C) 2001 by Martin Pool.  You may do whatever you want with
+# this file.
+#
+0	belong		0x72730236	rdiff network-delta data
+
+0	belong		0x72730136	rdiff network-delta signature data
+>4	belong		x		(block length=%d,
+>8	belong		x		signature strength=%d)

+ 2 - 1
magic/Magdir/dolby

@@ -1,12 +1,13 @@
 
 #------------------------------------------------------------------------------
-# $File: dolby,v 1.5 2009/09/19 16:28:08 christos Exp $
+# $File: dolby,v 1.6 2012/10/31 13:39:42 christos Exp $
 # ATSC A/53 aka AC-3 aka Dolby Digital <ashitaka@gmx.at>
 # from http://www.atsc.org/standards/a_52a.pdf
 # corrections, additions, etc. are always welcome!
 #
 # syncword
 0       beshort         0x0b77  ATSC A/52 aka AC-3 aka Dolby Digital stream,
+!:mime	audio/vnd.dolby.dd-raw
 # fscod
 >4      byte&0xc0       0x00    48 kHz,
 >4      byte&0xc0       0x40    44.1 kHz,

+ 34 - 72
magic/Magdir/dump

@@ -1,11 +1,11 @@
 
 #------------------------------------------------------------------------------
-# $File: dump,v 1.11 2009/09/19 16:28:09 christos Exp $
+# $File: dump,v 1.12 2012/11/01 04:26:40 christos Exp $
 # dump:  file(1) magic for dump file format--for new and old dump filesystems
 #
 # We specify both byte orders in order to recognize byte-swapped dumps.
 #
-24	belong	60012		new-fs dump file (big endian),
+0	name	new-dump-be
 >4	bedate	x		Previous dump %s,
 >8	bedate	x		This dump %s,
 >12	belong	>0		Volume %ld,
@@ -24,7 +24,7 @@
 >824	string	>\0		Host %s,
 >888	belong	>0		Flags %x
 
-24	belong	60011		old-fs dump file (big endian),
+0	name	old-dump-be
 #>4	bedate	x		Previous dump %s,
 #>8	bedate	x		This dump %s,
 >12	belong	>0		Volume %ld,
@@ -43,57 +43,7 @@
 >824	string	>\0		Host %s,
 >888	belong	>0		Flags %x
 
-24	lelong	60012		new-fs dump file (little endian),
->4	ledate	x		This dump %s,
->8	ledate	x		Previous dump %s,
->12	lelong	>0		Volume %ld,
->692	lelong	0		Level zero, type:
->692	lelong	>0		Level %d, type:
->0	lelong	1		tape header,
->0	lelong	2		beginning of file record,
->0	lelong	3		map of inodes on tape,
->0	lelong	4		continuation of file record,
->0	lelong	5		end of volume,
->0	lelong	6		map of inodes deleted,
->0	lelong	7		end of medium (for floppy),
->676	string	>\0		Label %s,
->696	string	>\0		Filesystem %s,
->760	string	>\0		Device %s,
->824	string	>\0		Host %s,
->888	lelong	>0		Flags %x
-
-24	lelong	60011		old-fs dump file (little endian),
-#>4	ledate	x		Previous dump %s,
-#>8	ledate	x		This dump %s,
->12	lelong	>0		Volume %ld,
->692	lelong	0		Level zero, type:
->692	lelong	>0		Level %d, type:
->0	lelong	1		tape header,
->0	lelong	2		beginning of file record,
->0	lelong	3		map of inodes on tape,
->0	lelong	4		continuation of file record,
->0	lelong	5		end of volume,
->0	lelong	6		map of inodes deleted,
->0	lelong	7		end of medium (for floppy),
->676	string	>\0		Label %s,
->696	string	>\0		Filesystem %s,
->760	string	>\0		Device %s,
->824	string	>\0		Host %s,
->888	lelong	>0		Flags %x
-
-18	leshort	60011		old-fs dump file (16-bit, assuming PDP-11 endianness),
->2	medate	x		Previous dump %s,
->6	medate	x		This dump %s,
->10	leshort	>0		Volume %ld,
->0	leshort	1		tape header.
->0	leshort	2		beginning of file record.
->0	leshort	3		map of inodes on tape.
->0	leshort	4		continuation of file record.
->0	leshort	5		end of volume.
->0	leshort	6		map of inodes deleted.
->0	leshort	7		end of medium (for floppy).
-
-24	belong	0x19540119	new-fs dump file (ufs2, big endian),
+0	name	ufs2-dump-be
 >896	beqdate	x		Previous dump %s,
 >904	beqdate	x		This dump %s,
 >12	belong	>0		Volume %ld,
@@ -112,21 +62,33 @@
 >824	string	>\0		Host %s,
 >888	belong	>0		Flags %x
 
-24	lelong	0x19540119	new-fs dump file (ufs2, little endian),
->896	leqdate	x		This dump %s,
->904	leqdate	x		Previous dump %s,
->12	lelong	>0		Volume %ld,
->692	lelong	0		Level zero, type:
->692	lelong	>0		Level %d, type:
->0	lelong	1		tape header,
->0	lelong	2		beginning of file record,
->0	lelong	3		map of inodes on tape,
->0	lelong	4		continuation of file record,
->0	lelong	5		end of volume,
->0	lelong	6		map of inodes deleted,
->0	lelong	7		end of medium (for floppy),
->676	string	>\0		Label %s,
->696	string	>\0		Filesystem %s,
->760	string	>\0		Device %s,
->824	string	>\0		Host %s,
->888	lelong	>0		Flags %x
+24	belong	60012		new-fs dump file (big endian), 
+>0	use	new-dump-be
+
+24	belong	60011		old-fs dump file (big endian), 
+>0	use	old-dump-be
+
+24	lelong	60012		new-fs dump file (little endian), 
+>0	use	\^new-dump-be
+
+24	lelong	60011		old-fs dump file (little endian), 
+>0	use	\^old-dump-be
+
+
+24	belong	0x19540119	new-fs dump file (ufs2, big endian), 
+>0	use	ufs2-dump-be
+
+24	lelong	0x19540119	new-fs dump file (ufs2, little endian), 
+>0	use	\^ufs2-dump-be
+
+18	leshort	60011		old-fs dump file (16-bit, assuming PDP-11 endianness),
+>2	medate	x		Previous dump %s,
+>6	medate	x		This dump %s,
+>10	leshort	>0		Volume %ld,
+>0	leshort	1		tape header.
+>0	leshort	2		beginning of file record.
+>0	leshort	3		map of inodes on tape.
+>0	leshort	4		continuation of file record.
+>0	leshort	5		end of volume.
+>0	leshort	6		map of inodes deleted.
+>0	leshort	7		end of medium (for floppy).

+ 159 - 237
magic/Magdir/elf

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: elf,v 1.54 2011/12/17 17:16:29 christos Exp $
+# $File: elf,v 1.58 2012/11/06 20:43:52 christos Exp $
 # elf:  file(1) magic for ELF executables
 #
 # We have to check the byte order flag to see what byte order all the
@@ -14,263 +14,185 @@
 # Modified by (3): Christian 'Dr. Disk' Hechelmann <drdisk@ds9.au.s.shuttle.de> (fix of core support)
 # Modified by (4): <gerardo.cacciari@gmail.com> (VMS Itanium)
 # Modified by (5): Matthias Urlichs <smurf@debian.org> (Listing of many architectures)
-0	string		\177ELF		ELF
->4	byte		0		invalid class
->4	byte		1		32-bit
->4	byte		2		64-bit
->5	byte		0		invalid byte order
->5	byte		1		LSB
->>16	leshort		0		no file type,
+
+0	name		elf-le
+>16	leshort		0		no file type,
 !:strength *2
 !:mime	application/octet-stream
->>16	leshort		1		relocatable,
+>16	leshort		1		relocatable,
 !:mime	application/x-object
->>16	leshort		2		executable,
+>16	leshort		2		executable,
 !:mime	application/x-executable
->>16	leshort		3		shared object,
+>16	leshort		3		shared object,
 !:mime	application/x-sharedlib
->>16	leshort		4		core file
+>16	leshort		4		core file
 !:mime	application/x-coredump
 # Core file detection is not reliable.
 #>>>(0x38+0xcc) string	>\0		of '%s'
 #>>>(0x38+0x10) lelong	>0		(signal %d),
->>16	leshort		&0xff00		processor-specific,
->>18	leshort		0		no machine,
->>18	leshort		1		AT&T WE32100 - invalid byte order,
->>18	leshort		2		SPARC - invalid byte order,
->>18	leshort		3		Intel 80386,
->>18	leshort		4		Motorola
+>16	leshort		&0xff00		processor-specific,
+>18	leshort		0		no machine,
+>18	leshort		1		AT&T WE32100
+>18	leshort		2		SPARC
+>18	leshort		3		Intel 80386,
+>18	leshort		4		Motorola
+>>4	byte		1
 >>>36	lelong		&0x01000000	68000 - invalid byte order,
 >>>36	lelong		&0x00810000	CPU32 - invalid byte order,
 >>>36	lelong		0		68020 - invalid byte order,
->>18	leshort		5		Motorola 88000 - invalid byte order,
->>18	leshort		6		Intel 80486,
->>18	leshort		7		Intel 80860,
+>18	leshort		5		Motorola 88000 - invalid byte order,
+>18	leshort		6		Intel 80486,
+>18	leshort		7		Intel 80860,
 # The official e_machine number for MIPS is now #8, regardless of endianness.
 # The second number (#10) will be deprecated later. For now, we still
 # say something if #10 is encountered, but only gory details for #8.
->>18	leshort		8		MIPS,
+>18	leshort		8		MIPS,
+>>4	byte		1
 >>>36	lelong		&0x20		N32
->>18	leshort		10		MIPS,
+>18	leshort		10		MIPS,
+>>4	byte		1
 >>>36	lelong		&0x20		N32
->>18	leshort		8
+>18	leshort		8
 # only for 32-bit
->>>4	byte		1
->>>>36  lelong&0xf0000000	0x00000000	MIPS-I
->>>>36  lelong&0xf0000000	0x10000000	MIPS-II
->>>>36  lelong&0xf0000000	0x20000000	MIPS-III
->>>>36  lelong&0xf0000000	0x30000000	MIPS-IV
->>>>36  lelong&0xf0000000	0x40000000	MIPS-V
->>>>36  lelong&0xf0000000	0x50000000	MIPS32
->>>>36  lelong&0xf0000000	0x60000000	MIPS64
->>>>36  lelong&0xf0000000	0x70000000	MIPS32 rel2
->>>>36  lelong&0xf0000000	0x80000000	MIPS64 rel2
+>>4	byte		1
+>>>36  lelong&0xf0000000	0x00000000	MIPS-I
+>>>36  lelong&0xf0000000	0x10000000	MIPS-II
+>>>36  lelong&0xf0000000	0x20000000	MIPS-III
+>>>36  lelong&0xf0000000	0x30000000	MIPS-IV
+>>>36  lelong&0xf0000000	0x40000000	MIPS-V
+>>>36  lelong&0xf0000000	0x50000000	MIPS32
+>>>36  lelong&0xf0000000	0x60000000	MIPS64
+>>>36  lelong&0xf0000000	0x70000000	MIPS32 rel2
+>>>36  lelong&0xf0000000	0x80000000	MIPS64 rel2
 # only for 64-bit
->>>4	byte		2
->>>>48  lelong&0xf0000000	0x00000000	MIPS-I
->>>>48  lelong&0xf0000000	0x10000000	MIPS-II
->>>>48  lelong&0xf0000000	0x20000000	MIPS-III
->>>>48  lelong&0xf0000000	0x30000000	MIPS-IV
->>>>48  lelong&0xf0000000	0x40000000	MIPS-V
->>>>48  lelong&0xf0000000	0x50000000	MIPS32
->>>>48  lelong&0xf0000000	0x60000000	MIPS64
->>>>48  lelong&0xf0000000	0x70000000	MIPS32 rel2
->>>>48  lelong&0xf0000000	0x80000000	MIPS64 rel2
->>18	leshort		9		Amdahl - invalid byte order,
->>18	leshort		10		MIPS (deprecated),
->>18	leshort		11		RS6000 - invalid byte order,
->>18	leshort		15		PA-RISC - invalid byte order,
->>>50	leshort		0x0214		2.0
->>>48	leshort		&0x0008		(LP64),
->>18	leshort		16		nCUBE,
->>18	leshort		17		Fujitsu VPP500,
->>18	leshort		18		SPARC32PLUS - invalid byte order,
->>18	leshort		20		PowerPC,
->>18	leshort		22		IBM S/390,
->>18	leshort		36		NEC V800,
->>18	leshort		37		Fujitsu FR20,
->>18	leshort		38		TRW RH-32,
->>18	leshort		39		Motorola RCE,
->>18	leshort		40		ARM,
->>18	leshort		41		Alpha,
->>18	leshort		0xa390		IBM S/390 (obsolete),
->>18	leshort		42		Renesas SH,
->>18	leshort		43		SPARC V9 - invalid byte order,
->>18	leshort		44		Siemens Tricore Embedded Processor,
->>18	leshort		45		Argonaut RISC Core, Argonaut Technologies Inc.,
->>18	leshort		46		Renesas H8/300,
->>18	leshort		47		Renesas H8/300H,
->>18	leshort		48		Renesas H8S,
->>18	leshort		49		Renesas H8/500,
->>18	leshort		50		IA-64,
->>18	leshort		51		Stanford MIPS-X,
->>18	leshort		52		Motorola Coldfire,
->>18	leshort		53		Motorola M68HC12,
->>18	leshort		54		Fujitsu MMA,
->>18	leshort		55		Siemens PCP,
->>18	leshort		56		Sony nCPU,
->>18	leshort		57		Denso NDR1,
->>18	leshort		58		Start*Core,
->>18	leshort		59		Toyota ME16,
->>18	leshort		60		ST100,
->>18	leshort		61		Tinyj emb.,
->>18	leshort		62		x86-64,
->>18	leshort		63		Sony DSP,
->>18	leshort		66		FX66,
->>18	leshort		67		ST9+ 8/16 bit,
->>18	leshort		68		ST7 8 bit,
->>18	leshort		69		MC68HC16,
->>18	leshort		70		MC68HC11,
->>18	leshort		71		MC68HC08,
->>18	leshort		72		MC68HC05,
->>18	leshort		73		SGI SVx,
->>18	leshort		74		ST19 8 bit,
->>18	leshort		75		Digital VAX,
->>18	leshort		76		Axis cris,
->>18	leshort		77		Infineon 32-bit embedded,
->>18	leshort		78		Element 14 64-bit DSP,
->>18	leshort		79		LSI Logic 16-bit DSP,
->>18	leshort		80		MMIX,
->>18	leshort		81		Harvard machine-independent,
->>18	leshort		82		SiTera Prism,
->>18	leshort		83		Atmel AVR 8-bit,
->>18	leshort		84		Fujitsu FR30,
->>18	leshort		85		Mitsubishi D10V,
->>18	leshort		86		Mitsubishi D30V,
->>18	leshort		87		NEC v850,
->>18	leshort		88		Renesas M32R,
->>18	leshort		89		Matsushita MN10300,
->>18	leshort		90		Matsushita MN10200,
->>18	leshort		91		picoJava,
->>18	leshort		92		OpenRISC,
->>18	leshort		93		ARC Cores Tangent-A5,
->>18	leshort		94		Tensilica Xtensa,
->>18	leshort		97		NatSemi 32k,
->>18	leshort		106		Analog Devices Blackfin,
->>18	leshort		113		Altera Nios II,
->>18	leshort		0xae		META,
->>18	leshort		187		Tilera TILE64,
->>18	leshort		188		Tilera TILEPro,
->>18	leshort		191		Tilera TILE-Gx,
->>18	leshort		0x3426		OpenRISC (obsolete),
->>18	leshort		0x8472		OpenRISC (obsolete),
->>18	leshort		0x9026		Alpha (unofficial),
->>20	lelong		0		invalid version
->>20	lelong		1		version 1
->>36	lelong		1		MathCoPro/FPU/MAU Required
->5	byte		2		MSB
->>16	beshort		0		no file type,
-!:mime	application/octet-stream
->>16	beshort		1		relocatable,
-!:mime	application/x-object
->>16	beshort		2		executable,
-!:mime	application/x-executable
->>16	beshort		3		shared object,
-!:mime	application/x-sharedlib
->>16	beshort		4		core file,
-!:mime	application/x-coredump
-#>>>(0x38+0xcc) string	>\0		of '%s'
-#>>>(0x38+0x10) belong	>0		(signal %d),
->>16	beshort		&0xff00		processor-specific,
->>18	beshort		0		no machine,
->>18	beshort		1		AT&T WE32100,
->>18	beshort		2		SPARC,
->>18	beshort		3		Intel 80386 - invalid byte order,
->>18	beshort		4		Motorola
->>>36	belong		&0x01000000	68000,
->>>36	belong		&0x00810000	CPU32,
->>>36	belong		0		68020,
->>18	beshort		5		Motorola 88000,
->>18	beshort		6		Intel 80486 - invalid byte order,
->>18	beshort		7		Intel 80860,
-# only for MIPS - see comment in little-endian section above.
->>18	beshort		8		MIPS,
->>>36	belong		&0x20		N32
->>18	beshort		10		MIPS,
->>>36	belong		&0x20		N32
->>18	beshort		8
+>>4	byte		2
+>>>48  lelong&0xf0000000	0x00000000	MIPS-I
+>>>48  lelong&0xf0000000	0x10000000	MIPS-II
+>>>48  lelong&0xf0000000	0x20000000	MIPS-III
+>>>48  lelong&0xf0000000	0x30000000	MIPS-IV
+>>>48  lelong&0xf0000000	0x40000000	MIPS-V
+>>>48  lelong&0xf0000000	0x50000000	MIPS32
+>>>48  lelong&0xf0000000	0x60000000	MIPS64
+>>>48  lelong&0xf0000000	0x70000000	MIPS32 rel2
+>>>48  lelong&0xf0000000	0x80000000	MIPS64 rel2
+>18	leshort		9		Amdahl - invalid byte order,
+>18	leshort		10		MIPS (deprecated),
+>18	leshort		11		RS6000 - invalid byte order,
+>18	leshort		15		PA-RISC - invalid byte order,
 # only for 32-bit
->>>4	byte		1
->>>>36  belong&0xf0000000	0x00000000	MIPS-I
->>>>36  belong&0xf0000000	0x10000000	MIPS-II
->>>>36  belong&0xf0000000	0x20000000	MIPS-III
->>>>36  belong&0xf0000000	0x30000000	MIPS-IV
->>>>36  belong&0xf0000000	0x40000000	MIPS-V
->>>>36  belong&0xf0000000	0x50000000	MIPS32
->>>>36  belong&0xf0000000	0x60000000	MIPS64
->>>>36  belong&0xf0000000	0x70000000	MIPS32 rel2
->>>>36  belong&0xf0000000	0x80000000	MIPS64 rel2
+>>4	byte		1
+>>>38	leshort		0x0214		2.0
+>>>36	leshort		&0x0008		(LP64)
 # only for 64-bit
->>>4	byte		2
->>>>48	belong&0xf0000000	0x00000000	MIPS-I
->>>>48	belong&0xf0000000	0x10000000	MIPS-II
->>>>48	belong&0xf0000000	0x20000000	MIPS-III
->>>>48	belong&0xf0000000	0x30000000	MIPS-IV
->>>>48	belong&0xf0000000	0x40000000	MIPS-V
->>>>48	belong&0xf0000000	0x50000000	MIPS32
->>>>48	belong&0xf0000000	0x60000000	MIPS64
->>>>48	belong&0xf0000000	0x70000000	MIPS32 rel2
->>>>48	belong&0xf0000000	0x80000000	MIPS64 rel2
->>18	beshort		9		Amdahl,
->>18	beshort		10		MIPS (deprecated),
->>18	beshort		11		RS6000,
->>18	beshort		15		PA-RISC
->>>50	beshort		0x0214		2.0
->>>48	beshort		&0x0008		(LP64)
->>18	beshort		16		nCUBE,
->>18	beshort		17		Fujitsu VPP500,
->>18	beshort		18		SPARC32PLUS,
->>>36	belong&0xffff00	0x000100	V8+ Required,
->>>36	belong&0xffff00	0x000200	Sun UltraSPARC1 Extensions Required,
->>>36	belong&0xffff00	0x000400	HaL R1 Extensions Required,
->>>36	belong&0xffff00	0x000800	Sun UltraSPARC3 Extensions Required,
->>18	beshort		20		PowerPC or cisco 4500,
->>18	beshort		21		64-bit PowerPC or cisco 7500,
->>18	beshort		22		IBM S/390,
->>18	beshort		23		Cell SPU,
->>18	beshort		24		cisco SVIP,
->>18	beshort		25		cisco 7200,
->>18	beshort		36		NEC V800 or cisco 12000,
->>18	beshort		37		Fujitsu FR20,
->>18	beshort		38		TRW RH-32,
->>18	beshort		39		Motorola RCE,
->>18	beshort		40		ARM,
->>18	beshort		41		Alpha,
->>18	beshort		42		Renesas SH,
->>18	beshort		43		SPARC V9,
->>>48	belong&0xffff00	0x000200	Sun UltraSPARC1 Extensions Required,
->>>48	belong&0xffff00	0x000400	HaL R1 Extensions Required,
->>>48	belong&0xffff00	0x000800	Sun UltraSPARC3 Extensions Required,
->>>48	belong&0x3	0		total store ordering,
->>>48	belong&0x3	1		partial store ordering,
->>>48	belong&0x3	2		relaxed memory ordering,
->>18	beshort		44		Siemens Tricore Embedded Processor,
->>18	beshort		45		Argonaut RISC Core, Argonaut Technologies Inc.,
->>18	beshort		46		Renesas H8/300,
->>18	beshort		47		Renesas H8/300H,
->>18	beshort		48		Renesas H8S,
->>18	beshort		49		Renesas H8/500,
->>18	beshort		50		IA-64,
->>18	beshort		51		Stanford MIPS-X,
->>18	beshort		52		Motorola Coldfire,
->>18	beshort		53		Motorola M68HC12,
->>18	beshort		73		Cray NV1,
->>18	beshort		75		Digital VAX,
->>18	beshort		88		Renesas M32R,
->>18	leshort		92		OpenRISC,
->>18	leshort		0x3426		OpenRISC (obsolete),
->>18	leshort		0x8472		OpenRISC (obsolete),
->>18	beshort		94		Tensilica Xtensa,
->>18	beshort		97		NatSemi 32k,
->>18	beshort		187		Tilera TILE64,
->>18	beshort		188		Tilera TILEPro,
->>18	beshort		191		Tilera TILE-Gx,
->>18	beshort		0x18ad		AVR32 (unofficial),
->>18	beshort		0x9026		Alpha (unofficial),
->>18	beshort		0xa390		IBM S/390 (obsolete),
->>20	belong		0		invalid version
->>20	belong		1		version 1
->>36	belong		1		MathCoPro/FPU/MAU Required
+>>4	byte		2
+>>>50	leshort		0x0214		2.0
+>>>48	leshort		&0x0008		(LP64)
+>18	leshort		16		nCUBE,
+>18	leshort		17		Fujitsu VPP500,
+>18	leshort		18		SPARC32PLUS,
+# only for 32-bit
+>>4	byte		1
+>>>36	lelong&0xffff00	0x000100	V8+ Required,
+>>>36	lelong&0xffff00	0x000200	Sun UltraSPARC1 Extensions Required,
+>>>36	lelong&0xffff00	0x000400	HaL R1 Extensions Required,
+>>>36	lelong&0xffff00	0x000800	Sun UltraSPARC3 Extensions Required,
+>18	leshort		20		PowerPC or cisco 4500,
+>18	leshort		21		64-bit PowerPC or cisco 7500,
+>18	leshort		22		IBM S/390,
+>18	leshort		23		Cell SPU,
+>18	leshort		24		cisco SVIP,
+>18	leshort		25		cisco 7200,
+>18	leshort		36		NEC V800 or cisco 12000,
+>18	leshort		37		Fujitsu FR20,
+>18	leshort		38		TRW RH-32,
+>18	leshort		39		Motorola RCE,
+>18	leshort		40		ARM,
+>>4	byte		1
+>>>36	lelong&0xff000000	0x04000000	EABI4
+>>>36	lelong&0xff000000	0x05000000	EABI5
+>18	leshort		41		Alpha,
+>18	leshort		0xa390		IBM S/390 (obsolete),
+>18	leshort		42		Renesas SH,
+>18	leshort		43		SPARC V9,
+>>4	byte		2
+>>>48	lelong&0xffff00	0x000200	Sun UltraSPARC1 Extensions Required,
+>>>48	lelong&0xffff00	0x000400	HaL R1 Extensions Required,
+>>>48	lelong&0xffff00	0x000800	Sun UltraSPARC3 Extensions Required,
+>>>48	lelong&0x3	0		total store ordering,
+>>>48	lelong&0x3	1		partial store ordering,
+>>>48	lelong&0x3	2		relaxed memory ordering,
+>18	leshort		44		Siemens Tricore Embedded Processor,
+>18	leshort		45		Argonaut RISC Core, Argonaut Technologies Inc.,
+>18	leshort		46		Renesas H8/300,
+>18	leshort		47		Renesas H8/300H,
+>18	leshort		48		Renesas H8S,
+>18	leshort		49		Renesas H8/500,
+>18	leshort		50		IA-64,
+>18	leshort		51		Stanford MIPS-X,
+>18	leshort		52		Motorola Coldfire,
+>18	leshort		53		Motorola M68HC12,
+>18	leshort		54		Fujitsu MMA,
+>18	leshort		55		Siemens PCP,
+>18	leshort		56		Sony nCPU,
+>18	leshort		57		Denso NDR1,
+>18	leshort		58		Start*Core,
+>18	leshort		59		Toyota ME16,
+>18	leshort		60		ST100,
+>18	leshort		61		Tinyj emb.,
+>18	leshort		62		x86-64,
+>18	leshort		63		Sony DSP,
+>18	leshort		66		FX66,
+>18	leshort		67		ST9+ 8/16 bit,
+>18	leshort		68		ST7 8 bit,
+>18	leshort		69		MC68HC16,
+>18	leshort		70		MC68HC11,
+>18	leshort		71		MC68HC08,
+>18	leshort		72		MC68HC05,
+>18	leshort		73		SGI SVx or Cray NV1,
+>18	leshort		74		ST19 8 bit,
+>18	leshort		75		Digital VAX,
+>18	leshort		76		Axis cris,
+>18	leshort		77		Infineon 32-bit embedded,
+>18	leshort		78		Element 14 64-bit DSP,
+>18	leshort		79		LSI Logic 16-bit DSP,
+>18	leshort		80		MMIX,
+>18	leshort		81		Harvard machine-independent,
+>18	leshort		82		SiTera Prism,
+>18	leshort		83		Atmel AVR 8-bit,
+>18	leshort		84		Fujitsu FR30,
+>18	leshort		85		Mitsubishi D10V,
+>18	leshort		86		Mitsubishi D30V,
+>18	leshort		87		NEC v850,
+>18	leshort		88		Renesas M32R,
+>18	leshort		89		Matsushita MN10300,
+>18	leshort		90		Matsushita MN10200,
+>18	leshort		91		picoJava,
+>18	leshort		92		OpenRISC,
+>18	leshort		93		ARC Cores Tangent-A5,
+>18	leshort		94		Tensilica Xtensa,
+>18	leshort		97		NatSemi 32k,
+>18	leshort		106		Analog Devices Blackfin,
+>18	leshort		113		Altera Nios II,
+>18	leshort		174		META,
+>18	leshort		183		ARM aarch64,
+>18	leshort		187		Tilera TILE64,
+>18	leshort		188		Tilera TILEPro,
+>18	leshort		191		Tilera TILE-Gx,
+>18	leshort		0x3426		OpenRISC (obsolete),
+>18	leshort		0x8472		OpenRISC (obsolete),
+>18	leshort		0x9026		Alpha (unofficial),
+>20	lelong		0		invalid version
+>20	lelong		1		version 1
+
+0	string		\177ELF		ELF
+>4	byte		0		invalid class
+>4	byte		1		32-bit
+>4	byte		2		64-bit
+>5	byte		0		invalid byte order
+>5	byte		1		LSB 
+>>0	use		elf-le
+>5	byte		2		MSB 
+>>0	use		\^elf-le
 # Up to now only 0, 1 and 2 are defined; I've seen a file with 0x83, it seemed
 # like proper ELF, but extracting the string had bad results.
 >4      byte            <0x80

+ 10 - 1
magic/Magdir/epoc

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: epoc,v 1.7 2009/09/19 16:28:09 christos Exp $
+# $File: epoc,v 1.8 2012/06/16 14:43:36 christos Exp $
 # EPOC : file(1) magic for EPOC documents [Psion Series 5/Osaris/Geofox 1]
 # Stefan Praszalowicz <hpicollo@worldnet.fr> and Peter Breitenlohner <peb@mppmu.mpg.de>
 # Useful information for improving this file can be found at:
@@ -21,6 +21,7 @@
 !:mime application/x-epoc-word
 >>8	lelong		0x10000085	OPL program (TextEd)
 !:mime application/x-epoc-opl
+>>8	lelong		0x10000087	Comms settings
 >>8	lelong		0x10000088	Sheet file
 !:mime application/x-epoc-sheet
 >>8	lelong		0x100001C4	EasyFax initialisation file
@@ -29,11 +30,19 @@
 >4	lelong		0x10000074	OPL application
 !:mime application/x-epoc-app
 >4	lelong		0x1000008A	exported multi-bitmap image
+>4	lelong		0x1000016D	
+>>8	lelong		0x10000088	Comms names
 
 0	lelong		0x10000041	Psion Series 5 ROM multi-bitmap image
 
 0	lelong		0x10000050	Psion Series 5
 >4	lelong		0x1000006D	database
+>>8	lelong		0x10000084	Agenda file
+!:mime application/x-epoc-agenda
+>>8	lelong		0x10000086	Data file
+!:mime application/x-epoc-data
+>>8	lelong		0x10000CEA	Jotter file
+!:mime application/x-epoc-jotter
 >4	lelong		0x100000E4	ini file
 
 0	lelong		0x10000079	Psion Series 5 binary:

+ 429 - 178
magic/Magdir/filesystems

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: filesystems,v 1.61 2011/01/10 14:01:10 christos Exp $
+# $File: filesystems,v 1.69 2012/12/18 17:28:43 christos Exp $
 # filesystems:  file(1) magic for different filesystems
 #
 0	string	\366\366\366\366	PC formatted floppy with no filesystem
@@ -27,7 +27,8 @@
 >>0770	long		x		%ld blocks
 # Is there a boot block written 1 sector in?
 >512    belong&077777777	0600407	\b, boot block present
-# Joerg Jenderek: Smart Boot Manager backup file is 41 byte header + first sectors of disc
+
+# Joerg Jenderek: Smart Boot Manager backup file is 25 (MSDOS) or 41 (LINUX) byte header + first sectors of disk
 # (http://btmgr.sourceforge.net/docs/user-guide-3.html)
 0		string	SBMBAKUP_	Smart Boot Manager backup file
 >9		string	x		\b, version %-5.5s
@@ -41,8 +42,10 @@
 >>>>21		ubyte	x		\b, from drive 0x%x
 >>>22		ubyte	>0		
 >>>>21		string	x		\b, from drive %s
+>>>535		search/17	\x55\xAA	
+>>>>&-512	indirect	x	\b; contains 
 
-# Joerg Jenderek
+# updated by Joerg Jenderek at Nov 2012
 # DOS Emulator image is 128 byte, null right padded header + harddisc image
 0	string	DOSEMU\0			
 >0x27E	leshort	0xAA55			
@@ -52,14 +55,23 @@
 >>>>7	ulelong	>0		\b, %u heads
 >>>>11	ulelong	>0		\b, %d sectors/track
 >>>>15	ulelong	>0		\b, %d cylinders
+>>>>128	indirect	x	\b; contains 
 
-# updated by Joerg Jenderek at Sep 2007
+# x86 boot sector updated by Joerg Jenderek at Sep 2007,May 2011
+# 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
+# for sector sizes < 512 Bytes
+>11		uleshort	<512		
+>>(11.s-2)	uleshort	0xAA55		x86 boot sector
+# for sector sizes with 512 or more Bytes
+>0x1FE		leshort		0xAA55		x86 boot sector
+# keep old x86 boot sector as dummy for mbr and bootloader displaying
 # only for sector sizes with 512 or more Bytes
-0x1FE	leshort	0xAA55			x86 boot sector
-# to do also for sectors < than 512 Bytes and some other files, GRR
-#30	search/481	\x55\xAA	x86 boot sector
-# not for BeOS floppy 1440k, MBRs
-#(11.s-2) uleshort	0xAA55		x86 boot sector
+0x1FE	leshort	0xAA55			
+# 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
@@ -131,8 +143,7 @@
 >>>>>>>420	ubyte&0x0F	0Xf			\b ask
 >>>>>420	ubyte		x			\b)
 #
->271	string	Operating\ system\ loading 		
->>296	string	error\r					\b, SYSLINUX MBR (2.10)
+# SYSLINUX MBR moved
 # http://www.acronis.de/
 >362	string	MBR\ Error\ \0\r			
 >>376	string	ress\ any\ key\ to\ 			
@@ -193,12 +204,7 @@
 >>>>321		string	Loading\ stage1.5	\b, GRUB version x.y
 >>>380		string	Geom\0Hard\ Disk\0Read\0\ Error\0
 >>>>374		string	GRUB\ \0		\b, GRUB version n.m
-# http://syslinux.zytor.com/
->478	string	Boot\ failed\r			
->>495	string	LDLINUX\ SYS			\b, SYSLINUX bootloader (1.62)
->480	string	Boot\ failed\r			
->>495	string	LDLINUX\ SYS			\b, SYSLINUX bootloader (2.06 or 2.11)
->484	string	Boot\ error\r			\b, SYSLINUX bootloader (3.11)
+# SYSLINUX bootloader moved
 >395	string	chksum\0\ ERROR!\0		\b, Gujin bootloader
 # http://www.bcdwb.de/bcdw/index_e.htm
 >3	string	BCDL				
@@ -263,11 +269,14 @@
 #OEM-ID=BOOTWIZ0
 >442	string	Non-system\ disk,\ 	
 >>459	string	press\ any\ key...\x7\0		\b, Acronis Startup Recovery Loader
-# DOS names like F11.SYS are 8 right space padded bytes+3 bytes
+# updated by Joerg Jenderek at Nov 2012
+# DOS names like F11.SYS or BOOTWIZ.SYS are 8 right space padded bytes+3 bytes
 >>>477		ubyte&0xDF	>0		
 >>>>477		string		x 		\b %-.3s
 >>>>>480	ubyte&0xDF	>0		
->>>>>>480	string		x 		\b%-.5s
+>>>>>>480	string		x 		\b%-.4s
+>>>>>>>484	ubyte&0xDF	>0		
+>>>>>>>>484	string		x 		\b%-.1s
 >>>>485		ubyte&0xDF	>0		
 >>>>>485	string		x 		\b.%-.3s
 #
@@ -279,24 +288,39 @@
 >>>>>291 string and\ press\ any\ key.\n\r		\b, FDBOOT harddisk Bootloader
 >>>>>>200 string	>\0                             \b, version %-3s
 >242	string	Bootsector\ from\ C.H.\ Hochst\204	
->>278	string	No\ Systemdisk.\ 			
->>>293	string	Booting\ from\ harddisk.\n\r		
->>>441	string	Cannot\ load\ from\ harddisk.\n\r	
->>>>469 string	Insert\ Systemdisk\ 			
->>>>>487 string and\ press\ any\ key.\n\r		\b, WinImage harddisk Bootloader
->>>>>>209 string	>\0                             \b, version %-4.4s
+# 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
+>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
+>>>208	search/261	Cannot\ load\ from\ harddisk.			
+# followed by variants CR-NL or NL-CR
+>>>>236	search/235	Insert\ Systemdisk\ and\ press\ any\ key.	
+# followed by variants with point,CR-NL or NL-CR
+>>>>>180	search/96	Disk\ formatted\ with\ WinImage\ 	\b, WinImage harddisk Bootloader
+# followed by string like "6.50 (c) 1993-2004 Gilles Vollant"
+>>>>>>&0	string		x 					\b, version %-4.4s
 >(1.b+2)	ubyte		0xe			
 >>(1.b+3)	ubyte		0x1f			
 >>>(1.b+4)	ubyte		0xbe			
->>>>(1.b+5)	ubyte		0x77			
->>>>(1.b+6)	ubyte		0x7c			
->>>>>(1.b+7)	ubyte		0xac			
->>>>>>(1.b+8)	ubyte		0x22			
->>>>>>>(1.b+9)	ubyte		0xc0			
->>>>>>>>(1.b+10)	ubyte	0x74			
->>>>>>>>>(1.b+11)	ubyte	0xb			
->>>>>>>>>>(1.b+12)	ubyte	0x56			
->>>>>>>>>>(1.b+13)	ubyte	0xb4			\b, mkdosfs boot message display
+# message offset found at (1.b+5) is 0x77 for FAT32 or 0x5b for others
+>>>>(1.b+5)	ubyte&0xd3	0x53			
+>>>>>(1.b+6)	ubyte		0x7c			
+# assembler instructions: lodsb;and al,al;jz 0xb;push si;mov ah,
+>>>>>>(1.b+7)	ubyte		0xac			
+>>>>>>>(1.b+8)	ubyte		0x22			
+>>>>>>>>(1.b+9)	ubyte		0xc0			
+>>>>>>>>>(1.b+10)	ubyte	0x74			
+>>>>>>>>>>(1.b+11)	ubyte	0x0b			
+>>>>>>>>>>>(1.b+12)	ubyte	0x56			
+>>>>>>>>>>>>(1.b+13)	ubyte	0xb4			\b, mkdosfs boot message display
+# FAT1X version
+>>>>>>>>>>>>>(1.b+5)	ubyte	0x5b			
+>>>>>>>>>>>>>>0x5b	string	>\0			"%-s"
+# FAT32 version
+>>>>>>>>>>>>>(1.b+5)	ubyte	0x77			
+>>>>>>>>>>>>>>0x77	string	>\0			"%-s"
 >214	string	Please\ try\ to\ install\ FreeDOS\ 	\b, DOS Emulator boot message display
 #>>244	string	from\ dosemu-freedos-*-bin.tgz\r	
 #>>>170	string	Sorry,\ could\ not\ load\ an\ 		
@@ -762,6 +786,18 @@
 >>>>>492		string		RENF		\b, FAT (12 bit)
 >>>>>495		string		RENF		\b, FAT (16 bit)
 # x86 bootloader end
+
+# added by Joerg Jenderek at Nov 2012
+# http://www.thenakedpc.com/articles/v04/08/0408-05.html
+# Symantec (Peter Norton) Image.dat file consists of variable header, bootrecord, part of FAT and root directory data
+0	string	PNCIHISK\0		Norton Utilities disc image data
+# real x86 boot sector with jump instruction
+>509	search/1026	\x55\xAA\xeb	
+>>&-1	indirect	x		\b; contains 
+# http://file-extension.net/seeker/file_extension_dat
+0	string	PNCIUNDO		Norton Disk Doctor UnDo file
+#
+
 # updated by Joerg Jenderek at Sep 2007
 >3	ubyte	0			
 #no active flag
@@ -776,149 +812,13 @@
 >>>>>>>466	ubyte	0x05			\b, extended partition table
 >>>>>>>466	ubyte	0x0F			\b, extended partition table (LBA)
 >>>>>>>466	ubyte	0x0			\b, extended partition table (last)	
-# JuMP short     bootcodeoffset NOP assembler instructions will usually be EB xx 90
-# http://mirror.href.com/thestarman/asm/2bytejumps.htmm#FWD
-# older drives may use Near JuMP instruction E9 xx xx
->0		lelong&0x009000EB	0x009000EB 
->0		lelong&0x000000E9	0x000000E9 
-# minimal short forward jump found 03cx??
-# maximal short forward jump is 07fx
->1		ubyte			<0xff	\b, code offset 0x%x
-# mtools-3.9.8/msdos.h
-# usual values are marked with comments to get only informations of strange FAT systems
-# valid sectorsize must be a power of 2 from 32 to 32768
->>11		uleshort&0x000f	x		
->>>11		uleshort	<32769		
->>>>11		uleshort	>31		
->>>>>21		ubyte&0xf0	0xF0		
->>>>>>3		string		>\0		\b, OEM-ID "%8.8s"
-#http://mirror.href.com/thestarman/asm/debug/debug2.htm#IHC
->>>>>>>8	string		IHC		\b cached by Windows 9M
->>>>>>11	uleshort	>512		\b, Bytes/sector %u
-#>>>>>>11	uleshort	=512		\b, Bytes/sector %u=512 (usual)
->>>>>>11	uleshort	<512		\b, Bytes/sector %u
->>>>>>13	ubyte		>1		\b, sectors/cluster %u
-#>>>>>>13	ubyte		=1		\b, sectors/cluster %u (usual on Floppies)
->>>>>>14	uleshort	>32		\b, reserved sectors %u
-#>>>>>>14	uleshort	=32		\b, reserved sectors %u (usual Fat32)
-#>>>>>>14	uleshort	>1		\b, reserved sectors %u
-#>>>>>>14	uleshort	=1		\b, reserved sectors %u (usual FAT12,FAT16)
->>>>>>14	uleshort	<1		\b, reserved sectors %u
->>>>>>16	ubyte		>2		\b, FATs %u
-#>>>>>>16	ubyte		=2		\b, FATs %u (usual)
->>>>>>16	ubyte		=1		\b, FAT  %u
->>>>>>16	ubyte		>0
->>>>>>17	uleshort	>0		\b, root entries %u
-#>>>>>>17	uleshort	=0		\b, root entries %u=0 (usual Fat32)
->>>>>>19	uleshort	>0		\b, sectors %u (volumes <=32 MB) 
-#>>>>>>19	uleshort	=0		\b, sectors %u=0 (usual Fat32)
->>>>>>21	ubyte		>0xF0		\b, Media descriptor 0x%x
-#>>>>>>21	ubyte		=0xF0		\b, Media descriptor 0x%x (usual floppy)
->>>>>>21	ubyte		<0xF0		\b, Media descriptor 0x%x
->>>>>>22	uleshort	>0		\b, sectors/FAT %u
-#>>>>>>22	uleshort	=0		\b, sectors/FAT %u=0 (usual Fat32)
->>>>>>26	ubyte		>2		\b, heads %u
-#>>>>>>26	ubyte		=2		\b, heads %u (usual floppy)
->>>>>>26	ubyte		=1		\b, heads %u
-#skip for Digital Research DOS (version 3.41) 1440 kB Bootdisk
->>>>>>38	ubyte		!0x70		
->>>>>>>28	ulelong		>0		\b, hidden sectors %u
-#>>>>>>>28	ulelong		=0		\b, hidden sectors %u (usual floppy)
->>>>>>>32	ulelong		>0		\b, sectors %u (volumes > 32 MB) 
-#>>>>>>>32	ulelong		=0		\b, sectors %u (volumes > 32 MB)
-# FAT<32 specific 
->>>>>>82	string		!FAT32
-#>>>>>>>36	ubyte		0x80		\b, physical drive 0x%x=0x80 (usual harddisk)
-#>>>>>>>36	ubyte		0		\b, physical drive 0x%x=0 (usual floppy)
->>>>>>>36	ubyte		!0x80		
->>>>>>>>36	ubyte		!0		\b, physical drive 0x%x
->>>>>>>37	ubyte		>0		\b, reserved 0x%x
-#>>>>>>>37	ubyte		=0		\b, reserved 0x%x
->>>>>>>38	ubyte		>0x29		\b, dos < 4.0 BootSector (0x%x)
->>>>>>>38	ubyte		<0x29		\b, dos < 4.0 BootSector (0x%x)
->>>>>>>38	ubyte		=0x29
->>>>>>>>39	ulelong		x		\b, serial number 0x%x
->>>>>>>>43	string		<NO\ NAME	\b, label: "%11.11s"
->>>>>>>>43	string		>NO\ NAME	\b, label: "%11.11s"
->>>>>>>>43	string		=NO\ NAME	\b, unlabeled
->>>>>>>54	string		FAT		\b, FAT
->>>>>>>>54	string		FAT12		\b (12 bit)
->>>>>>>>54	string		FAT16		\b (16 bit)
-# FAT32 specific
->>>>>>82	string		FAT32		\b, FAT (32 bit)
->>>>>>>36	ulelong		x		\b, sectors/FAT %u
->>>>>>>40	uleshort	>0		\b, extension flags %u
-#>>>>>>>40	uleshort	=0		\b, extension flags %u
->>>>>>>42	uleshort	>0		\b, fsVersion %u
-#>>>>>>>42	uleshort	=0		\b, fsVersion %u (usual)
->>>>>>>44	ulelong		>2		\b, rootdir cluster %u
-#>>>>>>>44	ulelong		=2		\b, rootdir cluster %u
-#>>>>>>>44	ulelong		=1		\b, rootdir cluster %u
->>>>>>>48	uleshort	>1		\b, infoSector %u
-#>>>>>>>48	uleshort	=1		\b, infoSector %u (usual)
->>>>>>>48	uleshort	<1		\b, infoSector %u
->>>>>>>50	uleshort	>6		\b, Backup boot sector %u
-#>>>>>>>50	uleshort	=6		\b, Backup boot sector %u (usual) 
->>>>>>>50	uleshort	<6		\b, Backup boot sector %u
->>>>>>>54	ulelong		>0		\b, reserved1 0x%x
->>>>>>>58	ulelong		>0		\b, reserved2 0x%x
->>>>>>>62	ulelong		>0		\b, reserved3 0x%x
-# same structure as FAT1X 
->>>>>>>64	ubyte		>0x80		\b, physical drive 0x%x
-#>>>>>>>64	ubyte		=0x80		\b, physical drive 0x%x=80 (usual harddisk)
->>>>>>>64	ubyte&0x7F	>0		\b, physical drive 0x%x
-#>>>>>>>64	ubyte		=0		\b, physical drive 0x%x=0 (usual floppy)
->>>>>>>65	ubyte		>0		\b, reserved 0x%x
->>>>>>>66	ubyte		>0x29		\b, dos < 4.0 BootSector (0x%x)
->>>>>>>66	ubyte		<0x29		\b, dos < 4.0 BootSector (0x%x)
->>>>>>>66	ubyte		=0x29
->>>>>>>>67	ulelong		x		\b, serial number 0x%x
->>>>>>>>71	string		<NO\ NAME	\b, label: "%11.11s"
->>>>>>>71	string		>NO\ NAME	\b, label: "%11.11s"
->>>>>>>71	string		=NO\ NAME	\b, unlabeled
-### FATs end
+
+# DOS x86 sector separated and moved from "x86 boot sector" by Joerg Jenderek at May 2011
+
 >0x200	lelong	0x82564557		\b, BSD disklabel
 # FATX 
 0		string		FATX		FATX filesystem data
 
-
-# Minix filesystems - Juan Cespedes <cespedes@debian.org>
-0x410	leshort		0x137f
-!:strength / 2
->0x402	beshort		< 100		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
->0x1e	string		minix		\b, bootable
-0x410	leshort		0x138f
-!:strength / 2
->0x402	beshort		< 100		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
->0x1e	string		minix		\b, bootable
-0x410	leshort		0x2468
->0x402	beshort		< 100		Minix filesystem, V2, %d zones
->0x1e	string		minix		\b, bootable
-0x410	beshort		0x2468
->0x402	beshort		< 100		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
->0x1e	string		minix		\b, bootable
-0x410	leshort		0x2478
->0x402	beshort		< 100		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
->0x1e	string		minix		\b, bootable
-0x410	leshort		0x4d5a
->0x402	beshort		!0		Minix filesystem, V3, %d zones
->0x1e	string		minix		\b, bootable
-
 # romfs filesystems - Juan Cespedes <cespedes@debian.org>
 0	string		-rom1fs-	romfs filesystem, version 1
 >8	belong	x			%d bytes,
@@ -933,12 +833,141 @@
 
 0x18b	string	OS/2	OS/2 Boot Manager
 
-# updated by Joerg Jenderek at Oct 2008!!
+# updated by Joerg Jenderek at Oct 2008 and Sep 2012
 # http://syslinux.zytor.com/iso.php
-0	ulelong	0x7c40eafa		isolinux Loader
+# tested with versions 1.47,1.48,1.49,1.50,1.62,1.76,2.00,2.10;3.00,3.11,3.31,;3.70,3.71,3.73,3.75,3.80,3.82,3.84,3.86,4.01,4.03 and 4.05
+# assembler instructions: cli;jmp 0:7Cyy (yy=0x40,0x5e,0x6c,0x6e,0x77);nop;nop
+0	ulequad&0x909000007cc0eafa	0x909000007c40eafa	
+>631	search/689	ISOLINUX\ 	isolinux Loader
+>>&0	string		x		(version %-4.4s)
 # http://syslinux.zytor.com/pxe.php
-0	ulelong	0x007c05ea		pxelinux Loader
-0	ulelong	0x60669c66		pxelinux Loader
+# assembler instructions: jmp 7C05
+0	ulelong	0x007c05ea		pxelinux loader (version 2.13 or older)
+# assembler instructions: pushfd;pushad
+0	ulelong	0x60669c66		pxelinux loader
+# assembler instructions: jmp 05
+0	ulelong	0xc00005ea		pxelinux loader (version 3.70 or newer)
+# http://syslinux.zytor.com/wiki/index.php/SYSLINUX
+0	string	LDLINUX\ SYS\ 		SYSLINUX loader
+>12	string	x			(older version %-4.4s)
+0	string	\r\nSYSLINUX\ 		SYSLINUX loader
+>11	string	x			(version %-4.4s)
+# syslinux updated and separated from "x86 boot sector" by Joerg Jenderek at Sep 2012
+# assembler instructions: jmp yy (yy=0x3c,0x58);nop;"SYSLINUX"
+0	ulelong&0x80909bEB	0x009018EB	
+# OEM-ID not always "SYSLINUX"
+>434	search/47	Boot\ failed		
+# followed by \r\n\0 or :\ 
+>>482	search/132	\0LDLINUX\ SYS		Syslinux bootloader (version 2.13 or older)
+>>1	ubyte		0x58			Syslinux bootloader (version 3.0-3.9)
+>459	search/30	Boot\ error\r\n\0	
+>>1	ubyte		0x58			Syslinux bootloader (version 3.10 or newer)
+# SYSLINUX MBR updated and separated from "x86 boot sector" by Joerg Jenderek at Sep 2012
+# assembler instructions: mov di,0600h;mov cx,0100h
+16	search/4	\xbf\x00\x06\xb9\x00\x01		
+>94	search/249	Missing\ operating\ system		
+# followed by \r for versions older 3.35 , .\r for versions newer 3.52 and point for other
+# skip Ranish MBR
+>>408	search/4	HD1/\0	 				
+>>408	default		x					
+>>>250	search/118	\0Operating\ system\ load		SYSLINUX MBR
+# followed by "ing " or space
+>>>>292	search/98	error   				
+>>>>>&0	string		\r		    			(version 3.35 or older)
+>>>>>&0	string		.\r					(version 3.52 or newer)
+>>>>>&0	default		x					(version 3.36-3.51 )
+>368	search/106	\0Disk\ error\ on\ boot\r\n		SYSLINUX GPT-MBR
+>>156	search/10	\0Boot\ partition\ not\ found\r\n	
+>>>270	search/10	\0OS\ not\ bootable\r\n			(version 3.86 or older)
+>>174	search/10	\0Missing\ OS\r\n			
+>>>189	search/10	\0Multiple\ active\ partitions\r\n	(version 4.00 or newer)
+# SYSLINUX END
+
+# NetBSD mbr variants (master-boot-code version 1.22) added by Joerg Jenderek at Nov 2012
+# assembler instructions: xor ax,ax;mov	ax,ss;mov sp,0x7c00;mov	ax,
+0	ubequad		0x31c08ed0bc007c8e			
+# mbr_bootsel magic before partition table not reliable with small ipl fragments
+#>444	uleshort	0xb5e1					
+>0004	uleshort	x					
+# ERRorTeXT
+>>181	search/166		Error\ \0\r\n				NetBSD mbr
+# NT Drive Serial Number http://thestarman.pcministry.com/asm/mbr/Win2kmbr.htm#DS
+>>>0x1B8	ubelong		>0					\b,Serial 0x%-.8x
+# BOOTSEL definitions contains assembler instructions: int 0x13;pop dx;push dx;push dx
+>>>0xbb		search/71	\xcd\x13\x5a\x52\x52			\b,bootselector
+# BOOT_EXTENDED definitions contains assembler instructions: 
+# xchg ecx,edx;addl ecx,edx;movw lba_info,si;movb 0x42,ah;pop dx;push dx;int 0x13
+>>>0x96	search/1	\x66\x87\xca\x66\x01\xca\x66\x89\x16\x3a\x07\xbe\x32\x07\xb4\x42\x5a\x52\xcd\x13	\b,boot extended
+# COM_PORT_VAL definitions contains assembler instructions: outb al,dx;add 5,dl;inb %dx;test 0x40,al
+>>>0x130	search/55	\xee\x80\xc2\x05\xec\xa8\x40		\b,serial IO
+# not TERSE_ERROR
+>>>196		search/106	No\ active\ partition\0			
+>>>>&0		string		Disk\ read\ error\0			
+>>>>>&0		string		No\ operating\ system\0			\b,verbose
+# not NO_CHS definitions contains assembler instructions: pop dx;push dx;movb $8,ah;int0x13
+>>>0x7d		search/7	\x5a\x52\xb4\x08\xcd\x13		\b,CHS
+# not NO_LBA_CHECK definitions contains assembler instructions: movw 0x55aa,bx;movb 0x41,ah;pop	dx;push	dx;int 0x13
+>>>0xa4		search/84	\xbb\xaa\x55\xb4\x41\x5a\x52\xcd\x13	\b,LBA-check
+# assembler instructions: movw nametab,bx
+>>>0x26	    search/21	\xBB\x94\x07					
+# not NO_BANNER definitions contains assembler instructions: mov banner,si;call message_crlf
+>>>>&-9	ubequad&0xBE00f0E800febb94	0xBE0000E80000bb94		
+>>>>>181	search/166		Error\ \0			
+# "a: disk" , "Fn: diskn" or "NetBSD MBR boot"
+>>>>>>&3	string			x				\b,"%s"
+# Andrea Mazzoleni AdvanceCD mbr loader of http://advancemame.sourceforge.net/boot-readme.html
+# added by Joerg Jenderek at Nov 2012 for versions 1.3 - 1.4
+# assembler instructions: jmp short 0x58;nop;ASCII
+0	ubequad&0xeb58908000000000	0xeb58900000000000	
+# assembler instructions: cli;xor ax,ax;mov ds,ax;mov es,ax;mov ss,
+>(1.b+2)	ubequad			0xfa31c08ed88ec08e	
+# Error messages at end of code
+>>376		string	No\ operating\ system\r\n\0		
+>>>398		string	Disk\ error\r\n\0FDD\0HDD\0		
+>>>>419		string	\ EBIOS\r\n\0				AdvanceMAME mbr
+
+# Neil Turton mbr loader variant of http://www.chiark.greenend.org.uk/~neilt/mbr/ 
+# added by Joerg Jenderek at Mar 2011 for versions 1.0.0 - 1.1.11
+# for 1st version assembler instructions:	cld;xor ax,ax;mov DS,ax;MOV ES,AX;mov SI,
+# or  	  	  	    			cld;xor ax,ax;mov SS,ax;XOR SP,SP;mov DS,
+0	ulequad&0xcE1b40D48EC031FC	0x8E0000D08EC031FC	
+# pointer to the data starting with Neil Turton signature string
+>(0x1BC.s)		string		NDTmbr			
+>>&-14			string		1234F\0			Turton mbr (
+# parameters also viewed by install-mbr --list
+>>>(0x1BC.s+7)		ubyte		x			\b%u<=
+>>>(0x1BC.s+9)		ubyte		x			\bVersion<=%u
+#>>>(0x1BC.s+8)		ubyte		x			asm_flag_%x
+>>>(0x1BC.s+8)		ubyte&1		1			\b,Y2K-Fix
+# variant used by testdisk of http://www.cgsecurity.org/wiki/Menu_MBRCode
+>>>(0x1BC.s+8)		ubyte&2		2			\b,TestDisk
+#0x1~1,..,0x8~4,0x10~F,0x80~A enabled
+#>>>(0x1BC.s+10)		ubyte		x			\b,flags 0x%x
+#0x0~1,0x1~2,...,0x3~4,0x4~F,0x7~D default boot
+#>>>(0x1BC.s+11)		ubyte		x			\b,cfg_def 0x%x
+# for older versions
+>>>(0x1BC.s+9)		ubyte		<2			
+#>>>>(0x1BC.s+12)	ubyte		18			\b,%u/18 seconds
+>>>>(0x1BC.s+12)	ubyte		!18			\b,%u/18 seconds
+# floppy A: or B:
+>>>>(0x1BC.s+13)	ubyte		<2			\b,floppy 0x%x
+>>>>(0x1BC.s+13)	ubyte		>1			
+# 1st hard disc
+#>>>>>(0x1BC.s+13)	ubyte		0x80			\b,drive 0x%x
+# not 1st hard disc
+>>>>>(0x1BC.s+13)	ubyte		!0x80			\b,drive 0x%x
+# for version >= 2 maximal timeout can be 65534
+>>>(0x1BC.s+9)		ubyte		>1			
+#>>>>(0x1BC.s+12)	uleshort	18			\b,%u/18 seconds
+>>>>(0x1BC.s+12)	uleshort	!18			\b,%u/18 seconds
+# floppy A: or B:
+>>>>(0x1BC.s+14)	ubyte		<2			\b,floppy 0x%x
+>>>>(0x1BC.s+14)	ubyte		>1			
+# 1st hard disc
+#>>>>>(0x1BC.s+14)	ubyte		0x80			\b,drive 0x%x
+# not 1st hard disc
+>>>>>(0x1BC.s+14)	ubyte		!0x80			\b,drive 0x%x
+>>>0	ubyte		x					\b)
 
 # added by Joerg Jenderek
 # In the second sector (+0x200) are variables according to grub-0.97/stage2/asm.S or
@@ -995,6 +1024,168 @@
 >>>>>0x217 	ulong		!0xffffffff	
 >>>>>>0x217 	string		>\0		\b, configuration file %-s
 
+# DOS x86 sector updated and separated from "x86 boot sector" by Joerg Jenderek at May 2011
+# JuMP short     bootcodeoffset NOP assembler instructions will usually be EB xx 90
+# over BIOS parameter block (BPB)
+# http://thestarman.pcministry.com/asm/2bytejumps.htm#FWD
+# older drives may use Near JuMP instruction E9 xx xx
+# minimal short forward jump found 0x29 for bootloaders or 0x0
+# maximal short forward jump is 0x7f
+# OEM-ID is empty or contain readable bytes
+0		ulelong&0x804000E9	0x000000E9	
+# mtools-3.9.8/msdos.h
+# usual values are marked with comments to get only informations of strange FAT systems
+# valid sectorsize must be a power of 2 from 32 to 32768
+>11		uleshort&0xf001f	0	
+>>11		uleshort	<32769		
+>>>11		uleshort	>31		
+>>>>21		ubyte&0xf0	0xF0		
+>>>>>0		ubyte		0xEB		
+>>>>>>1		ubyte		x		\b, code offset 0x%x+2
+>>>>>0		ubyte		0xE9		
+>>>>>>1		uleshort	x		\b, code offset 0x%x+2
+>>>>>3		string		>\0		\b, OEM-ID "%-.8s"
+#http://mirror.href.com/thestarman/asm/debug/debug2.htm#IHC
+>>>>>>8		string		IHC		\b cached by Windows 9M
+>>>>>11		uleshort	>512		\b, Bytes/sector %u
+#>>>>>11	uleshort	=512		\b, Bytes/sector %u=512 (usual)
+>>>>>11		uleshort	<512		\b, Bytes/sector %u
+>>>>>13		ubyte		>1		\b, sectors/cluster %u
+#>>>>>13	ubyte		=1		\b, sectors/cluster %u (usual on Floppies)
+>>>>>82		string		FAT32		
+>>>>>>14	uleshort	!32		\b, reserved sectors %u
+#>>>>>>14	uleshort	=32		\b, reserved sectors %u (usual Fat32)
+>>>>>82		string		!FAT32		
+>>>>>>14	uleshort	>1		\b, reserved sectors %u
+#>>>>>>14	uleshort	=1		\b, reserved sectors %u (usual FAT12,FAT16)
+#>>>>>>14	uleshort	0		\b, reserved sectors %u (usual NTFS)
+>>>>>16		ubyte		>2		\b, FATs %u
+#>>>>>16	ubyte		=2		\b, FATs %u (usual)
+>>>>>16		ubyte		=1		\b, FAT  %u
+>>>>>16		ubyte		>0
+>>>>>17		uleshort	>0		\b, root entries %u
+#>>>>>17	uleshort	=0		\b, root entries %u=0 (usual Fat32)
+>>>>>19		uleshort	>0		\b, sectors %u (volumes <=32 MB) 
+#>>>>>19	uleshort	=0		\b, sectors %u=0 (usual Fat32)
+>>>>>21		ubyte		>0xF0		\b, Media descriptor 0x%x
+#>>>>>21	ubyte		=0xF0		\b, Media descriptor 0x%x (usual floppy)
+>>>>>21		ubyte		<0xF0		\b, Media descriptor 0x%x
+>>>>>22		uleshort	>0		\b, sectors/FAT %u
+#>>>>>22	uleshort	=0		\b, sectors/FAT %u=0 (usual Fat32)
+>>>>>24		uleshort	x		\b, sectors/track %u
+>>>>>26		ubyte		>2		\b, heads %u
+#>>>>>26	ubyte		=2		\b, heads %u (usual floppy)
+>>>>>26		ubyte		=1		\b, heads %u
+# valid only for sector sizes with more then 32 Bytes
+>>>>>11		uleshort	>32		
+# skip for Digital Research DOS (version 3.41) 1440 kB Bootdisk
+>>>>>>38	ubyte		!0x70		
+>>>>>>>28	ulelong		>0		\b, hidden sectors %u
+#>>>>>>>28	ulelong		=0		\b, hidden sectors %u (usual floppy)
+>>>>>>>32	ulelong		>0		\b, sectors %u (volumes > 32 MB) 
+#>>>>>>>32	ulelong		=0		\b, sectors %u (volumes > 32 MB)
+# FAT<32 bit specific 
+>>>>>>>82	string		!FAT32
+#>>>>>>>>36	ubyte		0x80		\b, physical drive 0x%x=0x80 (usual harddisk)
+#>>>>>>>>36	ubyte		0		\b, physical drive 0x%x=0 (usual floppy)
+>>>>>>>>36	ubyte		!0x80		
+>>>>>>>>>36	ubyte		!0		\b, physical drive 0x%x
+>>>>>>>>37	ubyte		>0		\b, reserved 0x%x
+#>>>>>>>>37	ubyte		=0		\b, reserved 0x%x
+# value is 0x80 for NTFS
+>>>>>>>>38	ubyte		!0x29		\b, dos < 4.0 BootSector (0x%x)
+>>>>>>>>38	ubyte		=0x29
+>>>>>>>>>39	ulelong		x		\b, serial number 0x%x
+>>>>>>>>>43	string		<NO\ NAME	\b, label: "%11.11s"
+>>>>>>>>>43	string		>NO\ NAME	\b, label: "%11.11s"
+>>>>>>>>>43	string		=NO\ NAME	\b, unlabeled
+# there exist some old floppies without word FAT at offset 54
+# a word like "FATnm   " is only a hint for a FAT size on nm-bits
+# Normally the number of clusters is calculated by the values of BPP.
+# if it is small enough FAT is 12 bit, if it is too big enough FAT is 32 bit,
+# otherwise FAT is 16 bit.
+# http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-fat-widths.html
+>>>>>>54	string		FAT		\b, FAT
+>>>>>>>54	string		FAT12		\b (12 bit)
+>>>>>>>54	string		FAT16		\b (16 bit)
+# FAT32 bit specific
+>>>>>82		string		FAT32		\b, FAT (32 bit)
+>>>>>>36	ulelong		x		\b, sectors/FAT %u
+# http://technet.microsoft.com/en-us/library/cc977221.aspx
+>>>>>>40	uleshort	>0		\b, extension flags 0x%x
+#>>>>>>40	uleshort	=0		\b, extension flags %u
+>>>>>>42	uleshort	>0		\b, fsVersion %u
+#>>>>>>42	uleshort	=0		\b, fsVersion %u (usual)
+>>>>>>44	ulelong		>2		\b, rootdir cluster %u
+#>>>>>>44	ulelong		=2		\b, rootdir cluster %u
+#>>>>>>44	ulelong		=1		\b, rootdir cluster %u
+>>>>>>48	uleshort	>1		\b, infoSector %u
+#>>>>>>48	uleshort	=1		\b, infoSector %u (usual)
+>>>>>>48	uleshort	<1		\b, infoSector %u
+>>>>>>50	uleshort	>6		\b, Backup boot sector %u
+#>>>>>>50	uleshort	=6		\b, Backup boot sector %u (usual) 
+>>>>>>50	uleshort	<6		\b, Backup boot sector %u
+# corrected by Joerg Jenderek at Feb 2011 according to http://thestarman.pcministry.com/asm/mbr/MSWIN41.htm#FSINFO
+>>>>>>52	ulelong		>0		\b, reserved1 0x%x
+>>>>>>56	ulelong		>0		\b, reserved2 0x%x
+>>>>>>60	ulelong		>0		\b, reserved3 0x%x
+# same structure as FAT1X 
+#>>>>>>64	ubyte		=0x80		\b, physical drive 0x%x=80 (usual harddisk)
+#>>>>>>64	ubyte		=0		\b, physical drive 0x%x=0 (usual floppy)
+>>>>>>64	ubyte		!0x80		
+>>>>>>>64	ubyte		>0		\b, physical drive 0x%x
+# in Windows NT bit 0 is a dirty flag to request chkdsk at boot time. bit 1 requests surface scan too
+>>>>>>65	ubyte		>0		\b, reserved 0x%x
+>>>>>>66	ubyte		!0x29		\b, dos < 4.0 BootSector (0x%x)
+>>>>>>66	ubyte		=0x29
+>>>>>>>67	ulelong		x		\b, serial number 0x%x
+>>>>>>>71	string		<NO\ NAME	\b, label: "%11.11s"
+>>>>>>>71	string		>NO\ NAME	\b, label: "%11.11s"
+>>>>>>>71	string		=NO\ NAME	\b, unlabeled
+# additional tests for floppy image added by Joerg Jenderek
+# no fixed disk 
+>>>>>21		ubyte		!0xF8		
+# floppy media with 12 bit FAT
+>>>>>>54	string		!FAT16		
+# test for FAT after bootsector
+>>>>>>>(11.s)	ulelong&0x00ffffF0	0x00ffffF0	\b, followed by FAT
+# floppy image
+!:mime application/x-ima
+# NTFS specific added by Joerg Jenderek at Mar 2011 according to http://thestarman.pcministry.com/asm/mbr/NTFSBR.htm
+# and http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/bios-parameter-block.html
+# 0 FATs
+>>>>>16	ubyte		=0		
+# 0 root entries
+>>>>>>17	uleshort	=0		
+# 0 DOS sectors
+>>>>>>>19	uleshort	=0		
+# 0 sectors/FAT
+# dos < 4.0 BootSector value found is 0x80
+#38	ubyte		=0x80			\b, dos < 4.0 BootSector (0x%x)
+>>>>>>>>22	uleshort	=0		\b; NTFS
+>>>>>>>>>24	uleshort	>0		\b, sectors/track %u
+>>>>>>>>>36	ulelong		!0x800080	\b, physical drive 0x%x
+>>>>>>>>>40	ulequad		>0		\b, sectors %lld
+>>>>>>>>>48	ulequad		>0		\b, $MFT start cluster %lld
+>>>>>>>>>56	ulequad		>0		\b, $MFTMirror start cluster %lld
+# Values 0 to 127 represent MFT record sizes of 0 to 127 clusters.
+# Values 128 to 255 represent MFT record sizes of 2^(256-N) bytes. 
+>>>>>>>>>64	lelong		<256		
+>>>>>>>>>>64	lelong		<128		\b, clusters/RecordSegment %d
+>>>>>>>>>>64	ubyte		>127		\b, bytes/RecordSegment 2^(-1*%hhi)
+# Values 0 to 127 represent index block sizes of 0 to 127 clusters.
+# Values 128 to 255 represent index block sizes of 2^(256-N) byte
+>>>>>>>>>68	ulelong		<256		
+>>>>>>>>>>68	ulelong		<128		\b, clusters/index block %d
+#>>>>>>>>>>68	ulelong		>127		\b, bytes/index block 2^(256-%d)
+>>>>>>>>>>68	ubyte		>127		\b, bytes/index block 2^(-1*%hhi)
+>>>>>>>>>72	ulequad		x		\b, serial number 0%llx
+>>>>>>>>>80	ulelong		>0		\b, checksum 0x%x
+#>>>>>>>>>80	ulelong		=0		\b, checksum 0x%x=0 (usual)
+>>>>>>>>>0x258	ulelong&0x00009090	=0x00009090	
+>>>>>>>>>>&-92		indirect	x	\b; contains 
+### DOS boot sector end
+
 9564	lelong		0x00011954	Unix Fast File system [v1] (little-endian),
 >8404	string		x		last mounted on %s,
 #>9504	ledate		x		last checked at %s,
@@ -1157,6 +1348,43 @@
 #>0x464	lelong          &0x0000020      (many subdirs)
 #>0x463	lelong          &0x0000040      (extra isize)
 
+# Minix filesystems - Juan Cespedes <cespedes@debian.org>
+0x410	leshort		0x137f
+!:strength / 2
+>0x402	beshort		< 100		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
+>0x1e	string		minix		\b, bootable
+0x410	leshort		0x138f
+!:strength / 2
+>0x402	beshort		< 100		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
+>0x1e	string		minix		\b, bootable
+0x410	leshort		0x2468
+>0x402	beshort		< 100		Minix filesystem, V2, %d zones
+>0x1e	string		minix		\b, bootable
+0x410	beshort		0x2468
+>0x402	beshort		< 100		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
+>0x1e	string		minix		\b, bootable
+0x410	leshort		0x2478
+>0x402	beshort		< 100		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
+>0x1e	string		minix		\b, bootable
+0x410	leshort		0x4d5a
+>0x402	beshort		!0		Minix filesystem, V3, %d zones
+>0x1e	string		minix		\b, bootable
+
 # SGI disk labels - Nathan Scott <nathans@debian.org>
 0	belong		0x0BE5A941	SGI disk label (volume header)
 
@@ -1243,7 +1471,7 @@
 >>38917	byte     >0x33      (unknown version, ID 0x%X)
 >>38917	byte     <0x31      (unknown version, ID 0x%X)
 # "application id" which appears to be used as a volume label
->32808	string    >\0       '%s'
+>32808	string/T  >\0       '%s'
 >34816	string    \000CD001\001EL\ TORITO\ SPECIFICATION    (bootable)
 37633	string    CD001     ISO 9660 CD-ROM filesystem data (raw 2352 byte sectors)
 !:mime	application/x-iso9660-image
@@ -1569,3 +1797,26 @@
 >>&8	lelong	x	\b, blocksize %d
 >>&32	lelong&0x00000006	>0	(dirty)
 >>&36	lelong	>0	(compressed)
+
+# LFS
+0	lelong	0x070162	LFS filesystem image
+>4	lelong	1		version 1,
+>>8	lelong	x		\b blocks %u,
+>>12	lelong	x		\b blocks per segment %u,
+>4	lelong	2		version 2,
+>>8	lelong	x		\b fragments %u,
+>>12	lelong	x		\b bytes per segment %u,
+>16	lelong	x		\b disk blocks %u,
+>20	lelong	x		\b block size %u,
+>24	lelong	x		\b fragment size %u,
+>28	lelong	x		\b fragments per block %u,
+>32	lelong	x		\b start for free list %u,
+>36	lelong	x		\b number of free blocks %d,
+>40	lelong	x		\b number of files %u,
+>44	lelong	x		\b blocks available for writing %d,
+>48	lelong	x		\b inodes in cache %d,
+>52	lelong	x		\b inode file disk address 0x%x,
+>56	lelong	x		\b inode file inode number %u,
+>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

+ 9 - 1
magic/Magdir/fonts

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: fonts,v 1.23 2010/09/20 18:55:20 rrt Exp $
+# $File: fonts,v 1.24 2012/08/26 10:32:10 christos Exp $
 # fonts:  file(1) magic for font data
 #
 0	search/1	FONT		ASCII vfont text
@@ -83,3 +83,11 @@
 # EOT
 34	string		LP		Embedded OpenType (EOT)
 !:mime application/vnd.ms-fontobject
+
+# Web Open Font Format (.woff)
+# http://www.w3.org/TR/WOFF/
+0	string		wOFF	Web Open Font Format
+>4	belong		x	\b, flavor %d
+>8	belong		x	\b, length %d
+>20	beshort		x	\b, version %hd
+>22	beshort		x	\b.%hd

+ 2 - 1
magic/Magdir/fortran

@@ -1,6 +1,7 @@
 
 #------------------------------------------------------------------------------
-# $File: fortran,v 1.6 2009/09/19 16:28:09 christos Exp $
+# $File: fortran,v 1.7 2012/06/21 01:55:02 christos Exp $
 # FORTRAN source
 0	regex/100	\^[Cc][\ \t]	FORTRAN program
 !:mime	text/x-fortran
+!:strength - 5

+ 13 - 1
magic/Magdir/geo

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: geo,v 1.1 2010/02/23 23:40:07 christos Exp $
+# $File: geo,v 1.3 2013/01/04 00:47:02 christos Exp $
 # Geo- files from Kurt Schwehr <schwehr@ccom.unh.edu>
 
 ######################################################################
@@ -103,3 +103,15 @@
 
 # https://midas.psi.ch/elog/
 0	string	$@MID@$	elog journal entry
+
+# Geospatial Designs http://www.geospatialdesigns.com/surfer6_format.htm
+0	string		DSBB	Surfer 6 binary grid file
+>4	leshort		x	\b, %d
+>6	leshort		x	\bx%d
+>8	ledouble	x	\b, minx=%g
+>16	ledouble	x	\b, maxx=%g
+>24	ledouble	x	\b, miny=%g
+>32	ledouble	x	\b, maxy=%g
+>40	ledouble	x	\b, minz=%g
+>48	ledouble	x	\b, maxz=%g
+

+ 2 - 2
magic/Magdir/gnome-keyring

@@ -1,13 +1,13 @@
 
 #------------------------------------------------------------------------------
-# $File: gnome-keyring,v 1.2 2009/09/19 16:28:09 christos Exp $
+# $File: gnome-keyring,v 1.3 2012/06/21 01:19:51 christos Exp $
 # GNOME keyring
 # Contributed by Josh Triplett
 # FIXME: Could be simplified if pstring supported two-byte counts
 0         string   GnomeKeyring\n\r\0\n GNOME keyring
 >&0       ubyte    0                    \b, major version 0
 >>&0      ubyte    0                    \b, minor version 0
->>>&0     ubyte    0                    \b, crypto type 0 (AEL)
+>>>&0     ubyte    0                    \b, crypto type 0 (AES)
 >>>&0     ubyte    >0                   \b, crypto type %hhu (unknown)
 >>>&1     ubyte    0                    \b, hash type 0 (MD5)
 >>>&1     ubyte    >0                   \b, hash type %hhu (unknown)

+ 16 - 1
magic/Magdir/gnu

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: gnu,v 1.13 2012/01/03 17:16:54 christos Exp $
+# $File: gnu,v 1.14 2012/10/03 23:38:12 christos Exp $
 # gnu:  file(1) magic for various GNU tools
 #
 # GNU nlsutils message catalog file format
@@ -37,6 +37,21 @@
 0       beshort         0x9901                  GPG key public ring
 !:mime	application/x-gnupg-keyring
 
+# Symmetric encryption
+0	leshort		0x0d8c
+>4	leshort		0x0203
+>>2	leshort		0x0204		GPG symmetrically encrypted data (3DES cipher)
+>>2	leshort		0x0304		GPG symmetrically encrypted data (CAST5 cipher)
+>>2	leshort		0x0404		GPG symmetrically encrypted data (BLOWFISH cipher)
+>>2	leshort		0x0704		GPG symmetrically encrypted data (AES cipher)
+>>2	leshort		0x0804		GPG symmetrically encrypted data (AES192 cipher)
+>>2	leshort		0x0904		GPG symmetrically encrypted data (AES256 cipher)
+>>2	leshort		0x0a04		GPG symmetrically encrypted data (TWOFISH cipher)
+>>2	leshort		0x0b04		GPG symmetrically encrypted data (CAMELLIA128 cipher)
+>>2	leshort		0x0c04		GPG symmetrically encrypted data (CAMELLIA192 cipher)
+>>2	leshort		0x0d04		GPG symmetrically encrypted data (CAMELLIA256 cipher)
+
+
 # Gnumeric spreadsheet
 # This entry is only semi-helpful, as Gnumeric compresses its files, so
 # they will ordinarily reported as "compressed", but at least -z helps

+ 8 - 1
magic/Magdir/ibm6000

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: ibm6000,v 1.9 2009/09/19 16:28:09 christos Exp $
+# $File: ibm6000,v 1.10 2012/08/10 15:06:07 christos Exp $
 # ibm6000:  file(1) magic for RS/6000 and the RT PC.
 #
 0	beshort		0x01df		executable (RISC System/6000 V3.1) or obj module
@@ -18,3 +18,10 @@
 0	string		\<aiaff>	archive
 0	string		\<bigaf>	archive (big format)
 
+0	beshort		0x01f7		64-bit XCOFF executable or object module
+>20	belong		0		not stripped
+4	belong		&0x0feeddb0	AIX core file
+>7	byte		&0x01		32-bit
+>>0x6e0 string		>\0		\b, %s
+>7	byte		&0x02		64-bit
+>>0x524 string		>\0		\b, %s

+ 116 - 22
magic/Magdir/images

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: images,v 1.72 2011/12/08 12:12:46 rrt Exp $
+# $File: images,v 1.79 2012/12/18 17:28:44 christos Exp $
 # images:  file(1) magic for image formats (see also "iff", and "c-lang" for
 # XPM bitmaps)
 #
@@ -32,17 +32,42 @@
 
 # PBMPLUS images
 # The next byte following the magic is always whitespace.
-0	search/1	P1		Netpbm PBM image text
+# strength is changed to try these patterns before "x86 boot sector"
+0	search/1	P1		
+>3	regex		=[0-9]*\ [0-9]*		Netpbm PBM image text
+>3	regex		=[0-9]+\ 		\b, size = %sx
+>>3	regex		=\ [0-9]+	\b%s
+!:strength + 45
 !:mime	image/x-portable-bitmap
-0	search/1b	P2		Netpbm PGM image text
+0	search/1	P2		
+>3	regex		=[0-9]*\ [0-9]*		Netpbm PGM image text
+>3	regex		=[0-9]+\ 		\b, size = %sx
+>>3	regex		=\ [0-9]+	\b%s
+!:strength + 45
 !:mime	image/x-portable-greymap
 0	search/1	P3		Netpbm PPM image text
+>3	regex		=[0-9]*\ [0-9]*		Netpbm PPM image text
+>3	regex		=[0-9]+\ 		\b, size = %sx
+>>3	regex		=\ [0-9]+	\b%s
+!:strength + 45
 !:mime	image/x-portable-pixmap
-0	string		P4		Netpbm PBM "rawbits" image data
+0	string		P4		
+>3	regex		=[0-9]*\ [0-9]*		Netpbm PBM "rawbits" image data
+>3	regex		=[0-9]+\ 		\b, size = %sx
+>>3	regex		=\ [0-9]+	\b%s
+!:strength + 45
 !:mime	image/x-portable-bitmap
-0	string		P5		Netpbm PGM "rawbits" image data
+0	string		P5		
+>3	regex		=[0-9]*\ [0-9]*		Netpbm PGM "rawbits" image data
+>3	regex		=[0-9]+\ 		\b, size = %sx
+>>3	regex		=\ [0-9]+	\b%s
+!:strength + 45
 !:mime	image/x-portable-greymap
-0	string		P6		Netpbm PPM "rawbits" image data
+0	string		P6		
+>3	regex		=[0-9]*\ [0-9]*		Netpbm PPM "rawbits" image data
+>3	regex		=[0-9]+\ 		\b, size = %sx
+>>3	regex		=\ [0-9]+	\b%s
+!:strength + 45
 !:mime	image/x-portable-pixmap
 0	string		P7		Netpbm PAM image file
 !:mime	image/x-portable-pixmap
@@ -203,6 +228,32 @@
 # From: Herbert Rosmanith <herp@wildsau.idv.uni.linz.at>
 0	string		Sfff		structured fax file
 
+# From: Joerg Jenderek <joerg.jen.der.ek@gmx.net>
+# most files with the extension .EPA and some with .BMP
+0	string		\x11\x06	Award BIOS Logo, 136 x 84
+!:mime	image/x-award-bioslogo
+0	string		\x11\x09	Award BIOS Logo, 136 x 126
+!:mime	image/x-award-bioslogo
+#0	string		\x07\x1f	BIOS Logo corrupted?
+# http://www.blackfiveservices.co.uk/awbmtools.shtml
+# http://biosgfx.narod.ru/v3/
+# http://biosgfx.narod.ru/abr-2/
+0	string		AWBM		
+>4	leshort		<1981		Award BIOS bitmap
+!:mime	image/x-award-bmp
+# image width is a multiple of 4
+>>4	leshort&0x0003	0		
+>>>4		leshort	x		\b, %d
+>>>6		leshort	x		x %d
+>>4	leshort&0x0003	>0		\b,
+>>>4	leshort&0x0003	=1		
+>>>>4		leshort	x		%d+3
+>>>4	leshort&0x0003	=2		
+>>>>4		leshort	x		%d+2
+>>>4	leshort&0x0003	=3		
+>>>>4		leshort	x		%d+1
+>>>6		leshort	x		x %d
+# at offset 8 starts imagedata followed by "RGB " marker
 
 # PC bitmaps (OS/2, Windows BMP files)  (Greg Roelofs, newt@uchicago.edu)
 0	string		BM
@@ -401,16 +452,6 @@
 #>12	beshort	3		RP175
 #>12	beshort	4		YUV
 
-#------------------------------------------------------------------------------
-#
-# Marco Schmidt (marcoschmidt@users.sourceforge.net) -- an image  file format
-# for the EPOC operating system, which is used with PDAs like those from Psion
-#
-# see http://huizen.dds.nl/~frodol/psiconv/html/Index.html for a description
-# of various EPOC file formats
-
-0	string \x37\x00\x00\x10\x42\x00\x00\x10\x00\x00\x00\x00\x39\x64\x39\x47 EPOC MBM image file
-
 # PCX image files
 # From: Dan Fandrich <dan@coneharvesters.com>
 0	beshort		0x0a00	PCX ver. 2.5 image data
@@ -615,9 +656,61 @@
 >12	string	THUM		DjVu page thumbnails
 !:mime	image/vnd.djvu
 
-
-# From Marc Espie
-0	lelong	20000630		OpenEXR image data
+# Originally by Marc Espie
+# Modified by Robert Minsk <robertminsk at yahoo.com>
+# http://www.openexr.com/openexrfilelayout.pdf
+0	lelong		20000630	OpenEXR image data,
+!:mime image/x-exr
+>4	lelong&0x000000ff x		version %d,
+>4	lelong		^0x00000200	storage: scanline
+>4	lelong		&0x00000200	storage: tiled
+>8	search/0x1000	compression\0	\b, compression:
+>>&16	byte		0		none
+>>&16	byte		1		rle
+>>&16	byte		2		zips
+>>&16	byte		3		zip
+>>&16	byte		4		piz
+>>&16	byte		5		pxr24
+>>&16	byte		6		b44
+>>&16	byte		7		b44a
+>>&16	byte		>7		unknown
+>8	 search/0x1000	dataWindow\0	\b, dataWindow:
+>>&10	lelong		x		(%d
+>>&14	lelong		x		%d)-
+>>&18	lelong		x		\b(%d
+>>&22	lelong		x		%d)
+>8	search/0x1000	displayWindow\0	\b, displayWindow:
+>>&10	lelong		x		(%d
+>>&14	lelong		x		%d)-
+>>&18	lelong		x		\b(%d
+>>&22	lelong		x		%d)
+>8	search/0x1000	lineOrder\0	 \b, lineOrder:
+>>&14	byte		0		increasing y
+>>&14	byte		1		decreasing y
+>>&14	byte		2		random y
+>>&14	byte		>2		unknown
+
+# SMPTE Digital Picture Exchange Format, SMPTE DPX
+#
+# ANSI/SMPTE 268M-1994, SMPTE Standard for File Format for Digital
+# Moving-Picture Exchange (DPX), v1.0, 18 February 1994
+# Robert Minsk <robertminsk at yahoo.com>
+0	string		SDPX	DPX image data, big-endian,
+!:mime image/x-dpx
+>768	beshort		<4
+>>772	belong		x	%dx
+>>776	belong		x	\b%d,
+>768	beshort		>3
+>>776	belong		x	%dx
+>>772	belong		x	\b%d,
+>768	beshort		0	left to right/top to bottom
+>768	beshort		1	right to left/top to bottom
+>768	beshort		2	left to right/bottom to top
+>768	beshort		3	right to left/bottom to top
+>768	beshort		4	top to bottom/left to right
+>768	beshort		5	top to bottom/right to left
+>768	leshort		6	bottom to top/left to right
+>768	leshort		7	bottom to top/right to left
 
 # From: Tom Hilinski <tom.hilinski@comcast.net>
 # http://www.unidata.ucar.edu/packages/netcdf/
@@ -665,9 +758,10 @@
 # From Tano M Fotang <mfotang@quanteq.com>
 0	string	\xff\xa0\xff\xa8\x00	Wavelet Scalar Quantization image data
 
-# JPEG 2000 Code Stream Bitmap
-# From Petr Splichal <psplicha@redhat.com>
-0	string	\xFF\x4F\xFF\x51\x00	JPEG-2000 Code Stream Bitmap data
+# Polar Monitor Bitmap (.pmb) used as logo for Polar Electro watches
+# From: Markus Heidelberg <markus.heidelberg at web.de>
+0	string/t	[BitmapInfo2]	Polar Monitor Bitmap text
+!:mime	image/x-polar-monitor-bitmap
 
 # From: Rick Richardson <rick.richardson@comcast.net>
 0	string	GARMIN\ BITMAP\ 01	Garmin Bitmap file

+ 17 - 0
magic/Magdir/javascript

@@ -0,0 +1,17 @@
+
+#------------------------------------------------------------------------------
+# $File: javascript,v 1.1 2012/06/16 13:30:36 christos Exp $
+# javascript:  magic for javascript and node.js scripts.
+#
+0	search/1/w	#!/bin/node		Node.js script text executable
+!:mime application/javascript
+0	search/1/w	#!/usr/bin/node		Node.js script text executable
+!:mime application/javascript
+0	search/1/w	#!/bin/nodejs		Node.js script text executable
+!:mime application/javascript
+0	search/1/w	#!/usr/bin/nodejs	Node.js script text executable
+!:mime application/javascript
+0	search/1	#!/usr/bin/env\ node	Node.js script text executable
+!:mime application/javascript
+0	search/1	#!/usr/bin/env\ nodejs	Node.js script text executable
+!:mime application/javascript

+ 15 - 2
magic/Magdir/jpeg

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: jpeg,v 1.16 2011/01/04 19:29:32 rrt Exp $
+# $File: jpeg,v 1.18 2012/08/01 12:12:36 christos Exp $
 # JPEG images
 # SunOS 5.5.1 had
 #
@@ -153,7 +153,20 @@
 0	string		hsi1		JPEG image data, HSI proprietary
 
 # From: David Santinoli <david@santinoli.com>
-0	string		\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A	JPEG 2000 image data
+0	string		\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A	JPEG 2000
+# From: Johan van der Knijff <johan.vanderknijff@kb.nl>
+# Added sub-entries for JP2, JPX, JPM and MJ2 formats; added mimetypes
+# https://github.com/bitsgalore/jp2kMagic
+#
+# Now read value of 'Brand' field, which yields a few possibilities:
+>20	string		\x6a\x70\x32\x20	Part 1 (JP2)
+!:mime	image/jp2
+>20	string		\x6a\x70\x78\x20	Part 2 (JPX)
+!:mime	image/jpx
+>20	string		\x6a\x70\x6d\x20	Part 6 (JPM)
+!:mime	image/jpm
+>20	string		\x6d\x6a\x70\x32	Part 3 (MJ2)
+!:mime	video/mj2
 
 # Type: JPEG 2000 codesream
 # From: Mathieu Malaterre <mathieu.malaterre@gmail.com>

+ 20 - 0
magic/Magdir/keepass

@@ -0,0 +1,20 @@
+
+#------------------------------------------------------------------------------
+# $File: keepass,v 1.1 2012/12/24 22:14:56 christos Exp $
+# keepass: file(1) magic for KeePass file
+#
+# Keepass Password Safe:
+#  * original one: http://keepass.info/
+#  * *nix port:    http://www.keepassx.org/
+#  * android port: http://code.google.com/p/keepassdroid/
+
+0	lelong		0x9AA2D903	Keepass password database
+>4	lelong		0xB54BFB65	1.x KDB
+>>48	lelong		>0		\b, %d groups
+>>52	lelong		>0		\b, %d entries
+>>8	lelong&0x0f	1		\b, SHA-256
+>>8	lelong&0x0f	2		\b, AES
+>>8	lelong&0x0f	4		\b, RC4
+>>8	lelong&0x0f	8		\b, Twofish
+>>120	lelong		>0		\b, %d key transformation rounds
+>4	lelong		0xB54BFB67	2.x KDBX

+ 8 - 3
magic/Magdir/linux

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: linux,v 1.42 2012/02/07 21:35:03 christos Exp $
+# $File: linux,v 1.45 2012/10/29 17:36:49 christos Exp $
 # linux:  file(1) magic for Linux files
 #
 # Values for Linux/i386 binaries, from Daniel Quinlan <quinlan@yggdrasil.com>
@@ -36,6 +36,8 @@
 >28	long		!0		not stripped
 0	string		\01\03\040\20	Minix-386 executable
 >28	long		!0		not stripped
+0	string		\01\03\04\20	Minix-386 NSYM/GNU executable
+>28	long		!0		not stripped
 # core dump file, from Bill Reynolds <bill@goshawk.lanl.gov>
 216	lelong		0421		Linux/i386 core file
 >220	string		>\0		of '%s'
@@ -88,6 +90,7 @@
 # From Daniel Novotny <dnovotny@redhat.com>
 # swap file for PowerPC
 65526	string		SWAPSPACE2	Linux/ppc swap file
+16374	string		SWAPSPACE2	Linux/ia64 swap file
 #
 # Linux kernel boot images, from Albert Cahalan <acahalan@cs.uml.edu>
 # and others such as Axel Kohlmeyer <akohlmey@rincewind.chemie.uni-ulm.de>
@@ -213,9 +216,11 @@
 # 0	lelong&0xFF00FFFF 0x17000301	ld86 SPARC executable
 
 # SYSLINUX boot logo files (from 'ppmtolss16' sources)
-# http://syslinux.zytor.com/
-#
+# http://www.syslinux.org/wiki/index.php/SYSLINUX#Display_graphic_from_filename:
+# file extension .lss .16
 0	lelong	=0x1413f33d		SYSLINUX' LSS16 image data
+# syslinux-4.05/mime/image/x-lss16.xml
+!:mime image/x-lss16
 >4	leshort	x			\b, width %d
 >6	leshort	x			\b, height %d
 

+ 112 - 65
magic/Magdir/mach

@@ -1,86 +1,133 @@
 
 #------------------------------------------------------------
-# $File: mach,v 1.9 2009/09/19 16:28:10 christos Exp $
+# $File: mach,v 1.12 2012/11/01 04:26:40 christos Exp $
 # Mach has two magic numbers, 0xcafebabe and 0xfeedface.
 # Unfortunately the first, cafebabe, is shared with
 # Java ByteCode, so they are both handled in the file "cafebabe".
 # The "feedface" ones are handled herein.
 #------------------------------------------------------------
-0	lelong&0xfffffffe	0xfeedface	Mach-O
+
+0	name		mach-o-bed
 >0	byte		0xcf		64-bit
->12	lelong		1		object
->12	lelong		2		executable
->12	lelong		3		fixed virtual memory shared library
->12	lelong		4		core
->12	lelong		5		preload executable
->12	lelong		6		dynamically linked shared library
->12	lelong		7		dynamic linker
->12	lelong		8		bundle
->12	lelong		9		dynamically linked shared library stub
->12	lelong		>9
->>12	lelong		x		filetype=%ld
->4	lelong		<0
->>4	lelong		x		architecture=%ld
->4	lelong		1		vax
->4	lelong		2		romp
->4	lelong		3		architecture=3
->4	lelong		4		ns32032
->4	lelong		5		ns32332
->4	lelong		6		m68k
->4	lelong		7		i386
->4	lelong		8		mips
->4	lelong		9		ns32532
->4	lelong		10		architecture=10
->4	lelong		11		hppa
->4	lelong		12		acorn
->4	lelong		13		m88k
->4	lelong		14		sparc
->4	lelong		15		i860-big
->4	lelong		16		i860
->4	lelong		17		rs6000
->4	lelong		18		ppc
->4	lelong		16777234	ppc64
->4	lelong		>16777234
->>4	lelong		x		architecture=%ld
-#
-0	belong&0xfffffffe	0xfeedface	Mach-O
->3	byte		0xcf		64-bit
->12	belong		1		object
->12	belong		2		executable
->12	belong		3		fixed virtual memory shared library
->12	belong		4		core
->12	belong		5		preload executable
->12	belong		6               dynamically linked shared library
->12	belong		7               dynamic linker
->12	belong		8		bundle
->12	belong		9		dynamically linked shared library stub
->12	belong		>9
->>12	belong		x		filetype=%ld
 >4	belong		<0
 >>4	belong		x		architecture=%ld
->4	belong		1		vax
+>4	belong		1
+>>8	belong		0		vax
+>>8	belong		1		vax11/780
+>>8	belong		2		vax11/785
+>>8	belong		3		vax11/750
+>>8	belong		4		vax11/730
+>>8	belong		5		uvaxI
+>>8	belong		6		uvaxII
+>>8	belong		7		vax8200
+>>8	belong		8		vax8500
+>>8	belong		9		vax8600
+>>8	belong		10		vax8650
+>>8	belong		11		vax8800
+>>8	belong		12		uvaxIII
 >4	belong		2		romp
 >4	belong		3		architecture=3
 >4	belong		4		ns32032
 >4	belong		5		ns32332
->4	belong		6		for m68k architecture
-# from NeXTstep 3.0 <mach/machine.h>
-# i.e. mc680x0_all, ignore
-# >>8	belong		1		(mc68030)
->>8	belong		2		(mc68040)
->>8	belong		3		(mc68030 only)
->4	belong		7		i386
+>4	belong		6		m68k
+>4	belong		7
+>>8	belong		3		i386
+>>8	belong		4		i486
+>>8	belong		132		i486sx
+>>8	belong		5		i586
+>>8	belong		8		pentium_3
+>>8	belong		9		pentiumM
+>>8	belong		10		pentiumIV
+>>8	belong		11		itanium
+>>8	belong		12		xeon
+>>8	belong		14		pentiumIV_M
+>>8	belong		15		itanium2
+>>8	belong		21		pentiumpro
+>>8	belong		23		pentiumIII
+>>8	belong		24		pentium_3_M
+>>8	belong		25		pentiumV
+>>8	belong		26		xeon_mp
+>>8	belong		40		pentium_3_xeon
+>>8	belong		113		celeron
+>>8	belong		119		celeron_mobile
 >4	belong		8		mips
+>>8	belong		1		R2300
+>>8	belong		2		R2600
+>>8	belong		3		R2800
+>>8	belong		4		R2000a
+>>8	belong		5		R2000
+>>8	belong		6		R3000a
+>>8	belong		7		R3000
 >4	belong		9		ns32532
->4	belong		10		architecture=10
+>4	belong		10		mc98000
 >4	belong		11		hppa
->4	belong		12		acorn
->4	belong		13		m88k
+>>8	belong		0		7100
+>>8	belong		1		7100LC
+>4	belong		12
+>>8	belong		0		arm
+>>8	belong		1		arm_v4t
+>>8	belong		2		arm_v6
+>>8	belong		3		arm_v5tej
+>>8	belong		4		arm_xscale
+>>8	belong		5		arm_v7
+>>8	belong		6		arm_v7f
+>>8	belong		7		arm_v7k
+>4	belong		13
+>>8	belong		0		mc88000
+>>8	belong		1		mc88100
+>>8	belong		2		mc88110
 >4	belong		14		sparc
->4	belong		15		i860-big
->4	belong		16		i860
+>4	belong		15		i860g
+>4	belong		16		alpha
 >4	belong		17		rs6000
->4	belong		18		ppc
->4	belong		16777234	ppc64
+>4	belong		18
+>>8	belong		0		ppc
+>>8	belong		1		ppc_601
+>>8	belong		2		ppc_602
+>>8	belong		3		ppc_603
+>>8	belong		4		ppc_603e
+>>8	belong		5		ppc_603ev
+>>8	belong		6		ppc_604
+>>8	belong		7		ppc_604e
+>>8	belong		8		ppc_620
+>>8	belong		9		ppc_650
+>>8	belong		10		ppc_7400
+>>8	belong		11		ppc_7450
+>>8	belong		100		ppc_970
+>4	belong		16777223
+>>8	belong		3		x86_64
+>>8	belong		4		x86_64_arch1
+>4	belong		16777234
+>>8	belong		0		ppc64
+>>8	belong		1		ppc64_601
+>>8	belong		2		ppc64_602
+>>8	belong		3		ppc64_603
+>>8	belong		4		ppc64_603e
+>>8	belong		5		ppc64_603ev
+>>8	belong		6		ppc64_604
+>>8	belong		7		ppc64_604e
+>>8	belong		8		ppc64_620
+>>8	belong		9		ppc64_650
+>>8	belong		10		ppc64_7400
+>>8	belong		11		ppc64_7450
+>>8	belong		100		ppc64_970
 >4	belong		>16777234
 >>4	belong		x		architecture=%ld
+>12	belong		1		object
+>12	belong		2		executable
+>12	belong		3		fixed virtual memory shared library
+>12	belong		4		core
+>12	belong		5		preload executable
+>12	belong		6		dynamically linked shared library
+>12	belong		7		dynamic linker
+>12	belong		8		bundle
+>12	belong		9		dynamically linked shared library stub
+>12	belong		>9
+>>12	belong		x		filetype=%ld
+
+#
+0	lelong&0xfffffffe	0xfeedface	Mach-O 
+>0	use	\^mach-o-be
+
+0	belong&0xfffffffe	0xfeedface	Mach-O 
+>0	use	mach-o-be

+ 7 - 0
magic/Magdir/macos

@@ -0,0 +1,7 @@
+
+#------------------------------------------------------------------------------
+# $File: macos,v 1.1 2012/12/21 16:41:07 christos Exp $
+# MacOS files
+#
+
+0	string		book\0\0\0\0mark\0\0\0\0	MacOS Alias file

+ 2 - 1
magic/Magdir/mail.news

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: mail.news,v 1.20 2011/12/08 12:12:46 rrt Exp $
+# $File: mail.news,v 1.21 2012/06/21 01:44:52 christos Exp $
 # mail.news:  file(1) magic for mail and news
 #
 # Unfortunately, saved netnews also has From line added in some news software.
@@ -34,6 +34,7 @@
 
 # TNEF files...
 0	lelong		0x223E9F78	Transport Neutral Encapsulation Format
+!:mime	application/vnd.ms-tnef
 
 # From: Kevin Sullivan <ksulliva@psc.edu>
 0	string		*mbx*		MBX mail folder

+ 4 - 10
magic/Magdir/matroska

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: matroska,v 1.6 2010/09/20 21:11:35 rrt Exp $
+# $File: matroska,v 1.7 2012/08/26 10:06:15 christos Exp $
 # matroska:  file(1) magic for Matroska files
 #
 # See http://www.matroska.org/
@@ -9,15 +9,9 @@
 # EBML id:
 0		belong		0x1a45dfa3
 # DocType id:
->5		beshort		0x4282
-# DocType contents:
->>8		string		matroska	Matroska data
-!:mime  video/x-matroska
-
-# EBML id:
-0		belong		0x1a45dfa3
-# DocType id:
 >0		search/4096 	\x42\x82
 # DocType contents:
->>&1		string		webm	WebM
+>>&1		string		webm		WebM
 !:mime  video/webm
+>>&1		string		matroska	Matroska data
+!:mime  video/x-matroska

+ 41 - 2
magic/Magdir/msdos

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: msdos,v 1.77 2011/12/07 22:05:05 christos Exp $
+# $File: msdos,v 1.83 2012/11/13 14:55:44 christos Exp $
 # msdos:  file(1) magic for MS-DOS files
 #
 
@@ -83,6 +83,7 @@
 >>>(0x3c.l+4)	leshort		0x1a6	Hitachi SH4
 >>>(0x3c.l+4)	leshort		0x1c0	ARM
 >>>(0x3c.l+4)	leshort		0x1c2	ARM Thumb
+>>>(0x3c.l+4)	leshort		0x1c4	ARMv7 Thumb
 >>>(0x3c.l+4)	leshort		0x1f0	PowerPC
 >>>(0x3c.l+4)	leshort		0x200	Intel Itanium
 >>>(0x3c.l+4)	leshort		0x266	MIPS16
@@ -498,11 +499,18 @@
 !:mime	application/msword
 0	string/b	\333\245-\0\0\0			Microsoft Office Document
 !:mime	application/msword
-512	string/b		\354\245\301		Microsoft Word Document
+512	string/b	\354\245\301			Microsoft Word Document
 !:mime	application/msword
+
+#
+0	string/b	\xDB\xA5\x2D\x00		Microsoft WinWord 2.0 Document
+!:mime application/msword
 #
 2080	string	Microsoft\ Excel\ 5.0\ Worksheet	%s
 !:mime	application/vnd.ms-excel
+#
+0	string/b	\xDB\xA5\x2D\x00		Microsoft WinWord 2.0 Document
+!:mime application/msword
 
 2080	string	Foglio\ di\ lavoro\ Microsoft\ Exce	%s
 !:mime	application/vnd.ms-excel
@@ -702,6 +710,15 @@
 0	leshort		0x223e9f78	TNEF
 !:mime	application/vnd.ms-tnef
 
+# 4DOS help (.HLP) files added by Joerg Jenderek from source TPHELP.PAS 
+# of http://www.4dos.info/
+# pointer,HelpID[8]=4DHnnnmm
+0	ulelong	0x48443408		4DOS help file
+>4	string	x			\b, version %-4.4s
+
+# old binary Microsoft (.HLP) files added by Joerg Jenderek from http://file-extension.net/seeker/file_extension_hlp
+0	ulequad	0x3a000000024e4c	MS Advisor help file
+
 # HtmlHelp files (.chm)
 0	string/b	ITSF\003\000\000\000\x60\000\000\000\001\000\000\000	MS Windows HtmlHelp Data
 
@@ -815,6 +832,16 @@
 
 0	string/b	QEVM		QEMU suspend to disk image
 
+# QEMU QED Image
+# http://wiki.qemu.org/Features/QED/Specification
+0	string/b	QED\0		QEMU QED Image
+
+# VDI Image
+64	string/b	\x7f\x10\xda\xbe	VDI Image
+>68	string/b	\x01\x00\x01\x00	version 1.1
+>0	string		>\0			(%s)
+>368	lequad		x			 \b, %lld bytes
+
 0	string/b	Bochs\ Virtual\ HD\ Image	Bochs disk image,
 >32	string	x				type %s,
 >48	string	x				subtype %s
@@ -874,3 +901,15 @@
 
 # Windows Imaging (WIM) Image
 0	string/b	MSWIM\000\000\000	Windows imaging (WIM) image
+
+# The second byte of these signatures is a file version; I don't know what, 
+# if anything, produced files with version numbers 0-2.
+# From: John Elliott <johne@seasip.demon.co.uk>
+0	string	\xfc\x03\x00	Mallard BASIC program data (v1.11)
+0	string	\xfc\x04\x00	Mallard BASIC program data (v1.29+)
+0	string	\xfc\x03\x01	Mallard BASIC protected program data (v1.11)
+0	string	\xfc\x04\x01	Mallard BASIC protected program data (v1.29+)
+
+0	string	MIOPEN		Mallard BASIC Jetsam data
+0	string	Jetsam0		Mallard BASIC Jetsam index data
+

+ 6 - 3
magic/Magdir/perl

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: perl,v 1.17 2011/12/16 16:24:40 rrt Exp $
+# $File: perl,v 1.20 2012/06/21 01:16:49 christos Exp $
 # perl:  file(1) magic for Larry Wall's perl language.
 #
 # The `eval' lines recognizes an outrageously clever hack.
@@ -28,12 +28,12 @@
 # check the first line
 0	search/1	package
 >0	regex		\^package[\ \t]+[0-9A-Za-z_:]+\ *;	Perl5 module source text
+!:strength + 10
 # not 'p', check other lines
 0	search/1	!p
 >0	regex		\^package[\ \t]+[0-9A-Za-z_:]+\ *;
 >>0	regex		\^1\ *;|\^(use|sub|my)\ .*[(;{=]	Perl5 module source text
-
-
+!:strength + 10
 
 # Perl POD documents
 # From: Tom Hukins <tom@eborcom.com>
@@ -43,6 +43,9 @@
 0	search/1/W	\n\=head1\ 	Perl POD document text
 0	search/1/W	\=head2\ 	Perl POD document text
 0	search/1/W	\n\=head2\ 	Perl POD document text
+0	search/1/W	\=encoding\ 	Perl POD document text
+0	search/1/W	\n\=encoding\ 	Perl POD document text
+
 
 # Perl Storable data files.
 0	string	perl-store	perl Storable (v0.6) data

+ 14 - 0
magic/Magdir/pwsafe

@@ -0,0 +1,14 @@
+
+#------------------------------------------------------------------------------
+# $File: pwsafe,v 1.1 2012/10/25 00:12:19 christos Exp $
+# pwsafe: file(1) magic for passwordsafe file
+#
+# Password Safe
+# http://passwordsafe.sourceforge.net/
+# file format specs
+# http://passwordsafe.svn.sourceforge.net/viewvc/passwordsafe/trunk/pwsafe/pwsafe/docs/formatV3.txt
+# V2 http://passwordsafe.svn.sourceforge.net/viewvc/passwordsafe/trunk/pwsafe/pwsafe/docs/formatV2.txt
+# V1 http://passwordsafe.svn.sourceforge.net/viewvc/passwordsafe/trunk/pwsafe/pwsafe/docs/notes.txt
+# V2 and V1 have no easy identifier that I can find
+# .psafe3
+0	string	PWS3	Password Safe V3 database

+ 6 - 1
magic/Magdir/python

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: python,v 1.20 2011/12/13 13:53:14 christos Exp $
+# $File: python,v 1.21 2012/06/21 01:12:51 christos Exp $
 # python:  file(1) magic for python
 #
 # Outlook puts """ too for urgent messages
@@ -59,3 +59,8 @@
 !:mime text/x-python
 >&0	search/4096	finally:	Python script text executable
 !:mime text/x-python
+
+# def name(args, args):
+0	regex	 \^(\ |\\t)*def\ +[a-zA-Z]+
+>&0	regex	\ *\\(([a-zA-Z]|,|\ )*\\):$ Python script text executable
+!:mime text/x-python

+ 15 - 3
magic/Magdir/sgml

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: sgml,v 1.27 2011/12/07 12:01:24 rrt Exp $
+# $File: sgml,v 1.29 2012/08/26 10:25:41 christos Exp $
 # Type:	SVG Vectorial Graphics
 # From:	Noel Torres <tecnico@ejerciciosresueltos.com>
 0	string		\<?xml\ version="
@@ -36,35 +36,47 @@
 # adapted to string extenstions by Anthon van der Neut <anthon@mnt.org)
 0	search/4096/cWt	\<!doctype\ html	HTML document text
 !:mime	text/html
+!:strength + 5
 0	search/4096/cwt	\<head			HTML document text
 !:mime	text/html
+!:strength + 5
 0	search/4096/cwt	\<title			HTML document text
 !:mime	text/html
+!:strength + 5
 0	search/4096/cwt	\<html			HTML document text
 !:mime	text/html
+!:strength + 5
 0	search/4096/cwt	\<script 		HTML document text
 !:mime	text/html
+!:strength + 5
 0	search/4096/cwt	\<style 		HTML document text
 !:mime	text/html
+!:strength + 5
 0	search/4096/cwt	\<table			HTML document text
 !:mime	text/html
+!:strength + 5
 0	search/4096/cwt	\<a\ href=		HTML document text
 !:mime	text/html
+!:strength + 5
 
 # Extensible markup language (XML), a subset of SGML
 # from Marc Prud'hommeaux (marc@apocalypse.org)
 0	search/1/cwt	\<?xml			XML document text
 !:mime	application/xml
+!:strength + 5
 0	string/t		\<?xml\ version\ "	XML
 !:mime	application/xml
+!:strength + 5
 0	string/t		\<?xml\ version="	XML
 !:mime	application/xml
->15	search/1	>\0			%.3s document text
+!:strength + 5
+>15	string/t	>\0			%.3s document text
 >>23	search/1	\<xsl:stylesheet	(XSL stylesheet)
 >>24	search/1	\<xsl:stylesheet	(XSL stylesheet)
 0	string		\<?xml\ version='	XML
 !:mime	application/xml
->15	search/1	>\0			%.3s document text
+!:strength + 5
+>15	string/t	>\0			%.3s document text
 >>23	search/1	\<xsl:stylesheet	(XSL stylesheet)
 >>24	search/1	\<xsl:stylesheet	(XSL stylesheet)
 0	search/1/wbt	\<?xml			XML document text

+ 16 - 4
magic/Magdir/sql

@@ -1,22 +1,34 @@
 
 #------------------------------------------------------------------------------
-# $File: sql,v 1.6 2009/09/19 16:28:12 christos Exp $
+# $File: sql,v 1.8 2012/12/09 17:11:08 christos Exp $
 # sql:  file(1) magic for SQL files
 #
 # From: "Marty Leisner" <mleisner@eng.mc.xerox.com>
 # Recognize some MySQL files.
+# Elan Ruusamäe <glen@delfi.ee>, added MariaDB signatures
+# from https://bazaar.launchpad.net/~maria-captains/maria/5.5/view/head:/support-files/magic
 #
 0	beshort			0xfe01		MySQL table definition file
 >2	byte			x		Version %d
-0	belong&0xffffff00	0xfefe0300	MySQL MISAM index file
+0	belong&0xffffff00	0xfefe0700	MySQL MyISAM index file
 >3	byte			x		Version %d
-0	belong&0xffffff00	0xfefe0700	MySQL MISAM compressed data file
+0	belong&0xffffff00	0xfefe0800	MySQL MyISAM compressed data file
+>3	byte			x		Version %d
+0	belong&0xffffff00	0xfefe0900	MySQL Maria index file
+>3	byte			x		Version %d
+0	belong&0xffffff00	0xfefe0A00	MySQL Maria compressed data file
 >3	byte			x		Version %d
 0	belong&0xffffff00	0xfefe0500	MySQL ISAM index file
 >3	byte			x		Version %d
 0	belong&0xffffff00	0xfefe0600	MySQL ISAM compressed data file
 >3	byte			x		Version %d
-0	string		 	\376bin		MySQL replication log
+0	string			\376bin		MySQL replication log
+0	belong&0xffffff00	0xfefe0b00
+>4	string			MARIALOG	MySQL Maria transaction log file
+>>3	byte			x		Version %d
+0	belong&0xffffff00	0xfefe0c00
+>4	string			MACF		MySQL Maria control file
+>>3	byte			x		Version %d
 
 #------------------------------------------------------------------------------
 # iRiver H Series database file 

+ 16 - 0
magic/Magdir/uterus

@@ -0,0 +1,16 @@
+
+#------------------------------------------------------------------------------
+# $File: uterus,v 1.1 2012/12/18 18:53:32 christos Exp $
+# file(1) magic for uterus files
+# http://freecode.com/projects/uterus
+#
+0	string		UTE+	uterus file
+>4	string		v	\b, version
+>5	byte		x	%c
+>6	string		.	\b.
+>7	byte		x	\b%c
+>8	string		\<\>	\b, big-endian
+>>16	belong		>0	\b, slut size %u
+>8	string		\>\<	\b, litte-endian
+>>16	lelong		>0	\b, slut size %u
+>10	byte		&8	\b, compressed

+ 46 - 3
magic/Magdir/windows

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: windows,v 1.4 2009/09/19 16:28:13 christos Exp $
+# $File: windows,v 1.5 2012/04/03 22:25:07 christos Exp $
 # windows:  file(1) magic for Microsoft Windows
 #
 # This file is mainly reserved for files where programs
@@ -75,12 +75,55 @@
 0	string		HyperTerminal\ 
 >15	string		1.0\ --\ HyperTerminal\ data\ file	MS Windows HyperTerminal profile
 
-
+# http://ithreats.files.wordpress.com/2009/05/\
+# lnk_the_windows_shortcut_file_format.pdf
 # Summary: Windows shortcut
 # Extension: .lnk
 # Created by: unknown
+# 'L' + GUUID
 0	string		\114\0\0\0\001\024\002\0\0\0\0\0\300\0\0\0\0\0\0\106	MS Windows shortcut
-
+>20	lelong&1	1	\b, Item id list present
+>20	lelong&2	2	\b, Points to a file or directory
+>20	lelong&4	4	\b, Has Description string
+>20	lelong&8	8	\b, Has Relative path
+>20	lelong&16	16	\b, Has Working directory
+>20	lelong&32	32	\b, Has command line arguments
+>20	lelong&64	64	\b, Icon
+>>56	lelong			\b number=%d
+>24	lelong&1	1	\b, Read-Only
+>24	lelong&2	2	\b, Hidden
+>24	lelong&4	4	\b, System
+>24	lelong&8	8	\b, Volume Label
+>24	lelong&16	16	\b, Directory
+>24	lelong&32	32	\b, Archive
+>24	lelong&64	64	\b, Encrypted
+>24	lelong&128	128	\b, Normal
+>24	lelong&256	256	\b, Temporary
+>24	lelong&512	512	\b, Sparse
+>24	lelong&1024	1024	\b, Reparse point
+>24	lelong&2048	2048	\b, Compressed
+>24	lelong&4096	4096	\b, Offline
+>28	leqwdate	x	\b, ctime=%s
+>36	leqwdate	x	\b, mtime=%s
+>44	leqwdate	x	\b, atime=%s
+>52	lelong		x	\b, length=%u, window=
+>60	lelong&1	1	\bhide
+>60	lelong&2	2	\bnormal
+>60	lelong&4	4	\bshowminimized
+>60	lelong&8	8	\bshowmaximized
+>60	lelong&16	16	\bshownoactivate
+>60	lelong&32	32	\bminimize
+>60	lelong&64	64	\bshowminnoactive
+>60	lelong&128	128	\bshowna
+>60	lelong&256	256	\brestore
+>60	lelong&512	512	\bshowdefault
+#>20	lelong&1	0
+#>>20	lelong&2	2
+#>>>(72.l-64)	pstring/h	x	\b [%s]
+#>20	lelong&1	1
+#>>20	lelong&2	2
+#>>>(72.s)	leshort	x
+#>>>&75	pstring/h	x	\b [%s]
 
 # Summary: Outlook Personal Folders
 # Created by: unknown

+ 5 - 1
magic/Magdir/wordprocessors

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: wordprocessors,v 1.15 2010/09/20 19:19:17 rrt Exp $
+# $File: wordprocessors,v 1.16 2012/10/29 17:36:49 christos Exp $
 # wordprocessors:  file(1) magic fo word processors.
 #
 ####### PWP file format used on Smith Corona Personal Word Processors:
@@ -161,3 +161,7 @@
 0	string	\<SCRIBUSUTF8\ Version		Scribus Document
 0	string	\<SCRIBUSUTF8NEW\ Version	Scribus Document
 !:mime	application/x-scribus
+
+# help files .hlp compiled from html and used by gfxboot added by Joerg Jenderek
+# markups page=0x04,label=0x12, followed by strings like "opt" or "main" and title=0x14
+0	ulelong&0x8080FFFF	0x00001204	gfxboot compiled html help file

+ 7 - 1
magic/Makefile.am

@@ -1,5 +1,5 @@
 #
-# $File: Makefile.am,v 1.78 2012/01/27 01:41:26 christos Exp $
+# $File: Makefile.am,v 1.85 2013/01/03 16:00:42 christos Exp $
 #
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_DIR = $(top_srcdir)/magic
@@ -53,6 +53,7 @@ $(MAGIC_FRAGMENT_DIR)/console \
 $(MAGIC_FRAGMENT_DIR)/convex \
 $(MAGIC_FRAGMENT_DIR)/cracklib \
 $(MAGIC_FRAGMENT_DIR)/ctags \
+$(MAGIC_FRAGMENT_DIR)/cubemap \
 $(MAGIC_FRAGMENT_DIR)/cups \
 $(MAGIC_FRAGMENT_DIR)/dact \
 $(MAGIC_FRAGMENT_DIR)/database \
@@ -105,9 +106,11 @@ $(MAGIC_FRAGMENT_DIR)/island \
 $(MAGIC_FRAGMENT_DIR)/ispell \
 $(MAGIC_FRAGMENT_DIR)/isz \
 $(MAGIC_FRAGMENT_DIR)/java \
+$(MAGIC_FRAGMENT_DIR)/javascript \
 $(MAGIC_FRAGMENT_DIR)/jpeg \
 $(MAGIC_FRAGMENT_DIR)/karma \
 $(MAGIC_FRAGMENT_DIR)/kde \
+$(MAGIC_FRAGMENT_DIR)/keepass \
 $(MAGIC_FRAGMENT_DIR)/kml \
 $(MAGIC_FRAGMENT_DIR)/lecter \
 $(MAGIC_FRAGMENT_DIR)/lex \
@@ -119,6 +122,7 @@ $(MAGIC_FRAGMENT_DIR)/lua \
 $(MAGIC_FRAGMENT_DIR)/luks \
 $(MAGIC_FRAGMENT_DIR)/m4 \
 $(MAGIC_FRAGMENT_DIR)/mach \
+$(MAGIC_FRAGMENT_DIR)/macos \
 $(MAGIC_FRAGMENT_DIR)/macintosh \
 $(MAGIC_FRAGMENT_DIR)/magic \
 $(MAGIC_FRAGMENT_DIR)/mail.news \
@@ -178,6 +182,7 @@ $(MAGIC_FRAGMENT_DIR)/printer \
 $(MAGIC_FRAGMENT_DIR)/project \
 $(MAGIC_FRAGMENT_DIR)/psdbms \
 $(MAGIC_FRAGMENT_DIR)/pulsar \
+$(MAGIC_FRAGMENT_DIR)/pwsafe \
 $(MAGIC_FRAGMENT_DIR)/pyramid \
 $(MAGIC_FRAGMENT_DIR)/python \
 $(MAGIC_FRAGMENT_DIR)/revision \
@@ -222,6 +227,7 @@ $(MAGIC_FRAGMENT_DIR)/tuxedo \
 $(MAGIC_FRAGMENT_DIR)/typeset \
 $(MAGIC_FRAGMENT_DIR)/unicode \
 $(MAGIC_FRAGMENT_DIR)/unknown \
+$(MAGIC_FRAGMENT_DIR)/uterus \
 $(MAGIC_FRAGMENT_DIR)/uuencode \
 $(MAGIC_FRAGMENT_DIR)/varied.out \
 $(MAGIC_FRAGMENT_DIR)/varied.script \

+ 13 - 4
magic/Makefile.in

@@ -39,7 +39,8 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+	$(top_srcdir)/m4/visibility.m4 $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -90,6 +91,7 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
+CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -104,6 +106,7 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
+HAVE_VISIBILITY = @HAVE_VISIBILITY@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -196,7 +199,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 
 #
-# $File: Makefile.am,v 1.78 2012/01/27 01:41:26 christos Exp $
+# $File: Makefile.am,v 1.85 2013/01/03 16:00:42 christos Exp $
 #
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_DIR = $(top_srcdir)/magic
@@ -248,6 +251,7 @@ $(MAGIC_FRAGMENT_DIR)/console \
 $(MAGIC_FRAGMENT_DIR)/convex \
 $(MAGIC_FRAGMENT_DIR)/cracklib \
 $(MAGIC_FRAGMENT_DIR)/ctags \
+$(MAGIC_FRAGMENT_DIR)/cubemap \
 $(MAGIC_FRAGMENT_DIR)/cups \
 $(MAGIC_FRAGMENT_DIR)/dact \
 $(MAGIC_FRAGMENT_DIR)/database \
@@ -300,9 +304,11 @@ $(MAGIC_FRAGMENT_DIR)/island \
 $(MAGIC_FRAGMENT_DIR)/ispell \
 $(MAGIC_FRAGMENT_DIR)/isz \
 $(MAGIC_FRAGMENT_DIR)/java \
+$(MAGIC_FRAGMENT_DIR)/javascript \
 $(MAGIC_FRAGMENT_DIR)/jpeg \
 $(MAGIC_FRAGMENT_DIR)/karma \
 $(MAGIC_FRAGMENT_DIR)/kde \
+$(MAGIC_FRAGMENT_DIR)/keepass \
 $(MAGIC_FRAGMENT_DIR)/kml \
 $(MAGIC_FRAGMENT_DIR)/lecter \
 $(MAGIC_FRAGMENT_DIR)/lex \
@@ -314,6 +320,7 @@ $(MAGIC_FRAGMENT_DIR)/lua \
 $(MAGIC_FRAGMENT_DIR)/luks \
 $(MAGIC_FRAGMENT_DIR)/m4 \
 $(MAGIC_FRAGMENT_DIR)/mach \
+$(MAGIC_FRAGMENT_DIR)/macos \
 $(MAGIC_FRAGMENT_DIR)/macintosh \
 $(MAGIC_FRAGMENT_DIR)/magic \
 $(MAGIC_FRAGMENT_DIR)/mail.news \
@@ -373,6 +380,7 @@ $(MAGIC_FRAGMENT_DIR)/printer \
 $(MAGIC_FRAGMENT_DIR)/project \
 $(MAGIC_FRAGMENT_DIR)/psdbms \
 $(MAGIC_FRAGMENT_DIR)/pulsar \
+$(MAGIC_FRAGMENT_DIR)/pwsafe \
 $(MAGIC_FRAGMENT_DIR)/pyramid \
 $(MAGIC_FRAGMENT_DIR)/python \
 $(MAGIC_FRAGMENT_DIR)/revision \
@@ -417,6 +425,7 @@ $(MAGIC_FRAGMENT_DIR)/tuxedo \
 $(MAGIC_FRAGMENT_DIR)/typeset \
 $(MAGIC_FRAGMENT_DIR)/unicode \
 $(MAGIC_FRAGMENT_DIR)/unknown \
+$(MAGIC_FRAGMENT_DIR)/uterus \
 $(MAGIC_FRAGMENT_DIR)/uuencode \
 $(MAGIC_FRAGMENT_DIR)/varied.out \
 $(MAGIC_FRAGMENT_DIR)/varied.script \
@@ -465,9 +474,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu magic/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign magic/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu magic/Makefile
+	  $(AUTOMAKE) --foreign magic/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \

+ 6 - 3
python/Makefile.in

@@ -38,7 +38,8 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+	$(top_srcdir)/m4/visibility.m4 $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -66,6 +67,7 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
+CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -80,6 +82,7 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
+HAVE_VISIBILITY = @HAVE_VISIBILITY@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -183,9 +186,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu python/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign python/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu python/Makefile
+	  $(AUTOMAKE) --foreign python/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \

+ 1 - 1
src/Makefile.am

@@ -5,7 +5,7 @@ include_HEADERS = magic.h
 bin_PROGRAMS = file
 
 AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"'
-AM_CFLAGS = @WARNINGS@
+AM_CFLAGS = $(CFLAG_VISIBILITY) @WARNINGS@
 
 libmagic_la_SOURCES = magic.c apprentice.c softmagic.c ascmagic.c \
 	encoding.c compress.c is_tar.c readelf.c print.c fsmagic.c \

+ 22 - 14
src/Makefile.in

@@ -38,13 +38,14 @@ host_triplet = @host@
 bin_PROGRAMS = file$(EXEEXT)
 subdir = src
 DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
-	$(srcdir)/Makefile.in asprintf.c getline.c getopt_long.c \
-	strlcat.c strlcpy.c vasprintf.c
+	$(srcdir)/Makefile.in asctime_r.c asprintf.c ctime_r.c \
+	getline.c getopt_long.c strlcat.c strlcpy.c vasprintf.c
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+	$(top_srcdir)/m4/visibility.m4 $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -136,6 +137,7 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
+CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -150,6 +152,7 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
+HAVE_VISIBILITY = @HAVE_VISIBILITY@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -244,7 +247,7 @@ MAGIC = $(pkgdatadir)/magic
 lib_LTLIBRARIES = libmagic.la
 include_HEADERS = magic.h
 AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"'
-AM_CFLAGS = @WARNINGS@
+AM_CFLAGS = $(CFLAG_VISIBILITY) @WARNINGS@
 libmagic_la_SOURCES = magic.c apprentice.c softmagic.c ascmagic.c \
 	encoding.c compress.c is_tar.c readelf.c print.c fsmagic.c \
 	funcs.c file.h readelf.h tar.h apptype.c \
@@ -269,9 +272,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu src/Makefile
+	  $(AUTOMAKE) --foreign src/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -376,7 +379,9 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asctime_r.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asprintf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ctime_r.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getline.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt_long.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcat.Plo@am__quote@
@@ -400,24 +405,27 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/softmagic.Plo@am__quote@
 
 .c.o:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+@am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
 
 .c.obj:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .c.lo:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@

File diff suppressed because it is too large
+ 466 - 202
src/apprentice.c


+ 2 - 2
src/ascmagic.c

@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: ascmagic.c,v 1.84 2011/12/08 12:38:24 rrt Exp $")
+FILE_RCSID("@(#)$File: ascmagic.c,v 1.85 2012/08/09 16:33:15 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -134,7 +134,7 @@ file_ascmagic_with_encoding(struct magic_set *ms, const unsigned char *buf,
 		goto done;
 	}
 
-	if ((ms->flags & MAGIC_NO_CHECK_SOFT) == 0) {
+	if (ulen > 0 && (ms->flags & MAGIC_NO_CHECK_SOFT) == 0) {
 		/* Convert ubuf to UTF-8 and try text soft magic */
 		/* malloc size is a conservative overestimate; could be
 		   improved, or at least realloced after conversion. */

+ 19 - 0
src/asctime_r.c

@@ -0,0 +1,19 @@
+/*	$File: asctime_r.c,v 1.1 2012/05/15 17:14:36 christos Exp $	*/
+
+#include "file.h"
+#ifndef	lint
+FILE_RCSID("@(#)$File: asctime_r.c,v 1.1 2012/05/15 17:14:36 christos Exp $")
+#endif	/* lint */
+#include <time.h>
+#include <string.h>
+
+/* asctime_r is not thread-safe anyway */
+char *
+asctime_r(const struct tm *t, char *dst)
+{
+	char *p = asctime(t);
+	if (p == NULL)
+		return NULL;
+	memcpy(dst, p, 26);
+	return dst;
+}

+ 4 - 4
src/cdf.c

@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.50 2012/02/20 22:35:29 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.51 2012/03/20 18:28:02 christos Exp $")
 #endif
 
 #include <assert.h>
@@ -268,10 +268,10 @@ cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
 	const char *b = (const char *)sst->sst_tab;
 	const char *e = ((const char *)p) + tail;
 	(void)&line;
-	if (e >= b && (size_t)(e - b) < CDF_SEC_SIZE(h) * sst->sst_len)
+	if (e >= b && (size_t)(e - b) <= CDF_SEC_SIZE(h) * sst->sst_len)
 		return 0;
-	DPRINTF(("%d: offset begin %p end %p %" SIZE_T_FORMAT "u"
-	    " >= %" SIZE_T_FORMAT "u [%" SIZE_T_FORMAT "u %"
+	DPRINTF(("%d: offset begin %p < end %p || %" SIZE_T_FORMAT "u"
+	    " > %" SIZE_T_FORMAT "u [%" SIZE_T_FORMAT "u %"
 	    SIZE_T_FORMAT "u]\n", line, b, e, (size_t)(e - b),
 	    CDF_SEC_SIZE(h) * sst->sst_len, CDF_SEC_SIZE(h), sst->sst_len));
 	errno = EFTYPE;

+ 1 - 1
src/cdf.h

@@ -308,7 +308,7 @@ int cdf_print_elapsed_time(char *, size_t, cdf_timestamp_t);
 uint16_t cdf_tole2(uint16_t);
 uint32_t cdf_tole4(uint32_t);
 uint64_t cdf_tole8(uint64_t);
-char *cdf_ctime(const time_t *);
+char *cdf_ctime(const time_t *, char *);
 
 #ifdef CDF_DEBUG
 void cdf_dump_header(const cdf_header_t *);

+ 8 - 9
src/cdf_time.c

@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf_time.c,v 1.11 2011/12/13 13:48:41 christos Exp $")
+FILE_RCSID("@(#)$File: cdf_time.c,v 1.12 2012/05/15 17:14:36 christos Exp $")
 #endif
 
 #include <time.h>
@@ -166,15 +166,13 @@ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts)
 }
 
 char *
-cdf_ctime(const time_t *sec)
+cdf_ctime(const time_t *sec, char *buf)
 {
-	static char ctbuf[26];
-	char *ptr = ctime(sec);
+	char *ptr = ctime_r(sec, buf);
 	if (ptr != NULL)
-		return ptr;
-	(void)snprintf(ctbuf, sizeof(ctbuf), "*Bad* 0x%16.16llx\n",
-	    (long long)*sec);
-	return ctbuf;
+		return buf;
+	(void)snprintf(buf, 26, "*Bad* 0x%16.16llx\n", (long long)*sec);
+	return buf;
 }
 
 
@@ -183,12 +181,13 @@ int
 main(int argc, char *argv[])
 {
 	struct timespec ts;
+	char buf[25];
 	static const cdf_timestamp_t tst = 0x01A5E403C2D59C00ULL;
 	static const char *ref = "Sat Apr 23 01:30:00 1977";
 	char *p, *q;
 
 	cdf_timestamp_to_timespec(&ts, tst);
-	p = cdf_ctime(&ts.tv_sec);
+	p = cdf_ctime(&ts.tv_sec, buf);
 	if ((q = strchr(p, '\n')) != NULL)
 		*q = '\0';
 	if (strcmp(ref, p) != 0)

+ 17 - 16
src/compress.c

@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.68 2011/12/08 12:38:24 rrt Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.70 2012/11/07 17:54:48 christos Exp $")
 #endif
 
 #include "magic.h"
@@ -168,12 +168,9 @@ swrite(int fd, const void *buf, size_t n)
  * `safe' read for sockets and pipes.
  */
 protected ssize_t
-sread(int fd, void *buf, size_t n, int canbepipe __attribute__ ((unused)))
+sread(int fd, void *buf, size_t n, int canbepipe __attribute__((__unused__)))
 {
 	ssize_t rv;
-#ifdef FD_ZERO
-	ssize_t cnt;
-#endif
 #ifdef FIONREAD
 	int t = 0;
 #endif
@@ -183,8 +180,9 @@ sread(int fd, void *buf, size_t n, int canbepipe __attribute__ ((unused)))
 		goto nocheck;
 
 #ifdef FIONREAD
-	if ((canbepipe && (ioctl(fd, FIONREAD, &t) == -1)) || (t == 0)) {
+	if (canbepipe && (ioctl(fd, FIONREAD, &t) == -1 || t == 0)) {
 #ifdef FD_ZERO
+		ssize_t cnt;
 		for (cnt = 0;; cnt++) {
 			fd_set check;
 			struct timeval tout = {0, 100 * 1000};
@@ -241,9 +239,6 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
 	char buf[4096];
 	ssize_t r;
 	int tfd;
-#ifdef HAVE_MKSTEMP
-	int te;
-#endif
 
 	(void)strlcpy(buf, "/tmp/file.XXXXXX", sizeof buf);
 #ifndef HAVE_MKSTEMP
@@ -255,10 +250,13 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
 		errno = r;
 	}
 #else
-	tfd = mkstemp(buf);
-	te = errno;
-	(void)unlink(buf);
-	errno = te;
+	{
+		int te;
+		tfd = mkstemp(buf);
+		te = errno;
+		(void)unlink(buf);
+		errno = te;
+	}
 #endif
 	if (tfd == -1) {
 		file_error(ms, errno,
@@ -399,16 +397,19 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
 	case 0:	/* child */
 		(void) close(0);
 		if (fd != -1) {
-		    (void) dup(fd);
+		    if (dup(fd) == -1)
+			_exit(1);
 		    (void) lseek(0, (off_t)0, SEEK_SET);
 		} else {
-		    (void) dup(fdin[0]);
+		    if (dup(fdin[0]) == -1)
+			_exit(1);
 		    (void) close(fdin[0]);
 		    (void) close(fdin[1]);
 		}
 
 		(void) close(1);
-		(void) dup(fdout[1]);
+		if (dup(fdout[1]) == -1)
+			_exit(1);
 		(void) close(fdout[0]);
 		(void) close(fdout[1]);
 #ifndef DEBUG

+ 19 - 0
src/ctime_r.c

@@ -0,0 +1,19 @@
+/*	$File: ctime_r.c,v 1.1 2012/05/15 17:14:36 christos Exp $	*/
+
+#include "file.h"
+#ifndef	lint
+FILE_RCSID("@(#)$File: ctime_r.c,v 1.1 2012/05/15 17:14:36 christos Exp $")
+#endif	/* lint */
+#include <time.h>
+#include <string.h>
+
+/* ctime_r is not thread-safe anyway */
+char *
+ctime_r(const time_t *t, char *dst)
+{
+	char *p = ctime(t);
+	if (p == NULL)
+		return NULL;
+	memcpy(dst, p, 26);
+	return dst;
+}

+ 38 - 6
src/file.c

@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: file.c,v 1.145 2011/12/08 12:12:46 rrt Exp $")
+FILE_RCSID("@(#)$File: file.c,v 1.148 2012/11/21 16:27:39 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -122,8 +122,8 @@ private const struct {
 private char *progname;		/* used throughout 		*/
 
 private void usage(void);
+private void docprint(const char *);
 private void help(void);
-int main(int, char *[]);
 
 private int unwrap(struct magic_set *, const char *);
 private int process(struct magic_set *ms, const char *, int);
@@ -252,7 +252,7 @@ main(int argc, char *argv[])
 			(void)fprintf(stdout, "%s-%s\n", progname, VERSION);
 			(void)fprintf(stdout, "magic file from %s\n",
 				       magicfile);
-			return 1;
+			return 0;
 		case 'z':
 			flags |= MAGIC_COMPRESS;
 			break;
@@ -437,7 +437,7 @@ process(struct magic_set *ms, const char *inname, int wid)
 	}
 }
 
-size_t
+protected size_t
 file_mbswidth(const char *s)
 {
 #if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
@@ -479,6 +479,36 @@ usage(void)
 }
 
 private void
+docprint(const char *opts)
+{
+	size_t i;
+	int comma;
+	char *sp, *p;
+
+	p = strstr(opts, "%o");
+	if (p == NULL) {
+		fprintf(stdout, "%s", opts);
+		return;
+	}
+
+	for (sp = p - 1; sp > opts && *sp == ' '; sp--)
+		continue;
+
+	fprintf(stdout, "%.*s", (int)(p - opts), opts);
+
+	comma = 0;
+	for (i = 0; i < __arraycount(nv); i++) {
+		fprintf(stdout, "%s%s", comma++ ? ", " : "", nv[i].name);
+		if (i && i % 5 == 0) {
+			fprintf(stdout, ",\n%*s", (int)(p - sp - 1), "");
+			comma = 0;
+		}
+	}
+
+	fprintf(stdout, "%s", opts + (p - opts) + 2);
+}
+
+private void
 help(void)
 {
 	(void)fputs(
@@ -486,9 +516,11 @@ help(void)
 "Determine type of FILEs.\n"
 "\n", stdout);
 #define OPT(shortname, longname, opt, doc)      \
-	fprintf(stdout, "  -%c, --" longname doc, shortname);
+	fprintf(stdout, "  -%c, --" longname, shortname), \
+	docprint(doc);
 #define OPT_LONGONLY(longname, opt, doc)        \
-	fprintf(stdout, "      --" longname doc);
+	fprintf(stdout, "      --" longname),	\
+	docprint(doc);
 #include "file_opts.h"
 #undef OPT
 #undef OPT_LONGONLY

+ 39 - 7
src/file.h

@@ -27,7 +27,7 @@
  */
 /*
  * file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.135 2011/09/20 15:30:14 christos Exp $
+ * @(#)$File: file.h,v 1.140 2012/10/30 23:11:51 christos Exp $
  */
 
 #ifndef __file_h__
@@ -62,6 +62,7 @@
 #include <inttypes.h>
 #endif
 #include <regex.h>
+#include <time.h>
 #include <sys/types.h>
 #include <sys/param.h>
 /* Do this here and now, because struct stat gets re-defined on solaris */
@@ -81,10 +82,18 @@
 #endif
 
 #define private static
+
+#if HAVE_VISIBILITY
+#define public  __attribute__ ((__visibility__("default")))
 #ifndef protected
-#define protected
+#define protected __attribute__ ((__visibility__("hidden")))
 #endif
+#else
 #define public
+#ifndef protected
+#define protected
+#endif
+#endif
 
 #ifndef __arraycount
 #define __arraycount(a) (sizeof(a) / sizeof(a[0]))
@@ -123,7 +132,7 @@
 #define MAXstring 64		/* max leng of "string" types */
 
 #define MAGICNO		0xF11E041C
-#define VERSIONNO	8
+#define VERSIONNO	9
 #define FILE_MAGICSIZE	232
 
 #define	FILE_LOAD	0
@@ -207,7 +216,12 @@ struct magic {
 #define				FILE_BEID3	39
 #define				FILE_LEID3	40
 #define				FILE_INDIRECT	41
-#define				FILE_NAMES_SIZE	42/* size of array to contain all names */
+#define				FILE_QWDATE	42
+#define				FILE_LEQWDATE	43
+#define				FILE_BEQWDATE	44
+#define				FILE_NAME	45
+#define				FILE_USE	46
+#define				FILE_NAMES_SIZE	47 /* size of array to contain all names */
 
 #define IS_STRING(t) \
 	((t) == FILE_STRING || \
@@ -216,6 +230,8 @@ struct magic {
 	 (t) == FILE_LESTRING16 || \
 	 (t) == FILE_REGEX || \
 	 (t) == FILE_SEARCH || \
+	 (t) == FILE_NAME || \
+	 (t) == FILE_USE || \
 	 (t) == FILE_DEFAULT)
 
 #define FILE_FMT_NONE 0
@@ -307,12 +323,14 @@ struct magic {
 #define PSTRING_LEN	\
     (PSTRING_1_BE|PSTRING_2_LE|PSTRING_2_BE|PSTRING_4_LE|PSTRING_4_BE)
 #define PSTRING_LENGTH_INCLUDES_ITSELF		BIT(12)
+#define	STRING_TRIM				BIT(13)
 #define CHAR_COMPACT_WHITESPACE			'W'
 #define CHAR_COMPACT_OPTIONAL_WHITESPACE	'w'
 #define CHAR_IGNORE_LOWERCASE			'c'
 #define CHAR_IGNORE_UPPERCASE			'C'
 #define CHAR_REGEX_OFFSET_START			's'
 #define CHAR_TEXTTEST				't'
+#define	CHAR_TRIM				'T'
 #define CHAR_BINTEST				'b'
 #define CHAR_PSTRING_1_BE			'B'
 #define CHAR_PSTRING_1_LE			'B'
@@ -351,8 +369,11 @@ struct level_info {
 	int last_cond;	/* used for error checking by parse() */
 #endif
 };
+
+#define MAGIC_SETS	2
+
 struct magic_set {
-	struct mlist *mlist;
+	struct mlist *mlist[MAGIC_SETS];	/* list of regular entries */
 	struct cont {
 		size_t len;
 		struct level_info *li;
@@ -386,7 +407,11 @@ struct magic_set {
 typedef unsigned long unichar;
 
 struct stat;
-protected const char *file_fmttime(uint32_t, int);
+#define FILE_T_LOCAL	1
+#define FILE_T_WINDOWS	2
+protected const char *file_fmttime(uint64_t, int, char *);
+protected struct magic_set *file_ms_alloc(int);
+protected void file_ms_free(struct magic_set *);
 protected int file_buffer(struct magic_set *, int, const char *, const void *,
     size_t);
 protected int file_fsmagic(struct magic_set *, const char *, struct stat *);
@@ -415,7 +440,8 @@ protected int file_encoding(struct magic_set *, const unsigned char *, size_t,
 protected int file_is_tar(struct magic_set *, const unsigned char *, size_t);
 protected int file_softmagic(struct magic_set *, const unsigned char *, size_t,
     int, int);
-protected struct mlist *file_apprentice(struct magic_set *, const char *, int);
+protected int file_apprentice(struct magic_set *, const char *, int);
+protected int file_magicfind(struct magic_set *, const char *, struct mlist *);
 protected uint64_t file_signextend(struct magic_set *, struct magic *,
     uint64_t);
 protected void file_delmagic(struct magic *, int type, size_t entries);
@@ -477,6 +503,12 @@ size_t strlcat(char *dst, const char *src, size_t siz);
 ssize_t getline(char **dst, size_t *len, FILE *fp);
 ssize_t getdelim(char **dst, size_t *len, int delimiter, FILE *fp);
 #endif
+#ifndef HAVE_CTIME_R
+char   *ctime_r(const time_t *, char *);
+#endif
+#ifndef HAVE_ASCTIME_R
+char   *asctime_r(const struct tm *, char *);
+#endif
 
 #if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H) && !defined(QUICK)
 #define QUICK

+ 1 - 1
src/file_opts.h

@@ -23,7 +23,7 @@ OPT('c', "checking-printout", 0, "    print the parsed form of the magic file, u
     "                               before installing it\n")
 OPT('e', "exclude", 1, " TEST         exclude TEST from the list of test to be\n"
     "                               performed for file. Valid tests are:\n"
-    "                               ascii, apptype, compress, elf, soft, tar, tokens, troff\n")
+    "                               %o\n")
 OPT('f', "files-from", 1, " FILE      read the filenames to be examined from FILE\n")
 OPT('F', "separator", 1, " STRING     use string as separator instead of `:'\n")
 OPT('i', "mime", 0, "                 output MIME type strings (--mime-type and\n"

+ 30 - 27
src/fsmagic.c

@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: fsmagic.c,v 1.64 2011/08/14 09:03:12 christos Exp $")
+FILE_RCSID("@(#)$File: fsmagic.c,v 1.65 2012/08/26 09:56:26 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -98,7 +98,7 @@ handle_mime(struct magic_set *ms, int mime, const char *str)
 protected int
 file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 {
-	int ret = 0;
+	int ret = 0, did = 0;
 	int mime = ms->flags & MAGIC_MIME;
 #ifdef	S_IFLNK
 	char buf[BUFSIZ+4];
@@ -111,6 +111,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 	if (fn == NULL)
 		return 0;
 
+#define COMMA	(did++ ? ", " : "")
 	/*
 	 * Fstat is cheaper but fails for files you don't have read perms on.
 	 * On 4.2BSD and similar systems, use lstat() to identify symlinks.
@@ -136,18 +137,18 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 
 	if (!mime) {
 #ifdef S_ISUID
-		if (sb->st_mode & S_ISUID) 
-			if (file_printf(ms, "setuid ") == -1)
+		if (sb->st_mode & S_ISUID)
+			if (file_printf(ms, "%ssetuid", COMMA) == -1)
 				return -1;
 #endif
 #ifdef S_ISGID
 		if (sb->st_mode & S_ISGID) 
-			if (file_printf(ms, "setgid ") == -1)
+			if (file_printf(ms, "%ssetgid", COMMA) == -1)
 				return -1;
 #endif
 #ifdef S_ISVTX
 		if (sb->st_mode & S_ISVTX) 
-			if (file_printf(ms, "sticky ") == -1)
+			if (file_printf(ms, "%ssticky", COMMA) == -1)
 				return -1;
 #endif
 	}
@@ -157,7 +158,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		if (mime) {
 			if (handle_mime(ms, mime, "directory") == -1)
 				return -1;
-		} else if (file_printf(ms, "directory") == -1)
+		} else if (file_printf(ms, "%sdirectory", COMMA) == -1)
 			return -1;
 		return 1;
 #ifdef S_IFCHR
@@ -175,18 +176,18 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		} else {
 #ifdef HAVE_STAT_ST_RDEV
 # ifdef dv_unit
-			if (file_printf(ms, "character special (%d/%d/%d)",
-			    major(sb->st_rdev), dv_unit(sb->st_rdev),
+			if (file_printf(ms, "%scharacter special (%d/%d/%d)",
+			    COMMA, major(sb->st_rdev), dv_unit(sb->st_rdev),
 					dv_subunit(sb->st_rdev)) == -1)
 				return -1;
 # else
-			if (file_printf(ms, "character special (%ld/%ld)",
-			    (long)major(sb->st_rdev), (long)minor(sb->st_rdev))
-			    == -1)
+			if (file_printf(ms, "%scharacter special (%ld/%ld)",
+			    COMMA, (long)major(sb->st_rdev),
+			    (long)minor(sb->st_rdev)) == -1)
 				return -1;
 # endif
 #else
-			if (file_printf(ms, "character special") == -1)
+			if (file_printf(ms, "%scharacter special", COMMA) == -1)
 				return -1;
 #endif
 		}
@@ -207,17 +208,18 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		} else {
 #ifdef HAVE_STAT_ST_RDEV
 # ifdef dv_unit
-			if (file_printf(ms, "block special (%d/%d/%d)",
-					major(sb->st_rdev), dv_unit(sb->st_rdev),
-					dv_subunit(sb->st_rdev)) == -1)
+			if (file_printf(ms, "%sblock special (%d/%d/%d)",
+			    COMMA, major(sb->st_rdev), dv_unit(sb->st_rdev),
+			    dv_subunit(sb->st_rdev)) == -1)
 				return -1;
 # else
-			if (file_printf(ms, "block special (%ld/%ld)",
-					(long)major(sb->st_rdev), (long)minor(sb->st_rdev)) == -1)
+			if (file_printf(ms, "%sblock special (%ld/%ld)",
+			    COMMA, (long)major(sb->st_rdev),
+			    (long)minor(sb->st_rdev)) == -1)
 				return -1;
 # endif
 #else
-			if (file_printf(ms, "block special") == -1)
+			if (file_printf(ms, "%sblock special", COMMA) == -1)
 				return -1;
 #endif
 		}
@@ -231,7 +233,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		if (mime) {
 			if (handle_mime(ms, mime, "fifo") == -1)
 				return -1;
-		} else if (file_printf(ms, "fifo (named pipe)") == -1)
+		} else if (file_printf(ms, "%sfifo (named pipe)", COMMA) == -1)
 			return -1;
 		return 1;
 #endif
@@ -240,7 +242,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		if (mime) {
 			if (handle_mime(ms, mime, "door") == -1)
 				return -1;
-		} else if (file_printf(ms, "door") == -1)
+		} else if (file_printf(ms, "%sdoor", COMMA) == -1)
 			return -1;
 		return 1;
 #endif
@@ -256,7 +258,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 				if (handle_mime(ms, mime, "symlink") == -1)
 					return -1;
 			} else if (file_printf(ms,
-			    "unreadable symlink `%s' (%s)", fn,
+			    "%sunreadable symlink `%s' (%s)", COMMA, fn,
 			    strerror(errno)) == -1)
 				return -1;
 			return 1;
@@ -285,7 +287,8 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 						    "x-path-too-long") == -1)
 							return -1;
 					} else if (file_printf(ms,
-					    "path too long: `%s'", fn) == -1)
+					    "%spath too long: `%s'", COMMA,
+					    fn) == -1)
 						return -1;
 					return 1;
 				}
@@ -311,8 +314,8 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 			if (mime) {
 				if (handle_mime(ms, mime, "symlink") == -1)
 					return -1;
-			} else if (file_printf(ms, "symbolic link to `%s'",
-			    buf) == -1)
+			} else if (file_printf(ms, "%ssymbolic link to `%s'",
+			    COMMA, buf) == -1)
 				return -1;
 		}
 		return 1;
@@ -323,7 +326,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		if (mime) {
 			if (handle_mime(ms, mime, "socket") == -1)
 				return -1;
-		} else if (file_printf(ms, "socket") == -1)
+		} else if (file_printf(ms, "%ssocket", COMMA) == -1)
 			return -1;
 		return 1;
 #endif
@@ -352,7 +355,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 		if (mime) {
 			if (handle_mime(ms, mime, "x-empty") == -1)
 				return -1;
-		} else if (file_printf(ms, "empty") == -1)
+		} else if (file_printf(ms, "%sempty", COMMA) == -1)
 			return -1;
 		return 1;
 	}

+ 2 - 2
src/funcs.c

@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.60 2011/12/08 12:38:24 rrt Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.61 2012/10/30 23:11:51 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -301,7 +301,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((unu
 protected int
 file_reset(struct magic_set *ms)
 {
-	if (ms->mlist == NULL) {
+	if (ms->mlist[0] == NULL) {
 		file_error(ms, 0, "no magic files loaded");
 		return -1;
 	}

+ 40 - 74
src/magic.c

@@ -33,7 +33,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: magic.c,v 1.74 2011/05/26 01:27:59 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.77 2012/10/31 17:20:06 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -71,7 +71,6 @@ FILE_RCSID("@(#)$File: magic.c,v 1.74 2011/05/26 01:27:59 christos Exp $")
 #endif
 #endif
 
-private void free_mlist(struct mlist *);
 private void close_and_restore(const struct magic_set *, const char *, int,
     const struct stat *);
 private int unreadable_info(struct magic_set *, mode_t, const char *);
@@ -101,16 +100,21 @@ get_default_magic(void)
 	if ((home = getenv("HOME")) == NULL)
 		return MAGIC;
 
-	if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
+	if (asprintf(&hmagicpath, "%s/.magic.mgc", home) < 0)
 		return MAGIC;
-	if (stat(hmagicpath, &st) == -1)
-		goto out;
-	if (S_ISDIR(st.st_mode)) {
+	if (stat(hmagicpath, &st) == -1) {
 		free(hmagicpath);
-		if (asprintf(&hmagicpath, "%s/%s", home, hmagic) < 0)
+		if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
 			return MAGIC;
-		if (access(hmagicpath, R_OK) == -1)
+		if (stat(hmagicpath, &st) == -1)
 			goto out;
+		if (S_ISDIR(st.st_mode)) {
+			free(hmagicpath);
+			if (asprintf(&hmagicpath, "%s/%s", home, hmagic) < 0)
+				return MAGIC;
+			if (access(hmagicpath, R_OK) == -1)
+				goto out;
+		}
 	}
 
 	if (asprintf(&default_magic, "%s:%s", hmagicpath, MAGIC) < 0)
@@ -210,51 +214,7 @@ magic_getpath(const char *magicfile, int action)
 public struct magic_set *
 magic_open(int flags)
 {
-	struct magic_set *ms;
-	size_t len;
-
-	if ((ms = CAST(struct magic_set *, calloc((size_t)1,
-	    sizeof(struct magic_set)))) == NULL)
-		return NULL;
-
-	if (magic_setflags(ms, flags) == -1) {
-		errno = EINVAL;
-		goto free;
-	}
-
-	ms->o.buf = ms->o.pbuf = NULL;
-	len = (ms->c.len = 10) * sizeof(*ms->c.li);
-
-	if ((ms->c.li = CAST(struct level_info *, malloc(len))) == NULL)
-		goto free;
-
-	ms->event_flags = 0;
-	ms->error = -1;
-	ms->mlist = NULL;
-	ms->file = "unknown";
-	ms->line = 0;
-	return ms;
-free:
-	free(ms);
-	return NULL;
-}
-
-private void
-free_mlist(struct mlist *mlist)
-{
-	struct mlist *ml;
-
-	if (mlist == NULL)
-		return;
-
-	for (ml = mlist->next; ml != mlist;) {
-		struct mlist *next = ml->next;
-		struct magic *mg = ml->magic;
-		file_delmagic(mg, ml->mapped, ml->nmagic);
-		free(ml);
-		ml = next;
-	}
-	free(ml);
+	return file_ms_alloc(flags);
 }
 
 private int
@@ -278,11 +238,9 @@ unreadable_info(struct magic_set *ms, mode_t md, const char *file)
 public void
 magic_close(struct magic_set *ms)
 {
-	free_mlist(ms->mlist);
-	free(ms->o.pbuf);
-	free(ms->o.buf);
-	free(ms->c.li);
-	free(ms);
+	if (ms == NULL)
+		return;
+	file_ms_free(ms);
 }
 
 /*
@@ -291,37 +249,33 @@ magic_close(struct magic_set *ms)
 public int
 magic_load(struct magic_set *ms, const char *magicfile)
 {
-	struct mlist *ml = file_apprentice(ms, magicfile, FILE_LOAD);
-	if (ml) {
-		free_mlist(ms->mlist);
-		ms->mlist = ml;
-		return 0;
-	}
-	return -1;
+	if (ms == NULL)
+		return -1;
+	return file_apprentice(ms, magicfile, FILE_LOAD);
 }
 
 public int
 magic_compile(struct magic_set *ms, const char *magicfile)
 {
-	struct mlist *ml = file_apprentice(ms, magicfile, FILE_COMPILE);
-	free_mlist(ml);
-	return ml ? 0 : -1;
+	if (ms == NULL)
+		return -1;
+	return file_apprentice(ms, magicfile, FILE_COMPILE);
 }
 
 public int
 magic_check(struct magic_set *ms, const char *magicfile)
 {
-	struct mlist *ml = file_apprentice(ms, magicfile, FILE_CHECK);
-	free_mlist(ml);
-	return ml ? 0 : -1;
+	if (ms == NULL)
+		return -1;
+	return file_apprentice(ms, magicfile, FILE_CHECK);
 }
 
 public int
 magic_list(struct magic_set *ms, const char *magicfile)
 {
-	struct mlist *ml = file_apprentice(ms, magicfile, FILE_LIST);
-	free_mlist(ml);
-	return ml ? 0 : -1;
+	if (ms == NULL)
+		return -1;
+	return file_apprentice(ms, magicfile, FILE_LIST);
 }
 
 private void
@@ -365,6 +319,8 @@ close_and_restore(const struct magic_set *ms, const char *name, int fd,
 public const char *
 magic_descriptor(struct magic_set *ms, int fd)
 {
+	if (ms == NULL)
+		return NULL;
 	return file_or_fd(ms, NULL, fd);
 }
 
@@ -374,6 +330,8 @@ magic_descriptor(struct magic_set *ms, int fd)
 public const char *
 magic_file(struct magic_set *ms, const char *inname)
 {
+	if (ms == NULL)
+		return NULL;
 	return file_or_fd(ms, inname, STDIN_FILENO);
 }
 
@@ -476,6 +434,8 @@ done:
 public const char *
 magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
 {
+	if (ms == NULL)
+		return NULL;
 	if (file_reset(ms) == -1)
 		return NULL;
 	/*
@@ -492,18 +452,24 @@ magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
 public const char *
 magic_error(struct magic_set *ms)
 {
+	if (ms == NULL)
+		return "Magic database is not open";
 	return (ms->event_flags & EVENT_HAD_ERR) ? ms->o.buf : NULL;
 }
 
 public int
 magic_errno(struct magic_set *ms)
 {
+	if (ms == NULL)
+		return EINVAL;
 	return (ms->event_flags & EVENT_HAD_ERR) ? ms->error : 0;
 }
 
 public int
 magic_setflags(struct magic_set *ms, int flags)
 {
+	if (ms == NULL)
+		return -1;
 #if !defined(HAVE_UTIME) && !defined(HAVE_UTIMES)
 	if (flags & MAGIC_PRESERVE_ATIME)
 		return -1;

+ 30 - 12
src/print.c

@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: print.c,v 1.71 2011/09/20 15:28:09 christos Exp $")
+FILE_RCSID("@(#)$File: print.c,v 1.75 2012/10/30 23:11:51 christos Exp $")
 #endif  /* lint */
 
 #include <string.h>
@@ -45,11 +45,14 @@ FILE_RCSID("@(#)$File: print.c,v 1.71 2011/09/20 15:28:09 christos Exp $")
 
 #define SZOF(a)	(sizeof(a) / sizeof(a[0]))
 
+#include "cdf.h"
+
 #ifndef COMPILE_ONLY
 protected void
 file_mdump(struct magic *m)
 {
-	private const char optyp[] = { FILE_OPS };
+	static const char optyp[] = { FILE_OPS };
+	char tbuf[26];
 
 	(void) fprintf(stderr, "%u: %.*s %u", m->lineno,
 	    (m->cont_level & 7) + 1, ">>>>>>>>", m->offset);
@@ -153,26 +156,31 @@ file_mdump(struct magic *m)
 		case FILE_BEDATE:
 		case FILE_MEDATE:
 			(void)fprintf(stderr, "%s,",
-			    file_fmttime(m->value.l, 1));
+			    file_fmttime(m->value.l, FILE_T_LOCAL, tbuf));
 			break;
 		case FILE_LDATE:
 		case FILE_LELDATE:
 		case FILE_BELDATE:
 		case FILE_MELDATE:
 			(void)fprintf(stderr, "%s,",
-			    file_fmttime(m->value.l, 0));
-			break;
+			    file_fmttime(m->value.l, 0, tbuf));
 		case FILE_QDATE:
 		case FILE_LEQDATE:
 		case FILE_BEQDATE:
 			(void)fprintf(stderr, "%s,",
-			    file_fmttime((uint32_t)m->value.q, 1));
+			    file_fmttime(m->value.q, FILE_T_LOCAL, tbuf));
 			break;
 		case FILE_QLDATE:
 		case FILE_LEQLDATE:
 		case FILE_BEQLDATE:
 			(void)fprintf(stderr, "%s,",
-			    file_fmttime((uint32_t)m->value.q, 0));
+			    file_fmttime(m->value.q, 0, tbuf));
+			break;
+		case FILE_QWDATE:
+		case FILE_LEQWDATE:
+		case FILE_BEQWDATE:
+			(void)fprintf(stderr, "%s,",
+			    file_fmttime(m->value.q, FILE_T_WINDOWS, tbuf));
 			break;
 		case FILE_FLOAT:
 		case FILE_BEFLOAT:
@@ -187,6 +195,10 @@ file_mdump(struct magic *m)
 		case FILE_DEFAULT:
 			/* XXX - do anything here? */
 			break;
+		case FILE_USE:
+		case FILE_NAME:
+			(void) fprintf(stderr, "'%s'", m->value.s);
+			break;
 		default:
 			(void) fputs("*bad*", stderr);
 			break;
@@ -216,14 +228,20 @@ file_magwarn(struct magic_set *ms, const char *f, ...)
 }
 
 protected const char *
-file_fmttime(uint32_t v, int local)
+file_fmttime(uint64_t v, int flags, char *buf)
 {
 	char *pp;
 	time_t t = (time_t)v;
 	struct tm *tm;
 
-	if (local) {
-		pp = ctime(&t);
+	if (flags & FILE_T_WINDOWS) {
+		struct timespec ts;
+		cdf_timestamp_to_timespec(&ts, t);
+		t = ts.tv_sec;
+	}
+
+	if (flags & FILE_T_LOCAL) {
+		pp = ctime_r(&t, buf);
 	} else {
 #ifndef HAVE_DAYLIGHT
 		private int daylight = 0;
@@ -245,7 +263,7 @@ file_fmttime(uint32_t v, int local)
 		tm = gmtime(&t);
 		if (tm == NULL)
 			goto out;
-		pp = asctime(tm);
+		pp = asctime_r(tm, buf);
 	}
 
 	if (pp == NULL)
@@ -253,5 +271,5 @@ file_fmttime(uint32_t v, int local)
 	pp[strcspn(pp, "\n")] = '\0';
 	return pp;
 out:
-	return "*Invalid time*";
+	return strcpy(buf, "*Invalid time*");
 }

+ 20 - 10
src/readcdf.c

@@ -26,7 +26,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.29 2012/02/20 20:04:58 christos Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.33 2012/06/20 21:52:36 christos Exp $")
 #endif
 
 #include <stdlib.h>
@@ -125,8 +125,8 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
                 case CDF_FILETIME:
                         tp = info[i].pi_tp;
                         if (tp != 0) {
+				char tbuf[64];
                                 if (tp < 1000000000000000LL) {
-                                        char tbuf[64];
                                         cdf_print_elapsed_time(tbuf,
                                             sizeof(tbuf), tp);
                                         if (NOTMIME(ms) && file_printf(ms,
@@ -135,7 +135,7 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
                                 } else {
                                         char *c, *ec;
                                         cdf_timestamp_to_timespec(&ts, tp);
-                                        c = cdf_ctime(&ts.tv_sec);
+                                        c = cdf_ctime(&ts.tv_sec, tbuf);
                                         if ((ec = strchr(c, '\n')) != NULL)
                                                 *ec = '\0';
 
@@ -285,10 +285,14 @@ file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
 		    d = &dir.dir_tab[j];
 		    for (k = 0; k < sizeof(name); k++)
 			name[k] = (char)cdf_tole2(d->d_name[k]);
-		    if (strstr(name, "WordDocument") == 0) {
+		    if (strstr(name, "WordDocument") != 0) {
 			str = "msword";
 			break;
 		    }
+		    if (strstr(name, "PowerPoint") != 0) {
+			str = "vnd.ms-powerpoint";
+			break;
+		    }
 		}
                 if (file_printf(ms, "application/%s", str) == -1)
                         return -1;
@@ -305,13 +309,19 @@ out1:
         free(sat.sat_tab);
 out0:
         if (i != 1) {
-		if (i == -1)
-		    if (file_printf(ms, "Composite Document File V2 Document")
-			== -1)
+		if (i == -1) {
+		    if (NOTMIME(ms)) {
+			if (file_printf(ms,
+			    "Composite Document File V2 Document") == -1)
 			    return -1;
-                if (*expn)
-                        if (file_printf(ms, ", %s%s", corrupt, expn) == -1)
-                                return -1;
+			if (*expn)
+			    if (file_printf(ms, ", %s%s", corrupt, expn) == -1)
+				return -1;
+		    } else {
+			if (file_printf(ms, "application/CDFV2-corrupt") == -1)
+			    return -1;
+		    }
+		}
                 i = 1;
         }
         return i;

+ 28 - 7
src/readelf.c

@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.90 2011/08/23 08:01:12 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.94 2012/12/13 13:48:31 christos Exp $")
 #endif
 
 #ifdef BUILTIN_ELF
@@ -58,7 +58,9 @@ private size_t donote(struct magic_set *, void *, size_t, size_t, int,
 
 private uint16_t getu16(int, uint16_t);
 private uint32_t getu32(int, uint32_t);
+#ifndef USE_ARRAY_FOR_64BIT_TYPES
 private uint64_t getu64(int, uint64_t);
+#endif
 
 private uint16_t
 getu16(int swap, uint16_t value)
@@ -100,6 +102,7 @@ getu32(int swap, uint32_t value)
 		return value;
 }
 
+#ifndef USE_ARRAY_FOR_64BIT_TYPES
 private uint64_t
 getu64(int swap, uint64_t value)
 {
@@ -124,6 +127,7 @@ getu64(int swap, uint64_t value)
 	} else
 		return value;
 }
+#endif
 
 #define elf_getu16(swap, value) getu16(swap, value)
 #define elf_getu32(swap, value) getu32(swap, value)
@@ -416,6 +420,10 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
 	    (FLAGS_DID_NOTE|FLAGS_DID_BUILD_ID))
 		goto core;
 
+	if (namesz == 5 && strcmp((char *)&nbuf[noff], "SuSE") == 0 &&
+	    xnh_type == NT_GNU_VERSION && descsz == 2) {
+	    file_printf(ms, ", for SuSE %d.%d", nbuf[doff], nbuf[doff + 1]);
+	}
 	if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
 	    xnh_type == NT_GNU_VERSION && descsz == 16) {
 		uint32_t desc[4];
@@ -457,13 +465,14 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
 
 	if (namesz == 4 && strcmp((char *)&nbuf[noff], "GNU") == 0 &&
 	    xnh_type == NT_GNU_BUILD_ID && (descsz == 16 || descsz == 20)) {
-	    uint32_t desc[5], i;
-	    if (file_printf(ms, ", BuildID[%s]=0x", descsz == 16 ? "md5/uuid" :
+	    uint8_t desc[20];
+	    uint32_t i;
+	    if (file_printf(ms, ", BuildID[%s]=", descsz == 16 ? "md5/uuid" :
 		"sha1") == -1)
 		    return size;
 	    (void)memcpy(desc, &nbuf[doff], descsz);
-	    for (i = 0; i < descsz >> 2; i++)
-		if (file_printf(ms, "%.8x", desc[i]) == -1)
+	    for (i = 0; i < descsz; i++)
+		if (file_printf(ms, "%02x", desc[i]) == -1)
 		    return size;
 	    *flags |= FLAGS_DID_BUILD_ID;
 	}
@@ -919,6 +928,17 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
 			free(nbuf);
 			break;
 		case SHT_SUNW_cap:
+			switch (mach) {
+			case EM_SPARC:
+			case EM_SPARCV9:
+			case EM_IA_64:
+			case EM_386:
+			case EM_AMD64:
+				break;
+			default:
+				goto skip;
+			}
+
 			if (lseek(fd, (off_t)xsh_offset, SEEK_SET) ==
 			    (off_t)-1) {
 				file_badseek(ms);
@@ -958,12 +978,13 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
 					break;
 				}
 			}
-			break;
-
+			/*FALLTHROUGH*/
+		skip:
 		default:
 			break;
 		}
 	}
+
 	if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1)
 		return -1;
 	if (cap_hw1) {

+ 180 - 41
src/softmagic.c

@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.147 2011/11/05 15:44:22 rrt Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.156 2013/01/03 23:11:38 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -43,16 +43,16 @@ FILE_RCSID("@(#)$File: softmagic.c,v 1.147 2011/11/05 15:44:22 rrt Exp $")
 
 
 private int match(struct magic_set *, struct magic *, uint32_t,
-    const unsigned char *, size_t, int, int);
+    const unsigned char *, size_t, size_t, int, int, int);
 private int mget(struct magic_set *, const unsigned char *,
-    struct magic *, size_t, unsigned int, int);
+    struct magic *, size_t, size_t, unsigned int, int, int, int);
 private int magiccheck(struct magic_set *, struct magic *);
 private int32_t mprint(struct magic_set *, struct magic *);
 private int32_t moffset(struct magic_set *, struct magic *);
 private void mdebug(uint32_t, const char *, size_t);
 private int mcopy(struct magic_set *, union VALUETYPE *, int, int,
     const unsigned char *, uint32_t, size_t, size_t);
-private int mconvert(struct magic_set *, struct magic *);
+private int mconvert(struct magic_set *, struct magic *, int);
 private int print_sep(struct magic_set *, int);
 private int handle_annotation(struct magic_set *, struct magic *);
 private void cvt_8(union VALUETYPE *, const struct magic *);
@@ -71,9 +71,9 @@ file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
 {
 	struct mlist *ml;
 	int rv;
-	for (ml = ms->mlist->next; ml != ms->mlist; ml = ml->next)
-		if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, mode,
-		    text)) != 0)
+	for (ml = ms->mlist[0]->next; ml != ms->mlist[0]; ml = ml->next)
+		if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, 0, mode,
+		    text, 0)) != 0)
 			return rv;
 
 	return 0;
@@ -108,7 +108,8 @@ file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes,
  */
 private int
 match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
-    const unsigned char *s, size_t nbytes, int mode, int text)
+    const unsigned char *s, size_t nbytes, size_t offset, int mode, int text,
+    int flip)
 {
 	uint32_t magindex = 0;
 	unsigned int cont_level = 0;
@@ -125,13 +126,15 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 		int flush = 0;
 		struct magic *m = &magic[magindex];
 
+		if (m->type != FILE_NAME)
 		if ((IS_STRING(m->type) &&
 		     ((text && (m->str_flags & (STRING_BINTEST | STRING_TEXTTEST)) == STRING_BINTEST) ||
 		      (!text && (m->str_flags & (STRING_TEXTTEST | STRING_BINTEST)) == STRING_TEXTTEST))) ||
 		    (m->flag & mode) != mode) {
 			/* Skip sub-tests */
-			while (magic[magindex + 1].cont_level != 0 &&
-			       ++magindex < nmagic)
+			while (magindex + 1 < nmagic &&
+                               magic[magindex + 1].cont_level != 0 &&
+			       ++magindex)
 				continue;
 			continue; /* Skip to next top-level test*/
 		}
@@ -140,7 +143,8 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 		ms->line = m->lineno;
 
 		/* if main entry matches, print it... */
-		switch (mget(ms, s, m, nbytes, cont_level, text)) {
+		switch (mget(ms, s, m, nbytes, offset, cont_level, mode, text,
+		    flip)) {
 		case -1:
 			return -1;
 		case 0:
@@ -173,8 +177,9 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 			continue;
 		}
 
-		if ((e = handle_annotation(ms, m)) != 0)
+		if ((e = handle_annotation(ms, m)) != 0) {
 			return e;
+		}
 		/*
 		 * If we are going to print something, we'll need to print
 		 * a blank before we print something else.
@@ -223,7 +228,8 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
 					continue;
 			}
 #endif
-			switch (mget(ms, s, m, nbytes, cont_level, text)) {
+			switch (mget(ms, s, m, nbytes, offset, cont_level, mode,
+			    text, flip)) {
 			case -1:
 				return -1;
 			case 0:
@@ -363,7 +369,7 @@ mprint(struct magic_set *ms, struct magic *m)
 	float vf;
 	double vd;
 	int64_t t = 0;
- 	char buf[128];
+ 	char buf[128], tbuf[26];
 	union VALUETYPE *p = &ms->ms_value;
 
   	switch (m->type) {
@@ -448,11 +454,30 @@ mprint(struct magic_set *ms, struct magic *m)
 			t = ms->offset + m->vallen;
 		}
 		else {
+			char *str = p->s;
+
+			/* compute t before we mangle the string? */
+			t = ms->offset + strlen(str);
+
 			if (*m->value.s == '\0')
-				p->s[strcspn(p->s, "\n")] = '\0';
-			if (file_printf(ms, m->desc, p->s) == -1)
+				str[strcspn(str, "\n")] = '\0';
+
+			if (m->str_flags & STRING_TRIM) {
+				char *last;
+				while (isspace((unsigned char)*str))
+					str++;
+				last = str;
+				while (*last)
+					last++;
+				--last;
+				while (isspace((unsigned char)*last))
+					last--;
+				*++last = '\0';
+			}
+
+			if (file_printf(ms, m->desc, str) == -1)
 				return -1;
-			t = ms->offset + strlen(p->s);
+
 			if (m->type == FILE_PSTRING)
 				t += file_pstring_length_size(m);
 		}
@@ -462,25 +487,26 @@ mprint(struct magic_set *ms, struct magic *m)
 	case FILE_BEDATE:
 	case FILE_LEDATE:
 	case FILE_MEDATE:
-		if (file_printf(ms, m->desc, file_fmttime(p->l, 1)) == -1)
+		if (file_printf(ms, m->desc, file_fmttime(p->l, FILE_T_LOCAL,
+		    tbuf)) == -1)
 			return -1;
-		t = ms->offset + sizeof(time_t);
+		t = ms->offset + sizeof(uint32_t);
 		break;
 
 	case FILE_LDATE:
 	case FILE_BELDATE:
 	case FILE_LELDATE:
 	case FILE_MELDATE:
-		if (file_printf(ms, m->desc, file_fmttime(p->l, 0)) == -1)
+		if (file_printf(ms, m->desc, file_fmttime(p->l, 0, tbuf)) == -1)
 			return -1;
-		t = ms->offset + sizeof(time_t);
+		t = ms->offset + sizeof(uint32_t);
 		break;
 
 	case FILE_QDATE:
 	case FILE_BEQDATE:
 	case FILE_LEQDATE:
-		if (file_printf(ms, m->desc, file_fmttime((uint32_t)p->q,
-		    1)) == -1)
+		if (file_printf(ms, m->desc, file_fmttime(p->q, FILE_T_LOCAL,
+		    tbuf)) == -1)
 			return -1;
 		t = ms->offset + sizeof(uint64_t);
 		break;
@@ -488,8 +514,16 @@ mprint(struct magic_set *ms, struct magic *m)
 	case FILE_QLDATE:
 	case FILE_BEQLDATE:
 	case FILE_LEQLDATE:
-		if (file_printf(ms, m->desc, file_fmttime((uint32_t)p->q,
-		    0)) == -1)
+		if (file_printf(ms, m->desc, file_fmttime(p->q, 0, tbuf)) == -1)
+			return -1;
+		t = ms->offset + sizeof(uint64_t);
+		break;
+
+	case FILE_QWDATE:
+	case FILE_BEQWDATE:
+	case FILE_LEQWDATE:
+		if (file_printf(ms, m->desc, file_fmttime(p->q, FILE_T_WINDOWS,
+		    tbuf)) == -1)
 			return -1;
 		t = ms->offset + sizeof(uint64_t);
 		break;
@@ -572,6 +606,8 @@ mprint(struct magic_set *ms, struct magic *m)
 		break;
 
 	case FILE_INDIRECT:
+	case FILE_USE:
+	case FILE_NAME:
 		t = ms->offset;
 		break;
 
@@ -619,7 +655,7 @@ moffset(struct magic_set *ms, struct magic *m)
 				p->s[strcspn(p->s, "\n")] = '\0';
 			t = CAST(uint32_t, (ms->offset + strlen(p->s)));
 			if (m->type == FILE_PSTRING)
-				t += file_pstring_length_size(m);
+				t += (uint32_t)file_pstring_length_size(m);
 			return t;
 		}
 
@@ -627,13 +663,13 @@ moffset(struct magic_set *ms, struct magic *m)
 	case FILE_BEDATE:
 	case FILE_LEDATE:
 	case FILE_MEDATE:
-		return CAST(int32_t, (ms->offset + sizeof(time_t)));
+		return CAST(int32_t, (ms->offset + sizeof(uint32_t)));
 
 	case FILE_LDATE:
 	case FILE_BELDATE:
 	case FILE_LELDATE:
 	case FILE_MELDATE:
-		return CAST(int32_t, (ms->offset + sizeof(time_t)));
+		return CAST(int32_t, (ms->offset + sizeof(uint32_t)));
 
 	case FILE_QDATE:
 	case FILE_BEQDATE:
@@ -679,6 +715,56 @@ moffset(struct magic_set *ms, struct magic *m)
 	}
 }
 
+private int
+cvt_flip(int type, int flip)
+{
+	if (flip == 0)
+		return type;
+	switch (type) {
+	case FILE_BESHORT:
+		return FILE_LESHORT;
+	case FILE_BELONG:
+		return FILE_LELONG;
+	case FILE_BEDATE:
+		return FILE_LEDATE;
+	case FILE_BELDATE:
+		return FILE_LELDATE;
+	case FILE_BEQUAD:
+		return FILE_LEQUAD;
+	case FILE_BEQDATE:
+		return FILE_LEQDATE;
+	case FILE_BEQLDATE:
+		return FILE_LEQLDATE;
+	case FILE_BEQWDATE:
+		return FILE_LEQWDATE;
+	case FILE_LESHORT:
+		return FILE_BESHORT;
+	case FILE_LELONG:
+		return FILE_BELONG;
+	case FILE_LEDATE:
+		return FILE_BEDATE;
+	case FILE_LELDATE:
+		return FILE_BELDATE;
+	case FILE_LEQUAD:
+		return FILE_BEQUAD;
+	case FILE_LEQDATE:
+		return FILE_BEQDATE;
+	case FILE_LEQLDATE:
+		return FILE_BEQLDATE;
+	case FILE_LEQWDATE:
+		return FILE_BEQWDATE;
+	case FILE_BEFLOAT:
+		return FILE_LEFLOAT;
+	case FILE_LEFLOAT:
+		return FILE_BEFLOAT;
+	case FILE_BEDOUBLE:
+		return FILE_LEDOUBLE;
+	case FILE_LEDOUBLE:
+		return FILE_BEDOUBLE;
+	default:
+		return type;
+	}
+}
 #define DO_CVT(fld, cast) \
 	if (m->num_mask) \
 		switch (m->mask_op & FILE_OPS_MASK) { \
@@ -769,11 +855,11 @@ cvt_double(union VALUETYPE *p, const struct magic *m)
  * (unless you have a better idea)
  */
 private int
-mconvert(struct magic_set *ms, struct magic *m)
+mconvert(struct magic_set *ms, struct magic *m, int flip)
 {
 	union VALUETYPE *p = &ms->ms_value;
 
-	switch (m->type) {
+	switch (cvt_flip(m->type, flip)) {
 	case FILE_BYTE:
 		cvt_8(p, m);
 		return 1;
@@ -788,6 +874,7 @@ mconvert(struct magic_set *ms, struct magic *m)
 	case FILE_QUAD:
 	case FILE_QDATE:
 	case FILE_QLDATE:
+	case FILE_QWDATE:
 		cvt_64(p, m);
 		return 1;
 	case FILE_STRING:
@@ -821,6 +908,7 @@ mconvert(struct magic_set *ms, struct magic *m)
 	case FILE_BEQUAD:
 	case FILE_BEQDATE:
 	case FILE_BEQLDATE:
+	case FILE_BEQWDATE:
 		p->q = (uint64_t)
 		    (((uint64_t)p->hq[0]<<56)|((uint64_t)p->hq[1]<<48)|
 		     ((uint64_t)p->hq[2]<<40)|((uint64_t)p->hq[3]<<32)|
@@ -842,6 +930,7 @@ mconvert(struct magic_set *ms, struct magic *m)
 	case FILE_LEQUAD:
 	case FILE_LEQDATE:
 	case FILE_LEQLDATE:
+	case FILE_LEQWDATE:
 		p->q = (uint64_t)
 		    (((uint64_t)p->hq[7]<<56)|((uint64_t)p->hq[6]<<48)|
 		     ((uint64_t)p->hq[5]<<40)|((uint64_t)p->hq[4]<<32)|
@@ -889,6 +978,8 @@ mconvert(struct magic_set *ms, struct magic *m)
 	case FILE_REGEX:
 	case FILE_SEARCH:
 	case FILE_DEFAULT:
+	case FILE_NAME:
+	case FILE_USE:
 		return 1;
 	default:
 		file_magerror(ms, "invalid type %d in mconvert()", m->type);
@@ -1017,14 +1108,19 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
 }
 
 private int
-mget(struct magic_set *ms, const unsigned char *s,
-    struct magic *m, size_t nbytes, unsigned int cont_level, int text)
+mget(struct magic_set *ms, const unsigned char *s, struct magic *m,
+    size_t nbytes, size_t o, unsigned int cont_level, int mode, int text,
+    int flip)
 {
 	uint32_t offset = ms->offset;
 	uint32_t count = m->str_range;
+	int rv;
+	char *sbuf, *rbuf;
 	union VALUETYPE *p = &ms->ms_value;
+	struct mlist ml;
 
-	if (mcopy(ms, p, m->type, m->flag & INDIR, s, offset, nbytes, count) == -1)
+	if (mcopy(ms, p, m->type, m->flag & INDIR, s, (uint32_t)(offset + o),
+	    (uint32_t)(nbytes - o), count) == -1)
 		return -1;
 
 	if ((ms->flags & MAGIC_DEBUG) != 0) {
@@ -1039,7 +1135,7 @@ mget(struct magic_set *ms, const unsigned char *s,
 		if (m->in_op & FILE_OPINDIRECT) {
 			const union VALUETYPE *q = CAST(const union VALUETYPE *,
 			    ((const void *)(s + offset + off)));
-			switch (m->in_type) {
+			switch (cvt_flip(m->in_type, flip)) {
 			case FILE_BYTE:
 				off = q->b;
 				break;
@@ -1070,8 +1166,10 @@ mget(struct magic_set *ms, const unsigned char *s,
 						 (q->hl[3]<<8)|(q->hl[2]));
 				break;
 			}
+			if ((ms->flags & MAGIC_DEBUG) != 0)
+				fprintf(stderr, "indirect offs=%u\n", off);
 		}
-		switch (m->in_type) {
+		switch (cvt_flip(m->in_type, flip)) {
 		case FILE_BYTE:
 			if (nbytes < (offset + 1))
 				return 0;
@@ -1496,7 +1594,7 @@ mget(struct magic_set *ms, const unsigned char *s,
 			break;
 		}
 
-		switch (m->in_type) {
+		switch (cvt_flip(m->in_type, flip)) {
 		case FILE_LEID3:
 		case FILE_BEID3:
 			offset = ((((offset >>  0) & 0x7f) <<  0) |
@@ -1510,6 +1608,8 @@ mget(struct magic_set *ms, const unsigned char *s,
 
 		if (m->flag & INDIROFFADD) {
 			offset += ms->c.li[cont_level-1].off;
+			if ((ms->flags & MAGIC_DEBUG) != 0)
+				fprintf(stderr, "indirect +offs=%u\n", offset);
 		}
 		if (mcopy(ms, p, m->type, 0, s, offset, nbytes, count) == -1)
 			return -1;
@@ -1577,19 +1677,53 @@ mget(struct magic_set *ms, const unsigned char *s,
 		break;
 
 	case FILE_INDIRECT:
-	  	if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
-		    file_printf(ms, "%s", m->desc) == -1)
-			return -1;
 		if (nbytes < offset)
 			return 0;
-		return file_softmagic(ms, s + offset, nbytes - offset,
+		sbuf = ms->o.buf;
+		ms->o.buf = NULL;
+		ms->offset = 0;
+		rv = file_softmagic(ms, s + offset, nbytes - offset,
 		    BINTEST, text);
+		if ((ms->flags & MAGIC_DEBUG) != 0)
+			fprintf(stderr, "indirect @offs=%u[%d]\n", offset, rv);
+		if (rv == 1) {
+			rbuf = ms->o.buf;
+			ms->o.buf = sbuf;
+			if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
+			    file_printf(ms, m->desc, offset) == -1)
+				return -1;
+			if (file_printf(ms, "%s", rbuf) == -1)
+				return -1;
+			free(rbuf);
+		} else
+			ms->o.buf = sbuf;
+		return rv;
+
+	case FILE_USE:
+		if (nbytes < offset)
+			return 0;
+		sbuf = m->value.s;
+		if (*sbuf == '^') {
+			sbuf++;
+			flip = 1;
+		} else
+			flip = 0;
+		if (file_magicfind(ms, sbuf, &ml) == -1) {
+			file_error(ms, 0, "cannot find entry `%s'", sbuf);
+			return -1;
+		}
+		return match(ms, ml.magic, ml.nmagic, s, nbytes, offset,
+		    mode, text, flip);
 
+	case FILE_NAME:
+		if (file_printf(ms, "%s", m->desc) == -1)
+			return -1;
+		return 1;
 	case FILE_DEFAULT:	/* nothing to check */
 	default:
 		break;
 	}
-	if (!mconvert(ms, m))
+	if (!mconvert(ms, m, flip))
 		return 0;
 	return 1;
 }
@@ -1714,6 +1848,9 @@ magiccheck(struct magic_set *ms, struct magic *m)
 	case FILE_QLDATE:
 	case FILE_BEQLDATE:
 	case FILE_LEQLDATE:
+	case FILE_QWDATE:
+	case FILE_BEQWDATE:
+	case FILE_LEQWDATE:
 		v = p->q;
 		break;
 
@@ -1885,6 +2022,8 @@ magiccheck(struct magic_set *ms, struct magic *m)
 		break;
 	}
 	case FILE_INDIRECT:
+	case FILE_USE:
+	case FILE_NAME:
 		return 1;
 	default:
 		file_magerror(ms, "invalid type %d in magiccheck()", m->type);

+ 19 - 4
src/vasprintf.c

@@ -83,7 +83,7 @@ trying to do any interpretation
 flag:   none   +     -     #     (blank)
 width:  n    0n    *
 prec:   none   .0    .n     .*
-modifier:    F N L h l ll    ('F' and 'N' are ms-dos/16-bit specific)
+modifier:    F N L h l ll z t    ('F' and 'N' are ms-dos/16-bit specific)
 type:  d i o u x X f e g E G c s p n
 
 
@@ -108,7 +108,7 @@ you use strange formats.
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: vasprintf.c,v 1.8 2011/12/08 12:38:24 rrt Exp $")
+FILE_RCSID("@(#)$File: vasprintf.c,v 1.10 2012/08/09 16:40:04 christos Exp $")
 #endif	/* lint */
 
 #include <assert.h>
@@ -119,6 +119,9 @@ FILE_RCSID("@(#)$File: vasprintf.c,v 1.8 2011/12/08 12:38:24 rrt Exp $")
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
+#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
 
 #define ALLOC_CHUNK 2048
 #define ALLOC_SECURITY_MARGIN 1024   /* big value because some platforms have very big 'G' exponent */
@@ -385,7 +388,12 @@ static int dispatch(xprintf_struct *s)
     prec = -1;                  /* no .prec specified */
 
   /* modifier */
-  if (*SRCTXT == 'L' || *SRCTXT == 'h' || *SRCTXT == 'l') {
+  switch (*SRCTXT) {
+  case 'L':
+  case 'h':
+  case 'l':
+  case 'z':
+  case 't':
     modifier = *SRCTXT;
     SRCTXT++;
     if (modifier=='l' && *SRCTXT=='l') {
@@ -393,8 +401,11 @@ static int dispatch(xprintf_struct *s)
       modifier = 'L';  /* 'll' == 'L'      long long == long double */
     } /* only for compatibility ; not portable */
     INCOHERENT_TEST();
-  } else
+    break;
+  default:
     modifier = -1;              /* no modifier specified */
+    break;
+  }
 
   /* type */
   type = *SRCTXT;
@@ -477,6 +488,10 @@ static int dispatch(xprintf_struct *s)
       return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, long int));
     case 'h':
       return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, int));
+    case 'z':
+      return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, size_t));
+    case 't':
+      return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, ptrdiff_t));
       /* 'int' instead of 'short int' because default promotion is 'int' */
     default:
       INCOHERENT();

+ 17 - 11
tests/Makefile.in

@@ -39,7 +39,8 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+	$(top_srcdir)/m4/visibility.m4 $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -95,6 +96,7 @@ AWK = @AWK@
 CC = @CC@
 CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
+CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CYGPATH_W = @CYGPATH_W@
@@ -109,6 +111,7 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GREP = @GREP@
+HAVE_VISIBILITY = @HAVE_VISIBILITY@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,9 +221,9 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
 	      exit 1;; \
 	  esac; \
 	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
 	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --gnu tests/Makefile
+	  $(AUTOMAKE) --foreign tests/Makefile
 .PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	@case '$?' in \
@@ -261,24 +264,27 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-test.Po@am__quote@
 
 .c.o:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+@am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
 
 .c.obj:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
 @am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .c.lo:
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
 @am__fastdepCC_FALSE@	$(AM_V_CC) @AM_BACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@