Browse Source

Import upstream version 5.12

Christos Zoulas 11 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 $