Browse Source

Import upstream version 5.38

Christos Zoulas 4 years ago
parent
commit
460653f3ba
99 changed files with 11337 additions and 6622 deletions
  1. 20 0
      ChangeLog
  2. 15 11
      Makefile.in
  3. 6 1
      README
  4. 123 140
      aclocal.m4
  5. 7 6
      compile
  6. 358 312
      config.guess
  7. 19 5
      config.h.in
  8. 1249 1282
      config.sub
  9. 1543 1044
      configure
  10. 39 2
      configure.ac
  11. 5 5
      depcomp
  12. 9 5
      doc/Makefile.in
  13. 7 4
      doc/file.man
  14. 5 3
      doc/libmagic.man
  15. 3 3
      doc/magic.man
  16. 3501 2008
      ltmain.sh
  17. 1474 1087
      m4/libtool.m4
  18. 90 37
      m4/ltoptions.m4
  19. 4 3
      m4/ltsugar.m4
  20. 6 6
      m4/ltversion.m4
  21. 4 3
      m4/lt~obsolete.m4
  22. 13 3
      magic/Magdir/android
  23. 45 44
      magic/Magdir/animation
  24. 36 24
      magic/Magdir/apple
  25. 53 7
      magic/Magdir/archive
  26. 37 12
      magic/Magdir/audio
  27. 1 1
      magic/Magdir/bsi
  28. 2 2
      magic/Magdir/c-lang
  29. 157 30
      magic/Magdir/cad
  30. 4 1
      magic/Magdir/commands
  31. 10 10
      magic/Magdir/compress
  32. 81 14
      magic/Magdir/console
  33. 19 18
      magic/Magdir/database
  34. 4 5
      magic/Magdir/elf
  35. 2 2
      magic/Magdir/espressif
  36. 25 35
      magic/Magdir/filesystems
  37. 30 26
      magic/Magdir/fonts
  38. 80 0
      magic/Magdir/forth
  39. 18 6
      magic/Magdir/frame
  40. 5 1
      magic/Magdir/games
  41. 31 1
      magic/Magdir/gimp
  42. 13 0
      magic/Magdir/git
  43. 2 2
      magic/Magdir/icc
  44. 281 9
      magic/Magdir/images
  45. 6 1
      magic/Magdir/javascript
  46. 3 3
      magic/Magdir/kml
  47. 6 1
      magic/Magdir/linux
  48. 36 3
      magic/Magdir/macintosh
  49. 11 2
      magic/Magdir/mail.news
  50. 78 1
      magic/Magdir/map
  51. 9 0
      magic/Magdir/modulefile
  52. 173 109
      magic/Magdir/msdos
  53. 3 1
      magic/Magdir/msooxml
  54. 456 18
      magic/Magdir/ole2compounddocs
  55. 17 0
      magic/Magdir/openfst
  56. 16 0
      magic/Magdir/opentimestamps
  57. 7 1
      magic/Magdir/pdf
  58. 46 0
      magic/Magdir/pmem
  59. 19 6
      magic/Magdir/python
  60. 15 1
      magic/Magdir/rpi
  61. 11 0
      magic/Magdir/rst
  62. 3 3
      magic/Magdir/ruby
  63. 3 3
      magic/Magdir/sgml
  64. 5 3
      magic/Magdir/sniffer
  65. 40 0
      magic/Magdir/sosi
  66. 6 0
      magic/Magdir/ssh
  67. 1 6
      magic/Magdir/uuencode
  68. 9 1
      magic/Magdir/varied.script
  69. 12 7
      magic/Magdir/vax
  70. 117 5
      magic/Magdir/windows
  71. 46 4
      magic/Magdir/wordprocessors
  72. 2 2
      magic/Magdir/zip
  73. 9 1
      magic/Makefile.am
  74. 18 6
      magic/Makefile.in
  75. 8 8
      missing
  76. 9 5
      python/Makefile.in
  77. 2 2
      src/Makefile.am
  78. 188 91
      src/Makefile.in
  79. 2 12
      src/apprentice.c
  80. 1 2
      src/ascmagic.c
  81. 2 1
      src/buffer.c
  82. 20 7
      src/cdf.c
  83. 1 0
      src/cdf.h
  84. 165 31
      src/compress.c
  85. 1 2
      src/encoding.c
  86. 8 10
      src/file.c
  87. 2 1
      src/file.h
  88. 4 3
      src/file_opts.h
  89. 7 1
      src/fsmagic.c
  90. 20 3
      src/funcs.c
  91. 197 0
      src/is_csv.c
  92. 2 0
      src/magic.h.in
  93. 8 3
      src/readcdf.c
  94. 12 2
      src/readelf.c
  95. 21 3
      src/seccomp.c
  96. 2 2
      src/vasprintf.c
  97. 1 1
      tests/JW07022A.mp3.result
  98. 33 22
      tests/Makefile.in
  99. 2 2
      tests/test.c

+ 20 - 0
ChangeLog

@@ -1,3 +1,23 @@
+2019-12-16  21:11  Christos Zoulas <christos@zoulas.com>
+
+	* release 5.38
+
+2019-12-15  22:13  Christos Zoulas <christos@zoulas.com>
+    Document changes since the previous release:
+	- Always accept -S (no sandbox) even if we don't support sandboxing
+	- More syscalls elided for sandboxiing
+	- For ELF dynamic means having an interpreter not just PT_DYNAMIC
+	- Check for large ELF session header offset
+	- When saving and restoring a locale, keep the locale name in our
+	  own storage.
+	- Add a flag to disable CSV file detection.
+	- Don't pass NULL/0 to memset to appease sanitizers.
+	- Avoid spurious prints when looks for extensions or apple strings
+	  in fsmagic.
+	- Add builtin decompressors for xz and and bzip.
+	- Add a limit for the number of CDF elements.
+	- More checks for overflow in CDF.
+
 2019-05-14  22:26  Christos Zoulas <christos@zoulas.com>
 
 	* release 5.37

+ 15 - 11
Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -136,7 +136,7 @@ am__recursive_targets = \
   $(RECURSIVE_CLEAN_TARGETS) \
   $(am__extra_recursive_targets)
 AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
-	cscope distdir dist dist-all distcheck
+	cscope distdir distdir-am dist dist-all distcheck
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
 	$(LISP)config.h.in
 # Read a list of newline-separated strings from the standard input,
@@ -161,7 +161,7 @@ CSCOPE = cscope
 DIST_SUBDIRS = $(SUBDIRS)
 am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in AUTHORS \
 	COPYING ChangeLog INSTALL NEWS README TODO compile \
-	config.guess config.sub depcomp install-sh ltmain.sh missing
+	config.guess config.sub install-sh ltmain.sh missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -246,6 +246,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MINGW = @MINGW@
@@ -352,8 +353,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' $(SHELL) ./config.status'; \
 	    $(SHELL) ./config.status;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -495,7 +496,10 @@ distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 	-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	$(am__remove_distdir)
 	test -d "$(distdir)" || mkdir "$(distdir)"
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -560,7 +564,7 @@ distdir: $(DISTFILES)
 	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
 	|| chmod -R a+r "$(distdir)"
 dist-gzip: distdir
-	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
 	$(am__post_remove_distdir)
 
 dist-bzip2: distdir
@@ -586,7 +590,7 @@ dist-shar: distdir
 	@echo WARNING: "Support for shar distribution archives is" \
 	               "deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
-	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+	shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
 	$(am__post_remove_distdir)
 
 dist-zip: distdir
@@ -604,7 +608,7 @@ dist dist-all:
 distcheck: dist
 	case '$(DIST_ARCHIVES)' in \
 	*.tar.gz*) \
-	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
 	*.tar.bz2*) \
 	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
 	*.tar.lz*) \
@@ -614,7 +618,7 @@ distcheck: dist
 	*.tar.Z*) \
 	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
 	*.shar.gz*) \
-	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
 	*.zip*) \
 	  unzip $(distdir).zip ;;\
 	esac

+ 6 - 1
README

@@ -1,6 +1,6 @@
 ## README for file(1) Command and the libmagic(3) library ##
 
-    @(#) $File: README,v 1.57 2019/02/06 00:20:56 christos Exp $
+    @(#) $File: README,v 1.59 2019/09/19 01:04:01 christos Exp $
 
 Mailing List: file@astron.com
 Mailing List archives: http://mailman.astron.com/pipermail/file/
@@ -24,6 +24,10 @@ A public read-only git repository of the same sources is available at:
 
 	https://github.com/file/file
 
+We are continuously being fuzzed by OSS-FUZZ:
+
+	https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:file
+
 The major changes for 5.x are CDF file parsing, indirect magic, name/use
 (recursion) and overhaul in mime and ascii encoding handling.
 
@@ -91,6 +95,7 @@ src/funcs.c - utilility functions
 src/getline.c - replacement for OS's that don't have it.
 src/getopt_long.c - replacement for OS's that don't have it.
 src/gmtime_r.c - replacement for OS's that don't have it.
+src/is_csv.c - knows about Comma Separated Value file format (RFC 4180).
 src/is_json.c - knows about JavaScript Object Notation format (RFC 8259).
 src/is_tar.c, tar.h - knows about Tape ARchive format (courtesy John Gilmore).
 src/localtime_r.c - replacement for OS's that don't have it.

+ 123 - 140
aclocal.m4

@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.15 -*- Autoconf -*-
+# generated automatically by aclocal 1.16.1 -*- Autoconf -*-
 
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2018 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -20,8 +20,8 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# visibility.m4 serial 5 (gettext-0.18.2)
-dnl Copyright (C) 2005, 2008, 2010-2016 Free Software Foundation, Inc.
+# visibility.m4 serial 6
+dnl Copyright (C) 2005, 2008, 2010-2019 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.
@@ -51,42 +51,42 @@ AC_DEFUN([gl_VISIBILITY],
     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])
+    AC_CACHE_CHECK([whether the -Werror option is usable],
+      [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"
+      ])
     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])
+    AC_CACHE_CHECK([for simple visibility declarations],
+      [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"
+      ])
     if test $gl_cv_cc_visibility = yes; then
       CFLAG_VISIBILITY="-fvisibility=hidden"
       HAVE_VISIBILITY=1
@@ -98,7 +98,7 @@ AC_DEFUN([gl_VISIBILITY],
     [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.])
 ])
 
-# Copyright (C) 2002-2014 Free Software Foundation, Inc.
+# Copyright (C) 2002-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -110,10 +110,10 @@ AC_DEFUN([gl_VISIBILITY],
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.15'
+[am__api_version='1.16'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.15], [],
+m4_if([$1], [1.16.1], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -129,14 +129,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.15])dnl
+[AM_AUTOMAKE_VERSION([1.16.1])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -188,7 +188,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2014 Free Software Foundation, Inc.
+# Copyright (C) 1997-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -219,7 +219,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -410,13 +410,12 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2018 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.
 
-
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
@@ -424,49 +423,41 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
   # Older Autoconf quotes --file arguments for eval, but not when files
   # are listed without --file.  Let's play safe and only enable the eval
   # if we detect the quoting.
-  case $CONFIG_FILES in
-  *\'*) eval set x "$CONFIG_FILES" ;;
-  *)   set x $CONFIG_FILES ;;
-  esac
+  # TODO: see whether this extra hack can be removed once we start
+  # requiring Autoconf 2.70 or later.
+  AS_CASE([$CONFIG_FILES],
+          [*\'*], [eval set x "$CONFIG_FILES"],
+          [*], [set x $CONFIG_FILES])
   shift
-  for mf
+  # Used to flag and report bootstrapping failures.
+  am_rc=0
+  for am_mf
   do
     # Strip MF so we end up with the name of the file.
-    mf=`echo "$mf" | sed -e 's/:.*$//'`
-    # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named 'Makefile.in', but
-    # some people rename them; so instead we look at the file content.
-    # Grep'ing the first line is not enough: some people post-process
-    # each Makefile.in and add a new line on top of each file to say so.
-    # Grep'ing the whole file is not good either: AIX grep has a line
+    am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile which includes
+    # dependency-tracking related rules and includes.
+    # Grep'ing the whole file directly is not great: AIX grep has a line
     # limit of 2048, but all sed's we know have understand at least 4000.
-    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
-      dirpart=`AS_DIRNAME("$mf")`
-    else
-      continue
-    fi
-    # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running 'make'.
-    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
-    test -z "$DEPDIR" && continue
-    am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "$am__include" && continue
-    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # Find all dependency output files, they are included files with
-    # $(DEPDIR) in their names.  We invoke sed twice because it is the
-    # simplest approach to changing $(DEPDIR) to its actual value in the
-    # expansion.
-    for file in `sed -n "
-      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
-      # Make sure the directory exists.
-      test -f "$dirpart/$file" && continue
-      fdir=`AS_DIRNAME(["$file"])`
-      AS_MKDIR_P([$dirpart/$fdir])
-      # echo "creating $dirpart/$file"
-      echo '# dummy' > "$dirpart/$file"
-    done
+    sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \
+      || continue
+    am_dirpart=`AS_DIRNAME(["$am_mf"])`
+    am_filepart=`AS_BASENAME(["$am_mf"])`
+    AM_RUN_LOG([cd "$am_dirpart" \
+      && sed -e '/# am--include-marker/d' "$am_filepart" \
+        | $MAKE -f - am--depfiles]) || am_rc=$?
   done
+  if test $am_rc -ne 0; then
+    AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments
+    for automatic dependency tracking.  Try re-running configure with the
+    '--disable-dependency-tracking' option to at least be able to build
+    the package (albeit without support for automatic dependency tracking).])
+  fi
+  AS_UNSET([am_dirpart])
+  AS_UNSET([am_filepart])
+  AS_UNSET([am_mf])
+  AS_UNSET([am_rc])
+  rm -f conftest-deps.mk
 }
 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
 
@@ -475,18 +466,17 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
 # -----------------------------
 # This macro should only be invoked once -- use via AC_REQUIRE.
 #
-# This code is only required when automatic dependency tracking
-# is enabled.  FIXME.  This creates each '.P' file that we will
-# need in order to bootstrap the dependency handling code.
+# This code is only required when automatic dependency tracking is enabled.
+# This creates each '.Po' and '.Plo' makefile fragment that we'll need in
+# order to bootstrap the dependency handling code.
 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 [AC_CONFIG_COMMANDS([depfiles],
      [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
-     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
-])
+     [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])])
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -573,8 +563,8 @@ AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
 # For better backward compatibility.  To be removed once Automake 1.9.x
 # dies out for good.  For more background, see:
-# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
-# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+# <https://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <https://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
 AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
 # We need awk for the "check" target (and possibly the TAP driver).  The
 # system "awk" is bad on some platforms.
@@ -641,7 +631,7 @@ END
 Aborting the configuration process, to ensure you take notice of the issue.
 
 You can download and install GNU coreutils to get an 'rm' implementation
-that behaves properly: <http://www.gnu.org/software/coreutils/>.
+that behaves properly: <https://www.gnu.org/software/coreutils/>.
 
 If you want to complete the configuration process using your problematic
 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
@@ -683,7 +673,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -704,7 +694,7 @@ if test x"${install_sh+set}" != xset; then
 fi
 AC_SUBST([install_sh])])
 
-# Copyright (C) 2003-2014 Free Software Foundation, Inc.
+# Copyright (C) 2003-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -725,7 +715,7 @@ AC_SUBST([am__leading_dot])])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -733,49 +723,42 @@ AC_SUBST([am__leading_dot])])
 
 # AM_MAKE_INCLUDE()
 # -----------------
-# Check to see how make treats includes.
+# Check whether make has an 'include' directive that can support all
+# the idioms we need for our automatic dependency tracking code.
 AC_DEFUN([AM_MAKE_INCLUDE],
-[am_make=${MAKE-make}
-cat > confinc << 'END'
+[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive])
+cat > confinc.mk << 'END'
 am__doit:
-	@echo this is the am__doit target
+	@echo this is the am__doit target >confinc.out
 .PHONY: am__doit
 END
-# If we don't find an include directive, just comment out the code.
-AC_MSG_CHECKING([for style of include used by $am_make])
 am__include="#"
 am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# Ignore all kinds of additional output from 'make'.
-case `$am_make -s -f confmf 2> /dev/null` in #(
-*the\ am__doit\ target*)
-  am__include=include
-  am__quote=
-  _am_result=GNU
-  ;;
-esac
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
-   echo '.include "confinc"' > confmf
-   case `$am_make -s -f confmf 2> /dev/null` in #(
-   *the\ am__doit\ target*)
-     am__include=.include
-     am__quote="\""
-     _am_result=BSD
-     ;;
-   esac
-fi
-AC_SUBST([am__include])
-AC_SUBST([am__quote])
-AC_MSG_RESULT([$_am_result])
-rm -f confinc confmf
-])
+# BSD make does it like this.
+echo '.include "confinc.mk" # ignored' > confmf.BSD
+# Other make implementations (GNU, Solaris 10, AIX) do it like this.
+echo 'include confinc.mk # ignored' > confmf.GNU
+_am_result=no
+for s in GNU BSD; do
+  AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out])
+  AS_CASE([$?:`cat confinc.out 2>/dev/null`],
+      ['0:this is the am__doit target'],
+      [AS_CASE([$s],
+          [BSD], [am__include='.include' am__quote='"'],
+          [am__include='include' am__quote=''])])
+  if test "$am__include" != "#"; then
+    _am_result="yes ($s style)"
+    break
+  fi
+done
+rm -f confinc.* confmf.*
+AC_MSG_RESULT([${_am_result}])
+AC_SUBST([am__include])])
+AC_SUBST([am__quote])])
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2014 Free Software Foundation, Inc.
+# Copyright (C) 1997-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -814,7 +797,7 @@ fi
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -843,7 +826,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -890,7 +873,7 @@ AC_LANG_POP([C])])
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -909,7 +892,7 @@ AC_DEFUN([AM_RUN_LOG],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -990,7 +973,7 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+# Copyright (C) 2009-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1050,7 +1033,7 @@ AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
 ])
 
-# Copyright (C) 2001-2014 Free Software Foundation, Inc.
+# Copyright (C) 2001-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1078,7 +1061,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1097,7 +1080,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2014 Free Software Foundation, Inc.
+# Copyright (C) 2004-2018 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,

+ 7 - 6
compile

@@ -1,9 +1,9 @@
 #! /bin/sh
 # Wrapper for compilers which do not understand '-c -o'.
 
-scriptversion=2012-10-14.11; # UTC
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2018 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey@cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -255,7 +255,8 @@ EOF
     echo "compile $scriptversion"
     exit $?
     ;;
-  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
+  icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
     func_cl_wrapper "$@"      # Doesn't return...
     ;;
 esac
@@ -339,9 +340,9 @@ exit $ret
 # Local Variables:
 # mode: shell-script
 # sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:

File diff suppressed because it is too large
+ 358 - 312
config.guess


+ 19 - 5
config.h.in

@@ -6,6 +6,9 @@
 /* Define in built-in ELF support is used */
 #undef BUILTIN_ELF
 
+/* Enable bzlib compression support */
+#undef BZLIBSUPPORT
+
 /* Define for ELF core file support */
 #undef ELFCORE
 
@@ -15,6 +18,9 @@
 /* Define to 1 if you have the `asprintf' function. */
 #undef HAVE_ASPRINTF
 
+/* Define to 1 if you have the <bzlib.h> header file. */
+#undef HAVE_BZLIB_H
+
 /* Define to 1 if you have the `ctime_r' function. */
 #undef HAVE_CTIME_R
 
@@ -74,9 +80,15 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
+/* Define to 1 if you have the `bz2' library (-lbz2). */
+#undef HAVE_LIBBZ2
+
 /* Define to 1 if you have the `gnurx' library (-lgnurx). */
 #undef HAVE_LIBGNURX
 
+/* Define to 1 if you have the `lzma' library (-llzma). */
+#undef HAVE_LIBLZMA
+
 /* Define to 1 if you have the `seccomp' library (-lseccomp). */
 #undef HAVE_LIBSECCOMP
 
@@ -86,6 +98,9 @@
 /* Define to 1 if you have the `localtime_r' function. */
 #undef HAVE_LOCALTIME_R
 
+/* Define to 1 if you have the <lzma.h> header file. */
+#undef HAVE_LZMA_H
+
 /* Define to 1 if mbrtowc and mbstate_t are properly declared. */
 #undef HAVE_MBRTOWC
 
@@ -240,8 +255,7 @@
 /* Define to 1 if you have the <zlib.h> header file. */
 #undef HAVE_ZLIB_H
 
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
 /* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
@@ -316,6 +330,9 @@
 # endif
 #endif
 
+/* Enable xzlib compression support */
+#undef XZLIBSUPPORT
+
 /* Enable zlib compression support */
 #undef ZLIBSUPPORT
 
@@ -358,9 +375,6 @@
    #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

File diff suppressed because it is too large
+ 1249 - 1282
config.sub


File diff suppressed because it is too large
+ 1543 - 1044
configure


+ 39 - 2
configure.ac

@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT([file],[5.37],[christos@astron.com])
+AC_INIT([file],[5.38],[christos@astron.com])
 AM_INIT_AUTOMAKE([subdir-objects foreign])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
@@ -39,6 +39,16 @@ AC_ARG_ENABLE([zlib],
 [AS_HELP_STRING([--disable-zlib], [disable zlib compression support @<:@default=auto@:>@])])
 AC_MSG_RESULT($enable_zlib)
 
+AC_MSG_CHECKING(for bzlib support)
+AC_ARG_ENABLE([bzlib],
+[AS_HELP_STRING([--disable-bzlib], [disable bz2lib compression support @<:@default=auto@:>@])])
+AC_MSG_RESULT($enable_bzlib)
+
+AC_MSG_CHECKING(for xzlib support)
+AC_ARG_ENABLE([xzlib],
+[AS_HELP_STRING([--disable-xzlib], [disable liblzma/xz compression support @<:@default=auto@:>@])])
+AC_MSG_RESULT($enable_xzlib)
+
 AC_MSG_CHECKING(for libseccomp support)
 AC_ARG_ENABLE([libseccomp],
 [AS_HELP_STRING([--disable-libseccomp], [disable libseccomp sandboxing @<:@default=auto@:>@])])
@@ -97,10 +107,15 @@ AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h sys/sy
 if test "$enable_zlib" != "no"; then
   AC_CHECK_HEADERS(zlib.h)
 fi
+if test "$enable_bzlib" != "no"; then
+  AC_CHECK_HEADERS(bzlib.h)
+fi
+if test "$enable_xzlib" != "no"; then
+  AC_CHECK_HEADERS(lzma.h)
+fi
 AC_CHECK_TYPE([sig_t],[AC_DEFINE([HAVE_SIG_T],1,[Have sig_t type])],,[#include <signal.h>])
 
 dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
 AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
 AC_CHECK_MEMBERS([struct stat.st_rdev])
@@ -160,6 +175,12 @@ dnl Checks for libraries
 if test "$enable_zlib" != "no"; then
   AC_CHECK_LIB(z, gzopen)
 fi
+if test "$enable_bzlib" != "no"; then
+  AC_CHECK_LIB(bz2, BZ2_bzCompressInit)
+fi
+if test "$enable_xzlib" != "no"; then
+  AC_CHECK_LIB(lzma, lzma_stream_decoder)
+fi
 if test "$enable_libseccomp" != "no"; then
     AC_CHECK_LIB(seccomp, seccomp_init)
 fi
@@ -179,6 +200,22 @@ fi
 if  test "$ac_cv_header_zlib_h$ac_cv_lib_z_gzopen" = "yesyes"; then
   AC_DEFINE([ZLIBSUPPORT], 1, [Enable zlib compression support])
 fi
+if test "$enable_bzlib" = "yes"; then
+  if test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" != "yesyes"; then
+    AC_MSG_ERROR([bzlib support requested but not found])
+  fi
+fi
+if  test "$ac_cv_header_bzlib_h$ac_cv_lib_bz2_BZ2_bzCompressInit" = "yesyes"; then
+  AC_DEFINE([BZLIBSUPPORT], 1, [Enable bzlib compression support])
+fi
+if test "$enable_xzlib" = "yes"; then
+  if test "$ac_cv_header_lzma_h$ac_cv_lib_lzma_lzma_stream_decoder" != "yesyes"; then
+    AC_MSG_ERROR([xzlib support requested but not found])
+  fi
+fi
+if  test "$ac_cv_header_lzma_h$ac_cv_lib_lzma_lzma_stream_decoder" = "yesyes"; then
+  AC_DEFINE([XZLIBSUPPORT], 1, [Enable xzlib compression support])
+fi
 
 AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile])
 AC_OUTPUT

+ 5 - 5
depcomp

@@ -1,9 +1,9 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2013-05-30.07; # UTC
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2018 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@ scriptversion=2013-05-30.07; # UTC
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -783,9 +783,9 @@ exit 0
 # Local Variables:
 # mode: shell-script
 # sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:

+ 9 - 5
doc/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -198,6 +198,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MINGW = @MINGW@
@@ -302,8 +303,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -499,7 +500,10 @@ ctags CTAGS:
 cscope cscopelist:
 
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \

+ 7 - 4
doc/file.man

@@ -1,5 +1,5 @@
-.\" $File: file.man,v 1.135 2019/03/03 02:32:40 christos Exp $
-.Dd February 18, 2019
+.\" $File: file.man,v 1.138 2019/10/15 18:00:40 christos Exp $
+.Dd July 13, 2019
 .Dt FILE __CSECTION__
 .Os
 .Sh NAME
@@ -212,6 +212,8 @@ Ignored for backwards compatibility.
 Prints details of Compound Document Files.
 .It compress
 Checks for, and looks inside, compressed files.
+.It csv
+Checks Comma Separated Value files.
 .It elf
 Prints ELF file details, provided soft magic tests are enabled and the
 elf magic is found.
@@ -289,7 +291,7 @@ The magic pattern with the highest strength (see the
 option) comes first.
 .It Fl l , Fl Fl list
 Shows a list of patterns and their strength sorted descending by
-.Xr magic 4
+.Xr magic __FSECTION__
 strength
 which is used for the matching (see also the
 .Fl k
@@ -363,10 +365,11 @@ On systems where libseccomp
 is available, the
 .Fl S
 flag disables sandboxing which is enabled by default.
-This option is needed for file to execute external descompressing programs,
+This option is needed for file to execute external decompressing programs,
 i.e. when the
 .Fl z
 flag is specified and the built-in decompressors are not available.
+On systems where sandboxing is not available, this option has no effect.
 .It Fl v , Fl Fl version
 Print the version of the program and exit.
 .It Fl z , Fl Fl uncompress

+ 5 - 3
doc/libmagic.man

@@ -1,4 +1,4 @@
-.\" $File: libmagic.man,v 1.44 2018/09/09 20:33:28 christos Exp $
+.\" $File: libmagic.man,v 1.45 2019/06/08 22:16:24 christos Exp $
 .\"
 .\" Copyright (c) Christos Zoulas 2003, 2018.
 .\" All Rights Reserved.
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd August 18, 2018
+.Dd June 8, 2019
 .Dt LIBMAGIC 3
 .Os
 .Sh NAME
@@ -160,7 +160,9 @@ Don't check for various types of text files.
 .It Dv MAGIC_NO_CHECK_TOKENS
 Don't look for known tokens inside ascii files.
 .It Dv MAGIC_NO_CHECK_JSON
-Don't example JSON files.
+Don't examine JSON files.
+.It Dv MAGIC_NO_CHECK_CSV
+Don't examine CSV files.
 .El
 .Pp
 The

+ 3 - 3
doc/magic.man

@@ -1,4 +1,4 @@
-.\" $File: magic.man,v 1.96 2019/01/21 14:56:53 christos Exp $
+.\" $File: magic.man,v 1.97 2019/11/15 21:03:14 christos Exp $
 .Dd January 21, 2019
 .Dt MAGIC __FSECTION__
 .Os
@@ -44,7 +44,7 @@ This offset can be a negative number if it is:
 The first direct offset of the magic entry (at continuation level 0),
 in which case it is interpreted an offset from end end of the file
 going backwards.
-This works only when a file descriptor to the file is a available and it
+This works only when a file descriptor to the file is available and it
 is a regular file.
 .It
 A continuation offset relative to the end of the last up-level field
@@ -136,7 +136,7 @@ format.
 .It Dv date
 A four-byte value interpreted as a UNIX date.
 .It Dv qdate
-A eight-byte value interpreted as a UNIX date.
+An eight-byte value interpreted as a UNIX date.
 .It Dv ldate
 A four-byte value interpreted as a UNIX-style date, but interpreted as
 local time rather than UTC.

File diff suppressed because it is too large
+ 3501 - 2008
ltmain.sh


File diff suppressed because it is too large
+ 1474 - 1087
m4/libtool.m4


+ 90 - 37
m4/ltoptions.m4

@@ -1,14 +1,14 @@
 # Helper functions for option handling.                    -*- Autoconf -*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
-#   Inc.
+#   Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Gary V. Vaughan, 2004
 #
 # 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 7 ltoptions.m4
+# serial 8 ltoptions.m4
 
 # This is to help aclocal find these macros, as it can't see m4_define.
 AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@@ -29,7 +29,7 @@ m4_define([_LT_SET_OPTION],
 [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
 m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
         _LT_MANGLE_DEFUN([$1], [$2]),
-    [m4_warning([Unknown $1 option `$2'])])[]dnl
+    [m4_warning([Unknown $1 option '$2'])])[]dnl
 ])
 
 
@@ -75,13 +75,15 @@ m4_if([$1],[LT_INIT],[
   dnl
   dnl If no reference was made to various pairs of opposing options, then
   dnl we run the default mode handler for the pair.  For example, if neither
-  dnl `shared' nor `disable-shared' was passed, we enable building of shared
+  dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
   dnl archives by default:
   _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
   _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
   _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
-  		   [_LT_ENABLE_FAST_INSTALL])
+		   [_LT_ENABLE_FAST_INSTALL])
+  _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
+		   [_LT_WITH_AIX_SONAME([aix])])
   ])
 ])# _LT_SET_OPTIONS
 
@@ -112,7 +114,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN],
 [_LT_SET_OPTION([LT_INIT], [dlopen])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `dlopen' option into LT_INIT's first parameter.])
+put the 'dlopen' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -148,7 +150,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
 _LT_SET_OPTION([LT_INIT], [win32-dll])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `win32-dll' option into LT_INIT's first parameter.])
+put the 'win32-dll' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -157,9 +159,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
 
 # _LT_ENABLE_SHARED([DEFAULT])
 # ----------------------------
-# implement the --enable-shared flag, and supports the `shared' and
-# `disable-shared' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-shared flag, and supports the 'shared' and
+# 'disable-shared' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_SHARED],
 [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([shared],
@@ -172,14 +174,14 @@ AC_ARG_ENABLE([shared],
     *)
       enable_shared=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_shared=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
@@ -211,9 +213,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], [])
 
 # _LT_ENABLE_STATIC([DEFAULT])
 # ----------------------------
-# implement the --enable-static flag, and support the `static' and
-# `disable-static' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-static flag, and support the 'static' and
+# 'disable-static' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_STATIC],
 [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([static],
@@ -226,14 +228,14 @@ AC_ARG_ENABLE([static],
     *)
      enable_static=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_static=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
@@ -265,9 +267,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], [])
 
 # _LT_ENABLE_FAST_INSTALL([DEFAULT])
 # ----------------------------------
