From 5cd9c400fcbeee496f8f47e45dc276587bf46a39 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Thu, 16 May 2002 18:45:56 +0000 Subject: [PATCH] - pt_note elf additions from NetBSD - EMX os specific changes (Alexander Mai) - stdint.h detection, acconfig.h fixes (Maciej W. Rozycki, Franz Korntner) - regex file additions (Kim Cromie) - getopt_long support and misc cleanups (Michael Piefel) - many magic fixes and additions --- Makefile.in | 156 +++++++++++++++++++++++- README | 9 +- acinclude.m4 | 93 ++++++++++----- aclocal.m4 | 93 ++++++++++----- config.h.in | 19 +-- configure | 251 +++++++++++++++++++++++++++------------ configure.in | 12 +- doc/file.man | 22 ++-- doc/magic.man | 6 +- magic/Magdir/adventure | 32 ++++- magic/Magdir/animation | 152 ++++++++++++++---------- magic/Magdir/audio | 3 - magic/Magdir/commands | 20 ++-- magic/Magdir/compress | 50 ++++---- magic/Magdir/dolby | 33 ++++- magic/Magdir/elf | 78 +++++++----- magic/Magdir/filesystems | 11 ++ magic/Magdir/gringotts | 25 ++++ magic/Magdir/lisp | 15 ++- magic/Magdir/nitpicker | 12 ++ magic/Magdir/perl | 17 +++ magic/Magdir/pulsar | 10 ++ magic/Magdir/sendmail | 9 ++ magic/Magdir/tex | 56 +++++++++ magic/Magdir/varied.out | 4 + magic/Magdir/vorbis | 45 ++++--- magic/Magdir/vxl | 13 ++ magic/magic.mime | 8 +- src/Makefile.std | 6 +- src/acconfig.h | 6 + src/apprentice.c | 12 +- src/compress.c | 9 +- src/file.c | 116 ++++++++++++++++-- src/file.h | 8 +- src/is_tar.c | 7 +- src/patchlevel.h | 12 +- src/print.c | 5 +- src/readelf.h | 6 +- src/softmagic.c | 41 ++++++- 39 files changed, 1123 insertions(+), 359 deletions(-) create mode 100644 magic/Magdir/gringotts create mode 100644 magic/Magdir/nitpicker create mode 100644 magic/Magdir/perl create mode 100644 magic/Magdir/pulsar create mode 100644 magic/Magdir/vxl diff --git a/Makefile.in b/Makefile.in index 3a266cdf..9ee0358d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -86,7 +86,159 @@ EXTRA_DIST = LEGAL.NOTICE MAINT PORTING Makefile.std magic2mime Localstuff Head CLEANFILES = $(man_MANS) magic magic.mgc magic.mime.mgc -magic_FRAGMENTS = Magdir/adi Magdir/adventure Magdir/allegro Magdir/alliant Magdir/alpha Magdir/amanda Magdir/amigaos Magdir/animation Magdir/apl Magdir/apple Magdir/applix Magdir/archive Magdir/asterix Magdir/att3b Magdir/audio Magdir/blender Magdir/blit Magdir/bsdi Magdir/c-lang Magdir/chi Magdir/cisco Magdir/claris Magdir/clipper Magdir/commands Magdir/compress Magdir/console Magdir/convex Magdir/database Magdir/diamond Magdir/diff Magdir/digital Magdir/dump Magdir/elf Magdir/encore Magdir/epoc Magdir/filesystems Magdir/flash Magdir/fonts Magdir/frame Magdir/freebsd Magdir/fsav Magdir/gimp Magdir/gnu Magdir/grace Magdir/hp Magdir/ibm370 Magdir/ibm6000 Magdir/iff Magdir/images Magdir/intel Magdir/interleaf Magdir/island Magdir/ispell Magdir/java Magdir/jpeg Magdir/karma Magdir/lecter Magdir/lex Magdir/lif Magdir/linux Magdir/lisp Magdir/mach Magdir/macintosh Magdir/magic Magdir/mail.news Magdir/maple Magdir/mathematica Magdir/mcrypt Magdir/mime Magdir/mips Magdir/mirage Magdir/mkid Magdir/mmdf Magdir/modem Magdir/motorola Magdir/msdos Magdir/msvc Magdir/ncr Magdir/netbsd Magdir/netscape Magdir/news Magdir/octave Magdir/olf Magdir/os2 Magdir/os9 Magdir/osf1 Magdir/palm Magdir/pbm Magdir/pdf Magdir/pdp Magdir/pgp Magdir/pkgadd Magdir/plus5 Magdir/printer Magdir/project Magdir/psdbms Magdir/pyramid Magdir/python Magdir/riff Magdir/rpm Magdir/rtf Magdir/sc Magdir/sccs Magdir/sendmail Magdir/sequent Magdir/sgml Magdir/sketch Magdir/sniffer Magdir/softquad Magdir/spectrum Magdir/sun Magdir/teapot Magdir/terminfo Magdir/tex Magdir/ti-8x Magdir/timezone Magdir/troff Magdir/typeset Magdir/unknown Magdir/uuencode Magdir/varied.out Magdir/vax Magdir/vicar Magdir/visx Magdir/vms Magdir/vmware Magdir/wordperfect Magdir/xdelta Magdir/xenix Magdir/zilog Magdir/zyxel +magic_FRAGMENTS = \ +Magdir/acorn \ +Magdir/adi \ +Magdir/adventure \ +Magdir/allegro \ +Magdir/alliant \ +Magdir/alpha \ +Magdir/amanda \ +Magdir/amigaos \ +Magdir/animation \ +Magdir/apl \ +Magdir/apple \ +Magdir/applix \ +Magdir/archive \ +Magdir/asterix \ +Magdir/att3b \ +Magdir/audio \ +Magdir/blender \ +Magdir/blit \ +Magdir/bsdi \ +Magdir/c-lang \ +Magdir/chi \ +Magdir/cisco \ +Magdir/citrus \ +Magdir/claris \ +Magdir/clipper \ +Magdir/commands \ +Magdir/compress \ +Magdir/console \ +Magdir/convex \ +Magdir/ctags \ +Magdir/cvs \ +Magdir/database \ +Magdir/diamond \ +Magdir/diff \ +Magdir/digital \ +Magdir/dolby \ +Magdir/dump \ +Magdir/dyadic \ +Magdir/editors \ +Magdir/elf \ +Magdir/encore \ +Magdir/epoc \ +Magdir/filesystems \ +Magdir/flash \ +Magdir/fonts \ +Magdir/frame \ +Magdir/freebsd \ +Magdir/fsav \ +Magdir/gimp \ +Magdir/gnu \ +Magdir/grace \ +Magdir/gringotts \ +Magdir/hitachi-sh \ +Magdir/hp \ +Magdir/ibm370 \ +Magdir/ibm6000 \ +Magdir/iff \ +Magdir/images \ +Magdir/intel \ +Magdir/interleaf \ +Magdir/island \ +Magdir/ispell \ +Magdir/java \ +Magdir/jpeg \ +Magdir/karma \ +Magdir/lecter \ +Magdir/lex \ +Magdir/lif \ +Magdir/linux \ +Magdir/lisp \ +Magdir/mach \ +Magdir/macintosh \ +Magdir/magic \ +Magdir/mail.news \ +Magdir/maple \ +Magdir/mathematica \ +Magdir/mcrypt \ +Magdir/mime \ +Magdir/mips \ +Magdir/mirage \ +Magdir/mkid \ +Magdir/mmdf \ +Magdir/modem \ +Magdir/motorola \ +Magdir/msdos \ +Magdir/msvc \ +Magdir/natinst \ +Magdir/ncr \ +Magdir/netbsd \ +Magdir/netscape \ +Magdir/news \ +Magdir/nitpicker \ +Magdir/octave \ +Magdir/olf \ +Magdir/os2 \ +Magdir/os9 \ +Magdir/osf1 \ +Magdir/palm \ +Magdir/parix \ +Magdir/pbm \ +Magdir/pdf \ +Magdir/pdp \ +Magdir/perl \ +Magdir/pgp \ +Magdir/pkgadd \ +Magdir/plus5 \ +Magdir/printer \ +Magdir/project \ +Magdir/psdbms \ +Magdir/pulsar \ +Magdir/pyramid \ +Magdir/python \ +Magdir/riff \ +Magdir/rpm \ +Magdir/rtf \ +Magdir/sc \ +Magdir/sccs \ +Magdir/sendmail \ +Magdir/sequent \ +Magdir/sgml \ +Magdir/sharc \ +Magdir/sketch \ +Magdir/smalltalk \ +Magdir/sniffer \ +Magdir/softquad \ +Magdir/spectrum \ +Magdir/sun \ +Magdir/sysex \ +Magdir/teapot \ +Magdir/terminfo \ +Magdir/tex \ +Magdir/tgif \ +Magdir/ti-8x \ +Magdir/timezone \ +Magdir/troff \ +Magdir/tuxedo \ +Magdir/typeset \ +Magdir/unknown \ +Magdir/uuencode \ +Magdir/varied.out \ +Magdir/vax \ +Magdir/vicar \ +Magdir/visx \ +Magdir/vms \ +Magdir/vmware \ +Magdir/vorbis \ +Magdir/vxl \ +Magdir/wordperfect \ +Magdir/xdelta \ +Magdir/xenix \ +Magdir/zilog \ +Magdir/zyxel ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs @@ -416,7 +568,7 @@ distdir: $(DISTFILES) @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$/$$file $(distdir)/$$file; \ + cp -pr $$d/$$file $(distdir)/$$file; \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ diff --git a/README b/README index d8e941b8..1a0ff8de 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ ** README for file(1) Command ** -@(#) $Id: README,v 1.25 2001/07/23 21:30:22 christos Exp $ +@(#) $Id: README,v 1.26 2002/05/16 18:45:56 christos Exp $ This is Release 3.x of Ian Darwin's (copyright but distributable) file(1) command. This version is the standard "file" command for Linux, @@ -8,7 +8,7 @@ file(1) command. This version is the standard "file" command for Linux, UNIX is a trademark of UNIX System Laboratories. The prime contributor to Release 3.8 was Guy Harris, who put in megachanges -including byte-order independance. +including byte-order independence. The prime contributor to Release 3.0 was Christos Zoulas, who put in hundreds of lines of source code changes, including his own @@ -43,7 +43,7 @@ Makefile - read this next, adapt it as needed (particularly the man page layouts), type "make" to compile, "make try" to try it out against your old version. Expect some diffs, particularly since your original - file(1) may not grok the imbedded-space ("\ ") in + file(1) may not grok the embedded-space ("\ ") in the current magic file, or may even not use the magic file. apprentice.c - parses /etc/magic to learn magic @@ -61,9 +61,8 @@ magdir - directory of /etc/magic pieces magdir/Makefile - ADJUST THIS FOR YOUR CONFIGURATION names.h - header file for ascmagic.c softmagic.c - 2nd set of tests, based on /etc/magic -readelf.[ch] - Standalone elf parsing code. +readelf.[ch] - Stand-alone elf parsing code. compress.c - on-the-fly decompression. -internat.c - recognize international `text' files. print.c - print results, errors, warnings. If your gzip sometimes fails to decompress things complaining about a short diff --git a/acinclude.m4 b/acinclude.m4 index 0b1b0a53..79ecb0e1 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,5 +1,5 @@ dnl cloned from autoconf 2.13 acspecific.m4 -AC_DEFUN(AC_C_LONG_LONG, +AC_DEFUN([AC_C_LONG_LONG], [AC_CACHE_CHECK(for long long, ac_cv_c_long_long, [if test "$GCC" = yes; then ac_cv_c_long_long=yes @@ -14,23 +14,16 @@ if test $ac_cv_c_long_long = yes; then fi ]) -dnl from autoconf 2.13 acgeneral.m4, with patch: -dnl Date: Fri, 15 Jan 1999 05:52:41 -0800 -dnl Message-ID: <199901151352.FAA18237@shade.twinsun.com> -dnl From: eggert@twinsun.com (Paul Eggert) -dnl Subject: autoconf 2.13 AC_CHECK_TYPE doesn't allow shell vars -dnl Newsgroups: gnu.utils.bug - dnl from autoconf 2.13 acspecific.m4, with changes to check for daylight -AC_DEFUN(AC_STRUCT_TIMEZONE_DAYLIGHT, +AC_DEFUN([AC_STRUCT_TIMEZONE_DAYLIGHT], [AC_REQUIRE([AC_STRUCT_TM])dnl AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone, [AC_TRY_COMPILE([#include #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;], ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)]) if test "$ac_cv_struct_tm_zone" = yes; then - AC_DEFINE(HAVE_TM_ZONE) + AC_DEFINE(HAVE_TM_ZONE,1,[HAVE_TM_ZONE]) fi AC_CACHE_CHECK(for tzname, ac_cv_var_tzname, [AC_TRY_LINK( @@ -42,7 +35,7 @@ extern char *tzname[]; /* RS6000 and others reject char **tzname. */ changequote([, ])dnl [atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)]) if test $ac_cv_var_tzname = yes; then - AC_DEFINE(HAVE_TZNAME) + AC_DEFINE(HAVE_TZNAME,1,[HAVE_TZNAME]) fi AC_CACHE_CHECK([for tm_isdst in struct tm], ac_cv_struct_tm_isdst, @@ -66,15 +59,27 @@ changequote([, ])dnl fi ]) -dnl AC_CHECK_TYPE2(TYPE, DEFAULT) -AC_DEFUN(AC_CHECK_TYPE2, +dnl from autoconf 2.13 acgeneral.m4, with patch: +dnl Date: Fri, 15 Jan 1999 05:52:41 -0800 +dnl Message-ID: <199901151352.FAA18237@shade.twinsun.com> +dnl From: eggert@twinsun.com (Paul Eggert) +dnl Subject: autoconf 2.13 AC_CHECK_TYPE doesn't allow shell vars +dnl Newsgroups: gnu.utils.bug +dnl +dnl now include if available + +dnl AC_CHECK_TYPE2_STDC(TYPE, DEFAULT) +AC_DEFUN([AC_CHECK_TYPE2_STDC], [AC_REQUIRE([AC_HEADER_STDC])dnl +AC_REQUIRE([AC_HEADER_STDINT])dnl AC_MSG_CHECKING(for $1) AC_CACHE_VAL(ac_cv_type_$1, [AC_EGREP_CPP(dnl -changequote(<<,>>)dnl -<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl -changequote([,]), [#include +[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]], +[#if HAVE_STDINT_H +#include +#endif +#include #if STDC_HEADERS #include #include @@ -88,14 +93,12 @@ fi ]) dnl from autoconf 2.13 acgeneral.m4, with additional third argument -dnl AC_CHECK_SIZEOF_INCLUDES(TYPE [, CROSS-SIZE, [INCLUDES]]) -AC_DEFUN(AC_CHECK_SIZEOF_INCLUDES, -[changequote(<<, >>)dnl -dnl The name to #define. -define(<>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl +dnl AC_CHECK_SIZEOF_INCLUDES(TYPE [, CROSS-SIZE [, INCLUDES]]) +AC_DEFUN([AC_CHECK_SIZEOF_INCLUDES], +[dnl The name to #define. +define([AC_TYPE_NAME], translit(sizeof_$1, [[[a-z *]]], [[[A-Z_P]]]))dnl dnl The cache variable name. -define(<>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl -changequote([, ])dnl +define([AC_CV_NAME], translit(ac_cv_sizeof_$1, [[[ *]]], [[[_p]]]))dnl AC_MSG_CHECKING(size of $1) AC_CACHE_VAL(AC_CV_NAME, [AC_TRY_RUN([$3 @@ -114,9 +117,14 @@ undefine([AC_CV_NAME])dnl ]) dnl AC_CHECK_SIZEOF_STDC_HEADERS(TYPE [, CROSS_SIZE]) -AC_DEFUN(AC_CHECK_SIZEOF_STDC_HEADERS, -[AC_CHECK_SIZEOF_INCLUDES($1, $2, -[#include +AC_DEFUN([AC_CHECK_SIZEOF_STDC_HEADERS], +[AC_REQUIRE([AC_HEADER_STDC])dnl +AC_REQUIRE([AC_HEADER_STDINT])dnl +AC_CHECK_SIZEOF_INCLUDES($1, $2, +[#if HAVE_STDINT_H +#include +#endif +#include #ifdef STDC_HEADERS #include #endif @@ -124,6 +132,31 @@ AC_DEFUN(AC_CHECK_SIZEOF_STDC_HEADERS, ]) +dnl AC_CHECK_TYPE_STDC(TYPE, DEFAULT) +AC_DEFUN([AC_CHECK_TYPE_STDC], +[AC_REQUIRE([AC_HEADER_STDC])dnl +AC_REQUIRE([AC_HEADER_STDINT])dnl +AC_MSG_CHECKING(for $1) +AC_CACHE_VAL(ac_cv_type_$1, +[AC_EGREP_CPP(dnl +[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]], +[#if HAVE_STDINT_H +#include +#endif +#include +#if STDC_HEADERS +#include +#include +#endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl +AC_MSG_RESULT($ac_cv_type_$1) +if test $ac_cv_type_$1 = no; then + AC_DEFINE($1, $2) +fi +]) + +dnl AC_HEADER_STDINT +AC_DEFUN([AC_HEADER_STDINT], [AC_CHECK_HEADERS(stdint.h)]) + #serial 19 dnl By default, many hosts won't let programs access large files; @@ -135,7 +168,7 @@ dnl Written by Paul Eggert . dnl Internal subroutine of AC_SYS_LARGEFILE. dnl AC_SYS_LARGEFILE_TEST_INCLUDES -AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES, +AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES], [[#include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply "#define LARGE_OFF_T 9223372036854775807", @@ -150,7 +183,7 @@ AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES, dnl Internal subroutine of AC_SYS_LARGEFILE. dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLU= DES, FUNCTION-BODY) -AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE, +AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE], [AC_CACHE_CHECK([for $1 value needed for large files], $3, [$3=no AC_TRY_COMPILE([$5], @@ -165,7 +198,7 @@ AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE, AC_DEFINE_UNQUOTED([$1], [$]$3, [$4]) fi]) -AC_DEFUN(AC_SYS_LARGEFILE, +AC_DEFUN([AC_SYS_LARGEFILE], [AC_REQUIRE([AC_PROG_CC]) AC_ARG_ENABLE(largefile, [ --disable-largefile omit support for large files]) @@ -200,7 +233,7 @@ AC_DEFUN(AC_SYS_LARGEFILE, fi ]) -AC_DEFUN(AC_FUNC_FSEEKO, +AC_DEFUN([AC_FUNC_FSEEKO], [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1, ac_cv_sys_largefile_source, [Define to make fseeko visible on some hosts (e.g. glibc 2.2).], diff --git a/aclocal.m4 b/aclocal.m4 index 82ed39fb..c8873bca 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -11,7 +11,7 @@ dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A dnl PARTICULAR PURPOSE. dnl cloned from autoconf 2.13 acspecific.m4 -AC_DEFUN(AC_C_LONG_LONG, +AC_DEFUN([AC_C_LONG_LONG], [AC_CACHE_CHECK(for long long, ac_cv_c_long_long, [if test "$GCC" = yes; then ac_cv_c_long_long=yes @@ -26,23 +26,16 @@ if test $ac_cv_c_long_long = yes; then fi ]) -dnl from autoconf 2.13 acgeneral.m4, with patch: -dnl Date: Fri, 15 Jan 1999 05:52:41 -0800 -dnl Message-ID: <199901151352.FAA18237@shade.twinsun.com> -dnl From: eggert@twinsun.com (Paul Eggert) -dnl Subject: autoconf 2.13 AC_CHECK_TYPE doesn't allow shell vars -dnl Newsgroups: gnu.utils.bug - dnl from autoconf 2.13 acspecific.m4, with changes to check for daylight -AC_DEFUN(AC_STRUCT_TIMEZONE_DAYLIGHT, +AC_DEFUN([AC_STRUCT_TIMEZONE_DAYLIGHT], [AC_REQUIRE([AC_STRUCT_TM])dnl AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone, [AC_TRY_COMPILE([#include #include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;], ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)]) if test "$ac_cv_struct_tm_zone" = yes; then - AC_DEFINE(HAVE_TM_ZONE) + AC_DEFINE(HAVE_TM_ZONE,1,[HAVE_TM_ZONE]) fi AC_CACHE_CHECK(for tzname, ac_cv_var_tzname, [AC_TRY_LINK( @@ -54,7 +47,7 @@ extern char *tzname[]; /* RS6000 and others reject char **tzname. */ changequote([, ])dnl [atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)]) if test $ac_cv_var_tzname = yes; then - AC_DEFINE(HAVE_TZNAME) + AC_DEFINE(HAVE_TZNAME,1,[HAVE_TZNAME]) fi AC_CACHE_CHECK([for tm_isdst in struct tm], ac_cv_struct_tm_isdst, @@ -78,15 +71,27 @@ changequote([, ])dnl fi ]) -dnl AC_CHECK_TYPE2(TYPE, DEFAULT) -AC_DEFUN(AC_CHECK_TYPE2, +dnl from autoconf 2.13 acgeneral.m4, with patch: +dnl Date: Fri, 15 Jan 1999 05:52:41 -0800 +dnl Message-ID: <199901151352.FAA18237@shade.twinsun.com> +dnl From: eggert@twinsun.com (Paul Eggert) +dnl Subject: autoconf 2.13 AC_CHECK_TYPE doesn't allow shell vars +dnl Newsgroups: gnu.utils.bug +dnl +dnl now include if available + +dnl AC_CHECK_TYPE2_STDC(TYPE, DEFAULT) +AC_DEFUN([AC_CHECK_TYPE2_STDC], [AC_REQUIRE([AC_HEADER_STDC])dnl +AC_REQUIRE([AC_HEADER_STDINT])dnl AC_MSG_CHECKING(for $1) AC_CACHE_VAL(ac_cv_type_$1, [AC_EGREP_CPP(dnl -changequote(<<,>>)dnl -<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl -changequote([,]), [#include +[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]], +[#if HAVE_STDINT_H +#include +#endif +#include #if STDC_HEADERS #include #include @@ -100,14 +105,12 @@ fi ]) dnl from autoconf 2.13 acgeneral.m4, with additional third argument -dnl AC_CHECK_SIZEOF_INCLUDES(TYPE [, CROSS-SIZE, [INCLUDES]]) -AC_DEFUN(AC_CHECK_SIZEOF_INCLUDES, -[changequote(<<, >>)dnl -dnl The name to #define. -define(<>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl +dnl AC_CHECK_SIZEOF_INCLUDES(TYPE [, CROSS-SIZE [, INCLUDES]]) +AC_DEFUN([AC_CHECK_SIZEOF_INCLUDES], +[dnl The name to #define. +define([AC_TYPE_NAME], translit(sizeof_$1, [[[a-z *]]], [[[A-Z_P]]]))dnl dnl The cache variable name. -define(<>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl -changequote([, ])dnl +define([AC_CV_NAME], translit(ac_cv_sizeof_$1, [[[ *]]], [[[_p]]]))dnl AC_MSG_CHECKING(size of $1) AC_CACHE_VAL(AC_CV_NAME, [AC_TRY_RUN([$3 @@ -126,9 +129,14 @@ undefine([AC_CV_NAME])dnl ]) dnl AC_CHECK_SIZEOF_STDC_HEADERS(TYPE [, CROSS_SIZE]) -AC_DEFUN(AC_CHECK_SIZEOF_STDC_HEADERS, -[AC_CHECK_SIZEOF_INCLUDES($1, $2, -[#include +AC_DEFUN([AC_CHECK_SIZEOF_STDC_HEADERS], +[AC_REQUIRE([AC_HEADER_STDC])dnl +AC_REQUIRE([AC_HEADER_STDINT])dnl +AC_CHECK_SIZEOF_INCLUDES($1, $2, +[#if HAVE_STDINT_H +#include +#endif +#include #ifdef STDC_HEADERS #include #endif @@ -136,6 +144,31 @@ AC_DEFUN(AC_CHECK_SIZEOF_STDC_HEADERS, ]) +dnl AC_CHECK_TYPE_STDC(TYPE, DEFAULT) +AC_DEFUN([AC_CHECK_TYPE_STDC], +[AC_REQUIRE([AC_HEADER_STDC])dnl +AC_REQUIRE([AC_HEADER_STDINT])dnl +AC_MSG_CHECKING(for $1) +AC_CACHE_VAL(ac_cv_type_$1, +[AC_EGREP_CPP(dnl +[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]], +[#if HAVE_STDINT_H +#include +#endif +#include +#if STDC_HEADERS +#include +#include +#endif], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl +AC_MSG_RESULT($ac_cv_type_$1) +if test $ac_cv_type_$1 = no; then + AC_DEFINE($1, $2) +fi +]) + +dnl AC_HEADER_STDINT +AC_DEFUN([AC_HEADER_STDINT], [AC_CHECK_HEADERS(stdint.h)]) + #serial 19 dnl By default, many hosts won't let programs access large files; @@ -147,7 +180,7 @@ dnl Written by Paul Eggert . dnl Internal subroutine of AC_SYS_LARGEFILE. dnl AC_SYS_LARGEFILE_TEST_INCLUDES -AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES, +AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES], [[#include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply "#define LARGE_OFF_T 9223372036854775807", @@ -162,7 +195,7 @@ AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES, dnl Internal subroutine of AC_SYS_LARGEFILE. dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLU= DES, FUNCTION-BODY) -AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE, +AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE], [AC_CACHE_CHECK([for $1 value needed for large files], $3, [$3=no AC_TRY_COMPILE([$5], @@ -177,7 +210,7 @@ AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE, AC_DEFINE_UNQUOTED([$1], [$]$3, [$4]) fi]) -AC_DEFUN(AC_SYS_LARGEFILE, +AC_DEFUN([AC_SYS_LARGEFILE], [AC_REQUIRE([AC_PROG_CC]) AC_ARG_ENABLE(largefile, [ --disable-largefile omit support for large files]) @@ -212,7 +245,7 @@ AC_DEFUN(AC_SYS_LARGEFILE, fi ]) -AC_DEFUN(AC_FUNC_FSEEKO, +AC_DEFUN([AC_FUNC_FSEEKO], [AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1, ac_cv_sys_largefile_source, [Define to make fseeko visible on some hosts (e.g. glibc 2.2).], diff --git a/config.h.in b/config.h.in index 8765ba6f..aa058242 100644 --- a/config.h.in +++ b/config.h.in @@ -9,13 +9,6 @@ /* Define if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H -/* Define if your struct tm has tm_zone. */ -#undef HAVE_TM_ZONE - -/* Define if you don't have tm_zone but do have the external array - tzname. */ -#undef HAVE_TZNAME - /* Define if major, minor, and makedev are declared in . */ #undef MAJOR_IN_MKDEV @@ -89,9 +82,15 @@ /* Define if you have the header file. */ #undef HAVE_FCNTL_H +/* Define if you have the header file. */ +#undef HAVE_GETOPT_H + /* Define if you have the header file. */ #undef HAVE_LOCALE_H +/* Define if you have the header file. */ +#undef HAVE_STDINT_H + /* Define if you have the header file. */ #undef HAVE_SYS_MMAN_H @@ -113,6 +112,12 @@ /* Version number of package */ #undef VERSION +/* HAVE_TM_ZONE */ +#undef HAVE_TM_ZONE + +/* HAVE_TZNAME */ +#undef HAVE_TZNAME + /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS diff --git a/configure b/configure index 8aadd21c..9a9d14e7 100755 --- a/configure +++ b/configure @@ -1508,7 +1508,7 @@ EOF fi -for ac_hdr in fcntl.h locale.h +for ac_hdr in stdint.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 @@ -1548,7 +1548,7 @@ else fi done -for ac_hdr in sys/mman.h sys/stat.h sys/types.h +for ac_hdr in fcntl.h locale.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 @@ -1588,7 +1588,7 @@ else fi done -for ac_hdr in unistd.h +for ac_hdr in sys/mman.h sys/stat.h sys/types.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 @@ -1628,7 +1628,7 @@ else fi done -for ac_hdr in locale.h +for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 @@ -1668,14 +1668,94 @@ else fi done +for ac_hdr in getopt.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1676: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1686: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in locale.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1716: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1726: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1674: checking for working const" >&5 +echo "configure:1754: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1808: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1745,12 +1825,12 @@ EOF fi echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:1749: checking for off_t" >&5 +echo "configure:1829: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1778,12 +1858,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:1782: checking for size_t" >&5 +echo "configure:1862: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1811,12 +1891,12 @@ EOF fi echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6 -echo "configure:1815: checking for st_rdev in struct stat" >&5 +echo "configure:1895: checking for st_rdev in struct stat" >&5 if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1824,7 +1904,7 @@ int main() { struct stat s; s.st_rdev; ; return 0; } EOF -if { (eval echo configure:1828: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1908: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_st_rdev=yes else @@ -1845,12 +1925,12 @@ EOF fi echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 -echo "configure:1849: checking whether struct tm is in sys/time.h or time.h" >&5 +echo "configure:1929: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1858,7 +1938,7 @@ int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF -if { (eval echo configure:1862: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1942: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else @@ -1879,12 +1959,12 @@ EOF fi echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6 -echo "configure:1883: checking for tm_zone in struct tm" >&5 +echo "configure:1963: checking for tm_zone in struct tm" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_cv_struct_tm> @@ -1892,7 +1972,7 @@ int main() { struct tm tm; tm.tm_zone; ; return 0; } EOF -if { (eval echo configure:1896: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1976: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm_zone=yes else @@ -1912,12 +1992,12 @@ EOF fi echo $ac_n "checking for tzname""... $ac_c" 1>&6 -echo "configure:1916: checking for tzname" >&5 +echo "configure:1996: checking for tzname" >&5 if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifndef tzname /* For SGI. */ @@ -1927,7 +2007,7 @@ int main() { atoi(*tzname); ; return 0; } EOF -if { (eval echo configure:1931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_var_tzname=yes else @@ -1948,12 +2028,12 @@ EOF fi echo $ac_n "checking for tm_isdst in struct tm""... $ac_c" 1>&6 -echo "configure:1952: checking for tm_isdst in struct tm" >&5 +echo "configure:2032: checking for tm_isdst in struct tm" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm_isdst'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include <$ac_cv_struct_tm> @@ -1961,7 +2041,7 @@ int main() { struct tm tm; tm.tm_isdst; ; return 0; } EOF -if { (eval echo configure:1965: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2045: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm_isdst=yes else @@ -1981,12 +2061,12 @@ EOF fi echo $ac_n "checking for daylight""... $ac_c" 1>&6 -echo "configure:1985: checking for daylight" >&5 +echo "configure:2065: checking for daylight" >&5 if eval "test \"`echo '$''{'ac_cv_var_daylight'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #ifndef daylight /* In case IRIX #defines this, too */ @@ -1996,7 +2076,7 @@ int main() { atoi(daylight); ; return 0; } EOF -if { (eval echo configure:2000: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2080: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_var_daylight=yes else @@ -2027,7 +2107,7 @@ fi echo $ac_n "checking for special C compiler options needed for large files= ""... $ac_c" 1>&6 -echo "configure:2031: checking for special C compiler options needed for large files= +echo "configure:2111: checking for special C compiler options needed for large files= " >&5 if eval "test \"`echo '$''{'ac_cv_sys_largefile_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2037,7 +2117,7 @@ else # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat > conftest.$ac_ext < /* Check that off_t can represent 2**63 - 1 correctly. @@ -2053,7 +2133,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2057: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2137: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 @@ -2062,7 +2142,7 @@ else ac_save_CC="$CC" CC="$CC -n32" cat > conftest.$ac_ext < /* Check that off_t can represent 2**63 - 1 correctly. @@ -2078,7 +2158,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2082: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2162: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sys_largefile_CC=' -n32' else @@ -2098,13 +2178,13 @@ echo "$ac_t""$ac_cv_sys_largefile_CC" 1>&6 fi echo $ac_n "checking for _FILE_OFFSET_BITS value needed for large files""... $ac_c" 1>&6 -echo "configure:2102: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +echo "configure:2182: checking for _FILE_OFFSET_BITS value needed for large files" >&5 if eval "test \"`echo '$''{'ac_cv_sys_file_offset_bits'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_sys_file_offset_bits=no cat > conftest.$ac_ext < /* Check that off_t can represent 2**63 - 1 correctly. @@ -2120,14 +2200,14 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2124: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2204: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cat > conftest.$ac_ext < @@ -2145,7 +2225,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2149: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2229: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sys_file_offset_bits=64 else @@ -2165,13 +2245,13 @@ EOF fi echo $ac_n "checking for _LARGE_FILES value needed for large files""... $ac_c" 1>&6 -echo "configure:2169: checking for _LARGE_FILES value needed for large files" >&5 +echo "configure:2249: checking for _LARGE_FILES value needed for large files" >&5 if eval "test \"`echo '$''{'ac_cv_sys_large_files'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_sys_large_files=no cat > conftest.$ac_ext < /* Check that off_t can represent 2**63 - 1 correctly. @@ -2187,14 +2267,14 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2191: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2271: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cat > conftest.$ac_ext < @@ -2212,7 +2292,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:2216: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2296: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sys_large_files=1 else @@ -2235,13 +2315,16 @@ EOF echo $ac_n "checking for uint8_t""... $ac_c" 1>&6 -echo "configure:2239: checking for uint8_t" >&5 +echo "configure:2319: checking for uint8_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_uint8_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < +#endif #include #if STDC_HEADERS #include @@ -2268,13 +2351,16 @@ EOF fi echo $ac_n "checking for uint16_t""... $ac_c" 1>&6 -echo "configure:2272: checking for uint16_t" >&5 +echo "configure:2355: checking for uint16_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_uint16_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < +#endif #include #if STDC_HEADERS #include @@ -2301,13 +2387,16 @@ EOF fi echo $ac_n "checking for uint32_t""... $ac_c" 1>&6 -echo "configure:2305: checking for uint32_t" >&5 +echo "configure:2391: checking for uint32_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_uint32_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < +#endif #include #if STDC_HEADERS #include @@ -2333,9 +2422,8 @@ EOF fi - echo $ac_n "checking for long long""... $ac_c" 1>&6 -echo "configure:2339: checking for long long" >&5 +echo "configure:2427: checking for long long" >&5 if eval "test \"`echo '$''{'ac_cv_c_long_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2346,13 +2434,13 @@ if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2444: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_long_long=yes else @@ -2381,13 +2469,16 @@ else long64='unsigned long'; fi echo $ac_n "checking for uint64_t""... $ac_c" 1>&6 -echo "configure:2385: checking for uint64_t" >&5 +echo "configure:2473: checking for uint64_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_uint64_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < +#endif #include #if STDC_HEADERS #include @@ -2417,7 +2508,7 @@ fi echo $ac_n "checking size of uint8_t""... $ac_c" 1>&6 -echo "configure:2421: checking size of uint8_t" >&5 +echo "configure:2512: checking size of uint8_t" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_uint8_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2425,8 +2516,11 @@ else ac_cv_sizeof_uint8_t=0 else cat > conftest.$ac_ext < +#endif #include #ifdef STDC_HEADERS #include @@ -2441,7 +2535,7 @@ main() exit(0); } EOF -if { (eval echo configure:2445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_uint8_t=`cat conftestval` else @@ -2462,7 +2556,7 @@ EOF echo $ac_n "checking size of uint16_t""... $ac_c" 1>&6 -echo "configure:2466: checking size of uint16_t" >&5 +echo "configure:2560: checking size of uint16_t" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_uint16_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2470,8 +2564,11 @@ else ac_cv_sizeof_uint16_t=0 else cat > conftest.$ac_ext < +#endif #include #ifdef STDC_HEADERS #include @@ -2486,7 +2583,7 @@ main() exit(0); } EOF -if { (eval echo configure:2490: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2587: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_uint16_t=`cat conftestval` else @@ -2507,7 +2604,7 @@ EOF echo $ac_n "checking size of uint32_t""... $ac_c" 1>&6 -echo "configure:2511: checking size of uint32_t" >&5 +echo "configure:2608: checking size of uint32_t" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_uint32_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2515,8 +2612,11 @@ else ac_cv_sizeof_uint32_t=0 else cat > conftest.$ac_ext < +#endif #include #ifdef STDC_HEADERS #include @@ -2531,7 +2631,7 @@ main() exit(0); } EOF -if { (eval echo configure:2535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_uint32_t=`cat conftestval` else @@ -2552,7 +2652,7 @@ EOF echo $ac_n "checking size of uint64_t""... $ac_c" 1>&6 -echo "configure:2556: checking size of uint64_t" >&5 +echo "configure:2656: checking size of uint64_t" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_uint64_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2560,8 +2660,11 @@ else ac_cv_sizeof_uint64_t=0 else cat > conftest.$ac_ext < +#endif #include #ifdef STDC_HEADERS #include @@ -2576,7 +2679,7 @@ main() exit(0); } EOF -if { (eval echo configure:2580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2683: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_uint64_t=`cat conftestval` else @@ -2600,12 +2703,12 @@ EOF for ac_func in mmap strerror strtoul mkstemp do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2604: checking for $ac_func" >&5 +echo "configure:2707: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2735: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2654,7 +2757,7 @@ done echo $ac_n "checking for gzopen in -lz""... $ac_c" 1>&6 -echo "configure:2658: checking for gzopen in -lz" >&5 +echo "configure:2761: checking for gzopen in -lz" >&5 ac_lib_var=`echo z'_'gzopen | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2662,7 +2765,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lz $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else diff --git a/configure.in b/configure.in index 31f4018b..d8e24dc6 100644 --- a/configure.in +++ b/configure.in @@ -57,9 +57,11 @@ dnl Checks for headers AC_HEADER_STDC AC_HEADER_MAJOR AC_HEADER_SYS_WAIT +AC_HEADER_STDINT AC_CHECK_HEADERS(fcntl.h locale.h) AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h) AC_CHECK_HEADERS(unistd.h) +AC_CHECK_HEADERS(getopt.h) AC_CHECK_HEADERS(locale.h) dnl Checks for typedefs, structures, and compiler characteristics. @@ -70,11 +72,9 @@ AC_STRUCT_ST_RDEV AC_STRUCT_TIMEZONE_DAYLIGHT AC_SYS_LARGEFILE -dnl FIXME: only found in standard headers! -AC_CHECK_TYPE(uint8_t, unsigned char) -AC_CHECK_TYPE(uint16_t, unsigned short) -AC_CHECK_TYPE(uint32_t, unsigned int) - +AC_CHECK_TYPE_STDC(uint8_t, unsigned char) +AC_CHECK_TYPE_STDC(uint16_t, unsigned short) +AC_CHECK_TYPE_STDC(uint32_t, unsigned int) AC_C_LONG_LONG if test $ac_cv_c_long_long = yes; then long64='unsigned long long'; @@ -82,7 +82,7 @@ else long64='unsigned long'; fi dnl This needs a patch to autoconf 2.13 acgeneral.m4 -AC_CHECK_TYPE2(uint64_t, $long64) +AC_CHECK_TYPE2_STDC(uint64_t, $long64) AC_CHECK_SIZEOF_STDC_HEADERS(uint8_t, 0) AC_CHECK_SIZEOF_STDC_HEADERS(uint16_t, 0) diff --git a/doc/file.man b/doc/file.man index 7f6d623c..de2885aa 100644 --- a/doc/file.man +++ b/doc/file.man @@ -1,5 +1,5 @@ .TH FILE __CSECTION__ "Copyright but distributable" -.\" $Id: file.man,v 1.40 2002/05/16 15:26:54 christos Exp $ +.\" $Id: file.man,v 1.41 2002/05/16 18:45:56 christos Exp $ .SH NAME file \- determine file type @@ -304,12 +304,15 @@ keep the old magic file around for comparison purposes .IR __MAGIC__.orig ). .SH EXAMPLES .nf -$ file file.c file /dev/hda +$ file file.c file /dev/{wd0a,hda} file.c: C program text -file: ELF 32-bit LSB executable, Intel 80386, version 1, - dynamically linked, not stripped -/dev/hda: block special - +file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), + dynamically linked (uses shared libs), stripped +/dev/wd0a: block special (0/0) +/dev/hda: block special (3/0) +$ file -s /dev/wd0{b,d} +/dev/wd0b: data +/dev/wd0d: x86 boot sector $ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10} /dev/hda: x86 boot sector /dev/hda1: Linux/i386 ext2 filesystem @@ -323,18 +326,19 @@ $ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10} /dev/hda9: empty /dev/hda10: empty -$ file -i file.c file /dev/hda +$ file -i file.c file /dev/{wd0a,hda} file.c: text/x-c file: application/x-executable, dynamically linked (uses shared libs), not stripped /dev/hda: application/x-not-regular-file +/dev/wd0a: application/x-not-regular-file .fi .SH HISTORY There has been a .B file -command in every \s-1UNIX\s0 since at least Research Version 6 -(man page dated January 16, 1975). +command in every \s-1UNIX\s0 since at least Research Version 4 +(man page dated November, 1973). The System V version introduced one significant major change: the external list of magic number types. This slowed the program down slightly but made it a lot more flexible. diff --git a/doc/magic.man b/doc/magic.man index 5f6d0625..34c79931 100644 --- a/doc/magic.man +++ b/doc/magic.man @@ -7,7 +7,7 @@ This manual page documents the format of the magic file as used by the .BR file (__CSECTION__) command, version __VERSION__. The -.B file +.BR file command identifies the type of a file using, among other tests, a test for whether the file begins with a certain @@ -130,7 +130,7 @@ then presumably print that string, by doing .IP message The message to be printed if the comparison succeeds. If the string contains a -.BR printf (3S) +.BR printf (3) format specification, the value from the file (with any specified masking performed) is printed using the message as the format string. .PP @@ -219,4 +219,4 @@ indirect offsets. .\" the changes I posted to the S5R2 version. .\" .\" Modified for Ian Darwin's version of the file command. -.\" @(#)$Id: magic.man,v 1.17 2001/08/07 15:38:42 christos Exp $ +.\" @(#)$Id: magic.man,v 1.18 2002/05/16 18:45:56 christos Exp $ diff --git a/magic/Magdir/adventure b/magic/Magdir/adventure index 38a5e33a..864712f6 100644 --- a/magic/Magdir/adventure +++ b/magic/Magdir/adventure @@ -4,11 +4,12 @@ # # from Allen Garvin # Edited by Dave Chapeskie Jun 28, 1998 +# Edited by Chris Chittleborough , March 2002 # # ALAN # I assume there are other, lower versions, but these are the only ones I # saw in the archive. -0 beshort 0x0206 ALAN text adventure code data +0 beshort 0x0206 ALAN game data >2 byte <10 version 2.6%d # Conflicts with too much other stuff! @@ -34,6 +35,29 @@ #>18 string >\0 Serial %.6s) # TADS (Text Adventure Development System) -0 string TADS TADS game data ->13 string >\0 (ver. %.6s, ->22 string >\0 date %s) +# All files are machine-independent (games compile to byte-code) and are tagged +# with a version string of the form "V2..\0" (but TADS 3 is +# on the way). +# Game files start with "TADS2 bin\n\r\032\0" then the compiler version. +0 string TADS2\ bin TADS +>9 belong !0x0A0D1A00 game data, CORRUPTED +>9 belong 0x0A0D1A00 +>>13 string >\0 %s game data +# Resource files start with "TADS2 rsc\n\r\032\0" then the compiler version. +0 string TADS2\ rsc TADS +>9 belong !0x0A0D1A00 resource data, CORRUPTED +>9 belong 0x0A0D1A00 +>>13 string >\0 %s resource data +# Some saved game files start with "TADS2 save/g\n\r\032\0", a little-endian +# 2-byte length N, the N-char name of the game file *without* a NUL (darn!), +# "TADS2 save\n\r\032\0" and the interpreter version. +0 string TADS2\ save/g TADS +>12 belong !0x0A0D1A00 saved game data, CORRUPTED +>12 belong 0x0A0D1A00 +>>(16.s+32) string >\0 %s saved game data +# Other saved game files start with "TADS2 save\n\r\032\0" and the interpreter +# version. +0 string TADS2\ save TADS +>10 belong !0x0A0D1A00 saved game data, CORRUPTED +>10 belong 0x0A0D1A00 +>>14 string >\0 %s saved game data diff --git a/magic/Magdir/animation b/magic/Magdir/animation index 6fa689f8..56f25cf3 100644 --- a/magic/Magdir/animation +++ b/magic/Magdir/animation @@ -15,75 +15,96 @@ # MPEG Audio (*.mpx) # from dreesen@math.fu-berlin.de -# XXX -# This conflicts with the FF FE signature for UTF-16-encoded Unicode -# text, which will be identified as an MP3 file. I don't have any MP3s -# so I don't know how to (or even if it's possible to) change this to -# tell the two apart. enf@pobox.com +# MPEG 1.0 Layer 3 +0 beshort&0xfffe =0xfffa \bMP3 +>2 byte&0xf0 =0x10 \b, 32 kBits +>2 byte&0xf0 =0x20 \b, 40 kBits +>2 byte&0xf0 =0x30 \b, 48 kBits +>2 byte&0xf0 =0x40 \b, 56 kBits +>2 byte&0xf0 =0x50 \b, 64 kBits +>2 byte&0xf0 =0x60 \b, 80 kBits +>2 byte&0xf0 =0x70 \b, 96 kBits +>2 byte&0xf0 =0x80 \b, 112 kBits +>2 byte&0xf0 =0x90 \b, 128 kBits +>2 byte&0xf0 =0xA0 \b, 160 kBits +>2 byte&0xf0 =0xB0 \b, 192 kBits +>2 byte&0xf0 =0xC0 \b, 224 kBits +>2 byte&0xf0 =0xD0 \b, 256 kBits +>2 byte&0xf0 =0xE0 \b, 320 kBits +# freq +>2 byte&0x0C =0x00 \b, 44.1 kHz +>2 byte&0x0C =0x04 \b, 48 kHz +>2 byte&0x0C =0x08 \b, 32 kHz +# misc +>3 byte&0xC0 =0x00 \b, Stereo +>3 byte&0xC0 =0x40 \b, JStereo +>3 byte&0xC0 =0x80 \b, Dual-Ch +>3 byte&0xC0 =0xC0 \b, Mono +#>1 byte&0x01 =0x00 \b, Error Protection +#>2 byte&0x02 =0x02 \b, Padding +#>2 byte&0x01 =0x01 \b, Private +#>3 byte&0x08 =0x08 \b, Copyright +#>3 byte&0x04 =0x04 \b, Original +#>3 byte&0x03 1 \b, Emphasis 5 +#>3 byte&0x03 3 \b, Emphasis c -0 beshort &0xfff0 MP -# MPEG 1.0 ->1 byte&0x08 =0x08 \b -# Layer 3 ->>1 byte &0x02 \b3 ->>>2 byte&0xf0 =0x10 \b, 32 kBits ->>>2 byte&0xf0 =0x20 \b, 40 kBits ->>>2 byte&0xf0 =0x30 \b, 48 kBits ->>>2 byte&0xf0 =0x40 \b, 56 kBits ->>>2 byte&0xf0 =0x50 \b, 64 kBits ->>>2 byte&0xf0 =0x60 \b, 80 kBits ->>>2 byte&0xf0 =0x70 \b, 96 kBits ->>>2 byte&0xf0 =0x80 \b, 112 kBits ->>>2 byte&0xf0 =0x90 \b, 128 kBits ->>>2 byte&0xf0 =0xA0 \b, 160 kBits ->>>2 byte&0xf0 =0xB0 \b, 192 kBits ->>>2 byte&0xf0 =0xC0 \b, 224 kBits ->>>2 byte&0xf0 =0xD0 \b, 256 kBits ->>>2 byte&0xf0 =0xE0 \b, 320 kBits -# Layer 2 ->>1 byte &0x04 \b2 ->>>2 byte&0xf0 =0x10 \b, 32 kBits ->>>2 byte&0xf0 =0x20 \b, 48 kBits ->>>2 byte&0xf0 =0x30 \b, 56 kBits ->>>2 byte&0xf0 =0x40 \b, 64 kBits ->>>2 byte&0xf0 =0x50 \b, 80 kBits ->>>2 byte&0xf0 =0x60 \b, 96 kBits ->>>2 byte&0xf0 =0x70 \b, 112 kBits ->>>2 byte&0xf0 =0x80 \b, 128 kBits ->>>2 byte&0xf0 =0x90 \b, 160 kBits ->>>2 byte&0xf0 =0xA0 \b, 192 kBits ->>>2 byte&0xf0 =0xB0 \b, 224 kBits ->>>2 byte&0xf0 =0xC0 \b, 256 kBits ->>>2 byte&0xf0 =0xD0 \b, 320 kBits ->>>2 byte&0xf0 =0xE0 \b, 384 kBits +# MPEG 1.0 Layer 2 +0 beshort&0xfffe =0xfffc \bMP2 +>2 byte&0xf0 =0x10 \b, 32 kBits +>2 byte&0xf0 =0x20 \b, 48 kBits +>2 byte&0xf0 =0x30 \b, 56 kBits +>2 byte&0xf0 =0x40 \b, 64 kBits +>2 byte&0xf0 =0x50 \b, 80 kBits +>2 byte&0xf0 =0x60 \b, 96 kBits +>2 byte&0xf0 =0x70 \b, 112 kBits +>2 byte&0xf0 =0x80 \b, 128 kBits +>2 byte&0xf0 =0x90 \b, 160 kBits +>2 byte&0xf0 =0xA0 \b, 192 kBits +>2 byte&0xf0 =0xB0 \b, 224 kBits +>2 byte&0xf0 =0xC0 \b, 256 kBits +>2 byte&0xf0 =0xD0 \b, 320 kBits +>2 byte&0xf0 =0xE0 \b, 384 kBits # freq ->>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 +# misc +>3 byte&0xC0 =0x00 \b, Stereo +>3 byte&0xC0 =0x40 \b, JStereo +>3 byte&0xC0 =0x80 \b, Dual-Ch +>3 byte&0xC0 =0xC0 \b, Mono +#>1 byte&0x01 =0x00 \b, Error Protection +#>2 byte&0x02 =0x02 \b, Padding +#>2 byte&0x01 =0x01 \b, Private +#>3 byte&0x08 =0x08 \b, Copyright +#>3 byte&0x04 =0x04 \b, Original +#>3 byte&0x03 1 \b, Emphasis 5 +#>3 byte&0x03 3 \b, Emphasis c + # MPEG 2.0 ->1 byte&0x08 =0x00 \b +0 beshort&0xfff8 =0xfff0 MP # Layer 3 ->>1 byte &0x02 \b3 +>1 byte &0x02 \b3 # Layer 2 ->>1 byte &0x04 \b2 ->>2 byte&0xf0 =0x10 \b, 8 kBits ->>2 byte&0xf0 =0x20 \b, 16 kBits ->>2 byte&0xf0 =0x30 \b, 24 kBits ->>2 byte&0xf0 =0x40 \b, 32 kBits ->>2 byte&0xf0 =0x50 \b, 40 kBits ->>2 byte&0xf0 =0x60 \b, 48 kBits ->>2 byte&0xf0 =0x70 \b, 56 kBits ->>2 byte&0xf0 =0x80 \b, 64 kBits ->>2 byte&0xf0 =0x90 \b, 80 kBits ->>2 byte&0xf0 =0xA0 \b, 96 kBits ->>2 byte&0xf0 =0xB0 \b, 112 kBits ->>2 byte&0xf0 =0xC0 \b, 128 kBits ->>2 byte&0xf0 =0xD0 \b, 144 kBits ->>2 byte&0xf0 =0xE0 \b, 160 kBits +>1 byte &0x04 \b2 +>2 byte&0xf0 =0x10 \b, 8 kBits +>2 byte&0xf0 =0x20 \b, 16 kBits +>2 byte&0xf0 =0x30 \b, 24 kBits +>2 byte&0xf0 =0x40 \b, 32 kBits +>2 byte&0xf0 =0x50 \b, 40 kBits +>2 byte&0xf0 =0x60 \b, 48 kBits +>2 byte&0xf0 =0x70 \b, 56 kBits +>2 byte&0xf0 =0x80 \b, 64 kBits +>2 byte&0xf0 =0x90 \b, 80 kBits +>2 byte&0xf0 =0xA0 \b, 96 kBits +>2 byte&0xf0 =0xB0 \b, 112 kBits +>2 byte&0xf0 =0xC0 \b, 128 kBits +>2 byte&0xf0 =0xD0 \b, 144 kBits +>2 byte&0xf0 =0xE0 \b, 160 kBits # freq ->>2 byte&0x0C =0x00 \b, 22.05 kHz ->>2 byte&0x0C =0x04 \b, 24 kHz ->>2 byte&0x0C =0x08 \b, 16 kHz +>2 byte&0x0C =0x00 \b, 22.05 kHz +>2 byte&0x0C =0x04 \b, 24 kHz +>2 byte&0x0C =0x08 \b, 16 kHz # misc >3 byte&0xC0 =0x00 \b, Stereo >3 byte&0xC0 =0x40 \b, JStereo @@ -168,3 +189,8 @@ # Microsoft Advanced Streaming Format (ASF) 0 belong 0x3026b275 Microsoft ASF + +# MNG Video Format, +0 string \x8aMNG MNG video data, +>4 belong !0x0d0a1a0a CORRUPTED, +>4 belong 0x0d0a1a0a diff --git a/magic/Magdir/audio b/magic/Magdir/audio index b47dd437..94940986 100644 --- a/magic/Magdir/audio +++ b/magic/Magdir/audio @@ -136,9 +136,6 @@ # Audio Visual Research 0 string 2BIT Audio Visual Research file -# From Felix von Leitner -0 string OggS Ogg-Vorbis compressed sound file - # SGI SoundTrack 0 string _SGI_SoundTrack SGI SoundTrack project file # ID3 version 2 tags diff --git a/magic/Magdir/commands b/magic/Magdir/commands index 3fe253a5..a9dd089b 100644 --- a/magic/Magdir/commands +++ b/magic/Magdir/commands @@ -27,16 +27,6 @@ 0 string/b #!\ /usr/bin/awk awk script text executable 0 string BEGIN awk script text -# For Larry Wall's perl language. The ``eval'' line recognizes an -# outrageously clever hack for USG systems. -# Keith Waclena -0 string/b #!\ /bin/perl perl script text executable -0 string eval\ "exec\ /bin/perl perl script text -0 string/b #!\ /usr/bin/perl perl script text executable -0 string eval\ "exec\ /usr/bin/perl perl script text -0 string/b #!\ /usr/local/bin/perl perl script text -0 string eval\ "exec\ /usr/local/bin/perl perl script text executable - # AT&T Bell Labs' Plan 9 shell 0 string/b #!\ /bin/rc Plan 9 rc shell script text executable @@ -60,3 +50,13 @@ >2 string >\0 %s script text executable 0 string #!\ script text executable >3 string >\0 for %s + +# PHP scripts +# Ulf Harnhammar +0 string/c =2 byte&0x1f x %d bits # gzip (GNU zip, not to be confused with Info-ZIP or PKWARE zip archiver) +# Edited by Chris Chittleborough , March 2002 +# * Original filename is only at offset 10 if "extra field" absent +# * Produce shorter output - notably, only report compression methods +# other than 8 ("deflate", the only method defined in RFC 1952). 0 string \037\213 gzip compressed data ->2 byte <8 \b, reserved method, ->2 byte 8 \b, deflated, ->3 byte &0x01 ASCII, ->3 byte &0x02 continuation, ->3 byte &0x04 extra field, ->3 byte &0x08 original filename, ->>10 string x `%s', ->3 byte &0x10 comment, ->3 byte &0x20 encrypted, ->4 ledate x last modified: %s, ->8 byte 2 max compression, ->8 byte 4 max speed, ->9 byte =0x00 os: MS-DOS ->9 byte =0x01 os: Amiga ->9 byte =0x02 os: VMS ->9 byte =0x03 os: Unix ->9 byte =0x05 os: Atari ->9 byte =0x06 os: OS/2 ->9 byte =0x07 os: MacOS ->9 byte =0x0A os: Tops/20 ->9 byte =0x0B os: Win/32 +>2 byte <8 \b, reserved method +>2 byte >8 \b, unknown method +>3 byte &0x01 \b, ASCII +>3 byte &0x02 \b, continuation +>3 byte &0x04 \b, extra field +>3 byte&0xC =0x08 +>>10 string x \b, was "%s" +>9 byte =0x00 \b, from MS-DOS +>9 byte =0x01 \b, from Amiga +>9 byte =0x02 \b, from VMS +>9 byte =0x03 \b, from Unix +>9 byte =0x05 \b, from Atari +>9 byte =0x06 \b, from OS/2 +>9 byte =0x07 \b, from MacOS +>9 byte =0x0A \b, from Tops/20 +>9 byte =0x0B \b, from Win/32 +>3 byte &0x10 \b, comment +>3 byte &0x20 \b, encrypted +### >4 ledate x last modified: %s, +>8 byte 2 \b, max compression +>8 byte 4 \b, max speed # packed data, Huffman (minimum redundancy) codes on a byte-by-byte basis 0 string \037\036 packed data @@ -144,3 +148,7 @@ >>17 byte =0x0A os: Tops/20 >>17 byte =0x0B os: WinNT >>17 byte =0x0E os: Win32 + +# 4.3BSD-Quasijarus Strong Compression +# http://minnie.tuhs.org/Quasijarus/compress.html +0 string \037\241 Quasijarus strong compressed data diff --git a/magic/Magdir/dolby b/magic/Magdir/dolby index 238fc2b6..230f738a 100644 --- a/magic/Magdir/dolby +++ b/magic/Magdir/dolby @@ -1,14 +1,23 @@ -# AC-3 aka A/52 aka Dolby Digital +# ATSC A/53 aka AC-3 aka Dolby Digital +# from http://www.atsc.org/standards/a_52a.pdf # corrections, additions, etc. are always welcome! # # syncword -0 beshort 0x0b77 AC-3 aka A/52 aka Dolby Digital stream, +0 beshort 0x0b77 ATSC A/52 aka AC-3 aka Dolby Digital stream, # fscod >4 byte&0xc0 0x00 48 kHz, >4 byte&0xc0 0x40 44.1 kHz, >4 byte&0xc0 0x80 32 kHz, # is this one used for 96 kHz? >4 byte&0xc0 0xc0 reserved frequency, +# +>5 byte&7 = 0 \b, complete main (CM) +>5 byte&7 = 1 \b, music and effects (ME) +>5 byte&7 = 2 \b, visually impaired (VI) +>5 byte&7 = 3 \b, hearing impaired (HI) +>5 byte&7 = 4 \b, dialogue (D) +>5 byte&7 = 5 \b, commentary (C) +>5 byte&7 = 6 \b, emergency (E) # acmod >6 byte&0xe0 0x00 1+1 front, >6 byte&0xe0 0x20 1 front/0 rear, @@ -21,6 +30,26 @@ # lfeon (these may be incorrect) >7 byte&0x40 0x00 LFE off, >7 byte&0x40 0x40 LFE on, +# +>4 byte&0x3e = 0x00 \b, 32 kbit/s +>4 byte&0x3e = 0x02 \b, 40 kbit/s +>4 byte&0x3e = 0x04 \b, 48 kbit/s +>4 byte&0x3e = 0x06 \b, 56 kbit/s +>4 byte&0x3e = 0x08 \b, 64 kbit/s +>4 byte&0x3e = 0x0a \b, 80 kbit/s +>4 byte&0x3e = 0x0c \b, 96 kbit/s +>4 byte&0x3e = 0x0e \b, 112 kbit/s +>4 byte&0x3e = 0x10 \b, 128 kbit/s +>4 byte&0x3e = 0x12 \b, 160 kbit/s +>4 byte&0x3e = 0x14 \b, 192 kbit/s +>4 byte&0x3e = 0x16 \b, 224 kbit/s +>4 byte&0x3e = 0x18 \b, 256 kbit/s +>4 byte&0x3e = 0x1a \b, 320 kbit/s +>4 byte&0x3e = 0x1c \b, 384 kbit/s +>4 byte&0x3e = 0x1e \b, 448 kbit/s +>4 byte&0x3e = 0x20 \b, 512 kbit/s +>4 byte&0x3e = 0x22 \b, 576 kbit/s +>4 byte&0x3e = 0x24 \b, 640 kbit/s # dsurmod (these may be incorrect) >6 beshort&0x0180 0x0000 Dolby Surround not indicated >6 beshort&0x0180 0x0080 not Dolby Surround encoded diff --git a/magic/Magdir/elf b/magic/Magdir/elf index b53ec74e..a6c04ee5 100644 --- a/magic/Magdir/elf +++ b/magic/Magdir/elf @@ -5,38 +5,45 @@ # We have to check the byte order flag to see what byte order all the # other stuff in the header is in. # -# MIPS R3000 may also be for MIPS R2000. # What're the correct byte orders for the nCUBE and the Fujitsu VPP500? # # updated by Daniel Quinlan (quinlan@yggdrasil.com) 0 string \177ELF ELF >4 byte 0 invalid class >4 byte 1 32-bit -# only for MIPS +# only for MIPS - in the future, the ABI field of e_flags should be used. >>18 beshort 8 >>18 beshort 10 >>>36 belong &0x20 N32 >4 byte 2 64-bit >5 byte 0 invalid byte order >5 byte 1 LSB -# only for MIPS R3000_BE +# The official e_machine number for MIPS is now #8, regardless of endianness. +# The second number (#10) will be deprecated later. For now, we still +# say something if #10 is encountered, but only gory details for #8. >>18 leshort 8 # only for 32-bit >>>4 byte 1 ->>>>36 lelong&0xf0000000 0x00000000 mips-1 ->>>>36 lelong&0xf0000000 0x10000000 mips-2 ->>>>36 lelong&0xf0000000 0x20000000 mips-3 ->>>>36 lelong&0xf0000000 0x30000000 mips-4 ->>>>36 lelong&0xf0000000 0x40000000 mips-5 ->>>>36 lelong&0xf0000000 0x50000000 mips-6 +>>>>36 lelong&0xf0000000 0x00000000 MIPS-I +>>>>36 lelong&0xf0000000 0x10000000 MIPS-II +>>>>36 lelong&0xf0000000 0x20000000 MIPS-III +>>>>36 lelong&0xf0000000 0x30000000 MIPS-IV +>>>>36 lelong&0xf0000000 0x40000000 MIPS-V +>>>>36 lelong&0xf0000000 0x60000000 MIPS32 +>>>>36 lelong&0xf0000000 0x70000000 MIPS64 +>>>>36 lelong&0xf0000000 0x80000000 MIPS32 rel2 +>>>>36 lelong&0xf0000000 0x90000000 MIPS64 rel2 # only for 64-bit >>>4 byte 2 ->>>>48 lelong&0xf0000000 0x00000000 mips-1 ->>>>48 lelong&0xf0000000 0x10000000 mips-2 ->>>>48 lelong&0xf0000000 0x20000000 mips-3 ->>>>48 lelong&0xf0000000 0x30000000 mips-4 ->>>>48 lelong&0xf0000000 0x40000000 mips-5 ->>>>48 lelong&0xf0000000 0x50000000 mips-6 +>>>>48 lelong&0xf0000000 0x00000000 MIPS-I +>>>>48 lelong&0xf0000000 0x10000000 MIPS-II +>>>>48 lelong&0xf0000000 0x20000000 MIPS-III +>>>>48 lelong&0xf0000000 0x30000000 MIPS-IV +>>>>48 lelong&0xf0000000 0x40000000 MIPS-V +>>>>48 lelong&0xf0000000 0x60000000 MIPS32 +>>>>48 lelong&0xf0000000 0x70000000 MIPS64 +>>>>48 lelong&0xf0000000 0x80000000 MIPS32 rel2 +>>>>48 lelong&0xf0000000 0x90000000 MIPS64 rel2 >>16 leshort 0 no file type, >>16 leshort 1 relocatable, >>16 leshort 2 executable, @@ -59,10 +66,9 @@ >>18 leshort 5 Motorola 88000 - invalid byte order, >>18 leshort 6 Intel 80486, >>18 leshort 7 Intel 80860, -# "officially" big endian, but binutils bfd only emits magic #8 for MIPS. ->>18 leshort 8 MIPS R3000_LE [bfd bug], +>>18 leshort 8 MIPS, >>18 leshort 9 Amdahl - invalid byte order, ->>18 leshort 10 MIPS R3000_LE, +>>18 leshort 10 MIPS (deprecated), >>18 leshort 11 RS6000 - invalid byte order, >>18 leshort 15 PA-RISC - invalid byte order, >>>50 leshort 0x0214 2.0 @@ -96,24 +102,30 @@ >>20 lelong 1 version 1 >>36 lelong 1 MathCoPro/FPU/MAU Required >5 byte 2 MSB -# only for MIPS R3000_BE +# only for MIPS - see comment in little-endian section above. >>18 beshort 8 # only for 32-bit >>>4 byte 1 ->>>>36 belong&0xf0000000 0x00000000 mips-1 ->>>>36 belong&0xf0000000 0x10000000 mips-2 ->>>>36 belong&0xf0000000 0x20000000 mips-3 ->>>>36 belong&0xf0000000 0x30000000 mips-4 ->>>>36 belong&0xf0000000 0x40000000 mips-5 ->>>>36 belong&0xf0000000 0x50000000 mips-6 +>>>>36 belong&0xf0000000 0x00000000 MIPS-I +>>>>36 belong&0xf0000000 0x10000000 MIPS-II +>>>>36 belong&0xf0000000 0x20000000 MIPS-III +>>>>36 belong&0xf0000000 0x30000000 MIPS-IV +>>>>36 belong&0xf0000000 0x40000000 MIPS-V +>>>>36 belong&0xf0000000 0x60000000 MIPS32 +>>>>36 belong&0xf0000000 0x70000000 MIPS64 +>>>>36 belong&0xf0000000 0x80000000 MIPS32 rel2 +>>>>36 belong&0xf0000000 0x90000000 MIPS64 rel2 # only for 64-bit >>>4 byte 2 ->>>>48 belong&0xf0000000 0x00000000 mips-1 ->>>>48 belong&0xf0000000 0x10000000 mips-2 ->>>>48 belong&0xf0000000 0x20000000 mips-3 ->>>>48 belong&0xf0000000 0x30000000 mips-4 ->>>>48 belong&0xf0000000 0x40000000 mips-5 ->>>>48 belong&0xf0000000 0x50000000 mips-6 +>>>>48 belong&0xf0000000 0x00000000 MIPS-I +>>>>48 belong&0xf0000000 0x10000000 MIPS-II +>>>>48 belong&0xf0000000 0x20000000 MIPS-III +>>>>48 belong&0xf0000000 0x30000000 MIPS-IV +>>>>48 belong&0xf0000000 0x40000000 MIPS-V +>>>>48 belong&0xf0000000 0x60000000 MIPS32 +>>>>48 belong&0xf0000000 0x70000000 MIPS64 +>>>>48 belong&0xf0000000 0x80000000 MIPS32 rel2 +>>>>48 belong&0xf0000000 0x90000000 MIPS64 rel2 >>16 beshort 0 no file type, >>16 beshort 1 relocatable, >>16 beshort 2 executable, @@ -133,9 +145,9 @@ >>18 beshort 5 Motorola 88000, >>18 beshort 6 Intel 80486 - invalid byte order, >>18 beshort 7 Intel 80860, ->>18 beshort 8 MIPS R3000_BE, +>>18 beshort 8 MIPS, >>18 beshort 9 Amdahl, ->>18 beshort 10 MIPS R3000_LE - invalid byte order, +>>18 beshort 10 MIPS (deprecated), >>18 beshort 11 RS6000, >>18 beshort 15 PA-RISC >>>50 beshort 0x0214 2.0 diff --git a/magic/Magdir/filesystems b/magic/Magdir/filesystems index 20600c6f..71ea57dc 100644 --- a/magic/Magdir/filesystems +++ b/magic/Magdir/filesystems @@ -25,7 +25,12 @@ >512 belong&077777777 0600407 \b, boot block present 0x1FE leshort 0xAA55 x86 boot sector >2 string OSBS \b, OS/BS MBR +# J\xf6rg Jenderek >0x8C string Invalid\ partition\ table \b, MS-DOS MBR +>0x9D string Invalid\ partition\ table \b, DR-DOS MBR, version 7.01 to 7.03 +>0x10F string Ung\201ltige\ Partitionstabelle \b, MS-DOS MBR, german version 4.10.1998, 4.10.2222 +>0x8B string Ung\201ltige\ Partitionstabelle \b, MS-DOS MBR, german version 5.00 to 4.00.950 +>0x145 string Default:\ F \b, FREE-DOS MBR >0 string \0\0\0\0 \b, extended partition table >0 leshort 0x3CEB \b, system >>3 string >\0 %s @@ -41,6 +46,12 @@ >>>>32 lelong x %d sectors >0x200 lelong 0x82564557 \b, BSD disklabel +# Solaris 7 FAT12 floppies J\xf6rg Jenderek +>0 leshort 0x7AEB \b, system +>>3 string >\0 %s +>>0x36 string FAT \b, %s +>>>0x39 string 12 (%s bit) + # Minix filesystems - Juan Cespedes 0x410 leshort 0x137f Minix filesystem 0x410 leshort 0x138f Minix filesystem, 30 char names diff --git a/magic/Magdir/gringotts b/magic/Magdir/gringotts new file mode 100644 index 00000000..2d135f8f --- /dev/null +++ b/magic/Magdir/gringotts @@ -0,0 +1,25 @@ + +#------------------------------------------------------------------------------ +# gringotts: file(1) magic for Gringotts +# http://devel.pluto.linux.it/projects/Gringotts/ +# author: Germano Rizzo +#GRG2????Y +0 string GRG Gringotts data file +>3 string 1 v.1, SERPENT crypt, SHA-256 hash, ZLib lvl.9 +>3 string 2 v.2, +>>8 byte&0x70 0x00 RIJNDAEL-128 crypt, +>>8 byte&0x70 0x10 SERPENT crypt, +>>8 byte&0x70 0x20 TWOFISH crypt, +>>8 byte&0x70 0x30 CAST-256 crypt, +>>8 byte&0x70 0x40 SAFER+ crypt, +>>8 byte&0x70 0x50 LOKI97 crypt, +>>8 byte&0x70 0x60 3DES crypt, +>>8 byte&0x70 0x70 RIJNDAEL-256 crypt, +>>8 byte&0x08 0x00 SHA1 hash, +>>8 byte&0x08 0x08 RIPEMD-160 hash, +>>8 byte&0x04 0x00 ZLib +>>8 byte&0x04 0x04 BZip2 +>>8 byte&0x03 0x00 lvl.0 +>>8 byte&0x03 0x01 lvl.3 +>>8 byte&0x03 0x02 lvl.6 +>>8 byte&0x03 0x03 lvl.9 diff --git a/magic/Magdir/lisp b/magic/Magdir/lisp index 4e6c926b..11f33cd2 100644 --- a/magic/Magdir/lisp +++ b/magic/Magdir/lisp @@ -3,17 +3,24 @@ # lisp: file(1) magic for lisp programs # # various lisp types, from Daniel Quinlan (quinlan@yggdrasil.com) + +# This is a guess, but a good one. 0 string ;; Lisp/Scheme program text + # Emacs 18 - this is always correct, but not very magical. -0 string \012( byte-compiled Emacs-Lisp program data +0 string \012( Emacs v18 byte-compiled Lisp data # Emacs 19+ - ver. recognition added by Ian Springer -0 string ;ELC byte-compiled Emacs-Lisp program data, ->4 byte >0 version %d -# +# Also applies to XEmacs 19+ .elc files; could tell them apart if we had regexp +# support or similar - Chris Chittleborough +0 string ;ELC +>4 byte >19 +>4 byte <32 Emacs/XEmacs v%d byte-compiled Lisp data + # Files produced by CLISP Common Lisp From: Bruno Haible 0 string (SYSTEM::VERSION\040' CLISP byte-compiled Lisp program text 0 long 0x70768BD2 CLISP memory image data 0 long 0xD28B7670 CLISP memory image data, other endian + # Files produced by GNU gettext 0 long 0xDE120495 GNU-format message catalog data 0 long 0x950412DE GNU-format message catalog data diff --git a/magic/Magdir/nitpicker b/magic/Magdir/nitpicker new file mode 100644 index 00000000..c40daece --- /dev/null +++ b/magic/Magdir/nitpicker @@ -0,0 +1,12 @@ +#------------------------------------------------------------------------------ +# nitpicker: file(1) magic for Flowfiles. +# From: Christian Jachmann http://www.nitpicker.de +0 string NPFF NItpicker Flow File +>4 byte x V%d. +>5 byte x %d +>6 bedate x started: %s +>10 bedate x stopped: %s +>14 belong x Bytes: %u +>18 belong x Bytes1: %u +>22 belong x Flows: %u +>26 belong x Pkts: %u diff --git a/magic/Magdir/perl b/magic/Magdir/perl new file mode 100644 index 00000000..bfbec4c1 --- /dev/null +++ b/magic/Magdir/perl @@ -0,0 +1,17 @@ + +#------------------------------------------------------------------------------ +# perl: file(1) magic for Larry Wall's perl language. +# +# The ``eval'' line recognizes an outrageously clever hack for USG systems. +# Keith Waclena +# Send additions to +0 string/b #!\ /bin/perl perl script text executable +0 string eval\ "exec\ /bin/perl perl script text +0 string/b #!\ /usr/bin/perl perl script text executable +0 string eval\ "exec\ /usr/bin/perl perl script text +0 string/b #!\ /usr/local/bin/perl perl script text +0 string eval\ "exec\ /usr/local/bin/perl perl script text executable + +# a couple more, by me +0 regex package Perl5 module source text (via regex) +0 string package Perl5 module source text diff --git a/magic/Magdir/pulsar b/magic/Magdir/pulsar new file mode 100644 index 00000000..cb9cac6f --- /dev/null +++ b/magic/Magdir/pulsar @@ -0,0 +1,10 @@ +#------------------------------------------------------------------------------ +# pulsar: file(1) magic for Pulsar POP3 daemon binary files +# +# http://pulsar.sourceforge.net +# mailto:rok.papez@lugos.si +# + +0 belong 0x1ee7f11e Pulsar POP3 daemon mailbox cache file. +>4 ubelong x Version: %d. +>8 ubelong x \b%d diff --git a/magic/Magdir/sendmail b/magic/Magdir/sendmail index 503ef896..7880ab51 100644 --- a/magic/Magdir/sendmail +++ b/magic/Magdir/sendmail @@ -8,3 +8,12 @@ >16 string >\0 - version %s 0 short 0x271c Sendmail frozen configuration >16 string >\0 - version %s + +#------------------------------------------------------------------------------ +# sendmail: file(1) magic for sendmail m4(1) files +# +# From Hendrik Scholz +# i.e. files in /usr/share/sendmail/cf/ +# +0 string divert(-1)\n sendmail m4 text file + diff --git a/magic/Magdir/tex b/magic/Magdir/tex index 79d5bbaa..be84ecc4 100644 --- a/magic/Magdir/tex +++ b/magic/Magdir/tex @@ -37,6 +37,10 @@ 0 string \\documentclass LaTeX 2e document text 0 string \\relax LaTeX auxiliary file 0 string \\contentsline LaTeX table of contents +0 string %\ -*-latex-*- LaTeX document text + +# Tex document, from Hendrik Scholz +0 string \\ifx TeX document text # Index and glossary files 0 string \\indexentry LaTeX raw index file @@ -44,4 +48,56 @@ 0 string \\glossaryentry LaTeX raw glossary 0 string \\begin{theglossary} LaTeX sorted glossary 0 string This\ is\ makeindex Makeindex log file + # End of TeX + +#------------------------------------------------------------------------------ +# file(1) magic for BibTex text files +# From Hendrik Scholz + +0 string @article{ BibTex text file +0 string @book{ BibTex text file +0 string @inbook{ BibTex text file +0 string @incollection{ BibTex text file +0 string @inproceedings{ BibTex text file +0 string @manual{ BibTex text file +0 string @misc{ BibTex text file +0 string @preamble{ BibTex text file +0 string @phdthesis{ BibTex text file +0 string @techreport{ BibTex text file +0 string @unpublished{ BibTex text file + +0 string @Article{ BibTex text file +0 string @Book{ BibTex text file +0 string @Inbook{ BibTex text file +0 string @Incollection{ BibTex text file +0 string @Inproceedings{ BibTex text file +0 string @Manual{ BibTex text file +0 string @Misc{ BibTex text file +0 string @Preamble{ BibTex text file +0 string @Phdthesis{ BibTex text file +0 string @Techreport{ BibTex text file +0 string @Unpublished{ BibTex text file + +0 string @ARTICLE{ BibTex text file +0 string @BOOK{ BibTex text file +0 string @INBOOK{ BibTex text file +0 string @INCOLLECTION{ BibTex text file +0 string @INPROCEEDINGS{ BibTex text file +0 string @MANUAL{ BibTex text file +0 string @MISC{ BibTex text file +0 string @PREAMBLE{ BibTex text file +0 string @PHDTHESIS{ BibTex text file +0 string @TECHREPORT{ BibTex text file +0 string @UNPUBLISHED{ BibTex text file + +73 string %%%\ \ BibTeX-file{ BibTex text file (with full header) + +73 string %%%\ \ @BibTeX-style-file{ BibTeX style text file (with full header) + +0 string %\ BibTeX\ standard\ bibliography\ BibTeX standard bibliography style text file + +0 string %\ BibTeX\ ` BibTeX custom bibliography style text file + +0 string @c\ @mapfile{ TeX font aliases text file + diff --git a/magic/Magdir/varied.out b/magic/Magdir/varied.out index 03ca5103..76322dd5 100644 --- a/magic/Magdir/varied.out +++ b/magic/Magdir/varied.out @@ -26,3 +26,7 @@ # gnu gmon magic From: Eugen Dedu 0 string gmon GNU prof performance data >4 long x - version %ld +# From: Dave Pearson +# Harbour HRB files. +0 string \xc0HRB Harbour HRB file +>4 short x version %d diff --git a/magic/Magdir/vorbis b/magic/Magdir/vorbis index 6e4efadc..5e408428 100644 --- a/magic/Magdir/vorbis +++ b/magic/Magdir/vorbis @@ -4,6 +4,7 @@ # # From Felix von Leitner # Extended by Beni Cherniavsky +# Further extended by Greg Wooledge # # Most (everything but the number of channels and bitrate) is commented # out with `##' as it's not interesting to the average user. The most @@ -29,34 +30,44 @@ >>>>48 string <\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff \b, # The above tests if at least one of these is specified: >>>>>44 lelong !-1 ->>>>>>44 lelong x >%lu +# Vorbis RC2 has a bug which puts -1000 in the min/max bitrate fields +# instead of -1. +>>>>>>44 lelong !-1000 +>>>>>>>44 lelong x >%lu >>>>>48 lelong !-1 >>>>>>48 lelong x ~%lu >>>>>52 lelong !-1 ->>>>>>52 lelong x <%lu +>>>>>>52 lelong !-1000 +>>>>>>>52 lelong x <%lu >>>>>48 string <\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff kbps # -- Second vorbis header packet - the comments ->>>102 string \x03vorbis # A kludge to read the vendor string. It's a counted string, not a # zero-terminated one, so file(1) can't read it in a generic way. # libVorbis is the only one existing currently, so I detect specifically # it. The interesting value is the cvs date (8 digits decimal). -##>>>>113 string/c Xiphophorus\ libVorbis\ I \b, created by: Xiphophorus libVorbis I -##>>>>>137 string >00000000 %.8s +# Post-RC1 Ogg files have the second header packet (and thus the version) +# in a different place, so we must use an indirect offset. +>>>(84.b+85) string \x03vorbis +>>>>(84.b+96) string/c Xiphophorus\ libVorbis\ I \b, created by: Xiphophorus libVorbis I +>>>>>(84.b+120) string >00000000 %.8s # Map to beta version numbers: -##>>>>>>137 string <20000508 (>>>>>(84.b+120) string <20000508 (>>>>>(84.b+120) string 20000508 (beta1/2) +>>>>>>(84.b+120) string >20000508 +>>>>>>>(84.b+120) string <20001031 (beta2-3) +>>>>>>(84.b+120) string 20001031 (beta3) +>>>>>>(84.b+120) string >20001031 +>>>>>>>(84.b+120) string <20010225 (beta3-4) +>>>>>>(84.b+120) string 20010225 (beta4) +>>>>>>(84.b+120) string >20010225 +>>>>>>>(84.b+120) string <20010615 (beta4-RC1) +>>>>>>(84.b+120) string 20010615 (RC1) +>>>>>>(84.b+120) string 20010813 (RC2) +>>>>>>(84.b+120) string 20010816 (RC2 - Garf tuned v1) +>>>>>>(84.b+120) string 20011014 (RC2 - Garf tuned v2) +>>>>>>(84.b+120) string 20011217 (pre-RC3 CVS) +>>>>>>(84.b+120) string 20011231 (RC3) # The string has not changed from beta1 to 2 - they are indistinguishable. -##>>>>>>137 string 20000508 (beta1/2) -##>>>>>>137 string >20000508 -##>>>>>>>137 string <20001031 (beta2-3) -##>>>>>>137 string 20001031 (beta3) -##>>>>>>137 string >20001031 -##>>>>>>>137 string <20010225 (beta3-4) -##>>>>>>137 string 20010225 (beta4) -##>>>>>>137 string >20010225 -##>>>>>>>137 string <20010615 (beta4-RC1) -##>>>>>>137 string 20010615 (RC1) -##>>>>>>137 string >20010615 (>RC1) # Then come the comments, again length-counted (and number-counted). # Some looping constructs and registers would allow reading them but now # it's impossible. However we can print the number of comments present diff --git a/magic/Magdir/vxl b/magic/Magdir/vxl new file mode 100644 index 00000000..d3f55619 --- /dev/null +++ b/magic/Magdir/vxl @@ -0,0 +1,13 @@ + +#------------------------------------------------------------------------------ +# VXL: file(1) magic for VXL binary IO data files +# +# from Ian Scott +# +# VXL is a collection of C++ libraries for Computer Vision. +# See the vsl chapter in the VXL Book for more info +# http://www.isbe.man.ac.uk/public_vxl_doc/books/vxl/book.html +# http:/vxl.sf.net + +2 lelong 0x472b2c4e VXL data file, +>0 leshort >0 schema version no %d diff --git a/magic/magic.mime b/magic/magic.mime index 836942a8..f4249706 100644 --- a/magic/magic.mime +++ b/magic/magic.mime @@ -94,10 +94,9 @@ 0 belong 0x2e7261fd application/x-realaudio # MPEG Layer 3 sound files -# Modified the 11/20/97 at 15:59:04 by Christophe Prud'homme -0 belong 0xfffb audio/x-mp3 +0 beshort &0xffe0 audio/mpeg #MP3 with ID3 tag -0 string ID3 audio/x-mp3 +0 string ID3 audio/mpeg # Ogg/Vorbis 0 string OggS audio/x-ogg @@ -541,3 +540,6 @@ #PNG Image Format 0 string \x89PNG image/png + +# MNG Video Format, +0 string \x8aMNG video/x-mng diff --git a/src/Makefile.std b/src/Makefile.std index 47846d9c..9a091af7 100644 --- a/src/Makefile.std +++ b/src/Makefile.std @@ -1,6 +1,6 @@ # Makefile for file(1) cmd. # Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE. -# @(#)$Id: Makefile.std,v 1.12 2001/09/03 14:44:21 christos Exp $ +# @(#)$Id: Makefile.std,v 1.13 2002/05/16 18:45:56 christos Exp $ # # This software is not subject to any license of the American Telephone # and Telegraph Company or of the Regents of the University of California. @@ -71,10 +71,10 @@ LOCALOBJS = # localsrc/getopt.o localsrc/strtol.o \ LOCALINC = # localinc/*.h localinc/sys/*.h SRCS = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \ - compress.c is_tar.c readelf.c internat.c \ + compress.c is_tar.c readelf.c \ print.c $(LOCALSRCS) $(LOCALINC) OBJS = file.o apprentice.o fsmagic.o softmagic.o ascmagic.o \ - compress.o is_tar.o readelf.o internat.o \ + compress.o is_tar.o readelf.o \ print.o $(LOCALOBJS) HDRS = file.h names.h patchlevel.h readelf.h tar.h diff --git a/src/acconfig.h b/src/acconfig.h index 3423ecab..78181910 100644 --- a/src/acconfig.h +++ b/src/acconfig.h @@ -13,6 +13,12 @@ /* Define if the `long long' type works. */ #undef HAVE_LONG_LONG +/* Define if we have "tm_zone" in "struct tm". */ +#undef HAVE_TM_ZONE + +/* Define if we have a global "char * []" "tzname" variable. */ +#undef HAVE_TZNAME + /* Define if we have "tm_isdst" in "struct tm". */ #undef HAVE_TM_ISDST diff --git a/src/apprentice.c b/src/apprentice.c index 5c5ffc75..5465c73b 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -42,7 +42,7 @@ #endif #ifndef lint -FILE_RCSID("@(#)$Id: apprentice.c,v 1.45 2001/10/20 16:19:44 christos Exp $") +FILE_RCSID("@(#)$Id: apprentice.c,v 1.46 2002/05/16 18:45:56 christos Exp $") #endif /* lint */ #define EATAB {while (isascii((unsigned char) *l) && \ @@ -313,6 +313,8 @@ signextend(m, v) case STRING: case PSTRING: break; + case REGEX: + break; default: magwarn("can't happen: m->type=%d\n", m->type); @@ -479,6 +481,7 @@ parse(magicp, nmagicp, l, action) #define NLDATE 5 #define NBELDATE 7 #define NLELDATE 7 +#define NREGEX 5 if (*l == 'u') { ++l; @@ -534,6 +537,9 @@ parse(magicp, nmagicp, l, action) } else if (strncmp(l, "leldate", NLELDATE)==0) { m->type = LELDATE; l += NLELDATE; + } else if (strncmp(l, "regex", NREGEX)==0) { + m->type = REGEX; + l += sizeof("regex"); } else { magwarn("type %s invalid", l); return -1; @@ -698,7 +704,7 @@ getvalue(m, p) { int slen; - if (m->type == STRING || m->type == PSTRING) { + if (m->type == STRING || m->type == PSTRING || m->type == REGEX) { *p = getstr(*p, m->value.s, sizeof(m->value.s), &slen); m->vallen = slen; } else @@ -921,7 +927,7 @@ eatsize(p) } /* - * handle an mmaped file. + * handle a compiled file. */ static int apprentice_map(magicp, nmagicp, fn, action) diff --git a/src/compress.c b/src/compress.c index 19f6e2b7..82034863 100644 --- a/src/compress.c +++ b/src/compress.c @@ -22,7 +22,7 @@ #endif #ifndef lint -FILE_RCSID("@(#)$Id: compress.c,v 1.21 2001/10/20 17:44:52 christos Exp $") +FILE_RCSID("@(#)$Id: compress.c,v 1.22 2002/05/16 18:45:56 christos Exp $") #endif @@ -57,7 +57,8 @@ static int uncompressgzipped __P((const unsigned char *, unsigned char **, #endif int -zmagic(buf, nbytes) +zmagic(fname, buf, nbytes) + const char *fname; unsigned char *buf; int nbytes; { @@ -70,10 +71,10 @@ zmagic(buf, nbytes) continue; if (memcmp(buf, compr[i].magic, compr[i].maglen) == 0 && (newsize = uncompressbuf(i, buf, &newbuf, nbytes)) != 0) { - tryit(newbuf, newsize, 1); + tryit(fname, newbuf, newsize, 1); free(newbuf); printf(" ("); - tryit(buf, nbytes, 0); + tryit(fname, buf, nbytes, 0); printf(")"); return 1; } diff --git a/src/file.c b/src/file.c index 33bd4b0b..10dc8fe5 100644 --- a/src/file.c +++ b/src/file.c @@ -24,6 +24,8 @@ * * 4. This notice may not be removed or altered. */ +#include "file.h" + #include #include #include @@ -50,13 +52,16 @@ #include #endif +#ifdef HAVE_GETOPT_H +#include /* for long options (is this portable?)*/ +#endif + #include /* for byte swapping */ -#include "file.h" #include "patchlevel.h" #ifndef lint -FILE_RCSID("@(#)$Id: file.c,v 1.61 2001/12/18 20:56:38 christos Exp $") +FILE_RCSID("@(#)$Id: file.c,v 1.62 2002/05/16 18:45:56 christos Exp $") #endif /* lint */ @@ -66,6 +71,11 @@ FILE_RCSID("@(#)$Id: file.c,v 1.61 2001/12/18 20:56:38 christos Exp $") # define USAGE "Usage: %s [-bciknsvz] [-f namefile] [-m magicfiles] file...\n" #endif +#ifdef __EMX__ +static char *apptypeName = NULL; +int os2_apptype (const char *fn, char *buf, int nb); +#endif /* __EMX__ */ + #ifndef MAGIC # define MAGIC "/etc/magic" #endif @@ -98,6 +108,9 @@ int lineno; /* line number in the magic file */ static void unwrap __P((char *fn)); static void usage __P((void)); +#ifdef HAVE_GETOPT_H +static void help __P((void)); +#endif #if 0 static int byteconv4 __P((int, int, int)); static short byteconv2 __P((int, int, int)); @@ -117,11 +130,40 @@ main(argc, argv) int action = 0, didsomefiles = 0, errflg = 0, ret = 0, app = 0; char *mime, *home, *usermagic; struct stat sb; +#define OPTSTRING "bcdf:ikm:nsvzCL" +#ifdef HAVE_GETOPT_H + int longindex; + static struct option long_options[] = + { + {"version", 0, 0, 'v'}, + {"help", 0, 0, 0}, + {"brief", 0, 0, 'b'}, + {"checking-printout", 0, 0, 'c'}, + {"debug", 0, 0, 'd'}, + {"files-from", 1, 0, 'f'}, + {"mime", 0, 0, 'i'}, + {"keep-going", 0, 0, 'k'}, +#ifdef S_IFLNK + {"dereference", 0, 0, 'L'}, +#endif + {"magic-file", 1, 0, 'm'}, + {"uncompress", 0, 0, 'z'}, + {"no-buffer", 0, 0, 'n'}, + {"special-files", 0, 0, 's'}, + {"compile", 0, 0, 'C'}, + {0, 0, 0, 0}, + }; +#endif #ifdef LC_CTYPE setlocale(LC_CTYPE, ""); /* makes islower etc work for other langs */ #endif +#ifdef __EMX__ + /* sh-like wildcard expansion! Shouldn't hurt at least ... */ + _wildcard(&argc, &argv); +#endif + if ((progname = strrchr(argv[0], '/')) != NULL) progname++; else @@ -142,8 +184,19 @@ main(argc, argv) } } - while ((c = getopt(argc, argv, "bcdf:ikm:nsvzCL")) != -1) +#ifndef HAVE_GETOPT_H + while ((c = getopt(argc, argv, OPTSTRING)) != -1) +#else + while ((c = getopt_long(argc, argv, OPTSTRING, long_options, + &longindex)) != -1) +#endif switch (c) { +#ifdef HAVE_GETOPT_H + case 0 : + if (longindex == 1) + help(); + break; +#endif case 'b': ++bflag; break; @@ -400,7 +453,7 @@ process(inname, wid) ckfputs(iflag ? "application/x-empty" : "empty", stdout); else { buf[nbytes++] = '\0'; /* null-terminate it */ - match = tryit(buf, nbytes, zflag); + match = tryit(inname, buf, nbytes, zflag); } #ifdef BUILTIN_ELF @@ -446,12 +499,27 @@ process(inname, wid) int -tryit(buf, nb, zflag) - unsigned char *buf; - int nb, zflag; +tryit(fn, buf, nb, zfl) + const char *fn; /* file name*/ + unsigned char *buf; /* buffer */ + int nb, zfl; { + + /* + * The main work is done here! + * We have the file name and/or the data buffer to be identified. + */ + +#ifdef __EMX__ + /* + * Ok, here's the right place to add a call to some os-specific + * routine, e.g. + */ + if (os2_apptype(fn, buf, nb) == 1) + return 'o'; +#endif /* try compression stuff */ - if (zflag && zmagic(buf, nb)) + if (zfl && zmagic(fn, buf, nb)) return 'z'; /* try tests in /etc/magic (or surrogate magic file) */ @@ -472,5 +540,37 @@ usage() { (void)fprintf(stderr, USAGE, progname); (void)fprintf(stderr, "Usage: %s -C [-m magic]\n", progname); +#ifdef HAVE_GETOPT_H + (void)fputs("Try `file --help' for more information.\n", stderr); +#endif exit(1); } + +#ifdef HAVE_GETOPT_H +static void +help() +{ + puts( +"Usage: file [OPTION]... [FILE]... +Determine file type of FILEs. + + -m, --magic-file LIST use LIST as a colon-separated list of magic + number files + -z, --uncompress try to look inside compressed files + -b, --brief do not prepend filenames to output lines + -c, --checking-printout print the parsed form of the magic file, use in + conjunction with -m to debug a new magic file + before installing it + -f, --files-from FILE read the filenames to be examined from FILE + -i, --mime output mime type strings + -k, --keep-going don't stop at the first match + -L, --dereference causes symlinks to be followed + -n, --no-buffer do not buffer output + -s, --special-files treat special (block/char devices) files as + ordinary ones + --help display this help and exit + --version output version information and exit" +); + exit(0); +} +#endif diff --git a/src/file.h b/src/file.h index e0f588ae..1c673315 100644 --- a/src/file.h +++ b/src/file.h @@ -1,6 +1,6 @@ /* * file.h - definitions for file(1) program - * @(#)$Id: file.h,v 1.38 2001/10/20 17:44:53 christos Exp $ + * @(#)$Id: file.h,v 1.39 2002/05/16 18:45:56 christos Exp $ * * Copyright (c) Ian F. Darwin, 1987. * Written by Ian F. Darwin. @@ -79,6 +79,7 @@ struct magic { #define LDATE 14 #define BELDATE 15 #define LELDATE 16 +#define REGEX 17 uint8 in_op; /* operator for indirection */ uint8 mask_op; /* operator for mask */ #define OPAND 1 @@ -97,6 +98,7 @@ struct magic { unsigned short h; uint32 l; char s[MAXstring]; + char *buf; unsigned char hs[2]; /* 2 bytes of a fixed-endian "short" */ unsigned char hl[4]; /* 4 bytes of a fixed-endian "long" */ } value; /* either number or string */ @@ -146,8 +148,8 @@ extern void mdump __P((struct magic *)); extern void process __P((const char *, int)); extern void showstr __P((FILE *, const char *, int)); extern int softmagic __P((unsigned char *, int)); -extern int tryit __P((unsigned char *, int, int)); -extern int zmagic __P((unsigned char *, int)); +extern int tryit __P((const char *, unsigned char *, int, int)); +extern int zmagic __P((const char *, unsigned char *, int)); extern void ckfprintf __P((FILE *, const char *, ...)); extern uint32 signextend __P((struct magic *, unsigned int32)); extern void tryelf __P((int, unsigned char *, int)); diff --git a/src/is_tar.c b/src/is_tar.c index 6c5b61ce..d6651fb3 100644 --- a/src/is_tar.c +++ b/src/is_tar.c @@ -5,12 +5,15 @@ * Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu). * * @(#)list.c 1.18 9/23/86 Public Domain - gnu - * $Id: is_tar.c,v 1.13 2000/08/05 17:36:48 christos Exp $ + * $Id: is_tar.c,v 1.14 2002/05/16 18:45:56 christos Exp $ * * Comments changed and some code/comments reformatted * for file command by Ian Darwin. */ +#ifdef HAVE_CONFIG_H +#include +#endif #include #include #include @@ -18,7 +21,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$Id: is_tar.c,v 1.13 2000/08/05 17:36:48 christos Exp $") +FILE_RCSID("@(#)$Id: is_tar.c,v 1.14 2002/05/16 18:45:56 christos Exp $") #endif #define isodigit(c) ( ((c) >= '0') && ((c) <= '7') ) diff --git a/src/patchlevel.h b/src/patchlevel.h index f1e24644..d38ad4a5 100644 --- a/src/patchlevel.h +++ b/src/patchlevel.h @@ -1,11 +1,19 @@ #define FILE_VERSION_MAJOR 3 -#define patchlevel 37 +#define patchlevel 38 /* * Patchlevel file for Ian Darwin's MAGIC command. - * $Id: patchlevel.h,v 1.37 2001/09/03 14:44:22 christos Exp $ + * $Id: patchlevel.h,v 1.38 2002/05/16 18:45:56 christos Exp $ * * $Log: patchlevel.h,v $ + * Revision 1.38 2002/05/16 18:45:56 christos + * - pt_note elf additions from NetBSD + * - EMX os specific changes (Alexander Mai) + * - stdint.h detection, acconfig.h fixes (Maciej W. Rozycki, Franz Korntner) + * - regex file additions (Kim Cromie) + * - getopt_long support and misc cleanups (Michael Piefel) + * - many magic fixes and additions + * * Revision 1.37 2001/09/03 14:44:22 christos * daylight/tm_isdst detection * magic fixes diff --git a/src/print.c b/src/print.c index b6803994..3c0c99a7 100644 --- a/src/print.c +++ b/src/print.c @@ -41,7 +41,7 @@ #include #ifndef lint -FILE_RCSID("@(#)$Id: print.c,v 1.34 2001/08/07 16:01:26 christos Exp $") +FILE_RCSID("@(#)$Id: print.c,v 1.35 2002/05/16 18:45:56 christos Exp $") #endif /* lint */ #define SZOF(a) (sizeof(a) / sizeof(a[0])) @@ -54,7 +54,7 @@ mdump(m) "long", "string", "date", "beshort", "belong", "bedate", "leshort", "lelong", "ledate", "pstring", "ldate", "beldate", - "leldate" }; + "leldate", "regex" }; static const char optyp[] = { '@', '&', '|', '^', '+', '-', '*', '/', '%' }; (void) fputc('[', stderr); @@ -110,6 +110,7 @@ mdump(m) break; case STRING: case PSTRING: + case REGEX: showstr(stderr, m->value.s, -1); break; case DATE: diff --git a/src/readelf.h b/src/readelf.h index 21d64362..c0d3ba29 100644 --- a/src/readelf.h +++ b/src/readelf.h @@ -1,6 +1,6 @@ /* * readelf.h - * @(#)$Id: readelf.h,v 1.8 2002/05/16 15:01:41 christos Exp $ + * @(#)$Id: readelf.h,v 1.9 2002/05/16 18:45:56 christos Exp $ * * Provide elf data structures for non-elf machines, allowing file * non-elf hosts to determine if an elf binary is stripped. @@ -9,6 +9,10 @@ #ifndef __fake_elf_h__ #define __fake_elf_h__ +#if HAVE_STDINT_H +#include +#endif + typedef uint32_t Elf32_Addr; typedef uint32_t Elf32_Off; typedef uint16_t Elf32_Half; diff --git a/src/softmagic.c b/src/softmagic.c index 904360e2..dd3d9835 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -31,11 +31,12 @@ #include #include #include +#include #include "file.h" #ifndef lint -FILE_RCSID("@(#)$Id: softmagic.c,v 1.47 2002/05/16 15:01:41 christos Exp $") +FILE_RCSID("@(#)$Id: softmagic.c,v 1.48 2002/05/16 18:45:56 christos Exp $") #endif /* lint */ static int match __P((struct magic *, uint32, unsigned char *, int)); @@ -271,6 +272,10 @@ mprint(p, m) (void) printf(m->desc, fmttime(p->l, 0)); t = m->offset + sizeof(time_t); break; + case REGEX: + (void) printf(m->desc, p->s); + t = m->offset + strlen(p->s); + break; default: error("invalid m->type (%d) in mprint().\n", m->type); @@ -544,6 +549,8 @@ mconvert(p, m) if (m->mask_op & OPINVERSE) p->l = ~p->l; return 1; + case REGEX: + return 1; default: error("invalid type %d in mconvert().\n", m->type); return 0; @@ -572,7 +579,18 @@ mget(p, s, m, nbytes) { int32 offset = m->offset; - if (offset + sizeof(union VALUETYPE) <= nbytes) + if (m->type == REGEX) { + /* + * offset is interpreted as last line to search, + * (starting at 1), not as bytes-from start-of-file + */ + char *last = NULL; + p->buf = s; + for (; offset && (s = strchr(s, '\n')) != NULL; offset--, s++) + last = s; + if (last != NULL) + *last = '\0'; + } else if (offset + sizeof(union VALUETYPE) <= nbytes) memcpy(p, s + offset, sizeof(union VALUETYPE)); else { /* @@ -585,14 +603,12 @@ mget(p, s, m, nbytes) memcpy(p, s + offset, have); } - if (debug) { mdebug(offset, (char *) p, sizeof(union VALUETYPE)); mdump(m); } if (m->flag & INDIR) { - switch (m->in_type) { case BYTE: if (m->in_offset) @@ -971,7 +987,7 @@ mcheck(p, m) case STRING: case PSTRING: - { + { /* * What we want here is: * v = strncmp(m->value.s, p->s, m->vallen); @@ -1016,6 +1032,21 @@ mcheck(p, m) } break; } + case REGEX: + { + int rc; + regex_t rx; + char errmsg[512]; + + rc = regcomp(&rx, m->value.s, REG_EXTENDED|REG_NOSUB); + if (rc) { + regerror(rc, &rx, errmsg, sizeof(errmsg)); + error("regex error %d, (%s)\n", rc, errmsg); + } else { + rc = regexec(&rx, p->buf, 0, 0, 0); + return !rc; + } + } default: error("invalid type %d in mcheck().\n", m->type); return 0;/*NOTREACHED*/ -- 2.40.0