aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--COPYING (renamed from LEGAL.NOTICE)2
-rw-r--r--ChangeLog273
-rw-r--r--INSTALL234
-rw-r--r--MAINT5
-rw-r--r--Magdir/adventure10
-rw-r--r--Magdir/animation397
-rw-r--r--Magdir/apple31
-rw-r--r--Magdir/archive71
-rw-r--r--Magdir/audio92
-rw-r--r--Magdir/c-lang13
-rw-r--r--Magdir/c641
-rw-r--r--Magdir/cafebabe20
-rw-r--r--Magdir/cddb3
-rw-r--r--Magdir/clarion26
-rw-r--r--Magdir/commands42
-rw-r--r--Magdir/compress37
-rw-r--r--Magdir/console12
-rw-r--r--Magdir/cracklib2
-rw-r--r--Magdir/ctags3
-rw-r--r--Magdir/database26
-rw-r--r--Magdir/diff16
-rw-r--r--Magdir/dump38
-rw-r--r--Magdir/elf77
-rw-r--r--Magdir/erlang18
-rw-r--r--Magdir/filesystems136
-rw-r--r--Magdir/flash3
-rw-r--r--Magdir/fonts9
-rw-r--r--Magdir/fortran1
-rw-r--r--Magdir/frame14
-rw-r--r--Magdir/freebsd4
-rw-r--r--Magdir/fsav10
-rw-r--r--Magdir/games110
-rw-r--r--Magdir/gimp4
-rw-r--r--Magdir/gnome-keyring23
-rw-r--r--Magdir/gnu8
-rw-r--r--Magdir/gnumeric7
-rw-r--r--Magdir/graphviz7
-rw-r--r--Magdir/hp104
-rw-r--r--Magdir/iff3
-rw-r--r--Magdir/images151
-rw-r--r--Magdir/inform8
-rw-r--r--Magdir/java3
-rw-r--r--Magdir/jpeg9
-rw-r--r--Magdir/kde10
-rw-r--r--Magdir/lex9
-rw-r--r--Magdir/linux34
-rw-r--r--Magdir/lisp36
-rw-r--r--Magdir/llvm10
-rw-r--r--Magdir/lua19
-rw-r--r--Magdir/luks12
-rw-r--r--Magdir/macintosh132
-rw-r--r--Magdir/mail.news14
-rw-r--r--Magdir/mathcad7
-rw-r--r--Magdir/mathematica4
-rw-r--r--Magdir/mercurial12
-rw-r--r--Magdir/misctools14
-rw-r--r--Magdir/mozilla8
-rw-r--r--Magdir/msdos335
-rw-r--r--Magdir/mup2
-rw-r--r--Magdir/netware6
-rw-r--r--Magdir/ole2compounddocs13
-rw-r--r--Magdir/os25
-rw-r--r--Magdir/palm2
-rw-r--r--Magdir/pdf3
-rw-r--r--Magdir/perl48
-rw-r--r--Magdir/pgp23
-rw-r--r--Magdir/pkgadd1
-rw-r--r--Magdir/printer33
-rw-r--r--Magdir/psion2
-rw-r--r--Magdir/revision10
-rw-r--r--Magdir/riff6
-rw-r--r--Magdir/rpm3
-rw-r--r--Magdir/rtf13
-rw-r--r--Magdir/ruby10
-rw-r--r--Magdir/sc1
-rw-r--r--Magdir/scientific13
-rw-r--r--Magdir/securitycerts3
-rw-r--r--Magdir/sgi18
-rw-r--r--Magdir/sgml60
-rw-r--r--Magdir/sharc8
-rw-r--r--Magdir/sketch3
-rw-r--r--Magdir/softquad10
-rw-r--r--Magdir/spectrum11
-rw-r--r--Magdir/tex60
-rw-r--r--Magdir/troff38
-rw-r--r--Magdir/unicode7
-rw-r--r--Magdir/uuencode15
-rw-r--r--Magdir/varied.script6
-rw-r--r--Magdir/vorbis28
-rw-r--r--Magdir/warc6
-rw-r--r--Magdir/weak15
-rw-r--r--Magdir/windows115
-rw-r--r--Magdir/wordprocessors30
-rw-r--r--Magdir/xilinx34
-rw-r--r--Makefile.am435
-rw-r--r--Makefile.in451
-rw-r--r--Makefile.std167
-rw-r--r--NEWS1
-rw-r--r--PORTING0
-rw-r--r--README38
-rw-r--r--TODO9
-rw-r--r--acinclude.m4240
-rw-r--r--aclocal.m463
-rw-r--r--apprentice.c620
-rw-r--r--ascmagic.c198
-rw-r--r--asprintf.c (renamed from test.c)42
-rwxr-xr-xcompile142
-rw-r--r--compress.c11
-rwxr-xr-xconfig.guess1504
-rw-r--r--config.h.in114
-rwxr-xr-xconfig.sub1622
-rwxr-xr-xconfigure1754
-rw-r--r--configure.ac151
-rw-r--r--configure.in139
-rw-r--r--elfclass.h69
-rw-r--r--file.c93
-rw-r--r--file.h152
-rw-r--r--file.man155
-rw-r--r--fsmagic.c165
-rw-r--r--funcs.c151
-rw-r--r--getopt_long.c496
-rw-r--r--is_tar.c7
-rw-r--r--libmagic.man13
-rw-r--r--magic.c70
-rw-r--r--magic.h5
-rw-r--r--magic.man199
-rw-r--r--magic.mime991
-rwxr-xr-xmagic2mime69
-rw-r--r--mkinstalldirs161
-rw-r--r--mygetopt.h68
-rw-r--r--names.h29
-rw-r--r--patchlevel.h13
-rw-r--r--print.c14
-rw-r--r--readelf.c518
-rw-r--r--readelf.h81
-rw-r--r--softmagic.c191
-rw-r--r--tar.h64
-rw-r--r--tests/Makefile.am11
-rw-r--r--tests/Makefile.in455
-rw-r--r--tests/README17
-rw-r--r--tests/gedcom.magic6
-rw-r--r--tests/gedcom.result1
-rw-r--r--tests/gedcom.testfile8
-rw-r--r--tests/test.c114
-rw-r--r--vasprintf.c641
146 files changed, 11234 insertions, 4875 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 000000000000..3d3d34a0af6a
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+See COPYING. \ No newline at end of file
diff --git a/LEGAL.NOTICE b/COPYING
index 68148e2ffda6..b3db8b23fbf3 100644
--- a/LEGAL.NOTICE
+++ b/COPYING
@@ -1,4 +1,4 @@
-$File: LEGAL.NOTICE,v 1.15 2006/05/03 18:48:33 christos Exp $
+$File: COPYING,v 1.1 2008/02/05 19:08:11 christos Exp $
Copyright (c) Ian F. Darwin 1986, 1987, 1989, 1990, 1991, 1992, 1994, 1995.
Software written by Ian F. Darwin and others;
maintained 1994- Christos Zoulas.
diff --git a/ChangeLog b/ChangeLog
index 2beffb0cfd77..2c62a725d1b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,135 @@
-2007-12-28 15:06 Christos Zoulas <christos@zoulas.com>
+2008-08-30 12:54 Christos Zoulas <christos@astron.com>
+
+ * Don't eat trailing \n in magic enties.
+
+ * Cast defines to allow compilation using a c++ compiler.
+
+2008-07-26 00:59 Reuben Thomas <rrt@sc3d.org>
+
+ * Add MIME types for special files.
+
+ * Use access to give more accurate information for files that
+ can't be opened.
+
+ * Add a TODO list.
+
+2008-07-02 11:15 Christos Zoulas <christos@astron.com>
+
+ * add !:strength op to adjust magic strength (experimental)
+
+2008-06-16 21:41 Reuben Thomas <rrt@sc3d.org>
+
+ * Fix automake error in configure.ac.
+
+ * Add MIME type for Psion Sketch files.
+
+2008-06-05 08:59 Christos Zoulas <christos@astron.com>
+
+ * Don't print warnings about bad namesize in stripped
+ binaries with PT_NOTE is still there, and the actual
+ note is gone (Jakub Jelinek)
+
+2008-05-28 15:12 Robert Byrnes <byrnes@wildpumpkin.net>
+
+ * magic/Magdir/elf:
+ Note invalid byte order for little-endian SPARC32PLUS.
+ Add SPARC V9 vendor extensions and memory model.
+
+ * src/elfclass.h:
+ Pass target machine to doshn (for Solaris hardware capabilities).
+
+ * src/readelf.c (doshn):
+ Add support for Solaris hardware/software capabilities.
+
+ * src/readelf.h:
+ Ditto.
+
+ * src/vasprintf.c (dispatch):
+ Add support for ll modifier.
+
+2008-05-16 10:25 Christos Zoulas <christos@astron.com>
+
+ * Fix compiler warnings.
+
+ * remove stray printf, and fix a vprintf bug. (Martin Dorey)
+
+2008-05-06 00:13 Robert Byrnes <byrnes@wildpumpkin.net>
+
+ * src/Makefile.am:
+ Ensure that getopt_long and [v]asprintf are included in libmagic,
+ as needed.
+
+ Remove unnecessary EXTRA_DIST.
+
+ * src/Makefile.in:
+ Rerun automake.
+
+ * src/vasprintf.c (dispatch):
+ Fix variable precision bug: be sure to step past '*'.
+
+ * src/vasprintf.c (core):
+ Remove unreachable code.
+
+ * src/apprentice.c (set_test_type):
+ Add cast to avoid compiler warning.
+
+2008-04-22 23:45 Christos Zoulas <christos@astron.com>
+
+ * Add magic submission guidelines (Abel Cheung)
+
+ * split msdos and windows magic (Abel Cheung)
+
+2008-04-04 11:00 Christos Zoulas <christos@astron.com>
+
+ * >= <= is not supported, so fix the magic and warn about it.
+ reported by: Thien-Thi Nguyen <ttn@gnuvola.org>
+
+2008-03-27 16:16 Robert Byrnes <byrnes@wildpumpkin.net>
+
+ * src/readelf.c (donote):
+ ELF core file command name/line bug fixes and enhancements:
+
+ Try larger offsets first to avoid false matches
+ from earlier data that happen to look like strings;
+ this primarily affected SunOS 5.x 32-bit Intel core files.
+
+ Add support for command line (instead of just short name)
+ for SunOS 5.x.
+
+ Add information about NT_PSINFO for SunOS 5.x.
+
+ Only trim whitespace from end of command line.
+
+2007-02-11 01:36 Reuben Thomas <rrt@sc3d.org>
+
+ * Change strength of ! from MULT to 0, as it matches almost
+ anything (Reuben Thomas)
+
+ * Debian fixes (Reuben Thomas)
+
+2007-02-11 00:17 Reuben Thomas <rrt@sc3d.org>
+
+ * Clarify UTF-8 BOM message (Reuben Thomas)
+
+ * Add HTML comment to token list in names.h
+
+2007-02-04 15:50 Christos Zoulas <christos@astron.com>
+
+ * Debian fixes (Reuben Thomas)
+
+2007-02-04 11:31 Christos Zoulas <christos@astron.com>
+
+ * !:mime annotations in magic files (Reuben Thomas)
+
+2007-01-29 15:35 Christos Zoulas <christos@astron.com>
+
+ * zero out utime/utimes structs (Gavin Atkinson)
+
+2007-01-26 13:45 Christos Zoulas <christos@astron.com>
+
+ * reduce writable data from Diego "Flameeyes" Petten
+
+2007-12-28 15:06 Christos Zoulas <christos@astron.com>
* strtof detection
@@ -6,7 +137,7 @@
* better mismatch version message
-2007-12-27 11:35 Christos Zoulas <christos@zoulas.com>
+2007-12-27 11:35 Christos Zoulas <christos@astron.com>
* bring back some fixes from OpenBSD
@@ -14,46 +145,46 @@
* fix gcc warnings
-2007-12-01 19:55 Christos Zoulas <christos@zoulas.com>
+2007-12-01 19:55 Christos Zoulas <christos@astron.com>
* make sure we have zlib.h and libz to compile the builtin
decompress code
-2007-10-28 20:48 Christos Zoulas <christos@zoulas.com>
+2007-10-28 20:48 Christos Zoulas <christos@astron.com>
* float and double magic support (Behan Webster)
-2007-10-28 20:48 Christos Zoulas <christos@zoulas.com>
+2007-10-28 20:48 Christos Zoulas <christos@astron.com>
* Convert fortran to a soft test (Reuben Thomas)
-2007-10-23 5:25 Christos Zoulas <christos@zoulas.com>
+2007-10-23 5:25 Christos Zoulas <christos@astron.com>
* Add --with-filename, and --no-filename (Reuben Thomas)
-2007-10-23 3:59 Christos Zoulas <christos@zoulas.com>
+2007-10-23 3:59 Christos Zoulas <christos@astron.com>
* Rest of the mime split (Reuben Thomas)
* Make usage message generated from the flags so that
they stay consistent (Reuben Thomas)
-2007-10-20 3:06 Christos Zoulas <christos@zoulas.com>
+2007-10-20 3:06 Christos Zoulas <christos@astron.com>
* typo in comment, missing ifdef QUICK, remove unneeded code
(Charles Longeau)
-2007-10-17 3:33 Christos Zoulas <christos@zoulas.com>
+2007-10-17 3:33 Christos Zoulas <christos@astron.com>
* Fix problem printing -\012 in some entries
* Separate magic type and encoding flags (Reuben Thomas)
-2007-10-09 3:55 Christos Zoulas <christos@zoulas.com>
+2007-10-09 3:55 Christos Zoulas <christos@astron.com>
* configure fix for int64 and strndup (Reuben Thomas)
-2007-09-26 4:45 Christos Zoulas <christos@zoulas.com>
+2007-09-26 4:45 Christos Zoulas <christos@astron.com>
* Add magic_descriptor() function.
@@ -62,7 +193,7 @@
* Don't convert NUL's to spaces in {l,b}estring16 (Daniel Dawson)
-2007-08-19 6:30 Christos Zoulas <christos@zoulas.com>
+2007-08-19 6:30 Christos Zoulas <christos@astron.com>
* Make mime format consistent so that it can
be easily parsed:
@@ -79,38 +210,38 @@
This work was done by Reuben Thomas
-2007-05-24 10:00 Christos Zoulas <christos@zoulas.com>
+2007-05-24 10:00 Christos Zoulas <christos@astron.com>
* Fix another integer overflow (Colin Percival)
-2007-03-26 13:58 Christos Zoulas <christos@zoulas.com>
+2007-03-26 13:58 Christos Zoulas <christos@astron.com>
* make sure that all of struct magic_set is initialized appropriately
(Brett)
-2007-03-25 17:44 Christos Zoulas <christos@zoulas.com>
+2007-03-25 17:44 Christos Zoulas <christos@astron.com>
* reset left bytes in the buffer (Dmitry V. Levin)
* compilation failed with COMPILE_ONLY and ENABLE_CONDITIONALS
(Peter Avalos)
-2007-03-15 10:51 Christos Zoulas <christos@zoulas.com>
+2007-03-15 10:51 Christos Zoulas <christos@astron.com>
* fix fortran and nroff reversed tests (Dmitry V. Levin)
* fix exclude option (Dmitry V. Levin)
-2007-02-08 17:30 Christos Zoulas <christos@zoulas.com>
+2007-02-08 17:30 Christos Zoulas <christos@astron.com>
* fix integer underflow in file_printf which can lead to
to exploitable heap overflow (Jean-Sebastien Guay-Lero)
-2007-02-05 11:35 Christos Zoulas <christos@zoulas.com>
+2007-02-05 11:35 Christos Zoulas <christos@astron.com>
* make socket/pipe reading more robust
-2007-01-25 16:01 Christos Zoulas <christos@zoulas.com>
+2007-01-25 16:01 Christos Zoulas <christos@astron.com>
* Centralize all the tests in file_buffer.
@@ -184,7 +315,7 @@
* make file.c compile with gcc warnings and pass lint
-2006-12-11 16:49 Christos Zoulas <christos@zoulas.com>
+2006-12-11 16:49 Christos Zoulas <christos@astron.com>
* fix byteswapping issue
@@ -193,7 +324,7 @@
* add a few missed cases in the strength routine
-2006-12-08 16:32 Christos Zoulas <christos@zoulas.com>
+2006-12-08 16:32 Christos Zoulas <christos@astron.com>
* store and print the line number of the magic
entry for debugging.
@@ -210,7 +341,7 @@
* propagate the error return from match to
file_softmagic.
-2006-11-25 13:35 Christos Zoulas <christos@zoulas.com>
+2006-11-25 13:35 Christos Zoulas <christos@astron.com>
* Don't store the current offset in the magic
struct, because it needs to be restored and
@@ -221,12 +352,12 @@
print it as an additional separator; print
it as the only separator.
-2006-11-17 10:51 Christos Zoulas <christos@zoulas.com>
+2006-11-17 10:51 Christos Zoulas <christos@astron.com>
* Added a -0 option to print a '\0' separator
Etienne Buira <etienne.buira@free.fr>
-2006-10-31 15:14 Christos Zoulas <christos@zoulas.com>
+2006-10-31 15:14 Christos Zoulas <christos@astron.com>
* Check offset before copying (Mike Frysinger)
@@ -242,7 +373,7 @@
* use calloc to initialize the ascii buffers (Jos van den Oever)
-2006-06-08 11:11 Christos Zoulas <christos@zoulas.com>
+2006-06-08 11:11 Christos Zoulas <christos@astron.com>
* QNX fixes (Mike Gorchak)
@@ -256,7 +387,7 @@
* Magic format function improvent (Karl Chen)
-2006-05-03 11:11 Christos Zoulas <christos@zoulas.com>
+2006-05-03 11:11 Christos Zoulas <christos@astron.com>
* Pick up some elf changes and some constant fixes from SUSE
@@ -264,13 +395,13 @@
* When keep going, don't print spurious newlines (Radek Vokál)
-2006-04-01 12:02 Christos Zoulas <christos@zoulas.com>
+2006-04-01 12:02 Christos Zoulas <christos@astron.com>
* Use calloc instead of malloc (Mike Frysinger)
* Fix configure script to detect wctypes.h (Mike Frysinger)
-2006-03-02 16:06 Christos Zoulas <christos@zoulas.com>
+2006-03-02 16:06 Christos Zoulas <christos@astron.com>
* Print empty if the file is (Mike Frysinger)
@@ -278,21 +409,21 @@
* Sort magic entries by strength [experimental]
-2005-11-29 13:26 Christos Zoulas <christos@zoulas.com>
+2005-11-29 13:26 Christos Zoulas <christos@astron.com>
* Use iswprint() to convert the output string.
(Bastien Nocera)
-2005-10-31 8:54 Christos Zoulas <christos@zoulas.com>
+2005-10-31 8:54 Christos Zoulas <christos@astron.com>
* Fix regression where the core info was not completely processed
(Radek Vokál)
-2005-10-20 11:15 Christos Zoulas <christos@zoulas.com>
+2005-10-20 11:15 Christos Zoulas <christos@astron.com>
* Middle Endian magic (Diomidis Spinellis)
-2005-10-17 11:15 Christos Zoulas <christos@zoulas.com>
+2005-10-17 11:15 Christos Zoulas <christos@astron.com>
* Open with O_BINARY for CYGWIN (Corinna Vinschen)
@@ -300,39 +431,39 @@
* Look for note sections in non executables.
-2005-09-20 13:33 Christos Zoulas <christos@zoulas.com>
+2005-09-20 13:33 Christos Zoulas <christos@astron.com>
* Don't print SVR4 Style in core files multiple times
(Radek Vokál)
-2005-08-27 04:09 Christos Zoulas <christos@zoulas.com>
+2005-08-27 04:09 Christos Zoulas <christos@astron.com>
* Cygwin changes Corinna Vinschen
-2005-08-18 09:53 Christos Zoulas <christos@zoulas.com>
+2005-08-18 09:53 Christos Zoulas <christos@astron.com>
* Remove erroreous mention of /etc/magic in the file man page
This is gentoo bug 101639. (Mike Frysinger)
* Cross-compile support and detection (Mike Frysinger)
-2005-08-12 10:17 Christos Zoulas <christos@zoulas.com>
+2005-08-12 10:17 Christos Zoulas <christos@astron.com>
* Add -h flag and dereference symlinks if POSIXLY_CORRECT
is set.
-2005-07-29 13:57 Christos Zoulas <christos@zoulas.com>
+2005-07-29 13:57 Christos Zoulas <christos@astron.com>
* Avoid search and regex buffer overflows (Kelledin)
-2005-07-12 11:48 Christos Zoulas <christos@zoulas.com>
+2005-07-12 11:48 Christos Zoulas <christos@astron.com>
* Provide stub implementations for {v,}nsprintf() for older
OS's that don't have them.
* Change mbstate_t autoconf detection macro from AC_MBSTATE_T
to AC_TYPE_MBSTATE_T.
-2005-06-25 11:48 Christos Zoulas <christos@zoulas.com>
+2005-06-25 11:48 Christos Zoulas <christos@astron.com>
* Dynamically allocate the string buffers and make the
default read size 256K.
@@ -361,43 +492,43 @@
With CRLF, the line length was not computed correctly, and even
lines of length MAXLINELEN - 1 were treated as ``very long''.
-2004-12-07 14:15 Christos Zoulas <christos@zoulas.com>
+2004-12-07 14:15 Christos Zoulas <christos@astron.com>
* bzip2 needs a lot of input buffer space on some files
before it can begin uncompressing. This makes file -z
fail on some bz2 files. Fix it by giving it a copy of
the file descriptor to read as much as it wants if we
- have access to it. <christos@zoulas.com>
+ have access to it. <christos@astron.com>
-2004-11-24 12:39 Christos Zoulas <christos@zoulas.com>
+2004-11-24 12:39 Christos Zoulas <christos@astron.com>
* Stack smash fix, and ELF more conservative reading.
Jakub Bogusz <qboosh@pld-linux.org>
-2004-11-20 18:50 Christos Zoulas <christos@zoulas.com>
+2004-11-20 18:50 Christos Zoulas <christos@astron.com>
* New FreeBSD version parsing code:
Jon Noack <noackjr@alumni.rice.edu>
- * Hackish support for ucs16 strings <christos@zoulas.com>
+ * Hackish support for ucs16 strings <christos@astron.com>
-2004-11-13 03:07 Christos Zoulas <christos@zoulas.com>
+2004-11-13 03:07 Christos Zoulas <christos@astron.com>
* print the file name and line number in syntax errors.
-2004 10-12 10:50 Christos Zoulas <christos@zoulas.com>
+2004 10-12 10:50 Christos Zoulas <christos@astron.com>
* Fix stack overwriting on 0 length strings: Tim Waugh
<twaugh@redhat.com> Ned Ludd <solar@gentoo.org>
-2004-09-27 11:30 Christos Zoulas <christos@zoulas.com>
+2004-09-27 11:30 Christos Zoulas <christos@astron.com>
* Remove 3rd and 4th copyright clause; approved by Ian Darwin.
* Fix small memory leaks; caught by: Tamas Sarlos
<stamas@csillag.ilab.sztaki.hu>
-2004-07-24 16:33 Christos Zoulas <christos@zoulas.com>
+2004-07-24 16:33 Christos Zoulas <christos@astron.com>
* magic.mime update Danny Milosavljevic <danny.milo@gmx.net>
@@ -407,19 +538,19 @@
* errors reading elf magic Jakub Bogusz <qboosh@pld-linux.org>
-2004-04-12 10:55 Christos Zoulas <christos@zoulas.com>
+2004-04-12 10:55 Christos Zoulas <christos@astron.com>
* make sure that magic formats match magic types during compilation
* fix broken sgi magic file
-2004-04-06 20:36 Christos Zoulas <christos@zoulas.com>
+2004-04-06 20:36 Christos Zoulas <christos@astron.com>
* detect present of mbstate_t Petter Reinholdtsen <pere@hungry.com>
* magic fixes
-2004-03-22 15:25 Christos Zoulas <christos@zoulas.com>
+2004-03-22 15:25 Christos Zoulas <christos@astron.com>
* Lots of mime fixes
(Joerg Ostertag) <ostertag@rechengilde.de>
@@ -428,7 +559,7 @@
(Edwin Groothuis) <edwin@mavetju.org>
* correct cleanup in all cases; don't just close the file.
- (Christos Zoulas) <christos@zoulas.com>
+ (Christos Zoulas) <christos@astron.com>
* add gettext message catalogue support
(Michael Piefel) <piefel@debian.org>
@@ -446,37 +577,37 @@
or name and description note sizes. Reported by
(Mikael Magnusson) <mmikael@comhem.se>
-2004-03-09 13:55 Christos Zoulas <christos@zoulas.com>
+2004-03-09 13:55 Christos Zoulas <christos@astron.com>
* Fix possible memory leak on error and add missing regfree
(Dmitry V. Levin) <ldv@altlinux.org>
-2003-12-23 12:12 Christos Zoulas <christos@zoulas.com>
+2003-12-23 12:12 Christos Zoulas <christos@astron.com>
* fix -k flag (Maciej W. Rozycki)
-2003-11-18 14:10 Christos Zoulas <christos@zoulas.com>
+2003-11-18 14:10 Christos Zoulas <christos@astron.com>
* Try to give us much info as possible on corrupt elf files.
(Willy Tarreau) <willy@w.ods.org>
* Updated python bindings (Brett Funderburg)
<brettf@deepfile.com>
-2003-11-11 15:03 Christos Zoulas <christos@zoulas.com>
+2003-11-11 15:03 Christos Zoulas <christos@astron.com>
* Include file.h first, because it includes config.h
breaks largefile test macros otherwise.
(Paul Eggert <eggert@CS.UCLA.EDU> via
Lars Hecking <lhecking@nmrc.ie>)
-2003-10-14 21:39 Christos Zoulas <christos@zoulas.com>
+2003-10-14 21:39 Christos Zoulas <christos@astron.com>
* Python bindings (Brett Funderburg) <brettf@deepfile.com>
* Don't lookup past the end of the buffer
(Chad Hanson) <chanson@tcs-sec.com>
* Add MAGIC_ERROR and api on magic_errno()
-2003-10-08 12:40 Christos Zoulas <christos@zoulas.com>
+2003-10-08 12:40 Christos Zoulas <christos@astron.com>
* handle error conditions from compile as fatal
(Antti Kantee) <pooka@netbsd.org>
@@ -486,32 +617,32 @@
* describe magic file handling
(Bryan Henderson) <bryanh@giraffe-data.com>
-2003-09-12 15:09 Christos Zoulas <christos@zoulas.com>
+2003-09-12 15:09 Christos Zoulas <christos@astron.com>
* update magic files.
* remove largefile support from file.h; it breaks things on most OS's
-2003-08-10 10:25 Christos Zoulas <christos@zoulas.com>
+2003-08-10 10:25 Christos Zoulas <christos@astron.com>
* fix unmapping'ing of mmaped files.
-2003-07-10 12:03 Christos Zoulas <christos@zoulas.com>
+2003-07-10 12:03 Christos Zoulas <christos@astron.com>
* don't exit with -1 on error; always exit 1 (Marty Leisner)
* restore utimes code.
-2003-06-10 17:03 Christos Zoulas <christos@zoulas.com>
+2003-06-10 17:03 Christos Zoulas <christos@astron.com>
* make sure we don't access uninitialized memory.
* pass lint
* #ifdef __cplusplus in magic.h
-2003-05-25 19:23 Christos Zoulas <christos@zoulas.com>
+2003-05-25 19:23 Christos Zoulas <christos@astron.com>
* rename cvs magic file to revision to deal with
case insensitive filesystems.
-2003-05-23 17:03 Christos Zoulas <christos@zoulas.com>
+2003-05-23 17:03 Christos Zoulas <christos@astron.com>
* documentation fixes from Michael Piefel <piefel@debian.org>
* magic fixes (various)
@@ -521,30 +652,30 @@
close files
Maciej W. Rozycki <macro@ds2.pg.gda.pl
-2003-04-21 20:12 Christos Zoulas <christos@zoulas.com>
+2003-04-21 20:12 Christos Zoulas <christos@astron.com>
* fix zsh magic
-2003-04-04 16:59 Christos Zoulas <christos@zoulas.com>
+2003-04-04 16:59 Christos Zoulas <christos@astron.com>
* fix operand sort order in string.
-2003-04-02 17:30 Christos Zoulas <christos@zoulas.com>
+2003-04-02 17:30 Christos Zoulas <christos@astron.com>
* cleanup namespace in magic.h
-2003-04-02 13:50 Christos Zoulas <christos@zoulas.com>
+2003-04-02 13:50 Christos Zoulas <christos@astron.com>
* Magic additions (Alex Ott)
* Fix bug that broke VPATH compilation (Peter Breitenlohner)
-2003-03-28 16:03 Christos Zoulas <christos@zoulas.com>
+2003-03-28 16:03 Christos Zoulas <christos@astron.com>
* remove packed attribute from magic struct.
* make the magic struct properly aligned.
* bump version number of compiled files to 2.
-2003-03-27 13:10 Christos Zoulas <christos@zoulas.com>
+2003-03-27 13:10 Christos Zoulas <christos@astron.com>
* separate tar detection and run it before softmagic.
* fix reversed symlink test.
@@ -552,7 +683,7 @@
* make separator a string instead of a char.
* update manual page and sort options.
-2003-03-26 11:00 Christos Zoulas <christos@zoulas.com>
+2003-03-26 11:00 Christos Zoulas <christos@astron.com>
* Pass lint
* make NULL in magic_file mean stdin
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 000000000000..5458714e1e2c
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,234 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about. Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you can use GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+ Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
diff --git a/MAINT b/MAINT
index 077f9d67dfb4..b881615c3c15 100644
--- a/MAINT
+++ b/MAINT
@@ -1,4 +1,4 @@
-$File: MAINT,v 1.9 2007/01/19 21:15:27 christos Exp $
+$File: MAINT,v 1.10 2008/02/05 19:08:11 christos Exp $
Maintenance notes:
@@ -41,5 +41,4 @@ ascmagic.c file_ascmagic()
readelf.c file_tryelf()
"unknown"
-Christos Zoulas
-christos@astron.com
+Christos Zoulas (see README for email address)
diff --git a/Magdir/adventure b/Magdir/adventure
index 405d3cc41ed7..7b30c496144e 100644
--- a/Magdir/adventure
+++ b/Magdir/adventure
@@ -73,3 +73,13 @@
>10 belong 0x0A0D1A00
>>14 string >\0 %s saved game data
+# Danny Milosavljevic <danny.milo@gmx.net>
+# this are adrift (adventure game standard) game files, extension .taf
+# depending on version magic continues with 0x93453E6139FA (V 4.0)
+# 0x9445376139FA (V 3.90)
+# 0x9445366139FA (V 3.80)
+# this is from source (http://www.adrift.org.uk/) and I have some taf
+# files, and checked them.
+#0 belong 0x3C423FC9
+#>4 belong 0x6A87C2CF Adrift game file
+#!:mime application/x-adrift
diff --git a/Magdir/animation b/Magdir/animation
index 6392f850887e..443338a6c482 100644
--- a/Magdir/animation
+++ b/Magdir/animation
@@ -8,57 +8,78 @@
# SGI and Apple formats
0 string MOVI Silicon Graphics movie file
+!:mime video/x-sgi-movie
4 string moov Apple QuickTime
+!:mime video/quicktime
>12 string mvhd \b movie (fast start)
>12 string mdra \b URL
>12 string cmov \b movie (fast start, compressed header)
>12 string rmra \b multiple URLs
4 string mdat Apple QuickTime movie (unoptimized)
-4 string wide Apple QuickTime movie (unoptimized)
-4 string skip Apple QuickTime movie (modified)
-4 string free Apple QuickTime movie (modified)
+!:mime video/quicktime
+#4 string wide Apple QuickTime movie (unoptimized)
+#!:mime video/quicktime
+#4 string skip Apple QuickTime movie (modified)
+#!:mime video/quicktime
+#4 string free Apple QuickTime movie (modified)
+#!:mime video/quicktime
4 string idsc Apple QuickTime image (fast start)
-4 string idat Apple QuickTime image (unoptimized)
+!:mime image/x-quicktime
+#4 string idat Apple QuickTime image (unoptimized)
+#!:mime image/x-quicktime
4 string pckg Apple QuickTime compressed archive
+!:mime application/x-quicktime-player
4 string/B jP JPEG 2000 image
+!:mime image/jp2
4 string ftyp ISO Media
>8 string isom \b, MPEG v4 system, version 1
+!:mime video/mp4
>8 string iso2 \b, MPEG v4 system, part 12 revision
>8 string mp41 \b, MPEG v4 system, version 1
+!:mime video/mp4
>8 string mp42 \b, MPEG v4 system, version 2
+!:mime video/mp4
>8 string mp7t \b, MPEG v4 system, MPEG v7 XML
>8 string mp7b \b, MPEG v4 system, MPEG v7 binary XML
>8 string/B jp2 \b, JPEG 2000
+!:mime image/jp2
>8 string 3gp \b, MPEG v4 system, 3GPP
+!:mime video/3gpp
>>11 byte 4 \b v4 (H.263/AMR GSM 6.10)
>>11 byte 5 \b v5 (H.263/AMR GSM 6.10)
>>11 byte 6 \b v6 (ITU H.264/AMR GSM 6.10)
>8 string mmp4 \b, MPEG v4 system, 3GPP Mobile
+!:mime video/mp4
>8 string avc1 \b, MPEG v4 system, 3GPP JVT AVC
+!:mime video/3gpp
>8 string/B M4A \b, MPEG v4 system, iTunes AAC-LC
+!:mime audio/mp4
+>8 string/B M4V \b, MPEG v4 system, iTunes AVC-LC
+!:mime video/mp4
>8 string/B M4P \b, MPEG v4 system, iTunes AES encrypted
>8 string/B M4B \b, MPEG v4 system, iTunes bookmarked
>8 string/B qt \b, Apple QuickTime movie
+!:mime video/quicktime
# MPEG sequences
# Scans for all common MPEG header start codes
-0 belong 0x00000001 JVT NAL sequence
->4 byte&0x1F 0x07 \b, H.264 video
+0 belong 0x00000001
+>4 byte&0x1F 0x07 JVT NAL sequence, H.264 video
>>5 byte 66 \b, baseline
>>5 byte 77 \b, main
>>5 byte 88 \b, extended
>>7 byte x \b @ L %u
-0 belong&0xFFFFFF00 0x00000100 MPEG sequence
->3 byte 0xBA
+0 belong&0xFFFFFF00 0x00000100
+>3 byte 0xBA MPEG sequence
>>4 byte &0x40 \b, v2, program multiplex
>>4 byte ^0x40 \b, v1, system multiplex
->3 byte 0xBB \b, v1/2, multiplex (missing pack header)
->3 byte&0x1F 0x07 \b, H.264 video
+>3 byte 0xBB MPEG sequence, v1/2, multiplex (missing pack header)
+>3 byte&0x1F 0x07 MPEG sequence, H.264 video
>>4 byte 66 \b, baseline
>>4 byte 77 \b, main
>>4 byte 88 \b, extended
>>6 byte x \b @ L %u
->3 byte 0xB0 \b, v4
+>3 byte 0xB0 MPEG sequence, v4
>>5 belong 0x000001B5
>>>9 byte &0x80
>>>>10 byte&0xF0 16 \b, video
@@ -127,7 +148,7 @@
>>4 byte 251 \b, FGS @ L3
>>4 byte 252 \b, FGS @ L4
>>4 byte 253 \b, FGS @ L5
->3 byte 0xB5 \b, v4
+>3 byte 0xB5 MPEG sequence, v4
>>4 byte &0x80
>>>5 byte&0xF0 16 \b, video (missing profile header)
>>>5 byte&0xF0 32 \b, still texture (missing profile header)
@@ -137,7 +158,7 @@
>>4 byte&0xF8 16 \b, still texture (missing profile header)
>>4 byte&0xF8 24 \b, mesh (missing profile header)
>>4 byte&0xF8 32 \b, face (missing profile header)
->3 byte 0xB3
+>3 byte 0xB3 MPEG sequence
>>12 belong 0x000001B8 \b, v1, progressive Y'CbCr 4:2:0 video
>>12 belong 0x000001B2 \b, v1, progressive Y'CbCr 4:2:0 video
>>12 belong 0x000001B5 \b, v2,
@@ -252,22 +273,39 @@
# modified to fully support MPEG ADTS
# MP3, M1A
-0 beshort&0xFFFE 0xFFFA MPEG ADTS, layer III, v1
+# 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
+0 beshort&0xFFFE 0xFFFA
# rates
->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
+>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
+!:mime audio/mpeg
# timing
>2 byte&0x0C 0x00 \b, 44.1 kHz
>2 byte&0x0C 0x04 \b, 48 kHz
@@ -288,20 +326,20 @@
# MP2, M1A
0 beshort&0xFFFE 0xFFFC MPEG ADTS, layer II, v1
# rates
->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
+>2 byte&0xF0 0x10 \b, 32 kbps
+>2 byte&0xF0 0x20 \b, 48 kbps
+>2 byte&0xF0 0x30 \b, 56 kbps
+>2 byte&0xF0 0x40 \b, 64 kbps
+>2 byte&0xF0 0x50 \b, 80 kbps
+>2 byte&0xF0 0x60 \b, 96 kbps
+>2 byte&0xF0 0x70 \b, 112 kbps
+>2 byte&0xF0 0x80 \b, 128 kbps
+>2 byte&0xF0 0x90 \b, 160 kbps
+>2 byte&0xF0 0xA0 \b, 192 kbps
+>2 byte&0xF0 0xB0 \b, 224 kbps
+>2 byte&0xF0 0xC0 \b, 256 kbps
+>2 byte&0xF0 0xD0 \b, 320 kbps
+>2 byte&0xF0 0xE0 \b, 384 kbps
# timing
>2 byte&0x0C 0x00 \b, 44.1 kHz
>2 byte&0x0C 0x04 \b, 48 kHz
@@ -322,58 +360,60 @@
# MPA, M1A
# updated by Joerg Jenderek
# GRR the original test are too common for many DOS files, so test 32 <= kbits <= 448
-0 beshort&0xFFFE 0xFFFE
->2 ubyte&0xF0 >0x0F
->>2 ubyte&0xF0 <0xE1 MPEG ADTS, layer I, v1
-# rate
->>>2 byte&0xF0 0x10 \b, 32 kBits
->>>2 byte&0xF0 0x20 \b, 64 kBits
->>>2 byte&0xF0 0x30 \b, 96 kBits
->>>2 byte&0xF0 0x40 \b, 128 kBits
->>>2 byte&0xF0 0x50 \b, 160 kBits
->>>2 byte&0xF0 0x60 \b, 192 kBits
->>>2 byte&0xF0 0x70 \b, 224 kBits
->>>2 byte&0xF0 0x80 \b, 256 kBits
->>>2 byte&0xF0 0x90 \b, 288 kBits
->>>2 byte&0xF0 0xA0 \b, 320 kBits
->>>2 byte&0xF0 0xB0 \b, 352 kBits
->>>2 byte&0xF0 0xC0 \b, 384 kBits
->>>2 byte&0xF0 0xD0 \b, 416 kBits
->>>2 byte&0xF0 0xE0 \b, 448 kBits
-# timing
->>>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
+# GRR this test is still too general as it catches a BOM of UTF-16 files (0xFFFE)
+# FIXME: Almost all little endian UTF-16 text with BOM are clobbered by these entries
+#0 beshort&0xFFFE 0xFFFE
+#>2 ubyte&0xF0 >0x0F
+#>>2 ubyte&0xF0 <0xE1 MPEG ADTS, layer I, v1
+## rate
+#>>>2 byte&0xF0 0x10 \b, 32 kbps
+#>>>2 byte&0xF0 0x20 \b, 64 kbps
+#>>>2 byte&0xF0 0x30 \b, 96 kbps
+#>>>2 byte&0xF0 0x40 \b, 128 kbps
+#>>>2 byte&0xF0 0x50 \b, 160 kbps
+#>>>2 byte&0xF0 0x60 \b, 192 kbps
+#>>>2 byte&0xF0 0x70 \b, 224 kbps
+#>>>2 byte&0xF0 0x80 \b, 256 kbps
+#>>>2 byte&0xF0 0x90 \b, 288 kbps
+#>>>2 byte&0xF0 0xA0 \b, 320 kbps
+#>>>2 byte&0xF0 0xB0 \b, 352 kbps
+#>>>2 byte&0xF0 0xC0 \b, 384 kbps
+#>>>2 byte&0xF0 0xD0 \b, 416 kbps
+#>>>2 byte&0xF0 0xE0 \b, 448 kbps
+## timing
+#>>>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
# MP3, M2A
0 beshort&0xFFFE 0xFFF2 MPEG ADTS, layer III, v2
# rate
->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
+>2 byte&0xF0 0x10 \b, 8 kbps
+>2 byte&0xF0 0x20 \b, 16 kbps
+>2 byte&0xF0 0x30 \b, 24 kbps
+>2 byte&0xF0 0x40 \b, 32 kbps
+>2 byte&0xF0 0x50 \b, 40 kbps
+>2 byte&0xF0 0x60 \b, 48 kbps
+>2 byte&0xF0 0x70 \b, 56 kbps
+>2 byte&0xF0 0x80 \b, 64 kbps
+>2 byte&0xF0 0x90 \b, 80 kbps
+>2 byte&0xF0 0xA0 \b, 96 kbps
+>2 byte&0xF0 0xB0 \b, 112 kbps
+>2 byte&0xF0 0xC0 \b, 128 kbps
+>2 byte&0xF0 0xD0 \b, 144 kbps
+>2 byte&0xF0 0xE0 \b, 160 kbps
# timing
>2 byte&0x0C 0x00 \b, 22.05 kHz
>2 byte&0x0C 0x04 \b, 24 kHz
@@ -394,20 +434,20 @@
# MP2, M2A
0 beshort&0xFFFE 0xFFF4 MPEG ADTS, layer II, v2
# rate
->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
+>2 byte&0xF0 0x10 \b, 8 kbps
+>2 byte&0xF0 0x20 \b, 16 kbps
+>2 byte&0xF0 0x30 \b, 24 kbps
+>2 byte&0xF0 0x40 \b, 32 kbps
+>2 byte&0xF0 0x50 \b, 40 kbps
+>2 byte&0xF0 0x60 \b, 48 kbps
+>2 byte&0xF0 0x70 \b, 56 kbps
+>2 byte&0xF0 0x80 \b, 64 kbps
+>2 byte&0xF0 0x90 \b, 80 kbps
+>2 byte&0xF0 0xA0 \b, 96 kbps
+>2 byte&0xF0 0xB0 \b, 112 kbps
+>2 byte&0xF0 0xC0 \b, 128 kbps
+>2 byte&0xF0 0xD0 \b, 144 kbps
+>2 byte&0xF0 0xE0 \b, 160 kbps
# timing
>2 byte&0x0C 0x00 \b, 22.05 kHz
>2 byte&0x0C 0x04 \b, 24 kHz
@@ -428,20 +468,20 @@
# MPA, M2A
0 beshort&0xFFFE 0xFFF6 MPEG ADTS, layer I, v2
# rate
->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, 144 kBits
->2 byte&0xF0 0xA0 \b, 160 kBits
->2 byte&0xF0 0xB0 \b, 176 kBits
->2 byte&0xF0 0xC0 \b, 192 kBits
->2 byte&0xF0 0xD0 \b, 224 kBits
->2 byte&0xF0 0xE0 \b, 256 kBits
+>2 byte&0xF0 0x10 \b, 32 kbps
+>2 byte&0xF0 0x20 \b, 48 kbps
+>2 byte&0xF0 0x30 \b, 56 kbps
+>2 byte&0xF0 0x40 \b, 64 kbps
+>2 byte&0xF0 0x50 \b, 80 kbps
+>2 byte&0xF0 0x60 \b, 96 kbps
+>2 byte&0xF0 0x70 \b, 112 kbps
+>2 byte&0xF0 0x80 \b, 128 kbps
+>2 byte&0xF0 0x90 \b, 144 kbps
+>2 byte&0xF0 0xA0 \b, 160 kbps
+>2 byte&0xF0 0xB0 \b, 176 kbps
+>2 byte&0xF0 0xC0 \b, 192 kbps
+>2 byte&0xF0 0xD0 \b, 224 kbps
+>2 byte&0xF0 0xE0 \b, 256 kbps
# timing
>2 byte&0x0C 0x00 \b, 22.05 kHz
>2 byte&0x0C 0x04 \b, 24 kHz
@@ -462,20 +502,20 @@
# MP3, M25A
0 beshort&0xFFFE 0xFFE2 MPEG ADTS, layer III, v2.5
# rate
->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
+>2 byte&0xF0 0x10 \b, 8 kbps
+>2 byte&0xF0 0x20 \b, 16 kbps
+>2 byte&0xF0 0x30 \b, 24 kbps
+>2 byte&0xF0 0x40 \b, 32 kbps
+>2 byte&0xF0 0x50 \b, 40 kbps
+>2 byte&0xF0 0x60 \b, 48 kbps
+>2 byte&0xF0 0x70 \b, 56 kbps
+>2 byte&0xF0 0x80 \b, 64 kbps
+>2 byte&0xF0 0x90 \b, 80 kbps
+>2 byte&0xF0 0xA0 \b, 96 kbps
+>2 byte&0xF0 0xB0 \b, 112 kbps
+>2 byte&0xF0 0xC0 \b, 128 kbps
+>2 byte&0xF0 0xD0 \b, 144 kbps
+>2 byte&0xF0 0xE0 \b, 160 kbps
# timing
>2 byte&0x0C 0x00 \b, 11.025 kHz
>2 byte&0x0C 0x04 \b, 12 kHz
@@ -497,6 +537,7 @@
# Stored AAC streams (instead of the MP4 format)
0 string ADIF MPEG ADIF, AAC
+!:mime audio/x-hx-aac-adif
>4 byte &0x80
>>13 byte &0x10 \b, VBR
>>13 byte ^0x10 \b, CBR
@@ -521,6 +562,7 @@
# Live or stored single AAC stream (used with MPEG-2 systems)
0 beshort&0xFFF6 0xFFF0 MPEG ADTS, AAC
+!:mime audio/x-hx-aac-adts
>1 byte &0x08 \b, v2
>1 byte ^0x08 \b, v4
# profile
@@ -557,6 +599,7 @@
# Live MPEG-4 audio streams (instead of RTP FlexMux)
0 beshort&0xFFE0 0x56E0 MPEG-4 LOAS
+!:mime audio/x-mp4a-latm
#>1 beshort&0x1FFF x \b, %u byte packet
>3 byte&0xE0 0x40
>>4 byte&0x3C 0x04 \b, single stream
@@ -570,22 +613,34 @@
>>4 byte&0x78 0x18 \b, 3 streams
>>4 byte &0x20 \b, 4 or more streams
>>4 byte &0x40 \b, 8 or more streams
-0 beshort 0x4DE1 MPEG-4 LO-EP audio stream
+# This magic isn't strong enough (matches plausible ISO-8859-1 text)
+#0 beshort 0x4DE1 MPEG-4 LO-EP audio stream
+#!:mime audio/x-mp4a-latm
+
+# Summary: FLI animation format
+# Created by: Daniel Quinlan <quinlan@yggdrasil.com>
+# Modified by (1): Abel Cheung <abelcheung@gmail.com> (avoid over-generic detection)
+4 leshort 0xAF11
+# standard FLI always has 320x200 resolution and 8 bit color
+>8 leshort 320
+>>10 leshort 200
+>>>12 leshort 8 FLI animation, 320x200x8
+!:mime video/x-fli
+>>>>6 leshort x \b, %d frames
+# frame speed is multiple of 1/70s
+>>>>16 leshort x \b, %d/70s per frame
-# FLI animation format
-4 leshort 0xAF11 FLI file
->6 leshort x - %d frames,
->8 leshort x width=%d pixels,
->10 leshort x height=%d pixels,
->12 leshort x depth=%d,
->16 leshort x ticks/frame=%d
-# FLC animation format
-4 leshort 0xAF12 FLC file
->6 leshort x - %d frames
->8 leshort x width=%d pixels,
->10 leshort x height=%d pixels,
->12 leshort x depth=%d,
->16 leshort x ticks/frame=%d
+# Summary: FLC animation format
+# Created by: Daniel Quinlan <quinlan@yggdrasil.com>
+# Modified by (1): Abel Cheung <abelcheung@gmail.com> (avoid over-generic detection)
+4 leshort 0xAF12
+# standard FLC always use 8 bit color
+>12 leshort 8 FLC animation
+!:mime video/x-flc
+>>8 leshort x \b, %d
+>>10 leshort x \bx%dx8
+>>6 uleshort x \b, %d frames
+>>16 uleshort x \b, %dms per frame
# DL animation format
# XXX - collision with most `mips' magic
@@ -599,9 +654,11 @@
# 255 (hex FF)! The DL format is really bad.
#
#0 byte 1 DL version 1, medium format (160x100, 4 images/screen)
+#!:mime video/x-unknown
#>42 byte x - %d screens,
#>43 byte x %d commands
#0 byte 2 DL version 2
+#!:mime video/x-unknown
#>1 byte 1 - large format (320x200,1 image/screen),
#>1 byte 2 - medium format (160x100,4 images/screen),
#>1 byte >2 - unknown format,
@@ -641,6 +698,7 @@
# MNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
0 string \x8aMNG MNG video data,
+!:mime video/x-mng
>4 belong !0x0d0a1a0a CORRUPTED,
>4 belong 0x0d0a1a0a
>>16 belong x %ld x
@@ -648,6 +706,7 @@
# JNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
0 string \x8bJNG JNG video data,
+!:mime video/x-jng
>4 belong !0x0d0a1a0a CORRUPTED,
>4 belong 0x0d0a1a0a
>>16 belong x %ld x
@@ -658,7 +717,16 @@
# VRML (Virtual Reality Modelling Language)
0 string/b #VRML\ V1.0\ ascii VRML 1 file
+!:mime model/vrml
0 string/b #VRML\ V2.0\ utf8 ISO/IEC 14772 VRML 97 file
+!:mime model/vrml
+
+# X3D (Extensible 3D) [http://www.web3d.org/specifications/x3d-3.0.dtd]
+# From Michel Briand <michelbriand@free.fr>
+0 string \<?xml\ version="
+!:strength +1
+>20 search/1000/cb \<!DOCTYPE\ X3D X3D (Extensible 3D) model xml text
+!:mime model/x3d
#---------------------------------------------------------------------------
# HVQM4: compressed movie format designed by Hudson for Nintendo GameCube
@@ -681,7 +749,18 @@
# From: Behan Webster <behanw@websterwood.com>
# NuppelVideo used by Mythtv (*.nuv)
-0 regex NuppelVideo|MythTVVideo MythTV NuppelVideo
+# Note: there are two identical stanzas here differing only in the
+# initial string matched. It used to be done with a regex, but we're
+# trying to get rid of those.
+0 string NuppelVideo MythTV NuppelVideo
+>12 string x v%s
+>20 lelong x (%d
+>24 lelong x \bx%d),
+>36 string P \bprogressive,
+>36 string I \binterlaced,
+>40 ledouble x \baspect:%.2f,
+>48 ledouble x \bfps:%.2f
+0 string MythTV MythTV NuppelVideo
>12 string x v%s
>20 lelong x (%d
>24 lelong x \bx%d),
@@ -689,3 +768,25 @@
>36 string I \binterlaced,
>40 ledouble x \baspect:%.2f,
>48 ledouble x \bfps:%.2f
+
+# MPEG file
+# MPEG sequences
+# FIXME: This section is from the old magic.mime file and needs integrating with the rest
+0 belong 0x000001BA
+>4 byte &0x40
+!:mime video/mp2p
+>4 byte ^0x40
+!:mime video/mpeg
+0 belong 0x000001BB
+!:mime video/mpeg
+0 belong 0x000001B0
+!:mime video/mp4v-es
+0 belong 0x000001B5
+!:mime video/mp4v-es
+0 belong 0x000001B3
+!:mime video/mpv
+0 belong&0xFF5FFF1F 0x47400010
+!:mime video/mp2t
+0 belong 0x00000001
+>4 byte&0x1F 0x07
+!:mime video/h264
diff --git a/Magdir/apple b/Magdir/apple
index 4a593ea221ec..669ab04dcc6f 100644
--- a/Magdir/apple
+++ b/Magdir/apple
@@ -1,8 +1,7 @@
-
#------------------------------------------------------------------------------
# apple: file(1) magic for Apple file formats
#
-0 string FiLeStArTfIlEsTaRt binscii (apple ][) text
+0 search/1 FiLeStArTfIlEsTaRt binscii (apple ][) text
0 string \x0aGL Binary II (apple ][) data
0 string \x76\xff Squeezed (apple ][) data
0 string NuFile NuFile archive (apple ][) data
@@ -10,6 +9,23 @@
0 belong 0x00051600 AppleSingle encoded Macintosh file
0 belong 0x00051607 AppleDouble encoded Macintosh file
+# Type: Apple Emulator 2IMG format
+# From: Radek Vokal <rvokal@redhat.com>
+0 string 2IMG Apple ][ 2IMG Disk Image
+>4 string XGS! \b, XGS
+>4 string CTKG \b, Catakig
+>4 string ShIm \b, Sheppy's ImageMaker
+>4 string WOOF \b, Sweet 16
+>4 string B2TR \b, Bernie ][ the Rescue
+>4 string !nfc \b, ASIMOV2
+>4 string x \b, Unknown Format
+>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
+
# magic for Newton PDA package formats
# from Ruda Moura <ruda@helllabs.org>
0 string package0 Newton package, NOS 1.x,
@@ -118,11 +134,12 @@
# Nevertheless this will manage to catch a lot of images that happen
# to have a solid-colored line at the bottom of the screen.
-8144 string \x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F Apple II image with white background
-8144 string \x55\x2A\x55\x2A\x55\x2A\x55\x2A Apple II image with purple background
-8144 string \x2A\x55\x2A\x55\x2A\x55\x2A\x55 Apple II image with green background
-8144 string \xD5\xAA\xD5\xAA\xD5\xAA\xD5\xAA Apple II image with blue background
-8144 string \xAA\xD5\xAA\xD5\xAA\xD5\xAA\xD5 Apple II image with orange background
+# GRR: Magic too weak
+#8144 string \x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F Apple II image with white background
+#8144 string \x55\x2A\x55\x2A\x55\x2A\x55\x2A Apple II image with purple background
+#8144 string \x2A\x55\x2A\x55\x2A\x55\x2A\x55 Apple II image with green background
+#8144 string \xD5\xAA\xD5\xAA\xD5\xAA\xD5\xAA Apple II image with blue background
+#8144 string \xAA\xD5\xAA\xD5\xAA\xD5\xAA\xD5 Apple II image with orange background
# Beagle Bros. Apple Mechanic fonts
diff --git a/Magdir/archive b/Magdir/archive
index 0b3a9ba92bda..b75fac0838b5 100644
--- a/Magdir/archive
+++ b/Magdir/archive
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# archive: file(1) magic for archive formats (see also "msdos" for self-
# extracting compressed archives)
@@ -8,7 +7,9 @@
# POSIX tar archives
257 string ustar\0 POSIX tar archive
+!:mime application/x-tar # encoding: posix
257 string ustar\040\040\0 GNU tar archive
+!:mime application/x-tar # encoding: gnu
# cpio archives
#
@@ -22,7 +23,9 @@
# are defined as "short"s; I think all the new formats are
# character-header formats and thus are strings, not numbers.
0 short 070707 cpio archive
+!:mime application/x-cpio
0 short 0143561 byte-swapped cpio archive
+!:mime application/x-cpio # encoding: swapped
0 string 070707 ASCII cpio archive (pre-SVR4 or odc)
0 string 070701 ASCII cpio archive (SVR4 with no CRC)
0 string 070702 ASCII cpio archive (SVR4 with CRC)
@@ -30,8 +33,10 @@
# Debian package (needs to go before regular portable archives)
#
0 string =!<arch>\ndebian
+!:mime application/x-debian-package
>8 string debian-split part of multipart Debian package
>8 string debian-binary Debian binary package
+>8 string !debian
>68 string >\0 (format %s)
# These next two lines do not work, because a bzip2 Debian archive
# still uses gzip for the control.tar (first in the archive). Only
@@ -49,6 +54,7 @@
0 short 0177545 old PDP-11 archive
0 long 0100554 apl workspace
0 string =<ar> archive
+!:mime application/x-archive
# MIPS archive (needs to go before regular portable archives)
#
@@ -60,7 +66,7 @@
>19 string B and an EB hash table
>22 string X -- out of date
-0 string -h- Software Tools format archive text
+0 search/1 -h- Software Tools format archive text
#
# XXX - why are there multiple <ar> thingies? Note that 0x213c6172 is
@@ -79,6 +85,7 @@
# "ar" archives?
#
0 string =!<arch> current ar archive
+!:mime application/x-archive
>8 string __.SYMDEF random library
>0 belong =65538 - pre SR9.5
>0 belong =65539 - post SR9.5
@@ -121,15 +128,24 @@
# we only test some types on basis of frequency: 0x08 (83%), 0x09 (5%),
# 0x02 (5%), 0x03 (3%), 0x04 (2%), 0x06 (2%). 0x01 collides with terminfo.
0 lelong&0x8080ffff 0x0000081a ARC archive data, dynamic LZW
+!:mime application/x-arc
0 lelong&0x8080ffff 0x0000091a ARC archive data, squashed
+!:mime application/x-arc
0 lelong&0x8080ffff 0x0000021a ARC archive data, uncompressed
+!:mime application/x-arc
0 lelong&0x8080ffff 0x0000031a ARC archive data, packed
+!:mime application/x-arc
0 lelong&0x8080ffff 0x0000041a ARC archive data, squeezed
+!:mime application/x-arc
0 lelong&0x8080ffff 0x0000061a ARC archive data, crunched
+!:mime application/x-arc
# [JW] stuff taken from idarc, obviously ARC successors:
0 lelong&0x8080ffff 0x00000a1a PAK archive data
+!:mime application/x-arc
0 lelong&0x8080ffff 0x0000141a ARC+ archive data
+!:mime application/x-arc
0 lelong&0x8080ffff 0x0000481a HYP archive data
+!:mime application/x-arc
# Acorn archive formats (Disaster prone simpleton, m91dps@ecs.ox.ac.uk)
# I can't create either SPARK or ArcFS archives so I have not tested this stuff
@@ -435,6 +451,7 @@
# ARJ archiver (jason@jarthur.Claremont.EDU)
0 leshort 0xea60 ARJ archive data
+!:mime application/x-arj
>5 byte x \b, v%d,
>8 byte &0x04 multi-volume,
>8 byte &0x10 slash-switched,
@@ -487,19 +504,32 @@
# LHARC/LHA archiver (Greg Roelofs, newt@uchicago.edu)
2 string -lh0- LHarc 1.x/ARX archive data [lh0]
+!:mime application/x-lharc
2 string -lh1- LHarc 1.x/ARX archive data [lh1]
+!:mime application/x-lharc
2 string -lz4- LHarc 1.x archive data [lz4]
+!:mime application/x-lharc
2 string -lz5- LHarc 1.x archive data [lz5]
+!:mime application/x-lharc
# [never seen any but the last; -lh4- reported in comp.compression:]
2 string -lzs- LHa/LZS archive data [lzs]
+!:mime application/x-lha
2 string -lh\40- LHa 2.x? archive data [lh ]
+!:mime application/x-lha
2 string -lhd- LHa 2.x? archive data [lhd]
+!:mime application/x-lha
2 string -lh2- LHa 2.x? archive data [lh2]
+!:mime application/x-lha
2 string -lh3- LHa 2.x? archive data [lh3]
+!:mime application/x-lha
2 string -lh4- LHa (2.x) archive data [lh4]
+!:mime application/x-lha
2 string -lh5- LHa (2.x) archive data [lh5]
+!:mime application/x-lha
2 string -lh6- LHa (2.x) archive data [lh6]
+!:mime application/x-lha
2 string -lh7- LHa (2.x)/LHark archive data [lh7]
+!:mime application/x-lha
>20 byte x - header level %d
# taken from idarc [JW]
2 string -lZ PUT archive data
@@ -508,6 +538,7 @@
# RAR archiver (Greg Roelofs, newt@uchicago.edu)
0 string Rar! RAR archive data,
+!:mime application/x-rar
>44 byte x v%0x,
>10 byte >0 flags:
>>10 byte &0x01 Archive volume,
@@ -532,17 +563,24 @@
# ZIP archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu)
0 string PK\003\004
>4 byte 0x00 Zip archive data
+!:mime application/zip
>4 byte 0x09 Zip archive data, at least v0.9 to extract
+!:mime application/zip
>4 byte 0x0a Zip archive data, at least v1.0 to extract
+!:mime application/zip
>4 byte 0x0b Zip archive data, at least v1.1 to extract
+!:mime application/zip
+>0x161 string WINZIP Zip archive data, WinZIP self-extracting
+!:mime application/zip
>4 byte 0x14
>>30 ubelong !0x6d696d65 Zip archive data, at least v2.0 to extract
->0x161 string WINZIP Zip archive data, WinZIP self-extracting
-
+!:mime application/zip
# OpenOffice.org / KOffice / StarOffice documents
+# Listed here because they ARE zip files
+#
# From: Abel Cheung <abel@oaka.org>
-# Listed here because they are basically zip files
+>4 byte 0x14
>>30 string mimetype
# KOffice (1.2 or above) formats
@@ -572,12 +610,14 @@
>>>>>69 byte !0x2e presentation
>>>>>69 string .template template
>>>>62 string math Math document
+>>>>62 string base Database file
# OpenDocument formats (for OpenOffice 2.x / StarOffice >= 8)
# http://lists.oasis-open.org/archives/office/200505/msg00006.html
>>>50 string vnd.oasis.opendocument. OpenDocument
>>>>73 string text
>>>>>77 byte !0x2d Text
+!:mime application/vnd.oasis.opendocument.text
>>>>>77 string -template Text Template
>>>>>77 string -web HTML Document Template
>>>>>77 string -master Master Document
@@ -596,6 +636,7 @@
# Zoo archiver
20 lelong 0xfdc4a7dc Zoo archive data
+!:mime application/x-zoo
>4 byte >48 \b, v%c.
>>6 byte >47 \b%c
>>>7 byte >47 \b%c
@@ -607,6 +648,7 @@
# Shell archives
10 string #\ This\ is\ a\ shell\ archive shell archive text
+!:mime application/octet-stream
#
# LBR. NB: May conflict with the questionable
@@ -652,6 +694,7 @@
# Felix von Leitner <felix-file@fefe.de>
0 string d8:announce BitTorrent file
+!:mime application/x-bittorrent
# Atari MSA archive - Teemu Hukkanen <tjhukkan@iki.fi>
0 beshort 0x0e0f Atari MSA archive data
@@ -709,6 +752,7 @@
# EET archive
# From: Tilman Sauerbeck <tilman@code-monkey.de>
0 belong 0x1ee7ff00 EET archive
+!:mime application/x-eet
# rzip archives
0 string RZIP rzip compressed data
@@ -729,12 +773,11 @@
# http://www.thouky.co.uk/software/psifs/sis.html
# http://developer.symbian.com/main/downloads/papers/SymbianOSv91/softwareinstallsis.pdf
8 lelong 0x10000419 Symbian installation file
+!:mime application/vnd.symbian.install
>4 lelong 0x1000006D (EPOC release 3/4/5)
>4 lelong 0x10003A12 (EPOC release 6)
0 lelong 0x10201A7A Symbian installation file (Symbian OS 9.x)
-
-# Pack200 Java archives, http://jcp.org/en/jsr/detail?id=200
-0 belong 0xcafed00d Pack200 Java archive
+!:mime x-epoc/x-sisx-app
# From "Nelson A. de Oliveira" <naoliv@gmail.com>
0 string MPQ\032 MoPaQ (MPQ) archive
@@ -748,3 +791,15 @@
# .kgb
0 string KGB_arch KGB Archiver file
>10 string x with compression level %.1s
+
+# xar (eXtensible ARchiver) archive
+# From: "David Remahl" <dremahl@apple.com>
+0 string xar! xar archive
+#>4 beshort x header size %d
+>6 beshort x version %d,
+#>8 quad x compressed TOC: %d,
+#>16 quad x uncompressed TOC: %d,
+>24 belong 0 no checksum
+>24 belong 1 SHA-1 checksum
+>24 belong 2 MD5 checksum
+
diff --git a/Magdir/audio b/Magdir/audio
index 511da1dc5be0..3a9c176c8a4b 100644
--- a/Magdir/audio
+++ b/Magdir/audio
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# audio: file(1) magic for sound formats (see also "iff")
#
@@ -9,12 +8,19 @@
# Sun/NeXT audio data
0 string .snd Sun/NeXT audio data:
>12 belong 1 8-bit ISDN mu-law,
+!:mime audio/basic
>12 belong 2 8-bit linear PCM [REF-PCM],
+!:mime audio/basic
>12 belong 3 16-bit linear PCM,
+!:mime audio/basic
>12 belong 4 24-bit linear PCM,
+!:mime audio/basic
>12 belong 5 32-bit linear PCM,
+!:mime audio/basic
>12 belong 6 32-bit IEEE floating point,
+!:mime audio/basic
>12 belong 7 64-bit IEEE floating point,
+!:mime audio/basic
>12 belong 8 Fragmented sample data,
>12 belong 10 DSP program,
>12 belong 11 8-bit fixed point,
@@ -26,6 +32,7 @@
>12 belong 20 16-bit linear with emphasis and compression,
>12 belong 21 Music kit DSP commands,
>12 belong 23 8-bit ISDN mu-law compressed (CCITT G.721 ADPCM voice enc.),
+!:mime audio/x-adpcm
>12 belong 24 compressed (8-bit CCITT G.722 ADPCM)
>12 belong 25 compressed (3-bit CCITT G.723.3 ADPCM),
>12 belong 26 compressed (5-bit CCITT G.723.5 ADPCM),
@@ -39,12 +46,19 @@
# that uses little-endian encoding and has a different magic number
0 lelong 0x0064732E DEC audio data:
>12 lelong 1 8-bit ISDN mu-law,
+!:mime audio/x-dec-basic
>12 lelong 2 8-bit linear PCM [REF-PCM],
+!:mime audio/x-dec-basic
>12 lelong 3 16-bit linear PCM,
+!:mime audio/x-dec-basic
>12 lelong 4 24-bit linear PCM,
+!:mime audio/x-dec-basic
>12 lelong 5 32-bit linear PCM,
+!:mime audio/x-dec-basic
>12 lelong 6 32-bit IEEE floating point,
+!:mime audio/x-dec-basic
>12 lelong 7 64-bit IEEE floating point,
+!:mime audio/x-dec-basic
>12 belong 8 Fragmented sample data,
>12 belong 10 DSP program,
>12 belong 11 8-bit fixed point,
@@ -56,6 +70,7 @@
>12 belong 20 16-bit linear with emphasis and compression,
>12 belong 21 Music kit DSP commands,
>12 lelong 23 8-bit ISDN mu-law compressed (CCITT G.721 ADPCM voice enc.),
+!:mime audio/x-dec-basic
>12 belong 24 compressed (8-bit CCITT G.722 ADPCM)
>12 belong 25 compressed (3-bit CCITT G.723.3 ADPCM),
>12 belong 26 compressed (5-bit CCITT G.723.5 ADPCM),
@@ -67,6 +82,7 @@
# Creative Labs AUDIO stuff
0 string MThd Standard MIDI data
+!:mime audio/midi
>8 beshort x (format %d)
>10 beshort x using %d track
>10 beshort >1 \bs
@@ -74,8 +90,11 @@
>12 beshort&0x8000 >0 SMPTE
0 string CTMF Creative Music (CMF) data
+!:mime audio/x-unknown
0 string SBI SoundBlaster instrument data
+!:mime audio/x-unknown
0 string Creative\ Voice\ File Creative Labs voice data
+!:mime audio/x-unknown
# is this next line right? it came this way...
>19 byte 0x1A
>23 byte >0 - version %d
@@ -96,7 +115,13 @@
# Real Audio (Magic .ra\0375)
0 belong 0x2e7261fd RealAudio sound file
+!:mime audio/x-pn-realaudio
0 string .RMF RealMedia file
+!:mime application/vnd.rn-realmedia
+#video/x-pn-realvideo
+#video/vnd.rn-realvideo
+#application/vnd.rn-realmedia
+# sigh, there are many mimes for that but the above are the most common.
# MTM/669/FAR/S3M/ULT/XM format checking [Aaron Eppert, aeppert@dialin.ind.net]
# Oct 31, 1995
@@ -119,44 +144,84 @@
0 string GF1PATCH110\0ID#000002\0 GUS patch
0 string GF1PATCH100\0ID#000002\0 Old GUS patch
+# mime types according to http://www.geocities.com/nevilo/mod.htm:
+# audio/it .it
+# audio/x-zipped-it .itz
+# audio/xm fasttracker modules
+# audio/x-s3m screamtracker modules
+# audio/s3m screamtracker modules
+# audio/x-zipped-mod mdz
+# audio/mod mod
+# audio/x-mod All modules (mod, s3m, 669, mtm, med, xm, it, mdz, stm, itz, xmz, s3z)
+
#
# Taken from loader code from mikmod version 2.14
# by Steve McIntyre (stevem@chiark.greenend.org.uk)
# <doj@cubic.org> added title printing on 2003-06-24
0 string MAS_UTrack_V00
>14 string >/0 ultratracker V1.%.1s module sound data
+!:mime audio/x-mod
+#audio/x-tracker-module
0 string UN05 MikMod UNI format module sound data
0 string Extended\ Module: Fasttracker II module sound data
+!:mime audio/x-mod
+#audio/x-tracker-module
>17 string >\0 Title: "%s"
21 string/c =!SCREAM! Screamtracker 2 module sound data
+!:mime audio/x-mod
+#audio/x-screamtracker-module
21 string BMOD2STM Screamtracker 2 module sound data
+!:mime audio/x-mod
+#audio/x-screamtracker-module
1080 string M.K. 4-channel Protracker module sound data
+!:mime audio/x-mod
+#audio/x-protracker-module
>0 string >\0 Title: "%s"
1080 string M!K! 4-channel Protracker module sound data
+!:mime audio/x-mod
+#audio/x-protracker-module
>0 string >\0 Title: "%s"
1080 string FLT4 4-channel Startracker module sound data
+!:mime audio/x-mod
+#audio/x-startracker-module
>0 string >\0 Title: "%s"
1080 string FLT8 8-channel Startracker module sound data
+!:mime audio/x-mod
+#audio/x-startracker-module
>0 string >\0 Title: "%s"
1080 string 4CHN 4-channel Fasttracker module sound data
+!:mime audio/x-mod
+#audio/x-fasttracker-module
>0 string >\0 Title: "%s"
1080 string 6CHN 6-channel Fasttracker module sound data
+!:mime audio/x-mod
+#audio/x-fasttracker-module
>0 string >\0 Title: "%s"
1080 string 8CHN 8-channel Fasttracker module sound data
+!:mime audio/x-mod
+#audio/x-fasttracker-module
>0 string >\0 Title: "%s"
1080 string CD81 8-channel Octalyser module sound data
+!:mime audio/x-mod
+#audio/x-octalysertracker-module
>0 string >\0 Title: "%s"
-1080 string OKTA 8-channel Oktalyzer module sound data
+1080 string OKTA 8-channel Octalyzer module sound data
+!:mime audio/x-mod
+#audio/x-octalysertracker-module
>0 string >\0 Title: "%s"
# Not good enough.
#1082 string CH
#>1080 string >/0 %.2s-channel Fasttracker "oktalyzer" module sound data
1080 string 16CN 16-channel Taketracker module sound data
+!:mime audio/x-mod
+#audio/x-taketracker-module
>0 string >\0 Title: "%s"
1080 string 32CN 32-channel Taketracker module sound data
+!:mime audio/x-mod
+#audio/x-taketracker-module
>0 string >\0 Title: "%s"
# TOC sound files -Trevor Johnson <trevor@jpj.net>
@@ -208,7 +273,7 @@
>22 belong&0x00ffffff x %d Hz,
>18 beshort =0 no loop,
>18 beshort =-1 loop,
->21 ubyte <=127 note %d,
+>21 ubyte <128 note %d,
>22 byte =0 replay 5.485 KHz
>22 byte =1 replay 8.084 KHz
>22 byte =2 replay 10.971 Khz
@@ -221,9 +286,11 @@
# SGI SoundTrack <mpruett@sgi.com>
0 string _SGI_SoundTrack SGI SoundTrack project file
# ID3 version 2 tags <waschk@informatik.uni-rostock.de>
-0 string ID3 Audio file with ID3 version 2
->3 ubyte <0xff \b%d.
->4 ubyte <0xff \b%d tag
+0 string ID3 Audio file with ID3 version 2.
+# ??? Normally such a file is an MP3 file, but this will give false positives
+!:mime audio/mpeg
+>3 ubyte <0xff \b%d
+#>4 ubyte <0xff \b%d tag
>2584 string fLaC \b, FLAC encoding
>>2588 byte&0x7f >0 \b, unknown version
>>2588 byte&0x7f 0 \b
@@ -270,6 +337,7 @@
# Impulse tracker module (audio/x-it)
0 string IMPM Impulse Tracker module sound data -
+!:mime audio/x-mod
>4 string >\0 "%s"
>40 leshort !0 compatible w/ITv%x
>42 leshort !0 created w/ITv%x
@@ -380,6 +448,7 @@
# Free lossless audio codec <http://flac.sourceforge.net>
# From: Przemyslaw Augustyniak <silvathraec@rpg.pl>
0 string fLaC FLAC audio bitstream data
+!:mime audio/x-flac
>4 byte&0x7f >0 \b, unknown version
>4 byte&0x7f 0 \b
# some common bits/sample values
@@ -502,9 +571,9 @@
# .preset
0 string [Equalizer\ preset] XMMS equalizer preset
# .m3u
-0 string #EXTM3U M3U playlist
+0 search/1 #EXTM3U M3U playlist text
# .pls
-0 string [playlist] PLS playlist
+0 search/1 [playlist] PLS playlist text
# licq.conf
1 string [licq] LICQ configuration file
@@ -553,9 +622,6 @@
# http://www.wx800.com/msg/download/irda/iMelody.pdf
0 string BEGIN:IMELODY iMelody Ringtone Format
-# From: Matthew Flaschen <matthew.flaschen@gatech.edu>
-0 string #EXTM3U M3U playlist text
-
# From: "Mateus Caruccio" <mateus@caruccio.com>
# guitar pro v3,4,5 from http://filext.com/file-extension/gp3
0 string \030FICHIER\ GUITAR\ PRO\ v3. Guitar Pro Ver. 3 Tablature
@@ -563,3 +629,7 @@
# From: "Leslie P. Polzer" <leslie.polzer@gmx.net>
60 string SONG SoundFX Module sound file
+# Type: Adaptive Multi-Rate Codec
+# URL: http://filext.com/detaillist.php?extdetail=AMR
+# From: Russell Coker <russell@coker.com.au>
+0 string #!AMR Adaptive Multi-Rate Codec (GSM telephony)
diff --git a/Magdir/c-lang b/Magdir/c-lang
index fd3f9aa2491f..895e37f656bc 100644
--- a/Magdir/c-lang
+++ b/Magdir/c-lang
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# c-lang: file(1) magic for C programs (or REXX)
#
@@ -6,11 +5,15 @@
# XPM icons (Greg Roelofs, newt@uchicago.edu)
# if you uncomment "/*" for C/REXX below, also uncomment this entry
#0 string /*\ XPM\ */ X pixmap image data
+#!:mime image/x-xpmi
+
+# 3DS (3d Studio files) Conflicts with diff output 0x3d '='
+#16 beshort 0x3d3d image/x-3ds
# this first will upset you if you're a PL/1 shop...
# in which case rm it; ascmagic will catch real C programs
-#0 string /* C or REXX program text
-#0 string // C++ program text
+#0 search/1 /* C or REXX program text
+#0 search/1 // C++ program text
# From: Mikhail Teterin <mi@aldan.algebra.com>
0 string cscope cscope reference data
@@ -20,5 +23,5 @@
# The inverted index functionality was added some time betwen
# versions 11 and 15, so look for -q if version is above 14:
>7 string >14
->>10 regex .+\ -q\ with inverted index
->10 regex .+\ -c\ text (non-compressed)
+>>10 search/100 \ -q\ with inverted index
+>10 search/100 \ -c\ text (non-compressed)
diff --git a/Magdir/c64 b/Magdir/c64
index a224b216346c..f8a8b76c6b3b 100644
--- a/Magdir/c64
+++ b/Magdir/c64
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# c64: file(1) magic for various commodore 64 related files
#
diff --git a/Magdir/cafebabe b/Magdir/cafebabe
index 233411c80439..db385eaab819 100644
--- a/Magdir/cafebabe
+++ b/Magdir/cafebabe
@@ -12,10 +12,16 @@
# (and use as a hack). Let's not use 18, because the Mach-O people
# might add another one or two as time goes by...
#
-0 belong 0xcafebabe
->4 belong >30 compiled Java class data,
->>6 beshort x version %d.
->>4 beshort x \b%d
->4 belong 1 Mach-O fat file with 1 architecture
->4 belong >1
->>4 belong <20 Mach-O fat file with %ld architectures
+0 beshort 0xcafe
+>2 beshort 0xbabe
+!:mime application/x-java-applet
+>>2 belong >30 compiled Java class data,
+>>>6 beshort x version %d.
+>>>4 beshort x \b%d
+>>4 belong 1 Mach-O fat file with 1 architecture
+>>4 belong >1
+>>>4 belong <20 Mach-O fat file with %ld architectures
+>2 beshort 0xd00d JAR compressed with pack200,
+>>5 byte x version %d.
+>>4 byte x \b%d
+!:mime application/x-java-pack200
diff --git a/Magdir/cddb b/Magdir/cddb
index 2ea97eecd296..42ca416bd89b 100644
--- a/Magdir/cddb
+++ b/Magdir/cddb
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# CDDB: file(1) magic for CDDB(tm) format CD text data files
#
@@ -8,4 +7,4 @@
# CDDB-enabled CD player applications.
#
-0 string/b #\040xmcd CDDB(tm) format CD text data
+0 search/1/b #\040xmcd CDDB(tm) format CD text data
diff --git a/Magdir/clarion b/Magdir/clarion
new file mode 100644
index 000000000000..5f5f6e75613c
--- /dev/null
+++ b/Magdir/clarion
@@ -0,0 +1,26 @@
+
+#------------------------------------------------------------------------------
+# clarion: file(1) magic for # Clarion Personal/Professional Developer
+# (v2 and above)
+# From: Julien Blache <jb@jblache.org>
+
+# Database files
+# signature
+0 leshort 0x3343 Clarion Developer (v2 and above) data file
+# attributes
+>2 leshort &0x0001 \b, locked
+>2 leshort &0x0004 \b, encrypted
+>2 leshort &0x0008 \b, memo file exists
+>2 leshort &0x0010 \b, compressed
+>2 leshort &0x0040 \b, read only
+# number of records
+>5 lelong x \b, %ld records
+
+# Memo files
+0 leshort 0x334d Clarion Developer (v2 and above) memo data
+
+# Key/Index files
+# No magic? :(
+
+# Help files
+0 leshort 0x49e0 Clarion Developer (v2 and above) help data
diff --git a/Magdir/commands b/Magdir/commands
index 599c190a45ec..0942802d9101 100644
--- a/Magdir/commands
+++ b/Magdir/commands
@@ -2,41 +2,62 @@
#------------------------------------------------------------------------------
# commands: file(1) magic for various shells and interpreters
#
-0 string : shell archive or script for antique kernel text
-0 string/b #!\ /bin/sh Bourne shell script text executable
+#0 string : shell archive or script for antique kernel text
+0 string/b #!\ /bin/sh POSIX shell script text executable
+!:mime text/x-shellscript
0 string/b #!\ /bin/csh C shell script text executable
+!:mime text/x-shellscript
# korn shell magic, sent by George Wu, gwu@clyde.att.com
0 string/b #!\ /bin/ksh Korn shell script text executable
+!:mime text/x-shellscript
0 string/b #!\ /bin/tcsh Tenex C shell script text executable
+!:mime text/x-shellscript
0 string/b #!\ /usr/local/tcsh Tenex C shell script text executable
+!:mime text/x-shellscript
0 string/b #!\ /usr/local/bin/tcsh Tenex C shell script text executable
+!:mime text/x-shellscript
#
# zsh/ash/ae/nawk/gawk magic from cameron@cs.unsw.oz.au (Cameron Simpson)
0 string/b #!\ /bin/zsh Paul Falstad's zsh script text executable
+!:mime text/x-shellscript
0 string/b #!\ /usr/bin/zsh Paul Falstad's zsh script text executable
+!:mime text/x-shellscript
0 string/b #!\ /usr/local/bin/zsh Paul Falstad's zsh script text executable
+!:mime text/x-shellscript
0 string/b #!\ /usr/local/bin/ash Neil Brown's ash script text executable
+!:mime text/x-shellscript
0 string/b #!\ /usr/local/bin/ae Neil Brown's ae script text executable
+!:mime text/x-shellscript
0 string/b #!\ /bin/nawk new awk script text executable
+!:mime text/x-nawk
0 string/b #!\ /usr/bin/nawk new awk script text executable
+!:mime text/x-nawk
0 string/b #!\ /usr/local/bin/nawk new awk script text executable
+!:mime text/x-nawk
0 string/b #!\ /bin/gawk GNU awk script text executable
+!:mime text/x-gawk
0 string/b #!\ /usr/bin/gawk GNU awk script text executable
+!:mime text/x-gawk
0 string/b #!\ /usr/local/bin/gawk GNU awk script text executable
+!:mime text/x-gawk
#
0 string/b #!\ /bin/awk awk script text executable
+!:mime text/x-awk
0 string/b #!\ /usr/bin/awk awk script text executable
+!:mime text/x-awk
# update to distinguish from *.vcf files
# this is broken because postscript has /EBEGIN{ for example.
-#0 regex BEGIN[[:space:]]*[{] awk script text
+#0 search/Bb BEGIN { awk script text
# AT&T Bell Labs' Plan 9 shell
0 string/b #!\ /bin/rc Plan 9 rc shell script text executable
# bash shell magic, from Peter Tobias (tobias@server.et-inf.fho-emden.de)
0 string/b #!\ /bin/bash Bourne-Again shell script text executable
+!:mime text/x-shellscript
0 string/b #!\ /usr/local/bin/bash Bourne-Again shell script text executable
+!:mime text/x-shellscript
# using env
0 string #!/usr/bin/env a
@@ -46,11 +67,16 @@
# PHP scripts
# Ulf Harnhammar <ulfh@update.uu.se>
-0 string/c =<?php PHP script text
-0 string =<?\n PHP script text
-0 string =<?\r PHP script text
-0 string/b #!\ /usr/local/bin/php PHP script text executable
-0 string/b #!\ /usr/bin/php PHP script text executable
+0 search/1/c =<?php PHP script text
+!:mime text/x-php
+0 search/1 =<?\n PHP script text
+!:mime text/x-php
+0 search/1 =<?\r PHP script text
+!:mime text/x-php
+0 search/1/b #!\ /usr/local/bin/php PHP script text executable
+!:mime text/x-php
+0 search/1/b #!\ /usr/bin/php PHP script text executable
+!:mime text/x-php
0 string Zend\x00 PHP script Zend Optimizer data
diff --git a/Magdir/compress b/Magdir/compress
index e9be46b76c40..e2e4e03261cb 100644
--- a/Magdir/compress
+++ b/Magdir/compress
@@ -10,6 +10,7 @@
# standard unix compress
0 string \037\235 compress'd data
+!:mime application/x-compress
>2 byte&0x80 >0 block compressed
>2 byte&0x1f x %d bits
@@ -19,6 +20,7 @@
# * 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
+!:mime application/x-gzip
>2 byte <8 \b, reserved method
>2 byte >8 \b, unknown method
>3 byte &0x01 \b, ASCII
@@ -49,23 +51,29 @@
# packed data, Huffman (minimum redundancy) codes on a byte-by-byte basis
0 string \037\036 packed data
+!:mime application/octet-stream
>2 belong >1 \b, %d characters originally
>2 belong =1 \b, %d character originally
#
# This magic number is byte-order-independent.
0 short 0x1f1f old packed data
+!:mime application/octet-stream
# XXX - why *two* entries for "compacted data", one of which is
# byte-order independent, and one of which is byte-order dependent?
#
0 short 0x1fff compacted data
+!:mime application/octet-stream
# This string is valid for SunOS (BE) and a matching "short" is listed
# in the Ultrix (LE) magic file.
0 string \377\037 compacted data
+!:mime application/octet-stream
0 short 0145405 huf output
+!:mime application/octet-stream
# bzip2
0 string BZh bzip2 compressed data
+!:mime application/x-bzip2
>3 byte >47 \b, block size = %c00k
# squeeze and crunch
@@ -102,17 +110,17 @@
# bzip a block-sorting file compressor
# by Julian Seward <sewardj@cs.man.ac.uk> and others
#
-0 string BZ bzip compressed data
->2 byte x \b, version: %c
->3 string =1 \b, compression block size 100k
->3 string =2 \b, compression block size 200k
->3 string =3 \b, compression block size 300k
->3 string =4 \b, compression block size 400k
->3 string =5 \b, compression block size 500k
->3 string =6 \b, compression block size 600k
->3 string =7 \b, compression block size 700k
->3 string =8 \b, compression block size 800k
->3 string =9 \b, compression block size 900k
+#0 string BZ bzip compressed data
+#>2 byte x \b, version: %c
+#>3 string =1 \b, compression block size 100k
+#>3 string =2 \b, compression block size 200k
+#>3 string =3 \b, compression block size 300k
+#>3 string =4 \b, compression block size 400k
+#>3 string =5 \b, compression block size 500k
+#>3 string =6 \b, compression block size 600k
+#>3 string =7 \b, compression block size 700k
+#>3 string =8 \b, compression block size 800k
+#>3 string =9 \b, compression block size 900k
# lzop from <markus.oberhumer@jk.uni-linz.ac.at>
0 string \x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a lzop compressed data
@@ -174,6 +182,13 @@
>6 byte x version %d
>7 byte x \b.%d
+# Type: LZMA
+# URL: http://www.7-zip.org/sdk.html
+# From: Robert Millan <rmh@aybabtu.com> and Reuben Thomas <rrt@sc3d.org>
+# Commented out because apparently not reliable (according to Debian
+# bug #364260)
+#0 string ]\000\000\200\000 LZMA compressed data
+
# AFX compressed files (Wolfram Kleff)
2 string -afx- AFX compressed file data
diff --git a/Magdir/console b/Magdir/console
index 775472d4265c..2af6575499ac 100644
--- a/Magdir/console
+++ b/Magdir/console
@@ -117,6 +117,12 @@
#
0 belong 0x37804012 V64 Nintendo 64 ROM dump
+# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
+# Nintendo .nds
+192 string \044\377\256Qi\232 Nintendo DS Game ROM Image
+# Nintendo .gba
+0 string \056\000\000\352$\377\256Qi Nintendo Game Boy Advance ROM Image
+
#------------------------------------------------------------------------------
# msx: file(1) magic for MSX game cartridge dumps
# Too simple - MPi
@@ -246,9 +252,3 @@
>>>(0x18.l-26) lelong x CRC32 0x%08x
>>>(0x18.l-23) string x "%s"
-# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
-# .w3g
-0 string Warcraft\ III\ recorded\ game %s
-# .w3m
-0 string HM3W Warcraft III map file
-
diff --git a/Magdir/cracklib b/Magdir/cracklib
index 8f7e0d460e5a..a1a5a275532e 100644
--- a/Magdir/cracklib
+++ b/Magdir/cracklib
@@ -9,5 +9,5 @@
0 belong 0x70775631 Cracklib password index, big endian
>4 belong >-1 (%i words)
# really bellong 0x0000000070775631
-4 belong 0x70775631 Cracklib password index, big endian ("64-bit")
+0 search/1 \0\0\0\0pwV1 Cracklib password index, big endian ("64-bit")
>12 belong >0 (%i words)
diff --git a/Magdir/ctags b/Magdir/ctags
index 84c5b7f93aad..f326cf5cf96f 100644
--- a/Magdir/ctags
+++ b/Magdir/ctags
@@ -1,5 +1,4 @@
-
# ----------------------------------------------------------------------------
# ctags: file (1) magic for Exuberant Ctags files
# From: Alexander Mai <mai@migdal.ikp.physik.tu-darmstadt.de>
-0 string =!_TAG Exuberant Ctags tag file text
+0 search/1 =!_TAG Exuberant Ctags tag file text
diff --git a/Magdir/database b/Magdir/database
index 8f2fc0a76d33..2e6ad2fdd2c8 100644
--- a/Magdir/database
+++ b/Magdir/database
@@ -9,8 +9,11 @@
# Will be maintained as part of the GDBM distribution in the future.
# <downsj@teeny.org>
0 belong 0x13579ace GNU dbm 1.x or ndbm database, big endian
+!:mime application/x-gdbm
0 lelong 0x13579ace GNU dbm 1.x or ndbm database, little endian
+!:mime application/x-gdbm
0 string GDBM GNU dbm 2.x database
+!:mime application/x-gdbm
#
# Berkeley DB
#
@@ -21,6 +24,7 @@
# Hash and Btree 2.X and later databases store the metadata in host byte order.
0 long 0x00061561 Berkeley DB
+!:mime application/x-dbm
>8 belong 4321
>>4 belong >2 1.86
>>4 belong <3 1.85
@@ -107,74 +111,87 @@
#>>0x04 byte 6 non-incrementing secondary index .XGn file
#>>0x04 byte 7 secondary index .YGn file
#>>>0x04 byte 8 incrementing secondary index .XGn file
+
## XBase database files
#0 byte 0x02
#>8 leshort >0
#>>12 leshort 0 FoxBase
+#!:mime application/x-dbf
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x03
+#!:mime application/x-dbf
#>8 leshort >0
#>>12 leshort 0 FoxBase+, FoxPro, dBaseIII+, dBaseIV, no memo
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x04
+#!:mime application/x-dbf
#>8 leshort >0
#>>12 leshort 0 dBASE IV no memo file
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x05
+#!:mime application/x-dbf
#>8 leshort >0
#>>12 leshort 0 dBASE V no memo file
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x30
+#!:mime application/x-dbf
#>8 leshort >0
#>>12 leshort 0 Visual FoxPro
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x43
+#!:mime application/x-dbf
#>8 leshort >0
#>>12 leshort 0 FlagShip with memo var size
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x7b
+#!:mime application/x-dbf
#>8 leshort >0
#>>12 leshort 0 dBASEIV with memo
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x83
+#!:mime application/x-dbf
#>8 leshort >0
#>>12 leshort 0 FoxBase+, dBaseIII+ with memo
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x8b
+#!:mime application/x-dbf
#>8 leshort >0
#>>12 leshort 0 dBaseIV with memo
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0x8e
+#!:mime application/x-dbf
#>8 leshort >0
#>>12 leshort 0 dBaseIV with SQL Table
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0xb3
+#!:mime application/x-dbf
#>8 leshort >0
#>>12 leshort 0 FlagShip with .dbt memo
#>>>0x04 lelong 0 (no records)
#>>>0x04 lelong >0 (%ld records)
#
#0 byte 0xf5
+#!:mime application/x-dbf
#>8 leshort >0
#>>12 leshort 0 FoxPro with memo
#>>>0x04 lelong 0 (no records)
@@ -183,7 +200,8 @@
#0 leshort 0x0006 DBase 3 index file
# MS Access database
-4 string Standard\ Jet\ DB Microsoft Access Database
+4 string Standard\ Jet\ DB Microsoft Access Database
+!:mime application/x-msaccess
# TDB database from Samba et al - Martin Pool <mbp@samba.org>
0 string TDB\ file TDB database
@@ -216,7 +234,11 @@
0 string PGDMP PostgreSQL custom database dump
>5 byte x - v%d
>6 byte x \b.%d
->5 beshort <=0x100 \b-0
+>5 beshort <0x101 \b-0
>5 beshort >0x100
>>7 byte x \b-%d
+# Type: Advanced Data Format (ADF) database
+# URL: http://www.grc.nasa.gov/WWW/cgns/adf/
+# From: Nicolas Chauvat <nicolas.chauvat@logilab.fr>
+0 string @(#)ADF\ Database CGNS Advanced Data Format
diff --git a/Magdir/diff b/Magdir/diff
index 187e892a6d30..291bae67f55e 100644
--- a/Magdir/diff
+++ b/Magdir/diff
@@ -1,10 +1,14 @@
-
#------------------------------------------------------------------------------
# diff: file(1) magic for diff(1) output
#
-0 string diff\ 'diff' output text
-0 string ***\ 'diff' output text
-0 string Only\ in\ 'diff' output text
-0 string Common\ subdirectories:\ 'diff' output text
+0 search/1 diff\ diff output text
+!:mime text/x-diff
+0 search/1 ***\ diff output text
+!:mime text/x-diff
+0 search/1 Only\ in\ diff output text
+!:mime text/x-diff
+0 search/1 Common\ subdirectories:\ diff output text
+!:mime text/x-diff
-0 string Index: RCS/CVS diff output text
+0 search/1 Index: RCS/CVS diff output text
+!:mime text/x-diff
diff --git a/Magdir/dump b/Magdir/dump
index addd9549cc78..cef191a2de48 100644
--- a/Magdir/dump
+++ b/Magdir/dump
@@ -91,3 +91,41 @@
>0 leshort 5 end of volume.
>0 leshort 6 map of inodes deleted.
>0 leshort 7 end of medium (for floppy).
+
+24 belong 0x19540119 new-fs dump file (ufs2, big endian),
+>896 beqdate x Previous dump %s,
+>904 beqdate x This dump %s,
+>12 belong >0 Volume %ld,
+>692 belong 0 Level zero, type:
+>692 belong >0 Level %d, type:
+>0 belong 1 tape header,
+>0 belong 2 beginning of file record,
+>0 belong 3 map of inodes on tape,
+>0 belong 4 continuation of file record,
+>0 belong 5 end of volume,
+>0 belong 6 map of inodes deleted,
+>0 belong 7 end of medium (for floppy),
+>676 string >\0 Label %s,
+>696 string >\0 Filesystem %s,
+>760 string >\0 Device %s,
+>824 string >\0 Host %s,
+>888 belong >0 Flags %x
+
+24 lelong 0x19540119 new-fs dump file (ufs2, little endian),
+>896 leqdate x This dump %s,
+>904 leqdate x Previous dump %s,
+>12 lelong >0 Volume %ld,
+>692 lelong 0 Level zero, type:
+>692 lelong >0 Level %d, type:
+>0 lelong 1 tape header,
+>0 lelong 2 beginning of file record,
+>0 lelong 3 map of inodes on tape,
+>0 lelong 4 continuation of file record,
+>0 lelong 5 end of volume,
+>0 lelong 6 map of inodes deleted,
+>0 lelong 7 end of medium (for floppy),
+>676 string >\0 Label %s,
+>696 string >\0 Filesystem %s,
+>760 string >\0 Device %s,
+>824 string >\0 Host %s,
+>888 lelong >0 Flags %x
diff --git a/Magdir/elf b/Magdir/elf
index 464b436aca1d..891e2ad4e652 100644
--- a/Magdir/elf
+++ b/Magdir/elf
@@ -7,7 +7,12 @@
#
# What're the correct byte orders for the nCUBE and the Fujitsu VPP500?
#
-# updated by Daniel Quinlan (quinlan@yggdrasil.com)
+# Created by: unknown
+# Modified by (1): Daniel Quinlan <quinlan@yggdrasil.com>
+# Modified by (2): Peter Tobias <tobias@server.et-inf.fho-emden.de> (core support)
+# Modified by (3): Christian 'Dr. Disk' Hechelmann <drdisk@ds9.au.s.shuttle.de> (fix of core support)
+# Modified by (4): <gerardo.cacciari@gmail.com> (VMS Itanium)
+# Modified by (5): Matthias Urlichs <smurf@debian.org> (Listing of many architectures)
0 string \177ELF ELF
>4 byte 0 invalid class
>4 byte 1 32-bit
@@ -15,12 +20,16 @@
>5 byte 0 invalid byte order
>5 byte 1 LSB
>>16 leshort 0 no file type,
+!:strength *2
+!:mime application/octet-stream
>>16 leshort 1 relocatable,
+!:mime application/x-object
>>16 leshort 2 executable,
+!:mime application/x-executable
>>16 leshort 3 shared object,
-# Core handling from Peter Tobias <tobias@server.et-inf.fho-emden.de>
-# corrections by Christian 'Dr. Disk' Hechelmann <drdisk@ds9.au.s.shuttle.de>
+!:mime application/x-sharedlib
>>16 leshort 4 core file
+!:mime application/x-coredump
# Core file detection is not reliable.
#>>>(0x38+0xcc) string >\0 of '%s'
#>>>(0x38+0x10) lelong >0 (signal %d),
@@ -74,7 +83,7 @@
>>>48 leshort &0x0008 (LP64),
>>18 leshort 16 nCUBE,
>>18 leshort 17 Fujitsu VPP500,
->>18 leshort 18 SPARC32PLUS,
+>>18 leshort 18 SPARC32PLUS - invalid byte order,
>>18 leshort 20 PowerPC,
>>18 leshort 22 IBM S/390,
>>18 leshort 36 NEC V800,
@@ -96,9 +105,46 @@
>>18 leshort 51 Stanford MIPS-X,
>>18 leshort 52 Motorola Coldfire,
>>18 leshort 53 Motorola M68HC12,
+>>18 leshort 54 Fujitsu MMA,
+>>18 leshort 55 Siemens PCP,
+>>18 leshort 56 Sony nCPU,
+>>18 leshort 57 Denso NDR1,
+>>18 leshort 58 Start*Core,
+>>18 leshort 59 Toyota ME16,
+>>18 leshort 60 ST100,
+>>18 leshort 61 Tinyj emb.,
>>18 leshort 62 x86-64,
+>>18 leshort 63 Sony DSP,
+>>18 leshort 66 FX66,
+>>18 leshort 67 ST9+ 8/16 bit,
+>>18 leshort 68 ST7 8 bit,
+>>18 leshort 69 MC68HC16,
+>>18 leshort 70 MC68HC11,
+>>18 leshort 71 MC68HC08,
+>>18 leshort 72 MC68HC05,
+>>18 leshort 73 SGI SVx,
+>>18 leshort 74 ST19 8 bit,
>>18 leshort 75 Digital VAX,
+>>18 leshort 76 Axis cris,
+>>18 leshort 77 Infineon 32-bit embedded,
+>>18 leshort 78 Element 14 64-bit DSP,
+>>18 leshort 79 LSI Logic 16-bit DSP,
+>>18 leshort 80 MMIX,
+>>18 leshort 81 Harvard machine-independent,
+>>18 leshort 82 SiTera Prism,
+>>18 leshort 83 Atmel AVR 8-bit,
+>>18 leshort 84 Fujitsu FR30,
+>>18 leshort 85 Mitsubishi D10V,
+>>18 leshort 86 Mitsubishi D30V,
+>>18 leshort 87 NEC v850,
>>18 leshort 88 Renesas M32R,
+>>18 leshort 89 Matsushita MN10300,
+>>18 leshort 90 Matsushita MN10200,
+>>18 leshort 91 picoJava,
+>>18 leshort 92 OpenRISC,
+>>18 leshort 93 ARC Cores Tangent-A5,
+>>18 leshort 0x3426 OpenRISC (obsolete),
+>>18 leshort 0x8472 OpenRISC (obsolete),
>>18 leshort 94 Tensilica Xtensa,
>>18 leshort 97 NatSemi 32k,
>>18 leshort 106 Analog Devices Blackfin,
@@ -108,10 +154,15 @@
>>36 lelong 1 MathCoPro/FPU/MAU Required
>5 byte 2 MSB
>>16 beshort 0 no file type,
+!:mime application/octet-stream
>>16 beshort 1 relocatable,
+!:mime application/x-object
>>16 beshort 2 executable,
+!:mime application/x-executable
>>16 beshort 3 shared object,
+!:mime application/x-sharedlib
>>16 beshort 4 core file,
+!:mime application/x-coredump
#>>>(0x38+0xcc) string >\0 of '%s'
#>>>(0x38+0x10) belong >0 (signal %d),
>>16 beshort &0xff00 processor-specific,
@@ -163,10 +214,10 @@
>>18 beshort 16 nCUBE,
>>18 beshort 17 Fujitsu VPP500,
>>18 beshort 18 SPARC32PLUS,
->>>36 belong&0xffff00 &0x000100 V8+ Required,
->>>36 belong&0xffff00 &0x000200 Sun UltraSPARC1 Extensions Required,
->>>36 belong&0xffff00 &0x000400 HaL R1 Extensions Required,
->>>36 belong&0xffff00 &0x000800 Sun UltraSPARC3 Extensions Required,
+>>>36 belong&0xffff00 0x000100 V8+ Required,
+>>>36 belong&0xffff00 0x000200 Sun UltraSPARC1 Extensions Required,
+>>>36 belong&0xffff00 0x000400 HaL R1 Extensions Required,
+>>>36 belong&0xffff00 0x000800 Sun UltraSPARC3 Extensions Required,
>>18 beshort 20 PowerPC or cisco 4500,
>>18 beshort 21 64-bit PowerPC or cisco 7500,
>>18 beshort 22 IBM S/390,
@@ -181,6 +232,12 @@
>>18 beshort 41 Alpha,
>>18 beshort 42 Renesas SH,
>>18 beshort 43 SPARC V9,
+>>>48 belong&0xffff00 0x000200 Sun UltraSPARC1 Extensions Required,
+>>>48 belong&0xffff00 0x000400 HaL R1 Extensions Required,
+>>>48 belong&0xffff00 0x000800 Sun UltraSPARC3 Extensions Required,
+>>>48 belong&0x3 0 total store ordering,
+>>>48 belong&0x3 1 partial store ordering,
+>>>48 belong&0x3 2 relaxed memory ordering,
>>18 beshort 44 Siemens Tricore Embedded Processor,
>>18 beshort 45 Argonaut RISC Core, Argonaut Technologies Inc.,
>>18 beshort 46 Renesas H8/300,
@@ -194,6 +251,9 @@
>>18 beshort 73 Cray NV1,
>>18 beshort 75 Digital VAX,
>>18 beshort 88 Renesas M32R,
+>>18 leshort 92 OpenRISC,
+>>18 leshort 0x3426 OpenRISC (obsolete),
+>>18 leshort 0x8472 OpenRISC (obsolete),
>>18 beshort 94 Tensilica Xtensa,
>>18 beshort 97 NatSemi 32k,
>>18 beshort 0x18ad AVR32 (unofficial),
@@ -220,7 +280,6 @@
>>7 byte 10 (Tru64)
>>7 byte 11 (Novell Modesto)
>>7 byte 12 (OpenBSD)
-# VMS Itanium added by gerardo.cacciari@gmail.com
>8 string \2
>>7 byte 13 (OpenVMS)
>>7 byte 97 (ARM)
diff --git a/Magdir/erlang b/Magdir/erlang
new file mode 100644
index 000000000000..59f55ecb31b6
--- /dev/null
+++ b/Magdir/erlang
@@ -0,0 +1,18 @@
+
+#------------------------------------------------------------------------------
+# erlang: file(1) magic for Erlang JAM and BEAM files
+# URL: http://www.erlang.org/faq/x779.html#AEN812
+
+# OTP R3-R4
+0 string \0177BEAM! Old Erlang BEAM file
+>6 short >0 - version %d
+
+# OTP R5 and onwards
+0 string FOR1
+>8 string BEAM Erlang BEAM file
+
+# 4.2 version may have a copyright notice!
+4 string Tue Jan 22 14:32:44 MET 1991 Erlang JAM file - version 4.2
+79 string Tue Jan 22 14:32:44 MET 1991 Erlang JAM file - version 4.2
+
+4 string 1.0 Fri Feb 3 09:55:56 MET 1995 Erlang JAM file - version 4.3
diff --git a/Magdir/filesystems b/Magdir/filesystems
index 20b257bc3a4c..36c2f72d3ca8 100644
--- a/Magdir/filesystems
+++ b/Magdir/filesystems
@@ -833,7 +833,7 @@
# Minix filesystems - Juan Cespedes <cespedes@debian.org>
0x410 leshort 0x137f Minix filesystem
-0x410 beshort 0x137f Minix filesystem (big endian),
+0x410 beshort 0x137f Minix filesystem (big endian)
>0x402 beshort !0 \b, %d zones
>0x1e string minix \b, bootable
0x410 leshort 0x138f Minix filesystem, 30 char names
@@ -1025,19 +1025,42 @@
>&-1248 belong 0 TIME optimization
>&-1248 belong 1 SPACE optimization
-# ext2/ext3 filesystems - Andreas Dilger <adilger@turbolabs.com>
-0x438 leshort 0xEF53 Linux
->0x44c lelong x rev %d
->0x43e leshort x \b.%d
->0x45c lelong ^0x0000004 ext2 filesystem data
->>0x43a leshort ^0x0000001 (mounted or unclean)
->0x45c lelong &0x0000004 ext3 filesystem data
->>0x460 lelong &0x0000004 (needs journal recovery)
->0x43a leshort &0x0000002 (errors)
->0x460 lelong &0x0000001 (compressed)
-#>0x460 lelong &0x0000002 (filetype)
-#>0x464 lelong &0x0000001 (sparse_super)
->0x464 lelong &0x0000002 (large files)
+# ext2/ext3 filesystems - Andreas Dilger <adilger@dilger.ca>
+# ext4 filesystem - Eric Sandeen <sandeen@sandeen.net>
+0x438 leshort 0xEF53 Linux
+>0x44c lelong x rev %d
+>0x43e leshort x \b.%d
+# No journal? ext2
+>0x45c lelong ^0x0000004 ext2 filesystem data
+>>0x43a leshort ^0x0000001 (mounted or unclean)
+# Has a journal? ext3 or ext4
+>0x45c lelong &0x0000004
+# and small INCOMPAT?
+>>0x460 lelong <0x0000040
+# and small RO_COMPAT?
+>>>0x464 lelong <0x0000008 ext3 filesystem data
+# else large RO_COMPAT?
+>>>0x464 lelong >0x0000007 ext4 filesystem data
+# else large INCOMPAT?
+>>0x460 lelong >0x000003f ext4 filesystem data
+# General flags for any ext* fs
+>0x460 lelong &0x0000004 (needs journal recovery)
+>0x43a leshort &0x0000002 (errors)
+# INCOMPAT flags
+>0x460 lelong &0x0000001 (compressed)
+#>0x460 lelong &0x0000002 (filetype)
+#>0x460 lelong &0x0000010 (meta bg)
+>0x460 lelong &0x0000040 (extents)
+>0x460 lelong &0x0000080 (64bit)
+#>0x460 lelong &0x0000100 (mmp)
+#>0x460 lelong &0x0000200 (flex bg)
+# RO_INCOMPAT flags
+#>0x464 lelong &0x0000001 (sparse super)
+>0x464 lelong &0x0000002 (large files)
+>0x464 lelong &0x0000008 (huge files)
+#>0x464 lelong &0x0000010 (gdt checksum)
+#>0x464 lelong &0x0000020 (many subdirs)
+#>0x463 lelong &0x0000040 (extra isize)
# SGI disk labels - Nathan Scott <nathans@debian.org>
0 belong 0x0BE5A941 SGI disk label (volume header)
@@ -1115,40 +1138,42 @@
# CDROM Filesystems
# Modified for UDF by gerardo.cacciari@gmail.com
-32769 string CD001
->38913 string !NSR0 ISO 9660 CD-ROM filesystem data
->38913 string NSR0 UDF filesystem data
->>38917 string 1 (version 1.0)
->>38917 string 2 (version 1.5)
->>38917 string 3 (version 2.0)
->>38917 byte >0x33 (unknown version, ID 0x%X)
->>38917 byte <0x31 (unknown version, ID 0x%X)
+32769 string CD001
+!:mime application/x-iso9660-image
+>38913 string !NSR0 ISO 9660 CD-ROM filesystem data
+>38913 string NSR0 UDF filesystem data
+>>38917 string 1 (version 1.0)
+>>38917 string 2 (version 1.5)
+>>38917 string 3 (version 2.0)
+>>38917 byte >0x33 (unknown version, ID 0x%X)
+>>38917 byte <0x31 (unknown version, ID 0x%X)
# "application id" which appears to be used as a volume label
->32808 string >\0 '%s'
->34816 string \000CD001\001EL\ TORITO\ SPECIFICATION (bootable)
-37633 string CD001 ISO 9660 CD-ROM filesystem data (raw 2352 byte sectors)
-32776 string CDROM High Sierra CD-ROM filesystem data
+>32808 string >\0 '%s'
+>34816 string \000CD001\001EL\ TORITO\ SPECIFICATION (bootable)
+37633 string CD001 ISO 9660 CD-ROM filesystem data (raw 2352 byte sectors)
+!:mime application/x-iso9660-image
+32776 string CDROM High Sierra CD-ROM filesystem data
# cramfs filesystem - russell@coker.com.au
0 lelong 0x28cd3d45 Linux Compressed ROM File System data, little endian
->4 lelong x size %d
+>4 lelong x size %lu
>8 lelong &1 version #2
>8 lelong &2 sorted_dirs
>8 lelong &4 hole_support
>32 lelong x CRC 0x%x,
->36 lelong x edition %d,
->40 lelong x %d blocks,
->44 lelong x %d files
+>36 lelong x edition %lu,
+>40 lelong x %lu blocks,
+>44 lelong x %lu files
0 belong 0x28cd3d45 Linux Compressed ROM File System data, big endian
->4 belong x size %d
+>4 belong x size %lu
>8 belong &1 version #2
>8 belong &2 sorted_dirs
>8 belong &4 hole_support
>32 belong x CRC 0x%x,
->36 belong x edition %d,
->40 belong x %d blocks,
->44 belong x %d files
+>36 belong x edition %lu,
+>40 belong x %lu blocks,
+>44 belong x %lu files
# reiserfs - russell@coker.com.au
0x10034 string ReIsErFs ReiserFS V3.5
@@ -1241,6 +1266,34 @@
>>>2 short 2048 AXP generated)
>>>2 short 4096 I64 generated)
+# Summary: Oracle Clustered Filesystem
+# Created by: Aaron Botsis <redhat@digitalmafia.org>
+8 string OracleCFS Oracle Clustered Filesystem,
+>4 long x rev %d
+>0 long x \b.%d,
+>560 string x label: %.64s,
+>136 string x mountpoint: %.128s
+
+# Summary: Oracle ASM tagged volume
+# Created by: Aaron Botsis <redhat@digitalmafia.org>
+32 string ORCLDISK Oracle ASM Volume,
+>40 string x Disk Name: %0.12s
+32 string ORCLCLRD Oracle ASM Volume (cleared),
+>40 string x Disk Name: %0.12s
+
+# Oracle Clustered Filesystem - Aaron Botsis <redhat@digitalmafia.org>
+8 string OracleCFS Oracle Clustered Filesystem,
+>4 long x rev %d
+>0 long x \b.%d,
+>560 string x label: %.64s,
+>136 string x mountpoint: %.128s
+
+# Oracle ASM tagged volume - Aaron Botsis <redhat@digitalmafia.org>
+32 string ORCLDISK Oracle ASM Volume,
+>40 string x Disk Name: %0.12s
+32 string ORCLCLRD Oracle ASM Volume (cleared),
+>40 string x Disk Name: %0.12s
+
# Compaq/HP RILOE floppy image
# From: Dirk Jagdmann <doj@cubic.org>
0 string CPQRFBLO Compaq/HP RILOE floppy image
@@ -1259,3 +1312,18 @@
# http://filext.com/file-extension/DAA
# describes the daa file format. The magic would be:
0 string DAA\x0\x0\x0\x0\x0 PowerISO Direct-Access-Archive
+
+# From Albert Cahalan <acahalan@gmail.com>
+# really le32 operation,destination,payloadsize (but quite predictable)
+# 01 00 00 00 00 00 00 c0 00 02 00 00
+0 string \1\0\0\0\0\0\0\300\0\2\0\0 Marvell Libertas firmware
+
+# From Eric Sandeen
+# GFS2
+0x10000 belong 0x01161970 GFS2 Filesystem
+>0x10024 belong x (blocksize %d,
+>0x10060 string >\0 lockproto %s)
+
+# dvdisaster's .ecc
+# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
+0 string *dvdisaster* dvdisaster error correction file
diff --git a/Magdir/flash b/Magdir/flash
index f14b460c702e..0b985f22b7c8 100644
--- a/Magdir/flash
+++ b/Magdir/flash
@@ -8,10 +8,13 @@
#
0 string FWS Macromedia Flash data,
>3 byte x version %d
+!:mime application/x-shockwave-flash
0 string CWS Macromedia Flash data (compressed),
+!:mime application/x-shockwave-flash
>3 byte x version %d
# From: Cal Peake <cp@absolutedigital.net>
0 string FLV Macromedia Flash Video
+!:mime video/x-flv
#
# From Dave Wilson
diff --git a/Magdir/fonts b/Magdir/fonts
index cf6e0d7cc140..a6f43e74b4bf 100644
--- a/Magdir/fonts
+++ b/Magdir/fonts
@@ -1,14 +1,13 @@
-
#------------------------------------------------------------------------------
# fonts: file(1) magic for font data
#
-0 string FONT ASCII vfont text
+0 search/1 FONT ASCII vfont text
0 short 0436 Berkeley vfont data
0 short 017001 byte-swapped Berkeley vfont data
# PostScript fonts (must precede "printer" entries), quinlan@yggdrasil.com
-0 string %!PS-AdobeFont-1. PostScript Type 1 font text
->20 string >\0 (%s)
+0 search/1 %!PS-AdobeFont-1. PostScript Type 1 font text
+>20 search/1 >\0 (%s)
6 string %!PS-AdobeFont-1. PostScript Type 1 font program data
# X11 font files in SNF (Server Natural Format) format
@@ -16,7 +15,7 @@
0 lelong 00000004 X11 SNF font data, LSB first
# X11 Bitmap Distribution Format, from Daniel Quinlan (quinlan@yggdrasil.com)
-0 string STARTFONT\040 X11 BDF font text
+0 search/1 STARTFONT\ X11 BDF font text
# X11 fonts, from Daniel Quinlan (quinlan@yggdrasil.com)
# PCF must come before SGI additions ("MIPSEL MIPS-II COFF" collides)
diff --git a/Magdir/fortran b/Magdir/fortran
index ce004adb361b..3e490333e180 100644
--- a/Magdir/fortran
+++ b/Magdir/fortran
@@ -1,2 +1,3 @@
# FORTRAN source
0 string/c c\ FORTRAN program
+!:mime text/x-fortran
diff --git a/Magdir/frame b/Magdir/frame
index 1b397df05799..3699b44223fb 100644
--- a/Magdir/frame
+++ b/Magdir/frame
@@ -1,11 +1,14 @@
-
#------------------------------------------------------------------------------
# frame: file(1) magic for FrameMaker files
#
# This stuff came on a FrameMaker demo tape, most of which is
# copyright, but this file is "published" as witness the following:
#
+# Note that this is the Framemaker Maker Interchange Format, not the
+# Normal format which would be application/vnd.framemaker.
+#
0 string \<MakerFile FrameMaker document
+!:mime application/x-mif
>11 string 5.5 (5.5
>11 string 5.0 (5.0
>11 string 4.0 (4.0
@@ -14,25 +17,32 @@
>11 string 1.0 (1.0
>14 byte x %c)
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)
-0 string \<MakerDictionary FrameMaker Dictionary text
+0 search/1 \<MakerDictionary FrameMaker Dictionary text
+!:mime application/x-mif
>17 string 3.0 (3.0)
>17 string 2.0 (2.0)
>17 string 1.0 (1.x)
0 string \<MakerScreenFont FrameMaker Font file
+!:mime application/x-mif
>17 string 1.01 (%s)
0 string \<MML FrameMaker MML file
+!:mime application/x-mif
0 string \<BookFile FrameMaker Book file
+!:mime application/x-mif
>10 string 3.0 (3.0
>10 string 2.0 (2.0
>10 string 1.0 (1.0
>13 byte x %c)
# XXX - this book entry should be verified, if you find one, uncomment this
#0 string \<Book\ FrameMaker Book (ASCII) file
+#!:mime application/x-mif
#>6 string 3.0 (3.0)
#>6 string 2.0 (2.0)
#>6 string 1.0 (1.0)
0 string \<Maker Intermediate Print File FrameMaker IPL file
+!:mime application/x-mif
diff --git a/Magdir/freebsd b/Magdir/freebsd
index ee710fab5fd7..be304177702a 100644
--- a/Magdir/freebsd
+++ b/Magdir/freebsd
@@ -128,10 +128,10 @@
# What are you laughing about?
0 lelong 011421044151 ld.so hints file (Little Endian
>4 lelong >0 \b, version %d)
->4 belong <=0 \b)
+>4 belong <1 \b)
0 belong 011421044151 ld.so hints file (Big Endian
>4 belong >0 \b, version %d)
->4 belong <=0 \b)
+>4 belong <1 \b)
#
# Files generated by FreeBSD scrshot(1)/vidcontrol(1) utilities
diff --git a/Magdir/fsav b/Magdir/fsav
index 4d61bebaa292..ccc6d596c21a 100644
--- a/Magdir/fsav
+++ b/Magdir/fsav
@@ -46,7 +46,7 @@
0 string ClamAV-VDB:
>11 string >\0 Clam AntiVirus database %-.23s
>>34 string :
->>>35 regex [^:]+ \b, version
+>>>35 string !: \b, version
>>>>35 string x \b%-.1s
>>>>>36 string !:
>>>>>>36 string x \b%-.1s
@@ -54,7 +54,9 @@
>>>>>>>>37 string x \b%-.1s
>>>>>>>>>38 string !:
>>>>>>>>>>38 string x \b%-.1s
->>>>512 string \037\213 \b, gzipped
->>>>769 string ustar\0 \b, tared
>512 string \037\213 \b, gzipped
->769 string ustar\0 \b, tared
+>769 string ustar\0 \b, tarred
+
+# Type: Grisoft AVG AntiVirus
+# From: David Newgas <david@newgas.net>
+0 string AVG7_ANTIVIRUS_VAULT_FILE AVG 7 Antivirus vault file data
diff --git a/Magdir/games b/Magdir/games
index 2dc17da6c625..32ccdfeaab0c 100644
--- a/Magdir/games
+++ b/Magdir/games
@@ -1,12 +1,6 @@
#------------------------------------------------------------------------------
# games: file(1) for games
-# Thomas M. Ott (ThMO)
-1 string =WAD DOOM data,
->0 string =I main wad
->0 string =P patch wad
->0 byte x unknown junk
-
# Fabio Bonelli <fabiobonelli@libero.it>
# Quake II - III data files
0 string IDP2 Quake II 3D Model file,
@@ -29,11 +23,6 @@
# Doom and Quake
# submitted by Nicolas Patrois
-# DOOM
-
-0 string IWAD DOOM or DOOM ][ world
-0 string PWAD DOOM or DOOM ][ extension world
-
0 string \xcb\x1dBoom\xe6\xff\x03\x01 Boom or linuxdoom demo
# some doom lmp files don't match, I've got one beginning with \x6d\x02\x01\x01
@@ -155,3 +144,102 @@
0 string MComprHD MAME CHD compressed hard disk image,
>12 belong x version %lu
+
+# doom - submitted by Jon Dowland
+
+0 string =IWAD doom main IWAD data
+>4 lelong x containing %d lumps
+0 string =PWAD doom patch PWAD data
+>4 lelong x containing %d lumps
+
+
+# Summary: Warcraft 3 save
+# Extension: .w3g
+# Created by: "Nelson A. de Oliveira" <naoliv@gmail.com>
+0 string Warcraft\ III\ recorded\ game %s
+
+
+# Summary: Warcraft 3 map
+# Extension: .w3m
+# Created by: "Nelson A. de Oliveira" <naoliv@gmail.com>
+0 string HM3W Warcraft III map file
+
+
+# Summary: SGF Smart Game Format
+# Extension: .sgf
+# Reference: http://www.red-bean.com/sgf/
+# Created by: Eduardo Sabbatella <eduardo_sabbatella@yahoo.com.ar>
+# Modified by (1): Abel Cheung (regex, more game format)
+# FIXME: Some games don't have GM (game type)
+0 regex \\(;.*GM\\[[0-9]{1,2}\\] Smart Game Format
+>2 search/0x200 GM[
+>>&0 string 1] (Go)
+>>&0 string 2] (Othello)
+>>&0 string 3] (chess)
+>>&0 string 4] (Gomoku+Renju)
+>>&0 string 5] (Nine Men's Morris)
+>>&0 string 6] (Backgammon)
+>>&0 string 7] (Chinese chess)
+>>&0 string 8] (Shogi)
+>>&0 string 9] (Lines of Action)
+>>&0 string 10] (Ataxx)
+>>&0 string 11] (Hex)
+>>&0 string 12] (Jungle)
+>>&0 string 13] (Neutron)
+>>&0 string 14] (Philosopher's Football)
+>>&0 string 15] (Quadrature)
+>>&0 string 16] (Trax)
+>>&0 string 17] (Tantrix)
+>>&0 string 18] (Amazons)
+>>&0 string 19] (Octi)
+>>&0 string 20] (Gess)
+>>&0 string 21] (Twixt)
+>>&0 string 22] (Zertz)
+>>&0 string 23] (Plateau)
+>>&0 string 24] (Yinsh)
+>>&0 string 25] (Punct)
+>>&0 string 26] (Gobblet)
+>>&0 string 27] (hive)
+>>&0 string 28] (Exxit)
+>>&0 string 29] (Hnefatal)
+>>&0 string 30] (Kuba)
+>>&0 string 31] (Tripples)
+>>&0 string 32] (Chase)
+>>&0 string 33] (Tumbling Down)
+>>&0 string 34] (Sahara)
+>>&0 string 35] (Byte)
+>>&0 string 36] (Focus)
+>>&0 string 37] (Dvonn)
+>>&0 string 38] (Tamsk)
+>>&0 string 39] (Gipf)
+>>&0 string 40] (Kropki)
+
+
+# Summary: Civilization 4 video
+# Extension: .bik
+# Created by: Abel Cheung <abelcheung@gmail.com>
+0 string BIKi Civilization 4 Video
+
+
+##############################################
+# NetImmerse/Gamebryo game engine entries
+
+# Summary: Gamebryo game engine file
+# Extension: .nif, .kf
+# Created by: Abel Cheung <abelcheung@gmail.com>
+0 string Gamebryo\ File\ Format,\ Version\ Gamebryo game engine file
+>&0 regex [0-9a-z.]+ \b, version %s
+
+# Summary: Gamebryo game engine file
+# Extension: .kfm
+# Created by: Abel Cheung <abelcheung@gmail.com>
+0 string ;Gamebryo\ KFM\ File\ Version\ Gamebryo game engine animation File
+>&0 regex [0-9a-z.]+ \b, version %s
+
+# Summary: NetImmerse game engine file
+# Extension .nif
+# Created by: Abel Cheung <abelcheung@gmail.com>
+0 string NetImmerse\ File\ Format,\ Versio
+>&0 string n\ NetImmerse game engine file
+>>&0 regex [0-9a-z.]+ \b, version %s
+
diff --git a/Magdir/gimp b/Magdir/gimp
index 9a9d61e2f79c..674bbfba62e2 100644
--- a/Magdir/gimp
+++ b/Magdir/gimp
@@ -34,3 +34,7 @@
# ('Bucky' LaDieu, nega@vt.edu)
20 string GIMP GIMP brush data
+
+# GIMP Curves File
+# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
+0 string #\040GIMP\040Curves\040File GIMP curve file
diff --git a/Magdir/gnome-keyring b/Magdir/gnome-keyring
new file mode 100644
index 000000000000..80a4f882c167
--- /dev/null
+++ b/Magdir/gnome-keyring
@@ -0,0 +1,23 @@
+# GNOME keyring
+# Contributed by Josh Triplett
+# FIXME: Could be simplified if pstring supported two-byte counts
+0 string GnomeKeyring\n\r\0\n GNOME keyring
+>&0 ubyte 0 \b, major version 0
+>>&0 ubyte 0 \b, minor version 0
+>>>&0 ubyte 0 \b, crypto type 0 (AEL)
+>>>&0 ubyte >0 \b, crypto type %hhu (unknown)
+>>>&1 ubyte 0 \b, hash type 0 (MD5)
+>>>&1 ubyte >0 \b, hash type %hhu (unknown)
+>>>&2 ubelong 0xFFFFFFFF \b, name NULL
+>>>&2 ubelong !0xFFFFFFFF
+>>>>&-4 ubelong >255 \b, name too long for file's pstring type
+>>>>&-4 ubelong <256
+>>>>>&-1 pstring x \b, name "%s"
+>>>>>>&0 ubeqdate x \b, last modified %s
+>>>>>>&8 ubeqdate x \b, created %s
+>>>>>>&16 ubelong &1
+>>>>>>>&0 ubelong x \b, locked if idle for %u seconds
+>>>>>>&16 ubelong ^1 \b, not locked if idle
+>>>>>>&24 ubelong x \b, hash iterations %u
+>>>>>>&28 ubequad x \b, salt %llu
+>>>>>>&52 ubelong x \b, %u item(s)
diff --git a/Magdir/gnu b/Magdir/gnu
index 42d9c7bc68e4..66c670c55fa7 100644
--- a/Magdir/gnu
+++ b/Magdir/gnu
@@ -17,10 +17,14 @@
# The format is very similar to pgp
0 string \001gpg GPG key trust database
>4 byte x version %d
+# Note: magic.mime had 0x8501 for the next line instead of 0x8502
0 beshort 0x8502 GPG encrypted data
+!:mime text/PGP # encoding: data
+
# This magic is not particularly good, as the keyrings don't have true
# magic. Nevertheless, it covers many keyrings.
0 beshort 0x9901 GPG key public ring
+!:mime application/x-gnupg-keyring
# Gnumeric spreadsheet
# This entry is only semi-helpful, as Gnumeric compresses its files, so
@@ -32,3 +36,7 @@
0 string \0LOCATE GNU findutils locate database data
>7 string >\0 \b, format %s
>7 string 02 \b (frcode)
+
+# Files produced by GNU gettext
+0 long 0xDE120495 GNU-format message catalog data
+0 long 0x950412DE GNU-format message catalog data
diff --git a/Magdir/gnumeric b/Magdir/gnumeric
new file mode 100644
index 000000000000..76dfa90684eb
--- /dev/null
+++ b/Magdir/gnumeric
@@ -0,0 +1,7 @@
+
+#------------------------------------------------------------------------------
+# gnumeric: file(1) magic for Gnumeric spreadsheet
+# This entry is only semi-helpful, as Gnumeric compresses its files, so
+# they will ordinarily reported as "compressed", but at least -z helps
+39 string =<gmr:Workbook Gnumeric spreadsheet
+!:mime application/x-gnumeric
diff --git a/Magdir/graphviz b/Magdir/graphviz
new file mode 100644
index 000000000000..cf47f4e28c84
--- /dev/null
+++ b/Magdir/graphviz
@@ -0,0 +1,7 @@
+
+#------------------------------------------------------------------------------
+# graphviz: file(1) magic for http://www.graphviz.org/
+0 regex/100 [\r\n\t\ ]*graph[\r\n\t\ ]*.*\\{ graphviz graph text
+!:mime text/vnd.graphviz
+0 regex/100 [\r\n\t\ ]*digraph[\r\n\t\ ]*.*\\{ graphviz digraph text
+!:mime text/vnd.graphviz
diff --git a/Magdir/hp b/Magdir/hp
index 052f09a23996..2d064cc9971a 100644
--- a/Magdir/hp
+++ b/Magdir/hp
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# hp: file(1) magic for Hewlett Packard machines (see also "printer")
#
@@ -202,34 +201,40 @@
0 string msgcat01 HP NLS message catalog,
>8 long >0 %d messages
-# addendum to /etc/magic with HP-48sx file-types by phk@data.fls.dk 1jan92
-0 string HPHP48- HP48 binary
->7 byte >0 - Rev %c
->8 beshort 0x1129 (ADR)
->8 beshort 0x3329 (REAL)
->8 beshort 0x5529 (LREAL)
->8 beshort 0x7729 (COMPLX)
->8 beshort 0x9d29 (LCOMPLX)
->8 beshort 0xbf29 (CHAR)
->8 beshort 0xe829 (ARRAY)
->8 beshort 0x0a2a (LNKARRAY)
->8 beshort 0x2c2a (STRING)
->8 beshort 0x4e2a (HXS)
->8 beshort 0x742a (LIST)
->8 beshort 0x962a (DIR)
->8 beshort 0xb82a (ALG)
->8 beshort 0xda2a (UNIT)
->8 beshort 0xfc2a (TAGGED)
->8 beshort 0x1e2b (GROB)
->8 beshort 0x402b (LIB)
->8 beshort 0x622b (BACKUP)
->8 beshort 0x882b (LIBDATA)
->8 beshort 0x9d2d (PROG)
->8 beshort 0xcc2d (CODE)
->8 beshort 0x482e (GNAME)
->8 beshort 0x6d2e (LNAME)
->8 beshort 0x922e (XLIB)
-0 string %%HP: HP48 text
+# Summary: HP-48/49 calculator
+# Created by: phk@data.fls.dk
+# Modified by (1): AMAKAWA Shuhei <sa264@cam.ac.uk>
+# Modified by (2): Samuel Thibault <samuel.thibault@ens-lyon.org> (HP49 support)
+0 string HPHP HP
+>4 string 48 48 binary
+>4 string 49 49 binary
+>7 byte >64 - Rev %c
+>8 leshort 0x2911 (ADR)
+>8 leshort 0x2933 (REAL)
+>8 leshort 0x2955 (LREAL)
+>8 leshort 0x2977 (COMPLX)
+>8 leshort 0x299d (LCOMPLX)
+>8 leshort 0x29bf (CHAR)
+>8 leshort 0x29e8 (ARRAY)
+>8 leshort 0x2a0a (LNKARRAY)
+>8 leshort 0x2a2c (STRING)
+>8 leshort 0x2a4e (HXS)
+>8 leshort 0x2a74 (LIST)
+>8 leshort 0x2a96 (DIR)
+>8 leshort 0x2ab8 (ALG)
+>8 leshort 0x2ada (UNIT)
+>8 leshort 0x2afc (TAGGED)
+>8 leshort 0x2b1e (GROB)
+>8 leshort 0x2b40 (LIB)
+>8 leshort 0x2b62 (BACKUP)
+>8 leshort 0x2b88 (LIBDATA)
+>8 leshort 0x2d9d (PROG)
+>8 leshort 0x2dcc (CODE)
+>8 leshort 0x2e48 (GNAME)
+>8 leshort 0x2e6d (LNAME)
+>8 leshort 0x2e92 (XLIB)
+
+0 string %%HP: HP text
>6 string T(0) - T(0)
>6 string T(1) - T(1)
>6 string T(2) - T(2)
@@ -240,6 +245,45 @@
>14 string F(.) F(.);
>14 string F(,) F(,);
+
+# Summary: HP-38/39 calculator
+# Created by: Samuel Thibault <samuel.thibault@ens-lyon.org>
+0 string HP3
+>3 string 8 HP 38
+>3 string 9 HP 39
+>4 string Bin binary
+>4 string Asc ASCII
+>7 string A (Directory List)
+>7 string B (Zaplet)
+>7 string C (Note)
+>7 string D (Program)
+>7 string E (Variable)
+>7 string F (List)
+>7 string G (Matrix)
+>7 string H (Library)
+>7 string I (Target List)
+>7 string J (ASCII Vector specification)
+>7 string K (wildcard)
+
+# Summary: HP-38/39 calculator
+# Created by: Samuel Thibault <samuel.thibault@ens-lyon.org>
+0 string HP3
+>3 string 8 HP 38
+>3 string 9 HP 39
+>4 string Bin binary
+>4 string Asc ASCII
+>7 string A (Directory List)
+>7 string B (Zaplet)
+>7 string C (Note)
+>7 string D (Program)
+>7 string E (Variable)
+>7 string F (List)
+>7 string G (Matrix)
+>7 string H (Library)
+>7 string I (Target List)
+>7 string J (ASCII Vector specification)
+>7 string K (wildcard)
+
# hpBSD magic numbers
0 beshort 200 hp200 (68010) BSD
>2 beshort 0407 impure binary
@@ -390,6 +434,4 @@
>>>>>>>>>0xC4 belong 33 - received SIGXCPU
>>>>>>>>>0xC4 belong 34 - received SIGXFSZ
-# From: AMAKAWA Shuhei <sa264@cam.ac.uk>
-0 string HPHP49- HP49 binary
diff --git a/Magdir/iff b/Magdir/iff
index 3c88f9039c1f..4d2a832c6e95 100644
--- a/Magdir/iff
+++ b/Magdir/iff
@@ -13,8 +13,11 @@
#>4 belong x \b, FORM is %d bytes long
# audio formats
>8 string AIFF \b, AIFF audio
+!:mime audio/x-aiff
>8 string AIFC \b, AIFF-C compressed audio
+!:mime audio/x-aiff
>8 string 8SVX \b, 8SVX 8-bit sampled sound voice
+!:mime audio/x-aiff
>8 string 16SV \b, 16SV 16-bit sampled sound voice
>8 string SAMP \b, SAMP sampled audio
>8 string MAUD \b, MAUD MacroSystem audio
diff --git a/Magdir/images b/Magdir/images
index fd9e14f9fd2b..cccc70be5035 100644
--- a/Magdir/images
+++ b/Magdir/images
@@ -1,6 +1,6 @@
-
#------------------------------------------------------------------------------
-# images: file(1) magic for image formats (see also "iff")
+# images: file(1) magic for image formats (see also "iff", and "c-lang" for
+# XPM bitmaps)
#
# originally from jef@helios.ee.lbl.gov (Jef Poskanzer),
# additions by janl@ifi.uio.no as well as others. Jan also suggested
@@ -30,13 +30,20 @@
# PBMPLUS images
# The next byte following the magic is always whitespace.
-0 string P1 Netpbm PBM image text
-0 string P2 Netpbm PGM image text
-0 string P3 Netpbm PPM image text
+0 search/1 P1 Netpbm PBM image text
+!:mime image/x-portable-bitmap
+0 search/1 P2 Netpbm PGM image text
+!:mime image/x-portable-greymap
+0 search/1 P3 Netpbm PPM image text
+!:mime image/x-portable-pixmap
0 string P4 Netpbm PBM "rawbits" image data
+!:mime image/x-portable-bitmap
0 string P5 Netpbm PGM "rawbits" image data
+!:mime image/x-portable-greymap
0 string P6 Netpbm PPM "rawbits" image data
+!:mime image/x-portable-pixmap
0 string P7 Netpbm PAM image file
+!:mime image/x-portable-pixmap
# From: bryanh@giraffe-data.com (Bryan Henderson)
0 string \117\072 Solitaire Image Recorder format
@@ -50,13 +57,17 @@
>21 byte 51 version 3
# NIFF (Navy Interchange File Format, a modification of TIFF) images
+# [GRR: this *must* go before TIFF]
0 string IIN1 NIFF image data
+!:mime image/x-niff
# Tag Image File Format, from Daniel Quinlan (quinlan@yggdrasil.com)
# The second word of TIFF files is the TIFF version number, 42, which has
# never changed. The TIFF specification recommends testing for it.
0 string MM\x00\x2a TIFF image data, big-endian
+!:mime image/tiff
0 string II\x2a\x00 TIFF image data, little-endian
+!:mime image/tiff
# PNG [Portable Network Graphics, or "PNG's Not GIF"] images
# (Greg Roelofs, newt@uchicago.edu)
@@ -64,24 +75,41 @@
#
# 137 P N G \r \n ^Z \n [4-byte length] H E A D [HEAD data] [HEAD crc] ...
#
-0 string \x89PNG PNG image data,
->4 belong !0x0d0a1a0a CORRUPTED,
->4 belong 0x0d0a1a0a
->>16 belong x %ld x
->>20 belong x %ld,
->>24 byte x %d-bit
->>25 byte 0 grayscale,
->>25 byte 2 \b/color RGB,
->>25 byte 3 colormap,
->>25 byte 4 gray+alpha,
->>25 byte 6 \b/color RGBA,
-#>>26 byte 0 deflate/32K,
->>28 byte 0 non-interlaced
->>28 byte 1 interlaced
-1 string PNG PNG image data, CORRUPTED
+0 string \x89PNG\x0d\x0a\x1a\x0a PNG image
+!:mime image/png
+>16 belong x \b, %ld x
+>20 belong x %ld,
+>24 byte x %d-bit
+>25 byte 0 grayscale,
+>25 byte 2 \b/color RGB,
+>25 byte 3 colormap,
+>25 byte 4 gray+alpha,
+>25 byte 6 \b/color RGBA,
+#>26 byte 0 deflate/32K,
+>28 byte 0 non-interlaced
+>28 byte 1 interlaced
+
+# possible GIF replacements; none yet released!
+# (Greg Roelofs, newt@uchicago.edu)
+#
+# GRR 950115: this was mine ("Zip GIF"):
+0 string GIF94z ZIF image (GIF+deflate alpha)
+!:mime image/x-unknown
+#
+# GRR 950115: this is Jeremy Wohl's Free Graphics Format (better):
+#
+0 string FGF95a FGF image (GIF+deflate beta)
+!:mime image/x-unknown
+#
+# GRR 950115: this is Thomas Boutell's Portable Bitmap Format proposal
+# (best; not yet implemented):
+#
+0 string PBF PBF image (deflate compression)
+!:mime image/x-unknown
# GIF
0 string GIF8 GIF image data
+!:mime image/gif
>4 string 7a \b, version 8%s,
>4 string 9a \b, version 8%s,
>6 leshort >0 %hd x
@@ -113,7 +141,7 @@
>4 long 3 \b, rectangular 32-bit (24-bit with matte)
# FIG (Facility for Interactive Generation of figures), an object-based format
-0 string #FIG FIG image text
+0 search/1 #FIG FIG image text
>5 string x \b, version %.3s
# PHIGS
@@ -129,9 +157,6 @@
# CGM image files
0 string BEGMF clear text Computer Graphics Metafile
-# XXX - questionable magic
-0 beshort&0xffe0 0x0020 binary Computer Graphics Metafile
-0 beshort 0x3020 character Computer Graphics Metafile
# MGR bitmaps (Michael Haardt, u31b3hs@pool.informatik.rwth-aachen.de)
0 string yz MGR bitmap, modern format, 8-bit aligned
@@ -152,15 +177,23 @@
0 string Sfff structured fax file
-# PC bitmaps (OS/2, Windoze BMP files) (Greg Roelofs, newt@uchicago.edu)
-0 string BM PC bitmap data
->14 leshort 12 \b, OS/2 1.x format
+# PC bitmaps (OS/2, Windows BMP files) (Greg Roelofs, newt@uchicago.edu)
+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 \b, OS/2 2.x format
+>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 \b, Windows 3.x format
+>14 leshort 40 PC bitmap, Windows 3.x format
+!:mime image/x-ms-bmp
+>>18 lelong x \b, %d x
+>>22 lelong x %d x
+>>28 leshort x %d
+>14 leshort 128 PC bitmap, Windows NT/2000 format
+!:mime image/x-ms-bmp
>>18 lelong x \b, %d x
>>22 lelong x %d x
>>28 leshort x %d
@@ -174,7 +207,7 @@
# XPM icons (Greg Roelofs, newt@uchicago.edu)
# note possible collision with C/REXX entry in c-lang; currently commented out
-0 string /*\ XPM\ */ X pixmap image text
+0 search/1 /*\ XPM\ */ X pixmap image text
# Utah Raster Toolkit RLE images (janl@ifi.uio.no)
0 leshort 0xcc52 RLE image data,
@@ -260,7 +293,6 @@
# other images
0 string This\ is\ a\ BitMap\ file Lisp Machine bit-array-file
-0 string =!! Bennet Yee's "face" format
# From SunOS 5.5.1 "/etc/magic" - appeared right before Sun raster image
# stuff.
@@ -269,6 +301,7 @@
# DICOM medical imaging data
128 string DICM DICOM medical imaging data
+!:mime application/dicom
# XWD - X Window Dump file.
# As described in /usr/X11R6/include/X11/XWDFile.h
@@ -367,6 +400,7 @@
# Adobe Photoshop
0 string 8BPS Adobe Photoshop Image
+!:mime image/vnd.adobe.photoshop
# XV thumbnail indicator (ThMO)
0 string P7\ 332 XV thumbnail image data
@@ -456,9 +490,9 @@
>12 long x \b, track size %d bytes
>16 byte x \b, device type 33%2.2X
-# Squeak images and - etoffi@softhome.net
-0 string \146\031\0\0 Squeak image data
-0 string 'From\040Squeak Squeak program text
+# Squeak images and programs - etoffi@softhome.net
+0 string \146\031\0\0 Squeak image data
+0 search/1 'From\040Squeak Squeak program text
# partimage: file(1) magic for PartImage files (experimental, incomplete)
# Author: Hans-Joachim Baader <hjb@pro-linux.de>
@@ -505,12 +539,18 @@
# http://www.dalibor.cz/minolta/raw_file_format.htm
0 string \000MRM Minolta Dimage camera raw image data
-# From: stephane.loeuillet@tiscali.f
-# http://www.djvuzone.org/
-0 string AT&TFORM DjVu Image file
+# Summary: DjVu image / document
+# Extension: .djvu
+# Reference: http://djvu.org/docs/DjVu3Spec.djvu
+# Submitted by: Stephane Loeuillet <stephane.loeuillet@tiscali.fr>
+# Modified by (1): Abel Cheung <abelcheung@gmail.com>
+0 string AT&TFORM
+!:mime image/vnd.djvu
+>12 string DJVM DjVu multiple page document
+>12 string DJVU DjVu image or single page document
+>12 string DJVI DjVu shared document
+>12 string THUM DjVu page thumbnails
-# From: Jason Bacon <bacon@smithers.neuro.mcw.edu>
-0 beshort 0x3020 character Computer Graphics Metafile
# From Marc Espie
0 lelong 20000630 OpenEXR image data
@@ -523,9 +563,40 @@
# Hierarchical Data Format, used to facilitate scientific data exchange
# specifications at http://hdf.ncsa.uiuc.edu/
0 belong 0x0e031301 Hierarchical Data Format (version 4) data
+!:mime application/x-hdf
0 string \211HDF\r\n\032 Hierarchical Data Format (version 5) data
+!:mime application/x-hdf
# From: Tobias Burnus <burnus@net-b.de>
# Xara (for a while: Corel Xara) is a graphic package, see
-# http://www.xara.com/ for Windows and as GPL application for
+# http://www.xara.com/ for Windows and as GPL application for Linux
0 string XARA\243\243 Xara graphics file
+
+# http://www.cartesianinc.com/Tech/
+0 string CPC\262 Cartesian Perceptual Compression image
+!:mime image/x-cpi
+
+# From Albert Cahalan <acahalan@gmail.com>
+# puredigital used it for the CVS disposable camcorder
+#8 lelong 4 ZBM bitmap image data
+#>4 leshort x %u x
+#>6 leshort x %u
+
+# From Albert Cahalan <acahalan@gmail.com>
+# uncompressed 5:6:5 HighColor image for OLPC XO firmware icons
+0 string C565 OLPC firmware icon image data
+>4 leshort x %u x
+>6 leshort x %u
+
+# Applied Images - Image files from Cytovision
+# Gustavo Junior Alves <gjalves@gjalves.com.br>
+0 string \xce\xda\xde\xfa Cytovision Metaphases file
+0 string \xed\xad\xef\xac Cytovision Karyotype file
+0 string \x0b\x00\x03\x00 Cytovision FISH Probe file
+0 string \xed\xfe\xda\xbe Cytovision FLEX file
+0 string \xed\xab\xed\xfe Cytovision FLEX file
+0 string \xad\xfd\xea\xad Cytovision RATS file
+
+# Wavelet Scalar Quantization format used in gray-scale fingerprint images
+# From Tano M Fotang <mfotang@quanteq.com>
+0 string \xff\xa0\xff\xa8\x00 Wavelet Scalar Quantization image data
diff --git a/Magdir/inform b/Magdir/inform
new file mode 100644
index 000000000000..ba35d61e046c
--- /dev/null
+++ b/Magdir/inform
@@ -0,0 +1,8 @@
+
+#------------------------------------------------------------------------------
+# inform: file(1) magic for Inform interactive fiction language
+
+# URL: http://www.inform-fiction.org/
+# From: Reuben Thomas <rrt@sc3d.org>
+
+0 search/cB/100 constant\ story Inform source text
diff --git a/Magdir/java b/Magdir/java
index 971b72ceb3a4..cca5542c1f69 100644
--- a/Magdir/java
+++ b/Magdir/java
@@ -9,8 +9,9 @@
>2 beshort >0x0004 \b, version %d
0 belong 0xfeedfeed Java KeyStore
-
+!:mime application/x-java-keystore
0 belong 0xcececece Java JCE KeyStore
+!:mime application/x-java-jce-keystore
# Dalvik .dex format. http://retrodev.com/android/dexformat.html
# From <mkf@google.com> "Mike Fleming"
diff --git a/Magdir/jpeg b/Magdir/jpeg
index af646d6fb920..d728de6e6f7f 100644
--- a/Magdir/jpeg
+++ b/Magdir/jpeg
@@ -9,6 +9,8 @@
# both of which turn into "JPEG image data" here.
#
0 beshort 0xffd8 JPEG image data
+!:mime image/jpeg
+!:strength +1
>6 string JFIF \b, JFIF standard
# The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06
# in a vain attempt to add image size reporting for JFIF. Note that these
@@ -125,6 +127,8 @@
# At least we can show a comment if no other segments got inserted before:
>(4.S+5) byte 0xFE
>>(4.S+8) string >\0 \b, comment: "%s"
+# FIXME: When we can do non-byte counted strings, we can use that to get
+# the string's count, and fix Debian bug #283760
#>(4.S+5) byte 0xFE \b, comment
#>>(4.S+6) beshort x \b length=%d
#>>(4.S+8) string >\0 \b, "%s"
@@ -153,3 +157,8 @@
# From: David Santinoli <david@santinoli.com>
0 string \x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A JPEG 2000 image data
+
+# Type: JPEG 2000 codesream
+# From: Mathieu Malaterre <mathieu.malaterre@gmail.com>
+0 belong 0xff4fff51 JPEG 2000 codestream
+45 beshort 0xff52
diff --git a/Magdir/kde b/Magdir/kde
new file mode 100644
index 000000000000..d81ee693fd5e
--- /dev/null
+++ b/Magdir/kde
@@ -0,0 +1,10 @@
+
+#------------------------------------------------------------------------------
+# kde: file(1) magic for KDE
+
+0 string [KDE\ Desktop\ Entry] KDE desktop entry
+!:mime application/x-kdelnk
+0 string #\ KDE\ Config\ File KDE config file
+!:mime application/x-kdelnk
+0 string #\ xmcd xmcd database file for kscd
+!:mime text/x-xmcd
diff --git a/Magdir/lex b/Magdir/lex
index 7b6d0f74a400..eae9b107c231 100644
--- a/Magdir/lex
+++ b/Magdir/lex
@@ -1,11 +1,10 @@
-
#------------------------------------------------------------------------------
# lex: file(1) magic for lex
#
# derived empirically, your offsets may vary!
-53 string yyprevious C program text (from lex)
->3 string >\0 for %s
+0 search/100 yyprevious C program text (from lex)
+>3 search/1 >\0 for %s
# C program text from GNU flex, from Daniel Quinlan <quinlan@yggdrasil.com>
-21 string generated\ by\ flex C program text (from flex)
+0 search/100 generated\ by\ flex C program text (from flex)
# lex description file, from Daniel Quinlan <quinlan@yggdrasil.com>
-0 string %{ lex description text
+0 search/1 %{ lex description text
diff --git a/Magdir/linux b/Magdir/linux
index fe68013a1653..aaedff42d86f 100644
--- a/Magdir/linux
+++ b/Magdir/linux
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# linux: file(1) magic for Linux files
#
@@ -84,7 +83,7 @@
# Linux kernel boot images (i386 arch) (Wolfram Kleff)
514 string HdrS Linux kernel
>510 leshort 0xAA55 x86 boot executable
->>518 leshort >=0x200
+>>518 leshort >0x1ff
>>529 byte 0 zImage,
>>>529 byte 1 bzImage,
>>>(526.s+0x200) string >\0 version %s,
@@ -103,16 +102,18 @@
>0x1e9 string Loading from prehistoric times
# System.map files - Nicolás Lichtmaier <nick@debian.org>
-8 string \ A\ _text Linux kernel symbol map text
+8 search/1 \ A\ _text Linux kernel symbol map text
# LSM entries - Nicolás Lichtmaier <nick@debian.org>
-0 string Begin3 Linux Software Map entry text
-0 string Begin4 Linux Software Map entry text (new format)
+0 search/1 Begin3 Linux Software Map entry text
+0 search/1 Begin4 Linux Software Map entry text (new format)
-# From Matt Zimmerman
-0 belong 0x4f4f4f4d User-mode Linux COW file
->4 belong x \b, version %d
->8 string >\0 \b, backing file %s
+# From Matt Zimmerman, enhanced for v3 by Matthew Palmer
+0 belong 0x4f4f4f4d User-mode Linux COW file
+>4 belong <3 \b, version %d
+>>8 string >\0 \b, backing file %s
+>4 belong >2 \b, version %d
+>>32 string >\0 \b, backing file %s
############################################################################
# Linux kernel versions
@@ -230,6 +231,14 @@
0x618 string LVM2\ 001 LVM2 (Linux Logical Volume Manager)
>(0x614.l+0x600) string >\0 , UUID: %s
+# LVM snapshot
+# from Jason Farrel
+0 string SnAp LVM Snapshot (CopyOnWrite store)
+>4 lelong !0 - valid,
+>4 lelong 0 - invalid,
+>8 lelong x version %d,
+>12 lelong x chunk_size %d
+
# SE Linux policy database
0 lelong 0xf97cff8c SE Linux policy
>16 lelong x v%d
@@ -246,3 +255,10 @@
>72 string x %s]
>168 string x UUID: %s
+
+# Summary: Xen saved domain file
+# Created by: Radek Vokal <rvokal@redhat.com>
+0 string LinuxGuestRecord Xen saved domain
+>20 search/256 (name
+>>&1 string x (name %s)
+
diff --git a/Magdir/lisp b/Magdir/lisp
index e9c8ba8ec4e6..60b740a86a7a 100644
--- a/Magdir/lisp
+++ b/Magdir/lisp
@@ -1,44 +1,52 @@
-
#------------------------------------------------------------------------------
# lisp: file(1) magic for lisp programs
#
# various lisp types, from Daniel Quinlan (quinlan@yggdrasil.com)
# updated by Joerg Jenderek
-0 string ;;
+# GRR: This lot is too weak
+#0 string ;;
# windows INF files often begin with semicolon and use CRLF as line end
# lisp files are mainly created on unix system with LF as line end
->2 search/2048 !\r Lisp/Scheme program text
->2 search/2048 \r Windows INF file
+#>2 search/2048 !\r Lisp/Scheme program text
+#>2 search/2048 \r Windows INF file
0 search/256 (if\ Lisp/Scheme program text
+!:mime text/x-lisp
0 search/256 (setq\ Lisp/Scheme program text
+!:mime text/x-lisp
0 search/256 (defvar\ Lisp/Scheme program text
+!:mime text/x-lisp
0 search/256 (defparam\ Lisp/Scheme program text
+!:mime text/x-lisp
0 search/256 (defun\ Lisp/Scheme program text
+!:mime text/x-lisp
0 search/256 (autoload\ Lisp/Scheme program text
+!:mime text/x-lisp
0 search/256 (custom-set-variables\ Lisp/Scheme program text
+!:mime text/x-lisp
# Emacs 18 - this is always correct, but not very magical.
0 string \012( Emacs v18 byte-compiled Lisp data
+!:mime application/x-elc
# Emacs 19+ - ver. recognition added by Ian Springer
-# Also applies to XEmacs 19+ .elc files; could tell them apart if we had regexp
-# support or similar - Chris Chittleborough <cchittleborough@yahoo.com.au>
-0 string ;ELC
->4 byte >19
+# Also applies to XEmacs 19+ .elc files; could tell them apart with regexs
+# - Chris Chittleborough <cchittleborough@yahoo.com.au>
+0 string ;ELC
+>4 byte >18
>4 byte <32 Emacs/XEmacs v%d byte-compiled Lisp data
+!:mime application/x-elc
# Files produced by CLISP Common Lisp From: Bruno Haible <haible@ilog.fr>
-0 string (SYSTEM::VERSION\040' CLISP byte-compiled Lisp program text
+0 string (SYSTEM::VERSION\040' CLISP byte-compiled Lisp program (pre 2004-03-27)
+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
-
#.com and .bin for MIT scheme
0 string \372\372\372\372 MIT scheme (library?)
# From: David Allouche <david@allouche.net>
-0 string \<TeXmacs| TeXmacs document text
+0 search/1 \<TeXmacs| TeXmacs document text
+!:mime text/texmacs
diff --git a/Magdir/llvm b/Magdir/llvm
new file mode 100644
index 000000000000..8c1610cd10e6
--- /dev/null
+++ b/Magdir/llvm
@@ -0,0 +1,10 @@
+
+#------------------------------------------------------------------------------
+# llvm: file(1) magic for LLVM byte-codes
+# URL: http://llvm.cs.uiuc.edu/docs/BytecodeFormat.html#signature
+# From: Al Stone <ahs3@fc.hp.com>
+
+0 string llvm LLVM byte-codes, uncompressed
+0 string llvc0 LLVM byte-codes, null compression
+0 string llvc1 LLVM byte-codes, gzip compression
+0 string llvc2 LLVM byte-codes, bzip2 compression
diff --git a/Magdir/lua b/Magdir/lua
new file mode 100644
index 000000000000..9aa87b159c22
--- /dev/null
+++ b/Magdir/lua
@@ -0,0 +1,19 @@
+#------------------------------------------------------------------------------
+# lua: file(1) magic for Lua scripting language
+# URL: http://www.lua.org/
+# From: Reuben Thomas <rrt@sc3d.org>, Seo Sanghyeon <tinuviel@sparcs.kaist.ac.kr>
+
+# Lua scripts
+0 search/1/b #!\ /usr/bin/lua Lua script text executable
+!:mime text/x-lua
+0 search/1/b #!\ /usr/local/bin/lua Lua script text executable
+!:mime text/x-lua
+0 search/1 #!/usr/bin/env\ lua Lua script text executable
+!:mime text/x-lua
+0 search/1 #!\ /usr/bin/env\ lua Lua script text executable
+!:mime text/x-lua
+
+# Lua bytecode
+0 string \033Lua Lua bytecode,
+>4 byte 0x50 version 5.0
+>4 byte 0x51 version 5.1
diff --git a/Magdir/luks b/Magdir/luks
new file mode 100644
index 000000000000..2ab23935ef69
--- /dev/null
+++ b/Magdir/luks
@@ -0,0 +1,12 @@
+
+#------------------------------------------------------------------------------
+# luks: file(1) magic for Linux Unified Key Setup
+# URL: http://luks.endorphin.org/spec
+# From: Anthon van der Neut <anthon@mnt.org>
+
+0 string LUKS\xba\xbe LUKS encrypted file,
+>6 beshort x ver %d
+>8 string x [%s,
+>40 string x %s,
+>72 string x %s]
+>168 string x UUID: %s
diff --git a/Magdir/macintosh b/Magdir/macintosh
index 4acd5c88e170..77187a398d67 100644
--- a/Magdir/macintosh
+++ b/Magdir/macintosh
@@ -5,6 +5,7 @@
# 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
+!:mime application/mac-binhex40
>41 string x \b, version %.3s
# Stuffit archives are the de facto standard of compression for Macintosh
@@ -18,37 +19,41 @@
# Newer StuffIt archives (grant@netbsd.org)
0 string StuffIt StuffIt Archive
+!:mime application/x-stuffit
#>162 string >0 : %s
# Macintosh Applications and Installation binaries (franklsm@tuns.ca)
-0 string APPL Macintosh Application (data)
->2 string x \b: %s
+# GRR: Too weak
+#0 string APPL Macintosh Application (data)
+#>2 string x \b: %s
# Macintosh System files (franklsm@tuns.ca)
-0 string zsys Macintosh System File (data)
-0 string FNDR Macintosh Finder (data)
-0 string libr Macintosh Library (data)
->2 string x : %s
-0 string shlb Macintosh Shared Library (data)
->2 string x : %s
-0 string cdev Macintosh Control Panel (data)
->2 string x : %s
-0 string INIT Macintosh Extension (data)
->2 string x : %s
-0 string FFIL Macintosh Truetype Font (data)
->2 string x : %s
-0 string LWFN Macintosh Postscript Font (data)
->2 string x : %s
+# GRR: Too weak
+#0 string zsys Macintosh System File (data)
+#0 string FNDR Macintosh Finder (data)
+#0 string libr Macintosh Library (data)
+#>2 string x : %s
+#0 string shlb Macintosh Shared Library (data)
+#>2 string x : %s
+#0 string cdev Macintosh Control Panel (data)
+#>2 string x : %s
+#0 string INIT Macintosh Extension (data)
+#>2 string x : %s
+#0 string FFIL Macintosh Truetype Font (data)
+#>2 string x : %s
+#0 string LWFN Macintosh Postscript Font (data)
+#>2 string x : %s
# Additional Macintosh Files (franklsm@tuns.ca)
-0 string PACT Macintosh Compact Pro Archive (data)
->2 string x : %s
-0 string ttro Macintosh TeachText File (data)
->2 string x : %s
-0 string TEXT Macintosh TeachText File (data)
->2 string x : %s
-0 string PDF Macintosh PDF File (data)
->2 string x : %s
+# GRR: Too weak
+#0 string PACT Macintosh Compact Pro Archive (data)
+#>2 string x : %s
+#0 string ttro Macintosh TeachText File (data)
+#>2 string x : %s
+#0 string TEXT Macintosh TeachText File (data)
+#>2 string x : %s
+#0 string PDF Macintosh PDF File (data)
+#>2 string x : %s
# MacBinary format (Eric Fischer, enf@pobox.com)
#
@@ -320,41 +325,50 @@
# shorter than 32 bytes must be terminated with NULL" so I'll treat it as a
# cstring. Of course, partitions can contain more than four entries, but
# what're you gonna do?
-0x200 beshort 0x504D Apple Partition data
->0x2 beshort x block size: %d,
->0x230 string x first type: %s,
->0x210 string x name: %s,
->0x254 belong x number of blocks: %d,
->0x400 beshort 0x504D
->>0x430 string x second type: %s,
->>0x410 string x name: %s,
->>0x454 belong x number of blocks: %d,
->>0x800 beshort 0x504D
->>>0x830 string x third type: %s,
->>>0x810 string x name: %s,
->>>0x854 belong x number of blocks: %d,
->>>0xa00 beshort 0x504D
->>>>0xa30 string x fourth type: %s,
->>>>0xa10 string x name: %s,
->>>>0xa54 belong x number of blocks: %d
-# AFAIK, only the signature is different
-0x200 beshort 0x5453 Apple Old Partition data
->0x2 beshort x block size: %d,
->0x230 string x first type: %s,
->0x210 string x name: %s,
->0x254 belong x number of blocks: %d,
->0x400 beshort 0x504D
->>0x430 string x second type: %s,
->>0x410 string x name: %s,
->>0x454 belong x number of blocks: %d,
->>0x800 beshort 0x504D
->>>0x830 string x third type: %s,
->>>0x810 string x name: %s,
->>>0x854 belong x number of blocks: %d,
->>>0xa00 beshort 0x504D
->>>>0xa30 string x fourth type: %s,
->>>>0xa10 string x name: %s,
->>>>0xa54 belong x number of blocks: %d
+# GRR: This magic is too weak, it is just "PM"
+#0x200 beshort 0x504D Apple Partition data
+#>0x2 beshort x (block size: %d):
+#>0x230 string x first type: %s,
+#>0x210 string x name: %s,
+#>0x254 belong x number of blocks: %d,
+#>0x400 beshort 0x504D
+#>>0x430 string x second type: %s,
+#>>0x410 string x name: %s,
+#>>0x454 belong x number of blocks: %d,
+#>>0x600 beshort 0x504D
+#>>>0x630 string x third type: %s,
+#>>>0x610 string x name: %s,
+#>>>0x654 belong x number of blocks: %d,
+#>>0x800 beshort 0x504D
+#>>>0x830 string x fourth type: %s,
+#>>>0x810 string x name: %s,
+#>>>0x854 belong x number of blocks: %d,
+#>>>0xa00 beshort 0x504D
+#>>>>0xa30 string x fifth type: %s,
+#>>>>0xa10 string x name: %s,
+#>>>>0xa54 belong x number of blocks: %d
+#>>>0xc00 beshort 0x504D
+#>>>>0xc30 string x sixth type: %s,
+#>>>>0xc10 string x name: %s,
+#>>>>0xc54 belong x number of blocks: %d
+## AFAIK, only the signature is different
+#0x200 beshort 0x5453 Apple Old Partition data
+#>0x2 beshort x block size: %d,
+#>0x230 string x first type: %s,
+#>0x210 string x name: %s,
+#>0x254 belong x number of blocks: %d,
+#>0x400 beshort 0x504D
+#>>0x430 string x second type: %s,
+#>>0x410 string x name: %s,
+#>>0x454 belong x number of blocks: %d,
+#>>0x800 beshort 0x504D
+#>>>0x830 string x third type: %s,
+#>>>0x810 string x name: %s,
+#>>>0x854 belong x number of blocks: %d,
+#>>>0xa00 beshort 0x504D
+#>>>>0xa30 string x fourth type: %s,
+#>>>>0xa10 string x name: %s,
+#>>>>0xa54 belong x number of blocks: %d
# From: Remi Mommsen <mommsen@slac.stanford.edu>
0 string BOMStore Mac OS X bill of materials (BOM) file
diff --git a/Magdir/mail.news b/Magdir/mail.news
index f08261ca3a6e..0b9d90a4e20a 100644
--- a/Magdir/mail.news
+++ b/Magdir/mail.news
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# mail.news: file(1) magic for mail and news
#
@@ -6,17 +5,28 @@
#0 string From mail text
# There are tests to ascmagic.c to cope with mail and news.
0 string Relay-Version: old news text
+!:mime message/rfc822
0 string #!\ rnews batched news text
+!:mime message/rfc822
0 string N#!\ rnews mailed, batched news text
+!:mime message/rfc822
0 string Forward\ to mail forwarding text
+!:mime message/rfc822
0 string Pipe\ to mail piping text
+!:mime message/rfc822
0 string Return-Path: smtp mail text
+!:mime message/rfc822
0 string Path: news text
+!:mime message/news
0 string Xref: news text
+!:mime message/news
0 string From: news or mail text
+!:mime message/rfc822
0 string Article saved news text
+!:mime message/news
0 string BABYL Emacs RMAIL text
0 string Received: RFC 822 mail text
+!:mime message/rfc822
0 string MIME-Version: MIME entity text
#0 string Content- MIME entity text
@@ -39,3 +49,5 @@
# XXX: Weak magic
#256 leshort 0xAFAE4453 Squish message area data file
#>4 leshort >0 (%d messages)
+
+#0 string \<!--\ MHonArc text/html; x-type=mhonarc
diff --git a/Magdir/mathcad b/Magdir/mathcad
new file mode 100644
index 000000000000..41801968888e
--- /dev/null
+++ b/Magdir/mathcad
@@ -0,0 +1,7 @@
+
+#------------------------------------------------------------------------------
+# mathcad: file(1) magic for Mathcad documents
+# URL: http://www.mathsoft.com/
+# From: Josh Triplett <josh@freedesktop.org>
+
+0 string .MCAD\t Mathcad document
diff --git a/Magdir/mathematica b/Magdir/mathematica
index 0eca5d415d68..abbc1125e0b0 100644
--- a/Magdir/mathematica
+++ b/Magdir/mathematica
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# mathematica: file(1) magic for mathematica files
# "H. Nanosecond" <aldomel@ix.netcom.com>
@@ -56,7 +55,8 @@
0 string (*********************** Mathematica 3.0 notebook
# other (* matches it is a comment start in these langs
-0 string (* Mathematica, or Pascal, Modula-2 or 3 code text
+# GRR: Too weak; also matches other languages e.g. ML
+#0 string (* Mathematica, or Pascal, Modula-2 or 3 code text
#########################
# MatLab v5
diff --git a/Magdir/mercurial b/Magdir/mercurial
new file mode 100644
index 000000000000..3f1bdfc8f9cc
--- /dev/null
+++ b/Magdir/mercurial
@@ -0,0 +1,12 @@
+
+#------------------------------------------------------------------------------
+# mercurial: file(1) magic for Mercurial changeset bundles
+# http://www.selenic.com/mercurial/wiki/
+#
+# Jesse Glick (jesse.glick@sun.com)
+#
+
+0 string HG10 Mercurial changeset bundle
+>4 string UN (uncompressed)
+>4 string GZ (gzip compressed)
+>4 string BZ (bzip2 compressed)
diff --git a/Magdir/misctools b/Magdir/misctools
index bb995bad65c9..9a43e7b4e390 100644
--- a/Magdir/misctools
+++ b/Magdir/misctools
@@ -1,13 +1,21 @@
#-----------------------------------------------------------------------------
-# misctools: file(1) magic for miscelanous UNIX tools.
+# misctools: file(1) magic for miscellaneous UNIX tools.
#
-0 string %%!! X-Post-It-Note text
+0 search/1 %%!! X-Post-It-Note text
0 string/c BEGIN:VCALENDAR vCalendar calendar file
0 string/c BEGIN:VCARD vCard visiting card
+!:mime text/x-vcard
# From: Alex Beregszaszi <alex@fsn.hu>
4 string gtktalog GNOME Catalogue (gtktalog)
>13 string >\0 version %s
-# From: Tomasz Trojanowski <tomek@uninet.com.pl>
+# Summary: Libtool library file
+# Extension: .la
+# Submitted by: Tomasz Trojanowski <tomek@uninet.com.pl>
0 search/80 .la\ -\ a\ libtool\ library\ file libtool library file
+
+# Summary: Libtool object file
+# Extension: .lo
+# Submitted by: Abel Cheung <abelcheung@gmail.com>
+0 search/80 .lo\ -\ a\ libtool\ object\ file libtool object file
diff --git a/Magdir/mozilla b/Magdir/mozilla
new file mode 100644
index 000000000000..069886064fbc
--- /dev/null
+++ b/Magdir/mozilla
@@ -0,0 +1,8 @@
+
+#------------------------------------------------------------------------------
+# mozilla: file(1) magic for Mozilla XUL fastload files
+# (XUL.mfasl and XPC.mfasl)
+# URL: http://www.mozilla.org/
+# From: Josh Triplett <josh@freedesktop.org>
+
+0 string XPCOM\nMozFASL\r\n\x1A Mozilla XUL fastload data
diff --git a/Magdir/msdos b/Magdir/msdos
index 10ce8aefc045..cdd7c931c985 100644
--- a/Magdir/msdos
+++ b/Magdir/msdos
@@ -7,9 +7,13 @@
# updated by Joerg Jenderek
0 string @
>1 string/cB \ echo\ off MS-DOS batch file text
+!:mime text/x-msdos-batch
>1 string/cB echo\ off MS-DOS batch file text
+!:mime text/x-msdos-batch
>1 string/cB rem\ MS-DOS batch file text
+!:mime text/x-msdos-batch
>1 string/cB set\ MS-DOS batch file text
+!:mime text/x-msdos-batch
# OS/2 batch files are REXX. the second regex is a bit generic, oh well
@@ -39,13 +43,15 @@
#
# Required OS version and subsystem version were 4.0 on some NT 3.51
# executables built with Visual C++ 4.0, so it's not clear that
-# they're interesting. The user version was 0.0, but there's
+# they're interesting. The user version was 0.0, but there's
# probably some linker directive to set it. The linker version was
# 3.0, except for one ".exe" which had it as 4.20 (same damn linker!).
#
# many of the compressed formats were extraced from IDARC 1.23 source code
#
-0 string MZ MS-DOS executable
+0 string MZ
+!:mime application/x-dosexec
+>0x18 leshort <0x40 MS-DOS executable
>0 string MZ\0\0\0\0\0\0\0\0\0\0PE\0\0 \b, PE for MS Windows
>>&18 leshort&0x2000 >0 (DLL)
>>&88 leshort 0 (unknown subsystem)
@@ -64,29 +70,42 @@
>>&18 leshort&0x1000 >0 system file
>>&0xf4 search/0x140 \x0\x40\x1\x0
>>>(&0.l+(4)) string MSCF \b, WinHKI CAB self-extracting archive
+>30 string Copyright\ 1989-1990\ PKWARE\ Inc. Self-extracting PKZIP archive
+!:mime application/zip
+# Is next line correct? One might expect "Corp." not "Copr." If it is right, add a note to that effect.
+>30 string PKLITE\ Copr. Self-extracting PKZIP archive
+!:mime application/zip
>0x18 leshort >0x3f
->>(0x3c.l) string PE\0\0 PE
+>>(0x3c.l) string PE\0\0 PE
+>>>(0x3c.l+25) byte 1 \b32 executable
+>>>(0x3c.l+25) byte 2 \b32+ executable
# 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 for MS-DOS, 32rtm DOS extender
->>>(8.s*16) string !32STUB for MS Windows
->>>>(0x3c.l+22) leshort&0x2000 >0 (DLL)
->>>>(0x3c.l+92) leshort 0 (unknown subsystem)
->>>>(0x3c.l+92) leshort 1 (native)
->>>>(0x3c.l+92) leshort 2 (GUI)
->>>>(0x3c.l+92) leshort 3 (console)
->>>>(0x3c.l+92) leshort 7 (POSIX)
->>>>(0x3c.l+4) leshort 0x0 unknown processor
->>>>(0x3c.l+4) leshort 0x14c Intel 80386
->>>>(0x3c.l+4) leshort 0x166 MIPS R4000
->>>>(0x3c.l+4) leshort 0x184 Alpha
->>>>(0x3c.l+4) leshort 0x268 Motorola 68000
->>>>(0x3c.l+4) leshort 0x1f0 PowerPC
->>>>(0x3c.l+4) leshort 0x290 PA-RISC
->>>>(0x3c.l+22) leshort&0x0100 >0 32-bit
->>>>(0x3c.l+22) leshort&0x1000 >0 system file
->>>>(0x3c.l+232) lelong >0 Mono/.Net assembly
+>>>(0x3c.l+92) leshort <10
+>>>>(8.s*16) string 32STUB for MS-DOS, 32rtm DOS extender
+>>>>(8.s*16) string !32STUB for MS Windows
+>>>>>(0x3c.l+22) leshort&0x2000 >0 (DLL)
+>>>>>(0x3c.l+92) leshort 0 (unknown subsystem)
+>>>>>(0x3c.l+92) leshort 1 (native)
+>>>>>(0x3c.l+92) leshort 2 (GUI)
+>>>>>(0x3c.l+92) leshort 3 (console)
+>>>>>(0x3c.l+92) leshort 7 (POSIX)
+>>>(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 (XBOX)
+>>>(0x3c.l+4) leshort 0x0 unknown processor
+>>>(0x3c.l+4) leshort 0x14c Intel 80386
+>>>(0x3c.l+4) leshort 0x166 MIPS R4000
+>>>(0x3c.l+4) leshort 0x184 Alpha
+>>>(0x3c.l+4) leshort 0x268 Motorola 68000
+>>>(0x3c.l+4) leshort 0x1f0 PowerPC
+>>>(0x3c.l+4) leshort 0x290 PA-RISC
+>>>(0x3c.l+4) leshort 0x200 Intel Itanium
+>>>(0x3c.l+22) leshort&0x0100 >0 32-bit
+>>>(0x3c.l+22) leshort&0x1000 >0 system file
+>>>(0x3c.l+232) lelong >0 Mono/.Net assembly
>>>>(0x3c.l+0xf8) string UPX0 \b, UPX compressed
>>>>(0x3c.l+0xf8) search/0x140 PEC2 \b, PECompact2 compressed
@@ -115,6 +134,8 @@
>>>>&(0x3c.l+0xf8) search/0x100 SharedD \b, Microsoft Installer self-extracting archive
>>>>0x30 string Inno \b, InnoSetup self-extracting archive
+>>(0x3c.l) string !PE\0\0 MS-DOS executable
+
>>(0x3c.l) string NE \b, NE
>>>(0x3c.l+0x36) byte 0 (unknown OS)
>>>(0x3c.l+0x36) byte 1 for OS/2 1.x
@@ -176,7 +197,7 @@
>>>(4.s*512) leshort !0x014c \b, MZ for MS-DOS
# header data too small for extended executable
>2 long !0
->>0x18 leshort <0x40
+>>0x18 leshort <0x40
>>>(4.s*512) leshort !0x014c
>>>>&(2.s-514) string !LE
@@ -206,29 +227,31 @@
# .EXE formats (Greg Roelofs, newt@uchicago.edu)
#
->0x35 string \x8e\xc0\xb9\x08\x00\xf3\xa5\x4a\x75\xeb\x8e\xc3\x8e\xd8\x33\xff\xbe\x30\x00\x05 \b, aPack compressed
+>0x35 string \x8e\xc0\xb9\x08\x00\xf3\xa5\x4a\x75\xeb\x8e\xc3\x8e\xd8\x33\xff\xbe\x30\x00\x05 \b, aPack compressed
>0xe7 string LH/2\ Self-Extract \b, %s
>0x1c string diet \b, diet compressed
>0x1c string LZ09 \b, LZEXE v0.90 compressed
>0x1c string LZ91 \b, LZEXE v0.91 compressed
->0x1c string tz \b, TinyProg compressed
+>0x1c string tz \b, TinyProg compressed
>0x1e string PKLITE \b, %s compressed
->0x64 string W\ Collis\0\0 \b, Compack compressed
+>0x64 string W\ Collis\0\0 \b, Compack compressed
>0x24 string LHa's\ SFX \b, LHa self-extracting archive
+!:mime application/x-lha
>0x24 string LHA's\ SFX \b, LHa self-extracting archive
->0x24 string \ $ARX \b, ARX self-extracting archive
->0x24 string \ $LHarc \b, LHarc self-extracting archive
->0x20 string SFX\ by\ LARC \b, LARC self-extracting archive
+!:mime application/x-lha
+>0x24 string \ $ARX \b, ARX self-extracting archive
+>0x24 string \ $LHarc \b, LHarc self-extracting archive
+>0x20 string SFX\ by\ LARC \b, LARC self-extracting archive
>1638 string -lh5- \b, LHa self-extracting archive v2.13S
->0x17888 string Rar! \b, RAR self-extracting archive
->0x40 string aPKG \b, aPackage self-extracting archive
+>0x17888 string Rar! \b, RAR self-extracting archive
+>0x40 string aPKG \b, aPackage self-extracting archive
->32 string AIN
->>35 string 2 \b, AIN 2.x compressed
->>35 string <2 \b, AIN 1.x compressed
->>35 string >2 \b, AIN 1.x compressed
->28 string UC2X \b, UCEXE compressed
->28 string WWP\ \b, WWPACK compressed
+>32 string AIN
+>>35 string 2 \b, AIN 2.x compressed
+>>35 string <2 \b, AIN 1.x compressed
+>>35 string >2 \b, AIN 1.x compressed
+>28 string UC2X \b, UCEXE compressed
+>28 string WWP\ \b, WWPACK compressed
# skip to the end of the exe
>(4.s*512) long x
@@ -255,15 +278,15 @@
# TELVOX Teleinformatica CODEC self-extractor for OS/2:
>49801 string \x79\xff\x80\xff\x76\xff \b, CODEC archive v3.21
->>49824 leshort =1 \b, 1 file
->>49824 leshort >1 \b, %u files
+>>49824 leshort =1 \b, 1 file
+>>49824 leshort >1 \b, %u files
# .COM formats (Daniel Quinlan, quinlan@yggdrasil.com)
# Uncommenting only the first two lines will cover about 2/3 of COM files,
# but it isn't feasible to match all COM files since there must be at least
# two dozen different one-byte "magics".
-0 byte 0xe9 DOS executable (COM)
->0x1FE leshort 0xAA55 \b, boot code
+#0 byte 0xe9 DOS executable (COM)
+#>0x1FE leshort 0xAA55 \b, boot code
>6 string SFX\ of\ LHarc (%s)
0 belong 0xffffffff DOS executable (device driver)
#CMD640X2.SYS
@@ -286,25 +309,25 @@
>>77 string >\x40
>>>77 string <\x5B
>>>>77 string x \b, name: %.8s
-0 byte 0x8c DOS executable (COM)
+#0 byte 0x8c DOS executable (COM)
# 0xeb conflicts with "sequent" magic
-0 byte 0xeb DOS executable (COM)
->0x1FE leshort 0xAA55 \b, boot code
->85 string UPX \b, UPX compressed
->4 string \ $ARX \b, ARX self-extracting archive
->4 string \ $LHarc \b, LHarc self-extracting archive
->0x20e string SFX\ by\ LARC \b, LARC self-extracting archive
-0 byte 0xb8 COM executable
+#0 byte 0xeb DOS executable (COM)
+#>0x1FE leshort 0xAA55 \b, boot code
+#>85 string UPX \b, UPX compressed
+#>4 string \ $ARX \b, ARX self-extracting archive
+#>4 string \ $LHarc \b, LHarc self-extracting archive
+#>0x20e string SFX\ by\ LARC \b, LARC self-extracting archive
+#0 byte 0xb8 COM executable
# modified by Joerg Jenderek
->1 lelong !0x21cd4cff for DOS
+>1 lelong !0x21cd4cff for DOS
# http://syslinux.zytor.com/comboot.php
# (32-bit COMBOOT) programs *.C32 contain 32-bit code and run in flat-memory 32-bit protected mode
# start with assembler instructions mov eax,21cd4cffh
->1 lelong 0x21cd4cff (32-bit COMBOOT)
+>1 lelong 0x21cd4cff (32-bit COMBOOT)
0 string \x81\xfc
>4 string \x77\x02\xcd\x20\xb9
->>36 string UPX! FREE-DOS executable (COM), UPX compressed
-252 string Must\ have\ DOS\ version DR-DOS executable (COM)
+>>36 string UPX! FREE-DOS executable (COM), UPX compressed
+252 string Must\ have\ DOS\ version DR-DOS executable (COM)
# GRR search is not working
#2 search/28 \xcd\x21 COM executable for MS-DOS
#WHICHFAT.cOM
@@ -341,14 +364,6 @@
#0 byte 0xf0 MS-DOS program library data
#
-#
-# Windows Registry files.
-# updated by Joerg Jenderek
-0 string regf Windows NT/XP registry file
-0 string CREG Windows 95/98/ME registry file
-0 string SHCC3 Windows 3.1 registry file
-
-
# AAF files:
# <stuartc@rd.bbc.co.uk> Stuart Cunningham
0 string \320\317\021\340\241\261\032\341AAFB\015\000OM\006\016\053\064\001\001\001\377 AAF legacy file using MS Structured Storage
@@ -360,54 +375,73 @@
# 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
+!:mime application/msword
#
-0 string PO^Q` Microsoft Word 6.0 Document
+0 string PO^Q` Microsoft Word 6.0 Document
+!:mime application/msword
#
0 string \376\067\0\043 Microsoft Office Document
+!:mime application/msword
0 string \333\245-\0\0\0 Microsoft Office Document
+!:mime application/msword
+512 string \354\245\301 Microsoft Word Document
+!:mime application/msword
#
2080 string Microsoft\ Excel\ 5.0\ Worksheet %s
+!:mime application/vnd.ms-excel
+
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 \x09\x04\x06\x00\x00\x00\x10\x00 Microsoft Excel Worksheet
+!:mime application/vnd.ms-excel
#
0 belong 0x00001a00 Lotus 1-2-3
+!:mime application/x-123
>4 belong 0x00100400 wk3 document data
>4 belong 0x02100400 wk4 document data
>4 belong 0x07800100 fm3 or fmb document data
>4 belong 0x07800000 fm3 or fmb document data
#
-0 belong 0x00000200 Lotus 1-2-3
+0 belong 0x00000200 Lotus 1-2-3
+!:mime application/x-123
>4 belong 0x06040600 wk1 document data
>4 belong 0x06800200 fmt document data
+0 string WordPro\0 Lotus WordPro
+!:mime application/vnd.lotus-wordpro
+0 string WordPro\r\373 Lotus WordPro
+!:mime application/vnd.lotus-wordpro
-# Help files
-0 string ?_\3\0 MS Windows Help Data
-# DeIsL1.isu what this is I don't know
-0 string \161\250\000\000\001\002 DeIsL1.isu whatever that is
+# Summary: Script used by InstallScield to uninstall applications
+# Extension: .isu
+# Submitted by: unknown
+# Modified by (1): Abel Cheung <abelcheung@gmail.com> (replace useless entry)
+0 string \x71\xa8\x00\x00\x01\x02
+>12 string Stirling\ Technologies, InstallShield Uninstall Script
# Winamp .avs
-#0 string Nullsoft\ AVS\ Preset\ \060\056\061\032 A plug in for Winamp ms-windows Freeware media player
+#0 string Nullsoft\ AVS\ Preset\ \060\056\061\032 A plug in for Winamp ms-windows Freeware media player
0 string Nullsoft\ AVS\ Preset\ Winamp plug in
-# Hyper terminal:
-0 string HyperTerminal\ hyperterm
->15 string 1.0\ --\ HyperTerminal\ data\ file MS-windows Hyperterminal
-
# Windows Metafont .WMF
-0 string \327\315\306\232 ms-windows metafont .wmf
-0 string \002\000\011\000 ms-windows metafont .wmf
-0 string \001\000\011\000 ms-windows metafont .wmf
+0 string \327\315\306\232 ms-windows metafont .wmf
+0 string \002\000\011\000 ms-windows metafont .wmf
+0 string \001\000\011\000 ms-windows metafont .wmf
#tz3 files whatever that is (MS Works files)
0 string \003\001\001\004\070\001\000\000 tz3 ms-works file
@@ -427,21 +461,12 @@
0 string MDIF\032\000\010\000\000\000\372\046\100\175\001\000\001\036\001\000 MS Windows special zipped file
-# Windows help file FTG FTS
-0 string \164\146\115\122\012\000\000\000\001\000\000\000 MS Windows help cache
-
-# grp old windows 3.1 group files
-0 string \120\115\103\103 MS Windows 3.1 group files
-
-
-# lnk files windows symlinks
-0 string \114\000\000\000\001\024\002\000\000\000\000\000\300\000\000\000\000\000\000\106 MS Windows shortcut
-
#ico files
0 string \102\101\050\000\000\000\056\000\000\000\000\000\000\000 Icon for MS Windows
# Windows icons (Ian Springer <ips@fpk.hp.com>)
0 string \000\000\001\000 MS Windows icon resource
+!:mime image/x-ico
>4 byte 1 - 1 icon
>4 byte >1 - %d icons
>>6 byte >0 \b, %dx
@@ -462,18 +487,27 @@
# then there is a copyright notice
-# recycled/info the windows trash bin index
-9 string \000\000\000\030\001\000\000\000 MS Windows recycled bin info
+# Windows Recycle Bin record file (named INFO2)
+# By Abel Cheung (abelcheung AT gmail dot com)
+# Version 4 always has 280 bytes (0x118) per record, version 5 has 800 bytes
+# Since Vista uses another structure, INFO2 structure probably won't change
+# anymore. Detailed analysis in:
+# http://www.cybersecurityinstitute.biz/downloads/INFO2.pdf
+0 lelong 0x00000004
+>12 lelong 0x00000118 Windows Recycle Bin INFO2 file (Win98 or below)
+
+0 lelong 0x00000005
+>12 lelong 0x00000320 Windows Recycle Bin INFO2 file (Win2k - WinXP)
##### put in Either Magic/font or Magic/news
-# Acroread or something files wrongly identified as G3 .pfm
+# Acroread or something files wrongly identified as G3 .pfm
# these have the form \000 \001 any? \002 \000 \000
# or \000 \001 any? \022 \000 \000
-#0 string \000\001 pfm?
-#>3 string \022\000\000Copyright\ yes
-#>3 string \002\000\000Copyright\ yes
-#>3 string >\0 oops, not a font file. Cancel that.
+#0 string \000\001 pfm?
+#>3 string \022\000\000Copyright\ yes
+#>3 string \002\000\000Copyright\ yes
+#>3 string >\0 oops, not a font file. Cancel that.
#it clashes with ttf files so put it lower down.
# From Doug Lee via a FreeBSD pr
@@ -516,10 +550,12 @@
>>>>24 long >0 length %d
# TNEF magic From "Joomy" <joomy@se-ed.net>
+# Microsoft Outlook's Transport Neutral Encapsulation Format (TNEF)
0 leshort 0x223e9f78 TNEF
+!:mime application/vnd.ms-tnef
# HtmlHelp files (.chm)
-0 string ITSF\003\000\000\000\x60\000\000\000\001\000\000\000 MS Windows HtmlHelp Data
+0 string ITSF\003\000\000\000\x60\000\000\000\001\000\000\000 MS Windows HtmlHelp Data
# GFA-BASIC (Wolfram Kleff)
2 string GFA-BASIC3 GFA-BASIC 3 data
@@ -534,8 +570,8 @@
# InstallShield Cabinet files
0 string ISc( InstallShield Cabinet archive data
->5 byte&0xf0 =0x60 version 6,
->5 byte&0xf0 !0x60 version 4/5,
+>5 byte&0xf0 =0x60 version 6,
+>5 byte&0xf0 !0x60 version 4/5,
>(12.l+40) lelong x %u files
# Windows CE package files
@@ -549,57 +585,27 @@
>20 lelong 10004 \b, Hitachi SH3E
>20 lelong 10005 \b, Hitachi SH4
>20 lelong 70001 \b, ARM 7TDMI
->52 leshort 1 \b, 1 file
->52 leshort >1 \b, %u files
->56 leshort 1 \b, 1 registry entry
->56 leshort >1 \b, %u registry entries
-
-# Outlook Personal Folders
-0 lelong 0x4E444221 Microsoft Outlook binary email folder
->10 leshort 0x0e (Outlook <=2002)
->10 leshort 0x17 (Outlook >=2003)
-
-
-# From: Dirk Jagdmann <doj@cubic.org>
-0 lelong 0x00035f3f Windows 3.x help file
-
-# Christophe Monniez
-0 string Client\ UrlCache\ MMF Microsoft Internet Explorer Cache File
->20 string >\0 Version %s
-0 string \xCF\xAD\x12\xFE Microsoft Outlook Express DBX File
->4 byte =0xC5 Message database
->4 byte =0xC6 Folder database
->4 byte =0xC7 Accounts informations
->4 byte =0x30 Offline database
+>52 leshort 1 \b, 1 file
+>52 leshort >1 \b, %u files
+>56 leshort 1 \b, 1 registry entry
+>56 leshort >1 \b, %u registry entries
# Windows Enhanced Metafile (EMF)
# See msdn.microsoft.com/archive/en-us/dnargdi/html/msdn_enhmeta.asp
-# for further information. Note that "0 lelong 1" should be true i.e.
-# the first double word in the file should be 1. With the extended
-# syntax available by some file commands you could write:
-# 0 lelong 1
-# &40 ulelong 0x464D4520 Windows Enhanced Metafile (EMF) image data
-40 ulelong 0x464D4520 Windows Enhanced Metafile (EMF) image data
->44 ulelong x version 0x%x.
-# If the description has a length greater than zero, it exists and is
-# found at offset (*64).
->64 ulelong >0 Description available at offset 0x%x
->>60 ulelong >0 (length 0x%x)
-# Note it would be better to print out the description, which is found
-# as below. Unfortunately the following only prints out the first couple
-# of characters instead of all the "description length"
-# number of characters -- indicated by the ulelong at offset 60.
->>(64.l) lestring16 >0 Description: %15.15s
+# for further information.
+0 ulelong 1
+>40 string \ EMF Windows Enhanced Metafile (EMF) image data
+>>44 ulelong x version 0x%x
# From: Alex Beregszaszi <alex@fsn.hu>
0 string COWD VMWare3
->4 byte 3 disk image
+>4 byte 3 disk image
>>32 lelong x (%d/
>>36 lelong x \b%d/
>>40 lelong x \b%d)
->4 byte 2 undoable disk image
->>32 string >\0 (%s)
+>4 byte 2 undoable disk image
+>>32 string >\0 (%s)
0 string VMDK VMware4 disk image
0 string KDMV VMware4 disk image
@@ -609,39 +615,39 @@
# Lines written by Friedrich Schwittay (f.schwittay@yousable.de)
# Made by reading sources and doing trial and error on existing
# qcow files
-0 string QFI Qemu Image, Format: Qcow
+0 string QFI Qemu Image, Format: Qcow
# Uncomment the following line to display Magic (only used for debugging
# this magic number)
-#>0 string x , Magic: %s
+#>0 string x , Magic: %s
# There are currently 2 Versions: "1" and "2"
# I do not use Version 2 and therefor branch here
# but can assure: it works (tested on both versions)
# Also my Qemu 0.9.0 which uses this Version 2 refuses
# to start in its bios
->0x04 belong 2 , Version: 2
->0x04 belong 1 , Version: 1
+>0x04 belong 2 , Version: 2
+>0x04 belong 1 , Version: 1
# Using the existence of the Backing File Offset to Branch or not
# to read Backing File Information
->>0xc belong >0 , Backing File( Offset: %d
->>>(0xc.L) string >\0 , Path: %s
+>>0xc belong >0 , Backing File( Offset: %lu
+>>>(0xc.L) string >\0 , Path: %s
-# Didnt got the Trick here how qemu stores the "Size" at this Position
+# Didn't get the trick here how qemu stores the "Size" at this Position
# There is actually something stored but nothing makes sense
# The header in the sources talks about it
-#>>>16 lelong x , Size: %d
+#>>>16 lelong x , Size: %lu
# Modification time of the Backing File
-# Really usefull if you want to know if your backing
+# Really useful if you want to know if your backing
# file is still usable together with this image
->>>20 bedate x , Mtime: %s )
+>>>20 bedate x , Mtime: %s )
-# Dont know how to calculate in Magicfiles
+# Don't know how to calculate in Magicfiles
# Also: this Information is not reliably
-# stored in image-files
->>24 lelong x , Disk Size could be: %d * 256 bytes
+# stored in image-files
+>>24 lelong x , Disk Size could be: %d * 256 bytes
0 string QEVM QEMU's suspend to disk image
@@ -652,9 +658,21 @@
0 lelong 0x02468ace Bochs Sparse disk image
# from http://filext.com by Derek M Jones <derek@knosof.co.uk>
-# False positive with PPT
-#0 string \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 Microsoft Installer
+# False positive with PPT (also currently this string is too long)
+#0 string \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 \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
+!:mime application/msword
+>546 string jbjb Microsoft Word Document
+!:mime application/msword
+
+0 string \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
@@ -663,3 +681,20 @@
>23 string Dell %s system BIOS
>48 string x version %.3s
+# Type: Microsoft DirectDraw Surface
+# URL: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/DDSFileReference/ddsfileformat.asp
+# From: Morten Hustveit <morten@debian.org>
+0 string DDS\040\174\000\000\000 Microsoft DirectDraw Surface (DDS),
+>16 lelong >0 %hd x
+>12 lelong >0 %hd,
+>84 string x %.4s
+
+# Type: Microsoft Document Imaging Format (.mdi)
+# URL: http://en.wikipedia.org/wiki/Microsoft_Document_Imaging_Format
+# From: Daniele Sempione <scrows@oziosi.org>
+0 short 0x5045 Microsoft Document Imaging Format
+
+# MS eBook format (.lit)
+0 string ITOLITLS Microsoft Reader eBook Data
+>8 lelong x \b, version %u
+!:mime application/x-ms-reader
diff --git a/Magdir/mup b/Magdir/mup
index fd9a7b1353b5..f1022e39b0b3 100644
--- a/Magdir/mup
+++ b/Magdir/mup
@@ -8,7 +8,7 @@
# compatibility. Noteedit also use mup format, but is not forcing
# user to use any header as well.
#
-0 string //!Mup Mup music publication program input text
+0 search/1 //!Mup Mup music publication program input text
>6 string -Arkkra (Arkkra)
>>13 string -
>>>16 string .
diff --git a/Magdir/netware b/Magdir/netware
new file mode 100644
index 000000000000..fbc16054a32b
--- /dev/null
+++ b/Magdir/netware
@@ -0,0 +1,6 @@
+
+#------------------------------------------------------------------------------
+# netware: file(1) magic for NetWare Loadable Modules (NLMs)
+# From: Mads Martin Joergensen <mmj@suse.de>
+
+0 string NetWare\ Loadable\ Module NetWare Loadable Module
diff --git a/Magdir/ole2compounddocs b/Magdir/ole2compounddocs
new file mode 100644
index 000000000000..ee07514ec5bb
--- /dev/null
+++ b/Magdir/ole2compounddocs
@@ -0,0 +1,13 @@
+
+#------------------------------------------------------------------------------
+# Microsoft OLE 2 Compound Documents : file(1) magic for Microsoft Structured
+# storage (http://en.wikipedia.org/wiki/Structured_Storage)
+# Additional tests for OLE 2 Compound Documents should be under this recipe.
+
+0 string \320\317\021\340\241\261\032\341 OLE 2 Compound Document
+# - Microstation V8 DGN files (www.bentley.com)
+# Last update on 10/23/2006 by Lester Hightower
+> 0x480 string D\000g\000n\000~\000H : Microstation V8 DGN
+# - Visio documents
+# Last update on 10/23/2006 by Lester Hightower
+> 0x480 string V\000i\000s\000i\000o\000D\000o\000c : Visio Document
diff --git a/Magdir/os2 b/Magdir/os2
index 99dd63aeabe7..35f79ef4ba6f 100644
--- a/Magdir/os2
+++ b/Magdir/os2
@@ -1,12 +1,11 @@
-
#------------------------------------------------------------------------------
# os2: file(1) magic for OS/2 files
#
# Provided 1998/08/22 by
# David Mediavilla <davidme.news@REMOVEIFNOTSPAMusa.net>
-1 string InternetShortcut MS Windows 95 Internet shortcut text
->24 string >\ (URL=<%s>)
+1 search/1 InternetShortcut MS Windows 95 Internet shortcut text
+>24 search/1 >\ (URL=<%s>)
# OS/2 URL objects
# Provided 1998/08/22 by
diff --git a/Magdir/palm b/Magdir/palm
index 79af1f00c36f..e57e119b5419 100644
--- a/Magdir/palm
+++ b/Magdir/palm
@@ -45,7 +45,7 @@
>0 string >\0 "%s"
60 string SM01SMem SuperMemo PalmOS document
>0 string >\0 "%s"
-60 string DataTlPt TealDoc PalmOS document
+60 string TEXtTlDc TealDoc PalmOS document
>0 string >\0 "%s"
60 string InfoTlIf TealInfo PalmOS document
>0 string >\0 "%s"
diff --git a/Magdir/pdf b/Magdir/pdf
index e90214efb9a6..8a4d2e7eba75 100644
--- a/Magdir/pdf
+++ b/Magdir/pdf
@@ -3,11 +3,12 @@
#
0 string %PDF- PDF document
+!:mime application/pdf
>5 byte x \b, version %c
>7 byte x \b.%c
# From: Nick Schmalenberger <nick@schmalenberger.us>
# Forms Data Format
-0 string %FDF- FDF text
+0 string %FDF- FDF document
>5 byte x \b, version %c
>7 byte x \b.%c
diff --git a/Magdir/perl b/Magdir/perl
index a8daee4c647c..73fb88ba4b28 100644
--- a/Magdir/perl
+++ b/Magdir/perl
@@ -1,26 +1,32 @@
-
#------------------------------------------------------------------------------
# perl: file(1) magic for Larry Wall's perl language.
#
-# The ``eval'' line recognizes an outrageously clever hack for USG systems.
+# The `eval' lines recognizes an outrageously clever hack.
# Keith Waclena <keith@cerberus.uchicago.edu>
# Send additions to <perl5-porters@perl.org>
-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
-0 string eval\ '(exit\ $?0)'\ &&\ eval\ 'exec perl script text
+0 search/1/b #!\ /bin/perl Perl script text executable
+!:mime text/x-perl
+0 search/1 eval\ "exec\ /bin/perl Perl script text
+!:mime text/x-perl
+0 search/1/b #!\ /usr/bin/perl Perl script text executable
+!:mime text/x-perl
+0 search/1 eval\ "exec\ /usr/bin/perl Perl script text
+!:mime text/x-perl
+0 search/1/b #!\ /usr/local/bin/perl Perl script text executable
+!:mime text/x-perl
+0 search/1 eval\ "exec\ /usr/local/bin/perl Perl script text
+!:mime text/x-perl
+0 search/1 eval\ '(exit\ $?0)'\ &&\ eval\ 'exec Perl script text
+!:mime text/x-perl
# by Dmitry V. Levin and Alexey Tourbin
# check the first line
-0 string package
->1 regex \^package[\ \t]+[A-Za-z_]
->>1 regex \^package[\ \t]+[0-9A-Za-z_:]*\ *; Perl5 module source text
+0 search/1 package
+0 regex \^package[\ \t]+[A-Za-z_]
+>0 regex \^package[\ \t]+[0-9A-Za-z_:]+\ *; Perl5 module source text
# not 'p', check other lines
-0 byte !0x70
+0 search/1 !p
>0 regex \^package[\ \t]+[0-9A-Za-z_:]+\ *;
>>0 regex \^1\ *;|\^(use|sub|my)\ .*[(;{=] Perl5 module source text
@@ -28,21 +34,21 @@
# Perl POD documents
# From: Tom Hukins <tom@eborcom.com>
-0 string/B \=pod\n Perl POD document
-0 string/B \n\=pod\n Perl POD document
-0 string/B \=head1\ Perl POD document
-0 string/B \n\=head1\ Perl POD document
-0 string/B \=head2\ Perl POD document
-0 string/B \n\=head2\ Perl POD document
+0 search/1/B \=pod\n Perl POD document text
+0 search/1/B \n\=pod\n Perl POD document text
+0 search/1/B \=head1\ Perl POD document text
+0 search/1/B \n\=head1\ Perl POD document text
+0 search/1/B \=head2\ Perl POD document text
+0 search/1/B \n\=head2\ Perl POD document text
# Perl Storable data files.
-0 string perl-store perl Storable(v0.6) data
+0 string perl-store perl Storable (v0.6) data
>4 byte >0 (net-order %d)
>>4 byte &01 (network-ordered)
>>4 byte =3 (major 1)
>>4 byte =2 (major 1)
-0 string pst0 perl Storable(v0.7) data
+0 string pst0 perl Storable (v0.7) data
>4 byte >0
>>4 byte &01 (network-ordered)
>>4 byte =5 (major 2)
diff --git a/Magdir/pgp b/Magdir/pgp
index 038d098ee4ac..63042adeef82 100644
--- a/Magdir/pgp
+++ b/Magdir/pgp
@@ -1,13 +1,26 @@
#------------------------------------------------------------------------------
# pgp: file(1) magic for Pretty Good Privacy
+# see http://lists.gnupg.org/pipermail/gnupg-devel/1999-September/016052.html
#
0 beshort 0x9900 PGP key public ring
+!:mime application/x-pgp-keyring
0 beshort 0x9501 PGP key security ring
+!:mime application/x-pgp-keyring
0 beshort 0x9500 PGP key security ring
+!:mime application/x-pgp-keyring
0 beshort 0xa600 PGP encrypted data
-0 string -----BEGIN\040PGP PGP armored data
->15 string PUBLIC\040KEY\040BLOCK- public key block
->15 string MESSAGE- message
->15 string SIGNED\040MESSAGE- signed message
->15 string PGP\040SIGNATURE- signature
+#!:mime application/pgp-encrypted
+#0 string -----BEGIN\040PGP text/PGP armored data
+!:mime text/PGP # encoding: armored data
+#>15 string PUBLIC\040KEY\040BLOCK- public key block
+#>15 string MESSAGE- message
+#>15 string SIGNED\040MESSAGE- signed message
+#>15 string PGP\040SIGNATURE- signature
+
+2 string ---BEGIN\ PGP\ PUBLIC\ KEY\ BLOCK- PGP public key block
+!:mime application/pgp-keys
+0 string -----BEGIN\040PGP\40MESSAGE- PGP message
+!:mime application/pgp
+0 string -----BEGIN\040PGP\40SIGNATURE- PGP signature
+!:mime application/pgp-signature
diff --git a/Magdir/pkgadd b/Magdir/pkgadd
index dc8ef5d93ab4..876dacd79cd4 100644
--- a/Magdir/pkgadd
+++ b/Magdir/pkgadd
@@ -3,3 +3,4 @@
# pkgadd: file(1) magic for SysV R4 PKG Datastreams
#
0 string #\ PaCkAgE\ DaTaStReAm pkg Datastream (SVR4)
+!:mime application/x-svr4-package
diff --git a/Magdir/printer b/Magdir/printer
index 77ba7809748b..15a175821308 100644
--- a/Magdir/printer
+++ b/Magdir/printer
@@ -5,21 +5,26 @@
# PostScript, updated by Daniel Quinlan (quinlan@yggdrasil.com)
0 string %! PostScript document text
+!:mime application/postscript
>2 string PS-Adobe- conforming
->>11 string >\0 at level %.3s
->>>15 string EPS - type %s
->>>15 string Query - type %s
->>>15 string ExitServer - type %s
+>>11 string >\0 DSC level %.3s
+>>>15 string EPS \b, type %s
+>>>15 string Query \b, type %s
+>>>15 string ExitServer \b, type %s
+>>>15 search/1000 %%LanguageLevel:\
+>>>>&0 string >\0 \b, Level %s
# Some PCs have the annoying habit of adding a ^D as a document separator
0 string \004%! PostScript document text
+!:mime application/postscript
>3 string PS-Adobe- conforming
->>12 string >\0 at level %.3s
->>>16 string EPS - type %s
->>>16 string Query - type %s
->>>16 string ExitServer - type %s
+>>12 string >\0 DSC level %.3s
+>>>16 string EPS \b, type %s
+>>>16 string Query \b, type %s
+>>>16 string ExitServer \b, type %s
+>>>16 search/1000 %%LanguageLevel:\
+>>>>&0 string >\0 \b, Level %s
0 string \033%-12345X%!PS PostScript document
-
# DOS EPS Binary File Header
# From: Ed Sznyter <ews@Black.Market.NET>
0 belong 0xC5D0D3C6 DOS EPS Binary File
@@ -30,11 +35,13 @@
>>>20 long >0 TIFF starts at byte %d
>>>>24 long >0 length %d
-# Adobe's PostScript Printer Description (PPD) files
-# Yves Arrouye <arrouye@marin.fdn.fr>
+# Summary: Adobe's PostScript Printer Description File
+# Extension: .ppd
+# Reference: http://partners.adobe.com/public/developer/en/ps/5003.PPD_Spec_v4.3.pdf, Section 3.8
+# Submitted by: Yves Arrouye <arrouye@marin.fdn.fr>
#
-0 string *PPD-Adobe: PPD file
->13 string x \b, ve
+0 string *PPD-Adobe:\x20 PPD file
+>&0 string x \b, version %s
# HP Printer Job Language
0 string \033%-12345X@PJL HP Printer Job Language data
diff --git a/Magdir/psion b/Magdir/psion
index 578ea5906dc5..7aa2d74520a7 100644
--- a/Magdir/psion
+++ b/Magdir/psion
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# psion: file(1) magic for Psion handhelds data
# from: Peter Breitenlohner <peb@mppmu.mpg.de>
@@ -11,6 +10,7 @@
>4 lelong 0x1000006A application information file
>4 lelong 0x1000006D
>>8 lelong 0x1000007D sketch image
+!:mime image/x-psion-sketch
>>8 lelong 0x1000007E voice note
>>8 lelong 0x1000007F word file
>>8 lelong 0x10000085 OPL program
diff --git a/Magdir/revision b/Magdir/revision
index e47416ab68d0..a809cb9e6034 100644
--- a/Magdir/revision
+++ b/Magdir/revision
@@ -7,3 +7,13 @@
# Conary changesets
# From: Jonathan Smith <smithj@rpath.com>
0 belong 0xea3f81bb Conary changeset data
+
+# Type: Git bundles (git-bundle)
+# From: Josh Triplett <josh@freedesktop.org>
+0 string #\ v2\ git\ bundle\n Git bundle
+
+# Type: Mercurial bundles
+# From: Seo Sanghyeon <tinuviel@sparcs.kaist.ac.kr>
+0 string HG10 Mercurial bundle,
+>4 string UN uncompressed
+>4 string BZ bzip2 compressed
diff --git a/Magdir/riff b/Magdir/riff
index 5aa9d109388d..c6e3070b56ff 100644
--- a/Magdir/riff
+++ b/Magdir/riff
@@ -33,6 +33,7 @@
>8 string RMP3 \b, MPEG Layer 3 audio
# Microsoft WAVE format (*.wav)
>8 string WAVE \b, WAVE audio
+!:mime audio/x-wav
>>20 leshort 1 \b, Microsoft PCM
>>>34 leshort >0 \b, %d bit
>>20 leshort 2 \b, Microsoft ADPCM
@@ -50,8 +51,10 @@
>>24 lelong >0 %d Hz
# Corel Draw Picture
>8 string CDRA \b, Corel Draw Picture
+!:mime image/x-coreldraw
# AVI == Audio Video Interleave
>8 string AVI\040 \b, AVI
+!:mime video/x-msvideo
>>12 string LIST
>>>20 string hdrlavih
>>>>&36 lelong x \b, %lu x
@@ -130,8 +133,9 @@
>>>>>>>(104.l+132) string/c divx DivX 4
>>>>>>>(104.l+132) string/c dx50 DivX 5
>>>>>>>(104.l+132) string/c xvid XviD
+>>>>>>>(104.l+132) string/c h264 H.264
>>>>>>>(104.l+132) string/c wmv3 Windows Media Video 9
->>>>>>>(104.l+132) string/c h264 X.264
+>>>>>>>(104.l+132) string/c h264 X.264 or H.264
>>>>>>>(104.l+132) lelong 0
##>>>>>>>(104.l+132) string x (%.4s)
# skip past first (video) LIST
diff --git a/Magdir/rpm b/Magdir/rpm
index 09ee51b4f026..6d7e850bb7df 100644
--- a/Magdir/rpm
+++ b/Magdir/rpm
@@ -4,6 +4,7 @@
#
0 beshort 0xedab
>2 beshort 0xeedb RPM
+!:mime application/x-rpm
>>4 byte x v%d
>>6 beshort 0 bin
>>6 beshort 1 src
@@ -13,7 +14,7 @@
>>8 beshort 4 MIPS
>>8 beshort 5 PowerPC
>>8 beshort 6 68000
->>8 beshort 7 SGI
+>>8 beshort 7 SGI
>>8 beshort 8 RS6000
>>8 beshort 9 IA64
>>8 beshort 10 Sparc64
diff --git a/Magdir/rtf b/Magdir/rtf
index 8e2d4166fa58..8e5bfe0e32ee 100644
--- a/Magdir/rtf
+++ b/Magdir/rtf
@@ -5,8 +5,11 @@
# Duncan P. Simpson, D.P.Simpson@dcs.warwick.ac.uk
#
0 string {\\rtf Rich Text Format data,
->5 byte x version %c,
->6 string \\ansi ANSI
->6 string \\mac Apple Macintosh
->6 string \\pc IBM PC, code page 437
->6 string \\pca IBM PS/2, code page 850
+!:mime text/rtf
+>5 string 1 version 1,
+>>6 string \\ansi ANSI
+>>6 string \\mac Apple Macintosh
+>>6 string \\pc IBM PC, code page 437
+>>6 string \\pca IBM PS/2, code page 850
+>>6 default x unknown character set
+>5 default x unknown version
diff --git a/Magdir/ruby b/Magdir/ruby
new file mode 100644
index 000000000000..de6f2a0974cd
--- /dev/null
+++ b/Magdir/ruby
@@ -0,0 +1,10 @@
+#------------------------------------------------------------------------------
+# ruby: file(1) magic for Lua scripting language
+# URL: http://www.ruby-lang.org/
+# From: Reuben Thomas <rrt@sc3d.org>
+
+# Ruby scripts
+0 search/1/b #!\ /usr/bin/ruby Ruby script text executable
+0 search/1/b #!\ /usr/local/bin/ruby Ruby script text executable
+0 search/1 #!/usr/bin/env\ ruby Ruby script text executable
+0 search/1 #!\ /usr/bin/env\ ruby Ruby script text executable
diff --git a/Magdir/sc b/Magdir/sc
index 98599f264781..72027d69ebff 100644
--- a/Magdir/sc
+++ b/Magdir/sc
@@ -3,3 +3,4 @@
# sc: file(1) magic for "sc" spreadsheet
#
38 string Spreadsheet sc spreadsheet file
+!:mime application/x-sc
diff --git a/Magdir/scientific b/Magdir/scientific
index 81beac120603..f7aedaebd248 100644
--- a/Magdir/scientific
+++ b/Magdir/scientific
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# scientific: file(1) magic for scientific formats
#
@@ -58,3 +57,15 @@
>1104 ulong >0 %d x
>1108 ulong >0 %d,
>1120 ulong >0 %d bits/pixel
+
+# Type: GEDCOM genealogical (family history) data
+# From: Giuseppe Bilotta
+0 search/1/c 0\ HEAD GEDCOM genealogy text
+>&0 search 1\ GEDC
+>>&0 search 2\ VERS version
+>>>&1 search/1 >\0 %s
+# From: Phil Endecott <phil05@chezphil.org>
+0 string \000\060\000\040\000\110\000\105\000\101\000\104 GEDCOM data
+0 string \060\000\040\000\110\000\105\000\101\000\104\000 GEDCOM data
+0 string \376\377\000\060\000\040\000\110\000\105\000\101\000\104 GEDCOM data
+0 string \377\376\060\000\040\000\110\000\105\000\101\000\104\000 GEDCOM data
diff --git a/Magdir/securitycerts b/Magdir/securitycerts
new file mode 100644
index 000000000000..aa55d2188fc1
--- /dev/null
+++ b/Magdir/securitycerts
@@ -0,0 +1,3 @@
+0 search/1 -----BEGIN\ CERTIFICATE------ RFC1421 Security Certificate text
+0 search/1 -----BEGIN\ NEW\ CERTIFICATE RFC1421 Security Certificate Signing Request text
+0 belong 0xedfeedfe Sun 'jks' Java Keystore File data
diff --git a/Magdir/sgi b/Magdir/sgi
index f7de13800b9f..5b540278c8b1 100644
--- a/Magdir/sgi
+++ b/Magdir/sgi
@@ -8,12 +8,17 @@
0 string PmNs PCP compiled namespace (V.0)
0 string PmN PCP compiled namespace
>3 string >\0 (V.%1.1s)
-3 lelong 0x84500526 PCP archive
+#3 lelong 0x84500526 PCP archive
+3 belong 0x84500526 PCP archive
>7 byte x (V.%d)
->20 lelong -2 temporal index
->20 lelong -1 metadata
->20 lelong 0 log volume #0
->20 lelong >0 log volume #%ld
+#>20 lelong -2 temporal index
+#>20 lelong -1 metadata
+#>20 lelong 0 log volume #0
+#>20 lelong >0 log volume #%ld
+>20 belong -2 temporal index
+>20 belong -1 metadata
+>20 belong 0 log volume #0
+>20 belong >0 log volume #%ld
>24 string >\0 host: %s
0 string PCPFolio PCP
>9 string Version: Archive Folio
@@ -30,6 +35,9 @@
0 string #pmlogger PCP pmlogger config
>10 string Version
>18 string >\0 (V%1.1s)
+0 string #pmdahotproc PCP pmdahotproc config
+>13 string Version
+>21 string >\0 (V%-3.3s)
0 string PcPh PCP Help
>4 string 1 Index
>4 string 2 Text
diff --git a/Magdir/sgml b/Magdir/sgml
index ba6c3ef8971b..7e3391b09b8c 100644
--- a/Magdir/sgml
+++ b/Magdir/sgml
@@ -1,35 +1,63 @@
+#------------------------------------------------------------------------------
+# Type: SVG Vectorial Graphics
+# From: Noel Torres <tecnico@ejerciciosresueltos.com>
+0 string \<?xml\ version="
+>15 string >\0
+>>23 search/400 \<svg SVG Scalable Vector Graphics image
+!:mime image/svg+xml
+>>23 search/400 \<gnc-v2 GnuCash file
+!:mime application/x-gnucash
+
+# Sitemap file
+0 string \<?xml\ version="
+>15 string >\0
+>>23 search/400 \<urlset XML Sitemap document text
+!:mime application/xml-sitemap
#------------------------------------------------------------------------------
# sgml: file(1) magic for Standard Generalized Markup Language
# HyperText Markup Language (HTML) is an SGML document type,
# from Daniel Quinlan (quinlan@yggdrasil.com)
# adapted to string extenstions by Anthon van der Neut <anthon@mnt.org)
-0 string/cB \<!DOCTYPE\ html HTML document text
-0 string/cb \<head HTML document text
-0 string/cb \<title HTML document text
-0 string/cb \<html HTML document text
+0 search/1/cB \<!doctype\ html HTML document text
+!:mime text/html
+0 search/1/cb \<head HTML document text
+!:mime text/html
+0 search/1/cb \<title HTML document text
+!:mime text/html
+0 search/1/cb \<html HTML document text
+!:mime text/html
# Extensible markup language (XML), a subset of SGML
# from Marc Prud'hommeaux (marc@apocalypse.org)
-0 string/cb \<?xml XML document text
+0 search/1/cb \<?xml XML document text
+!:mime application/xml
0 string \<?xml\ version\ " XML
+!:mime application/xml
0 string \<?xml\ version=" XML
+!:mime application/xml
+>15 search/1 >\0 %.3s document text
+>>23 search/1 \<xsl:stylesheet (XSL stylesheet)
+>>24 search/1 \<xsl:stylesheet (XSL stylesheet)
0 string \<?xml\ version=' XML
->15 string >\0 %.3s document text
->>23 string \<xsl:stylesheet (XSL stylesheet)
->>24 string \<xsl:stylesheet (XSL stylesheet)
-0 string/b \<?xml XML document text
-0 string/cb \<?xml broken XML document text
+!:mime application/xml
+>15 search/1 >\0 %.3s document text
+>>23 search/1 \<xsl:stylesheet (XSL stylesheet)
+>>24 search/1 \<xsl:stylesheet (XSL stylesheet)
+0 search/1/b \<?xml XML document text
+!:mime application/xml
+0 search/1/b \<?XML broken XML document text
+!:mime application/xml
# SGML, mostly from rph@sq
-0 string/cb \<!doctype exported SGML document text
-0 string/cb \<!subdoc exported SGML subdocument text
-0 string/cb \<!-- exported SGML document text
+0 search/1/cb \<!doctype exported SGML document text
+0 search/1/cb \<!subdoc exported SGML subdocument text
+0 search/1/cb \<!-- exported SGML document text
# Web browser cookie files
# (Mozilla, Galeon, Netscape 4, Konqueror..)
# Ulf Harnhammar <ulfh@update.uu.se>
-0 string #\ HTTP\ Cookie\ File Web browser cookie text
-0 string #\ Netscape\ HTTP\ Cookie\ File Netscape cookie text
-0 string #\ KDE\ Cookie\ File Konqueror cookie text
+0 search/1 #\ HTTP\ Cookie\ File Web browser cookie text
+0 search/1 #\ Netscape\ HTTP\ Cookie\ File Netscape cookie text
+0 search/1 #\ KDE\ Cookie\ File Konqueror cookie text
diff --git a/Magdir/sharc b/Magdir/sharc
index 8c2cae4c25d0..0e0e4e38db6e 100644
--- a/Magdir/sharc
+++ b/Magdir/sharc
@@ -6,14 +6,14 @@
# FutureGroove Music (dsp@futuregroove.de)
#------------------------------------------------------------------------
-0 string Draw RiscOS Drawfile
-0 string PACK RiscOS PackdDir archive
+#0 string Draw RiscOS Drawfile
+#0 string PACK RiscOS PackdDir archive
#------------------------------------------------------------------------
# SHARC DSP stuff (based on the FGM SHARC DSP SDK)
-0 string =! Assembler source
-0 string Analog ADi asm listing file
+#0 string =! Assembler source
+#0 string Analog ADi asm listing file
0 string .SYSTEM SHARC architecture file
0 string .system SHARC architecture file
diff --git a/Magdir/sketch b/Magdir/sketch
index d31d18464ffd..a14803ebefbb 100644
--- a/Magdir/sketch
+++ b/Magdir/sketch
@@ -1,5 +1,4 @@
-
#------------------------------------------------------------------------------
# Sketch Drawings: http://sketch.sourceforge.net/
# From: Edwin Mons <e@ik.nu>
-0 string ##Sketch Sketch document text
+0 search/1 ##Sketch Sketch document text
diff --git a/Magdir/softquad b/Magdir/softquad
index aa1690426475..ac7891d736aa 100644
--- a/Magdir/softquad
+++ b/Magdir/softquad
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# softquad: file(1) magic for SoftQuad Publishing Software
#
@@ -19,7 +18,7 @@
0 short 0125252 SoftQuad DESC or font file binary
>2 short >0 - version %d
# Bitmaps...
-0 string SQ\ BITMAP1 SoftQuad Raster Format text
+0 search/1 SQ\ BITMAP1 SoftQuad Raster Format text
#0 string SQ\ BITMAP2 SoftQuad Raster Format data
# sqtroff intermediate language (replacement for ditroff int. lang.)
0 string X\ SoftQuad troff Context intermediate
@@ -27,3 +26,10 @@
>2 string hp for Hewlett-Packard LaserJet
>2 string impr for IMAGEN imPRESS
>2 string ps for PostScript
+
+# From: Michael Piefel <piefel@debian.org>
+# sqtroff intermediate language (replacement for ditroff int. lang.)
+0 string X\ 495 SoftQuad troff Context intermediate for AT&T 495 laser printer
+0 string X\ hp SoftQuad troff Context intermediate for HP LaserJet
+0 string X\ impr SoftQuad troff Context intermediate for IMAGEN imPRESS
+0 string X\ ps SoftQuad troff Context intermediate for PostScript
diff --git a/Magdir/spectrum b/Magdir/spectrum
index ab9fd0467f42..a48ac41357e9 100644
--- a/Magdir/spectrum
+++ b/Magdir/spectrum
@@ -31,14 +31,19 @@
# TZX tape images
0 string ZXTape!\x1a Spectrum .TZX data
>8 byte x version %d
->9 byte x .%d
+>9 byte x \b.%d
# RZX input recording files
0 string RZX! Spectrum .RZX data
>4 byte x version %d
->5 byte x .%d
+>5 byte x \b.%d
-# And three sorts of disk image
+# Floppy disk images
0 string MV\ -\ CPCEMU\ Disk-Fil Amstrad/Spectrum .DSK data
0 string MV\ -\ CPC\ format\ Dis Amstrad/Spectrum DU54 .DSK data
0 string EXTENDED\ CPC\ DSK\ Fil Amstrad/Spectrum Extended .DSK data
+0 string SINCLAIR Spectrum .SCL Betadisk image
+
+# Hard disk images
+0 string RS-IDE\x1a Spectrum .HDF hard disk image
+>7 byte x \b, version 0x%02x
diff --git a/Magdir/tex b/Magdir/tex
index 52adb8704a2f..5416db17463e 100644
--- a/Magdir/tex
+++ b/Magdir/tex
@@ -1,46 +1,61 @@
-
#------------------------------------------------------------------------------
# tex: file(1) magic for TeX files
#
+# XXX - needs byte-endian stuff (big-endian and little-endian DVI?)
+#
# From <conklin@talisman.kaleida.com>
# Although we may know the offset of certain text fields in TeX DVI
# and font files, we can't use them reliably because they are not
# zero terminated. [but we do anyway, christos]
0 string \367\002 TeX DVI file
+!:mime application/x-dvi
>16 string >\0 (%s)
0 string \367\203 TeX generic font data
0 string \367\131 TeX packed font data
>3 string >\0 (%s)
0 string \367\312 TeX virtual font data
-0 string This\ is\ TeX, TeX transcript text
-0 string This\ is\ METAFONT, METAFONT transcript text
+0 search/1 This\ is\ TeX, TeX transcript text
+0 search/1 This\ is\ METAFONT, METAFONT transcript text
# There is no way to detect TeX Font Metric (*.tfm) files without
# breaking them apart and reading the data. The following patterns
# match most *.tfm files generated by METAFONT or afm2tfm.
2 string \000\021 TeX font metric data
+!:mime application/x-tex-tfm
>33 string >\0 (%s)
2 string \000\022 TeX font metric data
+!:mime application/x-tex-tfm
>33 string >\0 (%s)
# Texinfo and GNU Info, from Daniel Quinlan (quinlan@yggdrasil.com)
-0 string \\input\ texinfo Texinfo source text
-0 string This\ is\ Info\ file GNU Info text
+0 search/1 \\input\ texinfo Texinfo source text
+!:mime text/x-texinfo
+0 search/1 This\ is\ Info\ file GNU Info text
+!:mime text/x-info
# TeX documents, from Daniel Quinlan (quinlan@yggdrasil.com)
0 search/400 \\input TeX document text
+!:mime text/x-tex
0 search/400 \\section LaTeX document text
+!:mime text/x-tex
0 search/400 \\setlength LaTeX document text
+!:mime text/x-tex
0 search/400 \\documentstyle LaTeX document text
+!:mime text/x-tex
0 search/400 \\chapter LaTeX document text
+!:mime text/x-tex
0 search/400 \\documentclass LaTeX 2e document text
+!:mime text/x-tex
0 search/400 \\relax LaTeX auxiliary file
+!:mime text/x-tex
0 search/400 \\contentsline LaTeX table of contents
+!:mime text/x-tex
0 search/400 %\ -*-latex-*- LaTeX document text
+!:mime text/x-tex
# Tex document, from Hendrik Scholz <hendrik@scholz.net>
-0 string \\ifx TeX document text
+0 search/1 \\ifx TeX document text
# Index and glossary files
0 search/400 \\indexentry LaTeX raw index file
@@ -55,25 +70,24 @@
# file(1) magic for BibTex text files
# From Hendrik Scholz <hendrik@scholz.net>
-0 string/c @article{ BibTeX text file
-0 string/c @book{ BibTeX text file
-0 string/c @inbook{ BibTeX text file
-0 string/c @incollection{ BibTeX text file
-0 string/c @inproceedings{ BibTeX text file
-0 string/c @manual{ BibTeX text file
-0 string/c @misc{ BibTeX text file
-0 string/c @preamble{ BibTeX text file
-0 string/c @phdthesis{ BibTeX text file
-0 string/c @techreport{ BibTeX text file
-0 string/c @unpublished{ BibTeX text file
-
-73 string %%%\ \ BibTeX-file{ BibTex text file (with full header)
+0 search/1/c @article{ BibTeX text file
+0 search/1/c @book{ BibTeX text file
+0 search/1/c @inbook{ BibTeX text file
+0 search/1/c @incollection{ BibTeX text file
+0 search/1/c @inproceedings{ BibTeX text file
+0 search/1/c @manual{ BibTeX text file
+0 search/1/c @misc{ BibTeX text file
+0 search/1/c @preamble{ BibTeX text file
+0 search/1/c @phdthesis{ BibTeX text file
+0 search/1/c @techreport{ BibTeX text file
+0 search/1/c @unpublished{ BibTeX text file
-73 string %%%\ \ @BibTeX-style-file{ BibTeX style text file (with full header)
+73 search/1 %%%\ \ BibTeX-file{ BibTex text file (with full header)
-0 string %\ BibTeX\ standard\ bibliography\ BibTeX standard bibliography style text file
+73 search/1 %%%\ \ @BibTeX-style-file{ BibTeX style text file (with full header)
-0 string %\ BibTeX\ ` BibTeX custom bibliography style text file
+0 search/1 %\ BibTeX\ standard\ bibliography\ BibTeX standard bibliography style text file
-0 string @c\ @mapfile{ TeX font aliases text file
+0 search/1 %\ BibTeX\ ` BibTeX custom bibliography style text file
+0 search/1 @c\ @mapfile{ TeX font aliases text file
diff --git a/Magdir/troff b/Magdir/troff
index 01ad88a0b445..337ca6837714 100644
--- a/Magdir/troff
+++ b/Magdir/troff
@@ -1,28 +1,32 @@
-
#------------------------------------------------------------------------------
# troff: file(1) magic for *roff
#
# updated by Daniel Quinlan (quinlan@yggdrasil.com)
# troff input
-0 string .\\" troff or preprocessor input text
-0 string '\\" troff or preprocessor input text
-0 string '.\\" troff or preprocessor input text
-0 string \\" troff or preprocessor input text
-0 string ''' troff or preprocessor input text
+0 search/1 .\\" troff or preprocessor input text
+!:mime text/troff
+0 search/1 '\\" troff or preprocessor input text
+!:mime text/troff
+0 search/1 '.\\" troff or preprocessor input text
+!:mime text/troff
+0 search/1 \\" troff or preprocessor input text
+!:mime text/troff
+0 search/1 ''' troff or preprocessor input text
+!:mime text/troff
# ditroff intermediate output text
-0 string x\ T ditroff output text
->4 string cat for the C/A/T phototypesetter
->4 string ps for PostScript
->4 string dvi for DVI
->4 string ascii for ASCII
->4 string lj4 for LaserJet 4
->4 string latin1 for ISO 8859-1 (Latin 1)
->4 string X75 for xditview at 75dpi
->>7 string -12 (12pt)
->4 string X100 for xditview at 100dpi
->>8 string -12 (12pt)
+0 search/1 x\ T ditroff output text
+>4 search/1 cat for the C/A/T phototypesetter
+>4 search/1 ps for PostScript
+>4 search/1 dvi for DVI
+>4 search/1 ascii for ASCII
+>4 search/1 lj4 for LaserJet 4
+>4 search/1 latin1 for ISO 8859-1 (Latin 1)
+>4 search/1 X75 for xditview at 75dpi
+>>7 search/1 -12 (12pt)
+>4 search/1 X100 for xditview at 100dpi
+>>8 search/1 -12 (12pt)
# output data formats
0 string \100\357 very old (C/A/T) troff output data
diff --git a/Magdir/unicode b/Magdir/unicode
index 45a32d4536b7..5f4a576470f0 100644
--- a/Magdir/unicode
+++ b/Magdir/unicode
@@ -1,15 +1,14 @@
-
#---------------------------------------------------------------------------
# Unicode: BOM prefixed text files - Adrian Havill <havill@turbolinux.co.jp>
+# GRR: These types should be recognised in file_ascmagic so these
+# encodings can be treated by text patterns.
+# Missing types are already dealt with internally.
#
0 string +/v8 Unicode text, UTF-7
0 string +/v9 Unicode text, UTF-7
0 string +/v+ Unicode text, UTF-7
0 string +/v/ Unicode text, UTF-7
-0 string \357\273\277 Unicode text, UTF-8
0 string \335\163\146\163 Unicode text, UTF-8-EBCDIC
0 string \376\377\000\000 Unicode text, UTF-32, big-endian
0 string \377\376\000\000 Unicode text, UTF-32, little-endian
-0 string \376\377 Unicode text, UTF-16, big-endian
-0 string \377\376 Unicode text, UTF-16, little-endian
0 string \016\376\377 Unicode text, SCSU (Standard Compression Scheme for Unicode)
diff --git a/Magdir/uuencode b/Magdir/uuencode
index 7e88619d5ca9..982cba9046f0 100644
--- a/Magdir/uuencode
+++ b/Magdir/uuencode
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# uuencode: file(1) magic for ASCII-encoded files
#
@@ -9,22 +8,22 @@
# punctuation and survives BITNET gateways better.) If regular expressions
# were supported, this entry could possibly be split into two with
# "begin\040\.\*\012M" or "begin\040\.\*\012h" (where \. and \* are REs).
-0 string begin\040 uuencoded or xxencoded text
+0 search/1 begin\ uuencoded or xxencoded text
# btoa(1) is an alternative to uuencode that requires less space.
-0 string xbtoa\ Begin btoa'd text
+0 search/1 xbtoa\ Begin btoa'd text
# ship(1) is another, much cooler alternative to uuencode.
# Greg Roelofs, newt@uchicago.edu
-0 string $\012ship ship'd binary text
+0 search/1 $\012ship ship'd binary text
# bencode(8) is used to encode compressed news batches (Bnews/Cnews only?)
# Greg Roelofs, newt@uchicago.edu
-0 string Decode\ the\ following\ with\ bdeco bencoded News text
+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 string must\ be\ converted\ with\ BinHex BinHex binary text
->41 string x \b, version %.3s
+11 search/1 must\ be\ converted\ with\ BinHex BinHex binary text
+>41 search/1 x \b, version %.3s
-# GRR: is MIME BASE64 encoding handled somewhere?
+# GRR: handle BASE64
diff --git a/Magdir/varied.script b/Magdir/varied.script
index ab5becef2d63..61f935cdcd81 100644
--- a/Magdir/varied.script
+++ b/Magdir/varied.script
@@ -10,3 +10,9 @@
0 string #!\ script text executable
>3 string >\0 for %s
+# From: arno <arenevier@fdn.fr>
+# mozilla xpconnect typelib
+# see http://www.mozilla.org/scriptable/typelib_file.html
+0 string XPCOM\nTypeLib\r\n\032 XPConnect Typelib
+>0x10 byte x version %d
+>>0x11 byte x \b.%d
diff --git a/Magdir/vorbis b/Magdir/vorbis
index 5957ea0d2782..cbef5fdff695 100644
--- a/Magdir/vorbis
+++ b/Magdir/vorbis
@@ -11,16 +11,40 @@
# probable things advanced users would want to uncomment are probably
# the number of comments and the encoder version.
#
+# FIXME: The first match has been made a search, so that it can skip
+# over prepended ID3 tags. This will work for MIME type detection, but
+# won't work for detecting other properties of the file (they all need
+# to be made relative to the search). In any case, if the file has ID3
+# tags, the ID3 information will be printed, not the Ogg information,
+# so until that's fixed, this doesn't matter.
+# FIXME[2]: Disable the above for now, since search assumes text mode.
+#
# --- Ogg Framing ---
-0 string OggS Ogg data
+#0 search/1000 OggS Ogg data
+0 string OggS Ogg data
+!:mime application/ogg
>4 byte !0 UNKNOWN REVISION %u
##>4 byte 0 revision 0
>4 byte 0
##>>14 lelong x (Serial %lX)
# non-Vorbis content: FLAC (Free Lossless Audio Codec, http://flac.sourceforge.net)
->>28 string fLaC \b, FLAC audio
+>>28 string \x7fFLAC \b, FLAC audio
# non-Vorbis content: Theora
>>28 string \x80theora \b, Theora video
+# non-Vorbis content: Kate
+>>28 string \x80kate\0\0\0\0 \b, Kate
+>>>37 ubyte x v%u
+>>>38 ubyte x \b.%u,
+>>>40 byte 0 utf8 encoding,
+>>>40 byte !0 unknown character encoding,
+>>>60 string >\0 language %s,
+>>>60 string \0 no language set,
+>>>76 string >\0 category %s
+>>>76 string \0 no category set
+# non-Vorbis content: Skeleton
+>>28 string fishead\0 \b, Skeleton
+>>>36 short x v%u
+>>>40 short x \b.%u
# non-Vorbis content: Speex
>>28 string Speex\ \ \ \b, Speex audio
# non-Vorbis content: OGM
diff --git a/Magdir/warc b/Magdir/warc
new file mode 100644
index 000000000000..968e2679248f
--- /dev/null
+++ b/Magdir/warc
@@ -0,0 +1,6 @@
+
+#------------------------------------------------------------------------------
+# warc: file(1) magic for WARC files
+
+0 string WARC/ WARC Archive
+>5 string x version %.4s
diff --git a/Magdir/weak b/Magdir/weak
new file mode 100644
index 000000000000..21324ea494f5
--- /dev/null
+++ b/Magdir/weak
@@ -0,0 +1,15 @@
+#------------------------------------------------------------------------------
+# weak: file(1) magic for very weak magic entries, disabled by default
+#
+# These entries are so weak that they might interfere identification of
+# other formats. Example include:
+# - Only identify for 1 or 2 bytes
+# - Match against very wide range of values
+# - Match against generic word in some spoken languages (e.g. English)
+
+# Summary: Computer Graphics Metafile
+# Extension: .cgm
+#0 beshort&0xffe0 0x0020 binary Computer Graphics Metafile
+#0 beshort 0x3020 character Computer Graphics Metafile
+
+#0 string =!! Bennet Yee's "face" format
diff --git a/Magdir/windows b/Magdir/windows
new file mode 100644
index 000000000000..5cde739f633d
--- /dev/null
+++ b/Magdir/windows
@@ -0,0 +1,115 @@
+
+#------------------------------------------------------------------------------
+# windows: file(1) magic for Microsoft Windows
+#
+# This file is mainly reserved for files where programs
+# using them are run almost always on MS Windows 3.x or
+# above, or files only used exclusively in Windows OS,
+# where there is no better category to allocate for.
+# For example, even though WinZIP almost run on Windows
+# only, it is better to treat them as "archive" instead.
+# For format usable in DOS, such as generic executable
+# format, please specify under "msdos" file.
+#
+
+
+# Summary: Outlook Express DBX file
+# Extension: .dbx
+# Created by: Christophe Monniez
+0 string \xCF\xAD\x12\xFE MS Outlook Express DBX file
+>4 byte =0xC5 \b, message database
+>4 byte =0xC6 \b, folder database
+>4 byte =0xC7 \b, account information
+>4 byte =0x30 \b, offline database
+
+
+# Summary: Windows crash dump
+# Extension: .dmp
+# Created by: Andreas Schuster (http://computer.forensikblog.de/)
+# Reference (1): http://computer.forensikblog.de/en/2008/02/64bit_magic.html
+# Modified by (1): Abel Cheung (Avoid match with first 4 bytes only)
+0 string PAGE
+>4 string DUMP MS Windows 32bit crash dump
+>>0x05c byte 0 \b, no PAE
+>>0x05c byte 1 \b, PAE
+>>0xf88 lelong 1 \b, full dump
+>>0xf88 lelong 2 \b, kernel dump
+>>0xf88 lelong 3 \b, small dump
+>>0x068 lelong x \b, %ld pages
+>4 string DU64 MS Windows 64bit crash dump
+>>0xf98 lelong 1 \b, full dump
+>>0xf98 lelong 2 \b, kernel dump
+>>0xf98 lelong 3 \b, small dump
+>>0x090 lequad x \b, %lld pages
+
+
+# Summary: Vista Event Log
+# Extension: .evtx
+# Created by: Andreas Schuster (http://computer.forensikblog.de/)
+# Reference (1): http://computer.forensikblog.de/en/2007/05/some_magic.html
+0 string ElfFile\0 MS Windows Vista Event Log
+>0x2a leshort x \b, %d chunks
+>>0x10 lelong x \b (no. %d in use)
+>0x18 lelong >1 \b, next record no. %d
+>0x18 lelong =1 \b, empty
+>0x78 lelong &1 \b, DIRTY
+>0x78 lelong &2 \b, FULL
+
+
+# Summary: Windows 3.1 group files
+# Extension: .grp
+# Created by: unknown
+0 string \120\115\103\103 MS Windows 3.1 group files
+
+
+# Summary: Old format help files
+# Extension: .hlp
+# Created by: Dirk Jagdmann <doj@cubic.org>
+0 lelong 0x00035f3f MS Windows 3.x help file
+
+
+# Summary: Hyper terminal
+# Extension: .ht
+# Created by: unknown
+0 string HyperTerminal\
+>15 string 1.0\ --\ HyperTerminal\ data\ file MS Windows HyperTerminal profile
+
+
+# Summary: Windows shortcut
+# Extension: .lnk
+# Created by: unknown
+0 string \114\0\0\0\001\024\002\0\0\0\0\0\300\0\0\0\0\0\0\106 MS Windows shortcut
+
+
+# Summary: Outlook Personal Folders
+# Created by: unknown
+0 lelong 0x4E444221 Microsoft Outlook email folder
+>10 leshort 0x0e (<=2002)
+>10 leshort 0x17 (>=2003)
+
+
+# Summary: Windows help cache
+# Created by: unknown
+0 string \164\146\115\122\012\000\000\000\001\000\000\000 MS Windows help cache
+
+
+# Summary: IE cache file
+# Created by: Christophe Monniez
+0 string Client\ UrlCache\ MMF Internet Explorer cache file
+>20 string >\0 version %s
+
+
+# Summary: Registry files
+# Created by: unknown
+# Modified by (1): Joerg Jenderek
+0 string regf MS Windows registry file, NT/2000 or above
+0 string CREG MS Windows 95/98/ME registry file
+0 string SHCC3 MS Windows 3.1 registry file
+
+
+# Summary: Windows Registry text
+# Extension: .reg
+# Submitted by: Abel Cheung <abelcheung@gmail.com>
+0 string REGEDIT4\r\n\r\n Windows Registry text (Win95 or above)
+0 string Windows\ Registry\ Editor\
+>&0 string Version\ 5.00\r\n\r\n Windows Registry text (Win2K or above)
diff --git a/Magdir/wordprocessors b/Magdir/wordprocessors
index 546d2616d965..8965d3387bbb 100644
--- a/Magdir/wordprocessors
+++ b/Magdir/wordprocessors
@@ -1,4 +1,3 @@
-
#------------------------------------------------------------------------------
# wordprocessors: file(1) magic fo word processors.
#
@@ -12,7 +11,7 @@
>26 byte 0x46 \b, A4
#WordPerfect type files Version 1.6 - PLEASE DO NOT REMOVE THIS LINE
-0 string \377WPC\020\000\000\000\022\012\001\001\000\000\000\000 (WP) loadable text
+0 string \377WPC\020\000\000\000\022\012\001\001\000\000\000\000 (WP) loadable file
>15 byte 0 Optimized for Intel
>15 byte 1 Optimized for Non-Intel
1 string WPC (Corel/WP)
@@ -107,6 +106,7 @@
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 Benoît Rouits
0 string CSBK Ted Neslson's CosmicBook hypertext file
@@ -122,15 +122,29 @@
2 string IIXPR3 Intel Quark Express Document (English)
2 string IIXPRa Intel Quark Express Document (Korean)
2 string MMXPR3 Motorola Quark Express Document (English)
+!:mime application/x-quark-xpress-3
2 string MMXPRa Motorola Quark Express Document (Korean)
# adobe indesign (document, whatever...) from querkan
0 belong 0x0606edf5 Adobe InDesign
>16 string DOCUMENT Document
-# From: Michael Piefel <piefel@debian.org>
-# sqtroff intermediate language (replacement for ditroff int. lang.)
-0 string X\ 495 SoftQuad troff Context intermediate for AT&T 495 laser printer
-0 string X\ hp SoftQuad troff Context intermediate for HP LaserJet
-0 string X\ impr SoftQuad troff Context intermediate for IMAGEN imPRESS
-0 string X\ ps SoftQuad troff Context intermediate for PostScript
+#------------------------------------------------------------------------------
+# ichitaro456: file(1) magic for Just System Word Processor Ichitaro
+#
+# Contributor kenzo-:
+# Reversed-engineered JS Ichitaro magic numbers
+#
+
+0 string DOC
+>43 byte 0x14 Just System Word Processor Ichitaro v4
+!:mime application/x-ichitaro4
+>144 string JDASH application/x-ichitaro4
+
+0 string DOC
+>43 byte 0x15 Just System Word Processor Ichitaro v5
+!:mime application/x-ichitaro5
+
+0 string DOC
+>43 byte 0x16 Just System Word Processor Ichitaro v6
+!:mime application/x-ichitaro6
diff --git a/Magdir/xilinx b/Magdir/xilinx
new file mode 100644
index 000000000000..8f411ce21ddf
--- /dev/null
+++ b/Magdir/xilinx
@@ -0,0 +1,34 @@
+
+#------------------------------------------------------------------------------
+# This is Aaron's attempt at a MAGIC file for Xilinx .bit files.
+# Xilinx-Magic@RevRagnarok.com
+# Got the info from FPGA-FAQ 0026
+#
+# First there is the sync header and its length
+0 beshort 0x0009
+>2 belong =0x0ff00ff0
+>>&0 belong =0x0ff00ff0
+>>>&0 beshort =0x0000
+>>>>&0 pstring a Xilinx BIT data
+# Next is a Pascal-style string with the NCD name. We want to capture that.
+>>>>0x0F pstring x - from %s
+# It is followed by a NUL
+>>>>>&1 byte 0x00
+# And then 'b'
+>>>>>&2 string b
+# With the part number:
+#>>>>>&5 string 4v (Virtex4)
+#>>>>>&5 string 2v (Virtex II
+#>>>>>>&0 string !p \b)
+#>>>>>>&0 string p Pro)
+>>>>>&4 pstring x - for %s
+# And then NUL / 'c' / Build Data / NUL / 'd' / Date / NUL / 'e' / Data Length
+>>>>>>&1 byte 0x00
+>>>>>>&2 string c
+>>>>>>&4 pstring x - built %s
+>>>>>>>&1 byte 0x00
+>>>>>>>&2 string d
+>>>>>>>&4 pstring x \b(%s)
+>>>>>>>>&1 byte 0x00
+>>>>>>>>&2 string e
+>>>>>>>>&4 belong x - data length 0x%lx
diff --git a/Makefile.am b/Makefile.am
index 730ad3253041..104dd8fa0815 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,219 +1,236 @@
-pkgdata_DATA = magic magic.mime magic.mgc magic.mime.mgc
+#
+# $File: Makefile.am,v 1.43 2008/08/08 08:24:06 christos Exp $
+#
+MAGIC_FRAGMENT_BASE = Magdir
+MAGIC_FRAGMENT_DIR = $(top_srcdir)/magic/$(MAGIC_FRAGMENT_BASE)
-EXTRA_DIST = magic2mime Localstuff Header magic.mime $(magic_FRAGMENTS)
+pkgdata_DATA = magic.mgc
-CLEANFILES = magic magic.mgc magic.mime.mgc
+EXTRA_DIST = Header Localstuff \
+$(MAGIC_FRAGMENT_DIR)/acorn \
+$(MAGIC_FRAGMENT_DIR)/adi \
+$(MAGIC_FRAGMENT_DIR)/adventure \
+$(MAGIC_FRAGMENT_DIR)/allegro \
+$(MAGIC_FRAGMENT_DIR)/alliant \
+$(MAGIC_FRAGMENT_DIR)/alpha \
+$(MAGIC_FRAGMENT_DIR)/amanda \
+$(MAGIC_FRAGMENT_DIR)/amigaos \
+$(MAGIC_FRAGMENT_DIR)/animation \
+$(MAGIC_FRAGMENT_DIR)/apl \
+$(MAGIC_FRAGMENT_DIR)/apple \
+$(MAGIC_FRAGMENT_DIR)/applix \
+$(MAGIC_FRAGMENT_DIR)/archive \
+$(MAGIC_FRAGMENT_DIR)/asterix \
+$(MAGIC_FRAGMENT_DIR)/att3b \
+$(MAGIC_FRAGMENT_DIR)/audio \
+$(MAGIC_FRAGMENT_DIR)/basis \
+$(MAGIC_FRAGMENT_DIR)/bflt \
+$(MAGIC_FRAGMENT_DIR)/blender \
+$(MAGIC_FRAGMENT_DIR)/blit \
+$(MAGIC_FRAGMENT_DIR)/bout \
+$(MAGIC_FRAGMENT_DIR)/bsdi \
+$(MAGIC_FRAGMENT_DIR)/btsnoop \
+$(MAGIC_FRAGMENT_DIR)/c-lang \
+$(MAGIC_FRAGMENT_DIR)/c64 \
+$(MAGIC_FRAGMENT_DIR)/cad \
+$(MAGIC_FRAGMENT_DIR)/cafebabe \
+$(MAGIC_FRAGMENT_DIR)/cddb \
+$(MAGIC_FRAGMENT_DIR)/chord \
+$(MAGIC_FRAGMENT_DIR)/cisco \
+$(MAGIC_FRAGMENT_DIR)/citrus \
+$(MAGIC_FRAGMENT_DIR)/clarion \
+$(MAGIC_FRAGMENT_DIR)/claris \
+$(MAGIC_FRAGMENT_DIR)/clipper \
+$(MAGIC_FRAGMENT_DIR)/commands \
+$(MAGIC_FRAGMENT_DIR)/communications \
+$(MAGIC_FRAGMENT_DIR)/compress \
+$(MAGIC_FRAGMENT_DIR)/console \
+$(MAGIC_FRAGMENT_DIR)/convex \
+$(MAGIC_FRAGMENT_DIR)/cracklib \
+$(MAGIC_FRAGMENT_DIR)/ctags \
+$(MAGIC_FRAGMENT_DIR)/dact \
+$(MAGIC_FRAGMENT_DIR)/database \
+$(MAGIC_FRAGMENT_DIR)/diamond \
+$(MAGIC_FRAGMENT_DIR)/diff \
+$(MAGIC_FRAGMENT_DIR)/digital \
+$(MAGIC_FRAGMENT_DIR)/dolby \
+$(MAGIC_FRAGMENT_DIR)/dump \
+$(MAGIC_FRAGMENT_DIR)/dyadic \
+$(MAGIC_FRAGMENT_DIR)/editors \
+$(MAGIC_FRAGMENT_DIR)/efi \
+$(MAGIC_FRAGMENT_DIR)/elf \
+$(MAGIC_FRAGMENT_DIR)/encore \
+$(MAGIC_FRAGMENT_DIR)/epoc \
+$(MAGIC_FRAGMENT_DIR)/erlang \
+$(MAGIC_FRAGMENT_DIR)/esri \
+$(MAGIC_FRAGMENT_DIR)/fcs \
+$(MAGIC_FRAGMENT_DIR)/filesystems \
+$(MAGIC_FRAGMENT_DIR)/flash \
+$(MAGIC_FRAGMENT_DIR)/fonts \
+$(MAGIC_FRAGMENT_DIR)/fortran \
+$(MAGIC_FRAGMENT_DIR)/frame \
+$(MAGIC_FRAGMENT_DIR)/freebsd \
+$(MAGIC_FRAGMENT_DIR)/fsav \
+$(MAGIC_FRAGMENT_DIR)/games \
+$(MAGIC_FRAGMENT_DIR)/gcc \
+$(MAGIC_FRAGMENT_DIR)/geos \
+$(MAGIC_FRAGMENT_DIR)/gimp \
+$(MAGIC_FRAGMENT_DIR)/gnome-keyring \
+$(MAGIC_FRAGMENT_DIR)/gnu \
+$(MAGIC_FRAGMENT_DIR)/gnumeric \
+$(MAGIC_FRAGMENT_DIR)/grace \
+$(MAGIC_FRAGMENT_DIR)/graphviz \
+$(MAGIC_FRAGMENT_DIR)/gringotts \
+$(MAGIC_FRAGMENT_DIR)/hitachi-sh \
+$(MAGIC_FRAGMENT_DIR)/hp \
+$(MAGIC_FRAGMENT_DIR)/human68k \
+$(MAGIC_FRAGMENT_DIR)/ibm370 \
+$(MAGIC_FRAGMENT_DIR)/ibm6000 \
+$(MAGIC_FRAGMENT_DIR)/iff \
+$(MAGIC_FRAGMENT_DIR)/images \
+$(MAGIC_FRAGMENT_DIR)/inform \
+$(MAGIC_FRAGMENT_DIR)/intel \
+$(MAGIC_FRAGMENT_DIR)/interleaf \
+$(MAGIC_FRAGMENT_DIR)/island \
+$(MAGIC_FRAGMENT_DIR)/ispell \
+$(MAGIC_FRAGMENT_DIR)/java \
+$(MAGIC_FRAGMENT_DIR)/jpeg \
+$(MAGIC_FRAGMENT_DIR)/karma \
+$(MAGIC_FRAGMENT_DIR)/kde \
+$(MAGIC_FRAGMENT_DIR)/lecter \
+$(MAGIC_FRAGMENT_DIR)/lex \
+$(MAGIC_FRAGMENT_DIR)/lif \
+$(MAGIC_FRAGMENT_DIR)/linux \
+$(MAGIC_FRAGMENT_DIR)/lisp \
+$(MAGIC_FRAGMENT_DIR)/llvm \
+$(MAGIC_FRAGMENT_DIR)/lua \
+$(MAGIC_FRAGMENT_DIR)/luks \
+$(MAGIC_FRAGMENT_DIR)/mach \
+$(MAGIC_FRAGMENT_DIR)/macintosh \
+$(MAGIC_FRAGMENT_DIR)/magic \
+$(MAGIC_FRAGMENT_DIR)/mail.news \
+$(MAGIC_FRAGMENT_DIR)/maple \
+$(MAGIC_FRAGMENT_DIR)/mathcad \
+$(MAGIC_FRAGMENT_DIR)/mathematica \
+$(MAGIC_FRAGMENT_DIR)/matroska \
+$(MAGIC_FRAGMENT_DIR)/mcrypt \
+$(MAGIC_FRAGMENT_DIR)/mercurial \
+$(MAGIC_FRAGMENT_DIR)/mime \
+$(MAGIC_FRAGMENT_DIR)/mips \
+$(MAGIC_FRAGMENT_DIR)/mirage \
+$(MAGIC_FRAGMENT_DIR)/misctools \
+$(MAGIC_FRAGMENT_DIR)/mkid \
+$(MAGIC_FRAGMENT_DIR)/mlssa \
+$(MAGIC_FRAGMENT_DIR)/mmdf \
+$(MAGIC_FRAGMENT_DIR)/modem \
+$(MAGIC_FRAGMENT_DIR)/motorola \
+$(MAGIC_FRAGMENT_DIR)/mozilla \
+$(MAGIC_FRAGMENT_DIR)/msdos \
+$(MAGIC_FRAGMENT_DIR)/msvc \
+$(MAGIC_FRAGMENT_DIR)/mup \
+$(MAGIC_FRAGMENT_DIR)/natinst \
+$(MAGIC_FRAGMENT_DIR)/ncr \
+$(MAGIC_FRAGMENT_DIR)/netbsd \
+$(MAGIC_FRAGMENT_DIR)/netscape \
+$(MAGIC_FRAGMENT_DIR)/netware \
+$(MAGIC_FRAGMENT_DIR)/news \
+$(MAGIC_FRAGMENT_DIR)/nitpicker \
+$(MAGIC_FRAGMENT_DIR)/ocaml \
+$(MAGIC_FRAGMENT_DIR)/octave \
+$(MAGIC_FRAGMENT_DIR)/ole2compounddocs \
+$(MAGIC_FRAGMENT_DIR)/olf \
+$(MAGIC_FRAGMENT_DIR)/os2 \
+$(MAGIC_FRAGMENT_DIR)/os400 \
+$(MAGIC_FRAGMENT_DIR)/os9 \
+$(MAGIC_FRAGMENT_DIR)/osf1 \
+$(MAGIC_FRAGMENT_DIR)/palm \
+$(MAGIC_FRAGMENT_DIR)/parix \
+$(MAGIC_FRAGMENT_DIR)/pbm \
+$(MAGIC_FRAGMENT_DIR)/pdf \
+$(MAGIC_FRAGMENT_DIR)/pdp \
+$(MAGIC_FRAGMENT_DIR)/perl \
+$(MAGIC_FRAGMENT_DIR)/pgp \
+$(MAGIC_FRAGMENT_DIR)/pkgadd \
+$(MAGIC_FRAGMENT_DIR)/plan9 \
+$(MAGIC_FRAGMENT_DIR)/plus5 \
+$(MAGIC_FRAGMENT_DIR)/printer \
+$(MAGIC_FRAGMENT_DIR)/project \
+$(MAGIC_FRAGMENT_DIR)/psdbms \
+$(MAGIC_FRAGMENT_DIR)/psion \
+$(MAGIC_FRAGMENT_DIR)/pulsar \
+$(MAGIC_FRAGMENT_DIR)/pyramid \
+$(MAGIC_FRAGMENT_DIR)/python \
+$(MAGIC_FRAGMENT_DIR)/revision \
+$(MAGIC_FRAGMENT_DIR)/riff \
+$(MAGIC_FRAGMENT_DIR)/rpm \
+$(MAGIC_FRAGMENT_DIR)/rtf \
+$(MAGIC_FRAGMENT_DIR)/ruby \
+$(MAGIC_FRAGMENT_DIR)/sc \
+$(MAGIC_FRAGMENT_DIR)/sccs \
+$(MAGIC_FRAGMENT_DIR)/scientific \
+$(MAGIC_FRAGMENT_DIR)/securitycerts \
+$(MAGIC_FRAGMENT_DIR)/sendmail \
+$(MAGIC_FRAGMENT_DIR)/sequent \
+$(MAGIC_FRAGMENT_DIR)/sgi \
+$(MAGIC_FRAGMENT_DIR)/sgml \
+$(MAGIC_FRAGMENT_DIR)/sharc \
+$(MAGIC_FRAGMENT_DIR)/sinclair \
+$(MAGIC_FRAGMENT_DIR)/sketch \
+$(MAGIC_FRAGMENT_DIR)/smalltalk \
+$(MAGIC_FRAGMENT_DIR)/sniffer \
+$(MAGIC_FRAGMENT_DIR)/softquad \
+$(MAGIC_FRAGMENT_DIR)/spec \
+$(MAGIC_FRAGMENT_DIR)/spectrum \
+$(MAGIC_FRAGMENT_DIR)/sql \
+$(MAGIC_FRAGMENT_DIR)/sun \
+$(MAGIC_FRAGMENT_DIR)/sysex \
+$(MAGIC_FRAGMENT_DIR)/teapot \
+$(MAGIC_FRAGMENT_DIR)/terminfo \
+$(MAGIC_FRAGMENT_DIR)/tex \
+$(MAGIC_FRAGMENT_DIR)/tgif \
+$(MAGIC_FRAGMENT_DIR)/ti-8x \
+$(MAGIC_FRAGMENT_DIR)/timezone \
+$(MAGIC_FRAGMENT_DIR)/troff \
+$(MAGIC_FRAGMENT_DIR)/tuxedo \
+$(MAGIC_FRAGMENT_DIR)/typeset \
+$(MAGIC_FRAGMENT_DIR)/unicode \
+$(MAGIC_FRAGMENT_DIR)/unknown \
+$(MAGIC_FRAGMENT_DIR)/uuencode \
+$(MAGIC_FRAGMENT_DIR)/varied.out \
+$(MAGIC_FRAGMENT_DIR)/varied.script \
+$(MAGIC_FRAGMENT_DIR)/vax \
+$(MAGIC_FRAGMENT_DIR)/vicar \
+$(MAGIC_FRAGMENT_DIR)/virtutech \
+$(MAGIC_FRAGMENT_DIR)/visx \
+$(MAGIC_FRAGMENT_DIR)/vms \
+$(MAGIC_FRAGMENT_DIR)/vmware \
+$(MAGIC_FRAGMENT_DIR)/vorbis \
+$(MAGIC_FRAGMENT_DIR)/vxl \
+$(MAGIC_FRAGMENT_DIR)/warc \
+$(MAGIC_FRAGMENT_DIR)/weak \
+$(MAGIC_FRAGMENT_DIR)/windows \
+$(MAGIC_FRAGMENT_DIR)/wordprocessors \
+$(MAGIC_FRAGMENT_DIR)/xdelta \
+$(MAGIC_FRAGMENT_DIR)/xenix \
+$(MAGIC_FRAGMENT_DIR)/xilinx \
+$(MAGIC_FRAGMENT_DIR)/xo65 \
+$(MAGIC_FRAGMENT_DIR)/xwindows \
+$(MAGIC_FRAGMENT_DIR)/zilog \
+$(MAGIC_FRAGMENT_DIR)/zyxel
-magic: Header Localstuff $(magic_FRAGMENTS)
- cat $(srcdir)/Header $(srcdir)/Localstuff > $@
- for frag in $(magic_FRAGMENTS); do \
- if test -f $(srcdir)/$$frag; then \
- f=$(srcdir)/$$frag; \
- else \
- f=$$frag; \
- fi; \
- cat $$f; \
- done >> $@
+MAGIC = magic.mgc
+CLEANFILES = ${MAGIC}
+# FIXME: Build file natively as well so that it can be used to compile
+# the target's magic file
if IS_CROSS_COMPILE
FILE_COMPILE = file
+FILE_COMPILE_DEP =
else
FILE_COMPILE = $(top_builddir)/src/file
+FILE_COMPILE_DEP = $(FILE_COMPILE)
endif
-magic.mgc: magic
- $(FILE_COMPILE) -C -m magic
-
-magic.mime.mgc: magic.mime
- $(FILE_COMPILE) -C -m $(srcdir)/magic.mime
-
-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/basis \
-Magdir/bflt \
-Magdir/blender \
-Magdir/blit \
-Magdir/bout \
-Magdir/bsdi \
-Magdir/btsnoop \
-Magdir/cad \
-Magdir/cafebabe \
-Magdir/c-lang \
-Magdir/c64 \
-Magdir/cddb \
-Magdir/chord \
-Magdir/cisco \
-Magdir/citrus \
-Magdir/claris \
-Magdir/clipper \
-Magdir/cracklib \
-Magdir/spec \
-Magdir/commands \
-Magdir/communications \
-Magdir/compress \
-Magdir/console \
-Magdir/convex \
-Magdir/ctags \
-Magdir/dact \
-Magdir/database \
-Magdir/diamond \
-Magdir/diff \
-Magdir/digital \
-Magdir/dolby \
-Magdir/dump \
-Magdir/editors \
-Magdir/efi \
-Magdir/elf \
-Magdir/encore \
-Magdir/epoc \
-Magdir/esri \
-Magdir/fcs \
-Magdir/filesystems \
-Magdir/flash \
-Magdir/fonts \
-Magdir/fortran \
-Magdir/frame \
-Magdir/freebsd \
-Magdir/fsav \
-Magdir/games \
-Magdir/geos \
-Magdir/gcc \
-Magdir/gimp \
-Magdir/gnu \
-Magdir/grace \
-Magdir/gringotts \
-Magdir/hitachi-sh \
-Magdir/hp \
-Magdir/human68k \
-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/matroska \
-Magdir/mcrypt \
-Magdir/mime \
-Magdir/mips \
-Magdir/mirage \
-Magdir/misctools \
-Magdir/mkid \
-Magdir/mlssa \
-Magdir/mmdf \
-Magdir/modem \
-Magdir/motorola \
-Magdir/msdos \
-Magdir/msvc \
-Magdir/mup \
-Magdir/natinst \
-Magdir/ncr \
-Magdir/netbsd \
-Magdir/netscape \
-Magdir/news \
-Magdir/nitpicker \
-Magdir/ocaml \
-Magdir/octave \
-Magdir/olf \
-Magdir/os2 \
-Magdir/os400 \
-Magdir/os9 \
-Magdir/osf1 \
-Magdir/palm \
-Magdir/parix \
-Magdir/pbm \
-Magdir/pdf \
-Magdir/pdp \
-Magdir/perl \
-Magdir/pgp \
-Magdir/pkgadd \
-Magdir/plan9 \
-Magdir/plus5 \
-Magdir/printer \
-Magdir/project \
-Magdir/psdbms \
-Magdir/psion \
-Magdir/pulsar \
-Magdir/pyramid \
-Magdir/python \
-Magdir/revision \
-Magdir/riff \
-Magdir/rpm \
-Magdir/rtf \
-Magdir/sc \
-Magdir/sccs \
-Magdir/sendmail \
-Magdir/sequent \
-Magdir/sgi \
-Magdir/sgml \
-Magdir/sharc \
-Magdir/sinclair \
-Magdir/sketch \
-Magdir/smalltalk \
-Magdir/sniffer \
-Magdir/dyadic \
-Magdir/scientific \
-Magdir/softquad \
-Magdir/spectrum \
-Magdir/sql \
-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/unicode \
-Magdir/uuencode \
-Magdir/varied.out \
-Magdir/varied.script \
-Magdir/vax \
-Magdir/vicar \
-Magdir/virtutech \
-Magdir/visx \
-Magdir/vms \
-Magdir/vmware \
-Magdir/vorbis \
-Magdir/vxl \
-Magdir/wordprocessors \
-Magdir/xdelta \
-Magdir/xenix \
-Magdir/xo65 \
-Magdir/xwindows \
-Magdir/zilog \
-Magdir/zyxel
+${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP)
+ $(FILE_COMPILE) -C -m $(MAGIC_FRAGMENT_DIR)
+ @mv $(MAGIC_FRAGMENT_BASE).mgc $@
diff --git a/Makefile.in b/Makefile.in
index ba2ef9dfaa68..d52e20de8514 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -36,10 +36,10 @@ subdir = magic
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/configure.in
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
@@ -93,7 +93,6 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
@@ -109,6 +108,7 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
+WARNINGS = @WARNINGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
@@ -161,206 +161,238 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-pkgdata_DATA = magic magic.mime magic.mgc magic.mime.mgc
-EXTRA_DIST = magic2mime Localstuff Header magic.mime $(magic_FRAGMENTS)
-CLEANFILES = magic magic.mgc magic.mime.mgc
+
+#
+# $File: Makefile.am,v 1.43 2008/08/08 08:24:06 christos Exp $
+#
+MAGIC_FRAGMENT_BASE = Magdir
+MAGIC_FRAGMENT_DIR = $(top_srcdir)/magic/$(MAGIC_FRAGMENT_BASE)
+pkgdata_DATA = magic.mgc
+EXTRA_DIST = Header Localstuff \
+$(MAGIC_FRAGMENT_DIR)/acorn \
+$(MAGIC_FRAGMENT_DIR)/adi \
+$(MAGIC_FRAGMENT_DIR)/adventure \
+$(MAGIC_FRAGMENT_DIR)/allegro \
+$(MAGIC_FRAGMENT_DIR)/alliant \
+$(MAGIC_FRAGMENT_DIR)/alpha \
+$(MAGIC_FRAGMENT_DIR)/amanda \
+$(MAGIC_FRAGMENT_DIR)/amigaos \
+$(MAGIC_FRAGMENT_DIR)/animation \
+$(MAGIC_FRAGMENT_DIR)/apl \
+$(MAGIC_FRAGMENT_DIR)/apple \
+$(MAGIC_FRAGMENT_DIR)/applix \
+$(MAGIC_FRAGMENT_DIR)/archive \
+$(MAGIC_FRAGMENT_DIR)/asterix \
+$(MAGIC_FRAGMENT_DIR)/att3b \
+$(MAGIC_FRAGMENT_DIR)/audio \
+$(MAGIC_FRAGMENT_DIR)/basis \
+$(MAGIC_FRAGMENT_DIR)/bflt \
+$(MAGIC_FRAGMENT_DIR)/blender \
+$(MAGIC_FRAGMENT_DIR)/blit \
+$(MAGIC_FRAGMENT_DIR)/bout \
+$(MAGIC_FRAGMENT_DIR)/bsdi \
+$(MAGIC_FRAGMENT_DIR)/btsnoop \
+$(MAGIC_FRAGMENT_DIR)/c-lang \
+$(MAGIC_FRAGMENT_DIR)/c64 \
+$(MAGIC_FRAGMENT_DIR)/cad \
+$(MAGIC_FRAGMENT_DIR)/cafebabe \
+$(MAGIC_FRAGMENT_DIR)/cddb \
+$(MAGIC_FRAGMENT_DIR)/chord \
+$(MAGIC_FRAGMENT_DIR)/cisco \
+$(MAGIC_FRAGMENT_DIR)/citrus \
+$(MAGIC_FRAGMENT_DIR)/clarion \
+$(MAGIC_FRAGMENT_DIR)/claris \
+$(MAGIC_FRAGMENT_DIR)/clipper \
+$(MAGIC_FRAGMENT_DIR)/commands \
+$(MAGIC_FRAGMENT_DIR)/communications \
+$(MAGIC_FRAGMENT_DIR)/compress \
+$(MAGIC_FRAGMENT_DIR)/console \
+$(MAGIC_FRAGMENT_DIR)/convex \
+$(MAGIC_FRAGMENT_DIR)/cracklib \
+$(MAGIC_FRAGMENT_DIR)/ctags \
+$(MAGIC_FRAGMENT_DIR)/dact \
+$(MAGIC_FRAGMENT_DIR)/database \
+$(MAGIC_FRAGMENT_DIR)/diamond \
+$(MAGIC_FRAGMENT_DIR)/diff \
+$(MAGIC_FRAGMENT_DIR)/digital \
+$(MAGIC_FRAGMENT_DIR)/dolby \
+$(MAGIC_FRAGMENT_DIR)/dump \
+$(MAGIC_FRAGMENT_DIR)/dyadic \
+$(MAGIC_FRAGMENT_DIR)/editors \
+$(MAGIC_FRAGMENT_DIR)/efi \
+$(MAGIC_FRAGMENT_DIR)/elf \
+$(MAGIC_FRAGMENT_DIR)/encore \
+$(MAGIC_FRAGMENT_DIR)/epoc \
+$(MAGIC_FRAGMENT_DIR)/erlang \
+$(MAGIC_FRAGMENT_DIR)/esri \
+$(MAGIC_FRAGMENT_DIR)/fcs \
+$(MAGIC_FRAGMENT_DIR)/filesystems \
+$(MAGIC_FRAGMENT_DIR)/flash \
+$(MAGIC_FRAGMENT_DIR)/fonts \
+$(MAGIC_FRAGMENT_DIR)/fortran \
+$(MAGIC_FRAGMENT_DIR)/frame \
+$(MAGIC_FRAGMENT_DIR)/freebsd \
+$(MAGIC_FRAGMENT_DIR)/fsav \
+$(MAGIC_FRAGMENT_DIR)/games \
+$(MAGIC_FRAGMENT_DIR)/gcc \
+$(MAGIC_FRAGMENT_DIR)/geos \
+$(MAGIC_FRAGMENT_DIR)/gimp \
+$(MAGIC_FRAGMENT_DIR)/gnome-keyring \
+$(MAGIC_FRAGMENT_DIR)/gnu \
+$(MAGIC_FRAGMENT_DIR)/gnumeric \
+$(MAGIC_FRAGMENT_DIR)/grace \
+$(MAGIC_FRAGMENT_DIR)/graphviz \
+$(MAGIC_FRAGMENT_DIR)/gringotts \
+$(MAGIC_FRAGMENT_DIR)/hitachi-sh \
+$(MAGIC_FRAGMENT_DIR)/hp \
+$(MAGIC_FRAGMENT_DIR)/human68k \
+$(MAGIC_FRAGMENT_DIR)/ibm370 \
+$(MAGIC_FRAGMENT_DIR)/ibm6000 \
+$(MAGIC_FRAGMENT_DIR)/iff \
+$(MAGIC_FRAGMENT_DIR)/images \
+$(MAGIC_FRAGMENT_DIR)/inform \
+$(MAGIC_FRAGMENT_DIR)/intel \
+$(MAGIC_FRAGMENT_DIR)/interleaf \
+$(MAGIC_FRAGMENT_DIR)/island \
+$(MAGIC_FRAGMENT_DIR)/ispell \
+$(MAGIC_FRAGMENT_DIR)/java \
+$(MAGIC_FRAGMENT_DIR)/jpeg \
+$(MAGIC_FRAGMENT_DIR)/karma \
+$(MAGIC_FRAGMENT_DIR)/kde \
+$(MAGIC_FRAGMENT_DIR)/lecter \
+$(MAGIC_FRAGMENT_DIR)/lex \
+$(MAGIC_FRAGMENT_DIR)/lif \
+$(MAGIC_FRAGMENT_DIR)/linux \
+$(MAGIC_FRAGMENT_DIR)/lisp \
+$(MAGIC_FRAGMENT_DIR)/llvm \
+$(MAGIC_FRAGMENT_DIR)/lua \
+$(MAGIC_FRAGMENT_DIR)/luks \
+$(MAGIC_FRAGMENT_DIR)/mach \
+$(MAGIC_FRAGMENT_DIR)/macintosh \
+$(MAGIC_FRAGMENT_DIR)/magic \
+$(MAGIC_FRAGMENT_DIR)/mail.news \
+$(MAGIC_FRAGMENT_DIR)/maple \
+$(MAGIC_FRAGMENT_DIR)/mathcad \
+$(MAGIC_FRAGMENT_DIR)/mathematica \
+$(MAGIC_FRAGMENT_DIR)/matroska \
+$(MAGIC_FRAGMENT_DIR)/mcrypt \
+$(MAGIC_FRAGMENT_DIR)/mercurial \
+$(MAGIC_FRAGMENT_DIR)/mime \
+$(MAGIC_FRAGMENT_DIR)/mips \
+$(MAGIC_FRAGMENT_DIR)/mirage \
+$(MAGIC_FRAGMENT_DIR)/misctools \
+$(MAGIC_FRAGMENT_DIR)/mkid \
+$(MAGIC_FRAGMENT_DIR)/mlssa \
+$(MAGIC_FRAGMENT_DIR)/mmdf \
+$(MAGIC_FRAGMENT_DIR)/modem \
+$(MAGIC_FRAGMENT_DIR)/motorola \
+$(MAGIC_FRAGMENT_DIR)/mozilla \
+$(MAGIC_FRAGMENT_DIR)/msdos \
+$(MAGIC_FRAGMENT_DIR)/msvc \
+$(MAGIC_FRAGMENT_DIR)/mup \
+$(MAGIC_FRAGMENT_DIR)/natinst \
+$(MAGIC_FRAGMENT_DIR)/ncr \
+$(MAGIC_FRAGMENT_DIR)/netbsd \
+$(MAGIC_FRAGMENT_DIR)/netscape \
+$(MAGIC_FRAGMENT_DIR)/netware \
+$(MAGIC_FRAGMENT_DIR)/news \
+$(MAGIC_FRAGMENT_DIR)/nitpicker \
+$(MAGIC_FRAGMENT_DIR)/ocaml \
+$(MAGIC_FRAGMENT_DIR)/octave \
+$(MAGIC_FRAGMENT_DIR)/ole2compounddocs \
+$(MAGIC_FRAGMENT_DIR)/olf \
+$(MAGIC_FRAGMENT_DIR)/os2 \
+$(MAGIC_FRAGMENT_DIR)/os400 \
+$(MAGIC_FRAGMENT_DIR)/os9 \
+$(MAGIC_FRAGMENT_DIR)/osf1 \
+$(MAGIC_FRAGMENT_DIR)/palm \
+$(MAGIC_FRAGMENT_DIR)/parix \
+$(MAGIC_FRAGMENT_DIR)/pbm \
+$(MAGIC_FRAGMENT_DIR)/pdf \
+$(MAGIC_FRAGMENT_DIR)/pdp \
+$(MAGIC_FRAGMENT_DIR)/perl \
+$(MAGIC_FRAGMENT_DIR)/pgp \
+$(MAGIC_FRAGMENT_DIR)/pkgadd \
+$(MAGIC_FRAGMENT_DIR)/plan9 \
+$(MAGIC_FRAGMENT_DIR)/plus5 \
+$(MAGIC_FRAGMENT_DIR)/printer \
+$(MAGIC_FRAGMENT_DIR)/project \
+$(MAGIC_FRAGMENT_DIR)/psdbms \
+$(MAGIC_FRAGMENT_DIR)/psion \
+$(MAGIC_FRAGMENT_DIR)/pulsar \
+$(MAGIC_FRAGMENT_DIR)/pyramid \
+$(MAGIC_FRAGMENT_DIR)/python \
+$(MAGIC_FRAGMENT_DIR)/revision \
+$(MAGIC_FRAGMENT_DIR)/riff \
+$(MAGIC_FRAGMENT_DIR)/rpm \
+$(MAGIC_FRAGMENT_DIR)/rtf \
+$(MAGIC_FRAGMENT_DIR)/ruby \
+$(MAGIC_FRAGMENT_DIR)/sc \
+$(MAGIC_FRAGMENT_DIR)/sccs \
+$(MAGIC_FRAGMENT_DIR)/scientific \
+$(MAGIC_FRAGMENT_DIR)/securitycerts \
+$(MAGIC_FRAGMENT_DIR)/sendmail \
+$(MAGIC_FRAGMENT_DIR)/sequent \
+$(MAGIC_FRAGMENT_DIR)/sgi \
+$(MAGIC_FRAGMENT_DIR)/sgml \
+$(MAGIC_FRAGMENT_DIR)/sharc \
+$(MAGIC_FRAGMENT_DIR)/sinclair \
+$(MAGIC_FRAGMENT_DIR)/sketch \
+$(MAGIC_FRAGMENT_DIR)/smalltalk \
+$(MAGIC_FRAGMENT_DIR)/sniffer \
+$(MAGIC_FRAGMENT_DIR)/softquad \
+$(MAGIC_FRAGMENT_DIR)/spec \
+$(MAGIC_FRAGMENT_DIR)/spectrum \
+$(MAGIC_FRAGMENT_DIR)/sql \
+$(MAGIC_FRAGMENT_DIR)/sun \
+$(MAGIC_FRAGMENT_DIR)/sysex \
+$(MAGIC_FRAGMENT_DIR)/teapot \
+$(MAGIC_FRAGMENT_DIR)/terminfo \
+$(MAGIC_FRAGMENT_DIR)/tex \
+$(MAGIC_FRAGMENT_DIR)/tgif \
+$(MAGIC_FRAGMENT_DIR)/ti-8x \
+$(MAGIC_FRAGMENT_DIR)/timezone \
+$(MAGIC_FRAGMENT_DIR)/troff \
+$(MAGIC_FRAGMENT_DIR)/tuxedo \
+$(MAGIC_FRAGMENT_DIR)/typeset \
+$(MAGIC_FRAGMENT_DIR)/unicode \
+$(MAGIC_FRAGMENT_DIR)/unknown \
+$(MAGIC_FRAGMENT_DIR)/uuencode \
+$(MAGIC_FRAGMENT_DIR)/varied.out \
+$(MAGIC_FRAGMENT_DIR)/varied.script \
+$(MAGIC_FRAGMENT_DIR)/vax \
+$(MAGIC_FRAGMENT_DIR)/vicar \
+$(MAGIC_FRAGMENT_DIR)/virtutech \
+$(MAGIC_FRAGMENT_DIR)/visx \
+$(MAGIC_FRAGMENT_DIR)/vms \
+$(MAGIC_FRAGMENT_DIR)/vmware \
+$(MAGIC_FRAGMENT_DIR)/vorbis \
+$(MAGIC_FRAGMENT_DIR)/vxl \
+$(MAGIC_FRAGMENT_DIR)/warc \
+$(MAGIC_FRAGMENT_DIR)/weak \
+$(MAGIC_FRAGMENT_DIR)/windows \
+$(MAGIC_FRAGMENT_DIR)/wordprocessors \
+$(MAGIC_FRAGMENT_DIR)/xdelta \
+$(MAGIC_FRAGMENT_DIR)/xenix \
+$(MAGIC_FRAGMENT_DIR)/xilinx \
+$(MAGIC_FRAGMENT_DIR)/xo65 \
+$(MAGIC_FRAGMENT_DIR)/xwindows \
+$(MAGIC_FRAGMENT_DIR)/zilog \
+$(MAGIC_FRAGMENT_DIR)/zyxel
+
+MAGIC = magic.mgc
+CLEANFILES = ${MAGIC}
@IS_CROSS_COMPILE_FALSE@FILE_COMPILE = $(top_builddir)/src/file
-@IS_CROSS_COMPILE_TRUE@FILE_COMPILE = file
-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/basis \
-Magdir/bflt \
-Magdir/blender \
-Magdir/blit \
-Magdir/bout \
-Magdir/bsdi \
-Magdir/btsnoop \
-Magdir/cad \
-Magdir/cafebabe \
-Magdir/c-lang \
-Magdir/c64 \
-Magdir/cddb \
-Magdir/chord \
-Magdir/cisco \
-Magdir/citrus \
-Magdir/claris \
-Magdir/clipper \
-Magdir/cracklib \
-Magdir/spec \
-Magdir/commands \
-Magdir/communications \
-Magdir/compress \
-Magdir/console \
-Magdir/convex \
-Magdir/ctags \
-Magdir/dact \
-Magdir/database \
-Magdir/diamond \
-Magdir/diff \
-Magdir/digital \
-Magdir/dolby \
-Magdir/dump \
-Magdir/editors \
-Magdir/efi \
-Magdir/elf \
-Magdir/encore \
-Magdir/epoc \
-Magdir/esri \
-Magdir/fcs \
-Magdir/filesystems \
-Magdir/flash \
-Magdir/fonts \
-Magdir/fortran \
-Magdir/frame \
-Magdir/freebsd \
-Magdir/fsav \
-Magdir/games \
-Magdir/geos \
-Magdir/gcc \
-Magdir/gimp \
-Magdir/gnu \
-Magdir/grace \
-Magdir/gringotts \
-Magdir/hitachi-sh \
-Magdir/hp \
-Magdir/human68k \
-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/matroska \
-Magdir/mcrypt \
-Magdir/mime \
-Magdir/mips \
-Magdir/mirage \
-Magdir/misctools \
-Magdir/mkid \
-Magdir/mlssa \
-Magdir/mmdf \
-Magdir/modem \
-Magdir/motorola \
-Magdir/msdos \
-Magdir/msvc \
-Magdir/mup \
-Magdir/natinst \
-Magdir/ncr \
-Magdir/netbsd \
-Magdir/netscape \
-Magdir/news \
-Magdir/nitpicker \
-Magdir/ocaml \
-Magdir/octave \
-Magdir/olf \
-Magdir/os2 \
-Magdir/os400 \
-Magdir/os9 \
-Magdir/osf1 \
-Magdir/palm \
-Magdir/parix \
-Magdir/pbm \
-Magdir/pdf \
-Magdir/pdp \
-Magdir/perl \
-Magdir/pgp \
-Magdir/pkgadd \
-Magdir/plan9 \
-Magdir/plus5 \
-Magdir/printer \
-Magdir/project \
-Magdir/psdbms \
-Magdir/psion \
-Magdir/pulsar \
-Magdir/pyramid \
-Magdir/python \
-Magdir/revision \
-Magdir/riff \
-Magdir/rpm \
-Magdir/rtf \
-Magdir/sc \
-Magdir/sccs \
-Magdir/sendmail \
-Magdir/sequent \
-Magdir/sgi \
-Magdir/sgml \
-Magdir/sharc \
-Magdir/sinclair \
-Magdir/sketch \
-Magdir/smalltalk \
-Magdir/sniffer \
-Magdir/dyadic \
-Magdir/scientific \
-Magdir/softquad \
-Magdir/spectrum \
-Magdir/sql \
-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/unicode \
-Magdir/uuencode \
-Magdir/varied.out \
-Magdir/varied.script \
-Magdir/vax \
-Magdir/vicar \
-Magdir/virtutech \
-Magdir/visx \
-Magdir/vms \
-Magdir/vmware \
-Magdir/vorbis \
-Magdir/vxl \
-Magdir/wordprocessors \
-Magdir/xdelta \
-Magdir/xenix \
-Magdir/xo65 \
-Magdir/xwindows \
-Magdir/zilog \
-Magdir/zyxel
+# FIXME: Build file natively as well so that it can be used to compile
+# the target's magic file
+@IS_CROSS_COMPILE_TRUE@FILE_COMPILE = file
+@IS_CROSS_COMPILE_FALSE@FILE_COMPILE_DEP = $(FILE_COMPILE)
+@IS_CROSS_COMPILE_TRUE@FILE_COMPILE_DEP =
all: all-am
.SUFFIXES:
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
@@ -385,9 +417,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
mostlyclean-libtool:
@@ -546,22 +578,9 @@ uninstall-am: uninstall-pkgdataDATA
uninstall uninstall-am uninstall-pkgdataDATA
-magic: Header Localstuff $(magic_FRAGMENTS)
- cat $(srcdir)/Header $(srcdir)/Localstuff > $@
- for frag in $(magic_FRAGMENTS); do \
- if test -f $(srcdir)/$$frag; then \
- f=$(srcdir)/$$frag; \
- else \
- f=$$frag; \
- fi; \
- cat $$f; \
- done >> $@
-
-magic.mgc: magic
- $(FILE_COMPILE) -C -m magic
-
-magic.mime.mgc: magic.mime
- $(FILE_COMPILE) -C -m $(srcdir)/magic.mime
+${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP)
+ $(FILE_COMPILE) -C -m $(MAGIC_FRAGMENT_DIR)
+ @mv $(MAGIC_FRAGMENT_BASE).mgc $@
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/Makefile.std b/Makefile.std
deleted file mode 100644
index ff2a9b5ddc92..000000000000
--- a/Makefile.std
+++ /dev/null
@@ -1,167 +0,0 @@
-# Makefile for file(1) cmd.
-# Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE.
-# @(#)$Id: Makefile.std,v 1.17 2003/02/27 20:47:45 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.
-#
-# Permission is granted to anyone to use this software for any purpose on
-# any computer system, and to alter it and redistribute it freely, subject
-# to the following restrictions:
-#
-# 1. The author is not responsible for the consequences of use of this
-# software, no matter how awful, even if they arise from flaws in it.
-#
-# 2. The origin of this software must not be misrepresented, either by
-# explicit claim or by omission. Since few users ever read sources,
-# credits must appear in the documentation.
-#
-# 3. Altered versions must be plainly marked as such, and must not be
-# misrepresented as being the original software. Since few users
-# ever read sources, credits must appear in the documentation.
-#
-# 4. This notice may not be removed or altered.
-#
-VERSION = 3.41
-SHELL = /bin/sh
-#MAGIC = /etc/magic
-MAGIC = /usr/local/etc/magic
-DEFS = -DMAGIC='"$(MAGIC)"' -DBUILTIN_ELF # -Dvoid=int
-CC = cc
-COPTS = -O -g # newer compilers allow both; else drop -O
-# For truly antique environments, use this for (dummy) include files:
-COPTS = -O # -Ilocalinc
-CFLAGS = $(COPTS) $(DEFS)
-LDFLAGS = $(COPTS) # -Bstatic # older gdb couldn't handle shared libs
-SHAR = bundle
-OFILE = /usr/bin/file # old or distributed version, for comparison
-# Where new binary lives; typically /usr/local (BSD), /usr/lbin (USG).
-BINDIR = /usr/local/bin
-# For installing our man pages;
-# MANCxxx is manual section for Commands, MANFxxx is section for file formats.
-# MANxDIR is directory names; MANxEXT is the filename extention. Usual values:
-# Variable V7 4BSD Sys V
-# MANCDIR /usr/man/man1 /usr/man/man1 /usr/man/u_man/man1
-# MANFDIR /usr/man/man5 /usr/man/man5 /usr/man/u_man/man4
-# MANCEXT 1 1 1
-# MANFEXT 5 5 4
-# --- possible alternative for 4BSD ---
-# MANCDIR /usr/local/man/man1
-# MANCEXT 1
-# or
-# MANCDIR /usr/man/manl
-# MANCEXT l
-# --- possible alternative for USG ---
-# MANCDIR /usr/man/local/man1
-# MANCEXT 1
-
-MANCDIR = /usr/local/man/man1
-MANCEXT = 1
-MANFDIR = /usr/local/man/man4
-MANFEXT = 4
-
-# There are no system-dependant configuration options (except maybe CFLAGS).
-# Uncomment any of these that is missing from your "standard" library.
-LOCALSRCS = # localsrc/getopt.c localsrc/strtol.c \
-# localsrc/strtok.c localsrc/strchr.c
-LOCALOBJS = # localsrc/getopt.o localsrc/strtol.o \
-# localsrc/strtok.o localsrc/strchr.o
-# These are not compiled in unless you use -Ilocalinc, but
-# are not commented out as "make dist" &c use them.
-LOCALINC = # localinc/*.h localinc/sys/*.h
-
-SRCS = file.c apprentice.c fsmagic.c softmagic.c ascmagic.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 \
- print.o $(LOCALOBJS)
-HDRS = file.h names.h patchlevel.h readelf.h tar.h
-
-AUTOSRC=configure configure.in install-sh config.h.in Makefile.in
-ALLSRC = LEGAL.NOTICE README MAINT PORTING $(SRCS) $(HDRS) \
- Makefile.std file.man magic.man magic2mime $(AUTOSRC) \
- Localstuff Header
-ALLMAGIC = Magdir/[a-z]*
-
-all: file magic file.${MANCEXT} magic.${MANFEXT}
-
-TESTFILES = * tst/*
-try: all $(OFILE)
- cd tst; $(MAKE)
- time $(OFILE) $(TESTFILES) >/tmp/t1 # can't use ./magic
- time ./file -m ./magic $(TESTFILES) >/tmp/t2
- -diff -b /tmp/t[12]
- what ./file >lastnocore
-
-file: $(OBJS)
- $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
-lint: $(SRCS)
- lint -ha $(DEFS) $(SRCS) | tee $@
-magic: Localstuff Header Magdir
- cat Header Localstuff Magdir/[a-z] > $@
-
-ascmagic.o: names.h
-
-compress.o apprentice.o ascmagic.o file.o fsmagic.o print.o softmagic.o: file.h
-
-install: file magic
- cp file $(BINDIR)/file
- cp magic $(MAGIC)
-
-install.man: file.${MANCEXT} magic.${MANFEXT}
- cp file.${MANCEXT} $(MANCDIR)/file.$(MANCEXT)
- cp magic.${MANFEXT} $(MANFDIR)/magic.$(MANFEXT)
-
-clean:
- rm -f *.o core file magic lint dist.* MANIFEST \
- magic.${MANFEXT} file.${MANCEXT} \
- config.h config.status config.cache config.log
-clobber:
- cd tst; $(MAKE) clean
-
-
-magic.${MANFEXT} : Makefile magic.man
- @rm -f $@
- sed -e s@__CSECTION__@${MANCEXT}@g \
- -e s@__FSECTION__@${MANFEXT}@g \
- -e s@__VERSION__@${VERSION}@g \
- -e s@__MAGIC__@${MAGIC}@g magic.man > $@
-
-file.${MANCEXT} : Makefile file.man
- @rm -f $@
- sed -e s@__CSECTION__@${MANCEXT}@g \
- -e s@__FSECTION__@${MANFEXT}@g \
- -e s@__VERSION__@${VERSION}@g \
- -e s@__MAGIC__@${MAGIC}@g file.man > $@
-
-send: dist
- ftp ftp.cs
-
-dist: dist.src dist.magic
- @echo Now check this patchlevel!
- ident patchlevel.h
-
-dist.src: $(ALLSRC) MANIFEST
-# Some versions of shar can't handle a single file from
-# a subdirectory, so we manually insert mkdir as needed.
-# The point is to exclude all the generable targets in tst.
- (echo mkdir localinc localinc/sys localsrc tst; \
- $(SHAR) $(ALLSRC) MANIFEST) > $@
-
-rcsdiff: $(ALLSRC)
- rcsdiff -q RCS/*
-
-MANIFEST: $(ALLSRC)
- ident $(ALLSRC) > MANIFEST
-dist.magic: Magdir
-# As above, but to exclude Magdir/RCS from being shipped.
- (echo mkdir Magdir; $(SHAR) $(ALLMAGIC)) >$@
-
-tar: $(ALLSRC) $(ALLMAGIC)
- -rm -fr file-${VERSION}
- -mkdir file-${VERSION} file-${VERSION}/Magdir
- ln $(ALLSRC) file-${VERSION}
- ln ${ALLMAGIC} file-${VERSION}/Magdir
- tar cvf file-${VERSION}.tar file-${VERSION}
- -rm -fr file-${VERSION}
diff --git a/NEWS b/NEWS
new file mode 100644
index 000000000000..939a2790ecc9
--- /dev/null
+++ b/NEWS
@@ -0,0 +1 @@
+See ChangeLog. \ No newline at end of file
diff --git a/PORTING b/PORTING
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/PORTING
+++ /dev/null
diff --git a/README b/README
index b7e9d559dca8..30b9fa832043 100644
--- a/README
+++ b/README
@@ -1,5 +1,10 @@
** README for file(1) Command **
-@(#) $File: README,v 1.34 2006/05/03 18:48:33 christos Exp $
+@(#) $File: README,v 1.40 2008/04/23 03:45:20 christos Exp $
+
+E-mail: christos@astron.com
+Mailing List: file@mx.gw.com
+
+Phone: Do not even think of telephoning me about this program. Send cash first!
This is Release 4.x of Ian Darwin's (copyright but distributable)
file(1) command. This version is the standard "file" command for Linux,
@@ -41,7 +46,7 @@ magic numbers assigned to all sorts of data files that
are in reasonable circulation. Send your magic numbers,
in magic(5) format please, to the maintainer, Christos Zoulas.
-LEGAL.NOTICE - read this first.
+COPYING - read this first.
README - read this second (you are currently reading this file).
PORTING - read this only if the program won't compile.
Makefile - read this next, adapt it as needed (particularly
@@ -71,6 +76,31 @@ readelf.[ch] - Stand-alone elf parsing code.
compress.c - on-the-fly decompression.
print.c - print results, errors, warnings.
+------------------------------------------------------------------------------
+
+If you submit a new magic entry please make sure you read the following
+guidelines:
+
+- Initial match is preferably at least 32 bits long, and is a _unique_ match
+- If this is not feasible, use additional check
+- Match of <= 16 bits are not accepted
+- Delay printing string as much as possible, don't print output too early
+- Avoid printf arbitrary byte as string, which can be a source of
+ crash and buffer overflow
+
+- Provide complete information with entry:
+ * One line short summary
+ * Optional long description
+ * File extension, if applicable
+ * Full name and contact method (for discussion when entry has problem)
+ * Further reference, such as documentation of format
+
+------------------------------------------------------------------------------
+
+You can download the latest version of file from:
+
+ ftp://ftp.astron.com/pub/file/
+
If your gzip sometimes fails to decompress things complaining about a short
file, apply this patch [which is going to be in the next version of gzip]:
*** - Tue Oct 29 02:06:35 1996
@@ -85,10 +115,6 @@ file, apply this patch [which is going to be in the next version of gzip]:
}
bytes_in += (ulg)insize;
-E-mail: christos@astron.com
-
-Phone: Do not even think of telephoning me about this program. Send cash first!
-
Parts of this software were developed at SoftQuad Inc., developers
of SGML/HTML/XML publishing software, in Toronto, Canada.
SoftQuad was swallowed up by Corel in 2002
diff --git a/TODO b/TODO
new file mode 100644
index 000000000000..50fd87fbd284
--- /dev/null
+++ b/TODO
@@ -0,0 +1,9 @@
+Continue to squash all magic bugs. See Debian BTS for a good source.
+
+Store arbitrarily long strings, for example for %s patterns, so that
+they can be printed out. Fixes Debian bug #271672.
+
+Add syntax for other sorts of counted string (Debian bug #466032). Use
+to fix bug #283760.
+
+Add syntax for relative offsets after current level (Debian bug #466037).
diff --git a/acinclude.m4 b/acinclude.m4
index f92a2d1db95e..31677b18215b 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,19 +1,3 @@
-dnl cloned from autoconf 2.13 acspecific.m4
-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
-else
-AC_TRY_RUN([int main() {
-long long foo = 0;
-exit(sizeof(long long) < sizeof(long)); }],
-ac_cv_c_long_long=yes, ac_cv_c_long_long=no)
-fi])
-if test $ac_cv_c_long_long = yes; then
- AC_DEFINE(HAVE_LONG_LONG)
-fi
-])
-
dnl from autoconf 2.13 acspecific.m4, with changes to check for daylight
AC_DEFUN([AC_STRUCT_TIMEZONE_DAYLIGHT],
@@ -43,7 +27,7 @@ AC_CACHE_CHECK([for tm_isdst in struct tm], ac_cv_struct_tm_isdst,
#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_isdst;],
ac_cv_struct_tm_isdst=yes, ac_cv_struct_tm_isdst=no)])
if test "$ac_cv_struct_tm_isdst" = yes; then
- AC_DEFINE(HAVE_TM_ISDST)
+ AC_DEFINE(HAVE_TM_ISDST,1,[HAVE_TM_ISDST])
fi
AC_CACHE_CHECK(for daylight, ac_cv_var_daylight,
[AC_TRY_LINK(
@@ -55,226 +39,6 @@ extern int daylight;
changequote([, ])dnl
[atoi(daylight);], ac_cv_var_daylight=yes, ac_cv_var_daylight=no)])
if test $ac_cv_var_daylight = yes; then
- AC_DEFINE(HAVE_DAYLIGHT)
+ AC_DEFINE(HAVE_DAYLIGHT,1,[HAVE_DAYLIGHT])
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
-dnl now include <stdint.h> 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
-[(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]],
-[#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif], eval "ac_cv_type_$1=yes", eval "ac_cv_type_$1=no")])dnl
-if eval "test \"`echo '$ac_cv_type_'$1`\" = yes"; then
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
- AC_DEFINE_UNQUOTED($1, $2)
-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],
-[dnl The name to #define.
-define([AC_TYPE_NAME], translit(sizeof_$1, [[[a-z *]]], [[[A-Z_P]]]))dnl
-dnl The cache variable name.
-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
-#include <stdio.h>
-main()
-{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof($1));
- exit(0);
-}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl
-AC_MSG_RESULT($AC_CV_NAME)
-AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
-undefine([AC_TYPE_NAME])dnl
-undefine([AC_CV_NAME])dnl
-])
-
-dnl AC_CHECK_SIZEOF_STDC_HEADERS(TYPE [, CROSS_SIZE])
-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 <stdint.h>
-#endif
-#include <sys/types.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#endif
-])
-])
-
-
-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 <stdint.h>
-#endif
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#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)])
-
-dnl By default, many hosts won't let programs access large files;
-dnl one must use special compiler options to get large-file access to work.
-dnl For more details about this brain damage please see:
-dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
-
-dnl Written by Paul Eggert <eggert@twinsun.com>.
-
-dnl Internal subroutine of AC_SYS_LARGEFILE.
-dnl AC_SYS_LARGEFILE_TEST_INCLUDES
-AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES],
- [[#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply "#define LARGE_OFF_T 9223372036854775807",
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
- ]])
-
-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_CACHE_CHECK([for $1 value needed for large files], $3,
- [$3=no
- AC_TRY_COMPILE([$5],
- [$6],
- ,
- [AC_TRY_COMPILE([#define $1 $2]
-[$5]
- ,
- [$6],
- [$3=$2])])])
- if test "[$]$3" != no; then
- AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
- fi])
-
-AC_DEFUN([AC_SYS_LARGEFILE],
- [AC_REQUIRE([AC_PROG_CC])
- AC_ARG_ENABLE(largefile,
- [ --disable-largefile omit support for large files])
- if test "$enable_largefile" != no; then
-
- AC_CACHE_CHECK([for special C compiler options needed for large files=
-],
- ac_cv_sys_largefile_CC,
- [ac_cv_sys_largefile_CC=no
- if test "$GCC" != yes; then
- # IRIX 6.2 and later do not support large files by default,
- # so use the C compiler's -n32 option if that helps.
- AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
- [ac_save_CC="$CC"
- CC="$CC -n32"
- AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
- ac_cv_sys_largefile_CC=' -n32')
- CC="$ac_save_CC"])
- fi])
- if test "$ac_cv_sys_largefile_CC" != no; then
- CC="$CC$ac_cv_sys_largefile_CC"
- fi
-
- AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
- ac_cv_sys_file_offset_bits,
- [Number of bits in a file offset, on hosts where this is settable.],
- AC_SYS_LARGEFILE_TEST_INCLUDES)
- AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
- ac_cv_sys_large_files,
- [Define for large files, on AIX-style hosts.],
- AC_SYS_LARGEFILE_TEST_INCLUDES)
- fi
- ])
-
-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).],
- [#include <stdio.h>], [return !fseeko;])
- # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
- # in glibc 2.1.3, but that breaks too many other things.
- # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
-
- AC_CACHE_CHECK([for fseeko], ac_cv_func_fseeko,
- [ac_cv_func_fseeko=no
- AC_TRY_LINK([#include <stdio.h>],
- [return fseeko && fseeko (stdin, 0, 0);],
- [ac_cv_func_fseeko=yes])])
- if test $ac_cv_func_fseeko != no; then
- AC_DEFINE(HAVE_FSEEKO, 1,
- [Define if fseeko (and presumably ftello) exists and is declared.])
- fi])
-
-# From Paul Eggert.
-
-# BeOS 5 has <wchar.h> but does not define mbstate_t,
-# so you can't declare an object of that type.
-# Check for this incompatibility with Standard C.
-
-# Include stdlib.h first, because otherwise this test would fail on Linux
-# (at least glibc-2.1.3) because the "_XOPEN_SOURCE 500" definition elicits
-# a syntax error in wchar.h due to the use of undefined __int32_t.
-AC_DEFUN([AC_MBSTATE_T],
- [
- AC_CHECK_HEADERS(stdlib.h)
-
- AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
- [AC_TRY_COMPILE([
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-#include <wchar.h>],
- [mbstate_t x; return sizeof x;],
- ac_cv_type_mbstate_t=yes,
- ac_cv_type_mbstate_t=no)])
- if test $ac_cv_type_mbstate_t = no; then
- AC_DEFINE(mbstate_t, int,
- [Define to a type if <wchar.h> does not define.])
- fi])
-
-
diff --git a/aclocal.m4 b/aclocal.m4
index c46c0411407a..593d2e957b4b 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -6685,35 +6685,6 @@ fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
-# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
-# From Jim Meyering
-
-# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
-# Free Software Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# serial 4
-
-AC_DEFUN([AM_MAINTAINER_MODE],
-[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
- dnl maintainer-mode is disabled by default
- AC_ARG_ENABLE(maintainer-mode,
-[ --enable-maintainer-mode enable make rules and dependencies not useful
- (and sometimes confusing) to the casual installer],
- USE_MAINTAINER_MODE=$enableval,
- USE_MAINTAINER_MODE=no)
- AC_MSG_RESULT([$USE_MAINTAINER_MODE])
- AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
- MAINT=$MAINTAINER_MODE_TRUE
- AC_SUBST(MAINT)dnl
-]
-)
-
-AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
-
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
@@ -6766,6 +6737,40 @@ AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
+# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 5
+
+# AM_PROG_CC_C_O
+# --------------
+# Like AC_PROG_CC_C_O, but changed for automake.
+AC_DEFUN([AM_PROG_CC_C_O],
+[AC_REQUIRE([AC_PROG_CC_C_O])dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+ac_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
+if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+dnl Make sure AC_PROG_CC is never called again, or it will override our
+dnl setting of CC.
+m4_define([AC_PROG_CC],
+ [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])])
+])
+
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
diff --git a/apprentice.c b/apprentice.c
index 162acfefa591..a29825c72af9 100644
--- a/apprentice.c
+++ b/apprentice.c
@@ -45,9 +45,11 @@
#ifdef QUICK
#include <sys/mman.h>
#endif
+#include <sys/types.h>
+#include <dirent.h>
#ifndef lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.109 2007/12/27 20:52:36 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.140 2008/07/20 04:02:15 christos Exp $")
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
@@ -97,14 +99,14 @@ private void eatsize(const char **);
private int apprentice_1(struct magic_set *, const char *, int, struct mlist *);
private size_t apprentice_magic_strength(const struct magic *);
private int apprentice_sort(const void *, const void *);
-private int apprentice_file(struct magic_set *, struct magic **, uint32_t *,
+private int apprentice_load(struct magic_set *, struct magic **, uint32_t *,
const char *, int);
private void byteswap(struct magic *, uint32_t);
private void bs1(struct magic *);
private uint16_t swap2(uint16_t);
private uint32_t swap4(uint32_t);
private uint64_t swap8(uint64_t);
-private char *mkdbname(const char *, char *, size_t, int);
+private void mkdbname(const char *, char **, int);
private int apprentice_map(struct magic_set *, struct magic **, uint32_t *,
const char *);
private int apprentice_compile(struct magic_set *, struct magic **, uint32_t *,
@@ -112,10 +114,27 @@ private int apprentice_compile(struct magic_set *, struct magic **, uint32_t *,
private int check_format_type(const char *, int);
private int check_format(struct magic_set *, struct magic *);
private int get_op(char);
+private int parse_mime(struct magic_set *, struct magic_entry *, const char *);
+private int parse_strength(struct magic_set *, struct magic_entry *,
+ const char *);
+
private size_t maxmagic = 0;
private size_t magicsize = sizeof(struct magic);
+private const char usg_hdr[] = "cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
+
+private struct {
+ const char *name;
+ size_t len;
+ int (*fun)(struct magic_set *, struct magic_entry *, const char *);
+} bang[] = {
+#define DECLARE_FIELD(name) { # name, sizeof(# name) - 1, parse_ ## name }
+ DECLARE_FIELD(mime),
+ DECLARE_FIELD(strength),
+#undef DECLARE_FIELD
+ { NULL, 0, NULL }
+};
#ifdef COMPILE_ONLY
@@ -151,13 +170,13 @@ main(int argc, char *argv[])
#endif /* COMPILE_ONLY */
static const struct type_tbl_s {
- const char *name;
+ const char name[16];
const size_t len;
const int type;
const int format;
} type_tbl[] = {
# define XX(s) s, (sizeof(s) - 1)
-# define XX_NULL NULL, 0
+# define XX_NULL "", 0
{ XX("byte"), FILE_BYTE, FILE_FMT_NUM },
{ XX("short"), FILE_SHORT, FILE_FMT_NUM },
{ XX("default"), FILE_DEFAULT, FILE_FMT_STR },
@@ -206,7 +225,7 @@ get_type(const char *l, const char **t)
{
const struct type_tbl_s *p;
- for (p = type_tbl; p->name; p++) {
+ for (p = type_tbl; p->len; p++) {
if (strncmp(l, p->name, p->len) == 0) {
if (t)
*t = l + p->len;
@@ -226,7 +245,7 @@ init_file_tables(void)
return;
done++;
- for (p = type_tbl; p->name; p++) {
+ for (p = type_tbl; p->len; p++) {
assert(p->type < FILE_NAMES_SIZE);
file_names[p->type] = p->name;
file_formats[p->type] = p->format;
@@ -234,7 +253,7 @@ init_file_tables(void)
}
/*
- * Handle one file.
+ * Handle one file or directory.
*/
private int
apprentice_1(struct magic_set *ms, const char *fn, int action,
@@ -254,7 +273,7 @@ apprentice_1(struct magic_set *ms, const char *fn, int action,
}
if (action == FILE_COMPILE) {
- rv = apprentice_file(ms, &magic, &nmagic, fn, action);
+ rv = apprentice_load(ms, &magic, &nmagic, fn, action);
if (rv != 0)
return -1;
rv = apprentice_compile(ms, &magic, &nmagic, fn);
@@ -266,19 +285,19 @@ apprentice_1(struct magic_set *ms, const char *fn, int action,
if ((rv = apprentice_map(ms, &magic, &nmagic, fn)) == -1) {
if (ms->flags & MAGIC_CHECK)
file_magwarn(ms, "using regular magic file `%s'", fn);
- rv = apprentice_file(ms, &magic, &nmagic, fn, action);
+ rv = apprentice_load(ms, &magic, &nmagic, fn, action);
if (rv != 0)
return -1;
}
mapped = rv;
- if (magic == NULL || nmagic == 0) {
+ if (magic == NULL) {
file_delmagic(magic, mapped, nmagic);
return -1;
}
- if ((ml = malloc(sizeof(*ml))) == NULL) {
+ if ((ml = CAST(struct mlist *, malloc(sizeof(*ml)))) == NULL) {
file_delmagic(magic, mapped, nmagic);
file_oomem(ms, sizeof(*ml));
return -1;
@@ -320,14 +339,13 @@ file_delmagic(struct magic *p, int type, size_t entries)
}
}
-/* const char *fn: list of magic files */
+/* const char *fn: list of magic files and directories */
protected struct mlist *
file_apprentice(struct magic_set *ms, const char *fn, int action)
{
- char *p, *mfn, *afn = NULL;
+ char *p, *mfn;
int file_err, errs = -1;
struct mlist *mlist;
- static const char mime[] = ".mime";
init_file_tables();
@@ -342,7 +360,7 @@ file_apprentice(struct magic_set *ms, const char *fn, int action)
}
fn = mfn;
- if ((mlist = malloc(sizeof(*mlist))) == NULL) {
+ if ((mlist = CAST(struct mlist *, malloc(sizeof(*mlist)))) == NULL) {
free(mfn);
file_oomem(ms, sizeof(*mlist));
return NULL;
@@ -355,25 +373,8 @@ file_apprentice(struct magic_set *ms, const char *fn, int action)
*p++ = '\0';
if (*fn == '\0')
break;
- if (ms->flags & MAGIC_MIME) {
- size_t len = strlen(fn) + sizeof(mime);
- if ((afn = malloc(len)) == NULL) {
- free(mfn);
- free(mlist);
- file_oomem(ms, len);
- return NULL;
- }
- (void)strcpy(afn, fn);
- (void)strcat(afn, mime);
- fn = afn;
- }
file_err = apprentice_1(ms, fn, action, mlist);
- if (file_err > errs)
- errs = file_err;
- if (afn) {
- free(afn);
- afn = NULL;
- }
+ errs = MAX(errs, file_err);
fn = p;
}
if (errs == -1) {
@@ -398,6 +399,8 @@ apprentice_magic_strength(const struct magic *m)
switch (m->type) {
case FILE_DEFAULT: /* make sure this sorts last */
+ if (m->factor_op != FILE_FACTOR_OP_NONE)
+ abort();
return 0;
case FILE_BYTE:
@@ -429,7 +432,7 @@ apprentice_magic_strength(const struct magic *m)
case FILE_SEARCH:
case FILE_REGEX:
- val += m->vallen;
+ val += m->vallen * MAX(MULT / m->vallen, 1);
break;
case FILE_DATE:
@@ -469,10 +472,10 @@ apprentice_magic_strength(const struct magic *m)
switch (m->reln) {
case 'x': /* matches anything penalize */
+ case '!': /* matches almost anything penalize */
val = 0;
break;
- case '!':
case '=': /* Exact match, prefer */
val += MULT;
break;
@@ -495,6 +498,31 @@ apprentice_magic_strength(const struct magic *m)
if (val == 0) /* ensure we only return 0 for FILE_DEFAULT */
val = 1;
+ switch (m->factor_op) {
+ case FILE_FACTOR_OP_NONE:
+ break;
+ case FILE_FACTOR_OP_PLUS:
+ val += m->factor;
+ break;
+ case FILE_FACTOR_OP_MINUS:
+ val -= m->factor;
+ break;
+ case FILE_FACTOR_OP_TIMES:
+ val *= m->factor;
+ break;
+ case FILE_FACTOR_OP_DIV:
+ val /= m->factor;
+ break;
+ default:
+ abort();
+ }
+
+ /*
+ * Magic entries with no description get a bonus because they depend
+ * on subsequent magic entries to print something.
+ */
+ if (m->desc[0] == '\0')
+ val++;
return val;
}
@@ -504,8 +532,8 @@ apprentice_magic_strength(const struct magic *m)
private int
apprentice_sort(const void *a, const void *b)
{
- const struct magic_entry *ma = a;
- const struct magic_entry *mb = b;
+ const struct magic_entry *ma = CAST(const struct magic_entry *, a);
+ const struct magic_entry *mb = CAST(const struct magic_entry *, b);
size_t sa = apprentice_magic_strength(ma->mp);
size_t sb = apprentice_magic_strength(mb->mp);
if (sa == sb)
@@ -516,36 +544,156 @@ apprentice_sort(const void *a, const void *b)
return 1;
}
+private void
+set_test_type(struct magic *mstart, struct magic *m)
+{
+ switch (m->type) {
+ case FILE_BYTE:
+ case FILE_SHORT:
+ case FILE_LONG:
+ case FILE_DATE:
+ case FILE_BESHORT:
+ case FILE_BELONG:
+ case FILE_BEDATE:
+ case FILE_LESHORT:
+ case FILE_LELONG:
+ case FILE_LEDATE:
+ case FILE_LDATE:
+ case FILE_BELDATE:
+ case FILE_LELDATE:
+ case FILE_MEDATE:
+ case FILE_MELDATE:
+ case FILE_MELONG:
+ case FILE_QUAD:
+ case FILE_LEQUAD:
+ case FILE_BEQUAD:
+ case FILE_QDATE:
+ case FILE_LEQDATE:
+ case FILE_BEQDATE:
+ case FILE_QLDATE:
+ case FILE_LEQLDATE:
+ case FILE_BEQLDATE:
+ case FILE_FLOAT:
+ case FILE_BEFLOAT:
+ case FILE_LEFLOAT:
+ case FILE_DOUBLE:
+ case FILE_BEDOUBLE:
+ case FILE_LEDOUBLE:
+ case FILE_STRING:
+ case FILE_PSTRING:
+ case FILE_BESTRING16:
+ case FILE_LESTRING16:
+ /* binary test, set flag */
+ mstart->flag |= BINTEST;
+ break;
+ case FILE_REGEX:
+ case FILE_SEARCH:
+ /* binary test if pattern is not text */
+ if (file_looks_utf8(m->value.us, m->vallen, NULL, NULL) <= 0)
+ mstart->flag |= BINTEST;
+ break;
+ case FILE_DEFAULT:
+ /* can't deduce anything; we shouldn't see this at the
+ top level anyway */
+ break;
+ case FILE_INVALID:
+ default:
+ /* invalid search type, but no need to complain here */
+ break;
+ }
+}
+
/*
- * parse from a file
- * const char *fn: name of magic file
+ * Load and parse one file.
*/
-private int
-apprentice_file(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
- const char *fn, int action)
+private void
+load_1(struct magic_set *ms, int action, const char *fn, int *errs,
+ struct magic_entry **marray, uint32_t *marraycount)
{
- private const char hdr[] =
- "cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
- FILE *f;
char line[BUFSIZ];
- int errs = 0;
- struct magic_entry *marray;
- uint32_t marraycount, i, mentrycount = 0;
size_t lineno = 0;
-
- ms->flags |= MAGIC_CHECK; /* Enable checks for parsed files */
-
- f = fopen(ms->file = fn, "r");
+ FILE *f = fopen(ms->file = fn, "r");
if (f == NULL) {
if (errno != ENOENT)
file_error(ms, errno, "cannot read magic file `%s'",
- fn);
- return -1;
+ fn);
+ (*errs)++;
+ } else {
+ /* read and parse this file */
+ for (ms->line = 1; fgets(line, sizeof(line), f) != NULL; ms->line++) {
+ size_t len;
+ len = strlen(line);
+ if (len == 0) /* null line, garbage, etc */
+ continue;
+ if (line[len - 1] == '\n') {
+ lineno++;
+ line[len - 1] = '\0'; /* delete newline */
+ }
+ if (line[0] == '\0') /* empty, do not parse */
+ continue;
+ if (line[0] == '#') /* comment, do not parse */
+ continue;
+ if (line[0] == '!' && line[1] == ':') {
+ size_t i;
+
+ for (i = 0; bang[i].name != NULL; i++) {
+ if (len - 2 > bang[i].len &&
+ memcmp(bang[i].name, line + 2,
+ bang[i].len) == 0)
+ break;
+ }
+ if (bang[i].name == NULL) {
+ file_error(ms, 0,
+ "Unknown !: entry `%s'", line);
+ (*errs)++;
+ continue;
+ }
+ if (*marraycount == 0) {
+ file_error(ms, 0,
+ "No current entry for :!%s type",
+ bang[i].name);
+ (*errs)++;
+ continue;
+ }
+ if ((*bang[i].fun)(ms,
+ &(*marray)[*marraycount - 1],
+ line + bang[i].len + 2) != 0) {
+ (*errs)++;
+ continue;
+ }
+ continue;
+ }
+ if (parse(ms, marray, marraycount, line, lineno,
+ action) != 0)
+ (*errs)++;
+ }
+
+ (void)fclose(f);
}
+}
+
+/*
+ * parse a file or directory of files
+ * const char *fn: name of magic file or directory
+ */
+private int
+apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
+ const char *fn, int action)
+{
+ int errs = 0;
+ struct magic_entry *marray;
+ uint32_t marraycount, i, mentrycount = 0, starttest;
+ size_t slen;
+ char subfn[MAXPATHLEN];
+ struct stat st;
+ DIR *dir;
+ struct dirent *d;
+
+ ms->flags |= MAGIC_CHECK; /* Enable checks for parsed files */
maxmagic = MAXMAGIS;
- if ((marray = calloc(maxmagic, sizeof(*marray))) == NULL) {
- (void)fclose(f);
+ if ((marray = CAST(struct magic_entry *, calloc(maxmagic,
+ sizeof(*marray)))) == NULL) {
file_oomem(ms, maxmagic * sizeof(*marray));
return -1;
}
@@ -553,32 +701,65 @@ apprentice_file(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
/* print silly verbose header for USG compat. */
if (action == FILE_CHECK)
- (void)fprintf(stderr, "%s\n", hdr);
+ (void)fprintf(stderr, "%s\n", usg_hdr);
+
+ /* load directory or file */
+ if (stat(fn, &st) == 0 && S_ISDIR(st.st_mode)) {
+ dir = opendir(fn);
+ if (dir) {
+ while ((d = readdir(dir)) != NULL) {
+ snprintf(subfn, sizeof(subfn), "%s/%s",
+ fn, d->d_name);
+ if (stat(subfn, &st) == 0 &&
+ S_ISREG(st.st_mode)) {
+ load_1(ms, action, subfn, &errs,
+ &marray, &marraycount);
+ }
+ }
+ closedir(dir);
+ } else
+ errs++;
+ } else
+ load_1(ms, action, fn, &errs, &marray, &marraycount);
+ if (errs)
+ goto out;
- /* read and parse this file */
- for (ms->line = 1; fgets(line, sizeof(line), f) != NULL; ms->line++) {
- size_t len;
- len = strlen(line);
- if (len == 0) /* null line, garbage, etc */
+ /* Set types of tests */
+ for (i = 0; i < marraycount; ) {
+ if (marray[i].mp->cont_level != 0) {
+ i++;
continue;
- if (line[len - 1] == '\n') {
- lineno++;
- line[len - 1] = '\0'; /* delete newline */
}
- if (line[0] == '\0') /* empty, do not parse */
- continue;
- if (line[0] == '#') /* comment, do not parse */
- continue;
- if (parse(ms, &marray, &marraycount, line, lineno, action) != 0)
- errs++;
- }
- (void)fclose(f);
- if (errs)
- goto out;
+ starttest = i;
+ do {
+ static const char text[] = "text";
+ static const char binary[] = "binary";
+ static const size_t len = sizeof(text);
+ set_test_type(marray[starttest].mp, marray[i].mp);
+ if ((ms->flags & MAGIC_DEBUG) == 0)
+ continue;
+ (void)fprintf(stderr, "%s%s%s: %s\n",
+ marray[i].mp->mimetype,
+ marray[i].mp->mimetype[0] == '\0' ? "" : "; ",
+ marray[i].mp->desc[0] ? marray[i].mp->desc :
+ "(no description)",
+ marray[i].mp->flag & BINTEST ? binary : text);
+ if (marray[i].mp->flag & BINTEST) {
+ char *p = strstr(marray[i].mp->desc, text);
+ if (p && (p == marray[i].mp->desc ||
+ isspace((unsigned char)p[-1])) &&
+ (p + len - marray[i].mp->desc ==
+ MAXstring || (p[len] == '\0' ||
+ isspace((unsigned char)p[len]))))
+ (void)fprintf(stderr, "*** Possible "
+ "binary test for text type\n");
+ }
+ } while (++i < marraycount && marray[i].mp->cont_level != 0);
+ }
-#ifndef NOORDER
qsort(marray, marraycount, sizeof(*marray), apprentice_sort);
+
/*
* Make sure that any level 0 "default" line is last (if one exists).
*/
@@ -596,13 +777,13 @@ apprentice_file(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
break;
}
}
-#endif
for (i = 0; i < marraycount; i++)
mentrycount += marray[i].cont_count;
- if ((*magicp = malloc(sizeof(**magicp) * mentrycount)) == NULL) {
- file_oomem(ms, sizeof(**magicp) * mentrycount);
+ slen = sizeof(**magicp) * mentrycount;
+ if ((*magicp = CAST(struct magic *, malloc(slen))) == NULL) {
+ file_oomem(ms, slen);
errs++;
goto out;
}
@@ -699,7 +880,7 @@ file_signextend(struct magic_set *ms, struct magic *m, uint64_t v)
}
private int
-string_modifier_check(struct magic_set *ms, struct magic const *m)
+string_modifier_check(struct magic_set *ms, struct magic *m)
{
if ((ms->flags & MAGIC_CHECK) == 0)
return 0;
@@ -708,19 +889,28 @@ string_modifier_check(struct magic_set *ms, struct magic const *m)
case FILE_BESTRING16:
case FILE_LESTRING16:
if (m->str_flags != 0) {
- file_magwarn(ms, "no modifiers allowed for 16-bit strings\n");
+ file_magwarn(ms,
+ "no modifiers allowed for 16-bit strings\n");
return -1;
}
break;
case FILE_STRING:
case FILE_PSTRING:
if ((m->str_flags & REGEX_OFFSET_START) != 0) {
- file_magwarn(ms, "'/%c' only allowed on regex and search\n",
+ file_magwarn(ms,
+ "'/%c' only allowed on regex and search\n",
CHAR_REGEX_OFFSET_START);
return -1;
}
break;
case FILE_SEARCH:
+ if (m->str_range == 0) {
+ file_magwarn(ms,
+ "missing range; defaulting to %d\n",
+ STRING_DEFAULT_RANGE);
+ m->str_range = STRING_DEFAULT_RANGE;
+ return -1;
+ }
break;
case FILE_REGEX:
if ((m->str_flags & STRING_COMPACT_BLANK) != 0) {
@@ -771,19 +961,19 @@ get_op(char c)
private int
get_cond(const char *l, const char **t)
{
- static struct cond_tbl_s {
- const char *name;
- const size_t len;
- const int cond;
+ static const struct cond_tbl_s {
+ char name[8];
+ size_t len;
+ int cond;
} cond_tbl[] = {
{ "if", 2, COND_IF },
{ "elif", 4, COND_ELIF },
{ "else", 4, COND_ELSE },
- { NULL, 0, COND_NONE },
+ { "", 0, COND_NONE },
};
- struct cond_tbl_s *p;
+ const struct cond_tbl_s *p;
- for (p = cond_tbl; p->name; p++) {
+ for (p = cond_tbl; p->len; p++) {
if (strncmp(l, p->name, p->len) == 0 &&
isspace((unsigned char)l[p->len])) {
if (t)
@@ -881,7 +1071,8 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
if (me->cont_count == me->max_count) {
struct magic *nm;
size_t cnt = me->max_count + ALLOC_CHUNK;
- if ((nm = realloc(me->mp, sizeof(*nm) * cnt)) == NULL) {
+ if ((nm = CAST(struct magic *, realloc(me->mp,
+ sizeof(*nm) * cnt))) == NULL) {
file_oomem(ms, sizeof(*nm) * cnt);
return -1;
}
@@ -896,7 +1087,8 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
struct magic_entry *mp;
maxmagic += ALLOC_INCR;
- if ((mp = realloc(*mentryp, sizeof(*mp) * maxmagic)) ==
+ if ((mp = CAST(struct magic_entry *,
+ realloc(*mentryp, sizeof(*mp) * maxmagic))) ==
NULL) {
file_oomem(ms, sizeof(*mp) * maxmagic);
return -1;
@@ -907,8 +1099,9 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
}
me = &(*mentryp)[*nmentryp];
if (me->mp == NULL) {
- if ((m = malloc(sizeof(*m) * ALLOC_CHUNK)) == NULL) {
- file_oomem(ms, sizeof(*m) * ALLOC_CHUNK);
+ size_t len = sizeof(*m) * ALLOC_CHUNK;
+ if ((m = CAST(struct magic *, malloc(len))) == NULL) {
+ file_oomem(ms, len);
return -1;
}
me->mp = m;
@@ -916,6 +1109,7 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
} else
m = me->mp;
(void)memset(m, 0, sizeof(*m));
+ m->factor_op = FILE_FACTOR_OP_NONE;
m->cont_level = 0;
me->cont_count = 1;
}
@@ -1060,7 +1254,7 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
file_magwarn(ms, "'~' invalid for string types");
++l;
}
- m->str_count = 0;
+ m->str_range = 0;
m->str_flags = 0;
m->num_mask = 0;
if ((op = get_op(*l)) != -1) {
@@ -1074,22 +1268,24 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
eatsize(&l);
}
else if (op == FILE_OPDIVIDE) {
- int have_count = 0;
+ int have_range = 0;
while (!isspace((unsigned char)*++l)) {
switch (*l) {
- /* for portability avoid "case '0' ... '9':" */
case '0': case '1': case '2':
case '3': case '4': case '5':
case '6': case '7': case '8':
- case '9': {
- if (have_count && ms->flags & MAGIC_CHECK)
+ case '9':
+ if (have_range &&
+ (ms->flags & MAGIC_CHECK))
+ file_magwarn(ms,
+ "multiple ranges");
+ have_range = 1;
+ m->str_range = strtoul(l, &t, 0);
+ if (m->str_range == 0)
file_magwarn(ms,
- "multiple counts");
- have_count = 1;
- m->str_count = strtoul(l, &t, 0);
+ "zero range");
l = t - 1;
break;
- }
case CHAR_COMPACT_BLANK:
m->str_flags |= STRING_COMPACT_BLANK;
break;
@@ -1114,7 +1310,8 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
return -1;
}
/* allow multiple '/' for readability */
- if (l[1] == '/' && !isspace((unsigned char)l[2]))
+ if (l[1] == '/' &&
+ !isspace((unsigned char)l[2]))
l++;
}
if (string_modifier_check(ms, m) == -1)
@@ -1135,6 +1332,17 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
switch (*l) {
case '>':
case '<':
+ m->reln = *l;
+ ++l;
+ if (*l == '=') {
+ if (ms->flags & MAGIC_CHECK) {
+ file_magwarn(ms, "%c= not supported",
+ m->reln);
+ return -1;
+ }
+ ++l;
+ }
+ break;
/* Old-style anding: "0 byte &0x80 dynamically linked" */
case '&':
case '^':
@@ -1177,13 +1385,12 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
EATAB;
if (l[0] == '\b') {
++l;
- m->nospflag = 1;
+ m->flag |= NOSPACE;
} else if ((l[0] == '\\') && (l[1] == 'b')) {
++l;
++l;
- m->nospflag = 1;
- } else
- m->nospflag = 0;
+ m->flag |= NOSPACE;
+ }
for (i = 0; (m->desc[i++] = *l++) != '\0' && i < sizeof(m->desc); )
continue;
if (i == sizeof(m->desc)) {
@@ -1205,11 +1412,103 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
file_mdump(m);
}
#endif
+ m->mimetype[0] = '\0'; /* initialise MIME type to none */
if (m->cont_level == 0)
++(*nmentryp); /* make room for next */
return 0;
}
+/*
+ * parse a STRENGTH annotation line from magic file, put into magic[index - 1]
+ * if valid
+ */
+private int
+parse_strength(struct magic_set *ms, struct magic_entry *me, const char *line)
+{
+ const char *l = line;
+ char *el;
+ unsigned long factor;
+ struct magic *m = &me->mp[0];
+
+ if (m->factor_op != FILE_FACTOR_OP_NONE) {
+ file_magwarn(ms,
+ "Current entry already has a strength type: %c %d",
+ m->factor_op, m->factor);
+ return -1;
+ }
+ EATAB;
+ switch (*l) {
+ case FILE_FACTOR_OP_NONE:
+ case FILE_FACTOR_OP_PLUS:
+ case FILE_FACTOR_OP_MINUS:
+ case FILE_FACTOR_OP_TIMES:
+ case FILE_FACTOR_OP_DIV:
+ m->factor_op = *l++;
+ break;
+ default:
+ file_magwarn(ms, "Unknown factor op `%c'", *l);
+ return -1;
+ }
+ EATAB;
+ factor = strtoul(l, &el, 0);
+ if (factor > 255) {
+ file_magwarn(ms, "Too large factor `%lu'", factor);
+ goto out;
+ }
+ if (*el && !isspace((unsigned char)*el)) {
+ file_magwarn(ms, "Bad factor `%s'", l);
+ goto out;
+ }
+ m->factor = (uint8_t)factor;
+ if (m->factor == 0 && m->factor_op == FILE_FACTOR_OP_DIV) {
+ file_magwarn(ms, "Cannot have factor op `%c' and factor %u",
+ m->factor_op, m->factor);
+ goto out;
+ }
+ return 0;
+out:
+ m->factor_op = FILE_FACTOR_OP_NONE;
+ m->factor = 0;
+ return -1;
+}
+
+/*
+ * parse a MIME annotation line from magic file, put into magic[index - 1]
+ * if valid
+ */
+private int
+parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line)
+{
+ size_t i;
+ const char *l = line;
+ struct magic *m = &me->mp[me->cont_count == 0 ? 0 : me->cont_count - 1];
+
+ if (m->mimetype[0] != '\0') {
+ file_magwarn(ms, "Current entry already has a MIME type `%s',"
+ " new type `%s'", m->mimetype, l);
+ return -1;
+ }
+
+ EATAB;
+ for (i = 0;
+ *l && ((isascii((unsigned char)*l) && isalnum((unsigned char)*l))
+ || strchr("-+/.", *l)) && i < sizeof(m->mimetype);
+ m->mimetype[i++] = *l++)
+ continue;
+ if (i == sizeof(m->mimetype)) {
+ m->desc[sizeof(m->mimetype) - 1] = '\0';
+ if (ms->flags & MAGIC_CHECK)
+ file_magwarn(ms, "MIME type `%s' truncated %zu",
+ m->mimetype, i);
+ } else
+ m->mimetype[i] = '\0';
+
+ if (i > 0)
+ return 0;
+ else
+ return -1;
+}
+
private int
check_format_type(const char *ptr, int type)
{
@@ -1354,12 +1653,12 @@ check_format(struct magic_set *ms, struct magic *m)
assert(file_nformats == file_nnames);
if (m->type >= file_nformats) {
- file_error(ms, 0, "Internal error inconsistency between "
+ file_magwarn(ms, "Internal error inconsistency between "
"m->type and format strings");
return -1;
}
if (file_formats[m->type] == FILE_FMT_NONE) {
- file_error(ms, 0, "No format string for `%s' with description "
+ file_magwarn(ms, "No format string for `%s' with description "
"`%s'", m->desc, file_names[m->type]);
return -1;
}
@@ -1370,15 +1669,16 @@ check_format(struct magic_set *ms, struct magic *m)
* TODO: this error message is unhelpful if the format
* string is not one character long
*/
- file_error(ms, 0, "Printf format `%c' is not valid for type "
- " `%s' in description `%s'", *ptr,
+ file_magwarn(ms, "Printf format `%c' is not valid for type "
+ "`%s' in description `%s'",
+ ptr && *ptr ? *ptr : '?',
file_names[m->type], m->desc);
return -1;
}
for (; *ptr; ptr++) {
if (*ptr == '%') {
- file_error(ms, 0,
+ file_magwarn(ms,
"Too many format strings (should have at most one) "
"for `%s' with description `%s'",
file_names[m->type], m->desc);
@@ -1413,6 +1713,8 @@ getvalue(struct magic_set *ms, struct magic *m, const char **p, int action)
return -1;
}
m->vallen = slen;
+ if (m->type == FILE_PSTRING)
+ m->vallen++;
return 0;
case FILE_FLOAT:
case FILE_BEFLOAT:
@@ -1709,51 +2011,51 @@ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
uint32_t *ptr;
uint32_t version;
int needsbyteswap;
- char buf[MAXPATHLEN];
- char *dbname = mkdbname(fn, buf, sizeof(buf), 0);
+ char *dbname = NULL;
void *mm = NULL;
+ mkdbname(fn, &dbname, 0);
if (dbname == NULL)
- return -1;
+ goto error2;
if ((fd = open(dbname, O_RDONLY|O_BINARY)) == -1)
- return -1;
+ goto error2;
if (fstat(fd, &st) == -1) {
file_error(ms, errno, "cannot stat `%s'", dbname);
- goto error;
+ goto error1;
}
- if (st.st_size < 16) {
+ if (st.st_size < 8) {
file_error(ms, 0, "file `%s' is too small", dbname);
- goto error;
+ goto error1;
}
#ifdef QUICK
if ((mm = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FILE, fd, (off_t)0)) == MAP_FAILED) {
file_error(ms, errno, "cannot map `%s'", dbname);
- goto error;
+ goto error1;
}
#define RET 2
#else
- if ((mm = malloc((size_t)st.st_size)) == NULL) {
+ if ((mm = CAST(void *, malloc((size_t)st.st_size))) == NULL) {
file_oomem(ms, (size_t)st.st_size);
- goto error;
+ goto error1;
}
if (read(fd, mm, (size_t)st.st_size) != (size_t)st.st_size) {
file_badread(ms);
- goto error;
+ goto error1;
}
#define RET 1
#endif
- *magicp = mm;
+ *magicp = CAST(struct magic *, mm);
(void)close(fd);
fd = -1;
ptr = (uint32_t *)(void *)*magicp;
if (*ptr != MAGICNO) {
if (swap4(*ptr) != MAGICNO) {
- file_error(ms, 0, "bad magic in `%s'");
- goto error;
+ file_error(ms, 0, "bad magic in `%s'", dbname);
+ goto error1;
}
needsbyteswap = 1;
} else
@@ -1766,15 +2068,18 @@ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
file_error(ms, 0, "File %d.%d supports only %d version magic "
"files. `%s' is version %d", FILE_VERSION_MAJOR, patchlevel,
VERSIONNO, dbname, version);
- goto error;
+ goto error1;
}
- *nmagicp = (uint32_t)(st.st_size / sizeof(struct magic)) - 1;
+ *nmagicp = (uint32_t)(st.st_size / sizeof(struct magic));
+ if (*nmagicp > 0)
+ (*nmagicp)--;
(*magicp)++;
if (needsbyteswap)
byteswap(*magicp, *nmagicp);
+ free(dbname);
return RET;
-error:
+error1:
if (fd != -1)
(void)close(fd);
if (mm) {
@@ -1787,6 +2092,8 @@ error:
*magicp = NULL;
*nmagicp = 0;
}
+error2:
+ free(dbname);
return -1;
}
@@ -1801,53 +2108,65 @@ apprentice_compile(struct magic_set *ms, struct magic **magicp,
uint32_t *nmagicp, const char *fn)
{
int fd;
- char buf[MAXPATHLEN];
- char *dbname = mkdbname(fn, buf, sizeof(buf), 1);
+ char *dbname;
+ int rv = -1;
+
+ mkdbname(fn, &dbname, 1);
if (dbname == NULL)
- return -1;
+ goto out;
if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644)) == -1) {
file_error(ms, errno, "cannot open `%s'", dbname);
- return -1;
+ goto out;
}
if (write(fd, ar, sizeof(ar)) != (ssize_t)sizeof(ar)) {
file_error(ms, errno, "error writing `%s'", dbname);
- return -1;
+ goto out;
}
if (lseek(fd, (off_t)sizeof(struct magic), SEEK_SET)
!= sizeof(struct magic)) {
file_error(ms, errno, "error seeking `%s'", dbname);
- return -1;
+ goto out;
}
if (write(fd, *magicp, (sizeof(struct magic) * *nmagicp))
!= (ssize_t)(sizeof(struct magic) * *nmagicp)) {
file_error(ms, errno, "error writing `%s'", dbname);
- return -1;
+ goto out;
}
(void)close(fd);
- return 0;
+ rv = 0;
+out:
+ free(dbname);
+ return rv;
}
private const char ext[] = ".mgc";
/*
* make a dbname
*/
-private char *
-mkdbname(const char *fn, char *buf, size_t bufsiz, int strip)
+private void
+mkdbname(const char *fn, char **buf, int strip)
{
+ const char *p;
if (strip) {
- const char *p;
if ((p = strrchr(fn, '/')) != NULL)
fn = ++p;
}
- (void)snprintf(buf, bufsiz, "%s%s", fn, ext);
- return buf;
+ if ((p = strstr(fn, ext)) != NULL && p[sizeof(ext) - 1] == '\0')
+ *buf = strdup(fn);
+ else
+ (void)asprintf(buf, "%s%s", fn, ext);
+
+ if (buf && *buf && strlen(*buf) > MAXPATHLEN) {
+ free(*buf);
+ *buf = NULL;
+ }
}
/*
@@ -1897,9 +2216,10 @@ swap4(uint32_t sv)
private uint64_t
swap8(uint64_t sv)
{
- uint32_t rv;
+ uint64_t rv;
uint8_t *s = (uint8_t *)(void *)&sv;
uint8_t *d = (uint8_t *)(void *)&rv;
+#if 0
d[0] = s[3];
d[1] = s[2];
d[2] = s[1];
@@ -1908,6 +2228,16 @@ swap8(uint64_t sv)
d[5] = s[6];
d[6] = s[5];
d[7] = s[4];
+#else
+ d[0] = s[7];
+ d[1] = s[6];
+ d[2] = s[5];
+ d[3] = s[4];
+ d[4] = s[3];
+ d[5] = s[2];
+ d[6] = s[1];
+ d[7] = s[0];
+#endif
return rv;
}
@@ -1922,7 +2252,7 @@ bs1(struct magic *m)
m->in_offset = swap4((uint32_t)m->in_offset);
m->lineno = swap4((uint32_t)m->lineno);
if (IS_STRING(m->type)) {
- m->str_count = swap4(m->str_count);
+ m->str_range = swap4(m->str_range);
m->str_flags = swap4(m->str_flags);
}
else {
diff --git a/ascmagic.c b/ascmagic.c
index 8d2d9a763c50..c374e02b4b83 100644
--- a/ascmagic.c
+++ b/ascmagic.c
@@ -49,32 +49,32 @@
#include "names.h"
#ifndef lint
-FILE_RCSID("@(#)$File: ascmagic.c,v 1.53 2007/10/29 00:54:08 christos Exp $")
+FILE_RCSID("@(#)$File: ascmagic.c,v 1.64 2008/07/16 18:00:57 christos Exp $")
#endif /* lint */
-typedef unsigned long unichar;
-
#define MAXLINELEN 300 /* longest sane line length */
#define ISSPC(x) ((x) == ' ' || (x) == '\t' || (x) == '\r' || (x) == '\n' \
|| (x) == 0x85 || (x) == '\f')
private int looks_ascii(const unsigned char *, size_t, unichar *, size_t *);
-private int looks_utf8(const unsigned char *, size_t, unichar *, size_t *);
-private int looks_unicode(const unsigned char *, size_t, unichar *, size_t *);
+private int looks_utf8_with_BOM(const unsigned char *, size_t, unichar *,
+ size_t *);
+private int looks_ucs16(const unsigned char *, size_t, unichar *, size_t *);
private int looks_latin1(const unsigned char *, size_t, unichar *, size_t *);
private int looks_extended(const unsigned char *, size_t, unichar *, size_t *);
private void from_ebcdic(const unsigned char *, size_t, unsigned char *);
private int ascmatch(const unsigned char *, const unichar *, size_t);
+private unsigned char *encode_utf8(unsigned char *, size_t, unichar *, size_t);
protected int
file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
{
size_t i;
- unsigned char *nbuf = NULL;
+ unsigned char *nbuf = NULL, *utf8_buf = NULL, *utf8_end;
unichar *ubuf = NULL;
- size_t ulen;
- struct names *p;
+ size_t ulen, mlen;
+ const struct names *p;
int rv = -1;
int mime = ms->flags & MAGIC_MIME;
@@ -103,9 +103,11 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
while (nbytes > 1 && buf[nbytes - 1] == '\0')
nbytes--;
- if ((nbuf = calloc(1, (nbytes + 1) * sizeof(nbuf[0]))) == NULL)
+ if ((nbuf = CAST(unsigned char *, calloc((size_t)1,
+ (nbytes + 1) * sizeof(nbuf[0])))) == NULL)
goto done;
- if ((ubuf = calloc(1, (nbytes + 1) * sizeof(ubuf[0]))) == NULL)
+ if ((ubuf = CAST(unichar *, calloc((size_t)1,
+ (nbytes + 1) * sizeof(ubuf[0])))) == NULL)
goto done;
/*
@@ -118,11 +120,15 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
code = "ASCII";
code_mime = "us-ascii";
type = "text";
- } else if (looks_utf8(buf, nbytes, ubuf, &ulen)) {
+ } else if (looks_utf8_with_BOM(buf, nbytes, ubuf, &ulen) > 0) {
+ code = "UTF-8 Unicode (with BOM)";
+ code_mime = "utf-8";
+ type = "text";
+ } else if (file_looks_utf8(buf, nbytes, ubuf, &ulen) > 1) {
code = "UTF-8 Unicode";
code_mime = "utf-8";
type = "text";
- } else if ((i = looks_unicode(buf, nbytes, ubuf, &ulen)) != 0) {
+ } else if ((i = looks_ucs16(buf, nbytes, ubuf, &ulen)) != 0) {
if (i == 1)
code = "Little-endian UTF-16 Unicode";
else
@@ -160,33 +166,25 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
goto done;
}
- /*
- * for troff, look for . + letter + letter or .\";
- * this must be done to disambiguate tar archives' ./file
- * and other trash from real troff input.
- *
- * I believe Plan 9 troff allows non-ASCII characters in the names
- * of macros, so this test might possibly fail on such a file.
- */
- if ((ms->flags & MAGIC_NO_CHECK_TROFF) == 0 && *ubuf == '.') {
- unichar *tp = ubuf + 1;
-
- while (ISSPC(*tp))
- ++tp; /* skip leading whitespace */
- if ((tp[0] == '\\' && tp[1] == '\"') ||
- (isascii((unsigned char)tp[0]) &&
- isalnum((unsigned char)tp[0]) &&
- isascii((unsigned char)tp[1]) &&
- isalnum((unsigned char)tp[1]) &&
- ISSPC(tp[2]))) {
- subtype_mime = "text/troff";
- subtype = "troff or preprocessor input";
- goto subtype_identified;
- }
+ /* Convert ubuf to UTF-8 and try text soft magic */
+ /* If original was ASCII or UTF-8, could use nbuf instead of
+ re-converting. */
+ /* malloc size is a conservative overestimate; could be
+ re-converting improved, or at least realloced after
+ re-converting conversion. */
+ mlen = ulen * 6;
+ if ((utf8_buf = CAST(unsigned char *, malloc(mlen))) == NULL) {
+ file_oomem(ms, mlen);
+ goto done;
+ }
+ if ((utf8_end = encode_utf8(utf8_buf, mlen, ubuf, ulen)) == NULL)
+ goto done;
+ if (file_softmagic(ms, utf8_buf, utf8_end - utf8_buf, TEXTTEST) != 0) {
+ rv = 1;
+ goto done;
}
/* look for tokens from names.h - this is expensive! */
-
if ((ms->flags & MAGIC_NO_CHECK_TOKENS) != 0)
goto subtype_identified;
@@ -194,24 +192,18 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
while (i < ulen) {
size_t end;
- /*
- * skip past any leading space
- */
+ /* skip past any leading space */
while (i < ulen && ISSPC(ubuf[i]))
i++;
if (i >= ulen)
break;
- /*
- * find the next whitespace
- */
+ /* find the next whitespace */
for (end = i + 1; end < nbytes; end++)
if (ISSPC(ubuf[end]))
break;
- /*
- * compare the word thus isolated against the token list
- */
+ /* compare the word thus isolated against the token list */
for (p = names; p < names + NNAMES; p++) {
if (ascmatch((const unsigned char *)p->name, ubuf + i,
end - i)) {
@@ -226,9 +218,7 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
subtype_identified:
- /*
- * Now try to discover other details about the file.
- */
+ /* Now try to discover other details about the file. */
for (i = 0; i < ulen; i++) {
if (ubuf[i] == '\n') {
if (seen_cr)
@@ -362,6 +352,8 @@ done:
free(nbuf);
if (ubuf)
free(ubuf);
+ if (utf8_buf)
+ free(utf8_buf);
return rv;
}
@@ -520,15 +512,84 @@ looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf,
return 1;
}
-private int
-looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
+/*
+ * Encode Unicode string as UTF-8, returning pointer to character
+ * after end of string, or NULL if an invalid character is found.
+ */
+private unsigned char *
+encode_utf8(unsigned char *buf, size_t len, unichar *ubuf, size_t ulen)
+{
+ size_t i;
+ unsigned char *end = buf + len;
+
+ for (i = 0; i < ulen; i++) {
+ if (ubuf[i] <= 0x7f) {
+ if (end - buf < 1)
+ return NULL;
+ *buf++ = (unsigned char)ubuf[i];
+ } else if (ubuf[i] <= 0x7ff) {
+ if (end - buf < 2)
+ return NULL;
+ *buf++ = (unsigned char)((ubuf[i] >> 6) + 0xc0);
+ *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80);
+ } else if (ubuf[i] <= 0xffff) {
+ if (end - buf < 3)
+ return NULL;
+ *buf++ = (unsigned char)((ubuf[i] >> 12) + 0xe0);
+ *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80);
+ } else if (ubuf[i] <= 0x1fffff) {
+ if (end - buf < 4)
+ return NULL;
+ *buf++ = (unsigned char)((ubuf[i] >> 18) + 0xf0);
+ *buf++ = (unsigned char)(((ubuf[i] >> 12) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80);
+ } else if (ubuf[i] <= 0x3ffffff) {
+ if (end - buf < 5)
+ return NULL;
+ *buf++ = (unsigned char)((ubuf[i] >> 24) + 0xf8);
+ *buf++ = (unsigned char)(((ubuf[i] >> 18) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 12) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80);
+ } else if (ubuf[i] <= 0x7fffffff) {
+ if (end - buf < 6)
+ return NULL;
+ *buf++ = (unsigned char)((ubuf[i] >> 30) + 0xfc);
+ *buf++ = (unsigned char)(((ubuf[i] >> 24) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 18) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 12) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)(((ubuf[i] >> 6) & 0x3f) + 0x80);
+ *buf++ = (unsigned char)((ubuf[i] & 0x3f) + 0x80);
+ } else /* Invalid character */
+ return NULL;
+ }
+
+ return buf;
+}
+
+/*
+ * Decide whether some text looks like UTF-8. Returns:
+ *
+ * -1: invalid UTF-8
+ * 0: uses odd control characters, so doesn't look like text
+ * 1: 7-bit text
+ * 2: definitely UTF-8 text (valid high-bit set bytes)
+ *
+ * If ubuf is non-NULL on entry, text is decoded into ubuf, *ulen;
+ * ubuf must be big enough!
+ */
+protected int
+file_looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
{
size_t i;
int n;
unichar c;
- int gotone = 0;
+ int gotone = 0, ctrl = 0;
- *ulen = 0;
+ if (ubuf)
+ *ulen = 0;
for (i = 0; i < nbytes; i++) {
if ((buf[i] & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */
@@ -538,11 +599,12 @@ looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
*/
if (text_chars[buf[i]] != T)
- return 0;
+ ctrl = 1;
- ubuf[(*ulen)++] = buf[i];
+ if (ubuf)
+ ubuf[(*ulen)++] = buf[i];
} else if ((buf[i] & 0x40) == 0) { /* 10xxxxxx never 1st byte */
- return 0;
+ return -1;
} else { /* 11xxxxxx begins UTF-8 */
int following;
@@ -562,7 +624,7 @@ looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
c = buf[i] & 0x01;
following = 5;
} else
- return 0;
+ return -1;
for (n = 0; n < following; n++) {
i++;
@@ -570,21 +632,37 @@ looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
goto done;
if ((buf[i] & 0x80) == 0 || (buf[i] & 0x40))
- return 0;
+ return -1;
c = (c << 6) + (buf[i] & 0x3f);
}
- ubuf[(*ulen)++] = c;
+ if (ubuf)
+ ubuf[(*ulen)++] = c;
gotone = 1;
}
}
done:
- return gotone; /* don't claim it's UTF-8 if it's all 7-bit */
+ return ctrl ? 0 : (gotone ? 2 : 1);
+}
+
+/*
+ * Decide whether some text looks like UTF-8 with BOM. If there is no
+ * BOM, return -1; otherwise return the result of looks_utf8 on the
+ * rest of the text.
+ */
+private int
+looks_utf8_with_BOM(const unsigned char *buf, size_t nbytes, unichar *ubuf,
+ size_t *ulen)
+{
+ if (nbytes > 3 && buf[0] == 0xef && buf[1] == 0xbb && buf[2] == 0xbf)
+ return file_looks_utf8(buf + 3, nbytes - 3, ubuf, ulen);
+ else
+ return -1;
}
private int
-looks_unicode(const unsigned char *buf, size_t nbytes, unichar *ubuf,
+looks_ucs16(const unsigned char *buf, size_t nbytes, unichar *ubuf,
size_t *ulen)
{
int bigend;
diff --git a/test.c b/asprintf.c
index 55b78d387c0d..c103cf18e553 100644
--- a/test.c
+++ b/asprintf.c
@@ -1,6 +1,7 @@
/*
- * Copyright (c) Christos Zoulas 2003.
- * All Rights Reserved.
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -24,36 +25,19 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#include <stdio.h>
-#include "magic.h"
-int
-main(int argc, char **argv)
-{
- struct magic_set *ms;
- const char *m;
- int i;
+#include <stdarg.h>
- if(argc < 2)
- return 1;
+int vasprintf(char **ptr, const char *format_string, va_list vargs);
- ms = magic_open(MAGIC_NONE);
- if (ms == NULL) {
- (void) printf("ERROR: out of memory\n");
- return 1;
- }
- if (magic_load(ms, NULL) == -1) {
- (void) printf("ERROR: %s\n", magic_error(ms));
- return 1;
- }
+int asprintf(char **ptr, const char *fmt, ...)
+{
+ va_list vargs;
+ int retval;
- for (i = 1; i < argc; i++) {
- if ((m = magic_file(ms, argv[i])) == NULL)
- (void) printf("ERROR: %s\n", magic_error(ms));
- else
- (void) printf("%s: %s\n", argv[i], m);
- }
+ va_start(vargs, fmt);
+ retval = vasprintf(ptr, fmt, vargs);
+ va_end(vargs);
- magic_close(ms);
- return 0;
+ return retval;
}
diff --git a/compile b/compile
new file mode 100755
index 000000000000..1b1d23216958
--- /dev/null
+++ b/compile
@@ -0,0 +1,142 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand `-c -o'.
+
+scriptversion=2005-05-14.22
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+case $1 in
+ '')
+ echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand `-c -o'.
+Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file `INSTALL'.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "compile $scriptversion"
+ exit $?
+ ;;
+esac
+
+ofile=
+cfile=
+eat=
+
+for arg
+do
+ if test -n "$eat"; then
+ eat=
+ else
+ case $1 in
+ -o)
+ # configure might choose to run compile as `compile cc -o foo foo.c'.
+ # So we strip `-o arg' only if arg is an object.
+ eat=1
+ case $2 in
+ *.o | *.obj)
+ ofile=$2
+ ;;
+ *)
+ set x "$@" -o "$2"
+ shift
+ ;;
+ esac
+ ;;
+ *.c)
+ cfile=$1
+ set x "$@" "$1"
+ shift
+ ;;
+ *)
+ set x "$@" "$1"
+ shift
+ ;;
+ esac
+ fi
+ shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+ # If no `-o' option was seen then we might have been invoked from a
+ # pattern rule where we don't need one. That is ok -- this is a
+ # normal compilation that the losing compiler can handle. If no
+ # `.c' file was seen then we are probably linking. That is also
+ # ok.
+ exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use `[/.-]' here to ensure that we don't use the same name
+# that we are using for the .o file. Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
+while true; do
+ if mkdir "$lockdir" >/dev/null 2>&1; then
+ break
+ fi
+ sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+ mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+ mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/compress.c b/compress.c
index 487b1b7f21ca..5867ac94a8f5 100644
--- a/compress.c
+++ b/compress.c
@@ -56,13 +56,13 @@
#ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.54 2007/12/02 00:28:10 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.57 2008/07/16 18:00:57 christos Exp $")
#endif
-private struct {
- const char *magic;
+private const struct {
+ const char magic[8];
size_t maglen;
- const char *const argv[3];
+ const char *argv[3];
int silent;
} compr[] = {
{ "\037\235", 2, { "gzip", "-cdq", NULL }, 1 }, /* compressed */
@@ -330,7 +330,7 @@ uncompressgzipped(struct magic_set *ms, const unsigned char *old,
if (data_start >= n)
return 0;
- if ((*newch = (unsigned char *)malloc(HOWMANY + 1)) == NULL) {
+ if ((*newch = CAST(unsigned char *, malloc(HOWMANY + 1))) == NULL) {
return 0;
}
@@ -374,6 +374,7 @@ uncompressbuf(struct magic_set *ms, int fd, size_t method,
int r;
#ifdef BUILTIN_DECOMPRESS
+ /* FIXME: This doesn't cope with bzip2 */
if (method == 2)
return uncompressgzipped(ms, old, newch, n);
#endif
diff --git a/config.guess b/config.guess
new file mode 100755
index 000000000000..3d427f02150a
--- /dev/null
+++ b/config.guess
@@ -0,0 +1,1504 @@
+#! /bin/sh
+#
+# $NetBSD: config.guess,v 1.9 2006/10/29 23:50:54 wiz Exp $
+#
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
+
+timestamp='2006-07-02'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm:riscos:*:*|arm:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[45])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ case ${UNAME_MACHINE} in
+ pc98)
+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ x86:Interix*:[3456]*)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ EM64T:Interix*:[3456]*)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit ;;
+ crisv32:Linux:*:*)
+ echo crisv32-axis-linux-gnu
+ exit ;;
+ frv:Linux:*:*)
+ echo frv-unknown-linux-gnu
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ or32:Linux:*:*)
+ echo or32-unknown-linux-gnu
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-gnu
+ exit ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported targets: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^LIBC/{
+ s: ::g
+ p
+ }'`"
+ test x"${LIBC}" != x && {
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit
+ }
+ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ case $UNAME_PROCESSOR in
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NSE-?:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ c34*)
+ echo c34-convex-bsd
+ exit ;;
+ c38*)
+ echo c38-convex-bsd
+ exit ;;
+ c4*)
+ echo c4-convex-bsd
+ exit ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+and
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.h.in b/config.h.in
index 281a4e40e7ed..26585d825bee 100644
--- a/config.h.in
+++ b/config.h.in
@@ -1,26 +1,41 @@
-/* config.h.in. Generated from configure.in by autoheader. */
+/* config.h.in. Generated from configure.ac by autoheader. */
-/* Use the builtin ELF recognition code */
+/* Define in built-in ELF support is used */
#undef BUILTIN_ELF
-/* Recognize ELF core files */
+/* Define for ELF core file support */
#undef ELFCORE
-/* */
+/* Define to 1 if you have the `asprintf' function. */
+#undef HAVE_ASPRINTF
+
+/* HAVE_DAYLIGHT */
#undef HAVE_DAYLIGHT
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
+/* Define to 1 if you have the <err.h> header file. */
+#undef HAVE_ERR_H
+
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+#undef HAVE_FSEEKO
+
/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
/* Define to 1 if you have the `getopt_long' function. */
#undef HAVE_GETOPT_LONG
+/* Define to 1 if the system has the type `int32_t'. */
+#undef HAVE_INT32_T
+
+/* Define to 1 if the system has the type `int64_t'. */
+#undef HAVE_INT64_T
+
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@@ -33,9 +48,6 @@
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
-/* */
-#undef HAVE_LONG_LONG
-
/* Define to 1 if you have the `mbrtowc' function. */
#undef HAVE_MBRTOWC
@@ -51,9 +63,6 @@
/* Define to 1 if you have the `mmap' function. */
#undef HAVE_MMAP
-/* Define to 1 if you have the `snprintf' function. */
-#undef HAVE_SNPRINTF
-
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@@ -81,10 +90,6 @@
/* Define to 1 if `st_rdev' is member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_RDEV
-/* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use
- `HAVE_STRUCT_STAT_ST_RDEV' instead. */
-#undef HAVE_ST_RDEV
-
/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
@@ -103,7 +108,7 @@
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
-/* */
+/* HAVE_TM_ISDST */
#undef HAVE_TM_ISDST
/* HAVE_TM_ZONE */
@@ -112,6 +117,18 @@
/* HAVE_TZNAME */
#undef HAVE_TZNAME
+/* Define to 1 if the system has the type `uint16_t'. */
+#undef HAVE_UINT16_T
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#undef HAVE_UINT32_T
+
+/* Define to 1 if the system has the type `uint64_t'. */
+#undef HAVE_UINT64_T
+
+/* Define to 1 if the system has the type `uint8_t'. */
+#undef HAVE_UINT8_T
+
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
@@ -124,8 +141,8 @@
/* Define to 1 if you have the <utime.h> header file. */
#undef HAVE_UTIME_H
-/* Define to 1 if you have the `vsnprintf' function. */
-#undef HAVE_VSNPRINTF
+/* Define to 1 if you have the `vasprintf' function. */
+#undef HAVE_VASPRINTF
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
@@ -147,6 +164,9 @@
<sysmacros.h>. */
#undef MAJOR_IN_SYSMACROS
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+#undef NO_MINUS_C_MINUS_O
+
/* Name of package */
#undef PACKAGE
@@ -165,20 +185,8 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
-/* */
-#undef SIZEOF_INT64_T
-
-/* */
-#undef SIZEOF_UINT16_T
-
-/* */
-#undef SIZEOF_UINT32_T
-
-/* */
-#undef SIZEOF_UINT64_T
-
-/* */
-#undef SIZEOF_UINT8_T
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
@@ -197,18 +205,15 @@
# undef _GNU_SOURCE
#endif
+/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
+#undef _LARGEFILE_SOURCE
+
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
-/* */
-#undef int32_t
-
-/* */
-#undef int64_t
-
/* Define to a type if <wchar.h> does not define. */
#undef mbstate_t
@@ -218,14 +223,31 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
-/* */
-#undef uint16_t
-
-/* */
-#undef uint32_t
-/* */
-#undef uint64_t
+#ifndef HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+#ifndef HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+#ifndef HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+#ifndef HAVE_INT32_T
+typedef int int32_t;
+#endif
+#ifndef HAVE_UINT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+#endif
+#ifndef HAVE_INT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef long long int64_t;
+#else
+typedef long int64_t;
+#endif
+#endif
-/* */
-#undef uint8_t
diff --git a/config.sub b/config.sub
new file mode 100755
index 000000000000..5b2ab48217c3
--- /dev/null
+++ b/config.sub
@@ -0,0 +1,1622 @@
+#! /bin/sh
+#
+# $NetBSD: config.sub,v 1.8 2006/10/29 23:52:55 wiz Exp $
+#
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
+# Inc.
+
+timestamp='2006-09-20'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | mt \
+ | msp430 \
+ | nios | nios2 \
+ | ns16k | ns32k \
+ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nios-* | nios2-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | xstormy16-* | xtensa-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16c)
+ basic_machine=cr16c-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rdos)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh5el)
+ basic_machine=sh5le-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure b/configure
index a81d93d52040..bf5ba58916ff 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,8 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61.
+# Generated by GNU Autoconf 2.61 for file 4.26.
+#
+# Report bugs to <christos@astron.com>.
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
@@ -724,13 +726,12 @@ MAKEFLAGS=
SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
-PACKAGE_NAME=
-PACKAGE_TARNAME=
-PACKAGE_VERSION=
-PACKAGE_STRING=
-PACKAGE_BUGREPORT=
+PACKAGE_NAME='file'
+PACKAGE_TARNAME='file'
+PACKAGE_VERSION='4.26'
+PACKAGE_STRING='file 4.26'
+PACKAGE_BUGREPORT='christos@astron.com'
-ac_unique_file="src/file.c"
# Factoring default headers for most tests.
ac_includes_default="\
#include <stdio.h>
@@ -826,12 +827,10 @@ am__leading_dot
AMTAR
am__tar
am__untar
-MAINTAINER_MODE_TRUE
-MAINTAINER_MODE_FALSE
-MAINT
fsect
FSECT5_TRUE
FSECT5_FALSE
+WARNINGS
CC
CFLAGS
LDFLAGS
@@ -874,9 +873,9 @@ F77
FFLAGS
ac_ct_F77
LIBTOOL
+LIBOBJS
IS_CROSS_COMPILE_TRUE
IS_CROSS_COMPILE_FALSE
-LIBOBJS
LTLIBOBJS'
ac_subst_files=''
ac_precious_vars='build_alias
@@ -932,7 +931,7 @@ sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
includedir='${prefix}/include'
oldincludedir='/usr/include'
-docdir='${datarootdir}/doc/${PACKAGE}'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
@@ -1396,7 +1395,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures this package to adapt to many kinds of systems.
+\`configure' configures file 4.26 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1444,7 +1443,7 @@ Fine tuning of the installation directories:
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
- --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/file]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
@@ -1465,14 +1464,14 @@ _ACEOF
fi
if test -n "$ac_init_help"; then
-
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of file 4.26:";;
+ esac
cat <<\_ACEOF
Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- --enable-maintainer-mode enable make rules and dependencies not useful
- (and sometimes confusing) to the casual installer
--disable-elf disable builtin ELF support
--disable-elf-core disable ELF core file support
--enable-fsect-man5 enable file formats in man section 5
@@ -1484,6 +1483,7 @@ Optional Features:
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--disable-largefile omit support for large files
+ --disable-warnings disable compiler warnings
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1511,6 +1511,7 @@ Some influential environment variables:
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
+Report bugs to <christos@astron.com>.
_ACEOF
ac_status=$?
fi
@@ -1571,7 +1572,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-configure
+file configure 4.26
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1585,7 +1586,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by $as_me, which was
+It was created by file $as_me 4.26, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -1923,6 +1924,14 @@ fi
+
+
+
+
+
+
+
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -1930,7 +1939,6 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
am__api_version='1.10'
ac_aux_dir=
@@ -2267,8 +2275,8 @@ fi
# Define the identity of the package.
- PACKAGE=file
- VERSION=4.23
+ PACKAGE='file'
+ VERSION='4.26'
cat >>confdefs.h <<_ACEOF
@@ -2416,28 +2424,6 @@ am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
ac_config_headers="$ac_config_headers config.h"
-{ echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5
-echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6; }
- # Check whether --enable-maintainer-mode was given.
-if test "${enable_maintainer_mode+set}" = set; then
- enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
-else
- USE_MAINTAINER_MODE=no
-fi
-
- { echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5
-echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6; }
- if test $USE_MAINTAINER_MODE = yes; then
- MAINTAINER_MODE_TRUE=
- MAINTAINER_MODE_FALSE='#'
-else
- MAINTAINER_MODE_TRUE='#'
- MAINTAINER_MODE_FALSE=
-fi
-
- MAINT=$MAINTAINER_MODE_TRUE
-
-
{ echo "$as_me:$LINENO: checking for builtin ELF support" >&5
echo $ECHO_N "checking for builtin ELF support... $ECHO_C" >&6; }
@@ -2446,7 +2432,8 @@ if test "${enable_elf+set}" = set; then
enableval=$enable_elf; if test "${enableval}" = yes; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define BUILTIN_ELF 1
_ACEOF
@@ -2459,7 +2446,8 @@ else
# enable by default
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define BUILTIN_ELF 1
_ACEOF
@@ -2474,7 +2462,8 @@ if test "${enable_elf_core+set}" = set; then
enableval=$enable_elf_core; if test "${enableval}" = yes; then
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define ELFCORE 1
_ACEOF
@@ -2487,7 +2476,8 @@ else
# enable by default
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define ELFCORE 1
_ACEOF
@@ -2518,6 +2508,7 @@ echo "${ECHO_T}no" >&6; }
fi
+
if test x$fsect = x5; then
FSECT5_TRUE=
FSECT5_FALSE='#'
@@ -2527,6 +2518,8 @@ else
fi
+
+
cat >>confdefs.h <<\_ACEOF
#define _GNU_SOURCE 1
_ACEOF
@@ -3622,6 +3615,132 @@ else
fi
+if test "x$CC" != xcc; then
+ { echo "$as_me:$LINENO: checking whether $CC and cc understand -c and -o together" >&5
+echo $ECHO_N "checking whether $CC and cc understand -c and -o together... $ECHO_C" >&6; }
+else
+ { echo "$as_me:$LINENO: checking whether cc understands -c and -o together" >&5
+echo $ECHO_N "checking whether cc understands -c and -o together... $ECHO_C" >&6; }
+fi
+set dummy $CC; ac_cc=`echo $2 |
+ sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+# Make sure it works both with $CC and with simple cc.
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+rm -f conftest2.*
+if { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ test -f conftest2.$ac_objext && { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); };
+then
+ eval ac_cv_prog_cc_${ac_cc}_c_o=yes
+ if test "x$CC" != xcc; then
+ # Test first that cc exists at all.
+ if { ac_try='cc -c conftest.$ac_ext >&5'
+ { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+ rm -f conftest2.*
+ if { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ test -f conftest2.$ac_objext && { (case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); };
+ then
+ # cc works too.
+ :
+ else
+ # cc exists but doesn't like -o.
+ eval ac_cv_prog_cc_${ac_cc}_c_o=no
+ fi
+ fi
+ fi
+else
+ eval ac_cv_prog_cc_${ac_cc}_c_o=no
+fi
+rm -f core conftest*
+
+fi
+if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+
+cat >>confdefs.h <<\_ACEOF
+#define NO_MINUS_C_MINUS_O 1
+_ACEOF
+
+fi
+
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+ac_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+
+
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
@@ -4484,7 +4603,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 4487 "configure"' > conftest.$ac_ext
+ echo '#line 4606 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -5233,7 +5352,12 @@ echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-
+ ( cat <<\_ASBOX
+## ---------------------------------- ##
+## Report this to christos@astron.com ##
+## ---------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
@@ -7225,11 +7349,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7228: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7352: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7232: \$? = $ac_status" >&5
+ echo "$as_me:7356: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7487,11 +7611,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7490: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7614: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7494: \$? = $ac_status" >&5
+ echo "$as_me:7618: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7549,11 +7673,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7552: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7676: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:7556: \$? = $ac_status" >&5
+ echo "$as_me:7680: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -9752,7 +9876,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9755 "configure"
+#line 9879 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -9850,7 +9974,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 9853 "configure"
+#line 9977 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12094,11 +12218,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12097: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:12221: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:12101: \$? = $ac_status" >&5
+ echo "$as_me:12225: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -12156,11 +12280,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:12159: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:12283: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:12163: \$? = $ac_status" >&5
+ echo "$as_me:12287: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -13492,7 +13616,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 13495 "configure"
+#line 13619 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -13590,7 +13714,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 13593 "configure"
+#line 13717 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -14475,11 +14599,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14478: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14602: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:14482: \$? = $ac_status" >&5
+ echo "$as_me:14606: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -14537,11 +14661,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14540: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14664: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:14544: \$? = $ac_status" >&5
+ echo "$as_me:14668: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -16654,11 +16778,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16657: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16781: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:16661: \$? = $ac_status" >&5
+ echo "$as_me:16785: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -16916,11 +17040,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16919: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:17043: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:16923: \$? = $ac_status" >&5
+ echo "$as_me:17047: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -16978,11 +17102,11 @@ else
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16981: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:17105: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:16985: \$? = $ac_status" >&5
+ echo "$as_me:17109: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -19181,7 +19305,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 19184 "configure"
+#line 19308 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -19279,7 +19403,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 19282 "configure"
+#line 19406 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -20329,39 +20453,6 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
if test "${ac_cv_header_stdc+set}" = set; then
@@ -20701,7 +20792,12 @@ echo "$as_me: WARNING: sys/mkdev.h: section \"Present But Cannot Be Compiled
echo "$as_me: WARNING: sys/mkdev.h: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: sys/mkdev.h: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: sys/mkdev.h: in the future, the compiler will take precedence" >&2;}
-
+ ( cat <<\_ASBOX
+## ---------------------------------- ##
+## Report this to christos@astron.com ##
+## ---------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ echo "$as_me:$LINENO: checking for sys/mkdev.h" >&5
@@ -20837,7 +20933,12 @@ echo "$as_me: WARNING: sys/sysmacros.h: section \"Present But Cannot Be Comp
echo "$as_me: WARNING: sys/sysmacros.h: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: sys/sysmacros.h: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: sys/sysmacros.h: in the future, the compiler will take precedence" >&2;}
-
+ ( cat <<\_ASBOX
+## ---------------------------------- ##
+## Report this to christos@astron.com ##
+## ---------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ echo "$as_me:$LINENO: checking for sys/sysmacros.h" >&5
@@ -20931,7 +21032,12 @@ _ACEOF
fi
-for ac_header in stdint.h
+
+
+
+
+
+for ac_header in stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -21046,7 +21152,12 @@ echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-
+ ( cat <<\_ASBOX
+## ---------------------------------- ##
+## Report this to christos@astron.com ##
+## ---------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
@@ -21074,9 +21185,7 @@ done
-
-
-for ac_header in fcntl.h locale.h stdint.h inttypes.h unistd.h getopt.h
+for ac_header in utime.h wchar.h wctype.h limits.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -21191,7 +21300,12 @@ echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-
+ ( cat <<\_ASBOX
+## ---------------------------------- ##
+## Report this to christos@astron.com ##
+## ---------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
@@ -21217,9 +21331,7 @@ done
-
-
-for ac_header in utime.h wchar.h wctype.h limits.h
+for ac_header in getopt.h err.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -21334,7 +21446,12 @@ echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-
+ ( cat <<\_ASBOX
+## ---------------------------------- ##
+## Report this to christos@astron.com ##
+## ---------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
@@ -21478,7 +21595,12 @@ echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-
+ ( cat <<\_ASBOX
+## ---------------------------------- ##
+## Report this to christos@astron.com ##
+## ---------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
@@ -21618,7 +21740,12 @@ echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-
+ ( cat <<\_ASBOX
+## ---------------------------------- ##
+## Report this to christos@astron.com ##
+## ---------------------------------- ##
+_ASBOX
+ ) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
@@ -21875,7 +22002,6 @@ _ACEOF
fi
-
{ echo "$as_me:$LINENO: checking for struct stat.st_rdev" >&5
echo $ECHO_N "checking for struct stat.st_rdev... $ECHO_C" >&6; }
if test "${ac_cv_member_struct_stat_st_rdev+set}" = set; then
@@ -21976,10 +22102,6 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_ST_RDEV 1
-_ACEOF
-
fi
@@ -22214,7 +22336,8 @@ fi
{ echo "$as_me:$LINENO: result: $ac_cv_struct_tm_isdst" >&5
echo "${ECHO_T}$ac_cv_struct_tm_isdst" >&6; }
if test "$ac_cv_struct_tm_isdst" = yes; then
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define HAVE_TM_ISDST 1
_ACEOF
@@ -22274,47 +22397,46 @@ fi
{ echo "$as_me:$LINENO: result: $ac_cv_var_daylight" >&5
echo "${ECHO_T}$ac_cv_var_daylight" >&6; }
if test $ac_cv_var_daylight = yes; then
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define HAVE_DAYLIGHT 1
_ACEOF
fi
-
- # Check whether --enable-largefile was given.
+# Check whether --enable-largefile was given.
if test "${enable_largefile+set}" = set; then
enableval=$enable_largefile;
fi
- if test "$enable_largefile" != no; then
+if test "$enable_largefile" != no; then
- { echo "$as_me:$LINENO: checking for special C compiler options needed for large files=
-" >&5
-echo $ECHO_N "checking for special C compiler options needed for large files=
-... $ECHO_C" >&6; }
+ { echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5
+echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6; }
if test "${ac_cv_sys_largefile_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_cv_sys_largefile_CC=no
- if test "$GCC" != yes; then
- # 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 <<_ACEOF
+ if test "$GCC" != yes; then
+ ac_save_CC=$CC
+ while :; do
+ # 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 <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply "#define LARGE_OFF_T 9223372036854775807",
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
int
main ()
{
@@ -22323,7 +22445,7 @@ main ()
return 0;
}
_ACEOF
-rm -f conftest.$ac_objext
+ rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
@@ -22340,38 +22462,17 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
- :
+ break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- ac_save_CC="$CC"
- CC="$CC -n32"
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply "#define LARGE_OFF_T 9223372036854775807",
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-int
-main ()
-{
+fi
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
+rm -f core conftest.err conftest.$ac_objext
+ CC="$CC -n32"
+ rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
@@ -22388,7 +22489,7 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
- ac_cv_sys_largefile_CC=' -n32'
+ ac_cv_sys_largefile_CC=' -n32'; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
@@ -22396,41 +22497,40 @@ sed 's/^/| /' conftest.$ac_ext >&5
fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- CC="$ac_save_CC"
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- fi
+rm -f core conftest.err conftest.$ac_objext
+ break
+ done
+ CC=$ac_save_CC
+ rm -f conftest.$ac_ext
+ fi
fi
{ echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5
echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6; }
- if test "$ac_cv_sys_largefile_CC" != no; then
- CC="$CC$ac_cv_sys_largefile_CC"
- fi
+ if test "$ac_cv_sys_largefile_CC" != no; then
+ CC=$CC$ac_cv_sys_largefile_CC
+ fi
- { echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5
+ { echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5
echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6; }
if test "${ac_cv_sys_file_offset_bits+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- ac_cv_sys_file_offset_bits=no
- cat >conftest.$ac_ext <<_ACEOF
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply "#define LARGE_OFF_T 9223372036854775807",
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
int
main ()
{
@@ -22456,12 +22556,16 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
- :
+ ac_cv_sys_file_offset_bits=no; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- cat >conftest.$ac_ext <<_ACEOF
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
@@ -22469,16 +22573,14 @@ cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply "#define LARGE_OFF_T 9223372036854775807",
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-
-
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
int
main ()
{
@@ -22504,7 +22606,7 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
- ac_cv_sys_file_offset_bits=64
+ ac_cv_sys_file_offset_bits=64; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
@@ -22513,41 +22615,43 @@ sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_cv_sys_file_offset_bits=unknown
+ break
+done
fi
{ echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5
echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6; }
- if test "$ac_cv_sys_file_offset_bits" != no; then
-
+case $ac_cv_sys_file_offset_bits in #(
+ no | unknown) ;;
+ *)
cat >>confdefs.h <<_ACEOF
#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
_ACEOF
-
- fi
- { echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5
+;;
+esac
+rm -f conftest*
+ if test $ac_cv_sys_file_offset_bits = unknown; then
+ { echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5
echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6; }
if test "${ac_cv_sys_large_files+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- ac_cv_sys_large_files=no
- cat >conftest.$ac_ext <<_ACEOF
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply "#define LARGE_OFF_T 9223372036854775807",
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
int
main ()
{
@@ -22573,12 +22677,16 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
- :
+ ac_cv_sys_large_files=no; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- cat >conftest.$ac_ext <<_ACEOF
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
@@ -22586,16 +22694,14 @@ cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#define _LARGE_FILES 1
#include <sys/types.h>
- /* Check that off_t can represent 2**63 - 1 correctly.
- We can't simply "#define LARGE_OFF_T 9223372036854775807",
- since some C++ compilers masquerading as C compilers
- incorrectly reject 9223372036854775807. */
-# define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
- int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
- && LARGE_OFF_T % 2147483647 == 1)
- ? 1 : -1];
-
-
+ /* Check that off_t can represent 2**63 - 1 correctly.
+ We can't simply define LARGE_OFF_T to be 9223372036854775807,
+ since some C++ compilers masquerading as C compilers
+ incorrectly reject 9223372036854775807. */
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+ int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
+ && LARGE_OFF_T % 2147483647 == 1)
+ ? 1 : -1];
int
main ()
{
@@ -22621,7 +22727,7 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
- ac_cv_sys_large_files=1
+ ac_cv_sys_large_files=1; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
@@ -22630,20 +22736,143 @@ sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_cv_sys_large_files=unknown
+ break
+done
fi
{ echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5
echo "${ECHO_T}$ac_cv_sys_large_files" >&6; }
- if test "$ac_cv_sys_large_files" != no; then
-
+case $ac_cv_sys_large_files in #(
+ no | unknown) ;;
+ *)
cat >>confdefs.h <<_ACEOF
#define _LARGE_FILES $ac_cv_sys_large_files
_ACEOF
+;;
+esac
+rm -f conftest*
+ fi
+fi
- fi
- fi
+{ echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5
+echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6; }
+if test "${ac_cv_sys_largefile_source+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ ac_cv_sys_largefile_source=no; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#define _LARGEFILE_SOURCE 1
+#include <stdio.h>
+int
+main ()
+{
+return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ ac_cv_sys_largefile_source=1; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+ ac_cv_sys_largefile_source=unknown
+ break
+done
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5
+echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6; }
+case $ac_cv_sys_largefile_source in #(
+ no | unknown) ;;
+ *)
+cat >>confdefs.h <<_ACEOF
+#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source
+_ACEOF
+;;
+esac
+rm -f conftest*
+
+# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
+# in glibc 2.1.3, but that breaks too many other things.
+# If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
+if test $ac_cv_sys_largefile_source != unknown; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_FSEEKO 1
+_ACEOF
+
+fi
{ echo "$as_me:$LINENO: checking for mbstate_t" >&5
echo $ECHO_N "checking for mbstate_t... $ECHO_C" >&6; }
@@ -22720,33 +22949,56 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
+$ac_includes_default
+typedef uint8_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+ return 0;
+if (sizeof (ac__type_new_))
+ return 0;
+ ;
+ return 0;
+}
_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "(^|[^a-zA-Z_0-9])uint8_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
ac_cv_type_uint8_t=yes
else
- ac_cv_type_uint8_t=no
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_uint8_t=no
fi
-rm -f conftest*
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ echo "$as_me:$LINENO: result: $ac_cv_type_uint8_t" >&5
echo "${ECHO_T}$ac_cv_type_uint8_t" >&6; }
-if test $ac_cv_type_uint8_t = no; then
- cat >>confdefs.h <<\_ACEOF
-#define uint8_t unsigned char
+if test $ac_cv_type_uint8_t = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT8_T 1
_ACEOF
-fi
+fi
{ echo "$as_me:$LINENO: checking for uint16_t" >&5
echo $ECHO_N "checking for uint16_t... $ECHO_C" >&6; }
if test "${ac_cv_type_uint16_t+set}" = set; then
@@ -22758,33 +23010,56 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
+$ac_includes_default
+typedef uint16_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+ return 0;
+if (sizeof (ac__type_new_))
+ return 0;
+ ;
+ return 0;
+}
_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "(^|[^a-zA-Z_0-9])uint16_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
ac_cv_type_uint16_t=yes
else
- ac_cv_type_uint16_t=no
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_uint16_t=no
fi
-rm -f conftest*
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ echo "$as_me:$LINENO: result: $ac_cv_type_uint16_t" >&5
echo "${ECHO_T}$ac_cv_type_uint16_t" >&6; }
-if test $ac_cv_type_uint16_t = no; then
- cat >>confdefs.h <<\_ACEOF
-#define uint16_t unsigned short
+if test $ac_cv_type_uint16_t = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT16_T 1
_ACEOF
-fi
+fi
{ echo "$as_me:$LINENO: checking for uint32_t" >&5
echo $ECHO_N "checking for uint32_t... $ECHO_C" >&6; }
if test "${ac_cv_type_uint32_t+set}" = set; then
@@ -22796,33 +23071,56 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
+$ac_includes_default
+typedef uint32_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+ return 0;
+if (sizeof (ac__type_new_))
+ return 0;
+ ;
+ return 0;
+}
_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "(^|[^a-zA-Z_0-9])uint32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
ac_cv_type_uint32_t=yes
else
- ac_cv_type_uint32_t=no
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_uint32_t=no
fi
-rm -f conftest*
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ echo "$as_me:$LINENO: result: $ac_cv_type_uint32_t" >&5
echo "${ECHO_T}$ac_cv_type_uint32_t" >&6; }
-if test $ac_cv_type_uint32_t = no; then
- cat >>confdefs.h <<\_ACEOF
-#define uint32_t unsigned int
+if test $ac_cv_type_uint32_t = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT32_T 1
_ACEOF
-fi
+fi
{ echo "$as_me:$LINENO: checking for int32_t" >&5
echo $ECHO_N "checking for int32_t... $ECHO_C" >&6; }
if test "${ac_cv_type_int32_t+set}" = set; then
@@ -22834,112 +23132,120 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
+$ac_includes_default
+typedef int32_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+ return 0;
+if (sizeof (ac__type_new_))
+ return 0;
+ ;
+ return 0;
+}
_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "(^|[^a-zA-Z_0-9])int32_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
ac_cv_type_int32_t=yes
else
- ac_cv_type_int32_t=no
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_int32_t=no
fi
-rm -f conftest*
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ echo "$as_me:$LINENO: result: $ac_cv_type_int32_t" >&5
echo "${ECHO_T}$ac_cv_type_int32_t" >&6; }
-if test $ac_cv_type_int32_t = no; then
- cat >>confdefs.h <<\_ACEOF
-#define int32_t int
+if test $ac_cv_type_int32_t = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT32_T 1
_ACEOF
-fi
-{ echo "$as_me:$LINENO: checking for long long" >&5
-echo $ECHO_N "checking for long long... $ECHO_C" >&6; }
-if test "${ac_cv_c_long_long+set}" = set; then
+fi
+{ echo "$as_me:$LINENO: checking for uint64_t" >&5
+echo $ECHO_N "checking for uint64_t... $ECHO_C" >&6; }
+if test "${ac_cv_type_uint64_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- if test "$GCC" = yes; then
- ac_cv_c_long_long=yes
-else
-if test "$cross_compiling" = yes; then
- { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-int main() {
-long long foo = 0;
-exit(sizeof(long long) < sizeof(long)); }
+$ac_includes_default
+typedef uint64_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+ return 0;
+if (sizeof (ac__type_new_))
+ return 0;
+ ;
+ return 0;
+}
_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
+ (eval "$ac_compile") 2>conftest.er1
ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_c_long_long=yes
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_type_uint64_t=yes
else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+ echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-( exit $ac_status )
-ac_cv_c_long_long=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+ ac_cv_type_uint64_t=no
fi
-
-fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_c_long_long" >&5
-echo "${ECHO_T}$ac_cv_c_long_long" >&6; }
-if test $ac_cv_c_long_long = yes; then
- cat >>confdefs.h <<\_ACEOF
-#define HAVE_LONG_LONG 1
+{ echo "$as_me:$LINENO: result: $ac_cv_type_uint64_t" >&5
+echo "${ECHO_T}$ac_cv_type_uint64_t" >&6; }
+if test $ac_cv_type_uint64_t = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT64_T 1
_ACEOF
-fi
-if test $ac_cv_c_long_long = yes; then
- ulong64='unsigned long long';
- long64='long long';
-else
- ulong64='unsigned long';
- long64='long';
fi
-{ echo "$as_me:$LINENO: checking for uint64_t" >&5
-echo $ECHO_N "checking for uint64_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_uint64_t+set}" = set; then
+{ echo "$as_me:$LINENO: checking for int64_t" >&5
+echo $ECHO_N "checking for int64_t... $ECHO_C" >&6; }
+if test "${ac_cv_type_int64_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
@@ -22948,39 +23254,60 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
+$ac_includes_default
+typedef int64_t ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+ return 0;
+if (sizeof (ac__type_new_))
+ return 0;
+ ;
+ return 0;
+}
_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "(^|[^a-zA-Z_0-9])uint64_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
- eval "ac_cv_type_uint64_t=yes"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_type_int64_t=yes
else
- eval "ac_cv_type_uint64_t=no"
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_type_int64_t=no
fi
-rm -f conftest*
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
-if eval "test \"`echo '$ac_cv_type_'uint64_t`\" = yes"; then
- { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
- cat >>confdefs.h <<_ACEOF
-#define uint64_t $ulong64
+{ echo "$as_me:$LINENO: result: $ac_cv_type_int64_t" >&5
+echo "${ECHO_T}$ac_cv_type_int64_t" >&6; }
+if test $ac_cv_type_int64_t = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT64_T 1
_ACEOF
+
fi
-{ echo "$as_me:$LINENO: checking for int64_t" >&5
-echo $ECHO_N "checking for int64_t... $ECHO_C" >&6; }
-if test "${ac_cv_type_int64_t+set}" = set; then
+{ echo "$as_me:$LINENO: checking for long long" >&5
+echo $ECHO_N "checking for long long... $ECHO_C" >&6; }
+if test "${ac_cv_type_long_long+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
@@ -22989,263 +23316,309 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif
+$ac_includes_default
+typedef long long ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+ return 0;
+if (sizeof (ac__type_new_))
+ return 0;
+ ;
+ return 0;
+}
_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "(^|[^a-zA-Z_0-9])int64_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
- eval "ac_cv_type_int64_t=yes"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+ (eval "$ac_compile") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_cv_type_long_long=yes
else
- eval "ac_cv_type_int64_t=no"
-fi
-rm -f conftest*
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+ ac_cv_type_long_long=no
fi
-if eval "test \"`echo '$ac_cv_type_'int64_t`\" = yes"; then
- { echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6; }
-else
- { echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6; }
- cat >>confdefs.h <<_ACEOF
-#define int64_t $long64
-_ACEOF
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5
+echo "${ECHO_T}$ac_cv_type_long_long" >&6; }
-
-{ echo "$as_me:$LINENO: checking size of uint8_t" >&5
-echo $ECHO_N "checking size of uint8_t... $ECHO_C" >&6; }
-if test "${ac_cv_sizeof_uint8_t+set}" = set; then
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ echo "$as_me:$LINENO: checking size of long long" >&5
+echo $ECHO_N "checking size of long long... $ECHO_C" >&6; }
+if test "${ac_cv_sizeof_long_long+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
- ac_cv_sizeof_uint8_t=0
-else
- cat >conftest.$ac_ext <<_ACEOF
+ # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#endif
-
-#include <stdio.h>
-main()
+$ac_includes_default
+ typedef long long ac__type_sizeof_;
+int
+main ()
{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(uint8_t));
- exit(0);
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
}
_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>&5
+ (eval "$ac_compile") 2>conftest.er1
ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (case "(($ac_try" in
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+ typedef long long ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
+ (eval "$ac_compile") 2>conftest.er1
ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_sizeof_uint8_t=`cat conftestval`
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_hi=$ac_mid; break
else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+ echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-( exit $ac_status )
-ac_cv_sizeof_uint8_t=0
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+ ac_lo=`expr $ac_mid + 1`
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid + 1`
fi
-
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_uint8_t" >&5
-echo "${ECHO_T}$ac_cv_sizeof_uint8_t" >&6; }
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_UINT8_T $ac_cv_sizeof_uint8_t
-_ACEOF
-
-
-
-{ echo "$as_me:$LINENO: checking size of uint16_t" >&5
-echo $ECHO_N "checking size of uint16_t... $ECHO_C" >&6; }
-if test "${ac_cv_sizeof_uint16_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_sizeof_uint16_t=0
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
else
- cat >conftest.$ac_ext <<_ACEOF
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#endif
-
-#include <stdio.h>
-main()
+$ac_includes_default
+ typedef long long ac__type_sizeof_;
+int
+main ()
{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(uint16_t));
- exit(0);
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)];
+test_array [0] = 0
+
+ ;
+ return 0;
}
_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>&5
+ (eval "$ac_compile") 2>conftest.er1
ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (case "(($ac_try" in
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+ typedef long long ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
+ (eval "$ac_compile") 2>conftest.er1
ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_sizeof_uint16_t=`cat conftestval`
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_lo=$ac_mid; break
else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+ echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-( exit $ac_status )
-ac_cv_sizeof_uint16_t=0
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+ ac_hi=`expr '(' $ac_mid ')' - 1`
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ ac_mid=`expr 2 '*' $ac_mid`
fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+ ac_lo= ac_hi=
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_uint16_t" >&5
-echo "${ECHO_T}$ac_cv_sizeof_uint16_t" >&6; }
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_UINT16_T $ac_cv_sizeof_uint16_t
-_ACEOF
-
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
-{ echo "$as_me:$LINENO: checking size of uint32_t" >&5
-echo $ECHO_N "checking size of uint32_t... $ECHO_C" >&6; }
-if test "${ac_cv_sizeof_uint32_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_sizeof_uint32_t=0
-else
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#endif
-
-#include <stdio.h>
-main()
+$ac_includes_default
+ typedef long long ac__type_sizeof_;
+int
+main ()
{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(uint32_t));
- exit(0);
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
+test_array [0] = 0
+
+ ;
+ return 0;
}
_ACEOF
-rm -f conftest$ac_exeext
-if { (ac_try="$ac_link"
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
+ (eval "$ac_compile") 2>conftest.er1
ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_sizeof_uint32_t=`cat conftestval`
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then
+ ac_hi=$ac_mid
else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+ echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-( exit $ac_status )
-ac_cv_sizeof_uint32_t=0
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-
-
+ ac_lo=`expr '(' $ac_mid ')' + 1`
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_uint32_t" >&5
-echo "${ECHO_T}$ac_cv_sizeof_uint32_t" >&6; }
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_UINT32_T $ac_cv_sizeof_uint32_t
-_ACEOF
-
-
-{ echo "$as_me:$LINENO: checking size of int64_t" >&5
-echo $ECHO_N "checking size of int64_t... $ECHO_C" >&6; }
-if test "${ac_cv_sizeof_int64_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_sizeof_int64_t=0
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_long_long=$ac_lo;;
+'') if test "$ac_cv_type_long_long" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long)
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long long)
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+ else
+ ac_cv_sizeof_long_long=0
+ fi ;;
+esac
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
@@ -23253,21 +23626,37 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <sys/types.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
-#endif
-
+$ac_includes_default
+ typedef long long ac__type_sizeof_;
+static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); }
+static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); }
#include <stdio.h>
-main()
+#include <stdlib.h>
+int
+main ()
{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(int64_t));
- exit(0);
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ return 1;
+ if (((long int) (sizeof (ac__type_sizeof_))) < 0)
+ {
+ long int i = longval ();
+ if (i != ((long int) (sizeof (ac__type_sizeof_))))
+ return 1;
+ fprintf (f, "%ld\n", i);
+ }
+ else
+ {
+ unsigned long int i = ulongval ();
+ if (i != ((long int) (sizeof (ac__type_sizeof_))))
+ return 1;
+ fprintf (f, "%lu\n", i);
+ }
+ return ferror (f) || fclose (f) != 0;
+
+ ;
+ return 0;
}
_ACEOF
rm -f conftest$ac_exeext
@@ -23290,35 +23679,90 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ac_cv_sizeof_int64_t=`cat conftestval`
+ ac_cv_sizeof_long_long=`cat conftest.val`
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
-ac_cv_sizeof_int64_t=0
+if test "$ac_cv_type_long_long" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long)
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long long)
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+ else
+ ac_cv_sizeof_long_long=0
+ fi
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
+rm -f conftest.val
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5
+echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6; }
+
-fi
-{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_int64_t" >&5
-echo "${ECHO_T}$ac_cv_sizeof_int64_t" >&6; }
cat >>confdefs.h <<_ACEOF
-#define SIZEOF_INT64_T $ac_cv_sizeof_int64_t
+#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
_ACEOF
-{ echo "$as_me:$LINENO: checking size of uint64_t" >&5
-echo $ECHO_N "checking size of uint64_t... $ECHO_C" >&6; }
-if test "${ac_cv_sizeof_uint64_t+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
+
+
+{ echo "$as_me:$LINENO: checking for gcc compiler warnings" >&5
+echo $ECHO_N "checking for gcc compiler warnings... $ECHO_C" >&6; }
+# Check whether --enable-warnings was given.
+if test "${enable_warnings+set}" = set; then
+ enableval=$enable_warnings; if test "${enableval}" = no -o $GCC = no; then
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+ WARNINGS=
else
- if test "$cross_compiling" = yes; then
- ac_cv_sizeof_uint64_t=0
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+ WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
+ -Wmissing-declarations -Wredundant-decls -Wnested-externs \
+ -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
+ -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter"
+fi
+else
+
+if test $GCC = no; then
+ WARNINGS=
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+else
+ { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+ WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
+ -Wmissing-declarations -Wredundant-decls -Wnested-externs \
+ -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
+ -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter"
+fi
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+for ac_func in mmap strerror strndup strtoul mbrtowc mkstemp utimes utime wcwidth strtof
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
@@ -23326,80 +23770,90 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#if HAVE_STDINT_H
-#include <stdint.h>
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
#endif
-#include <sys/types.h>
-#ifdef STDC_HEADERS
-#include <stdlib.h>
+
+#undef $ac_func
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$ac_func || defined __stub___$ac_func
+choke me
#endif
-#include <stdio.h>
-main()
+int
+main ()
{
- FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
- fprintf(f, "%d\n", sizeof(uint64_t));
- exit(0);
+return $ac_func ();
+ ;
+ return 0;
}
_ACEOF
-rm -f conftest$ac_exeext
+rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_link") 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (case "(($ac_try" in
- *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
- *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
- (eval "$ac_try") 2>&5
+ (eval "$ac_link") 2>conftest.er1
ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_sizeof_uint64_t=`cat conftestval`
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext &&
+ $as_test_x conftest$ac_exeext; then
+ eval "$as_ac_var=yes"
else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
+ echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-( exit $ac_status )
-ac_cv_sizeof_uint64_t=0
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+ eval "$as_ac_var=no"
fi
-
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
fi
-{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_uint64_t" >&5
-echo "${ECHO_T}$ac_cv_sizeof_uint64_t" >&6; }
-cat >>confdefs.h <<_ACEOF
-#define SIZEOF_UINT64_T $ac_cv_sizeof_uint64_t
+ac_res=`eval echo '${'$as_ac_var'}'`
+ { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
+fi
+done
-
-
-
-
-
-
-
-
-
-
-
-for ac_func in mmap strerror strndup strtoul mbrtowc mkstemp getopt_long utimes utime wcwidth snprintf vsnprintf strtof
+for ac_func in getopt_long asprintf vasprintf
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -23489,11 +23943,19 @@ if test `eval echo '${'$as_ac_var'}'` = yes; then
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
+else
+ case " $LIBOBJS " in
+ *" $ac_func.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
+ ;;
+esac
+
fi
done
+
{ echo "$as_me:$LINENO: checking for gzopen in -lz" >&5
echo $ECHO_N "checking for gzopen in -lz... $ECHO_C" >&6; }
if test "${ac_cv_lib_z_gzopen+set}" = set; then
@@ -23574,7 +24036,7 @@ else
fi
-ac_config_files="$ac_config_files Makefile src/Makefile magic/Makefile doc/Makefile python/Makefile"
+ac_config_files="$ac_config_files Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -23672,13 +24134,6 @@ LIBOBJS=$ac_libobjs
LTLIBOBJS=$ac_ltlibobjs
-if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
- { { echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined.
-Usually this means the macro was only invoked conditionally." >&5
-echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined.
-Usually this means the macro was only invoked conditionally." >&2;}
- { (exit 1); exit 1; }; }
-fi
if test -z "${FSECT5_TRUE}" && test -z "${FSECT5_FALSE}"; then
{ { echo "$as_me:$LINENO: error: conditional \"FSECT5\" was never defined.
Usually this means the macro was only invoked conditionally." >&5
@@ -24014,7 +24469,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by $as_me, which was
+This file was extended by file $as_me 4.26, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -24067,7 +24522,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-config.status
+file config.status 4.26
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
@@ -24186,6 +24641,7 @@ do
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
"magic/Makefile") CONFIG_FILES="$CONFIG_FILES magic/Makefile" ;;
+ "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
"doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
"python/Makefile") CONFIG_FILES="$CONFIG_FILES python/Makefile" ;;
@@ -24309,12 +24765,10 @@ am__leading_dot!$am__leading_dot$ac_delim
AMTAR!$AMTAR$ac_delim
am__tar!$am__tar$ac_delim
am__untar!$am__untar$ac_delim
-MAINTAINER_MODE_TRUE!$MAINTAINER_MODE_TRUE$ac_delim
-MAINTAINER_MODE_FALSE!$MAINTAINER_MODE_FALSE$ac_delim
-MAINT!$MAINT$ac_delim
fsect!$fsect$ac_delim
FSECT5_TRUE!$FSECT5_TRUE$ac_delim
FSECT5_FALSE!$FSECT5_FALSE$ac_delim
+WARNINGS!$WARNINGS$ac_delim
CC!$CC$ac_delim
CFLAGS!$CFLAGS$ac_delim
LDFLAGS!$LDFLAGS$ac_delim
@@ -24347,6 +24801,8 @@ AR!$AR$ac_delim
RANLIB!$RANLIB$ac_delim
CPP!$CPP$ac_delim
CXX!$CXX$ac_delim
+CXXFLAGS!$CXXFLAGS$ac_delim
+ac_ct_CXX!$ac_ct_CXX$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -24388,8 +24844,6 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
-CXXFLAGS!$CXXFLAGS$ac_delim
-ac_ct_CXX!$ac_ct_CXX$ac_delim
CXXDEPMODE!$CXXDEPMODE$ac_delim
am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim
am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim
@@ -24398,13 +24852,13 @@ F77!$F77$ac_delim
FFLAGS!$FFLAGS$ac_delim
ac_ct_F77!$ac_ct_F77$ac_delim
LIBTOOL!$LIBTOOL$ac_delim
+LIBOBJS!$LIBOBJS$ac_delim
IS_CROSS_COMPILE_TRUE!$IS_CROSS_COMPILE_TRUE$ac_delim
IS_CROSS_COMPILE_FALSE!$IS_CROSS_COMPILE_FALSE$ac_delim
-LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 14; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 12; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 000000000000..ae674ffee482
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,151 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(file, 4.26, christos@astron.com)
+AM_INIT_AUTOMAKE
+AM_CONFIG_HEADER(config.h)
+
+AC_MSG_CHECKING(for builtin ELF support)
+AC_ARG_ENABLE(elf,
+[ --disable-elf disable builtin ELF support],
+[if test "${enableval}" = yes; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([BUILTIN_ELF], 1, [Define if built-in ELF support is used])
+else
+ AC_MSG_RESULT(no)
+fi], [
+ # enable by default
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([BUILTIN_ELF], 1, [Define in built-in ELF support is used])
+])
+
+AC_MSG_CHECKING(for ELF core file support)
+AC_ARG_ENABLE(elf-core,
+[ --disable-elf-core disable ELF core file support],
+[if test "${enableval}" = yes; then
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
+else
+ AC_MSG_RESULT(no)
+fi], [
+ # enable by default
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([ELFCORE], 1, [Define for ELF core file support])
+])
+
+AC_MSG_CHECKING(for file formats in man section 5)
+AC_ARG_ENABLE(fsect-man5,
+[ --enable-fsect-man5 enable file formats in man section 5],
+[if test "${enableval}" = yes; then
+ AC_MSG_RESULT(yes)
+ fsect=5
+else
+ AC_MSG_RESULT(no)
+ fsect=4
+fi], [
+ # disable by default
+ AC_MSG_RESULT(no)
+ fsect=4
+])
+
+AC_SUBST(fsect)
+AM_CONDITIONAL(FSECT5, test x$fsect = x5)
+
+AC_SUBST(WARNINGS)
+AC_GNU_SOURCE
+
+dnl Checks for programs.
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_LIBTOOL
+
+dnl Checks for headers
+AC_HEADER_STDC
+AC_HEADER_MAJOR
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS(stdint.h fcntl.h locale.h stdint.h inttypes.h unistd.h)
+AC_CHECK_HEADERS(utime.h wchar.h wctype.h limits.h)
+AC_CHECK_HEADERS(getopt.h err.h)
+AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
+AC_CHECK_HEADERS(zlib.h)
+
+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])
+
+AC_STRUCT_TIMEZONE_DAYLIGHT
+AC_SYS_LARGEFILE
+AC_FUNC_FSEEKO
+AC_TYPE_MBSTATE_T
+
+AC_CHECK_TYPES([uint8_t, uint16_t, uint32_t, int32_t, uint64_t, int64_t])
+AC_CHECK_SIZEOF(long long)
+AH_BOTTOM([
+#ifndef HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+#ifndef HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+#ifndef HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+#ifndef HAVE_INT32_T
+typedef int int32_t;
+#endif
+#ifndef HAVE_UINT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef unsigned long long uint64_t;
+#else
+typedef unsigned long uint64_t;
+#endif
+#endif
+#ifndef HAVE_INT64_T
+#if SIZEOF_LONG_LONG == 8
+typedef long long int64_t;
+#else
+typedef long int64_t;
+#endif
+#endif
+])
+
+AC_MSG_CHECKING(for gcc compiler warnings)
+AC_ARG_ENABLE(warnings,
+[ --disable-warnings disable compiler warnings],
+[if test "${enableval}" = no -o $GCC = no; then
+ AC_MSG_RESULT(no)
+ WARNINGS=
+else
+ AC_MSG_RESULT(yes)
+ WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
+ -Wmissing-declarations -Wredundant-decls -Wnested-externs \
+ -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
+ -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter"
+fi], [
+if test $GCC = no; then
+ WARNINGS=
+ AC_MSG_RESULT(no)
+else
+ AC_MSG_RESULT(yes)
+ WARNINGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
+ -Wmissing-declarations -Wredundant-decls -Wnested-externs \
+ -Wsign-compare -Wreturn-type -Wswitch -Wshadow \
+ -Wcast-qual -Wwrite-strings -Wextra -Wunused-parameter"
+fi])
+
+dnl Checks for functions
+AC_CHECK_FUNCS(mmap strerror strndup strtoul mbrtowc mkstemp utimes utime wcwidth strtof)
+
+dnl Provide implementation of some required functions if necessary
+AC_REPLACE_FUNCS(getopt_long asprintf vasprintf)
+
+dnl Checks for libraries
+AC_CHECK_LIB(z,gzopen)
+
+dnl See if we are cross-compiling
+AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
+
+AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile tests/Makefile doc/Makefile python/Makefile])
+AC_OUTPUT
diff --git a/configure.in b/configure.in
deleted file mode 100644
index ee509e226a1c..000000000000
--- a/configure.in
+++ /dev/null
@@ -1,139 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT
-AC_CONFIG_SRCDIR([src/file.c])
-AM_INIT_AUTOMAKE(file, 4.23)
-AM_CONFIG_HEADER([config.h])
-AM_MAINTAINER_MODE
-
-AC_MSG_CHECKING(for builtin ELF support)
-AC_ARG_ENABLE(elf,
-[ --disable-elf disable builtin ELF support],
-[if test "${enableval}" = yes; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(BUILTIN_ELF)
-else
- AC_MSG_RESULT(no)
-fi], [
- # enable by default
- AC_MSG_RESULT(yes)
- AC_DEFINE(BUILTIN_ELF)
-])
-
-AC_MSG_CHECKING(for ELF core file support)
-AC_ARG_ENABLE(elf-core,
-[ --disable-elf-core disable ELF core file support],
-[if test "${enableval}" = yes; then
- AC_MSG_RESULT(yes)
- AC_DEFINE(ELFCORE)
-else
- AC_MSG_RESULT(no)
-fi], [
- # enable by default
- AC_MSG_RESULT(yes)
- AC_DEFINE(ELFCORE)
-])
-
-AC_MSG_CHECKING(for file formats in man section 5)
-AC_ARG_ENABLE(fsect-man5,
-[ --enable-fsect-man5 enable file formats in man section 5],
-[if test "${enableval}" = yes; then
- AC_MSG_RESULT(yes)
- fsect=5
-else
- AC_MSG_RESULT(no)
- fsect=4
-fi], [
- # disable by default
- AC_MSG_RESULT(no)
- fsect=4
-])
-AC_SUBST(fsect)
-AM_CONDITIONAL(FSECT5, test x$fsect = x5)
-AC_GNU_SOURCE
-
-dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_INSTALL
-AC_PROG_LN_S
-AC_PROG_LIBTOOL
-
-dnl Templates for autoheader
-AH_TEMPLATE([BUILTIN_ELF],
- [Use the builtin ELF recognition code])
-AH_TEMPLATE([ELFCORE],
- [Recognize ELF core files])
-AH_TEMPLATE([HAVE_DAYLIGHT], [])
-AH_TEMPLATE([HAVE_LONG_LONG], [])
-AH_TEMPLATE([HAVE_TM_ISDST], [])
-AH_TEMPLATE([SIZEOF_UINT16_T], [])
-AH_TEMPLATE([SIZEOF_UINT32_T], [])
-AH_TEMPLATE([SIZEOF_INT64_T], [])
-AH_TEMPLATE([SIZEOF_UINT64_T], [])
-AH_TEMPLATE([SIZEOF_UINT8_T], [])
-AH_TEMPLATE([int32_t], [])
-AH_TEMPLATE([uint16_t], [])
-AH_TEMPLATE([uint32_t], [])
-AH_TEMPLATE([int64_t], [])
-AH_TEMPLATE([uint64_t], [])
-AH_TEMPLATE([uint8_t], [])
-
-dnl Checks for headers
-AC_HEADER_STDC
-AC_HEADER_MAJOR
-AC_HEADER_SYS_WAIT
-AC_HEADER_STDINT
-AC_CHECK_HEADERS(fcntl.h locale.h stdint.h inttypes.h unistd.h getopt.h)
-AC_CHECK_HEADERS(utime.h wchar.h wctype.h limits.h)
-AC_CHECK_HEADERS(sys/mman.h sys/stat.h sys/types.h sys/utime.h sys/time.h)
-AC_CHECK_HEADERS(zlib.h)
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_TYPE_OFF_T
-AC_TYPE_SIZE_T
-AC_DIAGNOSE([obsolete],[AC_STRUCT_ST_RDEV:
- your code should no longer depend upon `HAVE_ST_RDEV', but
- `HAVE_STRUCT_STAT_ST_RDEV'. Remove this warning and
- the `AC_DEFINE' when you adjust the code.])
-AC_CHECK_MEMBERS([struct stat.st_rdev],[AC_DEFINE(HAVE_ST_RDEV, 1,
- [Define to 1 if your `struct stat' has `st_rdev'.
- Deprecated, use `HAVE_STRUCT_STAT_ST_RDEV'
- instead.])])
-
-AC_STRUCT_TIMEZONE_DAYLIGHT
-AC_SYS_LARGEFILE
-AC_TYPE_MBSTATE_T
-
-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_CHECK_TYPE_STDC(int32_t, int)
-AC_C_LONG_LONG
-if test $ac_cv_c_long_long = yes; then
- ulong64='unsigned long long';
- long64='long long';
-else
- ulong64='unsigned long';
- long64='long';
-fi
-dnl This needs a patch to autoconf 2.13 acgeneral.m4
-AC_CHECK_TYPE2_STDC(uint64_t, $ulong64)
-AC_CHECK_TYPE2_STDC(int64_t, $long64)
-
-AC_CHECK_SIZEOF_STDC_HEADERS(uint8_t, 0)
-AC_CHECK_SIZEOF_STDC_HEADERS(uint16_t, 0)
-AC_CHECK_SIZEOF_STDC_HEADERS(uint32_t, 0)
-AC_CHECK_SIZEOF_STDC_HEADERS(int64_t, 0)
-AC_CHECK_SIZEOF_STDC_HEADERS(uint64_t, 0)
-
-dnl Checks for functions
-AC_CHECK_FUNCS(mmap strerror strndup strtoul mbrtowc mkstemp getopt_long utimes utime wcwidth snprintf vsnprintf strtof)
-
-dnl Checks for libraries
-AC_CHECK_LIB(z,gzopen)
-
-dnl See if we are cross-compiling
-AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
-
-AC_CONFIG_FILES([Makefile src/Makefile magic/Makefile doc/Makefile python/Makefile])
-AC_OUTPUT
diff --git a/elfclass.h b/elfclass.h
new file mode 100644
index 000000000000..27817d0fefd0
--- /dev/null
+++ b/elfclass.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) Christos Zoulas 2008.
+ * 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 immediately at the beginning of the file, without modification,
+ * 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 AUTHOR 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 AUTHOR 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.
+ */
+ if (nbytes <= sizeof(elfhdr))
+ return 0;
+
+ u.l = 1;
+ (void)memcpy(&elfhdr, buf, sizeof elfhdr);
+ swap = (u.c[sizeof(int32_t) - 1] + 1) != elfhdr.e_ident[EI_DATA];
+
+ type = elf_getu16(swap, elfhdr.e_type);
+ switch (type) {
+#ifdef ELFCORE
+ case ET_CORE:
+ if (dophn_core(ms, clazz, swap, fd,
+ (off_t)elf_getu(swap, elfhdr.e_phoff),
+ elf_getu16(swap, elfhdr.e_phnum),
+ (size_t)elf_getu16(swap, elfhdr.e_phentsize),
+ fsize, &flags) == -1)
+ return -1;
+ break;
+#endif
+ case ET_EXEC:
+ case ET_DYN:
+ if (dophn_exec(ms, clazz, swap, fd,
+ (off_t)elf_getu(swap, elfhdr.e_phoff),
+ elf_getu16(swap, elfhdr.e_phnum),
+ (size_t)elf_getu16(swap, elfhdr.e_phentsize),
+ fsize, &flags, elf_getu16(swap, elfhdr.e_shnum))
+ == -1)
+ return -1;
+ /*FALLTHROUGH*/
+ case ET_REL:
+ if (doshn(ms, clazz, swap, fd,
+ (off_t)elf_getu(swap, elfhdr.e_shoff),
+ elf_getu16(swap, elfhdr.e_shnum),
+ (size_t)elf_getu16(swap, elfhdr.e_shentsize),
+ &flags,
+ elf_getu16(swap, elfhdr.e_machine)) == -1)
+ return -1;
+ break;
+
+ default:
+ break;
+ }
+ return 1;
diff --git a/file.c b/file.c
index 575b951f8178..2f518da99e57 100644
--- a/file.c
+++ b/file.c
@@ -61,9 +61,12 @@
#endif
#ifdef HAVE_GETOPT_H
-#include <getopt.h> /* for long options (is this portable?)*/
+#include <getopt.h>
#else
-#undef HAVE_GETOPT_LONG
+#include "mygetopt.h"
+#endif
+#ifndef HAVE_GETOPT_LONG
+int getopt_long(int argc, char * const *argv, const char *optstring, const struct option *longopts, int *longindex);
#endif
#include <netinet/in.h> /* for byte swapping */
@@ -71,7 +74,7 @@
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$File: file.c,v 1.117 2007/12/27 16:35:58 christos Exp $")
+FILE_RCSID("@(#)$File: file.c,v 1.121 2008/07/03 15:48:18 christos Exp $")
#endif /* lint */
@@ -103,13 +106,7 @@ private struct magic_set *magic;
private void unwrap(char *);
private void usage(void);
-#ifdef HAVE_GETOPT_LONG
private void help(void);
-#endif
-#if 0
-private int byteconv4(int, int, int);
-private short byteconv2(int, int, int);
-#endif
int main(int, char *[]);
private void process(const char *, int);
@@ -130,7 +127,6 @@ main(int argc, char *argv[])
struct stat sb;
static const char hmagic[] = "/.magic";
#define OPTSTRING "bcCde:f:F:hikLm:nNprsvz0"
-#ifdef HAVE_GETOPT_LONG
int longindex;
static const struct option long_options[] =
{
@@ -143,7 +139,6 @@ main(int argc, char *argv[])
#undef OPT_LONGONLY
{0, 0, NULL, 0}
};
-#endif
static const struct {
const char *name;
@@ -156,13 +151,10 @@ main(int argc, char *argv[])
{ "soft", MAGIC_NO_CHECK_SOFT },
{ "tar", MAGIC_NO_CHECK_TAR },
{ "tokens", MAGIC_NO_CHECK_TOKENS },
- { "troff", MAGIC_NO_CHECK_TROFF },
};
-#ifdef LC_CTYPE
/* makes islower etc work for other langs */
(void)setlocale(LC_CTYPE, "");
-#endif
#ifdef __EMX__
/* sh-like wildcard expansion! Shouldn't hurt at least ... */
@@ -193,14 +185,9 @@ main(int argc, char *argv[])
#ifdef S_IFLNK
flags |= getenv("POSIXLY_CORRECT") ? MAGIC_SYMLINK : 0;
#endif
-#ifndef HAVE_GETOPT_LONG
- 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_LONG
case 0 :
switch (longindex) {
case 0:
@@ -214,7 +201,6 @@ main(int argc, char *argv[])
break;
}
break;
-#endif
case '0':
nulsep = 1;
break;
@@ -349,8 +335,9 @@ main(int argc, char *argv[])
process(argv[optind], wid);
}
+ c = magic->haderr ? 1 : 0;
magic_close(magic);
- return 0;
+ return c;
}
@@ -392,7 +379,7 @@ unwrap(char *fn)
exit(1);
}
- while (fgets(buf, MAXPATHLEN, f) != NULL) {
+ while (fgets(buf, sizeof(buf), f) != NULL) {
buf[strcspn(buf, "\n")] = '\0';
cwid = file_mbswidth(buf);
if (cwid > wid)
@@ -438,64 +425,6 @@ process(const char *inname, int wid)
(void)printf("%s\n", type);
}
-
-#if 0
-/*
- * byteconv4
- * Input:
- * from 4 byte quantity to convert
- * same whether to perform byte swapping
- * big_endian whether we are a big endian host
- */
-private int
-byteconv4(int from, int same, int big_endian)
-{
- if (same)
- return from;
- else if (big_endian) { /* lsb -> msb conversion on msb */
- union {
- int i;
- char c[4];
- } retval, tmpval;
-
- tmpval.i = from;
- retval.c[0] = tmpval.c[3];
- retval.c[1] = tmpval.c[2];
- retval.c[2] = tmpval.c[1];
- retval.c[3] = tmpval.c[0];
-
- return retval.i;
- }
- else
- return ntohl(from); /* msb -> lsb conversion on lsb */
-}
-
-/*
- * byteconv2
- * Same as byteconv4, but for shorts
- */
-private short
-byteconv2(int from, int same, int big_endian)
-{
- if (same)
- return from;
- else if (big_endian) { /* lsb -> msb conversion on msb */
- union {
- short s;
- char c[2];
- } retval, tmpval;
-
- tmpval.s = (short) from;
- retval.c[0] = tmpval.c[1];
- retval.c[1] = tmpval.c[0];
-
- return retval.s;
- }
- else
- return ntohs(from); /* msb -> lsb conversion on lsb */
-}
-#endif
-
size_t
file_mbswidth(const char *s)
{
@@ -534,13 +463,10 @@ private void
usage(void)
{
(void)fprintf(stderr, USAGE, progname, progname);
-#ifdef HAVE_GETOPT_LONG
(void)fputs("Try `file --help' for more information.\n", stderr);
-#endif
exit(1);
}
-#ifdef HAVE_GETOPT_LONG
private void
help(void)
{
@@ -557,4 +483,3 @@ help(void)
#undef OPT_LONGONLY
exit(0);
}
-#endif
diff --git a/file.h b/file.h
index ce0f4e263022..aab1137b342a 100644
--- a/file.h
+++ b/file.h
@@ -27,7 +27,7 @@
*/
/*
* file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.92 2007/11/08 00:31:37 christos Exp $
+ * @(#)$File: file.h,v 1.108 2008/07/16 18:00:57 christos Exp $
*/
#ifndef __file_h__
@@ -50,6 +50,7 @@
#include <sys/types.h>
/* Do this here and now, because struct stat gets re-defined on solaris */
#include <sys/stat.h>
+#include <stdarg.h>
#define ENABLE_CONDITIONALS
@@ -79,40 +80,70 @@
#endif
#endif
+#ifndef __GNUC__
+#ifndef __attribute__
+#define __attribute__(a)
+#endif
+#endif
+
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
+#ifndef MAX
+#define MAX(a,b) (((a) > (b)) ? (a) : (b))
+#endif
+
#ifndef HOWMANY
# define HOWMANY (256 * 1024) /* how much of the file to look at */
#endif
-#define MAXMAGIS 8192 /* max entries in /etc/magic */
-#define MAXDESC 64 /* max leng of text description */
+#define MAXMAGIS 8192 /* max entries in any one magic file
+ or directory */
+#define MAXDESC 64 /* max leng of text description/MIME type */
#define MAXstring 32 /* max leng of "string" types */
#define MAGICNO 0xF11E041C
-#define VERSIONNO 4
-#define FILE_MAGICSIZE (32 * 4)
+#define VERSIONNO 6
+#define FILE_MAGICSIZE (32 * 6)
#define FILE_LOAD 0
#define FILE_CHECK 1
#define FILE_COMPILE 2
+union VALUETYPE {
+ uint8_t b;
+ uint16_t h;
+ uint32_t l;
+ uint64_t q;
+ uint8_t hs[2]; /* 2 bytes of a fixed-endian "short" */
+ uint8_t hl[4]; /* 4 bytes of a fixed-endian "long" */
+ uint8_t hq[8]; /* 8 bytes of a fixed-endian "quad" */
+ char s[MAXstring]; /* the search string or regex pattern */
+ unsigned char us[MAXstring];
+ float f;
+ double d;
+};
+
struct magic {
/* Word 1 */
uint16_t cont_level; /* level of ">" */
- uint8_t nospflag; /* supress space character */
uint8_t flag;
-#define INDIR 1 /* if '(...)' appears */
-#define OFFADD 2 /* if '>&' or '>...(&' appears */
-#define INDIROFFADD 4 /* if '>&(' appears */
-#define UNSIGNED 8 /* comparison is unsigned */
+#define INDIR 0x01 /* if '(...)' appears */
+#define OFFADD 0x02 /* if '>&' or '>...(&' appears */
+#define INDIROFFADD 0x04 /* if '>&(' appears */
+#define UNSIGNED 0x08 /* comparison is unsigned */
+#define NOSPACE 0x10 /* suppress space character before output */
+#define BINTEST 0x20 /* test is for a binary type (set only
+ for top-level tests) */
+#define TEXTTEST 0 /* for passing to file_softmagic */
+
+ uint8_t factor;
/* Word 2 */
uint8_t reln; /* relation (0=eq, '>'=gt, etc) */
uint8_t vallen; /* length of string value, if any */
- uint8_t type; /* int, short, long or string. */
- uint8_t in_type; /* type of indirrection */
+ uint8_t type; /* comparison type (FILE_*) */
+ uint8_t in_type; /* type of indirection */
#define FILE_INVALID 0
#define FILE_BYTE 1
#define FILE_SHORT 2
@@ -175,11 +206,15 @@ struct magic {
uint8_t mask_op; /* operator for mask */
#ifdef ENABLE_CONDITIONALS
uint8_t cond; /* conditional type */
- uint8_t dummy1;
#else
- uint8_t dummy1;
- uint8_t dummy2;
+ uint8_t dummy;
#endif
+ uint8_t factor_op;
+#define FILE_FACTOR_OP_PLUS '+'
+#define FILE_FACTOR_OP_MINUS '-'
+#define FILE_FACTOR_OP_TIMES '*'
+#define FILE_FACTOR_OP_DIV '/'
+#define FILE_FACTOR_OP_NONE '\0'
#define FILE_OPS "&|^+-*/%"
#define FILE_OPAND 0
@@ -219,24 +254,14 @@ struct magic {
} _s; /* for use with string types */
} _u;
#define num_mask _u._mask
-#define str_count _u._s._count
+#define str_range _u._s._count
#define str_flags _u._s._flags
-
/* Words 9-16 */
- union VALUETYPE {
- uint8_t b;
- uint16_t h;
- uint32_t l;
- uint64_t q;
- uint8_t hs[2]; /* 2 bytes of a fixed-endian "short" */
- uint8_t hl[4]; /* 4 bytes of a fixed-endian "long" */
- uint8_t hq[8]; /* 8 bytes of a fixed-endian "quad" */
- char s[MAXstring]; /* the search string or regex pattern */
- float f;
- double d;
- } value; /* either number or string */
+ union VALUETYPE value; /* either number or string */
/* Words 17..31 */
char desc[MAXDESC]; /* description */
+ /* Words 32..47 */
+ char mimetype[MAXDESC]; /* MIME type */
};
#define BIT(A) (1 << (A))
@@ -251,6 +276,7 @@ struct magic {
#define CHAR_IGNORE_UPPERCASE 'C'
#define CHAR_REGEX_OFFSET_START 's'
#define STRING_IGNORE_CASE (STRING_IGNORE_LOWERCASE|STRING_IGNORE_UPPERCASE)
+#define STRING_DEFAULT_RANGE 100
/* list of magic entries */
@@ -263,28 +289,29 @@ struct mlist {
struct mlist *next, *prev;
};
+#ifdef __cplusplus
+#define CAST(T, b) static_cast<T>(b)
+#else
+#define CAST(T, b) (b)
+#endif
+
+struct level_info {
+ int32_t off;
+ int got_match;
+#ifdef ENABLE_CONDITIONALS
+ int last_match;
+ int last_cond; /* used for error checking by parse() */
+#endif
+} *li;
struct magic_set {
struct mlist *mlist;
struct cont {
size_t len;
- struct level_info {
- int32_t off;
- int got_match;
-#ifdef ENABLE_CONDITIONALS
- int last_match;
- int last_cond; /* used for error checking by parse() */
-#endif
- } *li;
+ struct level_info *li;
} c;
struct out {
- /* Accumulation buffer */
- char *buf;
- char *ptr;
- size_t left;
- size_t size;
- /* Printable buffer */
- char *pbuf;
- size_t psize;
+ char *buf; /* Accumulation buffer */
+ char *pbuf; /* Printable buffer */
} o;
uint32_t offset;
int error;
@@ -301,16 +328,23 @@ struct magic_set {
size_t rm_len; /* match length */
} search;
+ /* FIXME: Make the string dynamically allocated so that e.g.
+ strings matched in files can be longer than MAXstring */
union VALUETYPE ms_value; /* either number or string */
};
+/* Type for Unicode characters */
+typedef unsigned long unichar;
+
struct stat;
protected const char *file_fmttime(uint32_t, int);
protected int file_buffer(struct magic_set *, int, const char *, const void *,
size_t);
protected int file_fsmagic(struct magic_set *, const char *, struct stat *);
protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
-protected int file_printf(struct magic_set *, const char *, ...);
+protected int file_vprintf(struct magic_set *, const char *, va_list);
+protected int file_printf(struct magic_set *, const char *, ...)
+ __attribute__((__format__(__printf__, 2, 3)));
protected int file_reset(struct magic_set *);
protected int file_tryelf(struct magic_set *, int, const unsigned char *,
size_t);
@@ -318,7 +352,7 @@ protected int file_zmagic(struct magic_set *, int, const char *,
const unsigned char *, size_t);
protected int file_ascmagic(struct magic_set *, const unsigned char *, size_t);
protected int file_is_tar(struct magic_set *, const unsigned char *, size_t);
-protected int file_softmagic(struct magic_set *, const unsigned char *, size_t);
+protected int file_softmagic(struct magic_set *, const unsigned char *, size_t, int);
protected struct mlist *file_apprentice(struct magic_set *, const char *, int);
protected uint64_t file_signextend(struct magic_set *, struct magic *,
uint64_t);
@@ -326,15 +360,19 @@ protected void file_delmagic(struct magic *, int type, size_t entries);
protected void file_badread(struct magic_set *);
protected void file_badseek(struct magic_set *);
protected void file_oomem(struct magic_set *, size_t);
-protected void file_error(struct magic_set *, int, const char *, ...);
-protected void file_magerror(struct magic_set *, const char *, ...);
-protected void file_magwarn(struct magic_set *, const char *, ...);
+protected void file_error(struct magic_set *, int, const char *, ...)
+ __attribute__((__format__(__printf__, 3, 4)));
+protected void file_magerror(struct magic_set *, const char *, ...)
+ __attribute__((__format__(__printf__, 2, 3)));
+protected void file_magwarn(struct magic_set *, const char *, ...)
+ __attribute__((__format__(__printf__, 2, 3)));
protected void file_mdump(struct magic *);
protected void file_showstr(FILE *, const char *, size_t);
protected size_t file_mbswidth(const char *);
protected const char *file_getbuffer(struct magic_set *);
protected ssize_t sread(int, void *, size_t, int);
protected int file_check_mem(struct magic_set *, unsigned int);
+protected int file_looks_utf8(const unsigned char *, size_t, unichar *, size_t *);
#ifndef COMPILE_ONLY
extern const char *file_names[];
@@ -352,8 +390,11 @@ extern char *sys_errlist[];
#define strtoul(a, b, c) strtol(a, b, c)
#endif
-#ifndef HAVE_SNPRINTF
-int snprintf(char *, size_t, const char *, ...);
+#ifndef HAVE_VASPRINTF
+int vasprintf(char **, const char *, va_list);
+#endif
+#ifndef HAVE_ASPRINTF
+int asprintf(char **ptr, const char *format_string, ...);
#endif
#if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H) && !defined(QUICK)
@@ -364,9 +405,16 @@ int snprintf(char *, size_t, const char *, ...);
#define O_BINARY 0
#endif
+#ifndef __cplusplus
+#ifdef __GNUC__
+static const char *rcsid(const char *) __attribute__((__used__));
+#endif
#define FILE_RCSID(id) \
static const char *rcsid(const char *p) { \
return rcsid(p = id); \
}
+#else
+#define FILE_RCSID(id)
+#endif
#endif /* __file_h__ */
diff --git a/file.man b/file.man
index 05bf9e71d966..197700f69ad2 100644
--- a/file.man
+++ b/file.man
@@ -1,5 +1,5 @@
-.\" $File: file.man,v 1.66 2007/10/23 19:58:59 christos Exp $
-.Dd January 8, 2007
+.\" $File: file.man,v 1.73 2008/02/19 17:58:00 rrt Exp $
+.Dd February 19, 2008
.Dt FILE __CSECTION__
.Os
.Sh NAME
@@ -8,8 +8,8 @@
.Sh SYNOPSIS
.Nm
.Op Fl bchikLnNprsvz
-.Op Fl mime-type
-.Op Fl mime-encoding
+.Op Fl -mime-type
+.Op Fl -mime-encoding
.Op Fl f Ar namefile
.Op Fl F Ar separator
.Op Fl m Ar magicfiles
@@ -17,6 +17,8 @@
.Nm
.Fl C
.Op Fl m Ar magicfile
+.Nm
+.Op Fl -help
.Sh DESCRIPTION
This manual page documents version __VERSION__ of the
.Nm
@@ -25,7 +27,7 @@ command.
.Nm
tests each argument in an attempt to classify it.
There are three sets of tests, performed in this order:
-filesystem tests, magic number tests, and language tests.
+filesystem tests, magic tests, and language tests.
The
.Em first
test that succeeds causes the file type to be printed.
@@ -49,11 +51,9 @@ meaning anything else (data is usually
or non-printable).
Exceptions are well-known file formats (core files, tar archives)
that are known to contain binary data.
-When modifying the file
-.Pa __MAGIC__
-or the program itself, make sure to
+When modifying magic files or the program itself, make sure to
.Em "preserve these keywords" .
-People depend on knowing that all the readable files in a directory
+Users depend on knowing that all the readable files in a directory
have the word
.Dq text
printed.
@@ -61,12 +61,6 @@ Don't do as Berkeley did and change
.Dq shell commands text
to
.Dq shell script .
-Note that the file
-.Pa __MAGIC__
-is built mechanically from a large number of small files in
-the subdirectory
-.Pa Magdir
-in the source distribution of this program.
.Pp
The filesystem tests are based on examining the return from a
.Xr stat 2
@@ -80,7 +74,7 @@ are intuited if they are defined in
the system header file
.In sys/stat.h .
.Pp
-The magic number tests are used to check for files with data in
+The magic tests are used to check for files with data in
particular fixed formats.
The canonical example of this is a binary executable (compiled program)
.Dv a.out
@@ -97,22 +91,20 @@ near the beginning of the file that tells the
.Dv UNIX operating system
that the file is a binary executable, and which of several types thereof.
The concept of a
-.Sq "magic number"
+.Sq "magic"
has been applied by extension to data files.
Any file with some invariant identifier at a small fixed
offset into the file can usually be described in this way.
The information identifying these files is read from the compiled
magic file
.Pa __MAGIC__.mgc ,
-or
+or the files in the directory
.Pa __MAGIC__
-if the compile file does not exist. In addition
-.Nm
-will look in
-.Pa $HOME/.magic.mgc ,
+if the compiled file does not exist. In addition, if
+.Pa $HOME/.magic.mgc
or
.Pa $HOME/.magic
-for magic entries.
+exists, it will be used in preference to the system magic files.
.Pp
If a file does not match any of the entries in the magic file,
it is examined to see if it seems to be a text file.
@@ -145,9 +137,9 @@ Once
has determined the character set used in a text-type file,
it will
attempt to determine in what language the file is written.
-The language tests look for particular strings (cf
+The language tests look for particular strings (cf.
.In names.h
-that can appear anywhere in the first few blocks of a file.
+) that can appear anywhere in the first few blocks of a file.
For example, the keyword
.Em .br
indicates that the file is most likely a
@@ -163,7 +155,8 @@ The language test routines also test for some miscellany
archives).
.Pp
Any file that cannot be identified as having been written
-in any of the character sets listed above is simply said to be ``data''.
+in any of the character sets listed above is simply said to be
+.Dq data .
.Sh OPTIONS
.Bl -tag -width indent
.It Fl b , -brief
@@ -176,7 +169,7 @@ flag to debug a new magic file before installing it.
.It Fl C , -compile
Write a
.Pa magic.mgc
-output file that contains a pre-parsed version of the magic file.
+output file that contains a pre-parsed version of the magic file or directory.
.It Fl e , -exclude Ar testname
Exclude the test named in
.Ar testname
@@ -239,12 +232,18 @@ file.
(See
.Dq FILES
section, below).
-.It Fl -mime-type , -mime-encoding
+.It Fl -mime-type , -mime-encoding
Like
.Fl i ,
but print only the specified element(s).
.It Fl k , -keep-going
-Don't stop at the first match, keep going.
+Don't stop at the first match, keep going. Subsequent matches will be
+have the string
+.Dq "\[rs]012\- "
+prepended.
+(If you want a newline, see the
+.Dq "\-r"
+option.)
.It Fl L , -dereference
option causes symlinks to be followed, as the like-named option in
.Xr ls 1
@@ -253,16 +252,9 @@ This is the default if the environment variable
.Dv POSIXLY_CORRECT
is defined.
.It Fl m , -magic-file Ar list
-Specify an alternate list of files containing magic numbers.
-This can be a single file, or a colon-separated list of files.
-If a compiled magic file is found alongside, it will be used instead.
-With the
-.Fl i
-or
-.Fl "mime"
-option, the program adds
-.Dq .mime
-to each file name.
+Specify an alternate list of files and directories containing magic.
+This can be a single item, or a colon-separated list.
+If a compiled magic file is found alongside a file or directory, it will be used instead.
.It Fl n , -no-buffer
Force stdout to be flushed after checking each file.
This is only useful if checking a list of files.
@@ -316,38 +308,27 @@ the output. This does not affect the separator which is still printed.
Print a help message and exit.
.El
.Sh FILES
-.Bl -tag -width __MAGIC__.mime.mgc -compact
+.Bl -tag -width __MAGIC__.mgc -compact
.It Pa __MAGIC__.mgc
-Default compiled list of magic numbers
+Default compiled list of magic.
.It Pa __MAGIC__
-Default list of magic numbers
-.It Pa __MAGIC__.mime.mgc
-Default compiled list of magic numbers, used to output mime types when
-the
-.Fl i
-option is specified.
-.It Pa __MAGIC__.mime
-Default list of magic numbers, used to output mime types when the
-.Fl i
-option is specified.
+Directory containing default magic files.
.El
.Sh ENVIRONMENT
The environment variable
.Dv MAGIC
-can be used to set the default magic number file name.
+can be used to set the default magic file name.
If that variable is set, then
.Nm
will not attempt to open
.Pa $HOME/.magic .
.Nm
adds
-.Dq .mime
-and/or
.Dq .mgc
to the value of this variable as appropriate.
The environment variable
.Dv POSIXLY_CORRECT
-controls (on systems that support symbolic links), if
+controls (on systems that support symbolic links), whether
.Nm
will attempt to follow symlinks or not. If set, then
.Nm
@@ -361,7 +342,8 @@ options.
.Xr magic __FSECTION__ ,
.Xr strings 1 ,
.Xr od 1 ,
-.Xr hexdump 1
+.Xr hexdump 1,
+.Xr file 1posix
.Sh STANDARDS CONFORMANCE
This program is believed to exceed the System V Interface Definition
of FILE(CMD), as near as one can determine from the vague language
@@ -465,7 +447,7 @@ command in every
.Dv UNIX 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.
+the external list of magic types.
This slowed the program down slightly but made it a lot more flexible.
.Pp
This program, based on the System V version,
@@ -486,17 +468,23 @@ Christos Zoulas (christos@astron.com).
Altered by Chris Lowth, chris@lowth.com, 2000:
Handle the
.Fl i
-option to output mime type strings and using an alternative
+option to output mime type strings, using an alternative
magic file and internal logic.
.Pp
Altered by Eric Fischer (enf@pobox.com), July, 2000,
to identify character codes and attempt to identify the languages
of non-ASCII files.
.Pp
-The list of contributors to the "Magdir" directory (source for the
-.Pa __MAGIC__
-file) is too long to include here.
+Altered by Reuben Thomas (rrt@sc3d.org), 2007 to 2008, to improve MIME
+support and merge MIME and non-MIME magic, support directories as well
+as files of magic, apply many bug fixes and improve the build system.
+.Pp
+The list of contributors to the
+.Dq magic
+directory (magic files)
+is too long to include here.
You know who you are; thank you.
+Many contributors are listed in the source files.
.Sh LEGAL NOTICE
Copyright (c) Ian F. Darwin, Toronto, Canada, 1986-1999.
Covered by the standard Berkeley Software Distribution copyright; see the file
@@ -510,17 +498,10 @@ were written by John Gilmore from his public-domain
.Xr tar 1
program, and are not covered by the above license.
.Sh BUGS
+.Pp
There must be a better way to automate the construction of the Magic
file from all the glop in Magdir.
What is it?
-.\" Compilation support has been done
-.\" Better yet, the magic file should be compiled into binary (say,
-.\" .Xr ndbm 3
-.\" or, better yet, fixed-length
-.\" .Dv ASCII
-.\" strings for use in heterogenous network environments) for faster startup.
-.\" Then the program would run as fast as the Version 7 program of the same
-.\" name, with the flexibility of the System V version.
.Pp
.Nm
uses several algorithms that favor speed over accuracy,
@@ -530,31 +511,6 @@ files.
.Pp
The support for text files (primarily for programming languages)
is simplistic, inefficient and requires recompilation to update.
-.\" Else support has been done
-.\" There should be an
-.\" .Dv else
-.\" clause to follow a series of continuation lines.
-.\" .Pp
-.\" Regular expression support has been done
-.\" The magic file and keywords should have regular expression support.
-Their use of
-.Dv ASCII TAB
-as a field delimiter is ugly and makes
-it hard to edit the files, but is entrenched.
-.Pp
-It might be advisable to allow upper-case letters in keywords
-for e.g.,
-.Xr troff 1
-commands vs man page macros.
-Regular expression support would make this easy.
-.Pp
-The program doesn't grok
-.Dv FORTRAN .
-It should be able to figure
-.Dv FORTRAN
-by seeing some keywords which
-appear indented at the start of line.
-Regular expression support would make this easy.
.Pp
The list of keywords in
.Dv ascmagic
@@ -563,11 +519,6 @@ This could be done by using some keyword like
.Sq *
for the offset value.
.Pp
-.\" Sorting has been done.
-.\" Another optimization would be to sort
-.\" the magic file so that we can just run down all the
-.\" tests for the first byte, first word, first long, etc, once we
-.\" have fetched it.
Complain about conflicts in the magic file entries.
Make a rule that the magic entries sort based on file offset rather
than position within the magic file?
@@ -587,10 +538,10 @@ versus
Still, if the others don't pan out, it should be possible to use the
first guess.
.Pp
-This program is slower than some vendors' file commands.
-The new support for multiple character codes makes it even slower.
-.Pp
This manual page, and particularly this section, is too long.
+.Sh RETURN CODE
+.Nm
+returns 0 on success, and non-zero on error.
.Sh AVAILABILITY
You can obtain the original author's latest version by anonymous FTP
on
diff --git a/fsmagic.c b/fsmagic.c
index e04f5981876f..f3b23725aafe 100644
--- a/fsmagic.c
+++ b/fsmagic.c
@@ -57,9 +57,33 @@
#undef HAVE_MAJOR
#ifndef lint
-FILE_RCSID("@(#)$File: fsmagic.c,v 1.48 2007/10/17 19:33:31 christos Exp $")
+FILE_RCSID("@(#)$File: fsmagic.c,v 1.52 2008/07/25 23:59:01 rrt Exp $")
#endif /* lint */
+private int
+bad_link(struct magic_set *ms, int err, char *buf)
+{
+ const char *errfmt;
+ int mime = ms->flags & MAGIC_MIME;
+ if ((mime & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "application/x-symlink")
+ == -1)
+ return -1;
+ else if (!mime) {
+ if (err == ELOOP)
+ errfmt = "symbolic link in a loop";
+ else
+ errfmt = "broken symbolic link to `%s'";
+ if (ms->flags & MAGIC_ERROR) {
+ file_error(ms, err, errfmt, buf);
+ return -1;
+ }
+ if (file_printf(ms, errfmt, buf) == -1)
+ return -1;
+ }
+ return 1;
+}
+
protected int
file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
{
@@ -96,16 +120,7 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
return 1;
}
- if (mime) {
- if ((sb->st_mode & S_IFMT) != S_IFREG) {
- if ((mime & MAGIC_MIME_TYPE) &&
- file_printf(ms, "application/x-not-regular-file")
- == -1)
- return -1;
- return 1;
- }
- }
- else {
+ if (!mime) {
#ifdef S_ISUID
if (sb->st_mode & S_ISUID)
if (file_printf(ms, "setuid ") == -1)
@@ -125,7 +140,11 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
switch (sb->st_mode & S_IFMT) {
case S_IFDIR:
- if (file_printf(ms, "directory") == -1)
+ if ((mime & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "application/x-directory")
+ == -1)
+ return -1;
+ if (!mime && file_printf(ms, "directory") == -1)
return -1;
return 1;
#ifdef S_IFCHR
@@ -137,21 +156,27 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
*/
if ((ms->flags & MAGIC_DEVICES) != 0)
break;
-#ifdef HAVE_ST_RDEV
-# ifdef dv_unit
- if (file_printf(ms, "character special (%d/%d/%d)",
- major(sb->st_rdev), dv_unit(sb->st_rdev),
- dv_subunit(sb->st_rdev)) == -1)
+ if ((mime & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "application/x-character-device")
+ == -1)
return -1;
+ if (!mime) {
+#ifdef HAVE_STAT_ST_RDEV
+# ifdef dv_unit
+ if (file_printf(ms, "character special (%d/%d/%d)",
+ major(sb->st_rdev), dv_unit(sb->st_rdev),
+ dv_subunit(sb->st_rdev)) == -1)
+ return -1;
# else
- if (file_printf(ms, "character special (%ld/%ld)",
- (long) major(sb->st_rdev), (long) minor(sb->st_rdev)) == -1)
- return -1;
+ if (file_printf(ms, "character special (%ld/%ld)",
+ (long) major(sb->st_rdev), (long) minor(sb->st_rdev)) == -1)
+ return -1;
# endif
#else
- if (file_printf(ms, "character special") == -1)
- return -1;
+ if (file_printf(ms, "character special") == -1)
+ return -1;
#endif
+ }
return 1;
#endif
#ifdef S_IFBLK
@@ -163,21 +188,27 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
*/
if ((ms->flags & MAGIC_DEVICES) != 0)
break;
-#ifdef HAVE_ST_RDEV
-# ifdef dv_unit
- if (file_printf(ms, "block special (%d/%d/%d)",
- major(sb->st_rdev), dv_unit(sb->st_rdev),
- dv_subunit(sb->st_rdev)) == -1)
+ if ((mime & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "application/x-block-device")
+ == -1)
return -1;
+ if (!mime) {
+#ifdef HAVE_STAT_ST_RDEV
+# ifdef dv_unit
+ if (file_printf(ms, "block special (%d/%d/%d)",
+ major(sb->st_rdev), dv_unit(sb->st_rdev),
+ dv_subunit(sb->st_rdev)) == -1)
+ return -1;
# else
- if (file_printf(ms, "block special (%ld/%ld)",
- (long)major(sb->st_rdev), (long)minor(sb->st_rdev)) == -1)
- return -1;
+ if (file_printf(ms, "block special (%ld/%ld)",
+ (long)major(sb->st_rdev), (long)minor(sb->st_rdev)) == -1)
+ return -1;
# endif
#else
- if (file_printf(ms, "block special") == -1)
- return -1;
+ if (file_printf(ms, "block special") == -1)
+ return -1;
#endif
+ }
return 1;
#endif
/* TODO add code to handle V7 MUX and Blit MUX files */
@@ -185,13 +216,21 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
case S_IFIFO:
if((ms->flags & MAGIC_DEVICES) != 0)
break;
- if (file_printf(ms, "fifo (named pipe)") == -1)
+ if ((mime & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "application/x-fifo")
+ == -1)
+ return -1;
+ if (!mime && file_printf(ms, "fifo (named pipe)") == -1)
return -1;
return 1;
#endif
#ifdef S_IFDOOR
case S_IFDOOR:
- if (file_printf(ms, "door") == -1)
+ if ((mime & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "application/x-door")
+ == -1)
+ return -1;
+ if (!mime && file_printf(ms, "door") == -1)
return -1;
return 1;
#endif
@@ -203,29 +242,23 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
fn);
return -1;
}
- if (file_printf(ms,
+ if ((mime & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "application/x-symlink")
+ == -1)
+ return -1;
+ if (!mime && file_printf(ms,
"unreadable symlink `%s' (%s)", fn,
strerror(errno)) == -1)
return -1;
return 1;
}
- buf[nch] = '\0'; /* readlink(2) forgets this */
+ buf[nch] = '\0'; /* readlink(2) does not do this */
/* If broken symlink, say so and quit early. */
if (*buf == '/') {
- if (stat(buf, &tstatbuf) < 0) {
- if (ms->flags & MAGIC_ERROR) {
- file_error(ms, errno,
- "broken symbolic link to `%s'", buf);
- return -1;
- }
- if (file_printf(ms, "broken symbolic link to `%s'",
- buf) == -1)
- return -1;
- return 1;
- }
- }
- else {
+ if (stat(buf, &tstatbuf) < 0)
+ return bad_link(ms, errno, buf);
+ } else {
char *tmp;
char buf2[BUFSIZ+BUFSIZ+4];
@@ -238,7 +271,11 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
"path too long: `%s'", buf);
return -1;
}
- if (file_printf(ms,
+ if ((mime & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "application/x-path-too-long")
+ == -1)
+ return -1;
+ if (!mime && file_printf(ms,
"path too long: `%s'", fn) == -1)
return -1;
return 1;
@@ -248,18 +285,8 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
(void)strcat(buf2, buf); /* plus (rel) link */
tmp = buf2;
}
- if (stat(tmp, &tstatbuf) < 0) {
- if (ms->flags & MAGIC_ERROR) {
- file_error(ms, errno,
- "broken symbolic link to `%s'",
- buf);
- return -1;
- }
- if (file_printf(ms,
- "broken symbolic link to `%s'", buf) == -1)
- return -1;
- return 1;
- }
+ if (stat(tmp, &tstatbuf) < 0)
+ return bad_link(ms, errno, buf);
}
/* Otherwise, handle it. */
@@ -270,16 +297,24 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
ms->flags |= MAGIC_SYMLINK;
return p != NULL ? 1 : -1;
} else { /* just print what it points to */
- if (file_printf(ms, "symbolic link to `%s'",
+ if ((mime & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "application/x-symlink")
+ == -1)
+ return -1;
+ if (!mime && file_printf(ms, "symbolic link to `%s'",
buf) == -1)
return -1;
}
- return 1;
+ return 1;
#endif
#ifdef S_IFSOCK
#ifndef __COHERENT__
case S_IFSOCK:
- if (file_printf(ms, "socket") == -1)
+ if ((mime & MAGIC_MIME_TYPE) &&
+ file_printf(ms, "application/x-socket")
+ == -1)
+ return -1;
+ if (!mime && file_printf(ms, "socket") == -1)
return -1;
return 1;
#endif
diff --git a/funcs.c b/funcs.c
index 5cf11812fb75..af9860517044 100644
--- a/funcs.c
+++ b/funcs.c
@@ -39,67 +39,55 @@
#if defined(HAVE_LIMITS_H)
#include <limits.h>
#endif
-#ifndef SIZE_T_MAX
-#ifdef __LP64__
-#define SIZE_T_MAX (size_t)0xffffffffffffffffU
-#else
-#define SIZE_T_MAX (size_t)0xffffffffU
-#endif
-#endif
#ifndef lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.35 2007/12/27 16:35:59 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.44 2008/07/16 18:00:57 christos Exp $")
#endif /* lint */
-#ifndef HAVE_VSNPRINTF
-int vsnprintf(char *, size_t, const char *, va_list);
+#ifndef SIZE_MAX
+#define SIZE_MAX ((size_t)~0)
#endif
/*
- * Like printf, only we print to a buffer and advance it.
+ * Like printf, only we append to a buffer.
*/
protected int
-file_printf(struct magic_set *ms, const char *fmt, ...)
+file_vprintf(struct magic_set *ms, const char *fmt, va_list ap)
{
- va_list ap;
- size_t size;
- ssize_t len;
- char *buf;
-
- va_start(ap, fmt);
+ int len;
+ char *buf, *newstr;
- len = vsnprintf(ms->o.ptr, ms->o.left, fmt, ap);
- if (len == -1)
+ len = vasprintf(&buf, fmt, ap);
+ if (len < 0)
goto out;
- if (len >= (ssize_t)ms->o.left) {
- long diff; /* XXX: really ptrdiff_t */
- va_end(ap);
- size = (ms->o.size - ms->o.left) + len + 1024;
- if ((buf = realloc(ms->o.buf, size)) == NULL) {
- file_oomem(ms, size);
- return -1;
- }
- diff = ms->o.ptr - ms->o.buf;
- ms->o.ptr = buf + diff;
- ms->o.buf = buf;
- ms->o.left = size - diff;
- ms->o.size = size;
-
- va_start(ap, fmt);
- len = vsnprintf(ms->o.ptr, ms->o.left, fmt, ap);
- if (len == -1)
+ if (ms->o.buf != NULL) {
+ len = asprintf(&newstr, "%s%s", ms->o.buf, buf);
+ free(buf);
+ if (len < 0)
goto out;
+ free(ms->o.buf);
+ buf = newstr;
}
- va_end(ap);
- ms->o.ptr += len;
- ms->o.left -= len;
+ ms->o.buf = buf;
return 0;
out:
- file_error(ms, errno, "vsnprintf failed");
+ file_error(ms, errno, "vasprintf failed");
return -1;
}
+protected int
+file_printf(struct magic_set *ms, const char *fmt, ...)
+{
+ int rv;
+ va_list ap;
+
+ va_start(ap, fmt);
+ rv = file_vprintf(ms, fmt, ap);
+ va_end(ap);
+ return rv;
+}
+
/*
* error - print best error message possible
*/
@@ -108,21 +96,17 @@ private void
file_error_core(struct magic_set *ms, int error, const char *f, va_list va,
uint32_t lineno)
{
- size_t len;
/* Only the first error is ok */
if (ms->haderr)
return;
- len = 0;
if (lineno != 0) {
- (void)snprintf(ms->o.buf, ms->o.size, "line %u: ", lineno);
- len = strlen(ms->o.buf);
- }
- (void)vsnprintf(ms->o.buf + len, ms->o.size - len, f, va);
- if (error > 0) {
- len = strlen(ms->o.buf);
- (void)snprintf(ms->o.buf + len, ms->o.size - len, " (%s)",
- strerror(error));
+ free(ms->o.buf);
+ ms->o.buf = NULL;
+ file_printf(ms, "line %u: ", lineno);
}
+ file_vprintf(ms, f, va);
+ if (error > 0)
+ file_printf(ms, " (%s)", strerror(error));
ms->haderr++;
ms->error = error;
}
@@ -175,6 +159,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
{
int m;
int mime = ms->flags & MAGIC_MIME;
+ const unsigned char *ubuf = CAST(const unsigned char *, buf);
if (nb == 0) {
if ((!mime || (mime & MAGIC_MIME_TYPE)) &&
@@ -184,7 +169,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
return 1;
} else if (nb == 1) {
if ((!mime || (mime & MAGIC_MIME_TYPE)) &&
- file_printf(ms, mime ? "application/octet-stream" :
+ file_printf(ms, mime ? "application/octet-stream" :
"very short file (no magic)") == -1)
return -1;
return 1;
@@ -205,19 +190,19 @@ file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
/* try compression stuff */
if ((ms->flags & MAGIC_NO_CHECK_COMPRESS) != 0 ||
- (m = file_zmagic(ms, fd, inname, buf, nb)) == 0) {
+ (m = file_zmagic(ms, fd, inname, ubuf, nb)) == 0) {
/* Check if we have a tar file */
if ((ms->flags & MAGIC_NO_CHECK_TAR) != 0 ||
- (m = file_is_tar(ms, buf, nb)) == 0) {
+ (m = file_is_tar(ms, ubuf, nb)) == 0) {
/* try tests in /etc/magic (or surrogate magic file) */
if ((ms->flags & MAGIC_NO_CHECK_SOFT) != 0 ||
- (m = file_softmagic(ms, buf, nb)) == 0) {
+ (m = file_softmagic(ms, ubuf, nb, BINTEST)) == 0) {
/* try known keywords, check whether it is ASCII */
if ((ms->flags & MAGIC_NO_CHECK_ASCII) != 0 ||
- (m = file_ascmagic(ms, buf, nb)) == 0) {
+ (m = file_ascmagic(ms, ubuf, nb)) == 0) {
/* abandon hope, all ye who remain here */
if ((!mime || (mime & MAGIC_MIME_TYPE)) &&
- file_printf(ms, mime ? "application/octet-stream" :
+ file_printf(ms, mime ? "application/octet-stream" :
"data") == -1)
return -1;
m = 1;
@@ -236,7 +221,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
* information from the ELF headers that cannot easily
* be extracted with rules in the magic file.
*/
- (void)file_tryelf(ms, fd, buf, nb);
+ (void)file_tryelf(ms, fd, ubuf, nb);
}
#endif
return m;
@@ -250,8 +235,7 @@ file_reset(struct magic_set *ms)
file_error(ms, 0, "no magic files loaded");
return -1;
}
- ms->o.ptr = ms->o.buf;
- ms->o.left = ms->o.size;
+ ms->o.buf = NULL;
ms->haderr = 0;
ms->error = -1;
return 0;
@@ -277,21 +261,18 @@ file_getbuffer(struct magic_set *ms)
if (ms->flags & MAGIC_RAW)
return ms->o.buf;
- len = ms->o.size - ms->o.left;
/* * 4 is for octal representation, + 1 is for NUL */
- if (len > (SIZE_T_MAX - 1) / 4) {
+ len = strlen(ms->o.buf);
+ if (len > (SIZE_MAX - 1) / 4) {
file_oomem(ms, len);
return NULL;
}
psize = len * 4 + 1;
- if (ms->o.psize < psize) {
- if ((pbuf = realloc(ms->o.pbuf, psize)) == NULL) {
- file_oomem(ms, psize);
- return NULL;
- }
- ms->o.psize = psize;
- ms->o.pbuf = pbuf;
+ if ((pbuf = CAST(char *, realloc(ms->o.pbuf, psize))) == NULL) {
+ file_oomem(ms, psize);
+ return NULL;
}
+ ms->o.pbuf = pbuf;
#if defined(HAVE_WCHAR_H) && defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)
{
@@ -304,7 +285,7 @@ file_getbuffer(struct magic_set *ms)
np = ms->o.pbuf;
op = ms->o.buf;
- eop = op + strlen(ms->o.buf);
+ eop = op + len;
while (op < eop) {
bytesconsumed = mbrtowc(&nextchar, op,
@@ -350,8 +331,9 @@ file_check_mem(struct magic_set *ms, unsigned int level)
if (level >= ms->c.len) {
len = (ms->c.len += 20) * sizeof(*ms->c.li);
- ms->c.li = (ms->c.li == NULL) ? malloc(len) :
- realloc(ms->c.li, len);
+ ms->c.li = CAST(struct level_info *, (ms->c.li == NULL) ?
+ malloc(len) :
+ realloc(ms->c.li, len));
if (ms->c.li == NULL) {
file_oomem(ms, len);
return -1;
@@ -364,28 +346,3 @@ file_check_mem(struct magic_set *ms, unsigned int level)
#endif /* ENABLE_CONDITIONALS */
return 0;
}
-/*
- * Yes these wrappers suffer from buffer overflows, but if your OS does not
- * have the real functions, maybe you should consider replacing your OS?
- */
-#ifndef HAVE_VSNPRINTF
-int
-vsnprintf(char *buf, size_t len, const char *fmt, va_list ap)
-{
- return vsprintf(buf, fmt, ap);
-}
-#endif
-
-#ifndef HAVE_SNPRINTF
-/*ARGSUSED*/
-int
-snprintf(char *buf, size_t len, const char *fmt, ...)
-{
- int rv;
- va_list ap;
- va_start(ap, fmt);
- rv = vsprintf(buf, fmt, ap);
- va_end(ap);
- return rv;
-}
-#endif
diff --git a/getopt_long.c b/getopt_long.c
new file mode 100644
index 000000000000..5b9c20b49928
--- /dev/null
+++ b/getopt_long.c
@@ -0,0 +1,496 @@
+/* $NetBSD: getopt_long.c,v 1.21.4.1 2008/01/09 01:34:14 matt Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <assert.h>
+#ifdef HAVE_ERR_H
+#include <err.h>
+#else
+#include <stdio.h>
+#define warnx printf
+#endif
+#include <errno.h>
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include "mygetopt.h"
+#endif
+#include <stdlib.h>
+#include <string.h>
+
+#define REPLACE_GETOPT
+
+#ifndef _DIAGASSERT
+#define _DIAGASSERT assert
+#endif
+
+#ifdef REPLACE_GETOPT
+#ifdef __weak_alias
+__weak_alias(getopt,_getopt)
+#endif
+int opterr = 1; /* if error message should be printed */
+int optind = 1; /* index into parent argv vector */
+int optopt = '?'; /* character checked for validity */
+int optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
+#elif HAVE_NBTOOL_CONFIG_H && !HAVE_DECL_OPTRESET
+static int optreset;
+#endif
+
+#ifdef __weak_alias
+__weak_alias(getopt_long,_getopt_long)
+#endif
+
+#define IGNORE_FIRST (*options == '-' || *options == '+')
+#define PRINT_ERROR ((opterr) && ((*options != ':') \
+ || (IGNORE_FIRST && options[1] != ':')))
+#define IS_POSIXLY_CORRECT (getenv("POSIXLY_CORRECT") != NULL)
+#define PERMUTE (!IS_POSIXLY_CORRECT && !IGNORE_FIRST)
+/* XXX: GNU ignores PC if *options == '-' */
+#define IN_ORDER (!IS_POSIXLY_CORRECT && *options == '-')
+
+/* return values */
+#define BADCH (int)'?'
+#define BADARG ((IGNORE_FIRST && options[1] == ':') \
+ || (*options == ':') ? (int)':' : (int)'?')
+#define INORDER (int)1
+
+#define EMSG ""
+
+static int getopt_internal(int, char **, const char *);
+static int gcd(int, int);
+static void permute_args(int, int, int, char **);
+
+static const char *place = EMSG; /* option letter processing */
+
+/* XXX: set optreset to 1 rather than these two */
+static int nonopt_start = -1; /* first non option argument (for permute) */
+static int nonopt_end = -1; /* first option after non options (for permute) */
+
+/* Error messages */
+static const char recargchar[] = "option requires an argument -- %c";
+static const char recargstring[] = "option requires an argument -- %s";
+static const char ambig[] = "ambiguous option -- %.*s";
+static const char noarg[] = "option doesn't take an argument -- %.*s";
+static const char illoptchar[] = "unknown option -- %c";
+static const char illoptstring[] = "unknown option -- %s";
+
+
+/*
+ * Compute the greatest common divisor of a and b.
+ */
+static int
+gcd(a, b)
+ int a;
+ int b;
+{
+ int c;
+
+ c = a % b;
+ while (c != 0) {
+ a = b;
+ b = c;
+ c = a % b;
+ }
+
+ return b;
+}
+
+/*
+ * Exchange the block from nonopt_start to nonopt_end with the block
+ * from nonopt_end to opt_end (keeping the same order of arguments
+ * in each block).
+ */
+static void
+permute_args(panonopt_start, panonopt_end, opt_end, nargv)
+ int panonopt_start;
+ int panonopt_end;
+ int opt_end;
+ char **nargv;
+{
+ int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
+ char *swap;
+
+ _DIAGASSERT(nargv != NULL);
+
+ /*
+ * compute lengths of blocks and number and size of cycles
+ */
+ nnonopts = panonopt_end - panonopt_start;
+ nopts = opt_end - panonopt_end;
+ ncycle = gcd(nnonopts, nopts);
+ cyclelen = (opt_end - panonopt_start) / ncycle;
+
+ for (i = 0; i < ncycle; i++) {
+ cstart = panonopt_end+i;
+ pos = cstart;
+ for (j = 0; j < cyclelen; j++) {
+ if (pos >= panonopt_end)
+ pos -= nnonopts;
+ else
+ pos += nopts;
+ swap = nargv[pos];
+ nargv[pos] = nargv[cstart];
+ nargv[cstart] = swap;
+ }
+ }
+}
+
+/*
+ * getopt_internal --
+ * Parse argc/argv argument vector. Called by user level routines.
+ * Returns -2 if -- is found (can be long option or end of options marker).
+ */
+static int
+getopt_internal(nargc, nargv, options)
+ int nargc;
+ char **nargv;
+ const char *options;
+{
+ char *oli; /* option letter list index */
+ int optchar;
+
+ _DIAGASSERT(nargv != NULL);
+ _DIAGASSERT(options != NULL);
+
+ optarg = NULL;
+
+ /*
+ * XXX Some programs (like rsyncd) expect to be able to
+ * XXX re-initialize optind to 0 and have getopt_long(3)
+ * XXX properly function again. Work around this braindamage.
+ */
+ if (optind == 0)
+ optind = 1;
+
+ if (optreset)
+ nonopt_start = nonopt_end = -1;
+start:
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ if (optind >= nargc) { /* end of argument vector */
+ place = EMSG;
+ if (nonopt_end != -1) {
+ /* do permutation, if we have to */
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ else if (nonopt_start != -1) {
+ /*
+ * If we skipped non-options, set optind
+ * to the first of them.
+ */
+ optind = nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ return -1;
+ }
+ if ((*(place = nargv[optind]) != '-')
+ || (place[1] == '\0')) { /* found non-option */
+ place = EMSG;
+ if (IN_ORDER) {
+ /*
+ * GNU extension:
+ * return non-option as argument to option 1
+ */
+ optarg = nargv[optind++];
+ return INORDER;
+ }
+ if (!PERMUTE) {
+ /*
+ * if no permutation wanted, stop parsing
+ * at first non-option
+ */
+ return -1;
+ }
+ /* do permutation */
+ if (nonopt_start == -1)
+ nonopt_start = optind;
+ else if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end,
+ optind, nargv);
+ nonopt_start = optind -
+ (nonopt_end - nonopt_start);
+ nonopt_end = -1;
+ }
+ optind++;
+ /* process next argument */
+ goto start;
+ }
+ if (nonopt_start != -1 && nonopt_end == -1)
+ nonopt_end = optind;
+ if (place[1] && *++place == '-') { /* found "--" */
+ place++;
+ return -2;
+ }
+ }
+ if ((optchar = (int)*place++) == (int)':' ||
+ (oli = strchr(options + (IGNORE_FIRST ? 1 : 0), optchar)) == NULL) {
+ /* option letter unknown or ':' */
+ if (!*place)
+ ++optind;
+ if (PRINT_ERROR)
+ warnx(illoptchar, optchar);
+ optopt = optchar;
+ return BADCH;
+ }
+ if (optchar == 'W' && oli[1] == ';') { /* -W long-option */
+ /* XXX: what if no long options provided (called by getopt)? */
+ if (*place)
+ return -2;
+
+ if (++optind >= nargc) { /* no arg */
+ place = EMSG;
+ if (PRINT_ERROR)
+ warnx(recargchar, optchar);
+ optopt = optchar;
+ return BADARG;
+ } else /* white space */
+ place = nargv[optind];
+ /*
+ * Handle -W arg the same as --arg (which causes getopt to
+ * stop parsing).
+ */
+ return -2;
+ }
+ if (*++oli != ':') { /* doesn't take argument */
+ if (!*place)
+ ++optind;
+ } else { /* takes (optional) argument */
+ optarg = NULL;
+ if (*place) /* no white space */
+ optarg = (char *)place;
+ /* XXX: disable test for :: if PC? (GNU doesn't) */
+ else if (oli[1] != ':') { /* arg not optional */
+ if (++optind >= nargc) { /* no arg */
+ place = EMSG;
+ if (PRINT_ERROR)
+ warnx(recargchar, optchar);
+ optopt = optchar;
+ return BADARG;
+ } else
+ optarg = nargv[optind];
+ }
+ place = EMSG;
+ ++optind;
+ }
+ /* dump back option letter */
+ return optchar;
+}
+
+#ifdef REPLACE_GETOPT
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ *
+ * [eventually this will replace the real getopt]
+ */
+int
+getopt(nargc, nargv, options)
+ int nargc;
+ char * const *nargv;
+ const char *options;
+{
+ int retval;
+
+ _DIAGASSERT(nargv != NULL);
+ _DIAGASSERT(options != NULL);
+
+ retval = getopt_internal(nargc, (char **)nargv, options);
+ if (retval == -2) {
+ ++optind;
+ /*
+ * We found an option (--), so if we skipped non-options,
+ * we have to permute.
+ */
+ if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end, optind,
+ (char **)nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ retval = -1;
+ }
+ return retval;
+}
+#endif
+
+/*
+ * getopt_long --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt_long(nargc, nargv, options, long_options, idx)
+ int nargc;
+ char * const *nargv;
+ const char *options;
+ const struct option *long_options;
+ int *idx;
+{
+ int retval;
+
+#define IDENTICAL_INTERPRETATION(_x, _y) \
+ (long_options[(_x)].has_arg == long_options[(_y)].has_arg && \
+ long_options[(_x)].flag == long_options[(_y)].flag && \
+ long_options[(_x)].val == long_options[(_y)].val)
+
+ _DIAGASSERT(nargv != NULL);
+ _DIAGASSERT(options != NULL);
+ _DIAGASSERT(long_options != NULL);
+ /* idx may be NULL */
+
+ retval = getopt_internal(nargc, (char **)nargv, options);
+ if (retval == -2) {
+ char *current_argv, *has_equal;
+ size_t current_argv_len;
+ int i, ambiguous, match;
+
+ current_argv = (char *)place;
+ match = -1;
+ ambiguous = 0;
+
+ optind++;
+ place = EMSG;
+
+ if (*current_argv == '\0') { /* found "--" */
+ /*
+ * We found an option (--), so if we skipped
+ * non-options, we have to permute.
+ */
+ if (nonopt_end != -1) {
+ permute_args(nonopt_start, nonopt_end,
+ optind, (char **)nargv);
+ optind -= nonopt_end - nonopt_start;
+ }
+ nonopt_start = nonopt_end = -1;
+ return -1;
+ }
+ if ((has_equal = strchr(current_argv, '=')) != NULL) {
+ /* argument found (--option=arg) */
+ current_argv_len = has_equal - current_argv;
+ has_equal++;
+ } else
+ current_argv_len = strlen(current_argv);
+
+ for (i = 0; long_options[i].name; i++) {
+ /* find matching long option */
+ if (strncmp(current_argv, long_options[i].name,
+ current_argv_len))
+ continue;
+
+ if (strlen(long_options[i].name) ==
+ (unsigned)current_argv_len) {
+ /* exact match */
+ match = i;
+ ambiguous = 0;
+ break;
+ }
+ if (match == -1) /* partial match */
+ match = i;
+ else if (!IDENTICAL_INTERPRETATION(i, match))
+ ambiguous = 1;
+ }
+ if (ambiguous) {
+ /* ambiguous abbreviation */
+ if (PRINT_ERROR)
+ warnx(ambig, (int)current_argv_len,
+ current_argv);
+ optopt = 0;
+ return BADCH;
+ }
+ if (match != -1) { /* option found */
+ if (long_options[match].has_arg == no_argument
+ && has_equal) {
+ if (PRINT_ERROR)
+ warnx(noarg, (int)current_argv_len,
+ current_argv);
+ /*
+ * XXX: GNU sets optopt to val regardless of
+ * flag
+ */
+ if (long_options[match].flag == NULL)
+ optopt = long_options[match].val;
+ else
+ optopt = 0;
+ return BADARG;
+ }
+ if (long_options[match].has_arg == required_argument ||
+ long_options[match].has_arg == optional_argument) {
+ if (has_equal)
+ optarg = has_equal;
+ else if (long_options[match].has_arg ==
+ required_argument) {
+ /*
+ * optional argument doesn't use
+ * next nargv
+ */
+ optarg = nargv[optind++];
+ }
+ }
+ if ((long_options[match].has_arg == required_argument)
+ && (optarg == NULL)) {
+ /*
+ * Missing argument; leading ':'
+ * indicates no error should be generated
+ */
+ if (PRINT_ERROR)
+ warnx(recargstring, current_argv);
+ /*
+ * XXX: GNU sets optopt to val regardless
+ * of flag
+ */
+ if (long_options[match].flag == NULL)
+ optopt = long_options[match].val;
+ else
+ optopt = 0;
+ --optind;
+ return BADARG;
+ }
+ } else { /* unknown option */
+ if (PRINT_ERROR)
+ warnx(illoptstring, current_argv);
+ optopt = 0;
+ return BADCH;
+ }
+ if (long_options[match].flag) {
+ *long_options[match].flag = long_options[match].val;
+ retval = 0;
+ } else
+ retval = long_options[match].val;
+ if (idx)
+ *idx = match;
+ }
+ return retval;
+#undef IDENTICAL_INTERPRETATION
+}
diff --git a/is_tar.c b/is_tar.c
index 142b4870f988..a9311117ed24 100644
--- a/is_tar.c
+++ b/is_tar.c
@@ -45,7 +45,7 @@
#include "tar.h"
#ifndef lint
-FILE_RCSID("@(#)$File: is_tar.c,v 1.29 2007/10/17 19:33:31 christos Exp $")
+FILE_RCSID("@(#)$File: is_tar.c,v 1.31 2008/02/04 20:51:17 christos Exp $")
#endif
#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
@@ -53,7 +53,7 @@ FILE_RCSID("@(#)$File: is_tar.c,v 1.29 2007/10/17 19:33:31 christos Exp $")
private int is_tar(const unsigned char *, size_t);
private int from_oct(int, const char *); /* Decode octal number */
-static const char *tartype[] = {
+static const char tartype[][32] = {
"tar archive",
"POSIX tar archive",
"POSIX tar archive (GNU)",
@@ -85,7 +85,8 @@ file_is_tar(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
* Return
* 0 if the checksum is bad (i.e., probably not a tar archive),
* 1 for old UNIX tar file,
- * 2 for Unix Std (POSIX) tar file.
+ * 2 for Unix Std (POSIX) tar file,
+ * 3 for GNU tar file.
*/
private int
is_tar(const unsigned char *buf, size_t nbytes)
diff --git a/libmagic.man b/libmagic.man
index 61e8f27e3d11..d7082c9904fc 100644
--- a/libmagic.man
+++ b/libmagic.man
@@ -1,3 +1,4 @@
+.\" $File: libmagic.man,v 1.18 2008/02/28 22:24:46 rrt Exp $
.\"
.\" Copyright (c) Christos Zoulas 2003.
.\" All Rights Reserved.
@@ -164,7 +165,7 @@ bytes size.
.Pp
The
.Fn magic_setflags
-function, sets the
+function sets the
.Ar flags
described above. Note that using both MIME flags together can also
return extra information on the charset.
@@ -185,7 +186,9 @@ separated list of database files passed in as
or NULL for the default database. It returns 0 on success and -1 on
failure. The compiled files created are named from the
.Xr basename 1
-of each file argument with ".mgc" appended to it.
+of each file argument with
+.Dq .mgc
+appended to it.
.Pp
The
.Fn magic_load
@@ -199,7 +202,11 @@ The default database file is named by the MAGIC environment variable. If
that variable is not set, the default database file name is __MAGIC__.
.Pp
.Fn magic_load
-adds ".mime" and/or ".mgc" to the database filename as appropriate.
+adds
+.Dq .mime
+and/or
+.Dq .mgc
+to the database filename as appropriate.
.Sh RETURN VALUES
The function
.Fn magic_open
diff --git a/magic.c b/magic.c
index 8fba30bfab1b..55dfee1b35b2 100644
--- a/magic.c
+++ b/magic.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) Christos Zoulas 2003.
* All Rights Reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -11,7 +11,7 @@
* 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 AUTHOR 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
@@ -38,7 +38,9 @@
#ifdef QUICK
#include <sys/mman.h>
#endif
+#ifdef HAVE_LIMITS_H
#include <limits.h> /* for PIPE_BUF */
+#endif
#if defined(HAVE_UTIMES)
# include <sys/time.h>
@@ -63,9 +65,18 @@
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$File: magic.c,v 1.45 2007/12/27 16:35:59 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.54 2008/07/25 23:30:32 rrt Exp $")
#endif /* lint */
+#ifndef PIPE_BUF
+/* Get the PIPE_BUF from pathconf */
+#ifdef _PC_PIPE_BUF
+#define PIPE_BUF pathconf(".", _PC_PIPE_BUF)
+#else
+#define PIPE_BUF 512
+#endif
+#endif
+
#ifdef __EMX__
private char *apptypeName = NULL;
protected int file_os2_apptype(struct magic_set *ms, const char *fn,
@@ -75,7 +86,7 @@ protected int file_os2_apptype(struct magic_set *ms, const char *fn,
private void free_mlist(struct mlist *);
private void close_and_restore(const struct magic_set *, const char *, int,
const struct stat *);
-private int info_from_stat(struct magic_set *, mode_t);
+private int unreadable_info(struct magic_set *, mode_t, const char *);
#ifndef COMPILE_ONLY
private const char *file_or_fd(struct magic_set *, const char *, int);
#endif
@@ -88,38 +99,30 @@ public struct magic_set *
magic_open(int flags)
{
struct magic_set *ms;
+ size_t len;
- if ((ms = calloc((size_t)1, sizeof(struct magic_set))) == NULL)
+ if ((ms = CAST(magic_set *, calloc((size_t)1,
+ sizeof(struct magic_set)))) == NULL)
return NULL;
if (magic_setflags(ms, flags) == -1) {
errno = EINVAL;
- goto free1;
+ goto free;
}
- ms->o.ptr = ms->o.buf = malloc(ms->o.left = ms->o.size = 1024);
- if (ms->o.buf == NULL)
- goto free1;
+ ms->o.buf = ms->o.pbuf = NULL;
+ len = (ms->c.len = 10) * sizeof(*ms->c.li);
- ms->o.pbuf = malloc(ms->o.psize = 1024);
- if (ms->o.pbuf == NULL)
- goto free2;
+ if ((ms->c.li = CAST(struct level_info *, malloc(len))) == NULL)
+ goto free;
- ms->c.li = malloc((ms->c.len = 10) * sizeof(*ms->c.li));
- if (ms->c.li == NULL)
- goto free3;
-
ms->haderr = 0;
ms->error = -1;
ms->mlist = NULL;
ms->file = "unknown";
ms->line = 0;
return ms;
-free3:
- free(ms->o.pbuf);
-free2:
- free(ms->o.buf);
-free1:
+free:
free(ms);
return NULL;
}
@@ -143,13 +146,13 @@ free_mlist(struct mlist *mlist)
}
private int
-info_from_stat(struct magic_set *ms, mode_t md)
+unreadable_info(struct magic_set *ms, mode_t md, const char *file)
{
/* We cannot open it, but we were able to stat it. */
- if (md & 0222)
+ if (access(file, W_OK) == 0)
if (file_printf(ms, "writable, ") == -1)
return -1;
- if (md & 0111)
+ if (access(file, X_OK) == 0)
if (file_printf(ms, "executable, ") == -1)
return -1;
if (S_ISREG(md))
@@ -218,7 +221,7 @@ close_and_restore(const struct magic_set *ms, const char *name, int fd,
*/
#ifdef HAVE_UTIMES
struct timeval utsbuf[2];
- memset(utsbuf, 0, sizeof(struct timeval) * 2);
+ (void)memset(utsbuf, 0, sizeof(utsbuf));
utsbuf[0].tv_sec = sb->st_atime;
utsbuf[1].tv_sec = sb->st_mtime;
@@ -226,7 +229,7 @@ close_and_restore(const struct magic_set *ms, const char *name, int fd,
#elif defined(HAVE_UTIME_H) || defined(HAVE_SYS_UTIME_H)
struct utimbuf utbuf;
- memset(&utbuf, 0, sizeof(struct utimbuf));
+ (void)memset(utbuf, 0, sizeof(utbuf));
utbuf.actime = sb->st_atime;
utbuf.modtime = sb->st_mtime;
(void) utime(name, &utbuf); /* don't care if loses */
@@ -268,7 +271,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
* some overlapping space for matches near EOF
*/
#define SLOP (1 + sizeof(union VALUETYPE))
- if ((buf = malloc(HOWMANY + SLOP)) == NULL)
+ if ((buf = CAST(unsigned char *, malloc(HOWMANY + SLOP))) == NULL)
return NULL;
if (file_reset(ms) == -1)
@@ -298,11 +301,18 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
errno = 0;
if ((fd = open(inname, flags)) < 0) {
#ifdef __CYGWIN__
+ /* FIXME: Do this with EXEEXT from autotools */
char *tmp = alloca(strlen(inname) + 5);
(void)strcat(strcpy(tmp, inname), ".exe");
if ((fd = open(tmp, flags)) < 0) {
#endif
- if (info_from_stat(ms, sb.st_mode) == -1)
+ if (unreadable_info(ms, sb.st_mode,
+#ifdef __CYGWIN
+ tmp
+#else
+ inname
+#endif
+ ) == -1)
goto done;
rv = 0;
goto done;
@@ -332,7 +342,7 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
if (nbytes == 0) {
/* We can not read it, but we were able to stat it. */
- if (info_from_stat(ms, sb.st_mode) == -1)
+ if (unreadable_info(ms, sb.st_mode, inname) == -1)
goto done;
rv = 0;
goto done;
@@ -363,7 +373,7 @@ magic_buffer(struct magic_set *ms, const void *buf, size_t nb)
return NULL;
/*
* The main work is done here!
- * We have the file name and/or the data buffer to be identified.
+ * We have the file name and/or the data buffer to be identified.
*/
if (file_buffer(ms, -1, NULL, buf, nb) == -1) {
return NULL;
diff --git a/magic.h b/magic.h
index 6041f548c8f9..ecdd53c1f96b 100644
--- a/magic.h
+++ b/magic.h
@@ -48,11 +48,12 @@
#define MAGIC_NO_CHECK_APPTYPE 0x008000 /* Don't check application type */
#define MAGIC_NO_CHECK_ELF 0x010000 /* Don't check for elf details */
#define MAGIC_NO_CHECK_ASCII 0x020000 /* Don't check for ascii files */
-#define MAGIC_NO_CHECK_TROFF 0x040000 /* Don't check ascii/troff */
#define MAGIC_NO_CHECK_TOKENS 0x100000 /* Don't check ascii/tokens */
-/* Defined for backwards compatibility; does nothing */
+/* Defined for backwards compatibility; do nothing */
#define MAGIC_NO_CHECK_FORTRAN 0x000000 /* Don't check ascii/fortran */
+#define MAGIC_NO_CHECK_TROFF 0x000000 /* Don't check ascii/troff */
+
#ifdef __cplusplus
extern "C" {
diff --git a/magic.man b/magic.man
index 3842b6481c30..314a01476af3 100644
--- a/magic.man
+++ b/magic.man
@@ -1,11 +1,11 @@
-.\" $File: magic.man,v 1.39 2007/11/08 00:31:37 christos Exp $
-.Dd January 10, 2007
+.\" $File: magic.man,v 1.57 2008/08/30 09:50:20 christos Exp $
+.Dd August 30, 2008
.Dt MAGIC __FSECTION__
.Os
-.\" install as magic.4 on USG, magic.5 on V7 or Berkeley systems.
+.\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems.
.Sh NAME
.Nm magic
-.Nd file command's magic number file
+.Nd file command's magic pattern file
.Sh DESCRIPTION
This manual page documents the format of the magic file as
used by the
@@ -15,18 +15,17 @@ The
.Xr file __CSECTION__
command identifies the type of a file using,
among other tests,
-a test for whether the file begins with a certain
-.Dq "magic number" .
+a test for whether the file contains certain
+.Dq "magic patterns" .
The file
.Pa __MAGIC__
-specifies what magic numbers are to be tested for,
-what message to print if a particular magic number is found,
+specifies what patterns are to be tested for, what message or
+MIME type to print if a particular pattern is found,
and additional information to extract from the file.
.Pp
Each line of the file specifies a test to be performed.
A test compares the data starting at a particular offset
-in the file with a 1-byte, 2-byte, or 4-byte numeric value or
-a string.
+in the file with a byte value, a string or a numeric value.
If the test succeeds, a message is printed.
The line consists of the following fields:
.Bl -tag -width ".Dv message"
@@ -40,15 +39,15 @@ The possible values are:
.It Dv byte
A one-byte value.
.It Dv short
-A two-byte value (on most systems) in this machine's native byte order.
+A two-byte value in this machine's native byte order.
.It Dv long
-A four-byte value (on most systems) in this machine's native byte order.
+A four-byte value in this machine's native byte order.
.It Dv quad
-An eight-byte value (on most systems) in this machine's native byte order.
+An eight-byte value in this machine's native byte order.
.It Dv float
-A 32-bit (on most systems) single precision IEEE floating point number in this machine's native byte order.
+A 32-bit single precision IEEE floating point number in this machine's native byte order.
.It Dv double
-A 64-bit (on most systems) double precision IEEE floating point number in this machine's native byte order.
+A 64-bit double precision IEEE floating point number in this machine's native byte order.
.It Dv string
A string of bytes.
The string type specification can be optionally followed
@@ -69,10 +68,10 @@ Finally the
.Dq c
flag, specifies case insensitive matching: lowercase
characters in the magic match both lower and upper case characters in the
-targer, whereas upper case characters in the magic, only much uppercase
+target, whereas upper case characters in the magic only match uppercase
characters in the target.
.It Dv pstring
-A pascal style string where the first byte is interpreted as the an
+A Pascal-style string where the first byte is interpreted as the an
unsigned length.
The string is not NUL terminated.
.It Dv date
@@ -86,106 +85,119 @@ local time rather than UTC.
An eight-byte value interpreted as a UNIX-style date, but interpreted as
local time rather than UTC.
.It Dv beshort
-A two-byte value (on most systems) in big-endian byte order.
+A two-byte value in big-endian byte order.
.It Dv belong
-A four-byte value (on most systems) in big-endian byte order.
+A four-byte value in big-endian byte order.
.It Dv bequad
-An eight-byte value (on most systems) in big-endian byte order.
+An eight-byte value in big-endian byte order.
.It Dv befloat
-A 32-bit (on most systems) single precision IEEE floating point number in big-endian byte order.
+A 32-bit single precision IEEE floating point number in big-endian byte order.
.It Dv bedouble
-A 64-bit (on most systems) double precision IEEE floating point number in big-endian byte order.
+A 64-bit double precision IEEE floating point number in big-endian byte order.
.It Dv bedate
-A four-byte value (on most systems) in big-endian byte order,
+A four-byte value in big-endian byte order,
interpreted as a Unix date.
.It Dv beqdate
-An eight-byte value (on most systems) in big-endian byte order,
+An eight-byte value in big-endian byte order,
interpreted as a Unix date.
.It Dv beldate
-A four-byte value (on most systems) in big-endian byte order,
+A four-byte value in big-endian byte order,
interpreted as a UNIX-style date, but interpreted as local time rather
than UTC.
.It Dv beqldate
-An eight-byte value (on most systems) in big-endian byte order,
+An eight-byte value in big-endian byte order,
interpreted as a UNIX-style date, but interpreted as local time rather
than UTC.
.It Dv bestring16
A two-byte unicode (UCS16) string in big-endian byte order.
.It Dv leshort
-A two-byte value (on most systems) in little-endian byte order.
+A two-byte value in little-endian byte order.
.It Dv lelong
-A four-byte value (on most systems) in little-endian byte order.
+A four-byte value in little-endian byte order.
.It Dv lequad
-An eight-byte value (on most systems) in little-endian byte order.
+An eight-byte value in little-endian byte order.
.It Dv lefloat
-A 32-bit (on most systems) single precision IEEE floating point number in little-endian byte order.
+A 32-bit single precision IEEE floating point number in little-endian byte order.
.It Dv ledouble
-A 64-bit (on most systems) double precision IEEE floating point number in little-endian byte order.
+A 64-bit double precision IEEE floating point number in little-endian byte order.
.It Dv ledate
-A four-byte value (on most systems) in little-endian byte order,
+A four-byte value in little-endian byte order,
interpreted as a UNIX date.
.It Dv leqdate
-An eight-byte value (on most systems) in little-endian byte order,
+An eight-byte value in little-endian byte order,
interpreted as a UNIX date.
.It Dv leldate
-A four-byte value (on most systems) in little-endian byte order,
+A four-byte value in little-endian byte order,
interpreted as a UNIX-style date, but interpreted as local time rather
than UTC.
.It Dv leqldate
-An eight-byte value (on most systems) in little-endian byte order,
+An eight-byte value in little-endian byte order,
interpreted as a UNIX-style date, but interpreted as local time rather
than UTC.
.It Dv lestring16
A two-byte unicode (UCS16) string in little-endian byte order.
.It Dv melong
-A four-byte value (on most systems) in middle-endian (PDP-11) byte order.
+A four-byte value in middle-endian (PDP-11) byte order.
.It Dv medate
-A four-byte value (on most systems) in middle-endian (PDP-11) byte order,
+A four-byte value in middle-endian (PDP-11) byte order,
interpreted as a UNIX date.
.It Dv meldate
-A four-byte value (on most systems) in middle-endian (PDP-11) byte order,
+A four-byte value in middle-endian (PDP-11) byte order,
interpreted as a UNIX-style date, but interpreted as local time rather
than UTC.
.It Dv regex
A regular expression match in extended POSIX regular expression syntax
-(much like egrep).
-The type specification can be optionally followed by /[cse]*.
+(like egrep). Regular expressions can take exponential time to
+process, and their performance is hard to predict, so their use is
+discouraged. When used in production environments, their performance
+should be carefully checked. The type specification can be optionally
+followed by
+.Dv /[c][s] .
The
.Dq c
flag makes the match case insensitive, while the
.Dq s
-or
-.Dq e
-flags update the offset to the starting or ending offsets of the
-match (only one should be used).
-By default, regex does not update the offset.
-The regular expression is always tested against the first
-.Dv N
-lines, where
+flag update the offset to the start offset of the match, rather than the end.
+The regular expression is tested against line
+.Dv N + 1
+onwards, where
.Dv N
-is the given offset, thus it
-is only useful for (single-byte encoded) text.
+is the given offset.
+Line endings are assumed to be in the machine's native format.
.Dv ^
and
.Dv $
-will match the beginning and end of individual lines, respectively,
+match the beginning and end of individual lines, respectively,
not beginning and end of file.
.It Dv search
-A literal string search starting at the given offset.
-It must be followed by
-.Dv \*[Lt]number\*[Gt]
-which specifies how many matches shall be attempted (the range).
-This is suitable for searching larger binary expressions with variable
-offsets, using
+A literal string search starting at the given offset. The same
+modifier flags can be used as for string patterns. The modifier flags
+(if any) must be followed by
+.Dv /number
+the range, that is, the number of positions at which the match will be
+attempted, starting from the start offset. This is suitable for
+searching larger binary expressions with variable offsets, using
.Dv \e
-escapes for special characters.
+escapes for special characters. The offset works as for regex.
.It Dv default
-This is intended to be used with the text
-.Dv x
+This is intended to be used with the test
+.Em x
(which is always true) and a message that is to be used if there are
no other matches.
.El
-.El
+.Pp
+Each top-level magic pattern (see below for an explanation of levels)
+is classified as text or binary according to the types used. Types
+.Dq regex
+and
+.Dq search
+are classified as text tests, unless non-printable characters are used
+in the pattern. All other tests are classified as binary. A top-level
+pattern is considered to be a test text when all its patterns are text
+patterns; otherwise, it is considered to be a binary pattern. When
+matching a file, binary patterns are tried first; if no match is
+found, and the file looks like text, then its encoding is determined
+and the text patterns are tried.
.Pp
The numeric types may optionally be followed by
.Dv \*[Am]
@@ -195,7 +207,6 @@ numeric value before any comparisons are done.
Prepending a
.Dv u
to the type indicates that ordered comparisons should be unsigned.
-.Bl -tag -width ".Dv message"
.It Dv test
The value to be compared with the value from the file.
If the type is
@@ -232,12 +243,8 @@ Operators
and
.Dv ~
don't work with floats and doubles.
-For all tests except
-.Em string
-and
-.Em regex ,
-operation
-.Dv !
+The operator
+.Dv !\&
specifies that the line matches if the test does
.Em not
succeed.
@@ -250,8 +257,8 @@ is octal, and
.Dv 0x13
is hexadecimal.
.Pp
-For string values, the byte string from the
-file must match the specified byte string.
+For string values, the string from the
+file must match the specified string.
The operators
.Dv = ,
.Dv \*[Lt]
@@ -262,10 +269,10 @@ and
can be applied to strings.
The length used for matching is that of the string argument
in the magic file.
-This means that a line can match any string, and
-then presumably print that string, by doing
+This means that a line can match any non-empty string (usually used to
+then print the string), with
.Em \*[Gt]\e0
-(because all strings are greater than the null string).
+(because all non-empty strings are greater than the empty string).
.Pp
The special test
.Em x
@@ -276,11 +283,44 @@ If the string contains a
.Xr printf 3
format specification, the value from the file (with any specified masking
performed) is printed using the message as the format string.
-If the string begins with ``\\b'', the message printed is the
-remainder of the string with no whitespace added before it: multiple
-matches are normally separated by a single space.
+If the string begins with
+.Dq \eb ,
+the message printed is the remainder of the string with no whitespace
+added before it: multiple matches are normally separated by a single
+space.
.El
.Pp
+A MIME type is given on a separate line, which must be the next
+non-blank or comment line after the magic line that identifies the
+file type, and has the following format:
+.Bd -literal -offset indent
+!:mime MIMETYPE
+.Ed
+.Pp
+i.e. the literal string
+.Dq !:mime
+followed by the MIME type.
+.Pp
+An optional strength can be supplied on a separate line which refers to
+the current magic description using the following format:
+.Bd -literal -offset indent
+!:strength OP VALUE
+.Ed
+.Pp
+The operand
+.Dv OP
+can be:
+.Dv + ,
+.Dv - ,
+.Dv * ,
+or
+.Dv /
+and
+.Dv VALUE
+is a constant between 0 and 255.
+This constant is applied using the specified operand
+to the currently computed default magic strength.
+.Pp
Some file formats contain additional information which is to be printed
along with the file type or need additional tests to determine the true
file type.
@@ -350,13 +390,13 @@ That way variable length structures can be examined:
\*[Gt]\*[Gt](0x3c.l) string LX\e0\e0 LX executable (OS/2)
.Ed
.Pp
-This strategy of examining has one drawback: You must make sure that
+This strategy of examining has a drawback: You must make sure that
you eventually print something, or users may get empty output (like, when
there is neither PE\e0\e0 nor LE\e0\e0 in the above example)
.Pp
-If this indirect offset cannot be used as-is, there are simple calculations
+If this indirect offset cannot be used directly, simple calculations are
possible: appending
-.Em [+-*/%\*[Am]|^]\*[Lt]number\*[Gt]
+.Em [+-*/%\*[Am]|^]number
inside parentheses allows one to modify
the value read from the file before it is used as an offset:
.Bd -literal -offset indent
@@ -468,4 +508,3 @@ a system on which the lengths are invariant.
.\" the changes I posted to the S5R2 version.
.\"
.\" Modified for Ian Darwin's version of the file command.
-.\" @(#)$Id: magic.man,v 1.39 2007/11/08 00:31:37 christos Exp $
diff --git a/magic.mime b/magic.mime
deleted file mode 100644
index dfa62de4b8d8..000000000000
--- a/magic.mime
+++ /dev/null
@@ -1,991 +0,0 @@
-# Magic data for KMimeMagic (originally for file(1) command)
-#
-# Note on adding additional MIME types:
-#
-# [RFC2045,RFC2046] specifies that Content Types, Content Subtypes, Character
-# Sets, Access Types, and conversion values for MIME mail will be assigned and
-# listed by the IANA.
-# http://www.iana.org/assignments/media-types/
-#
-# Any unregistered file type should be listed with a preceding x-, as in
-# application/x-foo (RFC2045 5.1), or a x., as in application/x.foo (RFC4288
-# 4.3). Any non x-prefixed type should be registered with IANA and listed at
-# the above address. Any other behavior is a MIME standards violation!
-#
-# It is preferred that when a registered MIME type exists, that
-# the registered Content-Type and Subtype be used to refer to a file of
-# that type, so don't use application/x-zip when application/zip is
-# registered.
-#
-# If an active RFC suggests that a MIME registration for a new type is in
-# progress, make a note of it pointing to that RFC.
-#
-# The format is 4-5 columns:
-# Column #1: byte number to begin checking from, ">" indicates continuation
-# Column #2: type of data to match
-# Column #3: contents of data to match
-# Column #4: MIME type of result
-# Column #5: MIME encoding of result (optional)
-
-#------------------------------------------------------------------------------
-# Localstuff: file(1) magic for locally observed files
-# Add any locally observed files here.
-
-# Real Audio (Magic .ra\0375)
-0 belong 0x2e7261fd audio/x-pn-realaudio
-0 string .RMF application/vnd.rn-realmedia
-
-#video/x-pn-realvideo
-#video/vnd.rn-realvideo
-#application/vnd.rn-realmedia
-# sigh, there are many mimes for that but the above are the most common.
-
-# Taken from magic, converted to magic.mime
-# mime types according to http://www.geocities.com/nevilo/mod.htm:
-# audio/it .it
-# audio/x-zipped-it .itz
-# audio/xm fasttracker modules
-# audio/x-s3m screamtracker modules
-# audio/s3m screamtracker modules
-# audio/x-zipped-mod mdz
-# audio/mod mod
-# audio/x-mod All modules (mod, s3m, 669, mtm, med, xm, it, mdz, stm, itz, xmz, s3z)
-
-# Taken from loader code from mikmod version 2.14
-# by Steve McIntyre (stevem@chiark.greenend.org.uk)
-# <doj@cubic.org> added title printing on 2003-06-24
-0 string MAS_UTrack_V00
->14 string >/0 audio/x-mod
-#audio/x-tracker-module
-
-#0 string UN05 MikMod UNI format module sound data
-
-0 string Extended\ Module: audio/x-mod
-#audio/x-tracker-module
-##>17 string >\0 Title: "%s"
-
-21 string/c \!SCREAM! audio/x-mod
-#audio/x-screamtracker-module
-21 string BMOD2STM audio/x-mod
-#audio/x-screamtracker-module
-1080 string M.K. audio/x-mod
-#audio/x-protracker-module
-#>0 string >\0 Title: "%s"
-1080 string M!K! audio/x-mod
-#audio/x-protracker-module
-#>0 string >\0 Title: "%s"
-1080 string FLT4 audio/x-mod
-#audio/x-startracker-module
-#>0 string >\0 Title: "%s"
-1080 string FLT8 audio/x-mod
-#audio/x-startracker-module
-#>0 string >\0 Title: "%s"
-1080 string 4CHN audio/x-mod
-#audio/x-fasttracker-module
-#>0 string >\0 Title: "%s"
-1080 string 6CHN audio/x-mod
-#audio/x-fasttracker-module
-#>0 string >\0 Title: "%s"
-1080 string 8CHN audio/x-mod
-#audio/x-fasttracker-module
-#>0 string >\0 Title: "%s"
-1080 string CD81 audio/x-mod
-#audio/x-oktalyzer-tracker-module
-#>0 string >\0 Title: "%s"
-1080 string OKTA audio/x-mod
-#audio/x-oktalyzer-tracker-module
-#>0 string >\0 Title: "%s"
-# Not good enough.
-#1082 string CH
-#>1080 string >/0 %.2s-channel Fasttracker "oktalyzer" module sound data
-1080 string 16CN audio/x-mod
-#audio/x-taketracker-module
-#>0 string >\0 Title: "%s"
-1080 string 32CN audio/x-mod
-#audio/x-taketracker-module
-#>0 string >\0 Title: "%s"
-
-# Impuse tracker module (it)
-0 string IMPM audio/x-mod
-#>4 string >\0 "%s"
-#>40 leshort !0 compatible w/ITv%x
-#>42 leshort !0 created w/ITv%x
-
-#------------------------------------------------------------------------------
-# end local stuff
-#------------------------------------------------------------------------------
-
-# xml based formats!
-
-# svg
-
-38 string \<\!DOCTYPE\040svg image/svg+xml
-
-0 belong 0xfeedfeed application/x-java-keystore
-
-0 belong 0xcececece application/x-java-jce-keystore
-
-
-# xml
-0 string \<?xml text/xml
-
-
-#------------------------------------------------------------------------------
-# Java
-
-0 beshort 0xcafe
->2 beshort 0xbabe application/x-java-applet
->2 beshort 0xd00d application/x-java-pack200
-
-#------------------------------------------------------------------------------
-# audio: file(1) magic for sound formats
-#
-# from Jan Nicolai Langfeldt <janl@ifi.uio.no>,
-#
-
-# Sun/NeXT audio data
-0 string .snd
->12 belong 1 audio/basic
->12 belong 2 audio/basic
->12 belong 3 audio/basic
->12 belong 4 audio/basic
->12 belong 5 audio/basic
->12 belong 6 audio/basic
->12 belong 7 audio/basic
-
->12 belong 23 audio/x-adpcm
-
-# DEC systems (e.g. DECstation 5000) use a variant of the Sun/NeXT format
-# that uses little-endian encoding and has a different magic number
-# (0x0064732E in little-endian encoding).
-0 lelong 0x0064732E
->12 lelong 1 audio/x-dec-basic
->12 lelong 2 audio/x-dec-basic
->12 lelong 3 audio/x-dec-basic
->12 lelong 4 audio/x-dec-basic
->12 lelong 5 audio/x-dec-basic
->12 lelong 6 audio/x-dec-basic
->12 lelong 7 audio/x-dec-basic
-# compressed (G.721 ADPCM)
->12 lelong 23 audio/x-dec-adpcm
-
-# Bytes 0-3 of AIFF, AIFF-C, & 8SVX audio files are "FORM"
-# AIFF audio data
-8 string AIFF audio/x-aiff
-# AIFF-C audio data
-8 string AIFC audio/x-aiff
-# IFF/8SVX audio data
-8 string 8SVX audio/x-aiff
-
-
-
-# Creative Labs AUDIO stuff
-# Standard MIDI data
-0 string MThd audio/x-midi
-#>9 byte >0 (format %d)
-#>11 byte >1 using %d channels
-# Creative Music (CMF) data
-0 string CTMF audio/x-unknown
-# SoundBlaster instrument data
-0 string SBI audio/x-unknown
-# Creative Labs voice data
-0 string Creative\ Voice\ File audio/x-unknown
-## is this next line right? it came this way...
-#>19 byte 0x1A
-#>23 byte >0 - version %d
-#>22 byte >0 \b.%d
-
-# [GRR 950115: is this also Creative Labs? Guessing that first line
-# should be string instead of unknown-endian long...]
-#0 long 0x4e54524b MultiTrack sound data
-#0 string NTRK MultiTrack sound data
-#>4 long x - version %ld
-
-# Microsoft WAVE format (*.wav)
-# [GRR 950115: probably all of the shorts and longs should be leshort/lelong]
-# Microsoft RIFF
-0 string RIFF
-# - WAVE format
->8 string WAVE audio/x-wav
->8 string/B AVI video/x-msvideo
-#
->8 string CDRA image/x-coreldraw
-
-# AAC (aka MPEG-2 NBC)
-0 beshort&0xfff6 0xfff0 audio/X-HX-AAC-ADTS
-0 string ADIF audio/X-HX-AAC-ADIF
-0 beshort&0xffe0 0x56e0 audio/MP4A-LATM
-0 beshort 0x4De1 audio/MP4A-LATM
-
-# MPEG Layer 3 sound files
-# modified by Joerg Jenderek
-# GRR the original test are too common for many DOS files
-# so test 1 <= kbits nibble <= E
-0 beshort &0xffe0
->2 ubyte&0xF0 >0x0F
->>2 ubyte&0xF0 <0xE1 audio/mpeg
-#MP3 with ID3 tag
-0 string ID3 audio/mpeg
-# Ogg/Vorbis
-0 string OggS application/ogg
-
-#------------------------------------------------------------------------------
-# c-lang: file(1) magic for C programs or various scripts
-#
-
-# XPM icons (Greg Roelofs, newt@uchicago.edu)
-# ideally should go into "images", but entries below would tag XPM as C source
-0 string /*\ XPM image/x-xpmi
-
-# 3DS (3d Studio files) Conflicts with diff output 0x3d '='
-#16 beshort 0x3d3d image/x-3ds
-
-# this first will upset you if you're a PL/1 shop... (are there any left?)
-# in which case rm it; ascmagic will catch real C programs
-# C or REXX program text
-#0 string /* text/x-c
-# C++ program text
-#0 string // text/x-c++
-
-#------------------------------------------------------------------------------
-# commands: file(1) magic for various shells and interpreters
-#
-#0 string :\ shell archive or commands for antique kernel text
-0 string #!/bin/sh application/x-shellscript
-0 string #!\ /bin/sh application/x-shellscript
-0 string #!/bin/csh application/x-shellscript
-0 string #!\ /bin/csh application/x-shellscript
-# korn shell magic, sent by George Wu, gwu@clyde.att.com
-0 string #!/bin/ksh application/x-shellscript
-0 string #!\ /bin/ksh application/x-shellscript
-0 string #!/bin/tcsh application/x-shellscript
-0 string #!\ /bin/tcsh application/x-shellscript
-0 string #!/usr/local/tcsh application/x-shellscript
-0 string #!\ /usr/local/tcsh application/x-shellscript
-0 string #!/usr/local/bin/tcsh application/x-shellscript
-0 string #!\ /usr/local/bin/tcsh application/x-shellscript
-# bash shell magic, from Peter Tobias (tobias@server.et-inf.fho-emden.de)
-0 string #!/bin/bash application/x-shellscript
-0 string #!\ /bin/bash application/x-shellscript
-0 string #!/usr/local/bin/bash application/x-shellscript
-0 string #!\ /usr/local/bin/bash application/x-shellscript
-
-#
-# zsh/ash/ae/nawk/gawk magic from cameron@cs.unsw.oz.au (Cameron Simpson)
-0 string #!/bin/zsh application/x-shellscript
-0 string #!/usr/bin/zsh application/x-shellscript
-0 string #!/usr/local/bin/zsh application/x-shellscript
-0 string #!\ /usr/local/bin/zsh application/x-shellscript
-0 string #!/usr/local/bin/ash application/x-shellscript
-0 string #!\ /usr/local/bin/ash application/x-shellscript
-#0 string #!/usr/local/bin/ae Neil Brown's ae
-#0 string #!\ /usr/local/bin/ae Neil Brown's ae
-0 string #!/bin/nawk application/x-nawk
-0 string #!\ /bin/nawk application/x-nawk
-0 string #!/usr/bin/nawk application/x-nawk
-0 string #!\ /usr/bin/nawk application/x-nawk
-0 string #!/usr/local/bin/nawk application/x-nawk
-0 string #!\ /usr/local/bin/nawk application/x-nawk
-0 string #!/bin/gawk application/x-gawk
-0 string #!\ /bin/gawk application/x-gawk
-0 string #!/usr/bin/gawk application/x-gawk
-0 string #!\ /usr/bin/gawk application/x-gawk
-0 string #!/usr/local/bin/gawk application/x-gawk
-0 string #!\ /usr/local/bin/gawk application/x-gawk
-#
-0 string #!/bin/awk application/x-awk
-0 string #!\ /bin/awk application/x-awk
-0 string #!/usr/bin/awk application/x-awk
-0 string #!\ /usr/bin/awk application/x-awk
-# update to distinguish from *.vcf files by Joerg Jenderek: joerg dot jenderek at web dot de
-# Too general, \EBEGIN matches in postscript
-#0 regex BEGIN[[:space:]]*[{] application/x-awk
-
-# For Larry Wall's perl language. The ``eval'' line recognizes an
-# outrageously clever hack for USG systems.
-# Keith Waclena <keith@cerberus.uchicago.edu>
-0 string #!/bin/perl application/x-perl
-0 string #!\ /bin/perl application/x-perl
-0 string eval\ "exec\ /bin/perl application/x-perl
-0 string #!/usr/bin/perl application/x-perl
-0 string #!\ /usr/bin/perl application/x-perl
-0 string eval\ "exec\ /usr/bin/perl application/x-perl
-0 string #!/usr/local/bin/perl application/x-perl
-0 string #!\ /usr/local/bin/perl application/x-perl
-0 string eval\ "exec\ /usr/local/bin/perl application/x-perl
-
-#------------------------------------------------------------------------------
-# compress: file(1) magic for pure-compression formats (no archives)
-#
-# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, whap, etc.
-#
-# Formats for various forms of compressed data
-# Formats for "compress" proper have been moved into "compress.c",
-# because it tries to uncompress it to figure out what's inside.
-
-# standard unix compress
-0 string \037\235 application/x-compress
-
-# gzip (GNU zip, not to be confused with [Info-ZIP/PKWARE] zip archiver)
-0 string \037\213 application/x-gzip
-
-0 string PK\003\004 application/zip
-
-# RAR archiver (Greg Roelofs, newt@uchicago.edu)
-0 string Rar! application/x-rar
-
-# According to gzip.h, this is the correct byte order for packed data.
-0 string \037\036 application/octet-stream
-#
-# This magic number is byte-order-independent.
-#
-0 short 017437 application/octet-stream
-
-# XXX - why *two* entries for "compacted data", one of which is
-# byte-order independent, and one of which is byte-order dependent?
-#
-# compacted data
-0 short 0x1fff application/octet-stream
-0 string \377\037 application/octet-stream
-# huf output
-0 short 0145405 application/octet-stream
-
-# Squeeze and Crunch...
-# These numbers were gleaned from the Unix versions of the programs to
-# handle these formats. Note that I can only uncrunch, not crunch, and
-# I didn't have a crunched file handy, so the crunch number is untested.
-# Keith Waclena <keith@cerberus.uchicago.edu>
-#0 leshort 0x76FF squeezed data (CP/M, DOS)
-#0 leshort 0x76FE crunched data (CP/M, DOS)
-
-# Freeze
-#0 string \037\237 Frozen file 2.1
-#0 string \037\236 Frozen file 1.0 (or gzip 0.5)
-
-# lzh?
-#0 string \037\240 LZH compressed data
-
-257 string ustar\0 application/x-tar posix
-257 string ustar\040\040\0 application/x-tar gnu
-
-0 short 070707 application/x-cpio
-0 short 0143561 application/x-cpio swapped
-
-0 string =<ar> application/x-archive
-0 string \!<arch> application/x-archive
->8 string debian application/x-debian-package
-
-#------------------------------------------------------------------------------
-#
-# RPM: file(1) magic for Red Hat Packages Erik Troan (ewt@redhat.com)
-#
-0 beshort 0xedab
->2 beshort 0xeedb application/x-rpm
-
-0 lelong&0x8080ffff 0x0000081a application/x-arc lzw
-0 lelong&0x8080ffff 0x0000091a application/x-arc squashed
-0 lelong&0x8080ffff 0x0000021a application/x-arc uncompressed
-0 lelong&0x8080ffff 0x0000031a application/x-arc packed
-0 lelong&0x8080ffff 0x0000041a application/x-arc squeezed
-0 lelong&0x8080ffff 0x0000061a application/x-arc crunched
-
-0 leshort 0xea60 application/x-arj
-
-# LHARC/LHA archiver (Greg Roelofs, newt@uchicago.edu)
-2 string -lh0- application/x-lharc lh0
-2 string -lh1- application/x-lharc lh1
-2 string -lz4- application/x-lharc lz4
-2 string -lz5- application/x-lharc lz5
-# [never seen any but the last; -lh4- reported in comp.compression:]
-2 string -lzs- application/x-lha lzs
-2 string -lh\ - application/x-lha lh
-2 string -lhd- application/x-lha lhd
-2 string -lh2- application/x-lha lh2
-2 string -lh3- application/x-lha lh3
-2 string -lh4- application/x-lha lh4
-2 string -lh5- application/x-lha lh5
-2 string -lh6- application/x-lha lh6
-2 string -lh7- application/x-lha lh7
-# Shell archives
-10 string #\ This\ is\ a\ shell\ archive application/octet-stream x-shell
-
-#------------------------------------------------------------------------------
-# frame: file(1) magic for FrameMaker files
-#
-# This stuff came on a FrameMaker demo tape, most of which is
-# copyright, but this file is "published" as witness the following:
-#
-# Note that this is the Framemaker Maker Interchange Format, not the
-# Normal format which would be application/vnd.framemaker.
-#
-0 string \<MakerFile application/x-mif
-0 string \<MIFFile application/x-mif
-0 string \<MakerDictionary application/x-mif
-0 string \<MakerScreenFon application/x-mif
-0 string \<MML application/x-mif
-0 string \<Book application/x-mif
-0 string \<Maker application/x-mif
-
-#------------------------------------------------------------------------------
-# html: file(1) magic for HTML (HyperText Markup Language) docs
-#
-# from Daniel Quinlan <quinlan@yggdrasil.com>
-#
-0 string \<HEAD text/html
-0 string \<head text/html
-0 string \<TITLE text/html
-0 string \<title text/html
-0 string \<html text/html
-0 string \<HTML text/html
-0 string \<!-- text/html
-0 string \<h1 text/html
-0 string \<H1 text/html
-0 string/c \<!doctype\ html text/html
-
-#------------------------------------------------------------------------------
-# images: file(1) magic for image formats (see also "c-lang" for XPM bitmaps)
-#
-# originally from jef@helios.ee.lbl.gov (Jef Poskanzer),
-# additions by janl@ifi.uio.no as well as others. Jan also suggested
-# merging several one- and two-line files into here.
-#
-# XXX - byte order for GIF and TIFF fields?
-# [GRR: TIFF allows both byte orders; GIF is probably little-endian]
-#
-
-# [GRR: what the hell is this doing in here?]
-#0 string xbtoa btoa'd file
-
-# PBMPLUS
-# PBM file
-0 string P1 image/x-portable-bitmap
-# PGM file
-0 string P2 image/x-portable-greymap
-# PPM file
-0 string P3 image/x-portable-pixmap
-# PBM "rawbits" file
-0 string P4 image/x-portable-bitmap
-# PGM "rawbits" file
-0 string P5 image/x-portable-greymap
-# PPM "rawbits" file
-0 string P6 image/x-portable-pixmap
-
-# NIFF (Navy Interchange File Format, a modification of TIFF)
-# [GRR: this *must* go before TIFF]
-0 string IIN1 image/x-niff
-
-# TIFF and friends
-# TIFF file, big-endian
-0 string MM image/tiff
-# TIFF file, little-endian
-0 string II image/tiff
-
-# possible GIF replacements; none yet released!
-# (Greg Roelofs, newt@uchicago.edu)
-#
-# GRR 950115: this was mine ("Zip GIF"):
-# ZIF image (GIF+deflate alpha)
-0 string GIF94z image/x-unknown
-#
-# GRR 950115: this is Jeremy Wohl's Free Graphics Format (better):
-# FGF image (GIF+deflate beta)
-0 string FGF95a image/x-unknown
-#
-# GRR 950115: this is Thomas Boutell's Portable Bitmap Format proposal
-# (best; not yet implemented):
-# PBF image (deflate compression)
-0 string PBF image/x-unknown
-
-# GIF
-0 string GIF image/gif
-
-# JPEG images
-0 beshort 0xffd8 image/jpeg
-
-# PC bitmaps (OS/2, Windoze BMP files) (Greg Roelofs, newt@uchicago.edu)
-0 string BM image/bmp
-#>14 byte 12 (OS/2 1.x format)
-#>14 byte 64 (OS/2 2.x format)
-#>14 byte 40 (Windows 3.x format)
-#0 string IC icon
-#0 string PI pointer
-#0 string CI color icon
-#0 string CP color pointer
-#0 string BA bitmap array
-
-# CDROM Filesystems
-32769 string CD001 application/x-iso9660-image
-
-# Newer StuffIt archives (grant@netbsd.org)
-0 string StuffIt application/x-stuffit
-#>162 string >0 : %s
-
-# BinHex is the Macintosh ASCII-encoded file format (see also "apple")
-# Daniel Quinlan, quinlan@yggdrasil.com
-11 string must\ be\ converted\ with\ BinHex\ 4 application/mac-binhex40
-##>41 string x \b, version %.3s
-
-
-#------------------------------------------------------------------------------
-# lisp: file(1) magic for lisp programs
-#
-# various lisp types, from Daniel Quinlan (quinlan@yggdrasil.com)
-0 string ;; text/plain
-# Emacs 18 - this is always correct, but not very magical.
-0 string \012( application/x-elc
-# Emacs 19
-0 string ;ELC\023\000\000\000 application/x-elc
-
-#------------------------------------------------------------------------------
-# mail.news: file(1) magic for mail and news
-#
-# There are tests to ascmagic.c to cope with mail and news.
-0 string Relay-Version: message/rfc822
-0 string #!\ rnews message/rfc822
-0 string N#!\ rnews message/rfc822
-0 string Forward\ to message/rfc822
-0 string Pipe\ to message/rfc822
-0 string Return-Path: message/rfc822
-0 string Received: message/rfc822
-0 string Path: message/news
-0 string Xref: message/news
-0 string From: message/rfc822
-0 string Article message/news
-#------------------------------------------------------------------------------
-# msword: file(1) magic for MS Word files
-#
-# Contributor claims:
-# Reversed-engineered MS Word magic numbers
-#
-
-0 string \376\067\0\043 application/msword
-# disable this one because it applies also to other
-# Office/OLE documents for which msword is not correct. See PR#2608.
-# from magic file of the apache
-#0 string \320\317\021\340\241\261 application/msword
-512 string \354\245\301 application/msword
-0 string \333\245-\0\0\0 application/msword
-
-
-
-#------------------------------------------------------------------------------
-# printer: file(1) magic for printer-formatted files
-#
-
-# PostScript
-0 string %! application/postscript
-0 string \004%! application/postscript
-
-# Acrobat
-# (due to clamen@cs.cmu.edu)
-0 string %PDF- application/pdf
-
-#------------------------------------------------------------------------------
-# sc: file(1) magic for "sc" spreadsheet
-#
-38 string Spreadsheet application/x-sc
-
-#------------------------------------------------------------------------------
-# tex: file(1) magic for TeX files
-#
-# XXX - needs byte-endian stuff (big-endian and little-endian DVI?)
-#
-# From <conklin@talisman.kaleida.com>
-
-# Although we may know the offset of certain text fields in TeX DVI
-# and font files, we can't use them reliably because they are not
-# zero terminated. [but we do anyway, christos]
-0 string \367\002 application/x-dvi
-#0 string \367\203 TeX generic font data
-#0 string \367\131 TeX packed font data
-#0 string \367\312 TeX virtual font data
-#0 string This\ is\ TeX, TeX transcript text
-#0 string This\ is\ METAFONT, METAFONT transcript text
-
-# There is no way to detect TeX Font Metric (*.tfm) files without
-# breaking them apart and reading the data. The following patterns
-# match most *.tfm files generated by METAFONT or afm2tfm.
-2 string \000\021 application/x-tex-tfm
-2 string \000\022 application/x-tex-tfm
-#>34 string >\0 (%s)
-
-# Texinfo and GNU Info, from Daniel Quinlan (quinlan@yggdrasil.com)
-0 string \\input\ texinfo text/x-texinfo
-0 string This\ is\ Info\ file text/x-info
-
-# correct TeX magic for Linux (and maybe more)
-# from Peter Tobias (tobias@server.et-inf.fho-emden.de)
-#
-0 leshort 0x02f7 application/x-dvi
-
-# RTF - Rich Text Format
-0 string {\\rtf text/rtf
-
-# TeX documents, from Daniel Quinlan (quinlan@yggdrasil.com)
-0 search/400 \\input text/x-tex
-0 search/400 \\section text/x-tex
-0 search/400 \\setlength text/x-tex
-0 search/400 \\documentstyle text/x-tex
-0 search/400 \\chapter text/x-tex
-0 search/400 \\documentclass text/x-tex
-
-#------------------------------------------------------------------------------
-# animation: file(1) magic for animation/movie formats
-#
-# animation formats, originally from vax@ccwf.cc.utexas.edu (VaX#n8)
-# MPEG file
-# MPEG sequences
-0 belong 0x000001BA
->4 byte &0x40 video/mp2p
->4 byte ^0x40 video/mpeg
-0 belong 0x000001BB video/mpeg
-0 belong 0x000001B0 video/mp4v-es
-0 belong 0x000001B5 video/mp4v-es
-0 belong 0x000001B3 video/mpv
-0 belong&0xFF5FFF1F 0x47400010 video/mp2t
-0 belong 0x00000001
->4 byte&0x1F 0x07 video/h264
-
-# FLI animation format
-0 leshort 0xAF11 video/x-fli
-# FLC animation format
-0 leshort 0xAF12 video/x-flc
-#
-# SGI and Apple formats
-# Added ISO mimes
-0 string MOVI video/x-sgi-movie
-4 string moov video/quicktime
-4 string mdat video/quicktime
-4 string wide video/quicktime
-4 string skip video/quicktime
-4 string free video/quicktime
-4 string idsc image/x-quicktime
-4 string idat image/x-quicktime
-4 string pckg application/x-quicktime-player
-4 string/B jP image/jp2
-4 string ftyp
->8 string isom video/mp4
->8 string mp41 video/mp4
->8 string mp42 video/mp4
->8 string/B jp2 image/jp2
->8 string 3gp video/3gpp
->8 string avc1 video/3gpp
->8 string mmp4 video/mp4
->8 string/B M4A audio/mp4
->8 string/B qt video/quicktime
-# The contributor claims:
-# I couldn't find a real magic number for these, however, this
-# -appears- to work. Note that it might catch other files, too,
-# so BE CAREFUL!
-#
-# Note that title and author appear in the two 20-byte chunks
-# at decimal offsets 2 and 22, respectively, but they are XOR'ed with
-# 255 (hex FF)! DL format SUCKS BIG ROCKS.
-#
-# DL file version 1 , medium format (160x100, 4 images/screen)
-0 byte 1 video/x-unknown
-0 byte 2 video/x-unknown
-#
-# Databases
-#
-# GDBM magic numbers
-# Will be maintained as part of the GDBM distribution in the future.
-# <downsj@teeny.org>
-0 belong 0x13579ace application/x-gdbm
-0 lelong 0x13579ace application/x-gdbm
-0 string GDBM application/x-gdbm
-#
-0 belong 0x061561 application/x-dbm
-#
-# Executables
-#
-0 string \177ELF
->16 leshort 0 application/octet-stream
->16 leshort 1 application/x-object
->16 leshort 2 application/x-executable
->16 leshort 3 application/x-sharedlib
->16 leshort 4 application/x-coredump
->16 beshort 0 application/octet-stream
->16 beshort 1 application/x-object
->16 beshort 2 application/x-executable
->16 beshort 3 application/x-sharedlib
->16 beshort 4 application/x-coredump
-#
-# DOS
-0 string MZ application/x-dosexec
-#
-# KDE
-0 string [KDE\ Desktop\ Entry] application/x-kdelnk
-0 string #\ KDE\ Config\ File application/x-kdelnk
-# xmcd database file for kscd
-0 string #\ xmcd text/x-xmcd
-
-#------------------------------------------------------------------------------
-# pkgadd: file(1) magic for SysV R4 PKG Datastreams
-#
-0 string #\ PaCkAgE\ DaTaStReAm application/x-svr4-package
-
-#PNG Image Format
-0 string \x89PNG image/png
-
-# MNG Video Format, <URL:http://www.libpng.org/pub/mng/spec/>
-0 string \x8aMNG video/x-mng
-0 string \x8aJNG video/x-jng
-
-#------------------------------------------------------------------------------
-# Hierarchical Data Format, used to facilitate scientific data exchange
-# specifications at http://hdf.ncsa.uiuc.edu/
-0 belong 0x0e031301 Hierarchical Data Format (version 4) data
-0 string \211HDF\r\n\032 Hierarchical Data Format (version 5) data
-
-# Adobe Photoshop
-0 string 8BPS image/vnd.adobe.photoshop
-
-# Felix von Leitner <felix-file@fefe.de>
-0 string d8:announce application/x-bittorrent
-
-
-# lotus 1-2-3 document
-0 belong 0x00001a00 application/x-123
-0 belong 0x00000200 application/x-123
-
-# MS Access database
-4 string Standard\ Jet\ DB application/x-msaccess
-
-## magic for XBase files
-#0 byte 0x02
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 byte 0x03
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 byte 0x04
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 byte 0x05
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 byte 0x30
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 byte 0x43
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 byte 0x7b
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 byte 0x83
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 byte 0x8b
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 byte 0x8e
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 byte 0xb3
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 byte 0xf5
-#>8 leshort >0
-#>>12 leshort 0 application/x-dbf
-#
-#0 leshort 0x0006 application/x-dbt
-
-# Debian has entries for the old PGP formats:
-# pgp: file(1) magic for Pretty Good Privacy
-# see http://lists.gnupg.org/pipermail/gnupg-devel/1999-September/016052.html
-0 beshort 0x9900 application/x-pgp-keyring
-0 beshort 0x9501 application/x-pgp-keyring
-0 beshort 0x9500 application/x-pgp-keyring
-0 beshort 0xa600 application/pgp-encrypted
-0 string -----BEGIN\040PGP text/PGP armored data
->15 string PUBLIC\040KEY\040BLOCK- public key block
->15 string MESSAGE- message
->15 string SIGNED\040MESSAGE- signed message
->15 string PGP\040SIGNATURE- signature
-0 beshort 0x8501 data
-#
-# GnuPG Magic:
-#
-0 beshort 0x9901 application/x-gnupg-keyring
-0 beshort 0x8501 text/OpenPGP data
-
-# flash: file(1) magic for Macromedia Flash file format
-#
-# See
-#
-# http://www.macromedia.com/software/flash/open/
-#
-0 string FWS
->3 byte x application/x-shockwave-flash
-# Flash Video
-0 string FLV video/x-flv
-
-
-# The following paramaters are created for Namazu.
-# <http://www.namazu.org/>
-#
-# 1999/08/13
-#0 string \<!--\ MHonArc text/html; x-type=mhonarc
-0 string BZh application/x-bzip2
-
-# 1999/09/09
-# VRML (suggested by Masao Takaku)
-0 string #VRML\ V1.0\ ascii model/vrml
-0 string #VRML\ V2.0\ utf8 model/vrml
-
-#------------------------------------------------------------------------------
-# ichitaro456: file(1) magic for Just System Word Processor Ichitaro
-#
-# Contributor kenzo-:
-# Reversed-engineered JS Ichitaro magic numbers
-#
-
-0 string DOC
->43 byte 0x14 application/x-ichitaro4
->144 string JDASH application/x-ichitaro4
-
-0 string DOC
->43 byte 0x15 application/x-ichitaro5
-
-0 string DOC
->43 byte 0x16 application/x-ichitaro6
-
-#------------------------------------------------------------------------------
-# office97: file(1) magic for MicroSoft Office files
-#
-# Contributor kenzo-:
-# Reversed-engineered MS Office magic numbers
-#
-
-#0 string \320\317\021\340\241\261\032\341
-#>48 byte 0x1B application/excel
-
-2080 string Microsoft\ Excel\ 5.0\ Worksheet application/vnd.ms-excel
-2114 string Biff5 application/vnd.ms-excel
-
-0 string \224\246\056 application/msword
-
-0 belong 0x31be0000 application/msword
-
-0 string PO^Q` application/msword
-
-0 string \320\317\021\340\241\261\032\341
->546 string bjbj application/msword
->546 string jbjb application/msword
-
-512 string R\0o\0o\0t\0\ \0E\0n\0t\0r\0y application/msword
-
-2080 string Microsoft\ Word\ 6.0\ Document application/msword
-2080 string Documento\ Microsoft\ Word\ 6 application/msword
-2112 string MSWordDoc application/msword
-
-#0 string \320\317\021\340\241\261\032\341 application/powerpoint
-0 string \320\317\021\340\241\261\032\341 application/msword
-
-0 string #\ PaCkAgE\ DaTaStReAm application/x-svr4-package
-
-
-# WinNT/WinCE PE files (Warner Losh, imp@village.org)
-#
-128 string PE\000\000 application/octet-stream
-0 string PE\000\000 application/octet-stream
-
-# miscellaneous formats
-0 string LZ application/octet-stream
-
-# DOS device drivers by Joerg Jenderek
-0 belong 0xffffffff application/octet-stream
-
-# .EXE formats (Greg Roelofs, newt@uchicago.edu)
-#
-0 string MZ
->24 string @ application/octet-stream
-
-0 string MZ
->30 string Copyright\ 1989-1990\ PKWARE\ Inc. application/zip
-
-0 string MZ
->30 string PKLITE\ Copr. application/zip
-
-0 string MZ
->36 string LHa's\ SFX application/x-lha
-
-0 string MZ application/octet-stream
-
-# LHA archiver
-2 string -lh
->6 string - application/x-lha
-
-
-# Zoo archiver
-20 lelong 0xfdc4a7dc application/x-zoo
-
-# ARC archiver
-0 lelong&0x8080ffff 0x0000081a application/x-arc
-0 lelong&0x8080ffff 0x0000091a application/x-arc
-0 lelong&0x8080ffff 0x0000021a application/x-arc
-0 lelong&0x8080ffff 0x0000031a application/x-arc
-0 lelong&0x8080ffff 0x0000041a application/x-arc
-0 lelong&0x8080ffff 0x0000061a application/x-arc
-
-# Microsoft Outlook's Transport Neutral Encapsulation Format (TNEF)
-0 lelong 0x223e9f78 application/vnd.ms-tnef
-
-# From: stephane.loeuillet@tiscali.f
-# http://www.djvuzone.org/
-0 string AT&TFORM image/vnd.djvu
-
-# Danny Milosavljevic <danny.milo@gmx.net>
-# this are adrift (adventure game standard) game files, extension .taf
-# depending on version magic continues with 0x93453E6139FA (V 4.0)
-# 0x9445376139FA (V 3.90)
-# 0x9445366139FA (V 3.80)
-# this is from source (http://www.adrift.org.uk/) and I have some taf
-# files, and checked them.
-#0 belong 0x3C423FC9
-#>4 belong 0x6A87C2CF application/x-adrift
-#0 string \000\000\001\000 image/x-ico
-
-# Quark Xpress 3 Files:
-# (made the mimetype up)
-0 string \0\0MMXPR3\0 application/x-quark-xpress-3
-
-# EET archive
-# From: Tilman Sauerbeck <tilman@code-monkey.de>
-0 belong 0x1ee7ff00 application/x-eet
-
-# From: Denis Knauf, via gentoo.
-0 string fLaC audio/x-flac
-0 string CWS application/x-shockwave-flash
-
-# Hangul Document Files:
-# Reversed-engineered HWP magic numbers
-# From: Won-Kyu Park <wkpark@kldp.org>
-512 string R\0o\0o\0t\0 application/x-hwp
-
-0 string/c BEGIN:VCARD text/x-vcard
-0 string WordPro\0 application/vnd.lotus-wordpro
-0 string WordPro\r\373 application/vnd.lotus-wordpro
-0 string CPC\262 image/x-cpi
-
-#
-128 string DICM application/dicom
-
-# Symbian installation files
-8 lelong 0x10000419 application/vnd.symbian.install
-0 lelong 0x10201A7A x-epoc/x-sisx-app
-# FORTRAN source
-0 string/c c\ text/x-fortran
diff --git a/magic2mime b/magic2mime
deleted file mode 100755
index 26f84d28a160..000000000000
--- a/magic2mime
+++ /dev/null
@@ -1,69 +0,0 @@
-#! /usr/bin/env perl
-# -*- PERL -*-
-# $File: magic2mime,v 1.4 2006/11/25 18:36:10 christos Exp $
-# Copyright (c) 1996, 1997 vax@linkdead.paranoia.com (VaX#n8)
-#
-# Usage: echo 'your-file-output-here' | file_to_ctype.pl
-# file -b files... | file_to_ctype.pl
-# It acts like a filter, reading from STDIN and any files on the command
-# line, printing to STDOUT.
-
-## refs
-# http://www.faqs.org/faqs/mail/mime-faq/part1/index.html
-# comp.mail.mime FAQ
-# ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/media-types
-# assigned content-types
-# ftp://ftp.uu.net/inet/rfc/rfc-index
-# RFC index; search for MIME
-
-@mapping =
-(
- # defaults
- 'data', 'application/octet-stream',
- 'text', 'text/plain',
- # more specific
- '^Rich Text Format data', 'text/richtext',
- '^HTML document text', 'text/html',
- '^exported SGML document text', 'text/sgml',
- 'mail text', 'message/rfc822',
- 'news text', 'message/news',
- '^PostScript document text', 'application/postscript',
- '^BinHex binary text', 'application/mac-binhex40',
- '^Zip archive data', 'application/zip',
- '^Microsoft Word', 'application/msword',
- '^PGP key', 'application/pgp-keys',
- '^PGP encrypted', 'application/pgp-encrypted',
- '^PGP armored data signature', 'application/pgp-signature',
- '^JPEG image', 'image/jpeg',
- '^GIF image', 'image/gif',
- '^PNG image', 'image/png',
- '^TIFF image', 'image/tiff',
- 'Computer Graphics Metafile', 'image/cgf',
- '^Sun/NeXT audio data', 'audio/basic',
- '^MPEG', 'video/mpeg',
- '^Apple QuickTime movie', 'video/quicktime',
- '^DICOM medical imaging data', 'application/dicom',
- # made up by me
- '^bitmap', 'image/x-bitmap',
- '^PC bitmap data, Windows 3.x format', 'image/x-msw3bmp',
- '^FLI', 'video/x-fli',
- '^FLC', 'video/x-flc',
- 'AVI data', 'video/x-avi',
- 'WAVE', 'audio/x-wav',
- 'VOC', 'audio/x-voc',
-);
-
-local($mimetype,$index,$regexp);
-while (<>)
- {
- chop;
- $index = $#mapping - 1;
- while ($index > -1 && !defined($mimetype))
- {
- $mimetype = $mapping[$index + 1] if (/$mapping[$index]/);
- $index -= 2;
- }
- print "$mimetype\n";
- undef $mimetype; # hack
- }
-0;
diff --git a/mkinstalldirs b/mkinstalldirs
deleted file mode 100644
index ef7e16fdafe2..000000000000
--- a/mkinstalldirs
+++ /dev/null
@@ -1,161 +0,0 @@
-#! /bin/sh
-# mkinstalldirs --- make directory hierarchy
-
-scriptversion=2006-05-11.19
-
-# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
-# Created: 1993-05-16
-# Public domain.
-#
-# This file is maintained in Automake, please report
-# bugs to <bug-automake@gnu.org> or send patches to
-# <automake-patches@gnu.org>.
-
-nl='
-'
-IFS=" "" $nl"
-errstatus=0
-dirmode=
-
-usage="\
-Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
-
-Create each directory DIR (with mode MODE, if specified), including all
-leading file name components.
-
-Report bugs to <bug-automake@gnu.org>."
-
-# process command line arguments
-while test $# -gt 0 ; do
- case $1 in
- -h | --help | --h*) # -h for help
- echo "$usage"
- exit $?
- ;;
- -m) # -m PERM arg
- shift
- test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
- dirmode=$1
- shift
- ;;
- --version)
- echo "$0 $scriptversion"
- exit $?
- ;;
- --) # stop option processing
- shift
- break
- ;;
- -*) # unknown option
- echo "$usage" 1>&2
- exit 1
- ;;
- *) # first non-opt arg
- break
- ;;
- esac
-done
-
-for file
-do
- if test -d "$file"; then
- shift
- else
- break
- fi
-done
-
-case $# in
- 0) exit 0 ;;
-esac
-
-# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
-# mkdir -p a/c at the same time, both will detect that a is missing,
-# one will create a, then the other will try to create a and die with
-# a "File exists" error. This is a problem when calling mkinstalldirs
-# from a parallel make. We use --version in the probe to restrict
-# ourselves to GNU mkdir, which is thread-safe.
-case $dirmode in
- '')
- if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
- echo "mkdir -p -- $*"
- exec mkdir -p -- "$@"
- else
- # On NextStep and OpenStep, the `mkdir' command does not
- # recognize any option. It will interpret all options as
- # directories to create, and then abort because `.' already
- # exists.
- test -d ./-p && rmdir ./-p
- test -d ./--version && rmdir ./--version
- fi
- ;;
- *)
- if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
- test ! -d ./--version; then
- echo "mkdir -m $dirmode -p -- $*"
- exec mkdir -m "$dirmode" -p -- "$@"
- else
- # Clean up after NextStep and OpenStep mkdir.
- for d in ./-m ./-p ./--version "./$dirmode";
- do
- test -d $d && rmdir $d
- done
- fi
- ;;
-esac
-
-for file
-do
- case $file in
- /*) pathcomp=/ ;;
- *) pathcomp= ;;
- esac
- oIFS=$IFS
- IFS=/
- set fnord $file
- shift
- IFS=$oIFS
-
- for d
- do
- test "x$d" = x && continue
-
- pathcomp=$pathcomp$d
- case $pathcomp in
- -*) pathcomp=./$pathcomp ;;
- esac
-
- if test ! -d "$pathcomp"; then
- echo "mkdir $pathcomp"
-
- mkdir "$pathcomp" || lasterr=$?
-
- if test ! -d "$pathcomp"; then
- errstatus=$lasterr
- else
- if test ! -z "$dirmode"; then
- echo "chmod $dirmode $pathcomp"
- lasterr=
- chmod "$dirmode" "$pathcomp" || lasterr=$?
-
- if test ! -z "$lasterr"; then
- errstatus=$lasterr
- fi
- fi
- fi
- fi
-
- pathcomp=$pathcomp/
- done
-done
-
-exit $errstatus
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-end: "$"
-# End:
diff --git a/mygetopt.h b/mygetopt.h
new file mode 100644
index 000000000000..ef87525eaf5b
--- /dev/null
+++ b/mygetopt.h
@@ -0,0 +1,68 @@
+/* $NetBSD: getopt.h,v 1.8 2007/11/06 19:21:18 christos Exp $ */
+
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * 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.
+ */
+
+#ifndef _GETOPT_H_
+#define _GETOPT_H_
+
+#include <unistd.h>
+
+/*
+ * Gnu like getopt_long() and BSD4.4 getsubopt()/optreset extensions
+ */
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+struct option {
+ /* name of long option */
+ const char *name;
+ /*
+ * one of no_argument, required_argument, and optional_argument:
+ * whether option takes an argument
+ */
+ int has_arg;
+ /* if not NULL, set *flag to val when option found */
+ int *flag;
+ /* if flag not NULL, value to set *flag to; else return value */
+ int val;
+};
+
+int getopt_long(int, char * const *, const char *,
+ const struct option *, int *);
+
+#endif /* !_GETOPT_H_ */
diff --git a/names.h b/names.h
index 509d2a24fc9b..2682edcc3a0f 100644
--- a/names.h
+++ b/names.h
@@ -32,7 +32,7 @@
* appear at fixed offsets into the file. Don't make HOWMANY
* too high unless you have a very fast CPU.
*
- * $File: names.h,v 1.29 2007/12/27 20:30:35 christos Exp $
+ * $File: names.h,v 1.32 2008/02/11 00:19:29 rrt Exp $
*/
/*
@@ -57,8 +57,8 @@
#define L_PO 13 /* PO */
static const struct {
- const char *human;
- const char *mime;
+ char human[48];
+ char mime[16];
} types[] = {
{ "C program", "text/x-c", },
{ "C++ program", "text/x-c++" },
@@ -74,8 +74,7 @@ static const struct {
{ "BCPL program", "text/x-bcpl" },
{ "M4 macro language pre-processor", "text/x-m4" },
{ "PO (gettext message catalogue)", "text/x-po" },
- { "cannot happen error on names.h/types", "error/x-error" },
- { 0, 0}
+ { "cannot happen error on names.h/types", "error/x-error" }
};
/*
@@ -114,8 +113,8 @@ static const struct {
* as Java, as it comes after "the" and "The". Perhaps we need a fancier
* heuristic to identify Java?
*/
-static struct names {
- const char *name;
+static const struct names {
+ char name[14];
short type;
} names[] = {
/* These must be sorted by eye for optimal hit rate */
@@ -145,18 +144,6 @@ static struct names {
{"LDFLAGS", L_MAKE},
{"all:", L_MAKE},
{".PRECIOUS", L_MAKE},
-/* Too many files of text have these words in them. Find another way
- * to recognize Fortrash.
- */
-#ifdef NOTDEF
- {"subroutine", L_FORT},
- {"function", L_FORT},
- {"block", L_FORT},
- {"common", L_FORT},
- {"dimension", L_FORT},
- {"integer", L_FORT},
- {"data", L_FORT},
-#endif /*NOTDEF*/
{".ascii", L_MACH},
{".asciiz", L_MACH},
{".byte", L_MACH},
@@ -181,6 +168,6 @@ static struct names {
{"<BODY", L_HTML},
{"<html", L_HTML},
{"<HTML", L_HTML},
- {NULL, 0}
+ {"<!--", L_HTML},
};
-#define NNAMES ((sizeof(names)/sizeof(struct names)) - 1)
+#define NNAMES (sizeof(names)/sizeof(struct names))
diff --git a/patchlevel.h b/patchlevel.h
index 10a506bfb517..db6858b5ffab 100644
--- a/patchlevel.h
+++ b/patchlevel.h
@@ -1,11 +1,20 @@
#define FILE_VERSION_MAJOR 4
-#define patchlevel 23
+#define patchlevel 26
/*
* Patchlevel file for Ian Darwin's MAGIC command.
- * $File: patchlevel.h,v 1.67 2007/12/28 20:08:40 christos Exp $
+ * $File: patchlevel.h,v 1.70 2008/08/30 10:01:01 christos Exp $
*
* $Log: patchlevel.h,v $
+ * Revision 1.70 2008/08/30 10:01:01 christos
+ * file 4.26
+ *
+ * Revision 1.69 2008/07/02 15:27:05 christos
+ * welcome to 4.25
+ *
+ * Revision 1.68 2008/03/22 21:39:43 christos
+ * file 4.24
+ *
* Revision 1.67 2007/12/28 20:08:40 christos
* welcome to 4.23.
*
diff --git a/print.c b/print.c
index c28ee2e145f1..c41e71eac534 100644
--- a/print.c
+++ b/print.c
@@ -41,7 +41,7 @@
#include <time.h>
#ifndef lint
-FILE_RCSID("@(#)$File: print.c,v 1.61 2007/12/27 16:35:59 christos Exp $")
+FILE_RCSID("@(#)$File: print.c,v 1.63 2008/02/17 19:28:54 rrt Exp $")
#endif /* lint */
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
@@ -89,8 +89,8 @@ file_mdump(struct magic *m)
if (m->str_flags & REGEX_OFFSET_START)
(void) fputc(CHAR_REGEX_OFFSET_START, stderr);
}
- if (m->str_count)
- (void) fprintf(stderr, "/%u", m->str_count);
+ if (m->str_range)
+ (void) fprintf(stderr, "/%u", m->str_range);
}
else {
if ((m->mask_op & FILE_OPS_MASK) < SZOF(optyp))
@@ -184,13 +184,15 @@ protected void
file_magwarn(struct magic_set *ms, const char *f, ...)
{
va_list va;
- va_start(va, f);
/* cuz we use stdout for most, stderr here */
(void) fflush(stdout);
- (void) fprintf(stderr, "%s, %lu: Warning ", ms->file,
- (unsigned long)ms->line);
+ if (ms->file)
+ (void) fprintf(stderr, "%s, %lu: ", ms->file,
+ (unsigned long)ms->line);
+ (void) fprintf(stderr, "Warning: ");
+ va_start(va, f);
(void) vfprintf(stderr, f, va);
va_end(va);
(void) fputc('\n', stderr);
diff --git a/readelf.c b/readelf.c
index 3c7472b4d4bb..9dcaf09cdabc 100644
--- a/readelf.c
+++ b/readelf.c
@@ -35,9 +35,10 @@
#endif
#include "readelf.h"
+#include "magic.h"
#ifndef lint
-FILE_RCSID("@(#)$File: readelf.c,v 1.68 2007/12/27 16:13:26 christos Exp $")
+FILE_RCSID("@(#)$File: readelf.c,v 1.76 2008/07/16 18:00:57 christos Exp $")
#endif
#ifdef ELFCORE
@@ -45,9 +46,10 @@ private int dophn_core(struct magic_set *, int, int, int, off_t, int, size_t,
off_t, int *);
#endif
private int dophn_exec(struct magic_set *, int, int, int, off_t, int, size_t,
- off_t, int *);
-private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, int *);
-private size_t donote(struct magic_set *, unsigned char *, size_t, size_t, int,
+ off_t, int *, int);
+private int doshn(struct magic_set *, int, int, int, off_t, int, size_t, int *,
+ int);
+private size_t donote(struct magic_set *, void *, size_t, size_t, int,
int, size_t, int *);
#define ELF_ALIGN(a) ((((a) + align - 1) / align) * align)
@@ -123,90 +125,124 @@ getu64(int swap, uint64_t value)
return value;
}
+#define elf_getu16(swap, value) getu16(swap, value)
+#define elf_getu32(swap, value) getu32(swap, value)
#ifdef USE_ARRAY_FOR_64BIT_TYPES
# define elf_getu64(swap, array) \
- ((swap ? ((uint64_t)getu32(swap, array[0])) << 32 : getu32(swap, array[0])) + \
- (swap ? getu32(swap, array[1]) : ((uint64_t)getu32(swap, array[1]) << 32)))
+ ((swap ? ((uint64_t)elf_getu32(swap, array[0])) << 32 : elf_getu32(swap, array[0])) + \
+ (swap ? elf_getu32(swap, array[1]) : ((uint64_t)elf_getu32(swap, array[1]) << 32)))
#else
# define elf_getu64(swap, value) getu64(swap, value)
#endif
-#define xsh_addr (class == ELFCLASS32 \
- ? (void *) &sh32 \
+#define xsh_addr (clazz == ELFCLASS32 \
+ ? (void *) &sh32 \
: (void *) &sh64)
-#define xsh_sizeof (class == ELFCLASS32 \
- ? sizeof sh32 \
+#define xsh_sizeof (clazz == ELFCLASS32 \
+ ? sizeof sh32 \
: sizeof sh64)
-#define xsh_size (class == ELFCLASS32 \
- ? getu32(swap, sh32.sh_size) \
- : getu64(swap, sh64.sh_size))
-#define xsh_offset (class == ELFCLASS32 \
- ? getu32(swap, sh32.sh_offset) \
- : getu64(swap, sh64.sh_offset))
-#define xsh_type (class == ELFCLASS32 \
- ? getu32(swap, sh32.sh_type) \
- : getu32(swap, sh64.sh_type))
-#define xph_addr (class == ELFCLASS32 \
- ? (void *) &ph32 \
+#define xsh_size (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, sh32.sh_size) \
+ : elf_getu64(swap, sh64.sh_size))
+#define xsh_offset (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, sh32.sh_offset) \
+ : elf_getu64(swap, sh64.sh_offset))
+#define xsh_type (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, sh32.sh_type) \
+ : elf_getu32(swap, sh64.sh_type))
+#define xph_addr (clazz == ELFCLASS32 \
+ ? (void *) &ph32 \
: (void *) &ph64)
-#define xph_sizeof (class == ELFCLASS32 \
- ? sizeof ph32 \
+#define xph_sizeof (clazz == ELFCLASS32 \
+ ? sizeof ph32 \
: sizeof ph64)
-#define xph_type (class == ELFCLASS32 \
- ? getu32(swap, ph32.p_type) \
- : getu32(swap, ph64.p_type))
-#define xph_offset (off_t)(class == ELFCLASS32 \
- ? getu32(swap, ph32.p_offset) \
- : getu64(swap, ph64.p_offset))
-#define xph_align (size_t)((class == ELFCLASS32 \
- ? (off_t) (ph32.p_align ? \
- getu32(swap, ph32.p_align) : 4) \
- : (off_t) (ph64.p_align ? \
- getu64(swap, ph64.p_align) : 4)))
-#define xph_filesz (size_t)((class == ELFCLASS32 \
- ? getu32(swap, ph32.p_filesz) \
- : getu64(swap, ph64.p_filesz)))
-#define xnh_addr (class == ELFCLASS32 \
- ? (void *) &nh32 \
+#define xph_type (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, ph32.p_type) \
+ : elf_getu32(swap, ph64.p_type))
+#define xph_offset (off_t)(clazz == ELFCLASS32 \
+ ? elf_getu32(swap, ph32.p_offset) \
+ : elf_getu64(swap, ph64.p_offset))
+#define xph_align (size_t)((clazz == ELFCLASS32 \
+ ? (off_t) (ph32.p_align ? \
+ elf_getu32(swap, ph32.p_align) : 4) \
+ : (off_t) (ph64.p_align ? \
+ elf_getu64(swap, ph64.p_align) : 4)))
+#define xph_filesz (size_t)((clazz == ELFCLASS32 \
+ ? elf_getu32(swap, ph32.p_filesz) \
+ : elf_getu64(swap, ph64.p_filesz)))
+#define xnh_addr (clazz == ELFCLASS32 \
+ ? (void *) &nh32 \
: (void *) &nh64)
-#define xph_memsz (size_t)((class == ELFCLASS32 \
- ? getu32(swap, ph32.p_memsz) \
- : getu64(swap, ph64.p_memsz)))
-#define xnh_sizeof (class == ELFCLASS32 \
- ? sizeof nh32 \
+#define xph_memsz (size_t)((clazz == ELFCLASS32 \
+ ? elf_getu32(swap, ph32.p_memsz) \
+ : elf_getu64(swap, ph64.p_memsz)))
+#define xnh_sizeof (clazz == ELFCLASS32 \
+ ? sizeof nh32 \
: sizeof nh64)
-#define xnh_type (class == ELFCLASS32 \
- ? getu32(swap, nh32.n_type) \
- : getu32(swap, nh64.n_type))
-#define xnh_namesz (class == ELFCLASS32 \
- ? getu32(swap, nh32.n_namesz) \
- : getu32(swap, nh64.n_namesz))
-#define xnh_descsz (class == ELFCLASS32 \
- ? getu32(swap, nh32.n_descsz) \
- : getu32(swap, nh64.n_descsz))
-#define prpsoffsets(i) (class == ELFCLASS32 \
- ? prpsoffsets32[i] \
+#define xnh_type (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, nh32.n_type) \
+ : elf_getu32(swap, nh64.n_type))
+#define xnh_namesz (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, nh32.n_namesz) \
+ : elf_getu32(swap, nh64.n_namesz))
+#define xnh_descsz (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, nh32.n_descsz) \
+ : elf_getu32(swap, nh64.n_descsz))
+#define prpsoffsets(i) (clazz == ELFCLASS32 \
+ ? prpsoffsets32[i] \
: prpsoffsets64[i])
+#define xcap_addr (clazz == ELFCLASS32 \
+ ? (void *) &cap32 \
+ : (void *) &cap64)
+#define xcap_sizeof (clazz == ELFCLASS32 \
+ ? sizeof cap32 \
+ : sizeof cap64)
+#define xcap_tag (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, cap32.c_tag) \
+ : elf_getu64(swap, cap64.c_tag))
+#define xcap_val (clazz == ELFCLASS32 \
+ ? elf_getu32(swap, cap32.c_un.c_val) \
+ : elf_getu64(swap, cap64.c_un.c_val))
#ifdef ELFCORE
-size_t prpsoffsets32[] = {
- 8, /* FreeBSD */
- 44, /* Linux (path name) */
+/*
+ * Try larger offsets first to avoid false matches
+ * from earlier data that happen to look like strings.
+ */
+static const size_t prpsoffsets32[] = {
+#ifdef USE_NT_PSINFO
+ 104, /* SunOS 5.x (command line) */
+ 88, /* SunOS 5.x (short name) */
+#endif /* USE_NT_PSINFO */
+
+ 100, /* SunOS 5.x (command line) */
+ 84, /* SunOS 5.x (short name) */
+
+ 44, /* Linux (command line) */
28, /* Linux 2.0.36 (short name) */
- 84, /* SunOS 5.x */
+
+ 8, /* FreeBSD */
};
-size_t prpsoffsets64[] = {
- 16, /* FreeBSD, 64-bit */
- 56, /* Linux (path name) */
+static const size_t prpsoffsets64[] = {
+#ifdef USE_NT_PSINFO
+ 152, /* SunOS 5.x (command line) */
+ 136, /* SunOS 5.x (short name) */
+#endif /* USE_NT_PSINFO */
+
+ 136, /* SunOS 5.x, 64-bit (command line) */
+ 120, /* SunOS 5.x, 64-bit (short name) */
+
+ 56, /* Linux (command line) */
40, /* Linux (tested on core from 2.4.x, short name) */
- 120, /* SunOS 5.x, 64-bit */
+
+ 16, /* FreeBSD, 64-bit */
};
#define NOFFSETS32 (sizeof prpsoffsets32 / sizeof prpsoffsets32[0])
#define NOFFSETS64 (sizeof prpsoffsets64 / sizeof prpsoffsets64[0])
-#define NOFFSETS (class == ELFCLASS32 ? NOFFSETS32 : NOFFSETS64)
+#define NOFFSETS (clazz == ELFCLASS32 ? NOFFSETS32 : NOFFSETS64)
/*
* Look through the program headers of an executable image, searching
@@ -220,6 +256,14 @@ size_t prpsoffsets64[] = {
* SVR4-flavored systems, and Linux) containing the start of the
* command line for that program.
*
+ * SunOS 5.x core files contain two PT_NOTE sections, with the types
+ * NT_PRPSINFO (old) and NT_PSINFO (new). These structs contain the
+ * same info about the command name and command line, so it probably
+ * isn't worthwhile to look for NT_PSINFO, but the offsets are provided
+ * above (see USE_NT_PSINFO), in case we ever decide to do so. The
+ * NT_PRPSINFO and NT_PSINFO sections are always in order and adjacent;
+ * the SunOS 5.x file command relies on this (and prefers the latter).
+ *
* The signal number probably appears in a section of type NT_PRSTATUS,
* but that's also rather OS-dependent, in ways that are harder to
* dissect with heuristics, so I'm not bothering with the signal number.
@@ -233,7 +277,7 @@ size_t prpsoffsets64[] = {
#define OS_STYLE_FREEBSD 1
#define OS_STYLE_NETBSD 2
-private const char *os_style_names[] = {
+private const char os_style_names[][8] = {
"SVR4",
"FreeBSD",
"NetBSD",
@@ -244,7 +288,7 @@ private const char *os_style_names[] = {
#define FLAGS_DID_CORE_STYLE 4
private int
-dophn_core(struct magic_set *ms, int class, int swap, int fd, off_t off,
+dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
int num, size_t size, off_t fsize, int *flags)
{
Elf32_Phdr ph32;
@@ -309,7 +353,7 @@ dophn_core(struct magic_set *ms, int class, int swap, int fd, off_t off,
if (offset >= (size_t)bufsize)
break;
offset = donote(ms, nbuf, offset, (size_t)bufsize,
- class, swap, 4, flags);
+ clazz, swap, 4, flags);
if (offset == 0)
break;
@@ -320,8 +364,8 @@ dophn_core(struct magic_set *ms, int class, int swap, int fd, off_t off,
#endif
private size_t
-donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
- int class, int swap, size_t align, int *flags)
+donote(struct magic_set *ms, void *vbuf, size_t offset, size_t size,
+ int clazz, int swap, size_t align, int *flags)
{
Elf32_Nhdr nh32;
Elf64_Nhdr nh64;
@@ -330,6 +374,7 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
int os_style = -1;
#endif
uint32_t namesz, descsz;
+ unsigned char *nbuf = CAST(unsigned char *, vbuf);
(void)memcpy(xnh_addr, &nbuf[offset], xnh_sizeof);
offset += xnh_sizeof;
@@ -384,7 +429,7 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
if (file_printf(ms, ", for GNU/") == -1)
return size;
- switch (getu32(swap, desc[0])) {
+ switch (elf_getu32(swap, desc[0])) {
case GNU_OS_LINUX:
if (file_printf(ms, "Linux") == -1)
return size;
@@ -397,12 +442,20 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
if (file_printf(ms, "Solaris") == -1)
return size;
break;
+ case GNU_OS_KFREEBSD:
+ if (file_printf(ms, "kFreeBSD") == -1)
+ return size;
+ break;
+ case GNU_OS_KNETBSD:
+ if (file_printf(ms, "kNetBSD") == -1)
+ return size;
+ break;
default:
if (file_printf(ms, "<unknown>") == -1)
return size;
}
- if (file_printf(ms, " %d.%d.%d", getu32(swap, desc[1]),
- getu32(swap, desc[2]), getu32(swap, desc[3])) == -1)
+ if (file_printf(ms, " %d.%d.%d", elf_getu32(swap, desc[1]),
+ elf_getu32(swap, desc[2]), elf_getu32(swap, desc[3])) == -1)
return size;
*flags |= FLAGS_DID_NOTE;
return size;
@@ -412,7 +465,7 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
xnh_type == NT_NETBSD_VERSION && descsz == 4) {
uint32_t desc;
(void)memcpy(&desc, &nbuf[doff], sizeof(desc));
- desc = getu32(swap, desc);
+ desc = elf_getu32(swap, desc);
if (file_printf(ms, ", for NetBSD") == -1)
return size;
@@ -458,7 +511,7 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
xnh_type == NT_FREEBSD_VERSION && descsz == 4) {
uint32_t desc;
(void)memcpy(&desc, &nbuf[doff], sizeof(desc));
- desc = getu32(swap, desc);
+ desc = elf_getu32(swap, desc);
if (file_printf(ms, ", for FreeBSD") == -1)
return size;
@@ -547,7 +600,7 @@ donote(struct magic_set *ms, unsigned char *nbuf, size_t offset, size_t size,
if (file_printf(ms, ", for DragonFly") == -1)
return size;
(void)memcpy(&desc, &nbuf[doff], sizeof(desc));
- desc = getu32(swap, desc);
+ desc = elf_getu32(swap, desc);
if (file_printf(ms, " %d.%d.%d", desc / 100000,
desc / 10000 % 10, desc % 10000) == -1)
return size;
@@ -615,7 +668,7 @@ core:
(void)memcpy(&signo, &nbuf[doff + 0x08],
sizeof(signo));
if (file_printf(ms, " (signal %u)",
- getu32(swap, signo)) == -1)
+ elf_getu32(swap, signo)) == -1)
return size;
*flags |= FLAGS_DID_CORE;
return size;
@@ -689,7 +742,11 @@ core:
&nbuf[doff + prpsoffsets(i)];
for (cp = cname; *cp && isprint(*cp); cp++)
continue;
- if (cp > cname)
+ /*
+ * Linux apparently appends a space at the end
+ * of the command line: remove it.
+ */
+ while (cp > cname && isspace(cp[-1]))
cp--;
if (file_printf(ms, ", from '%.*s'",
(int)(cp - cname), cname) == -1)
@@ -707,15 +764,67 @@ core:
return offset;
}
+/* SunOS 5.x hardware capability descriptions */
+typedef struct cap_desc {
+ uint64_t cd_mask;
+ const char *cd_name;
+} cap_desc_t;
+
+static const cap_desc_t cap_desc_sparc[] = {
+ { AV_SPARC_MUL32, "MUL32" },
+ { AV_SPARC_DIV32, "DIV32" },
+ { AV_SPARC_FSMULD, "FSMULD" },
+ { AV_SPARC_V8PLUS, "V8PLUS" },
+ { AV_SPARC_POPC, "POPC" },
+ { AV_SPARC_VIS, "VIS" },
+ { AV_SPARC_VIS2, "VIS2" },
+ { AV_SPARC_ASI_BLK_INIT, "ASI_BLK_INIT" },
+ { AV_SPARC_FMAF, "FMAF" },
+ { AV_SPARC_FJFMAU, "FJFMAU" },
+ { AV_SPARC_IMA, "IMA" },
+ { 0, NULL }
+};
+
+static const cap_desc_t cap_desc_386[] = {
+ { AV_386_FPU, "FPU" },
+ { AV_386_TSC, "TSC" },
+ { AV_386_CX8, "CX8" },
+ { AV_386_SEP, "SEP" },
+ { AV_386_AMD_SYSC, "AMD_SYSC" },
+ { AV_386_CMOV, "CMOV" },
+ { AV_386_MMX, "MMX" },
+ { AV_386_AMD_MMX, "AMD_MMX" },
+ { AV_386_AMD_3DNow, "AMD_3DNow" },
+ { AV_386_AMD_3DNowx, "AMD_3DNowx" },
+ { AV_386_FXSR, "FXSR" },
+ { AV_386_SSE, "SSE" },
+ { AV_386_SSE2, "SSE2" },
+ { AV_386_PAUSE, "PAUSE" },
+ { AV_386_SSE3, "SSE3" },
+ { AV_386_MON, "MON" },
+ { AV_386_CX16, "CX16" },
+ { AV_386_AHF, "AHF" },
+ { AV_386_TSCP, "TSCP" },
+ { AV_386_AMD_SSE4A, "AMD_SSE4A" },
+ { AV_386_POPCNT, "POPCNT" },
+ { AV_386_AMD_LZCNT, "AMD_LZCNT" },
+ { AV_386_SSSE3, "SSSE3" },
+ { AV_386_SSE4_1, "SSE4.1" },
+ { AV_386_SSE4_2, "SSE4.2" },
+ { 0, NULL }
+};
+
private int
-doshn(struct magic_set *ms, int class, int swap, int fd, off_t off, int num,
- size_t size, int *flags)
+doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
+ size_t size, int *flags, int mach)
{
Elf32_Shdr sh32;
Elf64_Shdr sh64;
int stripped = 1;
void *nbuf;
off_t noff;
+ uint64_t cap_hw1 = 0; /* SunOS 5.x hardware capabilites */
+ uint64_t cap_sf1 = 0; /* SunOS 5.x software capabilites */
if (size != xsh_sizeof) {
if (file_printf(ms, ", corrupted section header size") == -1)
@@ -769,7 +878,7 @@ doshn(struct magic_set *ms, int class, int swap, int fd, off_t off, int num,
if (noff >= (size_t)xsh_size)
break;
noff = donote(ms, nbuf, (size_t)noff,
- (size_t)xsh_size, class, swap, 4,
+ (size_t)xsh_size, clazz, swap, 4,
flags);
if (noff == 0)
break;
@@ -781,10 +890,115 @@ doshn(struct magic_set *ms, int class, int swap, int fd, off_t off, int num,
}
free(nbuf);
break;
+ case SHT_SUNW_cap:
+ {
+ off_t coff;
+ if ((off = lseek(fd, (off_t)0, SEEK_CUR)) ==
+ (off_t)-1) {
+ file_badread(ms);
+ return -1;
+ }
+ if (lseek(fd, (off_t)xsh_offset, SEEK_SET) ==
+ (off_t)-1) {
+ file_badread(ms);
+ return -1;
+ }
+ coff = 0;
+ for (;;) {
+ Elf32_Cap cap32;
+ Elf64_Cap cap64;
+ char cbuf[MAX(sizeof cap32, sizeof cap64)];
+ if ((coff += xcap_sizeof) >= (size_t)xsh_size)
+ break;
+ if (read(fd, cbuf, (size_t)xcap_sizeof) !=
+ (ssize_t)xcap_sizeof) {
+ file_badread(ms);
+ return -1;
+ }
+ (void)memcpy(xcap_addr, cbuf, xcap_sizeof);
+ switch (xcap_tag) {
+ case CA_SUNW_NULL:
+ break;
+ case CA_SUNW_HW_1:
+ cap_hw1 |= xcap_val;
+ break;
+ case CA_SUNW_SF_1:
+ cap_sf1 |= xcap_val;
+ break;
+ default:
+ if (file_printf(ms,
+ ", with unknown capability "
+ "0x%llx = 0x%llx",
+ xcap_tag, xcap_val) == -1)
+ return -1;
+ break;
+ }
+ }
+ if (lseek(fd, off, SEEK_SET) == (off_t)-1) {
+ file_badread(ms);
+ return -1;
+ }
+ break;
+ }
}
}
if (file_printf(ms, ", %sstripped", stripped ? "" : "not ") == -1)
return -1;
+ if (cap_hw1) {
+ const cap_desc_t *cdp;
+ switch (mach) {
+ case EM_SPARC:
+ case EM_SPARC32PLUS:
+ case EM_SPARCV9:
+ cdp = cap_desc_sparc;
+ break;
+ case EM_386:
+ case EM_IA_64:
+ case EM_AMD64:
+ cdp = cap_desc_386;
+ break;
+ default:
+ cdp = NULL;
+ break;
+ }
+ if (file_printf(ms, ", uses") == -1)
+ return -1;
+ if (cdp) {
+ while (cdp->cd_name) {
+ if (cap_hw1 & cdp->cd_mask) {
+ if (file_printf(ms,
+ " %s", cdp->cd_name) == -1)
+ return -1;
+ cap_hw1 &= ~cdp->cd_mask;
+ }
+ ++cdp;
+ }
+ if (cap_hw1)
+ if (file_printf(ms,
+ " unknown hardware capability 0x%llx",
+ cap_hw1) == -1)
+ return -1;
+ } else {
+ if (file_printf(ms,
+ " hardware capability 0x%llx", cap_hw1) == -1)
+ return -1;
+ }
+ }
+ if (cap_sf1) {
+ if (cap_sf1 & SF1_SUNW_FPUSED) {
+ if (file_printf(ms,
+ (cap_sf1 & SF1_SUNW_FPKNWN)
+ ? ", uses frame pointer"
+ : ", not known to use frame pointer") == -1)
+ return -1;
+ }
+ cap_sf1 &= ~SF1_SUNW_MASK;
+ if (cap_sf1)
+ if (file_printf(ms,
+ ", with unknown software capability 0x%llx",
+ cap_sf1) == -1)
+ return -1;
+ }
return 0;
}
@@ -794,8 +1008,8 @@ doshn(struct magic_set *ms, int class, int swap, int fd, off_t off, int num,
* otherwise it's statically linked.
*/
private int
-dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off,
- int num, size_t size, off_t fsize, int *flags)
+dophn_exec(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
+ int num, size_t size, off_t fsize, int *flags, int sh_num)
{
Elf32_Phdr ph32;
Elf64_Phdr ph64;
@@ -814,7 +1028,7 @@ dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off,
if (size != xph_sizeof) {
if (file_printf(ms, ", corrupted program header size") == -1)
- return -1;
+ return -1;
return 0;
}
@@ -864,6 +1078,8 @@ dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off,
return -1;
align = 4;
}
+ if (sh_num)
+ break;
/*
* This is a PT_NOTE section; loop through all the notes
* in the section.
@@ -884,7 +1100,7 @@ dophn_exec(struct magic_set *ms, int class, int swap, int fd, off_t off,
if (offset >= (size_t)bufsize)
break;
offset = donote(ms, nbuf, offset,
- (size_t)bufsize, class, swap, align,
+ (size_t)bufsize, clazz, swap, align,
flags);
if (offset == 0)
break;
@@ -913,122 +1129,60 @@ file_tryelf(struct magic_set *ms, int fd, const unsigned char *buf,
int32_t l;
char c[sizeof (int32_t)];
} u;
- int class;
+ int clazz;
int swap;
struct stat st;
off_t fsize;
int flags = 0;
+ Elf32_Ehdr elf32hdr;
+ Elf64_Ehdr elf64hdr;
+ uint16_t type;
- /*
- * If we cannot seek, it must be a pipe, socket or fifo.
- */
- if((lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))
- fd = file_pipe2file(ms, fd, buf, nbytes);
-
- if (fstat(fd, &st) == -1) {
- file_badread(ms);
- return -1;
- }
- fsize = st.st_size;
-
+ if (ms->flags & MAGIC_MIME)
+ return 0;
/*
* ELF executables have multiple section headers in arbitrary
* file locations and thus file(1) cannot determine it from easily.
* Instead we traverse thru all section headers until a symbol table
* one is found or else the binary is stripped.
+ * Return immediately if it's not ELF (so we avoid pipe2file unless needed).
*/
if (buf[EI_MAG0] != ELFMAG0
|| (buf[EI_MAG1] != ELFMAG1 && buf[EI_MAG1] != OLFMAG1)
|| buf[EI_MAG2] != ELFMAG2 || buf[EI_MAG3] != ELFMAG3)
- return 0;
-
-
- class = buf[EI_CLASS];
-
- if (class == ELFCLASS32) {
- Elf32_Ehdr elfhdr;
- uint16_t type;
-
- if (nbytes <= sizeof (Elf32_Ehdr))
- return 0;
-
-
- u.l = 1;
- (void) memcpy(&elfhdr, buf, sizeof elfhdr);
- swap = (u.c[sizeof(int32_t) - 1] + 1) != elfhdr.e_ident[EI_DATA];
+ return 0;
- type = getu16(swap, elfhdr.e_type);
- switch (type) {
-#ifdef ELFCORE
- case ET_CORE:
- if (dophn_core(ms, class, swap, fd,
- (off_t)getu32(swap, elfhdr.e_phoff),
- getu16(swap, elfhdr.e_phnum),
- (size_t)getu16(swap, elfhdr.e_phentsize),
- fsize, &flags) == -1)
- return -1;
- break;
-#endif
- case ET_EXEC:
- case ET_DYN:
- if (dophn_exec(ms, class, swap,
- fd, (off_t)getu32(swap, elfhdr.e_phoff),
- getu16(swap, elfhdr.e_phnum),
- (size_t)getu16(swap, elfhdr.e_phentsize),
- fsize, &flags) == -1)
- return -1;
- if (doshn(ms, class, swap, fd,
- (off_t)getu32(swap, elfhdr.e_shoff),
- getu16(swap, elfhdr.e_shnum),
- (size_t)getu16(swap, elfhdr.e_shentsize),
- &flags) == -1)
- return -1;
- break;
+ /*
+ * If we cannot seek, it must be a pipe, socket or fifo.
+ */
+ if((lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) && (errno == ESPIPE))
+ fd = file_pipe2file(ms, fd, buf, nbytes);
- default:
- break;
- }
- return 1;
+ if (fstat(fd, &st) == -1) {
+ file_badread(ms);
+ return -1;
}
+ fsize = st.st_size;
- if (class == ELFCLASS64) {
- Elf64_Ehdr elfhdr;
- if (nbytes <= sizeof (Elf64_Ehdr))
- return 0;
-
-
- u.l = 1;
- (void) memcpy(&elfhdr, buf, sizeof elfhdr);
- swap = (u.c[sizeof(int32_t) - 1] + 1) != elfhdr.e_ident[EI_DATA];
-
- if (getu16(swap, elfhdr.e_type) == ET_CORE) {
-#ifdef ELFCORE
- if (dophn_core(ms, class, swap, fd,
- (off_t)elf_getu64(swap, elfhdr.e_phoff),
- getu16(swap, elfhdr.e_phnum),
- (size_t)getu16(swap, elfhdr.e_phentsize),
- fsize, &flags) == -1)
- return -1;
-#else
- ;
-#endif
- } else {
- if (getu16(swap, elfhdr.e_type) == ET_EXEC) {
- if (dophn_exec(ms, class, swap, fd,
- (off_t)elf_getu64(swap, elfhdr.e_phoff),
- getu16(swap, elfhdr.e_phnum),
- (size_t)getu16(swap, elfhdr.e_phentsize),
- fsize, &flags) == -1)
- return -1;
- }
- if (doshn(ms, class, swap, fd,
- (off_t)elf_getu64(swap, elfhdr.e_shoff),
- getu16(swap, elfhdr.e_shnum),
- (size_t)getu16(swap, elfhdr.e_shentsize), &flags)
- == -1)
- return -1;
- }
- return 1;
+ clazz = buf[EI_CLASS];
+
+ switch (clazz) {
+ case ELFCLASS32:
+#undef elf_getu
+#define elf_getu(a, b) elf_getu32(a, b)
+#undef elfhdr
+#define elfhdr elf32hdr
+#include "elfclass.h"
+ case ELFCLASS64:
+#undef elf_getu
+#define elf_getu(a, b) elf_getu64(a, b)
+#undef elfhdr
+#define elfhdr elf64hdr
+#include "elfclass.h"
+ default:
+ if (file_printf(ms, ", unknown class %d", clazz) == -1)
+ return -1;
+ break;
}
return 0;
}
diff --git a/readelf.h b/readelf.h
index 610c310c82a8..ab4b5d1d60c5 100644
--- a/readelf.h
+++ b/readelf.h
@@ -44,7 +44,7 @@ typedef uint16_t Elf32_Half;
typedef uint32_t Elf32_Word;
typedef uint8_t Elf32_Char;
-#if SIZEOF_UINT64_T != 8
+#if SIZEOF_LONG_LONG != 8
#define USE_ARRAY_FOR_64BIT_TYPES
typedef uint32_t Elf64_Addr[2];
typedef uint32_t Elf64_Off[2];
@@ -96,14 +96,24 @@ typedef struct {
} Elf64_Ehdr;
/* e_type */
+#define ET_REL 1
#define ET_EXEC 2
#define ET_DYN 3
#define ET_CORE 4
+/* e_machine (used only for SunOS 5.x hardware capabilities) */
+#define EM_SPARC 2
+#define EM_386 3
+#define EM_SPARC32PLUS 18
+#define EM_SPARCV9 43
+#define EM_IA_64 50
+#define EM_AMD64 62
+
/* sh_type */
#define SHT_SYMTAB 2
#define SHT_NOTE 7
#define SHT_DYNSYM 11
+#define SHT_SUNW_cap 0x6ffffff5 /* SunOS 5.x hw/sw capabilites */
/* elf type */
#define ELFDATANONE 0 /* e_ident[EI_DATA] */
@@ -229,5 +239,74 @@ typedef struct {
#define GNU_OS_LINUX 0
#define GNU_OS_HURD 1
#define GNU_OS_SOLARIS 2
+#define GNU_OS_KFREEBSD 3
+#define GNU_OS_KNETBSD 4
+
+/* SunOS 5.x hardware/software capabilities */
+typedef struct {
+ Elf32_Word c_tag;
+ union {
+ Elf32_Word c_val;
+ Elf32_Addr c_ptr;
+ } c_un;
+} Elf32_Cap;
+
+typedef struct {
+ Elf64_Xword c_tag;
+ union {
+ Elf64_Xword c_val;
+ Elf64_Addr c_ptr;
+ } c_un;
+} Elf64_Cap;
+
+/* SunOS 5.x hardware/software capability tags */
+#define CA_SUNW_NULL 0
+#define CA_SUNW_HW_1 1
+#define CA_SUNW_SF_1 2
+
+/* SunOS 5.x software capabilities */
+#define SF1_SUNW_FPKNWN 0x01
+#define SF1_SUNW_FPUSED 0x02
+#define SF1_SUNW_MASK 0x03
+
+/* SunOS 5.x hardware capabilities: sparc */
+#define AV_SPARC_MUL32 0x0001
+#define AV_SPARC_DIV32 0x0002
+#define AV_SPARC_FSMULD 0x0004
+#define AV_SPARC_V8PLUS 0x0008
+#define AV_SPARC_POPC 0x0010
+#define AV_SPARC_VIS 0x0020
+#define AV_SPARC_VIS2 0x0040
+#define AV_SPARC_ASI_BLK_INIT 0x0080
+#define AV_SPARC_FMAF 0x0100
+#define AV_SPARC_FJFMAU 0x4000
+#define AV_SPARC_IMA 0x8000
+
+/* SunOS 5.x hardware capabilities: 386 */
+#define AV_386_FPU 0x00000001
+#define AV_386_TSC 0x00000002
+#define AV_386_CX8 0x00000004
+#define AV_386_SEP 0x00000008
+#define AV_386_AMD_SYSC 0x00000010
+#define AV_386_CMOV 0x00000020
+#define AV_386_MMX 0x00000040
+#define AV_386_AMD_MMX 0x00000080
+#define AV_386_AMD_3DNow 0x00000100
+#define AV_386_AMD_3DNowx 0x00000200
+#define AV_386_FXSR 0x00000400
+#define AV_386_SSE 0x00000800
+#define AV_386_SSE2 0x00001000
+#define AV_386_PAUSE 0x00002000
+#define AV_386_SSE3 0x00004000
+#define AV_386_MON 0x00008000
+#define AV_386_CX16 0x00010000
+#define AV_386_AHF 0x00020000
+#define AV_386_TSCP 0x00040000
+#define AV_386_AMD_SSE4A 0x00080000
+#define AV_386_POPCNT 0x00100000
+#define AV_386_AMD_LZCNT 0x00200000
+#define AV_386_SSSE3 0x00400000
+#define AV_386_SSE4_1 0x00800000
+#define AV_386_SSE4_2 0x01000000
#endif
diff --git a/softmagic.c b/softmagic.c
index 21a0148dd87f..39a7fc856520 100644
--- a/softmagic.c
+++ b/softmagic.c
@@ -38,11 +38,11 @@
#ifndef lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.103 2007/12/27 16:35:59 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.120 2008/07/28 17:25:21 christos Exp $")
#endif /* lint */
private int match(struct magic_set *, struct magic *, uint32_t,
- const unsigned char *, size_t);
+ const unsigned char *, size_t, int);
private int mget(struct magic_set *, const unsigned char *,
struct magic *, size_t, unsigned int);
private int magiccheck(struct magic_set *, struct magic *);
@@ -58,17 +58,23 @@ private void cvt_32(union VALUETYPE *, const struct magic *);
private void cvt_64(union VALUETYPE *, const struct magic *);
/*
+ * Macro to give description string according to whether we want plain
+ * text or MIME type
+ */
+#define MAGIC_DESC ((ms->flags & MAGIC_MIME) ? m->mimetype : m->desc)
+
+/*
* softmagic - lookup one file in parsed, in-memory copy of database
* Passed the name and FILE * of one file to be typed.
*/
/*ARGSUSED1*/ /* nbytes passed for regularity, maybe need later */
protected int
-file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
+file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes, int mode)
{
struct mlist *ml;
int rv;
for (ml = ms->mlist->next; ml != ms->mlist; ml = ml->next)
- if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes)) != 0)
+ if ((rv = match(ms, ml->magic, ml->nmagic, buf, nbytes, mode)) != 0)
return rv;
return 0;
@@ -103,7 +109,7 @@ file_softmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
*/
private int
match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
- const unsigned char *s, size_t nbytes)
+ const unsigned char *s, size_t nbytes, int mode)
{
uint32_t magindex = 0;
unsigned int cont_level = 0;
@@ -117,17 +123,26 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
for (magindex = 0; magindex < nmagic; magindex++) {
int flush;
+ struct magic *m = &magic[magindex];
- ms->offset = magic[magindex].offset;
- ms->line = magic[magindex].lineno;
+ if ((m->flag & BINTEST) != mode) {
+ /* Skip sub-tests */
+ while (magic[magindex + 1].cont_level != 0 &&
+ ++magindex < nmagic)
+ continue;
+ continue; /* Skip to next top-level test*/
+ }
+
+ ms->offset = m->offset;
+ ms->line = m->lineno;
/* if main entry matches, print it... */
- flush = !mget(ms, s, &magic[magindex], nbytes, cont_level);
+ flush = !mget(ms, s, m, nbytes, cont_level);
if (flush) {
- if (magic[magindex].reln == '!')
+ if (m->reln == '!')
flush = 0;
} else {
- switch (magiccheck(ms, &magic[magindex])) {
+ switch (magiccheck(ms, m)) {
case -1:
return -1;
case 0:
@@ -152,15 +167,14 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
* If we are going to print something, we'll need to print
* a blank before we print something else.
*/
- if (magic[magindex].desc[0]) {
+ if (*MAGIC_DESC) {
need_separator = 1;
printed_something = 1;
if (print_sep(ms, firstline) == -1)
return -1;
}
- if ((ms->c.li[cont_level].off = mprint(ms, &magic[magindex]))
- == -1)
+ if ((ms->c.li[cont_level].off = mprint(ms, m)) == -1)
return -1;
/* and any continuations that match */
@@ -169,36 +183,36 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
while (magic[magindex+1].cont_level != 0 &&
++magindex < nmagic) {
- ms->line = magic[magindex].lineno; /* for messages */
+ m = &magic[magindex];
+ ms->line = m->lineno; /* for messages */
- if (cont_level < magic[magindex].cont_level)
+ if (cont_level < m->cont_level)
continue;
- if (cont_level > magic[magindex].cont_level) {
+ if (cont_level > m->cont_level) {
/*
* We're at the end of the level
* "cont_level" continuations.
*/
- cont_level = magic[magindex].cont_level;
+ cont_level = m->cont_level;
}
- ms->offset = magic[magindex].offset;
- if (magic[magindex].flag & OFFADD) {
+ ms->offset = m->offset;
+ if (m->flag & OFFADD) {
ms->offset +=
ms->c.li[cont_level - 1].off;
}
#ifdef ENABLE_CONDITIONALS
- if (magic[magindex].cond == COND_ELSE ||
- magic[magindex].cond == COND_ELIF) {
+ if (m->cond == COND_ELSE ||
+ m->cond == COND_ELIF) {
if (ms->c.li[cont_level].last_match == 1)
continue;
}
#endif
- flush = !mget(ms, s, &magic[magindex], nbytes,
- cont_level);
- if (flush && magic[magindex].reln != '!')
+ flush = !mget(ms, s, m, nbytes, cont_level);
+ if (flush && m->reln != '!')
continue;
- switch (flush ? 1 : magiccheck(ms, &magic[magindex])) {
+ switch (flush ? 1 : magiccheck(ms, m)) {
case -1:
return -1;
case 0:
@@ -210,7 +224,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
#ifdef ENABLE_CONDITIONALS
ms->c.li[cont_level].last_match = 1;
#endif
- if (magic[magindex].type != FILE_DEFAULT)
+ if (m->type != FILE_DEFAULT)
ms->c.li[cont_level].got_match = 1;
else if (ms->c.li[cont_level].got_match) {
ms->c.li[cont_level].got_match = 0;
@@ -220,7 +234,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
* If we are going to print something,
* make sure that we have a separator first.
*/
- if (magic[magindex].desc[0]) {
+ if (*MAGIC_DESC) {
printed_something = 1;
if (print_sep(ms, firstline) == -1)
return -1;
@@ -233,15 +247,15 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
*/
/* space if previous printed */
if (need_separator
- && (magic[magindex].nospflag == 0)
- && (magic[magindex].desc[0] != '\0')) {
+ && ((m->flag & NOSPACE) == 0)
+ && *MAGIC_DESC) {
if (file_printf(ms, " ") == -1)
return -1;
need_separator = 0;
}
- if ((ms->c.li[cont_level].off = mprint(ms, &magic[magindex])) == -1)
+ if ((ms->c.li[cont_level].off = mprint(ms, m)) == -1)
return -1;
- if (magic[magindex].desc[0])
+ if (*MAGIC_DESC)
need_separator = 1;
/*
@@ -271,7 +285,7 @@ check_fmt(struct magic_set *ms, struct magic *m)
regex_t rx;
int rc;
- if (strchr(m->desc, '%') == NULL)
+ if (strchr(MAGIC_DESC, '%') == NULL)
return 0;
rc = regcomp(&rx, "%[-0-9\\.]*s", REG_EXTENDED|REG_NOSUB);
@@ -281,7 +295,7 @@ check_fmt(struct magic_set *ms, struct magic *m)
file_magerror(ms, "regex error %d, (%s)", rc, errmsg);
return -1;
} else {
- rc = regexec(&rx, m->desc, 0, 0, 0);
+ rc = regexec(&rx, MAGIC_DESC, 0, 0, 0);
regfree(&rx);
return !rc;
}
@@ -314,7 +328,7 @@ mprint(struct magic_set *ms, struct magic *m)
float vf;
double vd;
int64_t t = 0;
- char buf[512];
+ char *buf;
union VALUETYPE *p = &ms->ms_value;
switch (m->type) {
@@ -324,14 +338,13 @@ mprint(struct magic_set *ms, struct magic *m)
case -1:
return -1;
case 1:
- if (snprintf(buf, sizeof(buf), "%c",
- (unsigned char)v) < 0)
+ if (asprintf(&buf, "%c", (unsigned char)v) < 0)
return -1;
- if (file_printf(ms, m->desc, buf) == -1)
+ if (file_printf(ms, MAGIC_DESC, buf) == -1)
return -1;
break;
default:
- if (file_printf(ms, m->desc, (unsigned char) v) == -1)
+ if (file_printf(ms, MAGIC_DESC, (unsigned char) v) == -1)
return -1;
break;
}
@@ -346,14 +359,13 @@ mprint(struct magic_set *ms, struct magic *m)
case -1:
return -1;
case 1:
- if (snprintf(buf, sizeof(buf), "%hu",
- (unsigned short)v) < 0)
+ if (asprintf(&buf, "%hu", (unsigned short)v) < 0)
return -1;
- if (file_printf(ms, m->desc, buf) == -1)
+ if (file_printf(ms, MAGIC_DESC, buf) == -1)
return -1;
break;
default:
- if (file_printf(ms, m->desc, (unsigned short) v) == -1)
+ if (file_printf(ms, MAGIC_DESC, (unsigned short) v) == -1)
return -1;
break;
}
@@ -369,13 +381,13 @@ mprint(struct magic_set *ms, struct magic *m)
case -1:
return -1;
case 1:
- if (snprintf(buf, sizeof(buf), "%u", (uint32_t)v) < 0)
+ if (asprintf(&buf, "%u", (uint32_t)v) < 0)
return -1;
- if (file_printf(ms, m->desc, buf) == -1)
+ if (file_printf(ms, MAGIC_DESC, buf) == -1)
return -1;
break;
default:
- if (file_printf(ms, m->desc, (uint32_t) v) == -1)
+ if (file_printf(ms, MAGIC_DESC, (uint32_t) v) == -1)
return -1;
break;
}
@@ -386,7 +398,7 @@ mprint(struct magic_set *ms, struct magic *m)
case FILE_BEQUAD:
case FILE_LEQUAD:
v = file_signextend(ms, m, p->q);
- if (file_printf(ms, m->desc, (uint64_t) v) == -1)
+ if (file_printf(ms, MAGIC_DESC, (uint64_t) v) == -1)
return -1;
t = ms->offset + sizeof(int64_t);
break;
@@ -396,16 +408,18 @@ mprint(struct magic_set *ms, struct magic *m)
case FILE_BESTRING16:
case FILE_LESTRING16:
if (m->reln == '=' || m->reln == '!') {
- if (file_printf(ms, m->desc, m->value.s) == -1)
+ if (file_printf(ms, MAGIC_DESC, m->value.s) == -1)
return -1;
t = ms->offset + m->vallen;
}
else {
if (*m->value.s == '\0')
p->s[strcspn(p->s, "\n")] = '\0';
- if (file_printf(ms, m->desc, p->s) == -1)
+ if (file_printf(ms, MAGIC_DESC, p->s) == -1)
return -1;
t = ms->offset + strlen(p->s);
+ if (m->type == FILE_PSTRING)
+ t++;
}
break;
@@ -413,7 +427,7 @@ mprint(struct magic_set *ms, struct magic *m)
case FILE_BEDATE:
case FILE_LEDATE:
case FILE_MEDATE:
- if (file_printf(ms, m->desc, file_fmttime(p->l, 1)) == -1)
+ if (file_printf(ms, MAGIC_DESC, file_fmttime(p->l, 1)) == -1)
return -1;
t = ms->offset + sizeof(time_t);
break;
@@ -422,7 +436,7 @@ mprint(struct magic_set *ms, struct magic *m)
case FILE_BELDATE:
case FILE_LELDATE:
case FILE_MELDATE:
- if (file_printf(ms, m->desc, file_fmttime(p->l, 0)) == -1)
+ if (file_printf(ms, MAGIC_DESC, file_fmttime(p->l, 0)) == -1)
return -1;
t = ms->offset + sizeof(time_t);
break;
@@ -430,7 +444,7 @@ mprint(struct magic_set *ms, struct magic *m)
case FILE_QDATE:
case FILE_BEQDATE:
case FILE_LEQDATE:
- if (file_printf(ms, m->desc, file_fmttime((uint32_t)p->q, 1))
+ if (file_printf(ms, MAGIC_DESC, file_fmttime((uint32_t)p->q, 1))
== -1)
return -1;
t = ms->offset + sizeof(uint64_t);
@@ -439,7 +453,7 @@ mprint(struct magic_set *ms, struct magic *m)
case FILE_QLDATE:
case FILE_BEQLDATE:
case FILE_LEQLDATE:
- if (file_printf(ms, m->desc, file_fmttime((uint32_t)p->q, 0))
+ if (file_printf(ms, MAGIC_DESC, file_fmttime((uint32_t)p->q, 0))
== -1)
return -1;
t = ms->offset + sizeof(uint64_t);
@@ -453,13 +467,13 @@ mprint(struct magic_set *ms, struct magic *m)
case -1:
return -1;
case 1:
- if (snprintf(buf, sizeof(buf), "%g", vf) < 0)
+ if (asprintf(&buf, "%g", vf) < 0)
return -1;
- if (file_printf(ms, m->desc, buf) == -1)
+ if (file_printf(ms, MAGIC_DESC, buf) == -1)
return -1;
break;
default:
- if (file_printf(ms, m->desc, vf) == -1)
+ if (file_printf(ms, MAGIC_DESC, vf) == -1)
return -1;
break;
}
@@ -474,13 +488,13 @@ mprint(struct magic_set *ms, struct magic *m)
case -1:
return -1;
case 1:
- if (snprintf(buf, sizeof(buf), "%g", vd) < 0)
+ if (asprintf(&buf, "%g", vd) < 0)
return -1;
- if (file_printf(ms, m->desc, buf) == -1)
+ if (file_printf(ms, MAGIC_DESC, buf) == -1)
return -1;
break;
default:
- if (file_printf(ms, m->desc, vd) == -1)
+ if (file_printf(ms, MAGIC_DESC, vd) == -1)
return -1;
break;
}
@@ -496,7 +510,7 @@ mprint(struct magic_set *ms, struct magic *m)
file_oomem(ms, ms->search.rm_len);
return -1;
}
- rval = file_printf(ms, m->desc, cp);
+ rval = file_printf(ms, MAGIC_DESC, cp);
free(cp);
if (rval == -1)
@@ -510,7 +524,7 @@ mprint(struct magic_set *ms, struct magic *m)
}
case FILE_SEARCH:
- if (file_printf(ms, m->desc, m->value.s) == -1)
+ if (file_printf(ms, MAGIC_DESC, m->value.s) == -1)
return -1;
if ((m->str_flags & REGEX_OFFSET_START))
t = ms->search.offset;
@@ -519,7 +533,7 @@ mprint(struct magic_set *ms, struct magic *m)
break;
case FILE_DEFAULT:
- if (file_printf(ms, m->desc, m->value.s) == -1)
+ if (file_printf(ms, MAGIC_DESC, m->value.s) == -1)
return -1;
t = ms->offset;
break;
@@ -646,13 +660,14 @@ mconvert(struct magic_set *ms, struct magic *m)
case FILE_STRING:
case FILE_BESTRING16:
case FILE_LESTRING16: {
- size_t len;
-
/* Null terminate and eat *trailing* return */
p->s[sizeof(p->s) - 1] = '\0';
+#if 0
+ /* Why? breaks magic numbers that end with \xa */
len = strlen(p->s);
if (len-- && p->s[len] == '\n')
p->s[len] = '\0';
+#endif
return 1;
}
case FILE_PSTRING: {
@@ -663,9 +678,12 @@ mconvert(struct magic_set *ms, struct magic *m)
while (len--)
*ptr1++ = *ptr2++;
*ptr1 = '\0';
+#if 0
+ /* Why? breaks magic numbers that end with \xa */
len = strlen(p->s);
if (len-- && p->s[len] == '\n')
p->s[len] = '\0';
+#endif
return 1;
}
case FILE_BESHORT:
@@ -682,10 +700,11 @@ mconvert(struct magic_set *ms, struct magic *m)
case FILE_BEQUAD:
case FILE_BEQDATE:
case FILE_BEQLDATE:
- p->q = (int64_t)
- (((int64_t)p->hq[0]<<56)|((int64_t)p->hq[1]<<48)|
- ((int64_t)p->hq[2]<<40)|((int64_t)p->hq[3]<<32)|
- (p->hq[4]<<24)|(p->hq[5]<<16)|(p->hq[6]<<8)|(p->hq[7]));
+ p->q = (uint64_t)
+ (((uint64_t)p->hq[0]<<56)|((uint64_t)p->hq[1]<<48)|
+ ((uint64_t)p->hq[2]<<40)|((uint64_t)p->hq[3]<<32)|
+ ((uint64_t)p->hq[4]<<24)|((uint64_t)p->hq[5]<<16)|
+ ((uint64_t)p->hq[6]<<8)|((uint64_t)p->hq[7]));
cvt_64(p, m);
return 1;
case FILE_LESHORT:
@@ -702,10 +721,11 @@ mconvert(struct magic_set *ms, struct magic *m)
case FILE_LEQUAD:
case FILE_LEQDATE:
case FILE_LEQLDATE:
- p->q = (int64_t)
- (((int64_t)p->hq[7]<<56)|((int64_t)p->hq[6]<<48)|
- ((int64_t)p->hq[5]<<40)|((int64_t)p->hq[4]<<32)|
- (p->hq[3]<<24)|(p->hq[2]<<16)|(p->hq[1]<<8)|(p->hq[0]));
+ p->q = (uint64_t)
+ (((uint64_t)p->hq[7]<<56)|((uint64_t)p->hq[6]<<48)|
+ ((uint64_t)p->hq[5]<<40)|((uint64_t)p->hq[4]<<32)|
+ ((uint64_t)p->hq[3]<<24)|((uint64_t)p->hq[2]<<16)|
+ ((uint64_t)p->hq[1]<<8)|((uint64_t)p->hq[0]));
cvt_64(p, m);
return 1;
case FILE_MELONG:
@@ -778,13 +798,10 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
case FILE_SEARCH:
ms->search.s = (const char *)s + offset;
ms->search.s_len = nbytes - offset;
+ ms->search.offset = offset;
return 0;
case FILE_REGEX: {
- /*
- * offset is interpreted as last line to search,
- * (starting at 1), not as bytes-from start-of-file
- */
const char *b;
const char *c;
const char *last; /* end of search region */
@@ -879,7 +896,7 @@ mget(struct magic_set *ms, const unsigned char *s,
struct magic *m, size_t nbytes, unsigned int cont_level)
{
uint32_t offset = ms->offset;
- uint32_t count = m->str_count;
+ uint32_t count = m->str_range;
union VALUETYPE *p = &ms->ms_value;
if (mcopy(ms, p, m->type, m->flag & INDIR, s, offset, nbytes, count) == -1)
@@ -893,8 +910,8 @@ mget(struct magic_set *ms, const unsigned char *s,
if (m->flag & INDIR) {
int off = m->in_offset;
if (m->in_op & FILE_OPINDIRECT) {
- const union VALUETYPE *q =
- ((const void *)(s + offset + off));
+ const union VALUETYPE *q = CAST(const union VALUETYPE *,
+ ((const void *)(s + offset + off)));
switch (m->in_type) {
case FILE_BYTE:
off = q->b;
@@ -1340,13 +1357,6 @@ mget(struct magic_set *ms, const unsigned char *s,
case FILE_OPMODULO:
offset = p->l % off;
break;
- /* case TOOMANYSWITCHBLOCKS:
- * ugh = p->eye % m->strain;
- * rub;
- * case BEER:
- * off = p->tab & m->in_gest;
- * sleep;
- */
}
} else
offset = p->l;
@@ -1443,10 +1453,8 @@ file_strncmp(const char *s1, const char *s2, size_t len, uint32_t flags)
uint64_t v;
/*
- * What we want here is:
- * v = strncmp(m->value.s, p->s, m->vallen);
- * but ignoring any nulls. bcmp doesn't give -/+/0
- * and isn't universally available anyway.
+ * What we want here is v = strncmp(s1, s2, len),
+ * but ignoring any nulls.
*/
v = 0;
if (0L == flags) { /* normal string: do it fast */
@@ -1646,15 +1654,14 @@ magiccheck(struct magic_set *ms, struct magic *m)
slen = MIN(m->vallen, sizeof(m->value.s));
l = 0;
v = 0;
- ms->search.offset = m->offset;
- for (idx = 0; m->str_count == 0 || idx < m->str_count; idx++) {
+ for (idx = 0; m->str_range == 0 || idx < m->str_range; idx++) {
if (slen + idx > ms->search.s_len)
break;
v = file_strncmp(m->value.s, ms->search.s + idx, slen, m->str_flags);
if (v == 0) { /* found match */
- ms->search.offset = m->offset + idx;
+ ms->search.offset += idx;
break;
}
}
diff --git a/tar.h b/tar.h
index 30d386baa6fd..fa2390ab7d69 100644
--- a/tar.h
+++ b/tar.h
@@ -32,20 +32,10 @@
*
* Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
*
- * $File: tar.h,v 1.11 2007/01/16 14:56:45 ljt Exp $ # checkin only
+ * $File: tar.h,v 1.12 2008/02/07 00:58:52 christos Exp $ # checkin only
*/
/*
- * Kludge for handling systems that cannot cope with multiple
- * external definitions of a variable. In ONE routine (tar.c),
- * we #define TAR_EXTERN to null; here, we set it to "extern" if
- * it is not already set.
- */
-#ifndef TAR_EXTERN
-#define TAR_EXTERN extern
-#endif
-
-/*
* Header block on tape.
*
* I'm going to use traditional DP naming conventions here.
@@ -78,58 +68,6 @@ union record {
} header;
};
-/* The checksum field is filled with this while the checksum is computed. */
-#define CHKBLANKS " " /* 8 blanks, no null */
-
/* The magic field is filled with this if uname and gname are valid. */
#define TMAGIC "ustar" /* 5 chars and a null */
#define GNUTMAGIC "ustar " /* 7 chars and a null */
-
-/* The linkflag defines the type of file */
-#define LF_OLDNORMAL '\0' /* Normal disk file, Unix compat */
-#define LF_NORMAL '0' /* Normal disk file */
-#define LF_LINK '1' /* Link to previously dumped file */
-#define LF_SYMLINK '2' /* Symbolic link */
-#define LF_CHR '3' /* Character special file */
-#define LF_BLK '4' /* Block special file */
-#define LF_DIR '5' /* Directory */
-#define LF_FIFO '6' /* FIFO special file */
-#define LF_CONTIG '7' /* Contiguous file */
-/* Further link types may be defined later. */
-
-/*
- * Exit codes from the "tar" program
- */
-#define EX_SUCCESS 0 /* success! */
-#define EX_ARGSBAD 1 /* invalid args */
-#define EX_BADFILE 2 /* invalid filename */
-#define EX_BADARCH 3 /* bad archive */
-#define EX_SYSTEM 4 /* system gave unexpected error */
-
-/*
- * Structure for keeping track of filenames and lists thereof.
- */
-struct name {
- struct name *next;
- short length;
- char found;
- char name[NAMSIZ+1];
-};
-
-/*
- *
- * Due to the next struct declaration, each routine that includes
- * "tar.h" must also include <sys/types.h>. I tried to make it automatic,
- * but System V has no defines in <sys/types.h>, so there is no way of
- * knowing when it has been included. In addition, it cannot be included
- * twice, but must be included exactly once. Argghh!
- *
- * Thanks, typedef. Thanks, USG.
- */
-struct link {
- struct link *next;
- dev_t dev;
- ino_t ino;
- short linkcount;
- char name[NAMSIZ+1];
-};
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 000000000000..3e0a2e60c4d1
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,11 @@
+check_PROGRAMS = test
+test_LDADD = $(top_builddir)/src/libmagic.la
+test_CPPFLAGS = -I$(top_builddir)/src
+
+EXTRA_DIST = \
+ gedcom.magic gedcom.testfile gedcom.result
+
+T = $(top_srcdir)/tests
+check-local:
+ MAGIC=$(top_builddir)/magic/magic ./test
+ for i in $T/*.testfile; do MAGIC=$T/$${i%%.testfile}.magic $(top_builddir)/tests/test $T/$$i $T/$${i%%.testfile}.result; done
diff --git a/tests/Makefile.in b/tests/Makefile.in
new file mode 100644
index 000000000000..5d9de025cd17
--- /dev/null
+++ b/tests/Makefile.in
@@ -0,0 +1,455 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# This Makefile.in 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+check_PROGRAMS = test$(EXEEXT)
+subdir = tests
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+test_SOURCES = test.c
+test_OBJECTS = test-test.$(OBJEXT)
+test_DEPENDENCIES = $(top_builddir)/src/libmagic.la
+DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = test.c
+DIST_SOURCES = test.c
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+WARNINGS = @WARNINGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+fsect = @fsect@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+test_LDADD = $(top_builddir)/src/libmagic.la
+test_CPPFLAGS = -I$(top_builddir)/src
+EXTRA_DIST = \
+ gedcom.magic gedcom.testfile gedcom.result
+
+T = $(top_srcdir)/tests
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu tests/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *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);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-checkPROGRAMS:
+ @list='$(check_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+test$(EXEEXT): $(test_OBJECTS) $(test_DEPENDENCIES)
+ @rm -f test$(EXEEXT)
+ $(LINK) $(test_OBJECTS) $(test_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-test.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+test-test.o: test.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test-test.o -MD -MP -MF $(DEPDIR)/test-test.Tpo -c -o test-test.o `test -f 'test.c' || echo '$(srcdir)/'`test.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-test.Tpo $(DEPDIR)/test-test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test.c' object='test-test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test-test.o `test -f 'test.c' || echo '$(srcdir)/'`test.c
+
+test-test.obj: test.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test-test.obj -MD -MP -MF $(DEPDIR)/test-test.Tpo -c -o test-test.obj `if test -f 'test.c'; then $(CYGPATH_W) 'test.c'; else $(CYGPATH_W) '$(srcdir)/test.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/test-test.Tpo $(DEPDIR)/test-test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='test.c' object='test-test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test-test.obj `if test -f 'test.c'; then $(CYGPATH_W) 'test.c'; else $(CYGPATH_W) '$(srcdir)/test.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+ $(MAKE) $(AM_MAKEFLAGS) check-local
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+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
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am check-local clean \
+ clean-checkPROGRAMS clean-generic clean-libtool ctags \
+ 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 uninstall uninstall-am
+
+check-local:
+ MAGIC=$(top_builddir)/magic/magic ./test
+ for i in $T/*.testfile; do MAGIC=$T/$${i%%.testfile}.magic $(top_builddir)/tests/test $T/$$i $T/$${i%%.testfile}.result; done
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/README b/tests/README
new file mode 100644
index 000000000000..31f9b14e02e4
--- /dev/null
+++ b/tests/README
@@ -0,0 +1,17 @@
+file tests
+==========
+
+This directory contains tests for file. It is highly encouraged to add
+one each time a bug is found, and each time new magic is added. Each
+test consists of three files:
+
+ TEST.magic
+ TEST.testfile
+ TEST.result
+
+where TEST is the base name of the test, TEST.magic contains the magic
+used, TEST.testfile is the input, and TEST.result is the desired
+output from file.
+
+It suffices to add a triplet of test files to the directory to have
+them included in "make check".
diff --git a/tests/gedcom.magic b/tests/gedcom.magic
new file mode 100644
index 000000000000..616fd56b6956
--- /dev/null
+++ b/tests/gedcom.magic
@@ -0,0 +1,6 @@
+# GEDCOM Genealogy file
+
+0 string/c 0\ HEAD GEDCOM genealogy data
+>&0 search 1\ GEDC
+>>&0 search 2\ VERS version
+>>>&1 string >\0 %s
diff --git a/tests/gedcom.result b/tests/gedcom.result
new file mode 100644
index 000000000000..bbb0eb86c7a8
--- /dev/null
+++ b/tests/gedcom.result
@@ -0,0 +1 @@
+GEDCOM genealogy data version 5.5 \ No newline at end of file
diff --git a/tests/gedcom.testfile b/tests/gedcom.testfile
new file mode 100644
index 000000000000..3d9607e9a23b
--- /dev/null
+++ b/tests/gedcom.testfile
@@ -0,0 +1,8 @@
+0 HEAD
+1 SOUR GENJ
+2 VERS 2.x
+1 GEDC
+2 VERS 5.5
+2 FORM Lineage-Linked
+1 CHAR UNICODE
+1 LANG Italian
diff --git a/tests/test.c b/tests/test.c
new file mode 100644
index 000000000000..db91c62f2ece
--- /dev/null
+++ b/tests/test.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) Christos Zoulas 2003.
+ * 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 immediately at the beginning of the file, without modification,
+ * 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 AUTHOR 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 AUTHOR 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "magic.h"
+
+static void *
+xrealloc(void *p, size_t n)
+{
+ p = realloc(p, n);
+ if (p == NULL) {
+ (void)fprintf(stderr, "ERROR slurping file: out of memory\n");
+ exit(10);
+ }
+ return p;
+}
+
+static char *
+slurp(FILE *fp, size_t *final_len)
+{
+ size_t len = 256;
+ int c;
+ char *l = (char *)xrealloc(NULL, len), *s = l;
+
+ for (c = getc(fp); c != EOF; c = getc(fp)) {
+ if (s == l + len) {
+ l = (char *)xrealloc(l, len * 2);
+ len *= 2;
+ }
+ *s++ = c;
+ }
+ if (s == l + len)
+ l = (char *)xrealloc(l, len + 1);
+ *s++ = '\0';
+
+ *final_len = s - l;
+ l = (char *)xrealloc(l, s - l);
+ return l;
+}
+
+int
+main(int argc, char **argv)
+{
+ struct magic_set *ms;
+ const char *result;
+ char *desired;
+ size_t desired_len;
+ int i;
+ FILE *fp;
+
+ ms = magic_open(MAGIC_NONE);
+ if (ms == NULL) {
+ (void)fprintf(stderr, "ERROR opening MAGIC_NONE: out of memory\n");
+ return 10;
+ }
+ if (magic_load(ms, NULL) == -1) {
+ (void)fprintf(stderr, "ERROR loading with NULL file: %s\n", magic_error(ms));
+ return 11;
+ }
+
+ if (argc > 1) {
+ if (argc != 3) {
+ (void)fprintf(stderr, "Usage: test TEST-FILE RESULT\n");
+ } else {
+ if ((result = magic_file(ms, argv[1])) == NULL) {
+ (void)fprintf(stderr, "ERROR loading file %s: %s\n", argv[1], magic_error(ms));
+ return 12;
+ } else {
+ fp = fopen(argv[2], "r");
+ if (fp == NULL) {
+ (void)fprintf(stderr, "ERROR opening `%s': ", argv[2]);
+ perror(NULL);
+ return 13;
+ }
+ desired = slurp(fp, &desired_len);
+ fclose(fp);
+ (void)printf("%s: %s\n", argv[1], result);
+ if (strcmp(result, desired) != 0) {
+ (void)fprintf(stderr, "Error: result was\n%s\nexpected:\n%s\n", result, desired);
+ return 1;
+ }
+ }
+ }
+ }
+
+ magic_close(ms);
+ return 0;
+}
diff --git a/vasprintf.c b/vasprintf.c
new file mode 100644
index 000000000000..0289c0d88b4f
--- /dev/null
+++ b/vasprintf.c
@@ -0,0 +1,641 @@
+/*
+ * Copyright (c) Ian F. Darwin 1986-1995.
+ * Software written by Ian F. Darwin and others;
+ * maintained 1995-present by Christos Zoulas and others.
+ *
+ * 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 immediately at the beginning of the file, without modification,
+ * 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 AUTHOR 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 AUTHOR 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.
+ */
+/*###########################################################################
+ # #
+ # vasprintf #
+ # #
+ # Copyright (c) 2002-2005 David TAILLANDIER #
+ # #
+ ###########################################################################*/
+
+/*
+
+This software is distributed under the "modified BSD licence".
+
+This software is also released with GNU license (GPL) in another file (same
+source-code, only license differ).
+
+
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer. 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. The name of the author may not be used to
+endorse or promote products derived from this software without specific
+prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+
+====================
+
+Hacked from xnprintf version of 26th February 2005 to provide only
+vasprintf by Reuben Thomas <rrt@sc3d.org>.
+
+====================
+
+
+'printf' function family use the following format string:
+
+%[flag][width][.prec][modifier]type
+
+%% is the escape sequence to print a '%'
+% followed by an unknown format will print the characters without
+trying to do any interpretation
+
+flag: none + - # (blank)
+width: n 0n *
+prec: none .0 .n .*
+modifier: F N L h l ll ('F' and 'N' are ms-dos/16-bit specific)
+type: d i o u x X f e g E G c s p n
+
+
+The function needs to allocate memory to store the full text before to
+actually writting it. i.e if you want to fnprintf() 1000 characters, the
+functions will allocate 1000 bytes.
+This behaviour can be modified: you have to customise the code to flush the
+internal buffer (writing to screen or file) when it reach a given size. Then
+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.
+
+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
+code to handle those situations (only one place to modify).
+A buffer overflow can only occur if your sprintf() do strange things or when
+you use strange formats.
+
+*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <ctype.h>
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#define ALLOC_CHUNK 2048
+#define ALLOC_SECURITY_MARGIN 1024 /* big value because some platforms have very big 'G' exponent */
+#if ALLOC_CHUNK < ALLOC_SECURITY_MARGIN
+# error !!! ALLOC_CHUNK < ALLOC_SECURITY_MARGIN !!!
+#endif
+/* note: to have some interest, ALLOC_CHUNK should be much greater than ALLOC_SECURITY_MARGIN */
+
+/*
+ * To save a lot of push/pop, every variable are stored into this
+ * structure, which is passed among nearly every sub-functions.
+ */
+typedef struct {
+ const char * src_string; /* current position into intput string */
+ char * buffer_base; /* output buffer */
+ char * dest_string; /* current position into output string */
+ size_t buffer_len; /* length of output buffer */
+ size_t real_len; /* real current length of output text */
+ size_t pseudo_len; /* total length of output text if it were not limited in size */
+ size_t maxlen;
+ va_list vargs; /* pointer to current position into vargs */
+ char * sprintf_string;
+ FILE * fprintf_file;
+} xprintf_struct;
+
+/*
+ * Realloc buffer if needed
+ * Return value: 0 = ok
+ * EOF = not enought memory
+ */
+static int realloc_buff(xprintf_struct *s, size_t len)
+{
+ char * ptr;
+
+ if (len + ALLOC_SECURITY_MARGIN + s->real_len > s->buffer_len) {
+ len += s->real_len + ALLOC_CHUNK;
+ ptr = (char *)realloc((void *)(s->buffer_base), len);
+ if (ptr == NULL) {
+ s->buffer_base = NULL;
+ return EOF;
+ }
+
+ s->dest_string = ptr + (size_t)(s->dest_string - s->buffer_base);
+ s->buffer_base = ptr;
+ s->buffer_len = len;
+
+ (s->buffer_base)[s->buffer_len - 1] = 1; /* overflow marker */
+ }
+
+ return 0;
+}
+
+/*
+ * Prints 'usual' characters up to next '%'
+ * or up to end of text
+ */
+static int usual_char(xprintf_struct * s)
+{
+ size_t len;
+
+ len = strcspn(s->src_string, "%"); /* reachs the next '%' or end of input string */
+ /* note: 'len' is never 0 because the presence of '%' */
+ /* or end-of-line is checked in the calling function */
+
+ if (realloc_buff(s,len) == EOF)
+ return EOF;
+
+ memcpy(s->dest_string, s->src_string, len);
+ s->src_string += len;
+ s->dest_string += len;
+ s->real_len += len;
+ s->pseudo_len += len;
+
+ return 0;
+}
+
+/*
+ * Return value: 0 = ok
+ * EOF = error
+ */
+static int print_it(xprintf_struct *s, size_t approx_len,
+ const char *format_string, ...)
+{
+ va_list varg;
+ int vsprintf_len;
+ size_t len;
+
+ if (realloc_buff(s,approx_len) == EOF)
+ return EOF;
+
+ va_start(varg, format_string);
+ vsprintf_len = vsprintf(s->dest_string, format_string, varg);
+ va_end(varg);
+
+ /* Check for overflow */
+ assert((s->buffer_base)[s->buffer_len - 1] == 1);
+
+ if (vsprintf_len == EOF) /* must be done *after* overflow-check */
+ return EOF;
+
+ s->pseudo_len += vsprintf_len;
+ len = strlen(s->dest_string);
+ s->real_len += len;
+ s->dest_string += len;
+
+ return 0;
+}
+
+/*
+ * Prints a string (%s)
+ * We need special handling because:
+ * a: the length of the string is unknown
+ * b: when .prec is used, we must not access any extra byte of the
+ * string (of course, if the original sprintf() does... what the
+ * hell, not my problem)
+ *
+ * Return value: 0 = ok
+ * EOF = error
+ */
+static int type_s(xprintf_struct *s, int width, int prec,
+ const char *format_string, const char *arg_string)
+{
+ size_t string_len;
+
+ if (arg_string == NULL)
+ return print_it(s, (size_t)6, "(null)", 0);
+
+ /* hand-made strlen() whitch stops when 'prec' is reached. */
+ /* if 'prec' is -1 then it is never reached. */
+ string_len = 0;
+ while (arg_string[string_len] != 0 && (size_t)prec != string_len)
+ string_len++;
+
+ if (width != -1 && string_len < (size_t)width)
+ string_len = (size_t)width;
+
+ return print_it(s, string_len, format_string, arg_string);
+}
+
+/*
+ * Read a serie of digits. Stop when non-digit is found.
+ * Return value: the value read (between 0 and 32767).
+ * Note: no checks are made against overflow. If the string contain a big
+ * number, then the return value won't be what we want (but, in this case,
+ * the programmer don't know whatr he wants, then no problem).
+ */
+static int getint(const char **string)
+{
+ int i = 0;
+
+ while (isdigit((unsigned char)**string) != 0) {
+ i = i * 10 + (**string - '0');
+ (*string)++;
+ }
+
+ if (i < 0 || i > 32767)
+ i = 32767; /* if we have i==-10 this is not because the number is */
+ /* negative; this is because the number is big */
+ return i;
+}
+
+/*
+ * Read a part of the format string. A part is 'usual characters' (ie "blabla")
+ * or '%%' escape sequence (to print a single '%') or any combination of
+ * format specifier (ie "%i" or "%10.2d").
+ * After the current part is managed, the function returns to caller with
+ * everything ready to manage the following part.
+ * The caller must ensure than the string is not empty, i.e. the first byte
+ * is not zero.
+ *
+ * Return value: 0 = ok
+ * EOF = error
+ */
+static int dispatch(xprintf_struct *s)
+{
+ const char *initial_ptr;
+ char format_string[24]; /* max length may be something like "% +-#032768.32768Ld" */
+ char *format_ptr;
+ int flag_plus, flag_minus, flag_space, flag_sharp, flag_zero;
+ int width, prec, modifier, approx_width;
+ char type;
+ /* most of those variables are here to rewrite the format string */
+
+#define SRCTXT (s->src_string)
+#define DESTTXT (s->dest_string)
+
+ /* incoherent format string. Characters after the '%' will be printed with the next call */
+#define INCOHERENT() do {SRCTXT=initial_ptr; return 0;} while (0) /* do/while to avoid */
+#define INCOHERENT_TEST() do {if(*SRCTXT==0) INCOHERENT();} while (0) /* a null statement */
+
+ /* 'normal' text */
+ if (*SRCTXT != '%')
+ return usual_char(s);
+
+ /* we then have a '%' */
+ SRCTXT++;
+ /* don't check for end-of-string ; this is done later */
+
+ /* '%%' escape sequence */
+ if (*SRCTXT == '%') {
+ if (realloc_buff(s, (size_t)1) == EOF) /* because we can have "%%%%%%%%..." */
+ return EOF;
+ *DESTTXT = '%';
+ DESTTXT++;
+ SRCTXT++;
+ (s->real_len)++;
+ (s->pseudo_len)++;
+ return 0;
+ }
+
+ /* '%' managing */
+ initial_ptr = SRCTXT; /* save current pointer in case of incorrect */
+ /* 'decoding'. Points just after the '%' so the '%' */
+ /* won't be printed in any case, as required. */
+
+ /* flag */
+ flag_plus = flag_minus = flag_space = flag_sharp = flag_zero = 0;
+
+ for (;; SRCTXT++) {
+ if (*SRCTXT == ' ')
+ flag_space = 1;
+ else if (*SRCTXT == '+')
+ flag_plus = 1;
+ else if (*SRCTXT == '-')
+ flag_minus = 1;
+ else if (*SRCTXT == '#')
+ flag_sharp = 1;
+ else if (*SRCTXT == '0')
+ flag_zero = 1;
+ else
+ break;
+ }
+
+ INCOHERENT_TEST(); /* here is the first test for end of string */
+
+ /* width */
+ if (*SRCTXT == '*') { /* width given by next argument */
+ SRCTXT++;
+ width = va_arg(s->vargs, int);
+ if ((size_t)width > 0x3fffU) /* 'size_t' to check against negative values too */
+ width = 0x3fff;
+ } else if (isdigit((unsigned char)*SRCTXT)) /* width given as ASCII number */
+ width = getint(&SRCTXT);
+ else
+ width = -1; /* no width specified */
+
+ INCOHERENT_TEST();
+
+ /* .prec */
+ if (*SRCTXT == '.') {
+ SRCTXT++;
+ if (*SRCTXT == '*') { /* .prec given by next argument */
+ SRCTXT++;
+ prec = va_arg(s->vargs, int);
+ if ((size_t)prec >= 0x3fffU) /* 'size_t' to check against negative values too */
+ prec = 0x3fff;
+ } else { /* .prec given as ASCII number */
+ if (isdigit((unsigned char)*SRCTXT) == 0)
+ INCOHERENT();
+ prec = getint(&SRCTXT);
+ }
+ INCOHERENT_TEST();
+ } else
+ prec = -1; /* no .prec specified */
+
+ /* modifier */
+ if (*SRCTXT == 'L' || *SRCTXT == 'h' || *SRCTXT == 'l') {
+ modifier = *SRCTXT;
+ SRCTXT++;
+ if (modifier=='l' && *SRCTXT=='l') {
+ SRCTXT++;
+ modifier = 'L'; /* 'll' == 'L' long long == long double */
+ } /* only for compatibility ; not portable */
+ INCOHERENT_TEST();
+ } else
+ modifier = -1; /* no modifier specified */
+
+ /* type */
+ type = *SRCTXT;
+ if (strchr("diouxXfegEGcspn",type) == NULL)
+ INCOHERENT(); /* unknown type */
+ SRCTXT++;
+
+ /* rewrite format-string */
+ format_string[0] = '%';
+ format_ptr = &(format_string[1]);
+
+ if (flag_plus) {
+ *format_ptr = '+';
+ format_ptr++;
+ }
+ if (flag_minus) {
+ *format_ptr = '-';
+ format_ptr++;
+ }
+ if (flag_space) {
+ *format_ptr = ' ';
+ format_ptr++;
+ }
+ if (flag_sharp) {
+ *format_ptr = '#';
+ format_ptr++;
+ }
+ if (flag_zero) {
+ *format_ptr = '0';
+ format_ptr++;
+ } /* '0' *must* be the last one */
+
+ if (width != -1) {
+ sprintf(format_ptr, "%i", width);
+ format_ptr += strlen(format_ptr);
+ }
+
+ if (prec != -1) {
+ *format_ptr = '.';
+ format_ptr++;
+ sprintf(format_ptr, "%i", prec);
+ format_ptr += strlen(format_ptr);
+ }
+
+ if (modifier != -1) {
+ if (modifier == 'L' && strchr("diouxX",type) != NULL) {
+ *format_ptr = 'l';
+ format_ptr++;
+ *format_ptr = 'l';
+ format_ptr++;
+ } else {
+ *format_ptr = modifier;
+ format_ptr++;
+ }
+ }
+
+ *format_ptr = type;
+ format_ptr++;
+ *format_ptr = 0;
+
+ /* vague approximation of minimal length if width or prec are specified */
+ approx_width = width + prec;
+ if (approx_width < 0) /* because width == -1 and/or prec == -1 */
+ approx_width = 0;
+
+ switch (type) {
+ /* int */
+ case 'd':
+ case 'i':
+ case 'o':
+ case 'u':
+ case 'x':
+ case 'X':
+ switch (modifier) {
+ case -1 :
+ return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, int));
+ case 'L':
+ return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, long long int));
+ case 'l':
+ return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, long int));
+ case 'h':
+ return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, int));
+ /* 'int' instead of 'short int' because default promotion is 'int' */
+ default:
+ INCOHERENT();
+ }
+
+ /* char */
+ case 'c':
+ if (modifier != -1)
+ INCOHERENT();
+ return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, int));
+ /* 'int' instead of 'char' because default promotion is 'int' */
+
+ /* math */
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'E':
+ case 'G':
+ switch (modifier) {
+ case -1 : /* because of default promotion, no modifier means 'l' */
+ case 'l':
+ return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, double));
+ case 'L':
+ return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, long double));
+ default:
+ INCOHERENT();
+ }
+
+ /* string */
+ case 's':
+ return type_s(s, width, prec, format_string, va_arg(s->vargs, const char*));
+
+ /* pointer */
+ case 'p':
+ if (modifier == -1)
+ return print_it(s, (size_t)approx_width, format_string, va_arg(s->vargs, void *));
+ INCOHERENT();
+
+ /* store */
+ case 'n':
+ if (modifier == -1) {
+ int * p;
+ p = va_arg(s->vargs, int *);
+ if (p != NULL) {
+ *p = s->pseudo_len;
+ return 0;
+ }
+ return EOF;
+ }
+ INCOHERENT();
+
+ } /* switch */
+
+ INCOHERENT(); /* unknown type */
+
+#undef INCOHERENT
+#undef INCOHERENT_TEST
+#undef SRCTXT
+#undef DESTTXT
+}
+
+/*
+ * Return value: number of *virtually* written characters
+ * EOF = error
+ */
+static int core(xprintf_struct *s)
+{
+ size_t len, save_len;
+ char *dummy_base;
+
+ /* basic checks */
+ if ((int)(s->maxlen) <= 0) /* 'int' to check against some conversion */
+ return EOF; /* error for example if value is (int)-10 */
+ s->maxlen--; /* because initial maxlen counts final 0 */
+ /* note: now 'maxlen' _can_ be zero */
+
+ if (s->src_string == NULL)
+ s->src_string = "(null)";
+
+ /* struct init and memory allocation */
+ s->buffer_base = NULL;
+ s->buffer_len = 0;
+ s->real_len = 0;
+ s->pseudo_len = 0;
+ if (realloc_buff(s, (size_t)0) == EOF)
+ return EOF;
+ s->dest_string = s->buffer_base;
+
+ /* process source string */
+ for (;;) {
+ /* up to end of source string */
+ if (*(s->src_string) == 0) {
+ *(s->dest_string) = 0; /* final 0 */
+ len = s->real_len + 1;
+ break;
+ }
+
+ if (dispatch(s) == EOF)
+ goto free_EOF;
+
+ /* up to end of dest string */
+ if (s->real_len >= s->maxlen) {
+ (s->buffer_base)[s->maxlen] = 0; /* final 0 */
+ len = s->maxlen + 1;
+ break;
+ }
+ }
+
+ /* for (v)asnprintf */
+ dummy_base = s->buffer_base;
+ save_len = 0; /* just to avoid a compiler warning */
+
+ dummy_base = s->buffer_base + s->real_len;
+ save_len = s->real_len;
+
+ /* process the remaining of source string to compute 'pseudo_len'. We
+ * overwrite again and again, starting at 'dummy_base' because we don't
+ * need the text, only char count. */
+ while(*(s->src_string) != 0) { /* up to end of source string */
+ s->real_len = 0;
+ s->dest_string = dummy_base;
+ if (dispatch(s) == EOF)
+ goto free_EOF;
+ }
+
+ s->buffer_base = (char *)realloc((void *)(s->buffer_base), save_len + 1);
+ if (s->buffer_base == NULL)
+ return EOF; /* should rarely happen because we shrink the buffer */
+ return s->pseudo_len;
+
+ free_EOF:
+ if (s->buffer_base != NULL)
+ free(s->buffer_base);
+ return EOF;
+}
+
+int vasprintf(char **ptr, const char *format_string, va_list vargs)
+{
+ xprintf_struct s;
+ int retval;
+
+ s.src_string = format_string;
+#ifdef va_copy
+ va_copy (s.vargs, vargs);
+#else
+#ifdef __va_copy
+ __va_copy (s.vargs, vargs);
+#else
+ memcpy (&s.vargs, vargs, sizeof (va_list));
+#endif /* __va_copy */
+#endif /* va_copy */
+ s.maxlen = (size_t)INT_MAX;
+
+ retval = core(&s);
+ va_end(s.vargs);
+ if (retval == EOF) {
+ *ptr = NULL;
+ return EOF;
+ }
+
+ *ptr = s.buffer_base;
+ return retval;
+}