-# implement the --enable-fast-install flag, and support the `fast-install'
-# and `disable-fast-install' LT_INIT options.
-# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+# implement the --enable-fast-install flag, and support the 'fast-install'
+# and 'disable-fast-install' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'.  If omitted, it defaults to 'yes'.
 m4_define([_LT_ENABLE_FAST_INSTALL],
 [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
 AC_ARG_ENABLE([fast-install],
@@ -280,14 +282,14 @@ AC_ARG_ENABLE([fast-install],
     *)
       enable_fast_install=no
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for pkg in $enableval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$pkg" = "X$p"; then
 	  enable_fast_install=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
     [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
@@ -304,14 +306,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `fast-install' option into LT_INIT's first parameter.])
+the 'fast-install' option into LT_INIT's first parameter.])
 ])
 
 AU_DEFUN([AC_DISABLE_FAST_INSTALL],
 [_LT_SET_OPTION([LT_INIT], [disable-fast-install])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `disable-fast-install' option into LT_INIT's first parameter.])
+the 'disable-fast-install' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:
@@ -319,11 +321,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
 dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
 
 
+# _LT_WITH_AIX_SONAME([DEFAULT])
+# ----------------------------------
+# implement the --with-aix-soname flag, and support the `aix-soname=aix'
+# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
+# is either `aix', `both' or `svr4'.  If omitted, it defaults to `aix'.
+m4_define([_LT_WITH_AIX_SONAME],
+[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
+shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[[5-9]]*,yes)
+  AC_MSG_CHECKING([which variant of shared library versioning to provide])
+  AC_ARG_WITH([aix-soname],
+    [AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
+      [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
+    [case $withval in
+    aix|svr4|both)
+      ;;
+    *)
+      AC_MSG_ERROR([Unknown argument to --with-aix-soname])
+      ;;
+    esac
+    lt_cv_with_aix_soname=$with_aix_soname],
+    [AC_CACHE_VAL([lt_cv_with_aix_soname],
+      [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
+    with_aix_soname=$lt_cv_with_aix_soname])
+  AC_MSG_RESULT([$with_aix_soname])
+  if test aix != "$with_aix_soname"; then
+    # For the AIX way of multilib, we name the shared archive member
+    # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+    # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+    # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+    # the AIX toolchain works better with OBJECT_MODE set (default 32).
+    if test 64 = "${OBJECT_MODE-32}"; then
+      shared_archive_member_spec=shr_64
+    else
+      shared_archive_member_spec=shr
+    fi
+  fi
+  ;;
+*)
+  with_aix_soname=aix
+  ;;
+esac
+
+_LT_DECL([], [shared_archive_member_spec], [0],
+    [Shared archive member basename, for filename based shared library versioning on AIX])dnl
+])# _LT_WITH_AIX_SONAME
+
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
+
+
 # _LT_WITH_PIC([MODE])
 # --------------------
-# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
 # LT_INIT options.
-# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+# MODE is either 'yes' or 'no'.  If omitted, it defaults to 'both'.
 m4_define([_LT_WITH_PIC],
 [AC_ARG_WITH([pic],
     [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
@@ -334,19 +389,17 @@ m4_define([_LT_WITH_PIC],
     *)
       pic_mode=default
       # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
       for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
+	IFS=$lt_save_ifs
 	if test "X$lt_pkg" = "X$lt_p"; then
 	  pic_mode=yes
 	fi
       done
-      IFS="$lt_save_ifs"
+      IFS=$lt_save_ifs
       ;;
     esac],
-    [pic_mode=default])
-
-test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+    [pic_mode=m4_default([$1], [default])])
 
 _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
 ])# _LT_WITH_PIC
@@ -359,7 +412,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE],
 [_LT_SET_OPTION([LT_INIT], [pic-only])
 AC_DIAGNOSE([obsolete],
 [$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `pic-only' option into LT_INIT's first parameter.])
+put the 'pic-only' option into LT_INIT's first parameter.])
 ])
 
 dnl aclocal-1.4 backwards compatibility:

+ 4 - 3
m4/ltsugar.m4

@@ -1,6 +1,7 @@
 # ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
 #
-# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
+# Foundation, Inc.
 # Written by Gary V. Vaughan, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -33,7 +34,7 @@ m4_define([_lt_join],
 # ------------
 # Manipulate m4 lists.
 # These macros are necessary as long as will still need to support
-# Autoconf-2.59 which quotes differently.
+# Autoconf-2.59, which quotes differently.
 m4_define([lt_car], [[$1]])
 m4_define([lt_cdr],
 [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
@@ -44,7 +45,7 @@ m4_define([lt_unquote], $1)
 
 # lt_append(MACRO-NAME, STRING, [SEPARATOR])
 # ------------------------------------------
-# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
 # Note that neither SEPARATOR nor STRING are expanded; they are appended
 # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
 # No SEPARATOR is output if MACRO-NAME was previously undefined (different

+ 6 - 6
m4/ltversion.m4

@@ -1,6 +1,6 @@
 # ltversion.m4 -- version numbers			-*- Autoconf -*-
 #
-#   Copyright (C) 2004 Free Software Foundation, Inc.
+#   Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
 #   Written by Scott James Remnant, 2004
 #
 # This file is free software; the Free Software Foundation gives
@@ -9,15 +9,15 @@
 
 # @configure_input@
 
-# serial 3337 ltversion.m4
+# serial 4179 ltversion.m4
 # This file is part of GNU Libtool
 
-m4_define([LT_PACKAGE_VERSION], [2.4.2])
-m4_define([LT_PACKAGE_REVISION], [1.3337])
+m4_define([LT_PACKAGE_VERSION], [2.4.6])
+m4_define([LT_PACKAGE_REVISION], [2.4.6])
 
 AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.4.2'
-macro_revision='1.3337'
+[macro_version='2.4.6'
+macro_revision='2.4.6'
 _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
 _LT_DECL(, macro_revision, 0)
 ])

+ 4 - 3
m4/lt~obsolete.m4

@@ -1,6 +1,7 @@
 # lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
 #
-#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
+#   Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
+#   Foundation, Inc.
 #   Written by Scott James Remnant, 2004.
 #
 # This file is free software; the Free Software Foundation gives
@@ -11,7 +12,7 @@
 
 # These exist entirely to fool aclocal when bootstrapping libtool.
 #
-# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
 # which have later been changed to m4_define as they aren't part of the
 # exported API, or moved to Autoconf or Automake where they belong.
 #
@@ -25,7 +26,7 @@
 # included after everything else.  This provides aclocal with the
 # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
 # because those macros already exist, or will be overwritten later.
-# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
 #
 # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
 # Yes, that means every name once taken will need to remain here until

+ 13 - 3
magic/Magdir/android

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------
-# $File: android,v 1.12 2019/04/19 00:42:27 christos Exp $
+# $File: android,v 1.16 2019/11/15 21:03:14 christos Exp $
 # Various android related magic entries
 #------------------------------------------------------------
 
@@ -18,8 +18,11 @@
 # Android bootimg format
 # From https://android.googlesource.com/\
 # platform/system/core/+/master/mkbootimg/bootimg.h
+# https://github.com/djrbliss/loki/blob/master/loki.h#L43
 0		string	ANDROID!	Android bootimg
->1024	string	LOKI\01		\b, LOKI'd
+>1024	string	LOKI		\b, LOKI'd
+>>1028	lelong	0			\b (boot)
+>>1028	lelong	1			\b (recovery)
 >8		lelong	>0			\b, kernel
 >>12	lelong	>0			\b (0x%x)
 >16		lelong	>0			\b, ramdisk
@@ -47,7 +50,7 @@
 0	string/b	ANDROID\ BACKUP\n	Android Backup
 # maybe look for some more characteristics like linefeed '\n' or version
 #>16	string		\n			
-# No mime-type defined offically
+# No mime-type defined officially
 !:mime	application/x-google-ab
 !:ext	ab
 # on 2nd line version (often 1, 2 on kitkat 4.4.3+, 4 on 7.1.2)
@@ -178,3 +181,10 @@
 # RES_XML_TYPE = 0x0003 followed by the size of the header (ResXMLTree_header),
 # which is 8 bytes (2 bytes type + 2 bytes header size + 4 bytes size).
 0	lelong	0x00080003	Android binary XML
+
+# Android cryptfs footer
+# From https://android.googlesource.com/\
+# platform/system/vold/+/refs/heads/master/cryptfs.h
+0	lelong	0xd0b5b1c4	Android cryptfs footer
+>4	leshort	x	\b, version: %d
+>6	leshort	x	\b.%d

+ 45 - 44
magic/Magdir/animation

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: animation,v 1.71 2019/04/19 00:42:27 christos Exp $
+# $File: animation,v 1.74 2019/10/29 01:06:20 christos Exp $
 # animation:  file(1) magic for animation/movie formats
 #
 # animation formats
@@ -445,52 +445,43 @@
 # modified by Joerg Jenderek
 # GRR the original test are too common for many DOS files
 # so don't accept as MP3 until we've tested the rate
+# But also beat GEMDOS fonts
 0       beshort&0xFFFE  0xFFFA
 # rates
->2      byte&0xF0       0x10           MPEG ADTS, layer III, v1,  32 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0x20           MPEG ADTS, layer III, v1,  40 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0x30           MPEG ADTS, layer III, v1,  48 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0x40           MPEG ADTS, layer III, v1,  56 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0x50           MPEG ADTS, layer III, v1,  64 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0x60           MPEG ADTS, layer III, v1,  80 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0x70           MPEG ADTS, layer III, v1,  96 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0x80           MPEG ADTS, layer III, v1, 112 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0x90           MPEG ADTS, layer III, v1, 128 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0xA0           MPEG ADTS, layer III, v1, 160 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0xB0           MPEG ADTS, layer III, v1, 192 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0xC0           MPEG ADTS, layer III, v1, 224 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0xD0           MPEG ADTS, layer III, v1, 256 kbps
-!:mime	audio/mpeg
->2      byte&0xF0       0xE0           MPEG ADTS, layer III, v1, 320 kbps
+>2	byte&0xF0	!0	
+>>2	byte&0xF0	!0xF0		MPEG ADTS, layer III, v1
+!:strength +20
 !:mime	audio/mpeg
+>2	byte&0xF0	0x10		\b, 32 kbps
+>2	byte&0xF0	0x20		\b, 40 kbps
+>2	byte&0xF0	0x30		\b, 48 kbps
+>2	byte&0xF0	0x40		\b, 56 kbps
+>2	byte&0xF0	0x50		\b, 64 kbps
+>2	byte&0xF0	0x60		\b, 80 kbps
+>2	byte&0xF0	0x70		\b, 96 kbps
+>2	byte&0xF0	0x80		\b, 112 kbps
+>2	byte&0xF0	0x90		\b, 128 kbps
+>2	byte&0xF0	0xA0		\b, 160 kbps
+>2	byte&0xF0	0xB0		\b, 192 kbps
+>2	byte&0xF0	0xC0		\b, 224 kbps
+>2	byte&0xF0	0xD0		\b, 256 kbps
+>2	byte&0xF0	0xE0		\b, 320 kbps
 # timing
->2      byte&0x0C       0x00           \b, 44.1 kHz
->2      byte&0x0C       0x04           \b, 48 kHz
->2      byte&0x0C       0x08           \b, 32 kHz
+>2	byte&0x0C	0x00		\b, 44.1 kHz
+>2	byte&0x0C	0x04		\b, 48 kHz
+>2	byte&0x0C	0x08		\b, 32 kHz
 # channels/options
->3      byte&0xC0       0x00           \b, Stereo
->3      byte&0xC0       0x40           \b, JntStereo
->3      byte&0xC0       0x80           \b, 2x Monaural
->3      byte&0xC0       0xC0           \b, Monaural
-#>1     byte            ^0x01          \b, Data Verify
-#>2     byte            &0x02          \b, Packet Pad
-#>2     byte            &0x01          \b, Custom Flag
-#>3     byte            &0x08          \b, Copyrighted
-#>3     byte            &0x04          \b, Original Source
-#>3     byte&0x03       1              \b, NR: 50/15 ms
-#>3     byte&0x03       3              \b, NR: CCIT J.17
+>3	byte&0xC0	0x00		\b, Stereo
+>3	byte&0xC0	0x40		\b, JntStereo
+>3	byte&0xC0	0x80		\b, 2x Monaural
+>3	byte&0xC0	0xC0		\b, Monaural
+#>1	byte		^0x01		\b, Data Verify
+#>2	byte		&0x02		\b, Packet Pad
+#>2	byte		&0x01		\b, Custom Flag
+#>3	byte		&0x08		\b, Copyrighted
+#>3	byte		&0x04		\b, Original Source
+#>3	byte&0x03	1		\b, NR: 50/15 ms
+#>3	byte&0x03	3		\b, NR: CCIT J.17
 
 # MP2, M1A
 0       beshort&0xFFFE  0xFFFC         MPEG ADTS, layer II, v1
@@ -887,6 +878,9 @@
 # Vivo video (Wolfram Kleff)
 3	string		\x0D\x0AVersion:Vivo	Vivo video data
 
+# ABC (alembic.io 3d models)
+0	string	0gawa		ABC 3d model
+
 # VRML (Virtual Reality Modelling Language)
 0       string/w        #VRML\ V1.0\ ascii	VRML 1 file
 !:mime	model/vrml
@@ -970,8 +964,7 @@
 # Extension: .bik
 # URL:  https://wiki.multimedia.cx/index.php?title=Bink_Container
 # From: <hoehle@users.sourceforge.net>  2008-07-18
-0	string		BIK	Bink Video
->3	regex		=[a-z]	rev.%s
+0	name		bik
 #>4	ulelong		x	size %d
 >20	ulelong		x	\b, %d
 >24	ulelong		x	\bx%d
@@ -988,6 +981,14 @@
 #>>51	byte&0x10	0	FFT
 #>>51	byte&0x10	!0	DCT
 
+0	string		BIK
+>3	regex		=[bdfghi]	Bink Video rev.%s
+>>0	use		bik
+
+0	string		KB2
+>3	regex		=[adfghi]	Bink Video 2 rev.%s
+>>0	use		bik
+
 # Type:	NUT Container
 # URL:	https://wiki.multimedia.cx/index.php?title=NUT
 # From:	Adam Buchbinder <adam.buchbinder@gmail.com>

+ 36 - 24
magic/Magdir/apple

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: apple,v 1.43 2019/04/19 00:42:27 christos Exp $
+# $File: apple,v 1.44 2019/10/18 15:21:02 christos Exp $
 # apple:  file(1) magic for Apple file formats
 #
 0	search/1/t	FiLeStArTfIlEsTaRt	binscii (apple ][) text
@@ -75,33 +75,45 @@
 >>>>0xb06	pstring x		\b, Volume %s:
 >>>>0xb0e	leshort x		\b, %u Blocks
 >>>>0xb10	leshort x		\b, %u Files
+#
+# Diversi Dos boot loader?
+0		string	\x01\xA8\xAD\x81\xC0\xEE\x09\x08\xAD
+>0x11001	string	\x11\x0F\x03	Apple Diversi Dos Image
+>>0x11006	byte	x		\b, Volume %u
+>>0x11034	byte	x		\b, %u Tracks
+>>0x11035	byte	x		\b, %u Sectors
+>>0x11036	leshort	x		\b, %u bytes per sector
 
 # Type: Apple Emulator 2IMG format
 # From: Radek Vokal <rvokal@redhat.com>
 # Update: Greg Wildman <greg@apple2.org.za>
-0	string		2IMG		Apple ][ 2IMG Disk Image
->4	clear		x
->4	string		XGS!		\b, XGS
->4	string		CTKG		\b, Catakig
->4	string		ShIm		\b, Sheppy's ImageMaker
->4	string		SHEP		\b, Sheppy's ImageMaker
->4	string		WOOF		\b, Sweet 16
->4	string		B2TR		\b, Bernie ][ the Rescue
->4	string		\!nfc		\b, ASIMOV2
->4	string		\>BD\<		\b, Brutal Deluxe's Cadius
->4	string		CdrP		\b, CiderPress
->4	string		Vi][		\b, Virtual ][
->4	string		PRFS		\b, ProFUSE
->4	string		FISH		\b, FishWings
->4	string		RVLW		\b, Revival for Windows
->4	default		x
->>4	string		x		\b, Creator tag "%-4.4s"
->0xc	byte		00		\b, DOS 3.3 sector order
->>0x10	byte		00		\b, Volume 254
->>0x10	byte&0x7f	x		\b, Volume %u
->0xc	byte		01		\b, ProDOS sector order
->>0x14	short		x		\b, %u Blocks
->0xc	byte		02		\b, NIB data
+0		string	2IMG		Apple ][ 2IMG Disk Image
+>4		clear	x
+>4		string	XGS!		\b, XGS
+>4		string	CTKG		\b, Catakig
+>4		string	ShIm		\b, Sheppy's ImageMaker
+>4		string	SHEP		\b, Sheppy's ImageMaker
+>4		string	WOOF		\b, Sweet 16
+>4		string	B2TR		\b, Bernie ][ the Rescue
+>4		string	\!nfc		\b, ASIMOV2
+>4		string	\>BD\<		\b, Brutal Deluxe's Cadius
+>4		string	CdrP		\b, CiderPress
+>4		string	Vi][		\b, Virtual ][
+>4		string	PRFS		\b, ProFUSE
+>4		string	FISH		\b, FishWings
+>4		string	RVLW		\b, Revival for Windows
+>4		default	x
+>>4		string	x		\b, Creator tag "%-4.4s"
+>0xc		byte	00		\b, DOS 3.3 sector order
+>>0x10		byte	00		\b, Volume 254
+>>0x10		byte&0x7f x		\b, Volume %u
+>0xc		byte	01		\b, ProDOS sector order
+# Detect Volume Directory block ($02) + 2mg header offset
+>>0x440		string	\x00\x00\x03\x00
+>>>0x444	byte	&0xF0
+>>>>0x445	string	x		\b, Volume /%s
+>>>>0x469	leshort	x		\b, %u Blocks
+>0xc		byte	02		\b, NIB data
 
 # magic for Newton PDA package formats
 # from Ruda Moura <ruda@helllabs.org>

+ 53 - 7
magic/Magdir/archive

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: archive,v 1.129 2019/05/09 18:58:02 christos Exp $
+# $File: archive,v 1.133 2019/11/15 21:03:14 christos Exp $
 # archive:  file(1) magic for archive formats (see also "msdos" for self-
 #           extracting compressed archives)
 #
@@ -263,7 +263,7 @@
 # NL terminated original package length
 >>>>>&1	string		x		\b, unsplitted size %s
 # NL terminated part length
->>>>>>&1	string	x		\b, part lenght %s
+>>>>>>&1	string	x		\b, part length %s
 # NL terminated package part like n/m
 >>>>>>>&1	string	x		\b, part %s
 # NL terminated package architecture like armhf since dpkg 1.16.1 or later
@@ -439,6 +439,34 @@
 # skip keyword with low entropy
 >12	default		x	TTComp archive, binary, 4K dictionary
 # (version 5.25) labeled the above entry as "TTComp archive data"
+# From:		Joerg Jenderek
+# URL:		https://wiki.68kmla.org/DiskCopy_4.2_format_specification
+# reference:	http://nulib.com/library/FTN.e00005.htm
+0x52	ubeshort	0x0100
+# test for disk size equal or above 400k
+>0x40	ubelong		>409599	Apple DiskCopy 4.2 image
+#!:mime	application/octet-stream
+!:apple	dCpydImg
+!:ext	image/dc42
+# image pascal name padded with NULs like Microsoft Mail
+>>00	pstring/B	x	%s
+# data size in bytes like 409600
+>>0x40	ubelong		x	\b, %u bytes
+# tag size in bytes
+>>0x44	ubelong		>0	\b, 0x%x tag size
+# data checksum
+#>>0x48	ubelong		x	\b, 0x%x checksum
+# tag checksum
+#>>0x4c	ubelong		x	\b, 0x%x tag checksum
+# disk encoding
+>>0x50	ubyte		0	\b, GCR CLV ssdd (400k)
+>>0x50	ubyte		1	\b, GCR CLV dsdd (800k)
+>>0x50	ubyte		2	\b, MFM CAV dsdd (720k)
+>>0x50	ubyte		3	\b, MFM CAV dshd (1440k)
+>>0x50	ubyte		>3	\b, 0x%x encoding
+# format byte
+>>0x51	ubyte		x	\b, 0x%x format
+#>>0x54	ubequad		x	\b, data 0x%16.16llx
 # ESP, could this conflict with Easy Software Products' (e.g.ESP ghostscript) documentation?
 0	string	ESP ESP archive data
 # ZPack
@@ -1168,17 +1196,31 @@
 >>50	string	epub+zip	EPUB document
 !:mime application/epub+zip
 
+# From:	Joerg Jenderek
+# URL:	http://en.wikipedia.org/wiki/CorelDRAW
+# NOTE:	version; til 2 WL-based; from 3 til 13 by ./riff; from 14 zip based
+>>50	string	x-vnd.corel.	 Corel
+>>>62	string	draw.document+zip	Draw drawing, version 14-16
+!:mime	application/x-vnd.corel.draw.document+zip
+!:ext	cdr
+>>>62	string	draw.template+zip	Draw template, version 14-16
+!:mime	application/x-vnd.corel.draw.template+zip
+!:ext	cdrt
+>>>62	string	zcf.draw.document+zip	Draw drawing, version 17-21
+!:mime	application/x-vnd.corel.zcf.draw.document+zip
+!:ext	cdr
+>>>62	string	zcf.draw.template+zip	Draw template, version 17-21
+!:mime	application/x-vnd.corel.zcf.draw.template+zip
+!:ext	cdt/cdrt
+
 #  Catch other ZIP-with-mimetype formats
 #	In a ZIP file, the bytes immediately after a member's contents are
 #	always "PK". The 2 regex rules here print the "mimetype" member's
 #	contents up to the first 'P'. Luckily, most MIME types don't contain
 #	any capital 'P's. This is a kludge.
 #    (mimetype contains "application/<OTHER>")
->>50		string	!epub+zip
->>>50		string	!vnd.oasis.opendocument.
->>>>50		string	!vnd.sun.xml.
->>>>>50		string	!vnd.kde.
->>>>>>38	regex	[!-OQ-~]+		Zip data (MIME type "%s"?)
+>>50		default	x			Zip data
+>>>38		regex	[!-OQ-~]+		(MIME type "%s"?)
 !:mime	application/zip
 #    (mimetype contents other than "application/*")
 >26		string	\x8\0\0\0mimetype
@@ -1290,6 +1332,10 @@
 # Durval Menezes, <jmgthbfile at durval dot com>
 0	string	d13:announce-list	BitTorrent file
 !:mime	application/x-bittorrent
+0	string	d7:comment	BitTorrent file
+!:mime	application/x-bittorrent
+0	string	d4:info		BitTorrent file
+!:mime	application/x-bittorrent
 
 # Atari MSA archive - Teemu Hukkanen <tjhukkan@iki.fi>
 0	beshort 0x0e0f		Atari MSA archive data

+ 37 - 12
magic/Magdir/audio

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: audio,v 1.111 2019/05/08 18:02:45 christos Exp $
+# $File: audio,v 1.118 2019/11/19 05:30:07 christos Exp $
 # audio:  file(1) magic for sound formats (see also "iff")
 #
 # Jan Nicolai Langfeldt (janl@ifi.uio.no), Dan Quinlan (quinlan@yggdrasil.com),
@@ -139,6 +139,11 @@
 
 0x2c	string		SCRM		ScreamTracker III Module sound data
 >0	string		>\0		Title: "%s"
+!:mime	audio/x-s3m
+
+# .stm before it got above .s3m extension
+0x16	string		\!Scream\!	ScreamTracker Module sound data
+>0	string		>\0		Title: "%s"
 
 # Gravis UltraSound patches
 # From <ache@nagual.ru>
@@ -553,6 +558,8 @@
 >21	byte	x	\b.%u
 >20	byte	x	\b.%u
 
+0	string		CC2x		CheeseCutter 2 song
+
 0    	string		RAWADATA	RdosPlay RAW
 
 1068	string		RoR		AMUSIC Adlib Tracker
@@ -614,7 +621,13 @@
 1	string	[licq]			LICQ configuration file
 
 # Atari ST audio files by Dirk Jagdmann <doj@cubic.org>
-0	string		ICE!		SNDH Atari ST music
+# NOTE: Most SNDH music is packed using ICE, which has
+# magic numbers "ICE!" and "Ice!". Some SNDH music is
+# not packed, so we check for both packed and unpacked.
+12	string			SNDH	SNDH Atari ST music
+0	belong&0xFFDFDFFF	0x49434521
+>14	search/40		NDH	SNDH Atari ST music
+>14	search/40		TITL	SNDH Atari ST music
 0	string		SC68\ Music-file\ /\ (c)\ (BeN)jami	sc68 Atari ST music
 
 # musepak support From: "Jiri Pejchal" <jiri.pejchal@gmail.com>
@@ -743,6 +756,8 @@
 >>>>0x78 ubyte		0x03	AY-3-8930,
 >>>>0x78 ubyte		0x10	YM2149,
 >>>>0x78 ubyte		0x11	YM3439,
+>>>>0x78 ubyte		0x12	YMZ284,
+>>>>0x78 ubyte		0x13	YMZ294,
 # VGM 1.61
 >>0x34	ulelong		>0x4C
 >>>0x80	ulelong		>0	DMG,
@@ -993,17 +1008,27 @@
 # Used for audio rips for various consoles.
 # http://fileformats.archiveteam.org/wiki/Portable_Sound_Format
 # Added by David Korth <gerbilsoft@gerbilsoft.com>
-0	string	PSF	Portable Sound Format
+0	string	PSF
+>3	byte	0x01
+>3	byte	0x02
+>3	byte	0x11
+>3	byte	0x12
+>3	byte	0x13
+>3	byte	0x21
+>3	byte	0x22
+>3	byte	0x23
+>3	byte	0x41
+>>0	string	PSF	Portable Sound Format
 !:mime	audio/x-psf
->3	byte	0x01	(Sony PlayStation)
->3	byte	0x02	(Sony PlayStation 2)
->3	byte	0x11	(Sega Saturn)
->3	byte	0x12	(Sega Dreamcast)
->3	byte	0x13	(Sega Mega Drive)
->3	byte	0x21	(Nintendo 64)
->3	byte	0x22	(Game Boy Advance)
->3	byte	0x23	(Super NES)
->3	byte	0x41	(Capcom QSound)
+>>>3	byte	0x01	(Sony PlayStation)
+>>>3	byte	0x02	(Sony PlayStation 2)
+>>>3	byte	0x11	(Sega Saturn)
+>>>3	byte	0x12	(Sega Dreamcast)
+>>>3	byte	0x13	(Sega Mega Drive)
+>>>3	byte	0x21	(Nintendo 64)
+>>>3	byte	0x22	(Game Boy Advance)
+>>>3	byte	0x23	(Super NES)
+>>>3	byte	0x41	(Capcom QSound)
 
 # Atari 8-bit SAP audio format
 # http://asap.sourceforge.net/sap-format.html

+ 1 - 1
magic/Magdir/bsi

@@ -1,4 +1,4 @@
-# Chiasmus is a encryption standard developed by the German Federal
+# Chiasmus is an encryption standard developed by the German Federal
 # Office for Information Security (Bundesamt fuer Sicherheit in der
 # Informationstechnik).
 

+ 2 - 2
magic/Magdir/c-lang

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: c-lang,v 1.27 2019/02/27 16:46:23 christos Exp $
+# $File: c-lang,v 1.28 2019/11/15 21:03:14 christos Exp $
 # c-lang:  file(1) magic for C and related languages programs
 #
 # The strength is to beat standard HTML
@@ -11,7 +11,7 @@
 !:mime	text/x-bcpl
 
 # C
-# Check for class if include is found, otherwise class is beaten by include becouse of lowered strength
+# Check for class if include is found, otherwise class is beaten by include because of lowered strength
 0	search/8192	#include
 >0	regex	\^#include			C
 >>0	regex	\^class[[:space:]]+

+ 157 - 30
magic/Magdir/cad

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: cad,v 1.19 2019/04/19 00:42:27 christos Exp $
+# $File: cad,v 1.20 2019/08/10 13:34:17 christos Exp $
 # autocad:  file(1) magic for cad files
 #
 
@@ -18,29 +18,162 @@
 # 3F86C928&method=display&p_objectid=97F351F5-9C35-4E5E-89C280A93F86C928
 # https://www.bentley.com/products/default.cfm?objectid=A5C2FD43-3AC9-4C71-B682
 # 721C479F&method=display&p_objectid=A5C2FD43-3AC9-4C71-B682C7BE721C479F
-0	string	\010\011\376			Microstation
->3	string	\002
->>30	string	\026\105			DGNFile
->>30	string	\034\105			DGNFile
->>30	string	\073\107			DGNFile
->>30	string	\073\110			DGNFile
->>30	string	\106\107			DGNFile
->>30	string	\110\103			DGNFile
->>30	string	\120\104			DGNFile
->>30	string	\172\104			DGNFile
->>30	string	\172\105			DGNFile
->>30	string	\172\106			DGNFile
->>30	string	\234\106			DGNFile
->>30	string	\273\105			DGNFile
->>30	string	\306\106			DGNFile
->>30	string	\310\104			DGNFile
->>30	string	\341\104			DGNFile
->>30	string	\372\103			DGNFile
->>30	string	\372\104			DGNFile
->>30	string	\372\106			DGNFile
->>30	string	\376\103			DGNFile
->4	string	\030\000\000			CITFile
->4	string	\030\000\003			CITFile
+# 
+# URL:		https://en.wikipedia.org/wiki/MicroStation
+# reference:	http://dgnlib.maptools.org/dgn.html
+#		http://dgnlib.maptools.org/dl/ref18.pdf
+# Update:	Joerg Jenderek
+# Note: verfied by command like `dgndump seed2d_b.dgn`
+# test for level 8 and type 5 or 9
+0	beshort&0x3F73	0x0801
+# level of element like 8
+#>0	ubyte&0x3F	x			\b, level %u
+#>0	ubyte		&0x80			\b, complex
+#>0	ubyte		&0x40			\b, reserved
+# type of element 9~TCB 8~Digitizer setup 5~Group Data Elements
+#>1	ubyte&0x7F	x			\b, type %u
+# words to follow in element: 17H~CEL libray 2FEh~DGN 9FEh,DFEh~CIT
+#>2	uleshort	x			\b, words 0x%4.4x to follow
+# test for 3 reserved 0 bytes in CIT or "conversion" in ViewInfo structure (DGN CEL)
+#>508	ubelong		x			\b, RESERVED %8.8x
+>508	ubelong&0xFFffFF00	=0
+# test for level 8 and type 9 for INGR raster image
+>>0	beshort		0x0809
+# test for length of 1st element is multiple of blocks a 512 bytes
+>>>2	ubyte		0xfe
+>>>>0 	use		ingr-image
+# test for DGN or CEL by jump words (uleshort) forward to next element
+>(2.s*2)	ulong		x
+# 2nd element type: 8~Digitizer~DesiGNfile 1~library cell header other~CIT
+#>>&1		ubyte&0x7F	x		\b, 2nd type %u
+# DGN
+>>&1		ubyte&0x7F	8
+>>>2		uleshort	=0x02FE		Bentley/Intergraph Microstation CAD drawing
+!:mime		application/x-bentley-dgn
+!:ext		dgn
+# The 0x40 bit of this byte is 1 if the file is 3D, otherwise 0
+>>>>1214	ubyte  		&0x40		3D
+>>>>1214	ubyte  		^0x40		2D
+# 2 chars for name of subunits like ft FT in IN mu m mm '\0 '\040
+>>>>1120	string		x		\b, units %-.2s
+# 2 chars for name of master unit like IN in ML SU tn th TH HU mm "\0 "\040 \0\0
+>>>>1122	string		>\0		%-.2s
+#>>>>1120	ubelong		x		\b, units 0x%8.8x
+# element range low,high x y z like xlow=0 08010000h 01080000h
+#>>>>4		ubelong	  	!0		\b, xlow %8.8x
+#>>>>8		ubelong	  	!0		\b, ylow %8.8x
+#>>>>12		ubelong	  	!0		\b, zlow %8.8x
+#>>>>16		ubelong	  	!0		\b, xhigh %8.8x
+#>>>>20		ubelong	  	!0		\b, yhigh %8.8x
+#>>>>24		ubelong	  	!0		\b, zhigh %8.8x
+# graphic group number; all other elements in that group have same non-0 number
+#>>>>28		leshort		x		\b, grphgrp 0x%4.4x
+# words to optional attribute linkage
+#>>>>30		ubyte		x		\b, attindx \%o
+#>>>>31		ubyte		x		\b\%o
+# >>30	string	\026\105			DGNFile
+# >>30	string	\034\105			DGNFile
+# >>30	string	\073\107			DGNFile
+# >>30	string	\073\110			DGNFile
+# >>30	string	\106\107			DGNFile
+# >>30	string	\110\103			DGNFile
+# >>30	string	\120\104			DGNFile
+# >>30	string	\172\104			DGNFile
+# >>30	string	\172\105			DGNFile
+# >>30	string	\172\106			DGNFile
+# >>30	string	\234\106			DGNFile
+# >>30	string	\273\105			DGNFile
+# >>30	string	\306\106			DGNFile
+# >>30	string	\310\104			DGNFile
+# >>30	string	\341\104			DGNFile
+# >>30	string	\372\103			DGNFile
+# >>30	string	\372\104			DGNFile
+# >>30	string	\372\106			DGNFile
+# >>30	string	\376\103			DGNFile
+# elements properties indicator
+#>>>>32		uleshort	!0		\b, properties 0x%4.4x
+# class 0~Primary
+#>>>>>32		uleshort&0x000F	!0		\b, class 0x%4.4x
+# Symbology
+#>>>>>34		uleshort	x		\b, Symbology 0x%4.4x
+# test for 2nd element type 1~library cell header
+>>&1		ubyte&0x7F	1
+# test for 1st element with level 8 and type 5 for cell library
+>>>0		beshort		0x0805		Bentley/Intergraph Microstation CAD cell library
+!:mime		application/x-bentley-cel
+!:ext		cel
+#
+# URL:		http://fileformats.archiveteam.org/wiki/Intergraph_Raster
+# reference:	https://web.archive.org/web/20140903185431/
+#		http://oreilly.com/www/centers/gff/formats/ingr/index.htm
+# note:		verfied by command like `nconvert -fullinfo LONGLAT.CIT`
+# display information for intergraph raster bitmap
+0	name	ingr-image
+# in 5.37 "Microstation CITFile" "Bentley/Intergraph MicroStation CIT raster CAD"
+# DataTypeCode indicates format, depth of the pixel data and used compression 
+>4	uleshort	x			Intergraph raster image
+>>4	uleshort	0x0009			\b, Run-Length Encoded 1-bit
+!:mime	image/x-intergraph-rle
+!:ext	rel
+>>4	uleshort	0x0018			\b, CCITT Group 4 1-bit
+!:mime	image/x-intergraph-cit
+!:ext	cit
+>>4	uleshort	27			\b, Adaptive RLE RGB
+!:mime	image/x-intergraph-rgb
+!:ext	rgb
+>>4	default		x
+>>>4	uleshort	x			\b, Type %u
+!:mime	image/x-intergraph
+# TODO:
+#>4	uleshort	0			\b, no data
+# ...
+#>4	uleshort	0x0045			\b, Continuous Tone CMKY (Uncompressed)
+# ApplicationType: 0~generic raster image 3~drawing, scanning
+# 8~I/IMAGE and MicroStation Imager 9~ModelView
+>6	uleshort	!0			\b, ApplicationType %u
+#>6	uleshort	x			\b, ApplicationType %u
+# XViewOrigin; Raster grid data X origin
+#>8	ulequad		!0			\b, XViewOrigin %llx
+# PixelsPerLine is the number of pixels in a scan line of bitmapp
+>184	ulelong		x			\b, %u x
+# NumberOfLines is height of the raster data in scanlines
+>188	ulelong		x			%u
+# DeviceResolution; resolution of scanning device
+# positive indicates number of micros between lines; negative indicates DPI
+#>192	leshort		x			\b, DeviceResolution %d
+# ScanlineOrient indicates the origin and the orientation of the scan lines
+#>194	ubyte		x			\b, ScanlineOrient %x
+>194	ubyte		x			\b, orientation
+>194	ubyte		&0x01			right
+>194	ubyte		^0x01			left
+>194	ubyte		&0x02			down
+>194	ubyte		^0x02			top
+>194	ubyte		&0x04			horizontal
+>194	ubyte		^0x04			vertical
+# ScannableFlag; Scanline indexing method used
+#>195	ubyte		!0			\b, ScannableFlag 0x%x
+# RotationAngle; Rotation angle of raster data
+#>196	ubequad		!0			\b, RotationAngle 0x%llx
+# SkewAngle; Skew angle of raster data
+#>204	ubequad		!0			\b, SkewAngle %llx
+# DataTypeModifier; Additional raster data format info
+#>212	uleshort	!0			\b, DataTypeModifier 0x%4.4x
+# DesignFile[66]; Name of the design file
+>214	string		>\0			\b, DesignFile %-.66s
+# DatabaseFile[66]; Name of the database file
+>280	string		>\0			\b, DatabaseFile %-.66s
+# ParentGridFile[66]; Name of parent grid file
+>346	string		>\0			\b, ParentGridFile %-.66s
+# FileDescription[80]; Text description of file and contents
+>412	string		>\0			\b, FileDescription %-.80s
+# MinValue
+#>492	ubequad		!0			\b, MinValue 0x%llx
+# MaxValue
+#>500	ubequad		!0			\b, MaxValue 0x%llx
+# Reserved[3]; Unused (always 0)
+#>508	ubelong&0xFFffFF00	x		\b, RESERVED %8.8x
+# GridFileVersion; Grid File Version like 2 3
+#>511	ubyte		x			\b, GridFileVersion %x
 
 # AutoCAD
 # Merge of the different contributions and updates from https://en.wikipedia.org/wiki/Dwg
@@ -140,12 +273,6 @@
 # Phillip Griffith <phillip dot griffith at gmail dot com>
 # AutoCAD magic taken from the Open Design Alliance's OpenDWG specifications.
 #
-0	belong	0x08051700	Bentley/Intergraph MicroStation DGN cell library
-0	belong	0x0809fe02	Bentley/Intergraph MicroStation DGN vector CAD
-0	belong	0xc809fe02	Bentley/Intergraph MicroStation DGN vector CAD
-0	beshort	0x0809		Bentley/Intergraph MicroStation
->0x02	byte	0xfe
->>0x04	beshort	0x1800		CIT raster CAD
 
 # 3DS (3d Studio files)
 0	leshort		0x4d4d

+ 4 - 1
magic/Magdir/commands

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: commands,v 1.60 2019/04/19 00:42:27 christos Exp $
+# $File: commands,v 1.61 2019/10/30 03:16:43 christos Exp $
 # commands:  file(1) magic for various shells and interpreters
 #
 #0	string/w	:			shell archive or script for antique kernel text
@@ -35,6 +35,9 @@
 !:mime	text/x-shellscript
 0	string/wt	#!\ /usr/local/bin/zsh	Paul Falstad's zsh script text executable
 !:mime	text/x-shellscript
+0	search/1	#!/usr/bin/env\ zsh	Paul Falstad's zsh script text executable
+!:mime	text/x-shellscript
+
 0	string/wt	#!\ /usr/local/bin/ash	Neil Brown's ash script text executable
 !:mime	text/x-shellscript
 0	string/wt	#!\ /usr/local/bin/ae	Neil Brown's ae script text executable

+ 10 - 10
magic/Magdir/compress

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: compress,v 1.75 2019/04/19 00:42:27 christos Exp $
+# $File: compress,v 1.77 2019/10/08 20:25:13 christos Exp $
 # compress:  file(1) magic for pure-compression formats (no archives)
 #
 # compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, etc.
@@ -58,11 +58,11 @@
 >>>13	string		09			\b, version 9
 # other gzipped binary like gzipped tar, VirtualBox extension package,...
 >>10	default		x		gzip compressed data
+!:mime	application/gzip
 >>>0	use	gzip-info
 # size of the original (uncompressed) input data modulo 2^32
 >>>-4	ulelong		x		\b, original size modulo 2^32 %u
 # gzipped TAR or VirtualBox extension package
-!:mime	application/gzip
 #!:mime	application/x-compressed-tar
 #!:mime	application/x-virtualbox-vbox-extpack
 # https://www.w3.org/TR/SVG/mimereg.html
@@ -308,25 +308,25 @@
 # Zstandard compressed data
 # https://github.com/facebook/zstd/blob/dev/zstd_compression_format.md
 0     lelong       0xFD2FB522  Zstandard compressed data (v0.2)
-!:mime  application/x-zstd
+!:mime  application/zstd
 0     lelong       0xFD2FB523  Zstandard compressed data (v0.3)
-!:mime  application/x-zstd
+!:mime  application/zstd
 0     lelong       0xFD2FB524  Zstandard compressed data (v0.4)
-!:mime  application/x-zstd
+!:mime  application/zstd
 0     lelong       0xFD2FB525  Zstandard compressed data (v0.5)
-!:mime  application/x-zstd
+!:mime  application/zstd
 0     lelong       0xFD2FB526  Zstandard compressed data (v0.6)
-!:mime  application/x-zstd
+!:mime  application/zstd
 0     lelong       0xFD2FB527  Zstandard compressed data (v0.7)
-!:mime  application/x-zstd
+!:mime  application/zstd
 >4    use          zstd-dictionary-id
 0     lelong       0xFD2FB528  Zstandard compressed data (v0.8+)
-!:mime  application/x-zstd
+!:mime  application/zstd
 >4    use          zstd-dictionary-id
 
 # https://github.com/facebook/zstd/blob/dev/zstd_compression_format.md
 0  lelong    0xEC30A437  Zstandard dictionary
-!:mime  application/x-zstd-dictionary
+!:mime  application/x-std-dictionary
 >4 lelong    x           (ID %u)
 
 # AFX compressed files (Wolfram Kleff)

+ 81 - 14
magic/Magdir/console

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: console,v 1.45 2019/04/19 00:42:27 christos Exp $
+# $File: console,v 1.49 2019/05/27 01:33:32 christos Exp $
 # Console game magic
 # Toby Deshane <hac@shoelace.digivill.net>
 
@@ -508,6 +508,8 @@
 #------------------------------------------------------------------------------
 # Microsoft Xbox executables .xbe (Esa Hyytia <ehyytia@cc.hut.fi>)
 0	string	XBEH	Microsoft Xbox executable
+!:mime	audio/x-xbox-executable
+!:ext	xbe
 # expect base address of 0x10000
 >0x0104                 ulelong =0x10000
 >>(0x0118.l-0x0FFF4)    lestring16 x       \b: "%.40s"
@@ -546,25 +548,90 @@
 0		name	xbox-360-xex-execution-id
 >(0.L+0xC)	byte	x	(%c
 >(0.L+0xD)	byte	x	\b%c
->(0.L+0xE)	beshort	x	\b-%04u)
+>(0.L+0xE)	beshort	x	\b-%04u, media ID:
+>(0.L)		belong	x	%08X)
+
+# Region code (part of Security Info)
+0	name	xbox-360-xex-region-code
+>0	ubelong	0xFFFFFFFF	\b, all regions
+>0	ubelong	!0xFFFFFFFF
+>>0	ubelong	>0		(regions:
+>>0	ubelong&0x000000FF	0x000000FF	USA
+>>0	ubelong&0x00000100	0x00000100	Japan
+>>0	ubelong&0x00000200	0x00000200	China
+>>0	ubelong&0x0000FC00	0x0000FC00	Asia
+>>0	ubelong&0x00FF0000	0x00FF0000	PAL
+>>0	ubelong&0x00FF0000	0x00FE0000	PAL [except AU/NZ]
+>>0	ubelong&0x00FF0000	0x00010000	AU/NZ
+>>0	ubelong&0xFF000000	0xFF000000	Other
+>>0	ubelong	>0		\b)
 
 0	string	XEX2	Microsoft Xbox 360 executable
+!:mime	audio/x-xbox360-executable
+!:ext	xex
 >0x18	search/0x100	\x00\x04\x00\x06
 >>&0	use	xbox-360-xex-execution-id
->(0x010.L+0x178)	ubelong	0xFFFFFFFF	\b, all regions
->(0x010.L+0x178)	ubelong	!0xFFFFFFFF
->>(0x010.L+0x178)	ubelong	>0		(regions:
->>(0x010.L+0x178)	ubelong&0x000000FF	0x000000FF	USA
->>(0x010.L+0x178)	ubelong&0x00000100	0x00000100	Japan
->>(0x010.L+0x178)	ubelong&0x00000200	0x00000200	China
->>(0x010.L+0x178)	ubelong&0x0000FC00	0x0000FC00	Asia
->>(0x010.L+0x178)	ubelong&0x00FF0000	0x00FF0000	PAL
->>(0x010.L+0x178)	ubelong&0x00FF0000	0x00FE0000	PAL [except AU/NZ]
->>(0x010.L+0x178)	ubelong&0x00FF0000	0x00010000	AU/NZ
->>(0x010.L+0x178)	ubelong&0xFF000000	0xFF000000	Other
->>(0x010.L+0x178)	ubelong	>0		\b)
+>(0x010.L+0x178)	use	xbox-360-xex-region-code
 
+0	string	XEX1	Microsoft Xbox 360 executable (XEX1)
+!:mime	audio/x-xbox360-executable
+!:ext	xex
+>0x18	search/0x100	\x00\x04\x00\x06
+>>&0	use	xbox-360-xex-execution-id
+>(0x010.L+0x154)	use	xbox-360-xex-region-code
+
+#------------------------------------------------------------------------------
+# Microsoft Xbox 360 packages
+# From: David Korth <gerbilsoft@gerbilsoft.com>
+# References:
+# - https://free60project.github.io/wiki/STFS.html
+# - https://github.com/xenia-project/xenia/blob/HEAD/src/xenia/kernel/util/xex2_info.h
 
+# TODO: More information for console-signed packages.
+
+0	name	xbox-360-package
+>0x360	byte	x	(%c
+>0x361	byte	x	\b%c
+>0x362	beshort	x	\b-%04u, media ID:
+>0x354	belong	x	%08X)
+>0x344	belong	x	\b, content type:
+>>0x344	belong	0x1		Saved Game
+>>0x344	belong	0x2		Marketplace Content
+>>0x344	belong	0x3		Publisher
+>>0x344	belong	0x1000		Xbox 360 Title
+>>0x344	belong	0x2000		IPTV Pause Buffer
+>>0x344	belong	0x4000		Installed Game
+>>0x344	belong	0x5000		Original Xbox Game
+>>0x344	belong	0x9000		Avatar Item
+>>0x344	belong	0x10000		Profile
+>>0x344	belong	0x20000		Gamer Picture
+>>0x344	belong	0x30000		Theme
+>>0x344	belong	0x40000		Cache File
+>>0x344	belong	0x50000		Storage Download
+>>0x344	belong	0x60000		Xbox Saved Game
+>>0x344	belong	0x70000		Xbox Download
+>>0x344	belong	0x80000		Game Demo
+>>0x344	belong	0x90000		Video
+>>0x344	belong	0xA0000		Game
+>>0x344	belong	0xB0000		Installer
+>>0x344	belong	0xC0000		Game Trailer
+>>0x344	belong	0xD0000		Arcade Title
+>>0x344	belong	0xE0000		XNA
+>>0x344	belong	0xF0000		License Store
+>>0x344	belong	0x100000	Movie
+>>0x344	belong	0x200000	TV
+>>0x344	belong	0x300000	Music Video
+>>0x344	belong	0x400000	Game Video
+>>0x344	belong	0x500000	Podcast Video
+>>0x344	belong	0x600000	Viral Video
+>>0x344	belong	0x2000000	Community Game
+
+0	string	CON\x20	Microsoft Xbox 360 package (console-signed)
+>0	use	xbox-360-package
+0	string	PIRS	Microsoft Xbox 360 package (non-Xbox Live)
+>0	use	xbox-360-package
+0	string	LIVE	Microsoft Xbox 360 package (Xbox Live)
+>0	use	xbox-360-package
 
 # Atari Lynx cartridge dump (EXE/BLL header)
 # From: "Stefan A. Haubenthal" <polluks@web.de>

+ 19 - 18
magic/Magdir/database

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: database,v 1.55 2019/04/19 00:42:27 christos Exp $
+# $File: database,v 1.56 2019/06/14 20:12:00 christos Exp $
 # database:  file(1) magic for various databases
 #
 # extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
@@ -149,7 +149,6 @@
 # updated by Joerg Jenderek at Feb 2013
 # https://www.dbase.com/Knowledgebase/INT/db7_file_fmt.htm
 # https://www.clicketyclick.dk/databases/xbase/format/dbf.html
-# http://home.f1.htw-berlin.de/scheibl/db/intern/dBase.htm
 # inspect VVYYMMDD , where 1<= MM <= 12 and 1<= DD <= 31
 0	ubelong&0x0000FFFF		<0x00000C20
 # skip Infocom game Z-machine
@@ -339,7 +338,7 @@
 # next free block index is positive
 >>>0		ulelong		>0
 # skip many JPG. ZIP, BZ2 by test for reserved bytes NULL , 0|2 , 0|1 , low byte of block size
->>>>17		ubelong&0xFFfdFE00	0x00000000
+>>>>17		ubelong&0xFFfdFEff	0x00000000
 # skip many RAR by test for low byte 0 ,high byte 0|2|even of block size, 0|a|e|d7 , 0|64h
 >>>>>20		ubelong&0xFF01209B	0x00000000
 # dBASE III
@@ -355,36 +354,34 @@
 >>>>>>>>>6	ubeshort	>0
 # skip emacs.PIF
 >>>>>>>>>>4	ushort		0
->>>>>>>>>>>0	use		foxpro-memo-print
+# check for valid FoxPro field type
+>>>>>>>>>>>512	ubelong		<3
+>>>>>>>>>>>>0	use		foxpro-memo-print
 # dBASE III DBT , garbage
->>>>>>>>>6	ubeshort	0
-# skip MM*DD*.bin by test for for reserved NULL byte
->>>>>>>>>>510	ubeshort	0
-# skip TK-DOS11.img image by looking for memo text
->>>>>>>>>>>512	ubelong		<0xfeffff03
-# skip EFI executables by looking for memo text
->>>>>>>>>>>>512	ubelong		>0x1F202020
->>>>>>>>>>>>>513 ubyte		>0
+# skip WORD1XW.DOC with improbably high free block index
+>>>>>>>>>0	lelong		<2205083
 # unusual dBASE III DBT like adressen.dbt
->>>>>>>>>>>>>>0	use		dbase3-memo-print
+>>>>>>>>>>0	use		dbase3-memo-print
 # dBASE III DBT like angest.dbt, or garbage PCX DBF
 >>>>>>>>8	ubelong		!0
 # skip PCX and some DBF by test for for reserved NULL bytes
 >>>>>>>>>510	ubeshort	0
-# skip some DBF by test of invalid version
->>>>>>>>>>0	ubyte		>5
->>>>>>>>>>>0	ubyte		<48
->>>>>>>>>>>>0	use		dbase3-memo-print
+# skip AI070GEP.EPS with improbably high free block index
+>>>>>>>>>>0	lelong		<458766
+>>>>>>>>>>>0	use		dbase3-memo-print
 # dBASE IV DBT with positive block size
 >>>>>>>20	uleshort	>0
 # dBASE IV DBT with valid block length like 512, 1024
 # multiple of 2 in between 16 and 16 K ,implies upper and lower bits are zero
->>>>>>>>20	uleshort&0x800f	0
+# skip also 3600h 3E00h size
+>>>>>>>>20	uleshort&0xE00f	0
 >>>>>>>>>0	use		dbase4-memo-print
 
 #		Print the information of dBase III DBT memo file
 0	name				dbase3-memo-print
 >0	ubyte			x		dBase III DBT
+!:mime	application/x-dbt
+!:ext	dbt
 # instead 3 as version number 0 for unusual examples like biblio.dbt
 >16	ubyte			!3		\b, version number %u
 # Number of next available block for appending data
@@ -395,6 +392,7 @@
 >20	uleshort		!0		\b, block length %u
 # dBase III memo field terminated by \032\032
 >512	string			>\0		\b, 1st item "%s"
+# https://www.clicketyclick.dk/databases/xbase/format/dbt.html
 #		Print the information of dBase IV DBT memo file
 0	name				dbase4-memo-print
 >0		lelong		x		dBase IV DBT
@@ -433,9 +431,12 @@
 # length of memo field
 >>4		lelong		x		\b, field length %d
 >>>8		string		>\0		\b, 1st used item "%s"
+# http://www.dbfree.org/webdocs/1-documentation/0018-developers_stuff_(advanced)/os_related_stuff/xbase_file_format.htm
 #		Print the information of FoxPro FPT memo file
 0	name				foxpro-memo-print
 >0		belong		x		FoxPro FPT
+!:mime	application/x-fpt
+!:ext	fpt
 # Size of blocks for FoxPro ( 64,256 )
 >6		ubeshort	x		\b, blocks size %u
 # next available block

+ 4 - 5
magic/Magdir/elf

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: elf,v 1.77 2019/01/16 19:33:35 christos Exp $
+# $File: elf,v 1.79 2019/12/16 04:24:01 christos Exp $
 # elf:  file(1) magic for ELF executables
 #
 # We have to check the byte order flag to see what byte order all the
@@ -38,7 +38,7 @@
 >0	lelong&0x3		2		relaxed memory ordering,
 
 0	name		elf-pa-risc
->2	leshort		0x0208		1.0
+>2	leshort		0x020b		1.0
 >2	leshort		0x0210		1.1
 >2	leshort		0x0214		2.0
 >0	leshort		&0x0008		(LP64)
@@ -50,9 +50,8 @@
 !:mime	application/x-object
 >16	leshort		2		executable,
 !:mime	application/x-executable
->16	leshort		3		${x?pie executable:shared object},
-
-!:mime	application/x-${x?pie-executable:sharedlib}
+>16	leshort		3		shared object,
+!:mime	application/x-sharedlib
 >16	leshort		4		core file,
 !:mime	application/x-coredump
 # OS-specific

+ 2 - 2
magic/Magdir/espressif

@@ -1,5 +1,5 @@
 
-# $File: espressif,v 1.1 2018/11/20 18:57:17 christos Exp $
+# $File: espressif,v 1.2 2019/11/15 21:03:14 christos Exp $
 # configuration dump of Tasmota firmware for ESP8266 based devices by Espressif
 # URL: https://github.com/arendst/Sonoff-Tasmota/
 # Reference: https://codeload.github.com/arendst/Sonoff-Tasmota/zip/release-6.2/
@@ -8,7 +8,7 @@
 #
 # cfg_holder=4617=0x1209
 0		uleshort	4617
-# remainig settings normally 0x5A+offset XORed; free_1D5[20] empty since 5.12.0e
+# remaining settings normally 0x5A+offset XORed; free_1D5[20] empty since 5.12.0e
 >0x1D5		ubequad		0x2f30313233343536	configuration of Tasmota firmware (ESP8266)
 !:mime	application/x-tasmota-dmp
 !:ext	dmp

+ 25 - 35
magic/Magdir/filesystems

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: filesystems,v 1.128 2019/04/23 15:43:27 christos Exp $
+# $File: filesystems,v 1.131 2019/11/15 23:49:38 christos Exp $
 # filesystems:  file(1) magic for different filesystems
 #
 0	name	partid
@@ -2057,10 +2057,6 @@
 >0x10040	lelong	2		yura hash
 >0x10040	lelong	3		r5 hash
 
-# JFFS - russell@coker.com.au
-0	lelong	0x34383931	Linux Journalled Flash File system, little endian
-0	belong	0x34383931	Linux Journalled Flash File system, big endian
-
 # EST flat binary format (which isn't, but anyway)
 # From: Mark Brown <broonie@sirena.org.uk>
 0	string	ESTFBINR	EST flat binary
@@ -2122,6 +2118,7 @@
 >29	byte	23		\bDesignWare ARC,
 >29	byte	24		\bx86_64,
 >29	byte	25		\bXtensa,
+>29	byte	26		\bRISC-V,
 >30	byte	0		Invalid Image
 >30	byte	1		Standalone Program
 >30	byte	2		OS Kernel Image
@@ -2144,55 +2141,48 @@
 
 # JFFS2 file system
 0	leshort	0x1984		Linux old jffs2 filesystem data little endian
+0	beshort	0x1984		Linux old jffs2 filesystem data big endian
 0	leshort	0x1985		Linux jffs2 filesystem data little endian
+0	beshort	0x1985		Linux jffs2 filesystem data big endian
 
 # Squashfs
-0	string	sqsh	Squashfs filesystem, big endian,
+0	name	squashfs
 >28	beshort	x	version %d.
->30	beshort x	\b%d,
+>30	beshort	x	\b%d,
+>20	beshort 0	uncompressed,
+>20	beshort 1	zlib
+>20	beshort 2	lzma
+>20	beshort 3	lzo
+>20	beshort 4	xz
+>20	beshort 5	lz4
+>20	beshort 6	zstd
+>20	beshort >0	compressed,
 >28	beshort <3
 >>8	belong	x	%d bytes,
 >28	beshort >2
->>28 beshort <4
+>>28	beshort <4
 >>>63	bequad x	%lld bytes,
->>28 beshort >3
+>>28	beshort >3
 >>>40	bequad x	%lld bytes,
 #>>67	belong	x	%d bytes,
 >4	belong	x	%d inodes,
 >28	beshort <2
 >>32	beshort	x	blocksize: %d bytes,
 >28	beshort >1
->>28 beshort <4
+>>28	beshort <4
 >>>51	belong	x	blocksize: %d bytes,
->>28 beshort >3
+>>28	beshort >3
 >>>12	belong	x	blocksize: %d bytes,
->28 beshort <4
+>28	beshort <4
 >>39	bedate	x	created: %s
->28 beshort >3
+>28	beshort >3
 >>8	bedate	x	created: %s
+
+0	string	sqsh	Squashfs filesystem, big endian,
+>0	use	squashfs
+
 0	string	hsqs	Squashfs filesystem, little endian,
->28	leshort	x	version %d.
->30	leshort	x	\b%d,
->28	leshort <3
->>8	lelong	x	%d bytes,
->28	leshort >2
->>28 leshort <4
->>>63	lequad x	%lld bytes,
->>28 leshort >3
->>>40	lequad x	%lld bytes,
-#>>63	lelong	x	%d bytes,
->4	lelong	x	%d inodes,
->28	leshort <2
->>32	leshort	x	blocksize: %d bytes,
->28	leshort >1
->>28 leshort <4
->>>51	lelong	x	blocksize: %d bytes,
->>28 leshort >3
->>>12	lelong	x	blocksize: %d bytes,
->28 leshort <4
->>39	ledate	x	created: %s
->28 leshort >3
->>8	ledate	x	created: %s
+>0	use	^squashfs
 
 # AFS Dump Magic
 # From: Ty Sarna <tsarna@sarna.org>

+ 30 - 26
magic/Magdir/fonts

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: fonts,v 1.41 2019/05/05 16:44:04 christos Exp $
+# $File: fonts,v 1.43 2019/07/16 11:11:31 christos Exp $
 # fonts:  file(1) magic for font data
 #
 0	search/1	FONT		ASCII vfont text
@@ -133,51 +133,55 @@
 # Reference: http://cd.textfiles.com/ataricompendium/BOOK/HTML/APPENDC.HTM#cnt
 #
 # usual case with lightening mask and skewing mask 5555h~UU
-62	ulelong		0x55555555
->0	use		gdos-font
+#62	ulelong		0x55555555
+# skip cl8m8ocofedso.testfile by looking for face size lower/equal 72
+#>2	uleshort	<73
+#>>0	use		gdos-font
 # BOX18.GFT COWBOY30.GFT ROYALK30.GFT
-62	ulelong		0
+#62	ulelong		0
 # skip ISO 9660 CD-ROM ./filesystem by looking for low positive face size
->2	uleshort	>2
-# skip DOS 2.0 backup id file ./msdos by looking for face size lower/equal 48
->>2	uleshort	<49
-# skip MS Windows ICO ./msdos by looking for valid face name
->>>4	ubeshort	>0x1F00
-# skip DOS executable BACKM212.COM by looking for horizontal offset table after header
-#>>>>68	ulelong		>87		OFFSET_OK
->>>>0	use		gdos-font
+#>2	uleshort	>2
+# skip DOS 2.0 backup id file ./msdos by looking for face size lower/equal 72
+#>>2	uleshort	<73
+# skip MS oem.hlp, some Windows ICO ./msdos by looking for valid long name like WYE
+#>>>4	ulelong		>0x001F1f1F
+# skip Microsoft WinWord 2.0 ./msdos by looking for positive offset to font data
+#>>>>76	ulelong		>83
+#>>>>>0	use		gdos-font
 0	name		gdos-font
 >0	uleshort	x		GEM GDOS font
 !:mime	application/x-font-gdos
 # also .eps found like AA070GEP.EPS AI360GEP.EPS
 !:ext	fnt/gtf
-# font name like University Bold
+# font name like Big&Tall, Celtic #s, Courier, University Bold, WYE
 >4	string		x		%.32s
-# face size in points 3-48
+# face size in points 3-72 SLSS03CG.FNT H1CELT72.FNT
 >2	uleshort	x		%u
 # face ID (must be unique)
 >0	uleshort	x		\b, ID 0x%4.4x
-# lowest character index in face (usually 32 for disk-loaded fonts).
-#>36	uleshort	x		\b, low character index %u
-# width of the widest character
+# lowest character index in face (4 but usually 32 for disk-loaded fonts)
+#>36	uleshort	!32		\b, unusual character index %u
+# width of the widest character like 0 8 10 12 16 24 32
 #>50	uleshort	x		\b, %u char width
-# width of the widest character cell
+# width of the widest character cell like 8 11 12 14 15 16 33 67
 #>52	uleshort	x		\b, %u cell width
-# thickening size
+# thickening size in pixel like 0 1 2 3 4 5 6 7 8
 #>58	uleshort	x		\b, %u thick
 # lightening mask to eliminate pixels, usually 5555h
 >62	uleshort	!0x5555		\b, lightening mask 0x%x
 # skewing mask to determine when to perform additional rotation when skewing, usually 5555h
 >64	uleshort	!0x5555		\b, skewing mask 0x%x
-# offset to horizontal offset table 58h~88 5eh
-#>68	ulelong		>88		\b, 0x%x horizontal table offset
-# offset character offset table
+# offset to optional horizontal offset table 0 58h~88 5eh 252h
+#>68	ulelong		x		\b, 0x%x horizontal table offset
+# offset of character offset table 54h for many *.GFT 55h 58h 5Eh 120h 1D4h 202h 220h
 #>72	ulelong		x		\b, 0x%x coffset
-# offset to font data
-#>72	ulelong		x		\b, 0x%x foffset
-# form width in bytes
+# offset to font data like 116h 118h 158 20Ah 20Eh
+>76	ulelong		x		\b, 0x%x foffset
+# form width in bytes like 58 67 156 190 227 317 345
 #>80	uleshort	x		\b, %u fwidth
-# pointer to the next font, set by GDOS after loading
+# form height in bytes like 4 8 11 17 26 56 70 90 120 146 150
+#>82	uleshort	x		\b, %u fheight
+# pointer to the next font like 0 10000h 20000h 30000h 40000h 60000h 80000h E0000h D0000h 
 #>84	ulelong		x		\b, 0x%x noffset
 
 # downloadable fonts for browser (prints type) anthon@mnt.org

+ 80 - 0
magic/Magdir/forth

@@ -0,0 +1,80 @@
+
+#------------------------------------------------------------------------------
+# $File: forth,v 1.1 2019/06/06 19:14:20 christos Exp $
+# forth:  file(1) magic for various Forth environments
+# From: Lubomir Rintel <lkundrak@v3.sk>
+#
+
+# Has a FORTH stack diagram and something that looks very much like a FORTH
+# multi-line word definition. Probably a FORTH source.
+0       regex   \[[:space:]]\\(([[:space:]].*)?\ --\ (.*[[:space:]])?\\)
+>0      regex   \^:\[[:space:]]
+>>0     regex   \^;$				FORTH program
+!:mime  text/x-forth
+
+# Inline word definition complete with a stack diagram
+0       regex   \^:[[:space:]].*[[:space:]]\\(([[:space:]].*)?\ --\ (.*[[:space:]])?\\)[[:space:]].*[[:space:]];$	FORTH program
+!:mime  text/x-forth
+
+# Various dictionary images used by OpenFirware FORTH environent
+
+0	lelong	0xe1a00000
+>8	lelong	0xe1a00000	ARM OpenFirmware FORTH Dictionary,
+>>24	lelong	x		Text length: %d bytes,
+>>28	lelong	x		Data length: %d bytes,
+>>32	lelong	x		Text Relocation Table length: %d bytes,
+>>36	lelong	x		Data Relocation Table length: %d bytes,
+>>40	lelong	x		Entry Point: 0x%08X,
+>>44	lelong	x		BSS length: %d bytes
+
+0	string	MP
+>28	lelong	1		x86 OpenFirmware FORTH Dictionary,
+>>4	leshort	x		%d blocks
+>>2	leshort	x		+ %d bytes,
+>>6	leshort	x		%d relocations,
+>>8	leshort	x		Header length: %d paragraphs,
+>>10	leshort	x		Data Size: %d
+>>12	leshort	x		- %d 4K pages,
+>>14	lelong	x		Initial Stack Pointer: 0x%08X,
+>>20	lelong	x		Entry Point: 0x%08X,
+>>24	lelong	x		First Relocation Item: %d,
+>>26	lelong	x		Overlay Number: %d,
+>>18	leshort	x		Checksum: 0x%08X
+
+0	belong	0x48000020	PowerPC OpenFirmware FORTH Dictionary,
+>4	belong	x		Text length: %d bytes,
+>8	belong	x		Data length: %d bytes,
+>12	belong	x		BSS length: %d bytes,
+>16	belong	x		Symbol Table length: %d bytes,
+>20	belong	x		Entry Point: 0x%08X,
+>24	belong	x		Text Relocation Table length: %d bytes,
+>28	belong	x		Data Relocation Table length: %d bytes
+
+0	lelong	0x10000007	MIPS OpenFirmware FORTH Dictionary,
+>4	lelong	x		Text length: %d bytes,
+>8	lelong	x		Data length: %d bytes,
+>12	lelong	x		BSS length: %d bytes,
+>16	lelong	x		Symbol Table length: %d bytes,
+>20	lelong	x		Entry Point: 0x%08X,
+>24	lelong	x		Text Relocation Table length: %d bytes,
+>28	lelong	x		Data Relocation Table length: %d bytes
+
+# Dictionary images used by minimal C FORTH environments, any platform,
+# using native byte order.
+
+# Weak.
+#0	short	0x5820		cForth 16-bit Dictionary,
+#>2	short	x		Serial: 0x%08X,
+#>4	short	x		Dictionary Start: 0x%08X,
+#>6	short	x		Dictionary Size: %d bytes,
+#>8	short	x		User Area Start: 0x%08X,
+#>10	short	x		User Area Size: %d bytes,
+#>12	short	x		Entry Point: 0x%08X
+
+0	long	0x581120	cForth 32-bit Dictionary,
+>4	long	x		Serial: 0x%08X,
+>8	long	x		Dictionary Start: 0x%08X,
+>12	long	x		Dictionary Size: %d bytes,
+>16	long	x		User Area Start: 0x%08X,
+>20	long	x		User Area Size: %d bytes,
+>24	long	x		Entry Point: 0x%08X

+ 18 - 6
magic/Magdir/frame

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: frame,v 1.13 2015/08/29 07:10:35 christos Exp $
+# $File: frame,v 1.14 2019/11/25 00:31:30 christos Exp $
 # frame:  file(1) magic for FrameMaker files
 #
 # This stuff came on a FrameMaker demo tape, most of which is
@@ -18,12 +18,24 @@
 >11	string		2.0		 (2.0
 >11	string		1.0		 (1.0
 >14	byte		x		  %c)
+# URL:		http://fileformats.archiveteam.org/wiki/Maker_Interchange_Format
+# Reference:	https://help.adobe.com/en_US/framemaker/mifreference/mifref.pdf
+# Update:	Joerg Jenderek 2019 Nov
 0	string		\<MIFFile	FrameMaker MIF (ASCII) file
-!:mime	application/x-mif
->9	string		4.0		 (4.0)
->9	string		3.0		 (3.0)
->9	string		2.0		 (2.0)
->9	string		1.0		 (1.x)
+# https://www.iana.org/assignments/media-types/application/vnd.mif
+!:mime	application/vnd.mif
+# mif most but also find bookTOC.framemif
+!:ext	mif/framemif
+# followed by space~20h
+#>8	ubyte		0x20		\b, space before version
+# 3 characters of version number of the MIF language like 1.0, 2.0 ... 2015 ...
+>9	string		x		(%.3s
+# if not greater sign then display 4th character of version
+>12	ubyte		=0x3e		\b)
+>12	ubyte		!0x3e		\b%c)
+# comment starting with # shows the name+version number of generating program
+>13	search/3	#
+>>&0	string		x		"%s"
 0	search/1	\<MakerDictionary	FrameMaker Dictionary text
 !:mime	application/x-mif
 >17	string		3.0		 (3.0)

+ 5 - 1
magic/Magdir/games

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: games,v 1.17 2019/04/19 00:42:27 christos Exp $
+# $File: games,v 1.18 2019/11/10 19:19:58 christos Exp $
 # games:  file(1) for games
 
 # Fabio Bonelli <fabiobonelli@libero.it>
@@ -299,3 +299,7 @@
 >12	lelong		!0		\b, names: %i
 >28	lelong		!0		\b, imports: %i
 >20	lelong		!0		\b, exports: %i
+
+0	string		ESVG
+>4	lelong		0x00160000
+>10	string		TOC\020		Empire Deluxe for DOS saved game

+ 31 - 1
magic/Magdir/gimp

@@ -1,22 +1,33 @@
 
 #------------------------------------------------------------------------------
-# $File: gimp,v 1.9 2014/04/30 21:41:02 christos Exp $
+# $File: gimp,v 1.10 2019/10/15 18:19:40 christos Exp $
 # GIMP Gradient: file(1) magic for the GIMP's gradient data files (.ggr)
 # by Federico Mena <federico@nuclecu.unam.mx>
 
 0       string/t        GIMP\ Gradient  GIMP gradient data
+#!:mime	text/plain
+!:mime	text/x-gimp-ggr
+!:ext	ggr
 
 # GIMP palette (.gpl)
 # From: Markus Heidelberg <markus.heidelberg@web.de>
 0       string/t        GIMP\ Palette   GIMP palette data
+# URL:		https://docs.gimp.org/en/gimp-concepts-palettes.html
+# Reference:	http://fileformats.archiveteam.org/wiki/GIMP_Palette
+#!:mime	text/plain
+!:mime	text/x-gimp-gpl
+!:ext	gpl
 
 #------------------------------------------------------------------------------
 # XCF:  file(1) magic for the XCF image format used in the GIMP (.xcf) developed
 #       by Spencer Kimball and Peter Mattis
 #       ('Bucky' LaDieu, nega@vt.edu)
 
+# URL:		https://en.wikipedia.org/wiki/XCF_(file_format)
+# Reference:	https://gitlab.gnome.org/GNOME/gimp/blob/master/devel-docs/xcf.txt
 0	string		gimp\ xcf	GIMP XCF image data,
 !:mime	image/x-xcf
+!:ext	xcf
 >9	string		file		version 0,
 >9	string		v		version
 >>10	string		>\0		%s,
@@ -32,8 +43,11 @@
 #       by Spencer Kimball and Peter Mattis
 #       ('Bucky' LaDieu, nega@vt.edu)
 
+# Reference:	http://fileformats.archiveteam.org/wiki/GIMP_Pattern
 20      string          GPAT            GIMP pattern data,
 >24     string          x               %s
+!:mime	image/x-gimp-pat
+!:ext	pat
 
 #------------------------------------------------------------------------------
 # XCF:  file(1) magic for the brushes used in the GIMP (.gbr), developed
@@ -41,7 +55,23 @@
 #       ('Bucky' LaDieu, nega@vt.edu)
 
 20      string          GIMP            GIMP brush data
+# Reference:	http://fileformats.archiveteam.org/wiki/GIMP_Brush
+!:mime	image/x-gimp-gbr
+# some sources also list gpb
+!:ext	gbr
+
+# From:		Joerg Jenderek
+# URL:		https://docs.gimp.org/en/gimp-using-animated-brushes.html
+# Reference:	http://fileformats.archiveteam.org/wiki/GIMP_Animated_Brush
+# share\gimp\2.0\brushes\Legacy\confetti.gih
+0	search/21/b	\040ncells:		GIMP animated brush data
+!:mime	image/x-gimp-gih
+!:ext	gih
 
 # GIMP Curves File
 # From: "Nelson A. de Oliveira" <naoliv@gmail.com>
 0	string	#\040GIMP\040Curves\040File	GIMP curve file
+#!:mime	text/plain
+!:mime	text/x-gimp-curve
+!:ext	/txt
+

+ 13 - 0
magic/Magdir/git

@@ -0,0 +1,13 @@
+
+#------------------------------------------------------------------------------
+# $File: git,v 1.1 2019/10/04 18:46:29 christos Exp $
+# git:  file(1) magic for Git objects
+
+0	string	blob\040
+>5	regex	[0-9]+		Git blob %s
+
+0	string	tree\040
+>5	regex	[0-9]+		Git tree %s
+
+0	string	commit\040
+>7	regex	[0-9]+		Git commit %s

+ 2 - 2
magic/Magdir/icc

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: icc,v 1.5 2017/08/13 00:21:47 christos Exp $
+# $File: icc,v 1.6 2019/11/15 21:03:14 christos Exp $
 # icc:  file(1) magic for International Color Consortium file formats
 
 #
@@ -54,7 +54,7 @@
 !:mime	application/vnd.iccprofile
 # for "ICM" extension only versions 2.x and for Kodak "CC" 2.0 is found
 >>>8	ubyte		=2
-# do not use empty message text to a avoid error like
+# do not use empty message text to avoid error like
 # icc, 82: Warning: Current entry does not yet have a description for adding a EXTENSION type
 # file.exe: could not find any valid magic files!
 >>>>9	ubyte		!0		\ble

+ 281 - 9
magic/Magdir/images

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: images,v 1.160 2019/04/19 00:42:27 christos Exp $
+# $File: images,v 1.171 2019/11/23 16:19:47 christos Exp $
 # images:  file(1) magic for image formats (see also "iff", and "c-lang" for
 # XPM bitmaps)
 #
@@ -498,7 +498,31 @@
 >12	lelong		>0		%d-bit
 
 # Magick Image File Format
-0	string		id=ImageMagick	MIFF image data
+# URL:		https://imagemagick.org/script/miff.php
+# Reference:	http://fileformats.archiveteam.org/wiki/MIFF
+# Update:	Joerg Jenderek
+# http://www.nationalarchives.gov.uk/pronom/fmt/930
+0	search/256/bc	id=imagemagick
+# skip bad ASCII text by following new line~0x0A or space~0x20 character
+#>&0	ubyte		x		\b, next character 0x%x
+# called by TriD ImageMagick Machine independent File Format bitmap
+>&0	ubyte&0xD5	0		MIFF image data
+# https://reposcope.com/mimetype/image/miff
+#!:mime	image/miff
+!:mime	image/x-miff
+!:ext	miff/mif
+# examples with standard file(1) magic
+#>>0	string		=id=ImageMagick	with standard magic
+# examples with unusual file(1) magic like 
+>>0	string		!id=ImageMagick	starting with
+# start with comment (brace) like http://samples.fileformat.info/.../AQUARIUM.MIF
+>>>0	ubyte		=0x7b		comment
+# skip second character which is often a newline and show comment
+>>>>2	string		x		"%s"
+# does not start with comment, probably letters with other case like Id=ImageMagick
+# ImageMagick-7.0.9-2/Magick++/demo/smile_anim.miff
+>>>0	ubyte		!0x7b
+>>>>0	string		>\0		'%-.14s'
 
 # Artisan
 0	long		1123028772	Artisan image data
@@ -572,20 +596,115 @@
 # PC bitmaps (OS/2, Windows BMP files)  (Greg Roelofs, newt@uchicago.edu)
 # https://en.wikipedia.org/wiki/BMP_file_format#DIB_header_.\
 # 28bitmap_information_header.29
+# Note:	variant starting direct with DIB header see
+#	http://fileformats.archiveteam.org/wiki/BMP
+#	verified by ImageMagick version 6.8.9-8 command `identify *.dib`
+0	leshort		40
+# skip bad samples like GAME by looking for valid number of color planes
+>12	uleshort	1		Device independent bitmap graphic
+!:mime	image/bmp
+!:apple	????BMPp
+!:ext	dib
+>>4	lelong		x		\b, %d x
+>>8	lelong		x		%d x
+>>14	leshort		x		%d
+# number of color planes (must be 1) 
+#>>12	uleshort	>1		\b, %u color planes
+# compression method: 0~no 1~RLE 8-bit/pixel 3~Huffman 1D
+#>>16	ulelong		3		\b, Huffman 1D compression
+>>16	ulelong		>0		\b, %u compression
+# image size is the size of raw bitmap; a dummy 0 can be given for BI_RGB bitmaps
+>>20	ulelong		x		\b, image size %u
+# horizontal and vertical resolution of the image (pixel per metre, signed integer) 
+>>24	lelong		>0		\b, resolution %d x
+>>>28	lelong		x		%d px/m
+# number of colors in palette, or 0 to default to 2**n
+#>>32	ulelong		>0		\b, %u colors
+# number of important colors used, or 0 when every color is important
+>>36	ulelong		>0		\b, %u important colors
 0	string		BM
 >14	leshort		12		PC bitmap, OS/2 1.x format
 !:mime	image/x-ms-bmp
 >>18	leshort		x		\b, %d x
 >>20	leshort		x		%d
 >14	leshort		64		PC bitmap, OS/2 2.x format
-!:mime	image/x-ms-bmp
->>18	leshort		x		\b, %d x
->>20	leshort		x		%d
->14	leshort		40		PC bitmap, Windows 3.x format
-!:mime	image/x-ms-bmp
+!:mime	image/bmp
+!:apple	????BMPp
+!:ext	bmp
+# image width and height fields are unsigned integers for OS/2
+>>18	ulelong		x		\b, %u x
+>>22	ulelong		x		%u
+# number of bits per pixel (color depth); found 1 4 8
+>>28	uleshort	>1		x %u
+# x, y coordinates of the hotspot
+>>6	uleshort	>0		\b, hotspot %ux
+>>>8	uleshort	x		\b%u
+>>26	uleshort	>1		\b, %u color planes
+# cbSize; size of file or headers
+>>2	ulelong		x		\b, cbSize %u
+#>>2	ulelong		x		\b, cbSize 0x%x
+# offBits; offset to bitmap data like 56h 5Eh 8Eh 43Eh
+>>10	ulelong			x	\b, bits offset %u
+#>>10	ulelong			x	\b, bits offset 0x%x
+#>>(10.l) ubequad		!0	\b, bits 0x%16.16llx
+# BITMAPV2INFOHEADER	adds RGB bit masks
+>14	leshort		52		PC bitmap, Adobe Photoshop
+!:mime	image/bmp
+!:apple	????BMPp
+!:ext	bmp
+>>18	lelong		x		\b, %d x
+>>22	lelong		x		%d x
+>>28	leshort		x		%d
+# BITMAPV3INFOHEADER	adds alpha channel bit mask
+>14	leshort		56		PC bitmap, Adobe Photoshop with alpha channel mask
+!:mime	image/bmp
+!:apple	????BMPp
+!:ext	bmp
 >>18	lelong		x		\b, %d x
 >>22	lelong		x		%d x
 >>28	leshort		x		%d
+>14	leshort		40
+# jump 4 bytes before end of file/header to skip fmt-116-signature-id-118.dib
+>>(2.l-4)	ulong	x		PC bitmap, Windows 3.x format
+!:mime	image/bmp
+!:apple	????BMPp
+>>>18	lelong		x		\b, %d x
+>>>22	lelong		x		%d
+# 320 x 400		https://en.wikipedia.org/wiki/LOGO.SYS
+>>>18	ulequad		=0x0000019000000140	x
+!:ext	bmp/sys
+>>>18	ulequad		!0x0000019000000140
+# compression method 2~RLE 4-bit/pixel implies also extension rle
+>>>>30	ulelong		2		x
+!:ext	bmp/rle
+>>>>30	default		x		x
+!:ext	bmp
+# number of bits per pixel (color depth); found 1 2 4 8 16 24 32
+>>>28	leshort		x		%d
+# x, y coordinates of the hotspot; there is no hotspot in bitmaps, so values 0
+#>>>6	uleshort	>0		\b, hotspot %ux
+#>>>>8	uleshort	x		\b%u
+# number of color planes (must be 1), except badplanes.bmp for testing
+#>>>26	uleshort	>1		\b, %u color planes
+# compression method: 0~no 1~RLE 8-bit/pixel 2~RLE 4-bit/pixel 3~Huffman 1D 6~RGBA bit field masks
+#>>>30	ulelong		3		\b, Huffman 1D compression
+>>>30	ulelong		>0		\b, %u compression
+# image size is the size of raw bitmap; a dummy 0 can be given for BI_RGB bitmaps
+>>>34	ulelong		>0		\b, image size %u
+# horizontal and vertical resolution of the image (pixel per metre, signed integer) 
+>>>38	lelong		>0		\b, resolution %d x
+>>>>42	lelong		x		%d px/m
+# number of colors in palette 16 256, or 0 to default to 2**n
+#>>>46	ulelong		>0		\b, %u colors
+# number of important colors used, or 0 when every color is important
+>>>50	ulelong		>0		\b, %u important colors
+# cbSize; often size of file
+>>>2	ulelong		x		\b, cbSize %u
+#>>>2	ulelong		x		\b, cbSize 0x%x
+# offBits; offset to bitmap data like 36h 76h BEh 236h 406h 436h 4E6h
+>>>10	ulelong			x	\b, bits offset %u
+#>>>10	ulelong			x	\b, bits offset 0x%x
+#>>>(10.l) ubequad		!0	\b, bits 0x%16.16llxd
 >14	leshort		124		PC bitmap, Windows 98/2000 and newer format
 !:mime	image/x-ms-bmp
 >>18	lelong		x		\b, %d x
@@ -601,13 +720,143 @@
 >>18	lelong		x		\b, %d x
 >>22	lelong		x		%d x
 >>28	leshort		x		%d
-# Too simple - MPi
-#0	string		IC		PC icon data
+# Update:	Joerg Jenderek
+# URL:		http://fileformats.archiveteam.org/wiki/OS/2_Icon
+# Reference:	http://www.fileformat.info
+#		/format/os2bmp/spec/902d5c253f2a43ada39c2b81034f27fd/view.htm
+# Note: verified by command like `deark -l -d3 OS2MEMU.ICO`
+0	string			IC
+# skip Lotus smart icon *.smi by looking for valid hotspot coordinates
+>6	ulelong&0xFF00FF00	=0	OS/2 icon
+# jump 4 bytes before end of header/file and test for accessibility
+#>>(2.l-4) ubelong		x	End of header is OK!
+!:mime	image/x-os2-ico
+!:ext	ico
+# cbSize; size of header or file in bytes like 1ah 120h 420h
+>>2	ulelong			x	\b, cbSize %u
+# xHotspot, yHotspot; coordinates of the hotspot for icons like 16 32
+>>6	uleshort		x	\b, hotspot %ux
+>>8	uleshort		x	\b%u
+# offBits; offset in bytes to the beginning of the bit-map pel data like 20h
+>>10	ulelong			x	\b, bits offset %u
+#>>(10.l) ubequad		x	\b, bits 0x%16.16llx
 #0	string		PI		PC pointer image data
 #0	string		CI		PC color icon data
+0	string		CI
+# test also for valid dib header sizes 12 or 64
+>14	ulelong		<65		OS/2
+# test also for valid hotspot coordinates
+#>>6	ulelong&0xFE00FE00	=0	OS/2
+!:mime	image/x-os2-ico
+!:ext	ico
+>>14	ulelong		12		1.x color icon
+# image width and height fields are unsigned integers for OS/2
+>>>18	uleshort	x		%u x
+# stored height = 2 * real height
+>>>20	uleshort/2	x		%u
+# number of bits per pixel (color depth). Typical 32 24 16 8 4 but only 1 found
+>>>24	uleshort	>1		x %u
+# color planes; must be 1
+#>>>22	uleshort	>1		\b, %u color planes
+>>14	ulelong		64		2.x color icon
+# image width and height
+>>>18	ulelong		x		%u x
+# stored height = 2 * real height
+>>>22	ulelong/2	x		%u
+# number of bits per pixel (color depth). only 1 found
+>>>28	uleshort	>1		x %u
+#>>>26	uleshort	>1		\b, %u color planes
+# compression method: 0~no 3~Huffman 1D
+>>>30	ulelong		3		\b, Huffman 1D compression
+#>>>30	ulelong		>0		\b, %u compression
+# xHotspot, yHotspot; coordinates of the hotspot like 0 1 16 20 32 33 63 64
+>>6	uleshort		x	\b, hotspot %ux
+>>8	uleshort		x	\b%u
+# cbSize; size of header or maybe file in bytes like 1Ah 4Eh 84Eh
+>>2	ulelong			x	\b, cbSize %u
+#>>2	ulelong			x	\b, cbSize %x
+# offBits; offset to bitmap data (pixel array) like E4h 3Ah 66h 6Ah 33Ah 4A4h
+>>10	ulelong			x	\b, bits offset %u
+#>>10	ulelong			x	\b, bits offset 0x%x
+#>>(10.l) ubequad		!0	\b, bits 0x%16.16llx
+# dib header size: 12~Ch~OS/2 1.x 64~40h~OS/2 2.x
+#>>14	ulelong		x		\b, dib header size %u
 #0	string		CP		PC color pointer image data
+# URL:		http://fileformats.archiveteam.org/wiki/OS/2_Pointer
+# Reference:	http://www.fileformat.info/format/os2bmp/egff.htm
+0	string		CP
+# skip CPU-Z Report by checking for valid dib header sizes 12 or 64
+>14	ulelong		<65		OS/2
+# http://extension.nirsoft.net/PTR
+!:mime	image/x-ibm-pointer
+!:ext	ptr
+>>14	ulelong		12		1.x color pointer
+# image width and height fields are unsigned integers for OS/2
+>>>18	uleshort	x		%u x
+# stored height = 2 * real height
+>>>20	uleshort/2	x		%u
+# number of bits per pixel (color depth). Typical 32 24 16 8 4 but only 1 found
+>>>24	uleshort	>1		x %u
+# color planes; must be 1
+#>>>22	uleshort	>1		\b, %u color planes
+>>14	ulelong		64		2.x color pointer
+# image width and height
+>>>18	ulelong		x		%u x
+# stored height = 2 * real height
+>>>22	ulelong/2	x		%u
+# number of bits per pixel (color depth). only 1 found
+>>>28	uleshort	>1		x %u
+#>>>26	uleshort	>1		\b, %u color planes
+# compression method: 0~no 3~Huffman 1D
+>>>30	ulelong		3		\b, Huffman 1D compression
+#>>>30	ulelong		>0		\b, %u compression
+# xHotspot, yHotspot; coordinates of the hotspot like 0 3 4 8 15 16 23 27 31
+>>6	uleshort		x	\b, hotspot %ux
+>>8	uleshort		x	\b%u
+# cbSize; size of header or maybe file in bytes like 1Ah 4Eh
+>>2	ulelong			x	\b, cbSize %u
+#>>2	ulelong			x	\b, cbSize %x
+# offBits; offset to bitmap data (pixel array) like 6Ah A4h E4h 4A4h
+>>10	ulelong			x	\b, bits offset %u
+#>>10	ulelong			x	\b, bits offset 0x%x
+#>>(10.l) ubequad		!0	\b, bits 0x%16.16llx
+# dib header size: 12~Ch~OS/2 1.x 64~40h~OS/2 2.x
+#>>14	ulelong		x		\b, dib header size %u
 # Conflicts with other entries [BABYL]
+# URL:	http://fileformats.archiveteam.org/wiki/BMP#OS.2F2_Bitmap_Array
+# Note:	container for OS/2 icon "IC", color icon "CI", color pointer "CP" or bitmap "BM"
 #0	string		BA		PC bitmap array data
+0	string		BA
+# skip old Emacs RMAIL BABYL ./mail.news by checking for low header size
+>2	ulelong		<0x004c5942	OS/2 graphic array
+!:mime	image/x-os2-graphics
+#!:apple	????BMPf
+# cbSize; size of header like 28h 5Ch
+>>2	ulelong			x	\b, cbSize %u
+#>>2	ulelong			x	\b, cbSize 0x%x
+# offNext; offset to data like 0 48h F2h 4Eh 64h C6h D2h D6h DAh E6h EAh 348h
+>>6	ulelong			>0	\b, data offset %u
+#>>6	ulelong			>0	\b, data offset 0x%x
+#>>(6.l) ubequad		!0	\b, data 0x%16.16llx
+# dimensions of the intended device like 640 x 480 for VGA or 1024 x 768
+>>10	uleshort	>0		\b, display %u
+>>>12	uleshort	>0		x %u
+# usType of first array element
+#>>14	string		x		\b, usType %2.2s
+# 1 space char after "1st"
+# no *.bga examples found https://www.openwith.org/file-extensions/bga/1342
+>>14	string		BM	\b; 1st 
+!:ext	bmp/bga
+>>14	string		CI	\b; 1st 
+!:ext	ico
+>>14	string		CP	\b; 1st 
+!:ext	ico
+>>14	string		IC	\b; 1st 
+!:ext	ico
+# no white-black pointer found
+#>>14	string		PT	\b; 1st 
+#!:ext	
+>>14	indirect	x	
 
 # XPM icons (Greg Roelofs, newt@uchicago.edu)
 0	search/1	/*\ XPM\ */	X pixmap image text
@@ -1960,3 +2209,26 @@
 0	string		XPR0	Microsoft Xbox XPR0 texture
 >0x19	byte	x	\b, format:
 >>0x19	use	xbox-xpr-pixel-format
+
+# ILDA Image Data Transfer Format
+# https://www.ilda.com/resources/StandardsDocs/ILDA_IDTF14_rev011.pdf
+#
+# Updated by Chuck Hein (laser@geekdude.com)
+#
+0	string	ILDA	ILDA Image Data Transfer Format
+>7	byte	0x00	3D Coordinates with Indexed Color
+>7	byte	0x01	2D Coordinates with Indexed Color
+>7	byte	0x02	Color Palette
+>7	byte	0x04	3D Coordinates with True Color
+>7	byte	0x05	2D Coordinates with True Color
+>8	string	>0	\b, palette %s
+>16	string	>0	\b, company %s
+>24	beshort	>0	\b, number of records %d
+>>26	beshort	x	\b, palette number %d
+>>28	beshort	>0	\b, number of frames %d
+>>30	byte	>0	\b, projector number %d
+
+# Dropbox "lepton" compressed jpeg format
+# https://github.com/dropbox/lepton
+0	belong&0xfffff0ff	0xcf84005a	Lepton image file
+>2	byte			x		(version %d)

+ 6 - 1
magic/Magdir/javascript

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: javascript,v 1.1 2012/06/16 13:30:36 christos Exp $
+# $File: javascript,v 1.2 2019/08/05 10:34:26 christos Exp $
 # javascript:  magic for javascript and node.js scripts.
 #
 0	search/1/w	#!/bin/node		Node.js script text executable
@@ -15,3 +15,8 @@
 !:mime application/javascript
 0	search/1	#!/usr/bin/env\ nodejs	Node.js script text executable
 !:mime application/javascript
+# Hermes by Facebook https://hermesengine.dev/
+# https://github.com/facebook/hermes/blob/master/include/hermes/\
+# BCGen/HBC/BytecodeFileFormat.h#L24
+0	lequad		0x1F1903C103BC1FC6	Hermes JavaScript bytecode
+>8	lelong		x			\b, version %d

+ 3 - 3
magic/Magdir/kml

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: kml,v 1.5 2019/04/19 00:42:27 christos Exp $
+# $File: kml,v 1.6 2019/05/21 04:50:10 christos Exp $
 # Type: Google KML, formerly Keyhole Markup Language
 # Future development of this format has been handed
 # over to the Open Geospatial Consortium.
@@ -8,7 +8,7 @@
 # From: Asbjoern Sloth Toennesen <asbjorn@lila.io>
 0 string/t    \<?xml
 >20  search/400 \ xmlns=
->>&0 regex ['"]https://earth.google.com/kml Google KML document
+>>&0 regex ['"]http://earth.google.com/kml Google KML document
 !:mime application/vnd.google-earth.kml+xml
 >>>&1 string 2.0' \b, version 2.0
 >>>&1 string 2.1' \b, version 2.1
@@ -20,7 +20,7 @@
 # Open Geospatial Consortium.
 # https://www.opengeospatial.org/standards/kml/
 # From: Asbjoern Sloth Toennesen <asbjorn@lila.io>
->>&0 regex ['"]https://www.opengis.net/kml OpenGIS KML document
+>>&0 regex ['"]http://www.opengis.net/kml OpenGIS KML document
 !:mime application/vnd.google-earth.kml+xml
 >>>&1 string/t 2.2 \b, version 2.2
 

+ 6 - 1
magic/Magdir/linux

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: linux,v 1.67 2019/04/19 00:42:27 christos Exp $
+# $File: linux,v 1.68 2019/09/11 21:20:56 christos Exp $
 # linux:  file(1) magic for Linux files
 #
 # Values for Linux/i386 binaries, from Daniel Quinlan <quinlan@yggdrasil.com>
@@ -494,3 +494,8 @@
 >207		string		>\0		\b, version %s
 >272		string		>\0		\b, machine %s
 >337		string		>\0		\b, domain %s
+
+# Device Tree files
+0		search/1024	/dts-v1/	Device Tree File (v1)
+# beat c code
+!:strength +14

+ 36 - 3
magic/Magdir/macintosh

@@ -1,13 +1,46 @@
 
 #------------------------------------------------------------------------------
-# $File: macintosh,v 1.29 2019/04/19 00:42:27 christos Exp $
+# $File: macintosh,v 1.30 2019/12/14 20:40:26 christos Exp $
 # macintosh description
 #
 # BinHex is the Macintosh ASCII-encoded file format (see also "apple")
 # Daniel Quinlan, quinlan@yggdrasil.com
-11	string	must\ be\ converted\ with\ BinHex	BinHex binary text
+# Update:	Joerg Jenderek
+# URL:		https://en.wikipedia.org/wiki/BinHex
+# Reference:	http://fileformats.archiveteam.org/wiki/BinHex
+# Note:		only tested with version 4.0 and hqx extension
+# Any text/binary before the characteristic comment sentence is to be ignored like in
+# http://ftp.vim.org/pub/ftp/ftp/infomac/disk/mac-update-40b7.hqx
+0	search/1602	(This\ file\ 
+>&0	use		binhex
+# http://ftp.vim.org/pub/ftp/ftp/infomac/_Disk_&_File/zap-res-forks-101.hqx
+0	search/2652/b	(This\ file\ 
+>&0	use		binhex
+0	name				binhex
+# keep splitted search string format similar like in version 5.37
+>0	string	must\ be\ converted\ with\ BinHex\ 	BinHex binary text, version
+# http://www.macdisk.com/binhexen.php3
+!:apple	BNHQTEXT
+# http://www.faqs.org/faqs/macintosh/comm-faq/part1/
+>>&0	string	1.0					1.0
+!:mime	application/mac-binhex
+!:ext	hex
+>>&0	string	2.0					2.0
+!:mime	application/mac-binhex
+!:ext	hcx
+# BinHex	3.0 never existed
+>>&0	string	4.0					4.0
 !:mime	application/mac-binhex40
->41	string	x					\b, version %.3s
+!:ext	hqx
+# BinHex	5.0 also MacBinary I
+>>&0	string	5.0					5.0
+!:mime	application/mac-binhex40
+!:ext	hqx
+# this should never happen
+>>&0	default	x					
+>>>&0	string	x					%.3s
+!:mime	application/mac-binhex
+!:ext	hqx
 
 # Stuffit archives are the de facto standard of compression for Macintosh
 # files obtained from most archives. (franklsm@tuns.ca)

+ 11 - 2
magic/Magdir/mail.news

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: mail.news,v 1.24 2019/04/19 00:42:27 christos Exp $
+# $File: mail.news,v 1.25 2019/06/21 20:06:05 christos Exp $
 # mail.news:  file(1) magic for mail and news
 #
 # Unfortunately, saved netnews also has From line added in some news software.
@@ -26,7 +26,16 @@
 !:mime	message/rfc822
 0	string/t		Article 	saved news text
 !:mime	message/news
-0	string/t		BABYL		Emacs RMAIL text
+# Reference:	http://quimby.gnus.org/notes/BABYL
+# Update:	Joerg Jenderek
+# Note:		used by Rmail in Emacs version 22 and before
+#		is not text because of characters like Control-L Control-_
+0	string/b		BABYL\ OPTIONS:	Emacs RMAIL
+#0	string/t		BABYL		Emacs RMAIL text
+# https://reposcope.com/mimetype/message/x-gnu-rmail
+!:mime	message/x-gnu-rmail
+# ~/RMAIL
+!:ext	/
 0	string/t		Received:	RFC 822 mail text
 !:mime	message/rfc822
 0	string/t		MIME-Version:	MIME entity text

+ 78 - 1
magic/Magdir/map

@@ -1,7 +1,7 @@
 
 
 #------------------------------------------------------------------------------
-# $File: map,v 1.7 2019/04/30 04:02:04 christos Exp $
+# $File: map,v 1.8 2019/12/01 22:46:23 christos Exp $
 # map:  file(1) magic for Map data
 #
 
@@ -316,6 +316,83 @@
 # LBL:2A9h,SRT:1Dh 25h 27h,TRE:CFh 135h,TRF:5Ah,TYP:5Bh 6Eh 7Ch AEh,RGN:7Dh
 >>0	uleshort	x		\b, header length 0x%x
 
+# URL:		https://www.memotech.franken.de/FileFormats/
+# Reference:	https://www.memotech.franken.de/FileFormats/Garmin_RGN_Format.pdf
+# From:		Joerg Jenderek
+0	string		KpGr		Garmin update
+# format version like: 0064h~1.0
+>0x4	uleshort	!0x0064
+>>4	uleshort/100	x		\b, version %u
+>>4	uleshort%100	x		\b.%u
+# 1st Garmin entry
+>6	use	garmin-entry
+# 2nd Garmin entry
+>(0x6.l+10)	ubyte		x
+>>&0		use		garmin-entry
+# 3rd entry
+>(0x6.l+10)	ubyte		x
+>>&(&0.l+4)	ubyte		x
+>>>&0		use		garmin-entry
+# look again at version to use default clause
+>0x4	uleshort	x
+# test for region content by looking for
+# Garmin *.srf by ./images with normal builder name "SQA" or longer "hales"
+# 1 space after equal sign
+>>0x3a	search/5/s	GARMIN\ BITMAP	\b= 
+!:mime	image/x-garmin-exe
+!:ext	exe
+>>>&0	indirect	x
+# if not bitmap *.srf then region; 1 space after equal sign
+>>0x3a	default		x		\b= 
+!:mime	application/x-garmin-rgn
+!:ext	rgn
+# recursiv embedded
+>>>0x3a	search/5/s	KpGrd
+>>>>&0	indirect	x
+# look for ZIP or JAR archive by ./archive and ./zip
+>>>0x3a	search/5/s	PK\003\004
+>>>>&0	indirect	x
+# TODO: other garmin RGN record content like foo
+#>>0x3a	search/5/s	bar		BAR
+#		display information of Garmin RGN record
+0	name	garmin-entry
+# record length: 2 for Data, for Application often 1Bh sometimes 1Dh, "big" for Region
+#>0	ulelong		x		\b, length 0x%x
+# data record (ID='D') with version content like 0064h~1.0
+>4	ubyte		=0x44
+>>5	uleshort	!0x0064		\b; Data
+>>>5	uleshort/100	x		\b, version %u
+>>>5	uleshort%100	x		\b.%u
+# Application Record (ID='A')
+>4	ubyte		=0x41		\b; App
+# version content like 00c8h~2.0
+>>5	uleshort	!0x00C8
+>>>5	uleshort/100	x		\b, version %u
+>>>5	uleshort%100	x		\b.%u
+# builder name like: SQA sqa build hales
+>>7	string		x		\b, build by %s
+# build date like: Oct 25 1999, Oct 1 2008, Feb 23 2009, Dec 15 2009
+>>>&1	string		x		%s
+# build time like: 11:26:12, 11:45:54, 14:16:13, 18:23:01
+>>>>&1	string		x		%s
+# region record (ID='R')
+>4	ubyte		=0x52		\b; Region
+# region ID:14~fw_all.bin: 78~ZIP, RGN or SRF bitmap; 148~ZIP or JAR; 249~display firmware; 251~WiFi or GCD firmware; 255~ZIP
+>>5	uleshort	x		ID=%u
+# delay in ms: like 0, 500
+>>7	ulelong		!0		\b, %u ms
+# region size (is record length - 10)
+#>>11	ulelong		x		\b, length 0x%x
+# region content like:
+# "KpGr"~recursiv embedded,"GARMIN BITMAP"~Garmin Bitmap *.srf, "PK"~ZIP archive
+#>>15	string		x		\b, content "%s"
+>>15	ubequad		x		\b, content 0x%llx...
+# This does NOT WORK!
+#>>15	indirect	x		\b; contains 
+>4	default		x		\b; other
+# garmin Record ID Identifies the record content like: D A R
+>>4	ubyte		x		ID '%c'
+
 # TOM TOM GPS watches ttbin files:
 # https://github.com/ryanbinns/ttwatch/tree/master/ttbin
 # From: Daniel Lenski

+ 9 - 0
magic/Magdir/modulefile

@@ -0,0 +1,9 @@
+
+#------------------------------------------------------------------------------
+# $File: modulefile,v 1.1 2019/10/15 18:04:40 christos Exp $
+# modulefile:  file(1) magic for user's environment modulefile
+# URL: http://modules.sourceforge.net/
+# Reference: https://modules.readthedocs.io/en/stable/modulefile.html
+# From: Xavier Delaruelle <xavier.delaruelle@cea.fr>
+0	string	#%Module	modulefile
+!:mime	text/x-modulefile

+ 173 - 109
magic/Magdir/msdos

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: msdos,v 1.128 2019/04/19 00:42:27 christos Exp $
+# $File: msdos,v 1.134 2019/10/18 15:16:18 christos Exp $
 # msdos:  file(1) magic for MS-DOS files
 #
 
@@ -61,28 +61,24 @@
 #>>0x18	leshort	0x1c	(Borland compiler)
 #>>0x18	leshort	0x1e	(MS compiler)
 
-# If the relocation table is 0x40 or more bytes into the file, it's definitely
-# not a DOS EXE.
->0x18  leshort >0x3f
-
 # Maybe it's a PE?
->>(0x3c.l) string PE\0\0 PE
+>(0x3c.l)	string		PE\0\0	PE
 !:mime	application/x-dosexec
->>>(0x3c.l+24)	leshort		0x010b	\b32 executable
->>>(0x3c.l+24)	leshort		0x020b	\b32+ executable
->>>(0x3c.l+24)	leshort		0x0107	ROM image
->>>(0x3c.l+24)	default		x	Unknown PE signature
->>>>&0 		leshort		x	0x%x
->>>(0x3c.l+22)	leshort&0x2000	>0	(DLL)
->>>(0x3c.l+92)	leshort		1
+>>(0x3c.l+24)	leshort		0x010b	\b32 executable
+>>(0x3c.l+24)	leshort		0x020b	\b32+ executable
+>>(0x3c.l+24)	leshort		0x0107	ROM image
+>>(0x3c.l+24)	default		x	Unknown PE signature
+>>>&0 		leshort		x	0x%x
+>>(0x3c.l+22)	leshort&0x2000	>0	(DLL)
+>>(0x3c.l+92)	leshort		1
 # Native PEs include ntoskrnl.exe, hal.dll, smss.exe, autochk.exe, and all the
 # drivers in Windows/System32/drivers/*.sys.
->>>>(0x3c.l+22)	leshort&0x2000	>0	(native)
+>>>(0x3c.l+22)	leshort&0x2000	>0	(native)
 !:ext	dll/sys
->>>>(0x3c.l+22)	leshort&0x2000	0	(native)
+>>>(0x3c.l+22)	leshort&0x2000	0	(native)
 !:ext	exe/sys
->>>(0x3c.l+92)	leshort		2
->>>>(0x3c.l+22)	leshort&0x2000	>0	(GUI)
+>>(0x3c.l+92)	leshort		2
+>>>(0x3c.l+22)	leshort&0x2000	>0	(GUI)
 # These could probably be at least partially distinguished from one another by
 # looking for specific exported functions.
 # CPL: Control Panel item
@@ -92,80 +88,95 @@
 # AX: DirectShow source filter
 # IME: Input method editor
 !:ext	dll/cpl/tlb/ocx/acm/ax/ime
->>>>(0x3c.l+22)	leshort&0x2000	0	(GUI)
+>>>(0x3c.l+22)	leshort&0x2000	0	(GUI)
 # Screen savers typically include code from the scrnsave.lib static library, but
 # that's not guaranteed.
 !:ext	exe/scr
->>>(0x3c.l+92)	leshort		3
->>>>(0x3c.l+22)	leshort&0x2000	>0	(console)
+>>(0x3c.l+92)	leshort		3
+>>>(0x3c.l+22)	leshort&0x2000	>0	(console)
 !:ext	dll/cpl/tlb/ocx/acm/ax/ime
->>>>(0x3c.l+22)	leshort&0x2000	0	(console)
+>>>(0x3c.l+22)	leshort&0x2000	0	(console)
 !:ext	exe/com
->>>(0x3c.l+92)	leshort		7	(POSIX)
->>>(0x3c.l+92)	leshort		9	(Windows CE)
->>>(0x3c.l+92)	leshort		10	(EFI application)
->>>(0x3c.l+92)	leshort		11	(EFI boot service driver)
->>>(0x3c.l+92)	leshort		12	(EFI runtime driver)
->>>(0x3c.l+92)	leshort		13	(EFI ROM)
->>>(0x3c.l+92)	leshort		14	(XBOX)
->>>(0x3c.l+92)	leshort		15	(Windows boot application)
->>>(0x3c.l+92)	default		x	(Unknown subsystem
->>>>&0		leshort		x	0x%x)
->>>(0x3c.l+4)	leshort		0x14c	Intel 80386
->>>(0x3c.l+4)	leshort		0x166	MIPS R4000
->>>(0x3c.l+4)	leshort		0x168	MIPS R10000
->>>(0x3c.l+4)	leshort		0x184	Alpha
->>>(0x3c.l+4)	leshort		0x1a2	Hitachi SH3
->>>(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
->>>(0x3c.l+4)	leshort		0x268	Motorola 68000
->>>(0x3c.l+4)	leshort		0x290	PA-RISC
->>>(0x3c.l+4)	leshort		0x366	MIPSIV
->>>(0x3c.l+4)	leshort		0x466	MIPS16 with FPU
->>>(0x3c.l+4)	leshort		0xebc	EFI byte code
->>>(0x3c.l+4)	leshort		0x8664	x86-64
->>>(0x3c.l+4)	leshort		0xc0ee	MSIL
->>>(0x3c.l+4)	default		x	Unknown processor type
->>>>&0		leshort		x	0x%x
->>>(0x3c.l+22)	leshort&0x0200	>0	(stripped to external PDB)
->>>(0x3c.l+22)	leshort&0x1000	>0	system file
->>>(0x3c.l+24)	leshort		0x010b
->>>>(0x3c.l+232) lelong	>0	Mono/.Net assembly
->>>(0x3c.l+24)	leshort		0x020b
->>>>(0x3c.l+248) lelong	>0	Mono/.Net assembly
+# https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
+>>(0x3c.l+92)	leshort		7	(POSIX)
+>>(0x3c.l+92)	leshort		9	(Windows CE)
+>>(0x3c.l+92)	leshort		10	(EFI application)
+>>(0x3c.l+92)	leshort		11	(EFI boot service driver)
+>>(0x3c.l+92)	leshort		12	(EFI runtime driver)
+>>(0x3c.l+92)	leshort		13	(EFI ROM)
+>>(0x3c.l+92)	leshort		14	(XBOX)
+>>(0x3c.l+92)	leshort		15	(Windows boot application)
+>>(0x3c.l+92)	default		x	(Unknown subsystem
+>>>&0		leshort		x	0x%x)
+>>(0x3c.l+4)	leshort		0x14c	Intel 80386
+>>(0x3c.l+4)	leshort		0x166	MIPS R4000
+>>(0x3c.l+4)	leshort		0x168	MIPS R10000
+>>(0x3c.l+4)	leshort		0x184	Alpha
+>>(0x3c.l+4)	leshort		0x1a2	Hitachi SH3
+>>(0x3c.l+4)	leshort		0x1a3	Hitachi SH3 DSP
+>>(0x3c.l+4)	leshort		0x1a8	Hitachi SH5
+>>(0x3c.l+4)	leshort		0x169	MIPS WCE v2
+>>(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		0x1d3	Matsushita AM33
+>>(0x3c.l+4)	leshort		0x1f0	PowerPC
+>>(0x3c.l+4)	leshort		0x1f1	PowerPC with FPU
+>>(0x3c.l+4)	leshort		0x200	Intel Itanium
+>>(0x3c.l+4)	leshort		0x266	MIPS16
+>>(0x3c.l+4)	leshort		0x268	Motorola 68000
+>>(0x3c.l+4)	leshort		0x290	PA-RISC
+>>(0x3c.l+4)	leshort		0x366	MIPSIV
+>>(0x3c.l+4)	leshort		0x466	MIPS16 with FPU
+>>(0x3c.l+4)	leshort		0xebc	EFI byte code
+>>(0x3c.l+4)	leshort		0x5032	RISC-V 32-bit
+>>(0x3c.l+4)	leshort		0x5064	RISC-V 64-bit
+>>(0x3c.l+4)	leshort		0x5128	RISC-V 128-bit
+>>(0x3c.l+4)	leshort		0x9041	Mitsubishi M32R
+>>(0x3c.l+4)	leshort		0x8664	x86-64
+>>(0x3c.l+4)	leshort		0xaa64	Aarch64
+>>(0x3c.l+4)	leshort		0xc0ee	MSIL
+>>(0x3c.l+4)	default		x	Unknown processor type
+>>>&0		leshort		x	0x%x
+>>(0x3c.l+22)	leshort&0x0200	>0	(stripped to external PDB)
+>>(0x3c.l+22)	leshort&0x1000	>0	system file
+>>(0x3c.l+24)	leshort		0x010b
+>>>(0x3c.l+232) lelong	>0	Mono/.Net assembly
+>>(0x3c.l+24)	leshort		0x020b
+>>>(0x3c.l+248) lelong	>0	Mono/.Net assembly
 
 # hooray, there's a DOS extender using the PE format, with a valid PE
 # executable inside (which just prints a message and exits if run in win)
->>>(8.s*16)		string		32STUB	\b, 32rtm DOS extender
->>>(8.s*16)		string		!32STUB	\b, for MS Windows
->>>(0x3c.l+0xf8)	string		UPX0 \b, UPX compressed
->>>(0x3c.l+0xf8)	search/0x140	PEC2 \b, PECompact2 compressed
->>>(0x3c.l+0xf8)	search/0x140	UPX2
->>>>(&0x10.l+(-4))	string		PK\3\4 \b, ZIP self-extracting archive (Info-Zip)
->>>(0x3c.l+0xf8)	search/0x140	.idata
->>>>(&0xe.l+(-4))	string		PK\3\4 \b, ZIP self-extracting archive (Info-Zip)
->>>>(&0xe.l+(-4))	string		ZZ0 \b, ZZip self-extracting archive
->>>>(&0xe.l+(-4))	string		ZZ1 \b, ZZip self-extracting archive
->>>(0x3c.l+0xf8)	search/0x140	.rsrc
->>>>(&0x0f.l+(-4))	string		a\\\4\5 \b, WinHKI self-extracting archive
->>>>(&0x0f.l+(-4))	string		Rar! \b, RAR self-extracting archive
->>>>(&0x0f.l+(-4))	search/0x3000	MSCF \b, InstallShield self-extracting archive
->>>>(&0x0f.l+(-4))	search/32	Nullsoft \b, Nullsoft Installer self-extracting archive
->>>(0x3c.l+0xf8)	search/0x140	.data
->>>>(&0x0f.l)		string		WEXTRACT \b, MS CAB-Installer self-extracting archive
->>>(0x3c.l+0xf8)	search/0x140	.petite\0 \b, Petite compressed
->>>>(0x3c.l+0xf7)	byte		x
->>>>>(&0x104.l+(-4))	string		=!sfx! \b, ACE self-extracting archive
->>>(0x3c.l+0xf8)	search/0x140	.WISE \b, WISE installer self-extracting archive
->>>(0x3c.l+0xf8)	search/0x140	.dz\0\0\0 \b, Dzip self-extracting archive
->>>&(0x3c.l+0xf8)	search/0x100	_winzip_ \b, ZIP self-extracting archive (WinZip)
->>>&(0x3c.l+0xf8)	search/0x100	SharedD \b, Microsoft Installer self-extracting archive
->>>0x30			string		Inno \b, InnoSetup self-extracting archive
+>>(8.s*16)		string		32STUB	\b, 32rtm DOS extender
+>>(8.s*16)		string		!32STUB	\b, for MS Windows
+>>(0x3c.l+0xf8)		string		UPX0 \b, UPX compressed
+>>(0x3c.l+0xf8)		search/0x140	PEC2 \b, PECompact2 compressed
+>>(0x3c.l+0xf8)		search/0x140	UPX2
+>>>(&0x10.l+(-4))	string		PK\3\4 \b, ZIP self-extracting archive (Info-Zip)
+>>(0x3c.l+0xf8)		search/0x140	.idata
+>>>(&0xe.l+(-4))	string		PK\3\4 \b, ZIP self-extracting archive (Info-Zip)
+>>>(&0xe.l+(-4))	string		ZZ0 \b, ZZip self-extracting archive
+>>>(&0xe.l+(-4))	string		ZZ1 \b, ZZip self-extracting archive
+>>(0x3c.l+0xf8)		search/0x140	.rsrc
+>>>(&0x0f.l+(-4))	string		a\\\4\5 \b, WinHKI self-extracting archive
+>>>(&0x0f.l+(-4))	string		Rar! \b, RAR self-extracting archive
+>>>(&0x0f.l+(-4))	search/0x3000	MSCF \b, InstallShield self-extracting archive
+>>>(&0x0f.l+(-4))	search/32	Nullsoft \b, Nullsoft Installer self-extracting archive
+>>(0x3c.l+0xf8)		search/0x140	.data
+>>>(&0x0f.l)		string		WEXTRACT \b, MS CAB-Installer self-extracting archive
+>>(0x3c.l+0xf8)		search/0x140	.petite\0 \b, Petite compressed
+>>>(0x3c.l+0xf7)	byte		x
+>>>>(&0x104.l+(-4))	string		=!sfx! \b, ACE self-extracting archive
+>>(0x3c.l+0xf8)		search/0x140	.WISE \b, WISE installer self-extracting archive
+>>(0x3c.l+0xf8)		search/0x140	.dz\0\0\0 \b, Dzip self-extracting archive
+>>&(0x3c.l+0xf8)	search/0x100	_winzip_ \b, ZIP self-extracting archive (WinZip)
+>>&(0x3c.l+0xf8)	search/0x100	SharedD \b, Microsoft Installer self-extracting archive
+>>0x30			string		Inno \b, InnoSetup self-extracting archive
+
+# If the relocation table is 0x40 or more bytes into the file, it's definitely
+# not a DOS EXE.
+>0x18  leshort >0x3f
 
 # Hmm, not a PE but the relocation table is too high for a traditional DOS exe,
 # must be one of the unusual subformats.
@@ -647,16 +658,84 @@
 >30	byte	12		(4kB sectors)
 
 # Popular applications
-2080	string	Microsoft\ Word\ 6.0\ Document	%s
-!:mime	application/msword
-2080	string	Documento\ Microsoft\ Word\ 6 Spanish Microsoft Word 6 document data
-!:mime	application/msword
-# Pawel Wiecek <coven@i17linuxb.ists.pwr.wroc.pl> (for polish Word)
-2112	string	MSWordDoc			Microsoft Word document data
-!:mime	application/msword
 #
-0	belong	0x31be0000			Microsoft Word Document
+# Update:	Joerg Jenderek
+# URL:		http://fileformats.archiveteam.org/wiki/DOC
+# Reference:	https://web.archive.org/web/20170206041048/
+#		http://www.msxnet.org/word2rtf/formats/ffh-dosword5
+# wIdent+dty
+0	belong	0x31be0000
+# skip droid skeleton like x-fmt-274-signature-id-488.doc
+>128	ubyte		>0  			Microsoft
+>>96	uleshort	=0			Word
 !:mime	application/msword
+!:apple	MSWDWDBN
+# DCX is used in the Unix version.
+!:ext	doc/dcx
+>>>0x6E	ulequad		=0			1.0-4.0
+>>>0x6E	ulequad		!0			5.0-6.0
+>>>0x6E	ulequad		x			(DOS) Document
+# https://web.archive.org/web/20130831064118/http://msxnet.org/word2rtf/formats/write.txt
+>>96	uleshort	!0			Write 3.0 (Windows) Document
+!:mime	application/x-mswrite
+!:apple	MSWDWDBN
+# sometimes also doc like in splitter.doc srchtest.doc
+!:ext	wri/doc
+# wTool must be 0125400 octal
+#>>4	uleshort	!0xAB00			\b, wTool %o
+# reserved; must be zero
+#>>6	ulelong		!0			\b, reserved %u
+# block pointer to the block containing optional file manager information
+#>>0x1C	uleshort	x			\b, at 0x%x info block
+# jump to File manager information block
+>>(0x1C.s*128)	uleshort x
+# test for valid information start; maybe also 0012h
+>>>&-2		uleshort	=0x0014
+# Document ASCIIZ name
+>>>>&0x12	string		x		%s
+# author name
+>>>>>&1		string		x		\b, author %s
+# reviser name
+>>>>>>&1	string		x		\b, reviser %s
+# keywords
+>>>>>>>&1	string		x		\b, keywords %s
+# comment
+>>>>>>>>&1	string		x		\b, comment %s
+# version number
+>>>>>>>>>&1	string		x		\b, version %s
+# date of last change MM/DD/YY
+>>>>>>>>>>&1	string		x		\b, %-.8s
+# creation date MM/DD/YY
+>>>>>>>>>>&9	string		x		created %-.8s
+# file name of print format like NORMAL.STY
+>>0x1E	string		>0			\b, formatted by %-.66s
+# count of pages in whole file for write variant; maybe some times wrong
+>>96	uleshort	>0			\b, %u pages
+# name of the printer driver like HPLASMS
+>>0x62	string		>0			\b, %-.8s printer
+# number of blocks used in the file; seems to be 0 for Word 4.0 and Write 3.0
+>>0x6A	uleshort	>0			\b, %u blocks
+# bit field for corrected text areas
+#>>0x6C	uleshort	x			\b, 0x%x bit field
+# text of document; some times start with 4 non printable characters like CR LF
+>>128	ubyte		x			\b,
+>>>128		ubyte	>0x1F
+>>>>128		string	x			%s
+>>>128		ubyte	<0x20
+>>>>129		ubyte	>0x1F
+>>>>>129	string	x			%s
+>>>>129		ubyte	<0x20
+>>>>>130	ubyte	>0x1F
+>>>>>>130	string	x			%s
+>>>>>130	ubyte	<0x20
+>>>>>>131	ubyte	>0x1F
+>>>>>>>131	string	x			%s
+>>>>>>131	ubyte	<0x20
+>>>>>>>132	ubyte	>0x1F
+>>>>>>>>132	string	x			%s
+>>>>>>>132	ubyte	<0x20
+>>>>>>>>133	ubyte	>0x1F
+>>>>>>>>>133	string	x			%s
 #
 0	string/b	PO^Q`				Microsoft Word 6.0 Document
 !:mime	application/msword
@@ -686,23 +765,15 @@
 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
 #
-# Pawel Wiecek <coven@i17linuxb.ists.pwr.wroc.pl> (for polish Excel)
-2114	string	Biff5		Microsoft Excel 5.0 Worksheet
-!:mime	application/vnd.ms-excel
-# Italian MS-Excel
-2121	string	Biff5		Microsoft Excel 5.0 Worksheet
-!:mime	application/vnd.ms-excel
 0	string/b	\x09\x04\x06\x00\x00\x00\x10\x00	Microsoft Excel Worksheet
 !:mime	application/vnd.ms-excel
+# https://www.macdisk.com/macsigen.php
+!:apple	XCELXLS4
+!:ext	xls
 #
 # Update: Joerg Jenderek
 # URL: https://en.wikipedia.org/wiki/Lotus_1-2-3
@@ -901,10 +972,6 @@
 # windows zips files .dmf
 0	string/b	MDIF\032\000\010\000\000\000\372\046\100\175\001\000\001\036\001\000 MS Windows special zipped file
 
-
-#ico files
-0	string/b	\102\101\050\000\000\000\056\000\000\000\000\000\000\000	Icon for MS Windows
-
 # Windows icons
 # Update: Joerg Jenderek
 # URL: https://en.wikipedia.org/wiki/CUR_(file_format)
@@ -1397,9 +1464,6 @@
 0	string/b	\224\246\056		Microsoft Word Document
 !:mime	application/msword
 
-512	string	R\0o\0o\0t\0\ \0E\0n\0t\0r\0y	Microsoft Word Document
-!:mime	application/msword
-
 # From: "Nelson A. de Oliveira" <naoliv@gmail.com>
 # Magic type for Dell's BIOS .hdr files
 # Dell's .hdr

+ 3 - 1
magic/Magdir/msooxml

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: msooxml,v 1.12 2019/04/19 00:42:27 christos Exp $
+# $File: msooxml,v 1.13 2019/11/27 13:12:55 christos Exp $
 # msooxml:  file(1) magic for Microsoft Office XML
 # From: Ralf Brown <ralf.brown@gmail.com>
 
@@ -19,6 +19,8 @@
 !:mime application/vnd.openxmlformats-officedocument.presentationml.presentation
 >0		string		xl/		Microsoft Excel 2007+
 !:mime application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
+0		string		visio/		Microsoft Visio 2013+
+!:mime application/vnd.ms-visio.drawing.main+xml
 
 # start by checking for ZIP local file header signature
 0		string		PK\003\004

+ 456 - 18
magic/Magdir/ole2compounddocs

@@ -1,33 +1,471 @@
 
 #------------------------------------------------------------------------------
-# $File: ole2compounddocs,v 1.6 2019/04/19 00:42:27 christos Exp $
+# $File: ole2compounddocs,v 1.7 2019/08/02 18:08:18 christos Exp $
 # Microsoft OLE 2 Compound Documents : file(1) magic for Microsoft Structured
 # storage (https://en.wikipedia.org/wiki/Compound_File_Binary_Format)
 # Additional tests for OLE 2 Compound Documents should be under this recipe.
+# reference:	https://www.openoffice.org/sc/compdocfileformat.pdf
 
-0   string  \320\317\021\340\241\261\032\341      OLE 2 Compound Document
+0   string  \320\317\021\340\241\261\032\341
+# https://digital-preservation.github.io/droid/
+# skip droid skeleton like fmt-39-signature-id-128.doc by valid version
+>0x1A	ushort		!0xABAB		OLE 2 Compound Document
+#>0x1C	uleshort		x			\b, endnian 0x%4.4x
+# big endian not tested
+>>0x1C	ubeshort		=0xfffe			\b, big-endian
+>>>546	string	jbjb			: Microsoft Word Document
+!:mime	application/msword
+!:apple	MSWDWDBN
+!:ext	doc
+# Byte Order 0xFFFE means little-endian found in real world applications
+#>>0x1C	uleshort		=0xfffe			\b, little-endian
+>>0x1C	uleshort		=0xfffe
+# From:		Joerg Jenderek
+# Major Version 3 or 4
+>>>0x1A	uleshort		x			\b, v%u
+# Minor Version 32h=50 3Bh=59 3Eh=62
+>>>0x18	uleshort		x			\b.%u
+# SecID of first sector of the directory stream is often 1 but high like 3144h
+>>>48	ulelong			x			\b, SecID 0x%x
+# pointer to root entry only works with standard configuration for SecID ~< 800h
+# Red-Carpet-presentation-1.0-1.sdd sg10.sdv 2000_GA_Annual_Review_Data.xls
+# "ORLEN Factbook 2017.xls" XnView_metadata.doc
+# "Barham, Lisa - Die Shopping-Prinzessinnen.doc" then not recognized
+>>>48	ulelong			>0x800			too big for FILE_BYTES_MAX = 1 MiB
+# Sector Shift Exponent 9~512 for major version 3 or C~4096 for major version 4
+>>>0x1E	uleshort		0xc			\b, blocksize 4096
+# jump to one block (4096 bytes per block) before root storage block
+>>>>(48.l*4096)	ubyte	x
+>>>>>&4095 	use		ole2-directory
+#>>>0x1E	uleshort		9			\b, blocksize 512
+>>>0x1E	uleshort		9
+# jump to one block (512 bytes per block) before root storage block
+# in 5.37 only true for offset ~< FILE_BYTES_MAX=7 MiB defined in ../../src/file.h 
+>>>>(48.l*512)	ubyte		x
+>>>>>&511 	use		ole2-directory
+# check directory entry structure and display types by GUID
+0	name			ole2-directory
+# directory entry name like "Root Entry"
+#>0 	lestring16	x 			\b, 1st %.10s
+# type of the entry; 5~Root storage
+#>66 	ubyte		x			\b, type %x
+# node colour of the entry: 00H ~ Red 01H ~ Black
+#>67 	ubyte		x			\b, color %x
+# the DirIDs of the child nodes. Should both be –1 in the root storage entry
+#>68 	bequad		!0xffffffffffffffff	\b, DirIDs %llx
+# second directory entry name like VisioDocument Control000 
+#>128	lestring16	x \b, 2nd %.20s
+# third directory entry like WordDocument
+#>256	lestring16	x \b, 3rd %.20s
+# forth
+#>384	lestring16	x \b, 4th %.10s
+# 5th
+#>512	lestring16	x \b, 5th %.10s
+# 6th
+#>640	lestring16	x \b, 6th %.10s
+# 7th
+#>768	lestring16	x \b, 7th %.10s
+#	https://wikileaks.org/ciav7p1/cms/page_13762814.html
+#	https://m.blog.naver.com/superman4u/40047693679
+#	https://misc.daniel-marschall.de/projects/guid_analysis/guid.txt
+#	http://www.windowstricks.in/online-windows-guid-converter
+#>80 	ubequad		!0			\b, clsid 0x%16.16llx
+#>>88 	ubequad		x			\b%16.16llx
+# test for "Root Entry" inside directory by type 5 value
+>66 	ubyte		5
+# look for CLSID GUID 0
+>>88 	ubequad		0x0
+>>>80 	ubequad		0x0
 # - Microstation V8 DGN files (www.bentley.com)
+# URL:	https://en.wikipedia.org/wiki/MicroStation
 #   Last update on 10/23/2006 by Lester Hightower
-> 0x480  string  D\000g\000n\000~\000H                : Microstation V8 DGN
+#   07/24/2019 by Joerg Jenderek
+# Second directory entry name like Dgn~H Dgn~S 
+>>>>128 	lestring16	Dgn~			: Microstation V8 CAD
+#!:mime	application/x-ole-storage
+!:mime	application/x-bentley-dgn
+# http://www.q-cad.com/files/samples_cad_files/1344468165.dgn
+!:ext	dgn
+#
+# URL:	http://fileformats.archiveteam.org/wiki/WordPerfect
+# Second directory entry name PerfectOffice_
+>>>>128 	lestring16	PerfectOffice_		: WordPerfect 7-X3 presentations Master, Document or Graphic
+!:mime	application/vnd.wordperfect
+# https://www.macdisk.com/macsigen.php "WPC2" for Wordperfect 2 *.wpd
+!:apple	????WPC7
+!:ext	mst/wpd/wpg
+#
+# URL:	http://fileformats.archiveteam.org/wiki/Microsoft_Works_Word_Processor
+# Second directory entry name MatOST_
+>>>>128 	lestring16	MatOST			: Microsoft Works 3.0 document
+!:mime	application/vnd.ms-works
+!:apple	????AWWP
+!:ext	wps
+#
+# URL:	http://fileformats.archiveteam.org/wiki/Microsoft_Works_Spreadsheet
+# 3rd directory entry name WksSSWorkBook
+>>>>256 	lestring16	WksSSWorkBook		: Microsoft Works 6-9 spreadsheet
+!:mime	application/vnd.ms-works
+!:apple	????AWSS
+!:ext	xlr
+#
+# URL:	http://fileformats.archiveteam.org/wiki/XLS
+# what is the difference to {00020820-0000-0000-c000-000000000046} ?
+# Second directory entry name Workbook
+>>>>128 	lestring16	Workbook
+>>>>>256 	lestring16	!WksSSWorkBook		: Microsoft Excel 97-2003 worksheet 0 clsid
+!:mime	application/vnd.ms-excel
+# https://www.macdisk.com/macsigen.php	XLS5 for Excel 5
+!:apple	????XLS9
+!:ext	xls
+#
+# URL:	http://fileformats.archiveteam.org/wiki/PPT
+# Second directory entry name Object1 Object12 Object35
+>>>>128 	lestring16	Object			: Microsoft PowerPoint 4 presentation
+!:mime	application/vnd.ms-powerpoint
+# https://www.macdisk.com/macsigen.php
+!:apple	????PPT3
+!:ext	ppt
+#
+# URL:	https://www.msoutlook.info/question/164
+# Second directory entry name __CollDataStm
+>>>>128 	lestring16	__CollDataStm		: Microsoft Outlook Send Receive Settings
+#!:mime	application/vnd.ms-outlook
+!:mime	application/x-ms-srs
+# %APPDATA%\Microsoft\Outlook\Outlook.srs
+!:ext	srs
+#
+# URL:	https://www.file-extensions.org/cag-file-extension
+# Second directory entry name Category
+>>>>128 	lestring16	Category		: Microsoft Clip Art Gallery
+#!:mime	application/x-ole-storage
+!:mime	application/x-ms-cag
+!:apple	MScgCGdb
+!:ext	cag/
+#
+# URL:	https://www.filesuffix.com/de/extension/rra
+# 3rd directory entry name StrIndex_StringTable
+>>>>256 	lestring16	StrIndex_StringTable	: Windows temporarily installer
+#!:mime	application/x-ole-storage
+!:mime	application/x-ms-rra
+!:ext	rra
+#
+# URL:	https://www.forensicswiki.org/wiki/Jump_Lists
+# 3rd directory entry name DestList	
+>>>>256 	lestring16	DestList		: Windows jump list
+#!:mime	application/x-ole-storage
+!:mime	application/x-ms-jumplist
+# %APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations\*.automaticDestinations-ms
+!:ext	automaticDestinations-ms
+#
+# URL:	https://en.wikipedia.org/wiki/Windows_thumbnail_cache
+# Second directory entry name 256_
+>>>>128 	lestring16	256_			: Windows thumbnail database 256
+#!:mime	application/x-ole-storage
+!:mime	application/x-ms-thumbnail
+# Thumbs.db
+!:ext	db
+>>>>128 	lestring16	96_			: Windows thumbnail database 96
+!:mime	application/x-ms-thumbnail
+!:ext	db
+# 3rd directory entry name Catalog_
+>>>>256 	lestring16	Catalog			: Windows thumbnail database
+!:mime	application/x-ms-thumbnail
+!:ext	db
+#
+# URL:	https://support.microsoft.com/en-us/help/300887/how-to-use-system-information-msinfo32-command-line-tool-switches
+# Note:	older Microsoft Systeminfo (MSInfo Configuration File of msinfo32); newer use xml based
+# Second directory entry name Control000
+>>>>128 	lestring16	Control000		: Microsoft old Systeminfo
+#!:mime	application/x-ole-storage
+!:mime	application/x-ms-info
+!:ext	nfo
+#
+# URL:	http://fileformats.archiveteam.org/wiki/Corel_Print_House
+# Second directory entry name Thumbnail
+>>>>128 	lestring16	Thumbnail		: Corel PrintHouse image
+#!:mime	application/x-ole-storage
+!:mime	application/x-corel-cph
+!:ext	cph
+# 3rd directory entry name Thumbnail
+>>>>256 	lestring16	Thumbnail		: Corel PrintHouse image
+!:mime	application/x-corel-cph
+!:ext	cph
+#
+# URL:	https://en.wikipedia.org/wiki/Hangul_(word_processor)
+# Note:	"HWP Document File" signature found in FileHeader
+# Second directory entry name FileHeader hint for Thinkfree Office document
+>>>>128 	lestring16	FileHeader		: Hangul (Korean) 5.0 Word Processor File
+#!:mime	application/haansofthwp
+!:mime	application/x-hwp
+# https://example-files.online-convert.com/document/hwp/example.hwp
+!:ext	hwp
+#
+# URL:	https://ask.libreoffice.org/en/question/26303/creating-new-themes-for-the-gallery-not-functioning/
+# Second directory entry name like dd2000 dd2001 dd2036 dd2060 dd2083
+>>>>128 	lestring16	dd2			: StarOffice Gallery view
+#!:mime	application/x-ole-storage
+!:mime	application/x-star-sdv
+!:ext	sdv
+#	remaining null clsid
+>>>>128 	default		x			: UNKNOWN
+!:mime	application/x-ole-storage
+#	look for known clsid GUID
 # - Visio documents
-#   Last update on 10/23/2006 by Lester Hightower
-> 0x480  string  V\000i\000s\000i\000o\000D\000o\000c : Visio Document
-
-# Note: moved & merged Microsoft Office parts from ./msdos Oct 2017
-# Update: Joerg Jenderek
-# from https://filext.com by Derek M Jones <derek@knosof.co.uk>
-# False positive with PPT (also currently this string is too long)
-#0	string/b	\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E\x00\x03\x00\xFE\xFF\x09\x00\x06	Microsoft Installer
-#0	string/b	\320\317\021\340\241\261\032\341	Microsoft Office Document
-#>48	byte	0x1B					Excel Document
-#!:mime application/vnd.ms-excel
->546	string	bjbj			: Microsoft Word Document
+# URL:	http://fileformats.archiveteam.org/wiki/Visio
+#   Last update on 10/23/2006 by Lester Hightower, 07/20/2019 by Joerg Jenderek
+>>88 	ubequad		0xc000000000000046	: Microsoft
+>>>80 	ubequad		0x131a020000000000	Visio 2000-2002 Document, stencil or template
+!:mime	application/vnd.visio
+# VSD~Drawing VSS~Stencil VST~Template 
+!:ext	vsd/vss/vst
+>>>80 	ubequad		0x141a020000000000	Visio 2003-2010 Document, stencil or template
+!:mime	application/vnd.visio
+!:ext	vsd/vss/vst
+#
+# URL:	http://fileformats.archiveteam.org/wiki/Windows_Installer
+>>>80 	ubequad		0x84100c0000000000	Windows Installer Package
+!:mime	application/x-msi
+#!:mime	application/x-ms-win-installer
+!:ext	msi
+>>>80 	ubequad		0x86100c0000000000	Windows Installer Patch
+# ??
+!:mime	application/x-wine-extension-msp
+#!:mime	application/x-ms-msp
+!:ext	msp
+#
+# URL:	http://fileformats.archiveteam.org/wiki/DOC
+>>>80 	ubequad		0x0009020000000000	Word 6-95 document or template
 !:mime	application/msword
-# https://www.macdisk.com/macsigen.php
+# for template MSWDW8TN
 !:apple	MSWDWDBN
 !:ext	doc/dot
->546	string	jbjb			: Microsoft Word Document
+>>>80 	ubequad		0x0609020000000000	Word 97-2003 document or template
 !:mime	application/msword
 !:apple	MSWDWDBN
-!:ext	doc
+# dot for template; no extension on Macintosh
+!:ext	doc/dot/
+#
+# URL:	http://fileformats.archiveteam.org/wiki/Microsoft_Works_Word_Processor
+>>>80 	ubequad		0x0213020000000000	Works 3-4 document or template
+!:mime	application/vnd.ms-works
+!:apple	????AWWP
+# ps for template	https://filext.com/file-extension/PS	bps for backup
+!:ext	wps/ps/bps
+#
+# URL:	http://fileformats.archiveteam.org/wiki/Microsoft_Works_Database
+>>>80 	ubequad		0x0313020000000000	Works 3-4 database or template
+!:mime	application/vnd.ms-works-db
+# https://www.macdisk.com/macsigen.php
+!:apple	????AWDB
+# db for template www.file-extensions.org/db-file-extension-microsoft-works-data bdb for backup
+!:ext	wdb/db/bdb
+#
+# URL:	https://en.wikipedia.org/wiki/Microsoft_Excel
+>>>80 	ubequad		0x1008020000000000	Excel 5-95 worksheet, addin or template
+!:mime	application/vnd.ms-excel
+# https://www.macdisk.com/macsigen.php
+!:apple	????XLS5
+# worksheet/addin/template/no extension on Macintosh
+!:ext	xls/xla/xlt/
+#
+>>>80 	ubequad		0x2008020000000000	Excel 97-2003
+!:mime	application/vnd.ms-excel
+# https://www.macdisk.com/macsigen.php	XLS5 for Excel 5
+!:apple	????XLS9
+# 3nd directory entry name
+>>>>256 	lestring16	_VBA_PROJECT_CUR	addin
+!:ext	xla/
+# 4th directory entry name
+>>>>384 	lestring16	_VBA_PROJECT_CUR	addin
+!:ext	xla
+#!:ext	xla/
+>>>>256 	default		x			worksheet or template
+!:ext	xls/xlt
+#!:ext	xls/xlt/
+#
+# URL:	http://fileformats.archiveteam.org/wiki/OLE2
+>>>80 	ubequad		0x0b0d020000000000	Outlook 97-2003 item
+#>>>80 	ubequad		0x0b0d020000000000	Outlook 97-2003 Message
+#!:mime	application/vnd.ms-outlook
+!:mime	application/x-ms-msg
+!:ext	msg
+# URL:	https://wiki.fileformat.com/email/oft/
+>>>80 	ubequad		0x46f0060000000000	Outlook 97-2003 item template
+#!:mime	application/vnd.ms-outlook
+!:mime	application/x-ms-oft
+!:ext	oft
+#
+# URL:	http://fileformats.archiveteam.org/wiki/PPT
+>>>80 	ubequad		0x5148040000000000	PowerPoint 4.0 presentation
+!:mime	application/vnd.ms-powerpoint
+# https://www.macdisk.com/macsigen.php
+!:apple	????PPT3
+!:ext	ppt
+#??
+# URL:	http://www.checkfilename.com/view-details/Microsoft-Works/RespageIndex/0/sTab/2/
+>>88 	ubequad		0xa29a00aa004a1a72	: Microsoft
+# URL:	http://fileformats.archiveteam.org/wiki/Microsoft_Works_Word_Processor
+>>>80 	ubequad		0xc2dbcd28e20ace11	Works 4 document
+!:mime	application/vnd.ms-works
+!:apple	????AWWP
+!:ext	wps
+#
+# URL:	http://fileformats.archiveteam.org/wiki/Microsoft_Works_Database
+>>>80 	ubequad		0xc3dbcd28e20ace11	Works 4 database
+!:mime	application/vnd.ms-works-db
+!:apple	????AWDB
+!:ext	wdb/bdb
+#??
+>>88 	ubequad		0xa40700c04fb932ba	: Microsoft
+# URL:	http://fileformats.archiveteam.org/wiki/Microsoft_Works_Word_Processor
+>>>80 	ubequad		0xb25aa40e0a9ed111	Works 5-6 document
+!:mime	application/vnd.ms-works
+!:apple	????AWWP
+!:ext	wps
+#??
+# URL:	http://fileformats.archiveteam.org/wiki/Microsoft_Publisher
+>>88 	ubequad		0x00c0000000000046	: Microsoft
+>>>80 	ubequad		0x0112020000000000	Publisher
+!:mime	application/vnd.ms-publisher
+!:ext	pub
+#
+# URL:	http://fileformats.archiveteam.org/wiki/PPT
+#??
+>>88 	ubequad		0xa90300aa00510ea3	: Microsoft
+>>>80 	ubequad		0x70ae7bea3bfbcd11	PowerPoint 95 presentation
+!:mime	application/vnd.ms-powerpoint
+# https://www.macdisk.com/macsigen.php
+!:apple	????PPT3
+!:ext	ppt/pot
+#??
+>>88 	ubequad		0x86ea00aa00b929e8	: Microsoft
+>>>80 	ubequad		0x108d81649b4fcf11	PowerPoint 97-2003 presentation or template
+!:mime	application/vnd.ms-powerpoint
+!:apple	????PPT3
+# /autostart/template
+!:ext	ppt/pps/pot
+#
+# URL:	https://en.wikipedia.org/wiki/Microsoft_Project
+#??
+>>88 	ubequad		0xbe1100c04fb6faf1	: Microsoft
+>>>80 	ubequad		0x3a8fb774c8c8d111	Project
+!:mime	application/vnd.ms-project
+!:ext	mpp
+#
+# URL:	http://fileformats.archiveteam.org/wiki/SHW_(Corel)
+#???
+>>88 	ubequad		0x99ae04021c007002	: WordPerfect
+>>>80 	ubequad		0x62fe2e4099191b10	7-X3 presentation
+!:mime	application/x-corelpresentations
+#!:mime	application/x-shw-viewer
+#!:mime	image/x-presentations
+!:ext	shw
+#
+# URL:	http://www.checkfilename.com/view-details/WordPerfect-Office-X3/RespageIndex/0/sTab/2/
+>>>80 	ubequad		0x60fe2e4099191b10	9 Graphic
+#!:mime	application/x-wpg
+#!:mime	image/x-wordperfect-graphics
+!:mime	image/x-wpg
+# https://www.macdisk.com/macsigen.php "WPC2" for Wordperfect 2 *.wpd
+!:apple	????WPC9
+!:ext	wpg
+#
+# URL:	http://fileformats.archiveteam.org/wiki/StarOffice_binary_formats
+>>88 	ubequad		0x996104021c007002	: StarOffice
+>>>80 	ubequad		0x407e5cdc5cb31b10	StarWriter 3.0 document or template
+# https://www.openoffice.org/framework/documentation/mimetypes/mimetypes.html
+!:mime	application/x-starwriter
+!:ext	sdw/vor
+#
+>>>80 	ubequad		0xa03f543fa6b61b10	StarCalc 3.0 spreadsheet or template
+!:mime	application/x-starcalc
+!:ext	sdc/vor
+#
+>>>80 	ubequad		0xe0aa10af6db31b10	StarDraw 3.0 drawing or template
+!:mime	application/x-starimpress
+#!:mime	application/x-stardraw
+# sda ??
+!:ext	sdd/sda/vor
+#??
+>>88 	ubequad		0x89cb008029e4b0b1	: StarOffice
+>>>80 	ubequad		0x41d461633542d011	StarCalc 4.0 spreadsheet or template
+!:mime	application/x-starcalc
+!:ext	sdc/vor
+#
+>>>80 	ubequad		0x61b8a5c6d685d111	StarCalc 5.0 spreadsheet or template
+!:mime	application/vnd.stardivision.cal
+!:ext	sdc/vor
+#
+>>>80 	ubequad		0xc03c2d011642d011	StarImpress 4.0 presentation or template
+!:mime	application/x-starimpress
+!:ext	sdd/vor
+#??
+>>88 	ubequad		0xb12a04021c007002	: StarOffice
+>>>80 	ubequad		0x600459d4fd351c10	StarMath 3.0
+!:mime	application/x-starmath
+!:ext	smf
+#??
+>>88 	ubequad		0x8e2c00001b4cc711	: StarOffice
+>>>80 	ubequad		0xe0999cfb6d2c1c10	StarChart 3.0
+!:mime	application/x-starchart
+!:ext	sds
+#??
+>>88 	ubequad		0xa45e00a0249d57b1	: StarOffice
+>>>80 	ubequad		0xb0e9048b0e42d011	StarWriter 4.0 document or template
+!:mime	application/x-starwriter
+!:ext	sdw/vor
+#??
+>>88 	ubequad		0x89ca008029e4b0b1	: StarOffice
+>>>80 	ubequad		0xe1b7b3022542d011	StarMath 4.0
+!:mime	application/x-starmath
+!:ext	smf
+#
+>>>80 	ubequad		0xe0b7b3022542d011	StarChart 4.0
+!:mime	application/x-starchart
+!:ext	sds
+#??
+>>88 	ubequad		0xa53f00a0249d57b1	: StarOffice
+>>>80 	ubequad		0x70c90a340de3d011	Master 4.0 document
+!:mime	application/x-starwriter-global
+!:ext	sgl
+#??
+>>88 	ubequad		0x89d0008029e4b0b1	: StarOffice
+>>>80 	ubequad		0x40e6b5ffde85d111	StarMath 5.0
+!:mime	application/vnd.stardivision.math
+!:ext	smf
+#
+>>>80 	ubequad		0xa005892ebd85d111	StarDraw 5.0 drawing or template
+!:mime	application/vnd.stardivision.draw
+!:ext	sda/vor
+#
+>>>80 	ubequad		0x21725c56bc85d111	StarImpress 5.0 presentation or template
+!:mime	application/vnd.stardivision.impress
+# sda is used for what?
+!:ext	sdd/vor/sda
+#
+>>>80 	ubequad		0x214388bfdd85d111	StarChart 5.0
+!:mime	application/vnd.stardivision.chart
+!:ext	sds
+# ??
+>>88 	ubequad		0xaab4006097da561a	: StarOffice
+>>>80 	ubequad		0xd1f90cc2ae85d111	StarWriter 5.0 document or template
+!:mime	application/vnd.stardivision.writer
+!:ext	sdw/vor
+#
+>>>80 	ubequad		0xd3f90cc2ae85d111	Master 5.0 document
+!:mime	application/vnd.stardivision.writer-global
+!:ext	sgl
+#??
+# URL:	http://fileformats.archiveteam.org/wiki/FlashPix
+>>88 	ubequad		0x855300aa00a1f95b	: Kodak
+>>>80 	ubequad		0x0067615654c1ce11	FlashPIX Image
+!:mime	image/vnd.fpx
+!:apple	????FPix
+!:ext	fpx
+# remaining non null clsid
+>>88 	default		x			: UNKNOWN
+!:mime	application/x-ole-storage
+>>>80 	ubequad		!0			\b, clsid 0x%16.16llx
+>>>88 	ubequad		x			\b%16.16llx
 

+ 17 - 0
magic/Magdir/openfst

@@ -0,0 +1,17 @@
+
+#------------------------------------------------------------------------------
+# $File: openfst,v 1.1 2019/09/30 15:58:24 christos Exp $
+# openfs:  file(1) magic for OpenFST (Weighted finite-state tranducer library)
+
+0	long		0x7eb2fdd6	OpenFst binary FST data
+>&0	pstring/l	x		\b, fst type: %s
+>>&0	pstring/l	x		\b, arc type: %s
+>>>&0	long		x		\b, version: %d
+>>>>&20	quad		x		\b, num states: %lld
+>>>>>&0	quad		>0		\b, num arcs: %lld
+
+0	long    0x56515c	OpenFst binary FAR data, far type: stlist
+>4	long 	x		\b, version: %d
+
+0	long	0x7eb2f35c	OpenFst binary FAR data, far type: sttable
+>4	long	x		\b, version: %d

+ 16 - 0
magic/Magdir/opentimestamps

@@ -0,0 +1,16 @@
+
+#------------------------------------------------------------
+# $File: opentimestamps,v 1.1 2019/05/27 01:27:31 christos Exp $
+# OpenTimestamps related magic entries 
+# https://opentimestamps.org/
+# https://en.wikipedia.org/wiki/OpenTimestamps
+# "Emanuele Cisbani" <emanuele.cisbani@gmail.com>
+#------------------------------------------------------------
+
+# OpenTimestamps Proof .ots format. 
+# Magic is defined here:
+# https://github.com/opentimestamps/python-opentimestamps/\
+# blob/master/opentimestamps/core/timestamp.py#L273
+
+0	string	\x00\x4f\x70\x65\x6e\x54\x69\x6d\x65\x73\x74\x61\x6d\x70\x73\x00 OpenTimestamps
+>16	string	\x00\x50\x72\x6f\x6f\x66\x00\xbf\x89\xe2\xe8\x84\xe8\x92\x94\x01 Proof

+ 7 - 1
magic/Magdir/pdf

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: pdf,v 1.10 2018/05/23 22:21:01 christos Exp $
+# $File: pdf,v 1.11 2019/09/12 15:53:49 christos Exp $
 # pdf:  file(1) magic for Portable Document Format
 #
 
@@ -16,6 +16,12 @@
 >6	byte		x		\b, version %c
 >8	byte		x		\b.%c
 
+0	string		\xef\xbb\xbf%PDF-	PDF document (UTF-8)
+!:mime	application/pdf
+!:strength +60
+>6	byte		x		\b, version %c
+>8	byte		x		\b.%c
+
 # From: Nick Schmalenberger <nick@schmalenberger.us>
 # Forms Data Format
 0       string          %FDF-           FDF document

+ 46 - 0
magic/Magdir/pmem

@@ -0,0 +1,46 @@
+
+#------------------------------------------------------------------------------
+# $File: pmem,v 1.3 2019/06/13 11:45:44 christos Exp $
+# pmem: file(1) magic for Persistent Memory Development Kit pool files
+#
+0	string		PMEM
+>4	string		POOLSET		Persistent Memory Poolset file
+>>11	search		REPLICA		with replica
+>4	regex		LOG|BLK|OBJ	Persistent Memory Pool file, type: %s,
+>>8	lelong		>0		version: 0x%x,
+>>12	lelong		x		compat: 0x%x,
+>>16	lelong		x		incompat: 0x%x,
+>>20	lelong		x		ro_compat: 0x%x,
+
+
+>>120	leqldate	x		crtime: %s,
+>>128	lequad		x		alignment_desc: 0x%016llx,
+
+>>136	clear		x
+>>136	byte		2		machine_class: 64-bit,
+>>136	default		x		machine_class: unknown
+>>>136	byte		x		(0x%d),
+
+>>137	clear		x
+>>137	byte		1		data: little-endian,
+>>137	byte		2		data: big-endian,
+>>137	default		x		data: unknown
+>>>137	byte		x		(0x%d),
+
+>>138	byte		!0		reserved[0]: %d,
+>>139	byte		!0		reserved[1]: %d,
+>>140	byte		!0		reserved[2]: %d,
+>>141	byte		!0		reserved[3]: %d,
+
+>>142	clear		x
+>>142	leshort		62		machine: x86_64
+>>142	leshort		183		machine: aarch64
+>>142	default		x		machine: unknown
+>>>142	leshort		x		(0x%d)
+
+>4	string		BLK
+>>4096	lelong		x		\b, blk.bsize: %d
+
+>4	string		OBJ
+>>4096	string		>0		\b, obj.layout: '%s'
+>>4096	string		<0		\b, obj.layout: NULL

+ 19 - 6
magic/Magdir/python

@@ -1,31 +1,44 @@
 
 #------------------------------------------------------------------------------
-# $File: python,v 1.36 2019/04/09 18:28:25 christos Exp $
+# $File: python,v 1.37 2019/10/21 19:40:58 christos Exp $
 # python:  file(1) magic for python
 #
 # Outlook puts """ too for urgent messages
 # From: David Necas <yeti@physics.muni.cz>
 # often the module starts with a multiline string
 0	string/t	"""	Python script text executable
-# MAGIC as specified in Python/import.c (1.5 to 2.7a0 and 3.1a0, assuming
-# that Py_UnicodeFlag is off for Python 2)
+# MAGIC as specified in Python/import.c (1.0 to 3.7)
 # two bytes of magic followed by "\r\n" in little endian order
-0	belong		0x994e0d0a	python 1.5/1.6 byte-compiled
+0	belong		0x02099900	python 1.0 byte-compiled
+0	belong		0x03099900	python 1.1/1.2 byte-compiled
+0	belong		0x892e0d0a	python 1.3 byte-compiled
+0	belong		0x04170d0a	python 1.4 byte-compiled
+0	belong		0x994e0d0a	python 1.5 byte-compiled
+0	belong		0xfcc40d0a	python 1.6 byte-compiled
+0	belong		0xfdc40d0a	python 1.6 byte-compiled
 0	belong		0x87c60d0a	python 2.0 byte-compiled
+0	belong		0x88c60d0a	python 2.0 byte-compiled
 0	belong		0x2aeb0d0a	python 2.1 byte-compiled
+0	belong		0x2beb0d0a	python 2.1 byte-compiled
 0	belong		0x2ded0d0a	python 2.2 byte-compiled
+0	belong		0x2eed0d0a	python 2.2 byte-compiled
 0	belong		0x3bf20d0a	python 2.3 byte-compiled
+0	belong		0x3cf20d0a	python 2.3 byte-compiled
 0	belong		0x6df20d0a	python 2.4 byte-compiled
+0	belong		0x6ef20d0a	python 2.4 byte-compiled
 0	belong		0xb3f20d0a	python 2.5 byte-compiled
+0	belong		0xb4f20d0a	python 2.5 byte-compiled
 0	belong		0xd1f20d0a	python 2.6 byte-compiled
+0	belong		0xd2f20d0a	python 2.6 byte-compiled
 0	belong		0x03f30d0a	python 2.7 byte-compiled
+0	belong		0x04f30d0a	python 2.7 byte-compiled
 0	belong		0x3b0c0d0a	python 3.0 byte-compiled
 0	belong		0x4f0c0d0a	python 3.1 byte-compiled
 0	belong		0x6c0c0d0a	python 3.2 byte-compiled
 0	belong		0x9e0c0d0a	python 3.3 byte-compiled
 0	belong		0xee0c0d0a	python 3.4 byte-compiled
-0	belong		0x160d0d0a	python 3.5.1- byte-compiled
-0	belong		0x170d0d0a	python 3.5.2+ byte-compiled
+0	belong		0x160d0d0a	python 3.5.2- byte-compiled
+0	belong		0x170d0d0a	python 3.5.3+ byte-compiled
 0	belong		0x330d0d0a	python 3.6 byte-compiled
 0	belong		0x420d0d0a	python 3.7 byte-compiled
 

+ 15 - 1
magic/Magdir/rpi

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: rpi,v 1.1 2018/01/01 05:25:17 christos Exp $
+# $File: rpi,v 1.2 2019/10/02 02:07:30 christos Exp $
 # rpi:  file(1) magic for Raspberry Pi images
 -44		lelong	0
 >4		lelong	0
@@ -13,3 +13,17 @@
 >>>>>>>32	lelong	44
 >>>>>>>>36	lelong	4
 >>>>>>>>>40	string	RPTL		Raspberry PI kernel image
+
+-56		lelong	0
+>4		lelong	0
+>>8		lelong	1
+>>12		lelong	4
+>>>16		string	283x
+>>>>20		lelong	1
+>>>>>24		lelong	4
+>>>>>>28	string	DTOK
+>>>>>>>32	lelong	1
+>>>>>>>>36	lelong	4
+>>>>>>>>>40	string	DDTK8
+>>>>>>>>>>48	lelong	4
+>>>>>>>>>>>52	string	RPTL		Raspberry PI kernel image

+ 11 - 0
magic/Magdir/rst

@@ -0,0 +1,11 @@
+
+#------------------------------------------------------------------------------
+# $File: rst,v 1.2 2019/11/02 18:41:26 christos Exp $
+# rst: ReStructuredText http://docutils.sourceforge.net/rst.html
+0	search/256	\=\=
+!:strength + 30
+>&0	regex/256	\^[\=]+$
+>>&0	search/512	:Author:	ReStructuredText file
+>>&0	default		x
+>>>&0	regex/512	\^\.\.[A-Za-z]	ReStructuredText file
+!:ext	rst

+ 3 - 3
magic/Magdir/ruby

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: ruby,v 1.9 2019/04/19 00:42:27 christos Exp $
+# $File: ruby,v 1.10 2019/07/21 09:40:17 christos Exp $
 # ruby:  file(1) magic for Ruby scripting language
 # URL:  https://www.ruby-lang.org/
 # From: Reuben Thomas <rrt@sc3d.org>
@@ -23,7 +23,7 @@
 # (modules and such)
 # From: Lubomir Rintel <lkundrak@v3.sk>
 0	search/8192	require
->0	regex		\^[[:space:]]*require[[:space:]]'[A-Za-z_/]+'
+>0	regex		\^[[:space:]]*require[[:space:]]'[A-Za-z_/.]+'
 >>0	regex		def\ [a-z]|\ do$
 >>>&0	regex		\^[[:space:]]*end([[:space:]]+[;#].*)?$		Ruby script text
 !:strength + 30
@@ -48,7 +48,7 @@
 !:mime	text/x-ruby
 
 0	search/8192	require
->0	regex		\^[[:space:]]*require[[:space:]]'[A-Za-z_/]+'	Ruby script text
+>0	regex		\^[[:space:]]*require[[:space:]]'[A-Za-z_/.]+'	Ruby script text
 !:mime	text/x-ruby
 0	search/8192	include
 >0 regex 	\^[[:space:]]*include\ ([A-Z]+[a-z]*(::))+	Ruby script text

+ 3 - 3
magic/Magdir/sgml

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: sgml,v 1.39 2019/04/19 00:42:27 christos Exp $
+# $File: sgml,v 1.40 2019/09/30 15:44:22 christos Exp $
 # Type:	SVG Vectorial Graphics
 # From:	Noel Torres <tecnico@ejerciciosresueltos.com>
 0	string		\<?xml\ version=
@@ -10,7 +10,7 @@
 >>19	search/4096	\<gnc-v2		GnuCash file
 !:mime	application/x-gnucash
 0	string		\<svg			SVG Scalable Vector Graphics image
-!:mime	image/svg
+!:mime	image/svg+xml
 
 # Sitemap file
 0	string/t		\<?xml\ version=
@@ -142,4 +142,4 @@
 0   string      \<?xml\ version=
 >14 regex       ['"\ \t]*[0-9.]+['"\ \t]*
 >>19    search/4096 \<pef           Portable Embosser Format
-!:mime  application/x-pef+xml
+!:mime  application/x-pef+xml

+ 5 - 3
magic/Magdir/sniffer

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: sniffer,v 1.25 2019/05/05 17:03:41 christos Exp $
+# $File: sniffer,v 1.27 2019/12/08 18:22:24 christos Exp $
 # sniffer:  file(1) magic for packet capture files
 #
 # From: guy@alum.mit.edu (Guy Harris)
@@ -99,7 +99,7 @@
 >20	belong		9		(PPP
 >20	belong		10		(FDDI
 >20	belong		11		(RFC 1483 ATM
->20	belong		12		(raw IP
+>20	belong		12		(Raw IP
 >20	belong		13		(BSD/OS SLIP
 >20	belong		14		(BSD/OS PPP
 >20	belong		19		(Linux ATM Classical IP
@@ -107,7 +107,7 @@
 >20	belong		51		(PPP-over-Ethernet
 >20	belong		99		(Symantec Enterprise Firewall
 >20	belong		100		(RFC 1483 ATM
->20	belong		101		(raw IP
+>20	belong		101		(Raw IP
 >20	belong		102		(BSD/OS SLIP
 >20	belong		103		(BSD/OS PPP
 >20	belong		104		(BSD/OS Cisco HDLC
@@ -262,6 +262,8 @@
 >20	belong		279		(Elektrobit High Speed Capture and Replay (EBHSCR)
 >20	belong		281		(Broadcom tag
 >20	belong		282		(Broadcom tag (prepended)
+>20	belong		284		(Marvell DSA
+>20	belong		285		(Marvell EDSA
 # print default match
 >20	default		x
 >>20	belong		x		(linktype#%u

+ 40 - 0
magic/Magdir/sosi

@@ -0,0 +1,40 @@
+
+#------------------------------------------------------------------------------
+# $File: sosi,v 1.1 2019/05/20 17:25:09 christos Exp $
+# SOSI
+# Summary: Systematic Organization of Spatial Information
+# Long description: Norwegian text based map format
+# File extension: .sos
+# Full name:    Petter Reinholdtsen (pere@hungry.com)
+# Reference: https://en.wikipedia.org/wiki/SOSI
+#
+# Example SOSI files available from
+# https://trac.osgeo.org/gdal/ticket/3638
+# https://nedlasting.geonorge.no/geonorge/Basisdata/N50Kartdata/SOSI/
+# https://nedlasting.geonorge.no/geonorge/Samferdsel/Elveg/SOSI/
+#
+# Start with optional comments (from "!" to the next line end)
+# followed by ".HODE" and end with "\n.SLUTT" followed by an optional
+# separator (any number of " ", "\t", "\n" or "\r"), might have BOM at
+# the start and following ".HODE" near the start there is "..OMR=C3=85DE"
+# (either UTF-8, ISO-8859-1 or some 7 bit Norwegian charset based on
+# ASCII) , "..TRANSPAR", "..TEGNSETT " followed by the charset and a
+# separator, as well as "..SOSI-VERSJON " followed by the format
+# version and a separator.
+#
+# FIXME figure out how to accept any of [space], [tab], [newline] and
+# [carrige return] as separators, not only line end.
+
+# Not searching for full "OMR=C3=85DE" to match also for non-UTF-8
+# character sets
+0	search	..OMR
+>0	search	..TRANSPAR
+>>0       search  .HODE           SOSI map data
+>>>&0      search  ..SOSI-VERSJON
+>>>>&1	string	x		\b, version %s
+# FIXME could not figure out way to make a match for .SLUTT at the end required
+#>-7      string  \n.SLUTT	slutt
+#>-8      string  \n.SLUTT\n	slutt-nl
+#>-9      string  \n.SLUTT\r\n	slutt-crnl2
+!:mime text/vnd.sosi
+!:ext sos

+ 6 - 0
magic/Magdir/ssh

@@ -11,3 +11,9 @@
 0	string	ecdsa-sha2-nistp384	OpenSSH ECDSA public key
 0	string	ecdsa-sha2-nistp521	OpenSSH ECDSA public key
 0	string	ssh-ed25519		OpenSSH ED25519 public key
+
+0	string	SSHKRL\n\0
+>8	ubelong	1		OpenSSH key/certificate revocation list, format %u
+>>12	ubequad	x		\b, version %llx
+>>>20	beqdate	x		\b, generated %s
+

+ 1 - 6
magic/Magdir/uuencode

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: uuencode,v 1.7 2009/09/19 16:28:13 christos Exp $
+# $File: uuencode,v 1.8 2019/12/14 20:40:26 christos Exp $
 # uuencode:  file(1) magic for ASCII-encoded files
 #
 
@@ -23,9 +23,4 @@
 # Greg Roelofs, newt@uchicago.edu
 0	search/1	Decode\ the\ following\ with\ bdeco	bencoded News text
 
-# BinHex is the Macintosh ASCII-encoded file format (see also "apple")
-# Daniel Quinlan, quinlan@yggdrasil.com
-11	search/1	must\ be\ converted\ with\ BinHex	BinHex binary text
->41	search/1	x					\b, version %.3s
-
 # GRR: handle BASE64

+ 9 - 1
magic/Magdir/varied.script

@@ -1,30 +1,38 @@
 #------------------------------------------------------------------------------
-# $File: varied.script,v 1.12 2019/04/19 00:42:27 christos Exp $
+# $File: varied.script,v 1.13 2019/10/11 14:35:29 christos Exp $
 # varied.script:  file(1) magic for various interpreter scripts
 
 0	string/t		#!\ /			a
 >3	string		>\0			%s script text executable
+!:strength / 2
 
 0	string/b		#!\ /			a
 >3	string		>\0			%s script executable (binary data)
+!:strength / 2
 
 0	string/t		#!\t/			a
 >3	string		>\0			%s script text executable
+!:strength / 2
 
 0	string/b		#!\t/			a
 >3	string		>\0			%s script executable (binary data)
+!:strength / 2
 
 0	string/t		#!/			a
 >2	string		>\0			%s script text executable
+!:strength / 2
 
 0	string/b		#!/			a
 >2	string		>\0			%s script executable (binary data)
+!:strength / 2
 
 0	string/t		#!\ 			script text executable
 >3	string		>\0			for %s
+!:strength / 2
 
 0	string/b		#!\ 			script executable
 >3	string		>\0			for %s (binary data)
+!:strength / 2
 
 # using env
 0	string/t	#!/usr/bin/env		a

+ 12 - 7
magic/Magdir/vax

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: vax,v 1.9 2014/04/30 21:41:02 christos Exp $
+# $File: vax,v 1.10 2019/10/04 18:07:46 christos Exp $
 # vax:  file(1) magic for VAX executable/object and APL workspace
 #
 0	lelong		0101557		VAX single precision APL workspace
@@ -19,9 +19,14 @@
 # The `versions' were commented out, but have been un-commented out.
 # (Was the problem just one of endianness?)
 #
-0	leshort		0570		VAX COFF executable
->12	lelong		>0		not stripped
->22	leshort		>0		- version %d
-0	leshort		0575		VAX COFF pure executable
->12	lelong		>0		not stripped
->22	leshort		>0		- version %d
+0	leshort		0570
+>2	uleshort	<100		VAX COFF executable, sections %d
+>>4	ledate		x		\b, created %s
+>>12	lelong		>0		\b, not stripped
+>>22	leshort		>0		\b, version %d
+
+0	leshort		0575
+>2	uleshort	<100		VAX COFF pure executable, sections %d
+>>4	ledate		x		\b, created %s
+>>12	lelong		>0		\b, not stripped
+>>22	leshort		>0		\b, version %d

+ 117 - 5
magic/Magdir/windows

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: windows,v 1.26 2019/05/01 17:55:25 christos Exp $
+# $File: windows,v 1.29 2019/11/18 03:11:20 christos Exp $
 # windows:  file(1) magic for Microsoft Windows
 #
 # This file is mainly reserved for files where programs
@@ -119,6 +119,94 @@
 # 3rd BLOB
 >>0x480		string		>\0		\b, type %-3.8s
 
+# Summary:	Windows boot status log BOOTSTAT.DAT
+# From:		Joerg Jenderek
+# Reference:	https://www.geoffchappell.com/notes/windows/boot/bsd.htm
+# Note:		mainly refers to older Windows Vista, sometimes
+#		BOOTSTAT.DAT only contains nulls or invalid data
+# checking for valid version below 5
+0		ulelong		<5
+# skip many ISO images by checking for valid 64 KiB file size
+>8		ulelong		=0x00010000
+>>0		use		bootstat-dat
+# display information of BOOTSTAT.DAT
+0	name		bootstat-dat
+>0		ulelong		x		Windows boot log
+#!:mime	application/octet-stream
+!:mime	application/x-ms-dat
+# BOOTSTAT.DAT in BOOT subdirectory
+!:ext	dat
+# apparently a version number: 2 for older like Vista, 3, 4 Windows 10
+>0		ulelong		>2		\b, version %u
+# apparently the size of the header: often 10h in older Windows, 14h, 18h
+>4		ulelong		!0x10		\b, header size 0x%x
+#>4		ulelong		!0x10		\b, header size %u
+# apparently the size of the file: always 0x00010000~64KiB
+# the file is acceptable to BOOTMGR only if it is exactly 64 KiB
+>8		ulelong		!0x00010000	\b, file size 0x%x
+# size of valid data, in bytes: C8h 50h 172h 5D5Ch
+>0xc		ulelong		x		\b, 0x%x valid bytes
+# skip header and jump to first bootstat entry and display information
+>(0x4.l-1)	ubyte		x
+>>&0		use		bootstat-entry
+# jump to first entry again because pointer are bad after "use"
+>(0x4.l-1)	ubyte		x
+# by 1st entry size jump to 2nd entry and display information
+>>&(&0x18.l-1)	ubyte		x
+>>>&0		use		bootstat-entry
+# jump to possible 3rd boot entry and display information
+# >(0x4.l-1)	ubyte		x
+# >>&(&0x18.l-1)	ubyte		x
+# >>>&(&0x18.l-1)	ubyte		x
+# >>>>&0		use		bootstat-entry
+#	display BOOTSTAT.DAT entry
+0	name		bootstat-entry
+#>0x00		ubequad		x		\b, ENTRY %16.16llx
+# size of entry, in bytes: 40h(init) 78h(launced) 9Ch
+#>0x18		ulelong		x		\b; entry size %u
+>0x18		ulelong		x		\b; entry size 0x%x
+# time stamp, in seconds 
+>0x00		ulelong		x		\b, 0x%x seconds
+# always zero, significance unknown
+>0x04		ulelong		!0		\b, not null %u
+# GUID of event source; but empty if event source is BOOTMGR 
+>0x08		ubequad		!0		\b, GUID 0x%16.16llx
+>>0x10		ubequad		x		\b%16.16llx
+# severity code: 1~informational 3~errors
+>0x1C		ulelong		!1		\b, severity 0x%x
+# apparently a version number: 2 
+>0x20		ulelong		!2		\b, version %u
+# event identifier 1~log file initialised 11h~boot application launched 
+#>0x24		ulelong		x		\b, event 0x%x
+>0x24		ulelong		!1
+>>0x24		ulelong		!0x11		\b, event 0x%x
+# entry data; size depends on event identifier  
+#>0x28		ubequad		x		\b, data 0x%16.16llx
+>0x24		ulelong		=0x1		\b, Init
+# always 0, significance unknown 
+>>0x34		uleshort	!0		\b, not null %u
+# always 7, significance unknown 
+>>0x36		uleshort	!7		\b, not seven %u
+# year
+>>0x28		uleshort	x		%u
+# month
+>>0x2A		uleshort	x		\b-%u
+# day
+>>0x2C		uleshort	x		\b-%u
+# hour
+>>0x2E		uleshort	x		%u
+# minute
+>>0x30		uleshort	x		\b:%u
+# second
+>>0x32		uleshort	x		\b:%u
+# boot application launched
+>0x24		ulelong		=0x11		\b, launched
+# type of start: 0 normally, 1 or 2 maybe in a recovery sequence
+>>0x38		uleshort	!0		\b, type %u
+# pathname of boot application, as null-terminated Unicode string; typically
+# \Windows\system32\winload.exe \Windows\system32\winload.efi
+>>0x3C		lestring16	x		%s
+
 # Summary:	Windows Error Report text files
 # URL:		https://en.wikipedia.org/wiki/Windows_Error_Reporting
 # Reference:	https://www.nirsoft.net/utils/app_crash_view.html
@@ -275,7 +363,7 @@
 !:apple	????TEXT
 !:ext	cnt
 #
-# Windows creates an full text search from hlp file, if the user clicks the "Find" tab and enables keyword indexing
+# Windows creates a full text search from hlp file, if the user clicks the "Find" tab and enables keyword indexing
 0	string		tfMR			MS Windows help Full Text Search index
 !:mime application/x-winhelp-fts
 !:ext	fts
@@ -477,8 +565,8 @@
 # https://en.wikipedia.org/wiki/CONFIG.SYS
 >>&0	regex/c		\^(menu)]					MS-DOS CONFIG.SYS
 # @CONFIG.UI configuration file of previous DOS version saved by Caldera OPENDOS INSTALL.EXE
-# CONFIG.PSS saved version of file CONFIG.SYS created by %WINDIR%\SYTEM\MSCONFIG.EXE
-# CONFIG.TSH renamed file CONFIG.SYS.BAT by %WINDIR%\SYTEM\MSCONFIG.EXE
+# CONFIG.PSS saved version of file CONFIG.SYS created by %WINDIR%\SYSTEM\MSCONFIG.EXE
+# CONFIG.TSH renamed file CONFIG.SYS.BAT by %WINDIR%\SYSTEM\MSCONFIG.EXE
 # dos and w40 used in dual booting scene
 !:ext	sys/dos/w40
 # https://support.microsoft.com/kb/118579/
@@ -757,7 +845,7 @@
 >0x1c	string		>\0				\b%.7s
 # AppName[0x80] like "Minimal SYStem", ClamWin Free Antivirus , ...
 >0xc0	string		x				%s
-# AppId[0x80] is simliar to AppName or
+# AppId[0x80] is similar to AppName or
 # GUID like {4BB0DCDC-BC24-49EC-8937-72956C33A470} start with left brace
 >0x40	ubyte		0x7b
 >>0x40	string		x				%-.38s
@@ -879,3 +967,27 @@
 #>148	ubequad		!0			\b,unused 0x%16.16llx
 #
 
+# From:		Joerg Jenderek
+# URL:		https://en.wikipedia.org/wiki/Windows_Easy_Transfer
+# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/m/mig.trid.xml
+# Note:		called "Windows Easy Transfer migration data" by TrID,
+#		"Migration Store" or "EasyTransfer file" by Microsoft
+0		string		1giM	Windows Easy Transfer migration data
+#!:mime		application/octet-stream
+!:mime		application/x-ms-mig
+!:ext		mig
+>0x18		string		=MRTS	without password
+# data offset with 1 space at end
+>>0x1c		ulelong+0x38	x	\b, at 0x%x 
+# look for zlib compressed data by ./compress
+>>(0x1c.l+0x38)	ubyte		x
+>>>&-1	indirect	x
+# in password protected examples MRTS comes some bytes further
+>0x18		string		!MRTS	with password
+# look for first MRTS tag
+>0x18		search/29/b	MRTS
+# probably first file name length like 178, ...
+#>>&0		ulelong		x	\b, 1st length %u
+# URL like File\C:\Users\nutzer\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\desktop.ini
+>>&20		lestring16	x	\b, 1st %-s
+

+ 46 - 4
magic/Magdir/wordprocessors

@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: wordprocessors,v 1.20 2019/04/19 00:42:27 christos Exp $
+# $File: wordprocessors,v 1.23 2019/10/25 20:15:49 christos Exp $
 # wordprocessors:  file(1) magic fo word processors.
 #
 ####### PWP file format used on Smith Corona Personal Word Processors:
@@ -12,6 +12,21 @@
 >25	byte	0x54	\b, legal
 >26	byte	0x46	\b, A4
 
+# URL:	http://fileformats.archiveteam.org/wiki/Microsoft_Works_Word_Processor
+# reference:	http://mark0.net/download/triddefs_xml.7z
+#		/defs/w/wps-works-dos.trid.xml
+# From:	Joerg Jenderek
+# Note:	older non OLE 2 Compound based versions
+0	ubeshort	=0x01FE
+>112	ubeshort	=0x0100		Microsoft Works 1-3 (DOS) or 2 (Windows) document
+# title like THE GREAT KHAN GAME
+>>0x100	string		x		%s
+!:mime	application/vnd-ms-works
+#!:mime	application/x-msworks
+# https://www.macdisk.com/macsigen.php
+!:apple	????AWWP
+!:ext	wps
+
 # Corel/WordPerfect
 0	string	\xffWPC
 # WordPerfect
@@ -196,9 +211,6 @@
 
 # Hangul (Korean) Word Processor File
 0	string	HWP\ Document\ File	Hangul (Korean) Word Processor File 3.0
-# From: Won-Kyu Park <wkpark@kldp.org>
-512	string		R\0o\0o\0t\0	Hangul (Korean) Word Processor File 2000
-!:mime	application/x-hwp
 
 # CosmicBook, from Benoit Rouits
 0       string  CSBK    Ted Neslson's CosmicBook hypertext file
@@ -260,3 +272,33 @@
 # 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
+
+# From:		Joerg Jenderek
+# URL:		https://en.wikipedia.org/wiki/StarOffice
+# Note:		used in Star-, Open- and Libre-Office
+# named as soffice.StarConfigFile.6 or OpenOffice.org configuration by others
+0		ubeshort	0x0400
+#>(2.s+8)	ubequad		x		\b, gap 0x%16.16llx
+# test for null value in gap after theme name maybe unreliable
+#>(2.s+9)	ubyte		0		\b, 0-byte
+# look for keyword GALRESRV near the end
+# "C:\Program Files (x86)\StarOffice6.0\share\gallery\sg27.thm" Navigation, 238 objects
+#>0		search/8415	GALRESRV	\b, GALRESRV found
+# "neues thema6.thm" MorePictures, 315 objects
+#>0		search/19299	GALRESRV	\b, GALRESRV FOUND
+#>2		uleshort	x		\b, name length %u
+# skip file2147.chk by check for positive name length like for sg16.thm "3D"
+>2		uleshort	>0		StarOffice Gallery theme
+!:mime		application/x-stargallery-thm
+!:ext		thm
+# gallery name
+>>2		pstring/h	x		%s
+# number of objects
+>>(2.s+4)	ulelong		x		\b, %u object
+# plural s
+>>(2.s+4)	ulelong		!1		\bs
+# if available then display first object name 
+>>(2.s+4)	ulelong		>0
+# partial file name, URL or internal name like "dd2*" of 1st object or RESRV
+>>>(2.s+11)	pstring/h	x		\b, 1st %s
+

+ 2 - 2
magic/Magdir/zip

@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------
-# $File: zip,v 1.2 2019/04/09 18:34:15 christos Exp $
+# $File: zip,v 1.3 2019/07/06 19:25:06 christos Exp $
 # zip:  file(1) magic for zip files; this is not use
 # Note the version of magic in archive is currently stronger, this is
 # just an example until negative offsets are supported better
@@ -60,4 +60,4 @@
 #>10	leshort		>1		\b, %d central directories
 #>12	lelong		x		\b, %d central directory bytes
 >(16.l)	use		zipcd
->20	pstring/l	>0		\b, %s
+>>20	pstring/l	>0		\b, %s

+ 9 - 1
magic/Makefile.am

@@ -1,5 +1,5 @@
 #
-# $File: Makefile.am,v 1.143 2019/05/09 16:24:36 christos Exp $
+# $File: Makefile.am,v 1.151 2019/11/02 18:37:58 christos Exp $
 #
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_DIR = $(top_srcdir)/magic
@@ -99,6 +99,7 @@ $(MAGIC_FRAGMENT_DIR)/finger \
 $(MAGIC_FRAGMENT_DIR)/flash \
 $(MAGIC_FRAGMENT_DIR)/flif \
 $(MAGIC_FRAGMENT_DIR)/fonts \
+$(MAGIC_FRAGMENT_DIR)/forth \
 $(MAGIC_FRAGMENT_DIR)/fortran \
 $(MAGIC_FRAGMENT_DIR)/frame \
 $(MAGIC_FRAGMENT_DIR)/freebsd \
@@ -110,6 +111,7 @@ $(MAGIC_FRAGMENT_DIR)/gconv \
 $(MAGIC_FRAGMENT_DIR)/geo \
 $(MAGIC_FRAGMENT_DIR)/geos \
 $(MAGIC_FRAGMENT_DIR)/gimp \
+$(MAGIC_FRAGMENT_DIR)/git \
 $(MAGIC_FRAGMENT_DIR)/glibc \
 $(MAGIC_FRAGMENT_DIR)/gnome \
 $(MAGIC_FRAGMENT_DIR)/gnu \
@@ -179,6 +181,7 @@ $(MAGIC_FRAGMENT_DIR)/mkid \
 $(MAGIC_FRAGMENT_DIR)/mlssa \
 $(MAGIC_FRAGMENT_DIR)/mmdf \
 $(MAGIC_FRAGMENT_DIR)/modem \
+$(MAGIC_FRAGMENT_DIR)/modulefile \
 $(MAGIC_FRAGMENT_DIR)/motorola \
 $(MAGIC_FRAGMENT_DIR)/mozilla \
 $(MAGIC_FRAGMENT_DIR)/msdos \
@@ -202,6 +205,8 @@ $(MAGIC_FRAGMENT_DIR)/ocaml \
 $(MAGIC_FRAGMENT_DIR)/octave \
 $(MAGIC_FRAGMENT_DIR)/ole2compounddocs \
 $(MAGIC_FRAGMENT_DIR)/olf \
+$(MAGIC_FRAGMENT_DIR)/openfst \
+$(MAGIC_FRAGMENT_DIR)/opentimestamps \
 $(MAGIC_FRAGMENT_DIR)/os2 \
 $(MAGIC_FRAGMENT_DIR)/os400 \
 $(MAGIC_FRAGMENT_DIR)/os9 \
@@ -222,6 +227,7 @@ $(MAGIC_FRAGMENT_DIR)/pgp \
 $(MAGIC_FRAGMENT_DIR)/pkgadd \
 $(MAGIC_FRAGMENT_DIR)/plan9 \
 $(MAGIC_FRAGMENT_DIR)/plus5 \
+$(MAGIC_FRAGMENT_DIR)/pmem \
 $(MAGIC_FRAGMENT_DIR)/polyml \
 $(MAGIC_FRAGMENT_DIR)/printer \
 $(MAGIC_FRAGMENT_DIR)/project \
@@ -238,6 +244,7 @@ $(MAGIC_FRAGMENT_DIR)/rpi \
 $(MAGIC_FRAGMENT_DIR)/rpm \
 $(MAGIC_FRAGMENT_DIR)/rpmsg \
 $(MAGIC_FRAGMENT_DIR)/rtf \
+$(MAGIC_FRAGMENT_DIR)/rst \
 $(MAGIC_FRAGMENT_DIR)/ruby \
 $(MAGIC_FRAGMENT_DIR)/sc \
 $(MAGIC_FRAGMENT_DIR)/sccs \
@@ -257,6 +264,7 @@ $(MAGIC_FRAGMENT_DIR)/smalltalk \
 $(MAGIC_FRAGMENT_DIR)/smile \
 $(MAGIC_FRAGMENT_DIR)/sniffer \
 $(MAGIC_FRAGMENT_DIR)/softquad \
+$(MAGIC_FRAGMENT_DIR)/sosi \
 $(MAGIC_FRAGMENT_DIR)/spec \
 $(MAGIC_FRAGMENT_DIR)/spectrum \
 $(MAGIC_FRAGMENT_DIR)/sql \

+ 18 - 6
magic/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -193,6 +193,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MINGW = @MINGW@
@@ -273,7 +274,7 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 
 #
-# $File: Makefile.am,v 1.143 2019/05/09 16:24:36 christos Exp $
+# $File: Makefile.am,v 1.151 2019/11/02 18:37:58 christos Exp $
 #
 MAGIC_FRAGMENT_BASE = Magdir
 MAGIC_DIR = $(top_srcdir)/magic
@@ -371,6 +372,7 @@ $(MAGIC_FRAGMENT_DIR)/finger \
 $(MAGIC_FRAGMENT_DIR)/flash \
 $(MAGIC_FRAGMENT_DIR)/flif \
 $(MAGIC_FRAGMENT_DIR)/fonts \
+$(MAGIC_FRAGMENT_DIR)/forth \
 $(MAGIC_FRAGMENT_DIR)/fortran \
 $(MAGIC_FRAGMENT_DIR)/frame \
 $(MAGIC_FRAGMENT_DIR)/freebsd \
@@ -382,6 +384,7 @@ $(MAGIC_FRAGMENT_DIR)/gconv \
 $(MAGIC_FRAGMENT_DIR)/geo \
 $(MAGIC_FRAGMENT_DIR)/geos \
 $(MAGIC_FRAGMENT_DIR)/gimp \
+$(MAGIC_FRAGMENT_DIR)/git \
 $(MAGIC_FRAGMENT_DIR)/glibc \
 $(MAGIC_FRAGMENT_DIR)/gnome \
 $(MAGIC_FRAGMENT_DIR)/gnu \
@@ -451,6 +454,7 @@ $(MAGIC_FRAGMENT_DIR)/mkid \
 $(MAGIC_FRAGMENT_DIR)/mlssa \
 $(MAGIC_FRAGMENT_DIR)/mmdf \
 $(MAGIC_FRAGMENT_DIR)/modem \
+$(MAGIC_FRAGMENT_DIR)/modulefile \
 $(MAGIC_FRAGMENT_DIR)/motorola \
 $(MAGIC_FRAGMENT_DIR)/mozilla \
 $(MAGIC_FRAGMENT_DIR)/msdos \
@@ -474,6 +478,8 @@ $(MAGIC_FRAGMENT_DIR)/ocaml \
 $(MAGIC_FRAGMENT_DIR)/octave \
 $(MAGIC_FRAGMENT_DIR)/ole2compounddocs \
 $(MAGIC_FRAGMENT_DIR)/olf \
+$(MAGIC_FRAGMENT_DIR)/openfst \
+$(MAGIC_FRAGMENT_DIR)/opentimestamps \
 $(MAGIC_FRAGMENT_DIR)/os2 \
 $(MAGIC_FRAGMENT_DIR)/os400 \
 $(MAGIC_FRAGMENT_DIR)/os9 \
@@ -494,6 +500,7 @@ $(MAGIC_FRAGMENT_DIR)/pgp \
 $(MAGIC_FRAGMENT_DIR)/pkgadd \
 $(MAGIC_FRAGMENT_DIR)/plan9 \
 $(MAGIC_FRAGMENT_DIR)/plus5 \
+$(MAGIC_FRAGMENT_DIR)/pmem \
 $(MAGIC_FRAGMENT_DIR)/polyml \
 $(MAGIC_FRAGMENT_DIR)/printer \
 $(MAGIC_FRAGMENT_DIR)/project \
@@ -510,6 +517,7 @@ $(MAGIC_FRAGMENT_DIR)/rpi \
 $(MAGIC_FRAGMENT_DIR)/rpm \
 $(MAGIC_FRAGMENT_DIR)/rpmsg \
 $(MAGIC_FRAGMENT_DIR)/rtf \
+$(MAGIC_FRAGMENT_DIR)/rst \
 $(MAGIC_FRAGMENT_DIR)/ruby \
 $(MAGIC_FRAGMENT_DIR)/sc \
 $(MAGIC_FRAGMENT_DIR)/sccs \
@@ -529,6 +537,7 @@ $(MAGIC_FRAGMENT_DIR)/smalltalk \
 $(MAGIC_FRAGMENT_DIR)/smile \
 $(MAGIC_FRAGMENT_DIR)/sniffer \
 $(MAGIC_FRAGMENT_DIR)/softquad \
+$(MAGIC_FRAGMENT_DIR)/sosi \
 $(MAGIC_FRAGMENT_DIR)/spec \
 $(MAGIC_FRAGMENT_DIR)/spectrum \
 $(MAGIC_FRAGMENT_DIR)/sql \
@@ -612,8 +621,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -658,7 +667,10 @@ ctags CTAGS:
 cscope cscopelist:
 
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \

+ 8 - 8
missing

@@ -1,9 +1,9 @@
 #! /bin/sh
 # Common wrapper for a few potentially missing GNU programs.
 
-scriptversion=2013-10-28.13; # UTC
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2018 Free Software Foundation, Inc.
 # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ scriptversion=2013-10-28.13; # UTC
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -101,9 +101,9 @@ else
   exit $st
 fi
 
-perl_URL=http://www.perl.org/
-flex_URL=http://flex.sourceforge.net/
-gnu_software_URL=http://www.gnu.org/software
+perl_URL=https://www.perl.org/
+flex_URL=https://github.com/westes/flex
+gnu_software_URL=https://www.gnu.org/software
 
 program_details ()
 {
@@ -207,9 +207,9 @@ give_advice "$1" | sed -e '1s/^/WARNING: /' \
 exit $st
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:

+ 9 - 5
python/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -163,6 +163,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MINGW = @MINGW@
@@ -264,8 +265,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -289,7 +290,10 @@ ctags CTAGS:
 cscope cscopelist:
 
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \

+ 2 - 2
src/Makefile.am

@@ -8,8 +8,8 @@ AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"'
 AM_CFLAGS = $(CFLAG_VISIBILITY) @WARNINGS@
 
 libmagic_la_SOURCES = buffer.c magic.c apprentice.c softmagic.c ascmagic.c \
-	encoding.c compress.c is_json.c is_tar.c readelf.c print.c fsmagic.c \
-	funcs.c file.h readelf.h tar.h apptype.c der.c der.h \
+	encoding.c compress.c is_csv.c is_json.c is_tar.c readelf.c print.c \
+	fsmagic.c funcs.c file.h readelf.h tar.h apptype.c der.c der.h \
 	file_opts.h elfclass.h mygetopt.h cdf.c cdf_time.c readcdf.c cdf.h
 libmagic_la_LDFLAGS = -no-undefined -version-info 1:0:0
 if MINGW

+ 188 - 91
src/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -103,6 +103,9 @@ mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" \
+	"$(DESTDIR)$(includedir)"
+PROGRAMS = $(bin_PROGRAMS)
 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
 am__vpath_adj = case $$p in \
     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -130,15 +133,13 @@ am__uninstall_files_from_dir = { \
     || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
          $(am__cd) "$$dir" && rm -f $$files; }; \
   }
-am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
-	"$(DESTDIR)$(includedir)"
 LTLIBRARIES = $(lib_LTLIBRARIES)
 am__DEPENDENCIES_1 =
 libmagic_la_DEPENDENCIES = $(LTLIBOBJS) $(am__DEPENDENCIES_1)
 am_libmagic_la_OBJECTS = buffer.lo magic.lo apprentice.lo softmagic.lo \
-	ascmagic.lo encoding.lo compress.lo is_json.lo is_tar.lo \
-	readelf.lo print.lo fsmagic.lo funcs.lo apptype.lo der.lo \
-	cdf.lo cdf_time.lo readcdf.lo
+	ascmagic.lo encoding.lo compress.lo is_csv.lo is_json.lo \
+	is_tar.lo readelf.lo print.lo fsmagic.lo funcs.lo apptype.lo \
+	der.lo cdf.lo cdf_time.lo readcdf.lo
 libmagic_la_OBJECTS = $(am_libmagic_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -147,7 +148,6 @@ am__v_lt_1 =
 libmagic_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
 	$(libmagic_la_LDFLAGS) $(LDFLAGS) -o $@
-PROGRAMS = $(bin_PROGRAMS)
 am_file_OBJECTS = file.$(OBJEXT) seccomp.$(OBJEXT)
 file_OBJECTS = $(am_file_OBJECTS)
 file_DEPENDENCIES = libmagic.la
@@ -165,7 +165,25 @@ am__v_at_0 = @
 am__v_at_1 = 
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = $(DEPDIR)/asctime_r.Plo $(DEPDIR)/asprintf.Plo \
+	$(DEPDIR)/ctime_r.Plo $(DEPDIR)/dprintf.Plo \
+	$(DEPDIR)/fmtcheck.Plo $(DEPDIR)/getline.Plo \
+	$(DEPDIR)/getopt_long.Plo $(DEPDIR)/gmtime_r.Plo \
+	$(DEPDIR)/localtime_r.Plo $(DEPDIR)/pread.Plo \
+	$(DEPDIR)/strcasestr.Plo $(DEPDIR)/strlcat.Plo \
+	$(DEPDIR)/strlcpy.Plo $(DEPDIR)/vasprintf.Plo \
+	./$(DEPDIR)/apprentice.Plo ./$(DEPDIR)/apptype.Plo \
+	./$(DEPDIR)/ascmagic.Plo ./$(DEPDIR)/buffer.Plo \
+	./$(DEPDIR)/cdf.Plo ./$(DEPDIR)/cdf_time.Plo \
+	./$(DEPDIR)/compress.Plo ./$(DEPDIR)/der.Plo \
+	./$(DEPDIR)/encoding.Plo ./$(DEPDIR)/file.Po \
+	./$(DEPDIR)/fsmagic.Plo ./$(DEPDIR)/funcs.Plo \
+	./$(DEPDIR)/is_csv.Plo ./$(DEPDIR)/is_json.Plo \
+	./$(DEPDIR)/is_tar.Plo ./$(DEPDIR)/magic.Plo \
+	./$(DEPDIR)/print.Plo ./$(DEPDIR)/readcdf.Plo \
+	./$(DEPDIR)/readelf.Plo ./$(DEPDIR)/seccomp.Po \
+	./$(DEPDIR)/softmagic.Plo
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -259,6 +277,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MINGW = @MINGW@
@@ -343,8 +362,8 @@ nodist_include_HEADERS = magic.h
 AM_CPPFLAGS = -DMAGIC='"$(MAGIC)"'
 AM_CFLAGS = $(CFLAG_VISIBILITY) @WARNINGS@
 libmagic_la_SOURCES = buffer.c magic.c apprentice.c softmagic.c ascmagic.c \
-	encoding.c compress.c is_json.c is_tar.c readelf.c print.c fsmagic.c \
-	funcs.c file.h readelf.h tar.h apptype.c der.c der.h \
+	encoding.c compress.c is_csv.c is_json.c is_tar.c readelf.c print.c \
+	fsmagic.c funcs.c file.h readelf.h tar.h apptype.c der.c der.h \
 	file_opts.h elfclass.h mygetopt.h cdf.c cdf_time.c readcdf.c cdf.h
 
 libmagic_la_LDFLAGS = -no-undefined -version-info 1:0:0
@@ -379,8 +398,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -391,44 +410,6 @@ $(top_srcdir)/configure:  $(am__configure_deps)
 $(ACLOCAL_M4):  $(am__aclocal_m4_deps)
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
-
-install-libLTLIBRARIES: $(lib_LTLIBRARIES)
-	@$(NORMAL_INSTALL)
-	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
-	list2=; for p in $$list; do \
-	  if test -f $$p; then \
-	    list2="$$list2 $$p"; \
-	  else :; fi; \
-	done; \
-	test -z "$$list2" || { \
-	  echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
-	  $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
-	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
-	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
-	}
-
-uninstall-libLTLIBRARIES:
-	@$(NORMAL_UNINSTALL)
-	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
-	for p in $$list; do \
-	  $(am__strip_dir) \
-	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
-	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
-	done
-
-clean-libLTLIBRARIES:
-	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-	@list='$(lib_LTLIBRARIES)'; \
-	locs=`for p in $$list; do echo $$p; done | \
-	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
-	      sort -u`; \
-	test -z "$$locs" || { \
-	  echo rm -f $${locs}; \
-	  rm -f $${locs}; \
-	}
-
-libmagic.la: $(libmagic_la_OBJECTS) $(libmagic_la_DEPENDENCIES) $(EXTRA_libmagic_la_DEPENDENCIES) 
-	$(AM_V_CCLD)$(libmagic_la_LINK) -rpath $(libdir) $(libmagic_la_OBJECTS) $(libmagic_la_LIBADD) $(LIBS)
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
 	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
@@ -479,6 +460,44 @@ clean-binPROGRAMS:
 	echo " rm -f" $$list; \
 	rm -f $$list
 
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+	@$(NORMAL_INSTALL)
+	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+	list2=; for p in $$list; do \
+	  if test -f $$p; then \
+	    list2="$$list2 $$p"; \
+	  else :; fi; \
+	done; \
+	test -z "$$list2" || { \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+	}
+
+uninstall-libLTLIBRARIES:
+	@$(NORMAL_UNINSTALL)
+	@list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+	for p in $$list; do \
+	  $(am__strip_dir) \
+	  echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+	  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+	done
+
+clean-libLTLIBRARIES:
+	-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+	@list='$(lib_LTLIBRARIES)'; \
+	locs=`for p in $$list; do echo $$p; done | \
+	      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+	      sort -u`; \
+	test -z "$$locs" || { \
+	  echo rm -f $${locs}; \
+	  rm -f $${locs}; \
+	}
+
+libmagic.la: $(libmagic_la_OBJECTS) $(libmagic_la_DEPENDENCIES) $(EXTRA_libmagic_la_DEPENDENCIES) 
+	$(AM_V_CCLD)$(libmagic_la_LINK) -rpath $(libdir) $(libmagic_la_OBJECTS) $(libmagic_la_LIBADD) $(LIBS)
+
 file$(EXEEXT): $(file_OBJECTS) $(file_DEPENDENCIES) $(EXTRA_file_DEPENDENCIES) 
 	@rm -f file$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(file_OBJECTS) $(file_LDADD) $(LIBS)
@@ -489,40 +508,47 @@ 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)/dprintf.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/fmtcheck.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)/gmtime_r.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/localtime_r.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pread.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strcasestr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcat.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcpy.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vasprintf.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/apprentice.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/apptype.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascmagic.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buffer.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdf.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdf_time.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compress.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/der.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encoding.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsmagic.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/funcs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_json.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_tar.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/magic.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readcdf.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readelf.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/seccomp.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/softmagic.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asctime_r.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asprintf.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ctime_r.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/dprintf.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/fmtcheck.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getline.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt_long.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/gmtime_r.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/localtime_r.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pread.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strcasestr.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcat.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcpy.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vasprintf.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/apprentice.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/apptype.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascmagic.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/buffer.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdf.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdf_time.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compress.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/der.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encoding.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsmagic.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/funcs.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_csv.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_json.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_tar.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/magic.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readcdf.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readelf.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/seccomp.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/softmagic.Plo@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+	@$(MKDIR_P) $(@D)
+	@echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -627,7 +653,10 @@ cscopelist-am: $(am__tagged_files)
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \
@@ -660,11 +689,11 @@ distdir: $(DISTFILES)
 check-am: all-am
 check: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) check-am
-all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS)
+all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(HEADERS)
 install-binPROGRAMS: install-libLTLIBRARIES
 
 installdirs:
-	for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \
+	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \
 	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
 	done
 install: $(BUILT_SOURCES)
@@ -706,7 +735,41 @@ clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
 	clean-libtool mostlyclean-am
 
 distclean: distclean-am
-	-rm -rf $(DEPDIR) ./$(DEPDIR)
+		-rm -f $(DEPDIR)/asctime_r.Plo
+	-rm -f $(DEPDIR)/asprintf.Plo
+	-rm -f $(DEPDIR)/ctime_r.Plo
+	-rm -f $(DEPDIR)/dprintf.Plo
+	-rm -f $(DEPDIR)/fmtcheck.Plo
+	-rm -f $(DEPDIR)/getline.Plo
+	-rm -f $(DEPDIR)/getopt_long.Plo
+	-rm -f $(DEPDIR)/gmtime_r.Plo
+	-rm -f $(DEPDIR)/localtime_r.Plo
+	-rm -f $(DEPDIR)/pread.Plo
+	-rm -f $(DEPDIR)/strcasestr.Plo
+	-rm -f $(DEPDIR)/strlcat.Plo
+	-rm -f $(DEPDIR)/strlcpy.Plo
+	-rm -f $(DEPDIR)/vasprintf.Plo
+	-rm -f ./$(DEPDIR)/apprentice.Plo
+	-rm -f ./$(DEPDIR)/apptype.Plo
+	-rm -f ./$(DEPDIR)/ascmagic.Plo
+	-rm -f ./$(DEPDIR)/buffer.Plo
+	-rm -f ./$(DEPDIR)/cdf.Plo
+	-rm -f ./$(DEPDIR)/cdf_time.Plo
+	-rm -f ./$(DEPDIR)/compress.Plo
+	-rm -f ./$(DEPDIR)/der.Plo
+	-rm -f ./$(DEPDIR)/encoding.Plo
+	-rm -f ./$(DEPDIR)/file.Po
+	-rm -f ./$(DEPDIR)/fsmagic.Plo
+	-rm -f ./$(DEPDIR)/funcs.Plo
+	-rm -f ./$(DEPDIR)/is_csv.Plo
+	-rm -f ./$(DEPDIR)/is_json.Plo
+	-rm -f ./$(DEPDIR)/is_tar.Plo
+	-rm -f ./$(DEPDIR)/magic.Plo
+	-rm -f ./$(DEPDIR)/print.Plo
+	-rm -f ./$(DEPDIR)/readcdf.Plo
+	-rm -f ./$(DEPDIR)/readelf.Plo
+	-rm -f ./$(DEPDIR)/seccomp.Po
+	-rm -f ./$(DEPDIR)/softmagic.Plo
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
@@ -752,7 +815,41 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-	-rm -rf $(DEPDIR) ./$(DEPDIR)
+		-rm -f $(DEPDIR)/asctime_r.Plo
+	-rm -f $(DEPDIR)/asprintf.Plo
+	-rm -f $(DEPDIR)/ctime_r.Plo
+	-rm -f $(DEPDIR)/dprintf.Plo
+	-rm -f $(DEPDIR)/fmtcheck.Plo
+	-rm -f $(DEPDIR)/getline.Plo
+	-rm -f $(DEPDIR)/getopt_long.Plo
+	-rm -f $(DEPDIR)/gmtime_r.Plo
+	-rm -f $(DEPDIR)/localtime_r.Plo
+	-rm -f $(DEPDIR)/pread.Plo
+	-rm -f $(DEPDIR)/strcasestr.Plo
+	-rm -f $(DEPDIR)/strlcat.Plo
+	-rm -f $(DEPDIR)/strlcpy.Plo
+	-rm -f $(DEPDIR)/vasprintf.Plo
+	-rm -f ./$(DEPDIR)/apprentice.Plo
+	-rm -f ./$(DEPDIR)/apptype.Plo
+	-rm -f ./$(DEPDIR)/ascmagic.Plo
+	-rm -f ./$(DEPDIR)/buffer.Plo
+	-rm -f ./$(DEPDIR)/cdf.Plo
+	-rm -f ./$(DEPDIR)/cdf_time.Plo
+	-rm -f ./$(DEPDIR)/compress.Plo
+	-rm -f ./$(DEPDIR)/der.Plo
+	-rm -f ./$(DEPDIR)/encoding.Plo
+	-rm -f ./$(DEPDIR)/file.Po
+	-rm -f ./$(DEPDIR)/fsmagic.Plo
+	-rm -f ./$(DEPDIR)/funcs.Plo
+	-rm -f ./$(DEPDIR)/is_csv.Plo
+	-rm -f ./$(DEPDIR)/is_json.Plo
+	-rm -f ./$(DEPDIR)/is_tar.Plo
+	-rm -f ./$(DEPDIR)/magic.Plo
+	-rm -f ./$(DEPDIR)/print.Plo
+	-rm -f ./$(DEPDIR)/readcdf.Plo
+	-rm -f ./$(DEPDIR)/readelf.Plo
+	-rm -f ./$(DEPDIR)/seccomp.Po
+	-rm -f ./$(DEPDIR)/softmagic.Plo
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
@@ -774,7 +871,7 @@ uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES \
 
 .MAKE: all check install install-am install-strip
 
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
 	clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
 	clean-libtool cscopelist-am ctags ctags-am distclean \
 	distclean-compile distclean-generic distclean-libtool \

+ 2 - 12
src/apprentice.c

@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.283 2019/02/20 02:35:27 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.284 2019/06/29 22:31:04 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -1926,17 +1926,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line,
 			file_magwarn(ms, "offset `%s' invalid", l);
 		return -1;
 	}
-#if 0
-        if (m->offset < 0 && cont_level != 0 &&
-	    (m->flag & (OFFADD | INDIROFFADD)) == 0) {
-		if (ms->flags & MAGIC_CHECK) {
-			file_magwarn(ms,
-			    "negative direct offset `%s' at level %u",
-			    l, cont_level);
-		}
-		return -1;
-	}
-#endif
+
         l = t;
 
 	if (m->flag & INDIR) {

+ 1 - 2
src/ascmagic.c

@@ -35,12 +35,11 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: ascmagic.c,v 1.104 2019/05/07 02:27:11 christos Exp $")
+FILE_RCSID("@(#)$File: ascmagic.c,v 1.105 2019/06/08 20:49:14 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
 #include <string.h>
-#include <memory.h>
 #include <ctype.h>
 #include <stdlib.h>
 #ifdef HAVE_UNISTD_H

+ 2 - 1
src/buffer.c

@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: buffer.c,v 1.6 2019/05/07 02:27:11 christos Exp $")
+FILE_RCSID("@(#)$File: buffer.c,v 1.7 2019/06/10 21:35:26 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -77,6 +77,7 @@ buffer_fill(const struct buffer *bb)
 	b->eoff = b->st.st_size - b->elen;
 	if (pread(b->fd, b->ebuf, b->elen, b->eoff) == -1) {
 		free(b->ebuf);
+		b->ebuf = NULL;
 		goto out;
 	}
 

+ 20 - 7
src/cdf.c

@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: cdf.c,v 1.114 2019/02/20 02:35:27 christos Exp $")
+FILE_RCSID("@(#)$File: cdf.c,v 1.116 2019/08/26 14:31:39 christos Exp $")
 #endif
 
 #include <assert.h>
@@ -53,6 +53,10 @@ FILE_RCSID("@(#)$File: cdf.c,v 1.114 2019/02/20 02:35:27 christos Exp $")
 #define EFTYPE EINVAL
 #endif
 
+#ifndef SIZE_T_MAX
+#define SIZE_T_MAX CAST(size_t, ~0ULL)
+#endif
+
 #include "cdf.h"
 
 #ifdef CDF_DEBUG
@@ -405,7 +409,12 @@ cdf_read_sector(const cdf_info_t *info, void *buf, size_t offs, size_t len,
     const cdf_header_t *h, cdf_secid_t id)
 {
 	size_t ss = CDF_SEC_SIZE(h);
-	size_t pos = CDF_SEC_POS(h, id);
+	size_t pos;
+
+	if (SIZE_T_MAX / ss < CAST(size_t, id))
+		return -1;
+
+	pos = CDF_SEC_POS(h, id);
 	assert(ss == len);
 	return cdf_read(info, CAST(off_t, pos), RCAST(char *, buf) + offs, len);
 }
@@ -415,7 +424,12 @@ cdf_read_short_sector(const cdf_stream_t *sst, void *buf, size_t offs,
     size_t len, const cdf_header_t *h, cdf_secid_t id)
 {
 	size_t ss = CDF_SHORT_SEC_SIZE(h);
-	size_t pos = CDF_SHORT_SEC_POS(h, id);
+	size_t pos;
+
+	if (SIZE_T_MAX / ss < CAST(size_t, id))
+		return -1;
+
+	pos = CDF_SHORT_SEC_POS(h, id);
 	assert(ss == len);
 	if (pos + len > CDF_SEC_SIZE(h) * sst->sst_len) {
 		DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
@@ -1013,8 +1027,9 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
 				goto out;
 			}
 			nelements = CDF_GETUINT32(q, 1);
-			if (nelements == 0) {
-				DPRINTF(("CDF_VECTOR with nelements == 0\n"));
+			if (nelements > CDF_ELEMENT_LIMIT || nelements == 0) {
+				DPRINTF(("CDF_VECTOR with nelements == %"
+				    SIZE_T_FORMAT "u\n", nelements));
 				goto out;
 			}
 			slen = 2;
@@ -1056,8 +1071,6 @@ cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
 					goto out;
 				inp += nelem;
 			}
-			DPRINTF(("nelements = %" SIZE_T_FORMAT "u\n",
-			    nelements));
 			for (j = 0; j < nelements && i < sh.sh_properties;
 			    j++, i++)
 			{

+ 1 - 0
src/cdf.h

@@ -48,6 +48,7 @@
 typedef int32_t cdf_secid_t;
 
 #define CDF_LOOP_LIMIT					10000
+#define CDF_ELEMENT_LIMIT				100000
 
 #define CDF_SECID_NULL					0
 #define CDF_SECID_FREE					-1

+ 165 - 31
src/compress.c

@@ -35,7 +35,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.121 2019/05/07 02:27:11 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.124 2019/07/21 11:42:09 christos Exp $")
 #endif
 
 #include "magic.h"
@@ -66,11 +66,16 @@ typedef void (*sig_t)(int);
 #include <zlib.h>
 #endif
 
-#if defined(HAVE_BZLIB_H)
+#if defined(HAVE_BZLIB_H) || defined(BZLIBSUPPORT)
 #define BUILTIN_BZLIB
 #include <bzlib.h>
 #endif
 
+#if defined(HAVE_XZLIB_H) || defined(XZLIBSUPPORT)
+#define BUILTIN_XZLIB
+#include <lzma.h>
+#endif
+
 #ifdef DEBUG
 int tty = -1;
 #define DPRINTF(...)	do { \
@@ -113,6 +118,16 @@ zlibcmp(const unsigned char *buf)
 }
 #endif
 
+static int
+lzmacmp(const unsigned char *buf)
+{
+	if (buf[0] != 0x5d || buf[1] || buf[2])
+		return 0;
+	if (buf[12] && buf[12] != 0xff)
+		return 0;
+	return 1;
+}
+
 #define gzip_flags "-cd"
 #define lrzip_flags "-do"
 #define lzip_flags gzip_flags
@@ -147,29 +162,35 @@ static const char *zstd_args[] = {
 
 private const struct {
 	const void *magic;
-	size_t maglen;
+	int maglen;
 	const char **argv;
 	void *unused;
 } compr[] = {
-	{ "\037\235",	2, gzip_args, NULL },		/* compressed */
+#define METH_FROZEN	2
+#define METH_BZIP	7
+#define METH_XZ		9
+#define METH_LZMA	13
+#define METH_ZLIB	14
+	{ "\037\235",	2, gzip_args, NULL },		/* 0, compressed */
 	/* Uncompress can get stuck; so use gzip first if we have it
 	 * Idea from Damien Clark, thanks! */
-	{ "\037\235",	2, uncompress_args, NULL },	/* compressed */
-	{ "\037\213",	2, gzip_args, do_zlib },	/* gzipped */
-	{ "\037\236",	2, gzip_args, NULL },		/* frozen */
-	{ "\037\240",	2, gzip_args, NULL },		/* SCO LZH */
+	{ "\037\235",	2, uncompress_args, NULL },	/* 1, compressed */
+	{ "\037\213",	2, gzip_args, do_zlib },	/* 2, gzipped */
+	{ "\037\236",	2, gzip_args, NULL },		/* 3, frozen */
+	{ "\037\240",	2, gzip_args, NULL },		/* 4, SCO LZH */
 	/* the standard pack utilities do not accept standard input */
-	{ "\037\036",	2, gzip_args, NULL },		/* packed */
-	{ "PK\3\4",	4, gzip_args, NULL },		/* pkzipped, */
+	{ "\037\036",	2, gzip_args, NULL },		/* 5, packed */
+	{ "PK\3\4",	4, gzip_args, NULL },		/* 6, pkzipped, */
 	/* ...only first file examined */
-	{ "BZh",	3, bzip2_args, do_bzlib },	/* bzip2-ed */
-	{ "LZIP",	4, lzip_args, NULL },		/* lzip-ed */
- 	{ "\3757zXZ\0",	6, xz_args, NULL },		/* XZ Utils */
- 	{ "LRZI",	4, lrzip_args, NULL },	/* LRZIP */
- 	{ "\004\"M\030",4, lz4_args, NULL },		/* LZ4 */
- 	{ "\x28\xB5\x2F\xFD", 4, zstd_args, NULL },	/* zstd */
+	{ "BZh",	3, bzip2_args, do_bzlib },	/* 7, bzip2-ed */
+	{ "LZIP",	4, lzip_args, NULL },		/* 8, lzip-ed */
+ 	{ "\3757zXZ\0",	6, xz_args, NULL },		/* 9, XZ Utils */
+ 	{ "LRZI",	4, lrzip_args, NULL },	/* 10, LRZIP */
+ 	{ "\004\"M\030",4, lz4_args, NULL },		/* 11, LZ4 */
+ 	{ "\x28\xB5\x2F\xFD", 4, zstd_args, NULL },	/* 12, zstd */
+	{ RCAST(const void *, lzmacmp),	-13, xz_args, NULL },	/* 13, lzma */
 #ifdef ZLIBSUPPORT
-	{ RCAST(const void *, zlibcmp),	0, zlib_args, NULL },	/* zlib */
+	{ RCAST(const void *, zlibcmp),	-2, zlib_args, NULL },	/* 14, zlib */
 #endif
 };
 
@@ -190,7 +211,11 @@ private int uncompressgzipped(const unsigned char *, unsigned char **, size_t,
 #endif
 #ifdef BUILTIN_BZLIB
 private int uncompressbzlib(const unsigned char *, unsigned char **, size_t,
-    size_t *, int);
+    size_t *);
+#endif
+#ifdef BUILTIN_XZLIB
+private int uncompressxzlib(const unsigned char *, unsigned char **, size_t,
+    size_t *);
 #endif
 
 static int makeerror(unsigned char **, size_t *, const char *, ...)
@@ -234,15 +259,15 @@ file_zmagic(struct magic_set *ms, const struct buffer *b, const char *name)
 
 	for (i = 0; i < ncompr; i++) {
 		int zm;
-		if (nbytes < compr[i].maglen)
+		if (nbytes < CAST(size_t, abs(compr[i].maglen)))
 			continue;
-#ifdef ZLIBSUPPORT
-		if (compr[i].maglen == 0)
+		if (compr[i].maglen < 0) {
 			zm = (RCAST(int (*)(const unsigned char *),
 			    CCAST(void *, compr[i].magic)))(buf);
-		else
-#endif
-			zm = memcmp(buf, compr[i].magic, compr[i].maglen) == 0;
+		} else {
+			zm = memcmp(buf, compr[i].magic,
+			    CAST(size_t, compr[i].maglen)) == 0;
+		}
 
 		if (!zm)
 			continue;
@@ -570,6 +595,90 @@ err:
 }
 #endif
 
+#ifdef BUILTIN_BZLIB
+private int
+uncompressbzlib(const unsigned char *old, unsigned char **newch,
+    size_t bytes_max, size_t *n)
+{
+	int rc;
+	bz_stream bz;
+
+	memset(&bz, 0, sizeof(bz));
+	rc = BZ2_bzDecompressInit(&bz, 0, 0);
+	if (rc != BZ_OK)
+		goto err;
+
+	if ((*newch = CAST(unsigned char *, malloc(bytes_max + 1))) == NULL)
+		return makeerror(newch, n, "No buffer, %s", strerror(errno));
+
+	bz.next_in = CCAST(char *, RCAST(const char *, old));
+	bz.avail_in = CAST(uint32_t, *n);
+	bz.next_out = RCAST(char *, *newch);
+	bz.avail_out = CAST(unsigned int, bytes_max);
+
+	rc = BZ2_bzDecompress(&bz);
+	if (rc != BZ_OK && rc != BZ_STREAM_END)
+		goto err;
+
+	/* Assume byte_max is within 32bit */
+	/* assert(bz.total_out_hi32 == 0); */
+	*n = CAST(size_t, bz.total_out_lo32);
+	rc = BZ2_bzDecompressEnd(&bz);
+	if (rc != BZ_OK)
+		goto err;
+
+	/* let's keep the nul-terminate tradition */
+	(*newch)[*n] = '\0';
+
+	return OKDATA;
+err:
+	snprintf(RCAST(char *, *newch), bytes_max, "bunzip error %d", rc);
+	*n = strlen(RCAST(char *, *newch));
+	return ERRDATA;
+}
+#endif
+
+#ifdef BUILTIN_XZLIB
+private int
+uncompressxzlib(const unsigned char *old, unsigned char **newch,
+    size_t bytes_max, size_t *n)
+{
+	int rc;
+	lzma_stream xz;
+
+	memset(&xz, 0, sizeof(xz));
+	rc = lzma_auto_decoder(&xz, UINT64_MAX, 0);
+	if (rc != LZMA_OK)
+		goto err;
+
+	if ((*newch = CAST(unsigned char *, malloc(bytes_max + 1))) == NULL)
+		return makeerror(newch, n, "No buffer, %s", strerror(errno));
+
+	xz.next_in = CCAST(const uint8_t *, old);
+	xz.avail_in = CAST(uint32_t, *n);
+	xz.next_out = RCAST(uint8_t *, *newch);
+	xz.avail_out = CAST(unsigned int, bytes_max);
+
+	rc = lzma_code(&xz, LZMA_RUN);
+	if (rc != LZMA_OK && rc != LZMA_STREAM_END)
+		goto err;
+
+	*n = CAST(size_t, xz.total_out);
+
+	lzma_end(&xz);
+
+	/* let's keep the nul-terminate tradition */
+	(*newch)[*n] = '\0';
+
+	return OKDATA;
+err:
+	snprintf(RCAST(char *, *newch), bytes_max, "unxz error %d", rc);
+	*n = strlen(RCAST(char *, *newch));
+	return ERRDATA;
+}
+#endif
+
+
 static int
 makeerror(unsigned char **buf, size_t *len, const char *fmt, ...)
 {
@@ -676,12 +785,24 @@ filter_error(unsigned char *ubuf, ssize_t n)
 private const char *
 methodname(size_t method)
 {
+	switch (method) {
 #ifdef BUILTIN_DECOMPRESS
-        /* FIXME: This doesn't cope with bzip2 */
-	if (method == 2 || compr[method].maglen == 0)
-	    return "zlib";
+	case METH_FROZEN:
+	case METH_ZLIB:
+		return "zlib";
+#endif
+#ifdef BUILTIN_BZLIB
+	case METH_BZIP:
+		return "bzlib";
 #endif
-	return compr[method].argv[0];
+#ifdef BUILTIN_XZLIB
+	case METH_XZ:
+	case METH_LZMA:
+		return "xzlib";
+#endif
+	default:
+		return compr[method].argv[0];
+	}
 }
 
 private int
@@ -695,13 +816,26 @@ uncompressbuf(int fd, size_t bytes_max, size_t method, const unsigned char *old,
 	size_t i;
 	ssize_t r;
 
+	switch (method) {
 #ifdef BUILTIN_DECOMPRESS
-        /* FIXME: This doesn't cope with bzip2 */
-	if (method == 2)
+	case METH_FROZEN:
 		return uncompressgzipped(old, newch, bytes_max, n);
-	if (compr[method].maglen == 0)
+	case METH_ZLIB:
 		return uncompresszlib(old, newch, bytes_max, n, 1);
 #endif
+#ifdef BUILTIN_BZLIB
+	case METH_BZIP:
+		return uncompressbzlib(old, newch, bytes_max, n);
+#endif
+#ifdef BUILTIN_XZLIB
+	case METH_XZ:
+	case METH_LZMA:
+		return uncompressxzlib(old, newch, bytes_max, n);
+#endif
+	default:
+		break;
+	}
+
 	(void)fflush(stdout);
 	(void)fflush(stderr);
 

+ 1 - 2
src/encoding.c

@@ -35,12 +35,11 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: encoding.c,v 1.20 2019/04/15 16:48:41 christos Exp $")
+FILE_RCSID("@(#)$File: encoding.c,v 1.21 2019/06/08 20:49:14 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
 #include <string.h>
-#include <memory.h>
 #include <stdlib.h>
 
 

+ 8 - 10
src/file.c

@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: file.c,v 1.181 2019/03/28 20:54:03 christos Exp $")
+FILE_RCSID("@(#)$File: file.c,v 1.184 2019/08/03 11:51:59 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -76,13 +76,7 @@ int getopt_long(int, char * const *, const char *,
 # define IFLNK_L ""
 #endif
 
-#ifdef HAVE_LIBSECCOMP
-# define SECCOMP_S "S"
-#else
-# define SECCOMP_S ""
-#endif
-
-#define FILE_FLAGS	"bcCdE" IFLNK_h "ik" IFLNK_L "lNnprs" SECCOMP_S "vzZ0"
+#define FILE_FLAGS	"bcCdE" IFLNK_h "ik" IFLNK_L "lNnprsSvzZ0"
 #define OPTSTRING	"bcCde:Ef:F:hiklLm:nNpP:rsSvzZ0"
 
 # define USAGE  \
@@ -124,6 +118,7 @@ private const struct {
 	{ "ascii",	MAGIC_NO_CHECK_ASCII },
 	{ "cdf",	MAGIC_NO_CHECK_CDF },
 	{ "compress",	MAGIC_NO_CHECK_COMPRESS },
+	{ "csv",	MAGIC_NO_CHECK_CSV },
 	{ "elf",	MAGIC_NO_CHECK_ELF },
 	{ "encoding",	MAGIC_NO_CHECK_ENCODING },
 	{ "soft",	MAGIC_NO_CHECK_SOFT },
@@ -297,11 +292,11 @@ main(int argc, char *argv[])
 		case 's':
 			flags |= MAGIC_DEVICES;
 			break;
-#ifdef HAVE_LIBSECCOMP
 		case 'S':
+#ifdef HAVE_LIBSECCOMP
 			sandbox = 0;
-			break;
 #endif
+			break;
 		case 'v':
 			if (magicfile == NULL)
 				magicfile = magic_getpath(magicfile, action);
@@ -309,6 +304,9 @@ main(int argc, char *argv[])
 			    VERSION);
 			(void)fprintf(stdout, "magic file from %s\n",
 			    magicfile);
+#ifdef HAVE_LIBSECCOMP
+			(void)fprintf(stdout, "seccomp support included\n");
+#endif
 			return 0;
 		case 'z':
 			flags |= MAGIC_COMPRESS;

+ 2 - 1
src/file.h

@@ -27,7 +27,7 @@
  */
 /*
  * file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.206 2019/05/07 02:27:11 christos Exp $
+ * @(#)$File: file.h,v 1.208 2019/06/26 20:31:31 christos Exp $
  */
 
 #ifndef __file_h__
@@ -479,6 +479,7 @@ protected int file_ascmagic_with_encoding(struct magic_set *,
 protected int file_encoding(struct magic_set *, const struct buffer *,
     unichar **, size_t *, const char **, const char **, const char **);
 protected int file_is_json(struct magic_set *, const struct buffer *);
+protected int file_is_csv(struct magic_set *, const struct buffer *, int);
 protected int file_is_tar(struct magic_set *, const struct buffer *);
 protected int file_softmagic(struct magic_set *, const struct buffer *,
     uint16_t *, uint16_t *, int, int);

+ 4 - 3
src/file_opts.h

@@ -4,7 +4,10 @@
  * The first column specifies the short name, if any, or 0 if none.
  * The second column specifies the long name.
  * The third column specifies whether it takes a parameter.
- * The fourth column is the documentation.
+ * The fourth colums specifies whether is is marked as "default"
+ *      if POSIXLY_CORRECT is defined: 1,
+ *      if POSIXLY_CORRECT is not defined: 2.
+ * The fifth column is the documentation.
  *
  * N.B. The long options' order must correspond to the code in file.c,
  * and OPTSTRING must be kept up-to-date with the short options.
@@ -54,8 +57,6 @@ OPT('P', "parameter", 1, 0, "            set file engine parameter limits\n"
 OPT('r', "raw", 0, 0, "                  don't translate unprintable chars to \\ooo\n")
 OPT('s', "special-files", 0, 0, "        treat special (block/char devices) files as\n"
     "                             ordinary ones\n")
-#ifdef HAVE_LIBSECCOMP
 OPT('S', "no-sandbox", 0, 0, "           disable system call sandboxing\n")
-#endif
 OPT('C', "compile", 0, 0, "              compile file specified by -m\n")
 OPT('d', "debug", 0, 0, "                print debugging messages\n")

+ 7 - 1
src/fsmagic.c

@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: fsmagic.c,v 1.80 2019/04/23 18:59:27 christos Exp $")
+FILE_RCSID("@(#)$File: fsmagic.c,v 1.81 2019/07/16 13:30:32 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -425,5 +425,11 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
 	    if (file_printf(ms, " ") == -1)
 		    return -1;
 	}
+	/*
+	 * If we were looking for extensions or apple (silent) it is not our
+	 * job to print here, so don't count this as a match.
+	 */
+	if (ret == 1 && silent)
+		return 0;
 	return ret;
 }

+ 20 - 3
src/funcs.c

@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.104 2019/05/07 02:27:11 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.108 2019/11/09 00:35:46 christos Exp $")
 #endif	/* lint */
 
 #include "magic.h"
@@ -283,6 +283,17 @@ file_buffer(struct magic_set *ms, int fd, struct stat *st,
 		}
 	}
 
+	/* Check if we have a CSV file */
+	if ((ms->flags & MAGIC_NO_CHECK_CSV) == 0) {
+		m = file_is_csv(ms, &b, looks_text);
+		if ((ms->flags & MAGIC_DEBUG) != 0)
+			(void)fprintf(stderr, "[try csv %d]\n", m);
+		if (m) {
+			if (checkdone(ms, &rv))
+				goto done;
+		}
+	}
+
 	/* Check if we have a CDF file */
 	if ((ms->flags & MAGIC_NO_CHECK_CDF) == 0) {
 		m = file_trycdf(ms, &b);
@@ -545,7 +556,11 @@ file_regcomp(file_regex_t *rx, const char *pat, int flags)
 	rx->old_lc_ctype = uselocale(rx->c_lc_ctype);
 	assert(rx->old_lc_ctype != NULL);
 #else
-	rx->old_lc_ctype = setlocale(LC_CTYPE, "C");
+	rx->old_lc_ctype = setlocale(LC_CTYPE, NULL);
+	assert(rx->old_lc_ctype != NULL);
+	rx->old_lc_ctype = strdup(rx->old_lc_ctype);
+	assert(rx->old_lc_ctype != NULL);
+	(void)setlocale(LC_CTYPE, "C");
 #endif
 	rx->pat = pat;
 
@@ -558,7 +573,8 @@ file_regexec(file_regex_t *rx, const char *str, size_t nmatch,
 {
 	assert(rx->rc == 0);
 	/* XXX: force initialization because glibc does not always do this */
-	memset(pmatch, 0, nmatch * sizeof(*pmatch));
+	if (nmatch != 0)
+		memset(pmatch, 0, nmatch * sizeof(*pmatch));
 	return regexec(&rx->rx, str, nmatch, pmatch, eflags);
 }
 
@@ -572,6 +588,7 @@ file_regfree(file_regex_t *rx)
 	freelocale(rx->c_lc_ctype);
 #else
 	(void)setlocale(LC_CTYPE, rx->old_lc_ctype);
+	free(rx->old_lc_ctype);
 #endif
 }
 

+ 197 - 0
src/is_csv.c

@@ -0,0 +1,197 @@
+/*-
+ * Copyright (c) 2019 Christos Zoulas
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Parse CSV object serialization format (RFC-4180, RFC-7111)
+ */
+
+#ifndef TEST
+#include "file.h"
+
+#ifndef lint
+FILE_RCSID("@(#)$File: is_csv.c,v 1.4 2019/06/26 20:31:31 christos Exp $")
+#endif
+
+#include <string.h>
+#include "magic.h"
+#else
+#include <sys/types.h>
+#endif
+
+
+#ifdef DEBUG
+#include <stdio.h>
+#define DPRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
+#else
+#define DPRINTF(fmt, ...)
+#endif
+
+/*
+ * if CSV_LINES == 0:
+ *	check all the lines in the buffer
+ * otherwise:
+ *	check only up-to the number of lines specified
+ *
+ * the last line count is always ignored if it does not end in CRLF
+ */
+#ifndef CSV_LINES
+#define CSV_LINES 10
+#endif
+
+static int csv_parse(const unsigned char *, const unsigned char *);
+
+static const unsigned char *
+eatquote(const unsigned char *uc, const unsigned char *ue)
+{
+	int quote = 0;
+
+	while (uc < ue) {
+		unsigned char c = *uc++;
+		if (c != '"') {
+			// We already got one, done.
+			if (quote) {
+				return --uc;
+			}
+			continue;
+		}
+		if (quote) {
+			// quote-quote escapes
+			quote = 0;
+			continue;
+		}
+		// first quote
+		quote = 1;
+	}
+	return ue;
+}
+
+static int
+csv_parse(const unsigned char *uc, const unsigned char *ue)
+{
+	size_t nf = 0, tf = 0, nl = 0;
+
+	while (uc < ue) {
+		unsigned char c;
+		switch (c = *uc++) {
+		case '"':
+			// Eat until the matching quote
+			uc = eatquote(uc, ue);
+			break;
+		case ',':
+			nf++;
+			break;
+		case '\n':
+			DPRINTF("%zu %zu %zu\n", nl, nf, tf);
+			nl++;
+#if CSV_LINES
+			if (nl == CSV_LINES)
+				return tf != 0 && tf == nf;
+#endif
+			if (tf == 0) {
+				// First time and no fields, give up
+				if (nf == 0) 
+					return 0;
+				// First time, set the number of fields
+				tf = nf;
+			} else if (tf != nf) {
+				// Field number mismatch, we are done.
+				return 0;
+			}
+			nf = 0;
+			break;
+		default:
+			break;
+		}
+	}
+	return tf && nl > 2;
+}
+
+#ifndef TEST
+int
+file_is_csv(struct magic_set *ms, const struct buffer *b, int looks_text)
+{
+	const unsigned char *uc = CAST(const unsigned char *, b->fbuf);
+	const unsigned char *ue = uc + b->flen;
+	int mime = ms->flags & MAGIC_MIME;
+
+	if (!looks_text)
+		return 0;
+
+	if ((ms->flags & (MAGIC_APPLE|MAGIC_EXTENSION)) != 0)
+		return 0;
+
+	if (!csv_parse(uc, ue))
+		return 0;
+
+	if (mime == MAGIC_MIME_ENCODING)
+		return 1;
+
+	if (mime) {
+		if (file_printf(ms, "application/csv") == -1)
+			return -1;
+		return 1;
+	}
+
+	if (file_printf(ms, "CSV text") == -1)
+		return -1;
+
+	return 1;
+}
+
+#else
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <err.h>
+
+int
+main(int argc, char *argv[])
+{
+	int fd, rv;
+	struct stat st;
+	unsigned char *p;
+
+	if ((fd = open(argv[1], O_RDONLY)) == -1)
+		err(EXIT_FAILURE, "Can't open `%s'", argv[1]);
+
+	if (fstat(fd, &st) == -1)
+		err(EXIT_FAILURE, "Can't stat `%s'", argv[1]);
+
+	if ((p = malloc(st.st_size)) == NULL)
+		err(EXIT_FAILURE, "Can't allocate %jd bytes",
+		    (intmax_t)st.st_size);
+	if (read(fd, p, st.st_size) != st.st_size)
+		err(EXIT_FAILURE, "Can't read %jd bytes",
+		    (intmax_t)st.st_size);
+	printf("is csv %d\n", csv_parse(p, p + st.st_size));
+	return 0;
+}
+#endif

+ 2 - 0
src/magic.h.in

@@ -56,6 +56,7 @@
 #define	MAGIC_NO_CHECK_ELF	0x0010000 /* Don't check for elf details */
 #define	MAGIC_NO_CHECK_TEXT	0x0020000 /* Don't check for text files */
 #define	MAGIC_NO_CHECK_CDF	0x0040000 /* Don't check for cdf files */
+#define MAGIC_NO_CHECK_CSV	0x0080000 /* Don't check for CSV files */
 #define	MAGIC_NO_CHECK_TOKENS	0x0100000 /* Don't check tokens */
 #define MAGIC_NO_CHECK_ENCODING 0x0200000 /* Don't check text encodings */
 #define MAGIC_NO_CHECK_JSON	0x0400000 /* Don't check for JSON files */
@@ -68,6 +69,7 @@
 	MAGIC_NO_CHECK_APPTYPE	| \
 	MAGIC_NO_CHECK_ELF	| \
 	MAGIC_NO_CHECK_TEXT	| \
+	MAGIC_NO_CHECK_CSV	| \
 	MAGIC_NO_CHECK_CDF	| \
 	MAGIC_NO_CHECK_TOKENS	| \
 	MAGIC_NO_CHECK_ENCODING	| \

+ 8 - 3
src/readcdf.c

@@ -26,7 +26,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readcdf.c,v 1.73 2019/03/12 20:43:05 christos Exp $")
+FILE_RCSID("@(#)$File: readcdf.c,v 1.74 2019/09/11 15:46:30 christos Exp $")
 #endif
 
 #include <assert.h>
@@ -120,7 +120,11 @@ cdf_app_to_mime(const char *vbuf, const struct nv *nv)
 	old_lc_ctype = uselocale(c_lc_ctype);
 	assert(old_lc_ctype != NULL);
 #else
-	char *old_lc_ctype = setlocale(LC_CTYPE, "C");
+	char *old_lc_ctype = setlocale(LC_CTYPE, NULL);
+	assert(old_lc_ctype != NULL);
+	old_lc_ctype = strdup(old_lc_ctype);
+	assert(old_lc_ctype != NULL);
+	(void)setlocale(LC_CTYPE, "C");
 #endif
 	for (i = 0; nv[i].pattern != NULL; i++)
 		if (strcasestr(vbuf, nv[i].pattern) != NULL) {
@@ -134,7 +138,8 @@ cdf_app_to_mime(const char *vbuf, const struct nv *nv)
 	(void)uselocale(old_lc_ctype);
 	freelocale(c_lc_ctype);
 #else
-	setlocale(LC_CTYPE, old_lc_ctype);
+	(void)setlocale(LC_CTYPE, old_lc_ctype);
+	free(old_lc_ctype);
 #endif
 	return rv;
 }

+ 12 - 2
src/readelf.c

@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.165 2019/05/07 02:27:11 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.168 2019/12/16 03:49:19 christos Exp $")
 #endif
 
 #ifdef BUILTIN_ELF
@@ -1140,6 +1140,9 @@ donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
 		 */
 		return xnh_sizeof + offset;
 	}
+	/*XXX: GCC */
+	memset(&nh32, 0, sizeof(nh32));
+	memset(&nh64, 0, sizeof(nh64));
 
 	memcpy(xnh_addr, &nbuf[offset], xnh_sizeof);
 	offset += xnh_sizeof;
@@ -1345,6 +1348,13 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
 	}
 	name_off = xsh_offset;
 
+	if (fsize != SIZE_UNKNOWN && fsize < name_off) {
+		if (file_printf(ms, ", too large section header offset %td",
+		    name_off) == -1)
+			return -1;
+		return 0;
+	}
+
 	for ( ; num; num--) {
 		/* Read the name of this section. */
 		if ((namesize = pread(fd, name, sizeof(name) - 1,
@@ -1628,7 +1638,6 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
 		/* Things we can determine before we seek */
 		switch (xph_type) {
 		case PT_DYNAMIC:
-			linking_style = "dynamically";
 			doread = 1;
 			break;
 		case PT_NOTE:
@@ -1644,6 +1653,7 @@ dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
 			}
 			/*FALLTHROUGH*/
 		case PT_INTERP:
+			linking_style = "dynamically";
 			doread = 1;
 			break;
 		default:

+ 21 - 3
src/seccomp.c

@@ -27,12 +27,13 @@
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: seccomp.c,v 1.8 2019/02/24 18:12:04 christos Exp $")
+FILE_RCSID("@(#)$File: seccomp.c,v 1.11 2019/07/18 20:32:06 christos Exp $")
 #endif	/* lint */
 
 #if HAVE_LIBSECCOMP
 #include <seccomp.h> /* libseccomp */
 #include <sys/prctl.h> /* prctl */
+#include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <fcntl.h>
 #include <stdlib.h>
@@ -49,8 +50,14 @@ FILE_RCSID("@(#)$File: seccomp.c,v 1.8 2019/02/24 18:12:04 christos Exp $")
 	    goto out; \
     while (/*CONSTCOND*/0)
 
-static scmp_filter_ctx ctx;
+#define ALLOW_IOCTL_RULE(param) \
+    do \
+	if (seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(ioctl), 1, \
+	    SCMP_CMP(1, SCMP_CMP_EQ, param)) == -1) \
+		goto out; \
+    while (/*CONSTCOND*/0)
 
+static scmp_filter_ctx ctx;
 
 int
 enable_sandbox_basic(void)
@@ -167,11 +174,21 @@ enable_sandbox_full(void)
  	ALLOW_RULE(fcntl64);
 	ALLOW_RULE(fstat);
  	ALLOW_RULE(fstat64);
+#ifdef XZLIBSUPPORT
+	ALLOW_RULE(futex);
+#endif
 	ALLOW_RULE(getdents);
 #ifdef __NR_getdents64
 	ALLOW_RULE(getdents64);
 #endif
-	ALLOW_RULE(ioctl);
+#ifdef FIONREAD
+	// called in src/compress.c under sread
+	ALLOW_IOCTL_RULE(FIONREAD);
+#endif
+#ifdef TIOCGWINSZ
+	// musl libc may call ioctl TIOCGWINSZ when calling stdout
+	ALLOW_IOCTL_RULE(TIOCGWINSZ);
+#endif
 	ALLOW_RULE(lseek);
  	ALLOW_RULE(_llseek);
 	ALLOW_RULE(lstat);
@@ -197,6 +214,7 @@ enable_sandbox_full(void)
 	ALLOW_RULE(stat);
 	ALLOW_RULE(stat64);
 	ALLOW_RULE(sysinfo);
+	ALLOW_RULE(umask);	// Used in file_pipe2file()
 	ALLOW_RULE(unlink);
 	ALLOW_RULE(write);
 

+ 2 - 2
src/vasprintf.c

@@ -96,7 +96,7 @@ the buffer can have a shorter length. But what? If you really need to write
 HUGE string, don't use printf!
 During the process, some other memory is allocated (1024 bytes minimum)
 to handle the output of partial sprintf() calls. If you have only 10000 bytes
-free in memory, you *may* not be able to nprintf() a 8000 bytes-long text.
+free in memory, you *may* not be able to nprintf() an 8000 bytes-long text.
 
 note: if a buffer overflow occurs, exit() is called. This situation should
 never appear ... but if you want to be *really* sure, you have to modify the
@@ -108,7 +108,7 @@ you use strange formats.
 #include "file.h"
 
 #ifndef	lint
-FILE_RCSID("@(#)$File: vasprintf.c,v 1.16 2018/10/01 18:45:39 christos Exp $")
+FILE_RCSID("@(#)$File: vasprintf.c,v 1.17 2019/11/15 21:03:14 christos Exp $")
 #endif	/* lint */
 
 #include <assert.h>

+ 1 - 1
tests/JW07022A.mp3.result

@@ -1 +1 @@
-Audio file with ID3 version 2.2.0, contains:MPEG ADTS, layer III, v1,  96 kbps, 44.1 kHz, Monaural
+Audio file with ID3 version 2.2.0, contains:MPEG ADTS, layer III, v1, 96 kbps, 44.1 kHz, Monaural

+ 33 - 22
tests/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -121,7 +121,8 @@ am__v_at_0 = @
 am__v_at_1 = 
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/test-test.Po
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -211,6 +212,7 @@ LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MINGW = @MINGW@
@@ -384,8 +386,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -416,7 +418,13 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-test.Po@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+	@$(MKDIR_P) $(@D)
+	@echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -514,7 +522,10 @@ cscopelist-am: $(am__tagged_files)
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \
@@ -586,7 +597,7 @@ clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
 	mostlyclean-am
 
 distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/test-test.Po
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
@@ -632,7 +643,7 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/test-test.Po
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
@@ -653,19 +664,19 @@ uninstall-am:
 
 .MAKE: check-am install-am install-strip
 
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am check-local clean \
-	clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \
-	ctags ctags-am distclean distclean-compile distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-pdf install-pdf-am \
-	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-compile \
-	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
-	tags tags-am uninstall uninstall-am
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am \
+	check-local clean clean-checkPROGRAMS clean-generic \
+	clean-libtool cscopelist-am ctags ctags-am distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am install-man \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+	pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am
 
 .PRECIOUS: Makefile
 

+ 2 - 2
tests/test.c

@@ -102,10 +102,10 @@ main(int argc, char **argv)
 				desired = slurp(fp, &desired_len);
 				fclose(fp);
 				(void)printf("%s: %s\n", argv[1], result);
-                                if (strcmp(result, desired) != 0) {
+				if (strcmp(result, desired) != 0) {
 					(void)fprintf(stderr, "Error: result was\n%s\nexpected:\n%s\n", result, desired);
 					return 1;
-                                }
+				}
 			}
 		}
 	}