resolve conflicts
This commit is contained in:
parent
f28852500d
commit
2344ff9853
2
external/bsd/file/dist/Makefile.am
vendored
2
external/bsd/file/dist/Makefile.am
vendored
@ -1,4 +1,4 @@
|
||||
#ACLOCAL_AMFLAGS = -I m4
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
EXTRA_DIST = MAINT
|
||||
|
||||
|
29
external/bsd/file/dist/Makefile.in
vendored
29
external/bsd/file/dist/Makefile.in
vendored
@ -13,8 +13,6 @@
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
#ACLOCAL_AMFLAGS = -I m4
|
||||
VPATH = @srcdir@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
@ -39,8 +37,10 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
|
||||
TODO compile config.guess config.sub depcomp install-sh \
|
||||
ltmain.sh missing
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
|
||||
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
|
||||
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
@ -86,38 +86,40 @@ CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
FFLAGS = @FFLAGS@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MINGW = @MINGW@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
@ -137,8 +139,7 @@ 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@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
@ -170,6 +171,7 @@ libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
lt_ECHO = @lt_ECHO@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
@ -184,6 +186,7 @@ sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
EXTRA_DIST = MAINT
|
||||
SUBDIRS = src magic
|
||||
#SUBDIRS = src magic tests doc python
|
||||
|
16787
external/bsd/file/dist/configure
vendored
16787
external/bsd/file/dist/configure
vendored
File diff suppressed because it is too large
Load Diff
203
external/bsd/file/dist/doc/file.1
vendored
203
external/bsd/file/dist/doc/file.1
vendored
@ -1,7 +1,7 @@
|
||||
.\" $NetBSD: file.1,v 1.5 2010/05/14 16:51:32 joerg Exp $
|
||||
.\" $NetBSD: file.1,v 1.6 2011/05/13 01:52:13 christos Exp $
|
||||
.\"
|
||||
.\" $File: file.man,v 1.79 2008/11/06 22:49:08 rrt Exp $
|
||||
.Dd October 9, 2008
|
||||
.\" $File: file.man,v 1.94 2011/04/20 19:08:44 christos Exp $
|
||||
.Dd April 20, 2011
|
||||
.Dt FILE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -9,20 +9,24 @@
|
||||
.Nd determine file type
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl 0bchikLNnprsvz
|
||||
.Bk -words
|
||||
.Op Fl bchiklLNnprsvz0
|
||||
.Op Fl Fl apple
|
||||
.Op Fl Fl mime-encoding
|
||||
.Op Fl Fl mime-type
|
||||
.Op Fl e Ar testname
|
||||
.Op Fl F Ar separator
|
||||
.Op Fl f Ar namefile
|
||||
.Op Fl m Ar magicfiles
|
||||
.Op Fl Fl mime-encoding
|
||||
.Op Fl Fl mime-type
|
||||
.Ar file
|
||||
.Ar
|
||||
.Ek
|
||||
.Nm
|
||||
.Fl C
|
||||
.Op Fl m Ar magicfile
|
||||
.Op Fl m Ar magicfiles
|
||||
.Nm
|
||||
.Op Fl Fl help
|
||||
.Sh DESCRIPTION
|
||||
This manual page documents version 5.03 of the
|
||||
This manual page documents version 5.07 of the
|
||||
.Nm
|
||||
command.
|
||||
.Pp
|
||||
@ -162,7 +166,7 @@ in any of the character sets listed above is simply said to be
|
||||
.Dq data .
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width indent
|
||||
.It Fl 0 , -print0
|
||||
.It Fl 0 , Fl Fl print0
|
||||
Output a null character
|
||||
.Sq \e0
|
||||
after the end of the filename.
|
||||
@ -172,15 +176,15 @@ the output.
|
||||
This does not affect the separator which is still printed.
|
||||
.It Fl b , Fl Fl brief
|
||||
Do not prepend filenames to output lines (brief mode).
|
||||
.It Fl C , Fl Fl compile
|
||||
Write a
|
||||
.Pa magic.mgc
|
||||
output file that contains a pre-parsed version of the magic file or directory.
|
||||
.It Fl c , Fl Fl checking-printout
|
||||
Cause a checking printout of the parsed form of the magic file.
|
||||
This is usually used in conjunction with the
|
||||
.Fl m
|
||||
flag to debug a new magic file before installing it.
|
||||
.It Fl C , Fl Fl compile
|
||||
Write a
|
||||
.Pa magic.mgc
|
||||
output file that contains a pre-parsed version of the magic file or directory.
|
||||
.It Fl e , Fl Fl exclude Ar testname
|
||||
Exclude the test named in
|
||||
.Ar testname
|
||||
@ -190,10 +194,10 @@ Valid test names are:
|
||||
.It apptype
|
||||
.Dv EMX
|
||||
application type (only on EMX).
|
||||
.It text
|
||||
.It ascii
|
||||
Various types of text files (this test will try to guess the text
|
||||
encoding, irrespective of the setting of the
|
||||
.Dq encoding
|
||||
.Sq encoding
|
||||
option).
|
||||
.It encoding
|
||||
Different text encodings for soft magic tests.
|
||||
@ -227,20 +231,16 @@ to test the standard input, use
|
||||
.Sq -
|
||||
as a filename argument.
|
||||
.It Fl h , Fl Fl no-dereference
|
||||
Do not follow symlinks
|
||||
option causes symlinks not to be followed
|
||||
(on systems that support symbolic links).
|
||||
This is the default if the environment variable
|
||||
.Ev POSIXLY_CORRECT
|
||||
.Dv POSIXLY_CORRECT
|
||||
is not defined.
|
||||
.It Fl Fl help
|
||||
Print a help message and exit.
|
||||
.It Fl i , Fl Fl mime
|
||||
Output mime type strings rather than the more
|
||||
Causes the file command to output mime type strings rather than the more
|
||||
traditional human readable ones.
|
||||
Thus
|
||||
.Nm
|
||||
may say
|
||||
.Dq text/plain; charset=us-ascii
|
||||
Thus it may say
|
||||
.Sq text/plain; charset=us-ascii
|
||||
rather than
|
||||
.Dq ASCII text .
|
||||
In order for this option to work,
|
||||
@ -259,20 +259,25 @@ Like
|
||||
but print only the specified element(s).
|
||||
.It Fl k , Fl Fl keep-going
|
||||
Don't stop at the first match, keep going.
|
||||
Subsequent matches will have the string
|
||||
.Dq "\[rs]012\- "
|
||||
Subsequent matches will be
|
||||
have the string
|
||||
.Sq "\[rs]012\- "
|
||||
prepended.
|
||||
(If you want a newline, see the
|
||||
.Fl r
|
||||
option.)
|
||||
.It Fl l , Fl Fl list
|
||||
Print information about the strength of each magic pattern.
|
||||
.It Fl L , Fl Fl dereference
|
||||
Follow symlinks, as the like-named option in
|
||||
option causes symlinks to be followed, as the like-named option in
|
||||
.Xr ls 1
|
||||
(on systems that support symbolic links).
|
||||
This is the default if the environment variable
|
||||
.Ev POSIXLY_CORRECT
|
||||
is defined.
|
||||
.It Fl m , Fl Fl magic-file Ar list
|
||||
.It Fl l
|
||||
Shows sorted patterns list in the order which is used for the matching.
|
||||
.It Fl m , Fl Fl magic-file Ar magicfiles
|
||||
Specify an alternate list of files and directories containing magic.
|
||||
This can be a single item, or a colon-separated list.
|
||||
If a compiled magic file is found alongside a file or directory,
|
||||
@ -320,6 +325,23 @@ since on some systems it reports a zero size for raw disk partitions.
|
||||
Print the version of the program and exit.
|
||||
.It Fl z , Fl Fl uncompress
|
||||
Try to look inside compressed files.
|
||||
.It Fl 0 , Fl Fl print0
|
||||
Output a null character
|
||||
.Sq \e0
|
||||
after the end of the filename.
|
||||
Nice to
|
||||
.Xr cut 1
|
||||
the output.
|
||||
This does not affect the separator which is still printed.
|
||||
.It Fl -help
|
||||
Print a help message and exit.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width /usr/share/misc/magic.mgc -compact
|
||||
.It Pa /usr/share/misc/magic.mgc
|
||||
Default compiled list of magic.
|
||||
.It Pa /usr/share/misc/magic
|
||||
Directory containing default magic files.
|
||||
.El
|
||||
.Sh ENVIRONMENT
|
||||
The environment variable
|
||||
@ -333,6 +355,11 @@ will not attempt to open
|
||||
adds
|
||||
.Dq Pa .mgc
|
||||
to the value of this variable as appropriate.
|
||||
However,
|
||||
.Pa file
|
||||
has to exist in order for
|
||||
.Pa file.mime
|
||||
to be considered.
|
||||
The environment variable
|
||||
.Ev POSIXLY_CORRECT
|
||||
controls (on systems that support symbolic links), whether
|
||||
@ -392,8 +419,10 @@ file: application/x-executable
|
||||
.Xr hexdump 1 ,
|
||||
.Xr od 1 ,
|
||||
.Xr strings 1 ,
|
||||
.Xr od 1 ,
|
||||
.Xr hexdump 1 ,
|
||||
.Xr magic 5
|
||||
.Sh STANDARDS
|
||||
.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
|
||||
contained therein.
|
||||
@ -456,6 +485,39 @@ command uses a magic file,
|
||||
keep the old magic file around for comparison purposes
|
||||
(rename it to
|
||||
.Pa /usr/share/misc/magic.orig ) .
|
||||
.Sh EXAMPLES
|
||||
.Bd -literal -offset indent
|
||||
$ file file.c file /dev/{wd0a,hda}
|
||||
file.c: C program text
|
||||
file: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
|
||||
dynamically linked (uses shared libs), stripped
|
||||
/dev/wd0a: block special (0/0)
|
||||
/dev/hda: block special (3/0)
|
||||
|
||||
$ file -s /dev/wd0{b,d}
|
||||
/dev/wd0b: data
|
||||
/dev/wd0d: x86 boot sector
|
||||
|
||||
$ file -s /dev/hda{,1,2,3,4,5,6,7,8,9,10}
|
||||
/dev/hda: x86 boot sector
|
||||
/dev/hda1: Linux/i386 ext2 filesystem
|
||||
/dev/hda2: x86 boot sector
|
||||
/dev/hda3: x86 boot sector, extended partition table
|
||||
/dev/hda4: Linux/i386 ext2 filesystem
|
||||
/dev/hda5: Linux/i386 swap file
|
||||
/dev/hda6: Linux/i386 swap file
|
||||
/dev/hda7: Linux/i386 swap file
|
||||
/dev/hda8: Linux/i386 swap file
|
||||
/dev/hda9: empty
|
||||
/dev/hda10: empty
|
||||
|
||||
$ file -i file.c file /dev/{wd0a,hda}
|
||||
file.c: text/x-c
|
||||
file: application/x-executable
|
||||
/dev/hda: application/x-not-regular-file
|
||||
/dev/wd0a: application/x-not-regular-file
|
||||
|
||||
.Ed
|
||||
.Sh HISTORY
|
||||
There has been a
|
||||
.Nm
|
||||
@ -477,16 +539,22 @@ Geoff Collyer found several inadequacies
|
||||
and provided some magic file entries.
|
||||
Contributions by the
|
||||
.Sq \*[Am]
|
||||
operator by Rob McMahon, cudcv@warwick.ac.uk, 1989.
|
||||
operator by Rob McMahon,
|
||||
.Aq cudcv@warwick.ac.uk ,
|
||||
1989.
|
||||
.Pp
|
||||
Guy Harris, guy@netapp.com, made many changes from 1993 to the present.
|
||||
Guy Harris,
|
||||
.Aq guy@netapp.com ,
|
||||
made many changes from 1993 to the present.
|
||||
1989.
|
||||
.Pp
|
||||
Primary development and maintenance from 1990 to the present by
|
||||
Christos Zoulas
|
||||
.Aq christos@astron.com .
|
||||
.Pp
|
||||
Altered by Chris Lowth, chris@lowth.com, 2000:
|
||||
Handle the
|
||||
Altered by Chris Lowth
|
||||
.Aq chris@lowth.com ,
|
||||
2000: handle the
|
||||
.Fl i
|
||||
option to output mime type strings, using an alternative
|
||||
magic file and internal logic.
|
||||
@ -499,9 +567,10 @@ of non-ASCII files.
|
||||
.Pp
|
||||
Altered by Reuben Thomas
|
||||
.Aq 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.
|
||||
2007-2011, to improve MIME support, merge MIME and non-MIME magic,
|
||||
support directories as well as files of magic, apply many bug fixes,
|
||||
update and fix a lot of magic, improve the build system, improve the
|
||||
documentation, and rewrite the Python bindings in pure Python.
|
||||
.Pp
|
||||
The list of contributors to the
|
||||
.Sq magic
|
||||
@ -512,7 +581,7 @@ 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
|
||||
LEGAL.NOTICE in the source distribution.
|
||||
COPYING in the source distribution.
|
||||
.Pp
|
||||
The files
|
||||
.Pa tar.h
|
||||
@ -521,43 +590,39 @@ and
|
||||
were written by John Gilmore from his public-domain
|
||||
.Xr tar 1
|
||||
program, and are not covered by the above license.
|
||||
.Sh BUGS
|
||||
There must be a better way to automate the construction of the Magic
|
||||
file from all the glop in Magdir.
|
||||
What is it?
|
||||
.Pp
|
||||
.Sh RETURN CODE
|
||||
.Nm
|
||||
uses several algorithms that favor speed over accuracy,
|
||||
thus it can be misled about the contents of text files.
|
||||
returns 0 on success, and non-zero on error.
|
||||
.Sh BUGS
|
||||
.Pp
|
||||
The support for text files (primarily for programming languages)
|
||||
is simplistic, inefficient and requires recompilation to update.
|
||||
Please report bugs and send patches to the bug tracker at
|
||||
.Pa http://bugs.gw.com/
|
||||
or the mailing list at
|
||||
.Aq file@mx.gw.com .
|
||||
.Sh TODO
|
||||
.Pp
|
||||
The list of keywords in
|
||||
.Dv ascmagic
|
||||
probably belongs in the Magic file.
|
||||
This could be done by using some keyword like
|
||||
.Sq *
|
||||
for the offset value.
|
||||
Fix output so that tests for MIME and APPLE flags are not needed all
|
||||
over the place, and actual output is only done in one place. This
|
||||
needs a design. Suggestion: push possible outputs on to a list, then
|
||||
pick the last-pushed (most specific, one hopes) value at the end, or
|
||||
use a default if the list is empty. This should not slow down evaluation.
|
||||
.Pp
|
||||
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?
|
||||
Continue to squash all magic bugs. See Debian BTS for a good source.
|
||||
.Pp
|
||||
The program should provide a way to give an estimate of
|
||||
.Sq how good
|
||||
a guess is.
|
||||
We end up removing guesses (e.g.
|
||||
.Sq From\
|
||||
as first 5 chars of file) because
|
||||
they are not as good as other guesses (e.g.
|
||||
.Sq Newsgroups:
|
||||
versus
|
||||
.Sq Return-Path: ) .
|
||||
Still, if the others don't pan out, it should be possible to use the
|
||||
first guess.
|
||||
Store arbitrarily long strings, for example for %s patterns, so that
|
||||
they can be printed out. Fixes Debian bug #271672. Would require more
|
||||
complex store/load code in apprentice.
|
||||
.Pp
|
||||
This manual page, and particularly this section, is too long.
|
||||
Add syntax for relative offsets after current level (Debian bug #466037).
|
||||
.Pp
|
||||
Make file -ki work, i.e. give multiple MIME types.
|
||||
.Pp
|
||||
Add a zip library so we can peek inside Office2007 documents to
|
||||
figure out what they are.
|
||||
.Pp
|
||||
Don't complain when ~/.magic is not compiled.
|
||||
.Pp
|
||||
Add an option to print URLs for the sources of the file descriptions.
|
||||
.Sh AVAILABILITY
|
||||
You can obtain the original author's latest version by anonymous FTP
|
||||
on
|
||||
|
42
external/bsd/file/dist/doc/libmagic.3
vendored
42
external/bsd/file/dist/doc/libmagic.3
vendored
@ -1,6 +1,6 @@
|
||||
.\" $NetBSD: libmagic.3,v 1.5 2010/05/14 03:14:41 joerg Exp $
|
||||
.\" $NetBSD: libmagic.3,v 1.6 2011/05/13 01:52:13 christos Exp $
|
||||
.\"
|
||||
.\" $File: libmagic.man,v 1.19 2008/10/06 20:16:04 christos Exp $
|
||||
.\" $File: libmagic.man,v 1.23 2011/01/14 21:59:17 rrt Exp $
|
||||
.\"
|
||||
.\" Copyright (c) Christos Zoulas 2003.
|
||||
.\" All Rights Reserved.
|
||||
@ -27,14 +27,14 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd October 6, 2008
|
||||
.Dd January 14, 2011
|
||||
.Dt LIBMAGIC 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm magic_open ,
|
||||
.Nm magic_close ,
|
||||
.Nm magic_error ,
|
||||
.Nm magic_file ,
|
||||
.Nm magic_descriptor ,
|
||||
.Nm magic_buffer ,
|
||||
.Nm magic_setflags ,
|
||||
.Nm magic_check ,
|
||||
@ -54,7 +54,9 @@
|
||||
.Ft int
|
||||
.Fn magic_errno "magic_t cookie"
|
||||
.Ft const char *
|
||||
.Fn magic_file "magic_t cookie" "const char *filename"
|
||||
.Fn magic_descriptor "magic_t cookie, "int fd"
|
||||
.Ft const char *
|
||||
.Fn magic_file "magic_t cookie, const char *filename"
|
||||
.Ft const char *
|
||||
.Fn magic_buffer "magic_t cookie" "const void *buffer" "size_t length"
|
||||
.Ft int
|
||||
@ -97,6 +99,8 @@ and try to look in its contents.
|
||||
Return a MIME type string, instead of a textual description.
|
||||
.It Dv MAGIC_MIME_ENCODING
|
||||
Return a MIME encoding, instead of a textual description.
|
||||
.It Dv MAGIC_MIME
|
||||
A shorthand for MAGIC_MIME_TYPE | MAGIC_MIME_ENCODING.
|
||||
.It Dv MAGIC_CONTINUE
|
||||
Return all matches, not just the first.
|
||||
.It Dv MAGIC_CHECK
|
||||
@ -106,32 +110,34 @@ On systems that support
|
||||
.Xr utime 3
|
||||
or
|
||||
.Xr utimes 2 ,
|
||||
attempt to preserve the access time of files analyzed.
|
||||
attempt to preserve the access time of files analysed.
|
||||
.It Dv MAGIC_RAW
|
||||
Don't translate unprintable characters to a \eooo octal representation.
|
||||
.It Dv MAGIC_ERROR
|
||||
Treat operating system errors while trying to open files and follow symlinks
|
||||
as real errors, instead of printing them in the magic buffer.
|
||||
.It Dv MAGIC_APPLE
|
||||
Return the Apple creator and type.
|
||||
.It Dv MAGIC_NO_CHECK_APPTYPE
|
||||
Check for
|
||||
Don't check for
|
||||
.Dv EMX
|
||||
application type (only on EMX).
|
||||
.It Dv MAGIC_NO_CHECK_ASCII
|
||||
Check for various types of ascii files.
|
||||
.It Dv MAGIC_NO_CHECK_CDF
|
||||
Don't get extra information on MS Composite Document Files.
|
||||
.It Dv MAGIC_NO_CHECK_COMPRESS
|
||||
Don't look for, or inside compressed files.
|
||||
Don't look inside compressed files.
|
||||
.It Dv MAGIC_NO_CHECK_ELF
|
||||
Don't print elf details.
|
||||
.It Dv MAGIC_NO_CHECK_FORTRAN
|
||||
Don't look for fortran sequences inside ascii files.
|
||||
Don't print ELF details.
|
||||
.It Dv NO_CHECK_ENCODING
|
||||
Don't check text encodings.
|
||||
.It Dv MAGIC_NO_CHECK_SOFT
|
||||
Don't consult magic files.
|
||||
.It Dv MAGIC_NO_CHECK_TAR
|
||||
Don't examine tar files.
|
||||
.It Dv MAGIC_NO_CHECK_TEXT
|
||||
Don't check for various types of text files.
|
||||
.It Dv MAGIC_NO_CHECK_TOKENS
|
||||
Don't look for known tokens inside ascii files.
|
||||
.It Dv MAGIC_NO_CHECK_TROFF
|
||||
Don't look for troff sequences inside ascii files.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
@ -166,6 +172,12 @@ is
|
||||
then stdin is used.
|
||||
.Pp
|
||||
The
|
||||
.Fn magic_descriptor
|
||||
function returns a textual description of the contents of the
|
||||
.Ar fd
|
||||
argument, or NULL if an error occurred.
|
||||
.Pp
|
||||
The
|
||||
.Fn magic_buffer
|
||||
function returns a textual description of the contents of the
|
||||
.Ar buffer
|
||||
|
67
external/bsd/file/dist/doc/magic.5
vendored
67
external/bsd/file/dist/doc/magic.5
vendored
@ -1,7 +1,7 @@
|
||||
.\" $NetBSD: magic.5,v 1.4 2009/05/08 20:20:39 wiz Exp $
|
||||
.\" $NetBSD: magic.5,v 1.5 2011/05/13 01:52:13 christos Exp $
|
||||
.\"
|
||||
.\" $File: magic.man,v 1.59 2008/11/06 23:22:53 christos Exp $
|
||||
.Dd August 30, 2008
|
||||
.\" $File: magic.man,v 1.68 2011/04/20 19:08:44 christos Exp $
|
||||
.Dd April 20, 2011
|
||||
.Dt MAGIC 5
|
||||
.Os
|
||||
.\" install as magic.4 on USG, magic.5 on V7, Berkeley and Linux systems.
|
||||
@ -12,7 +12,7 @@
|
||||
This manual page documents the format of the magic file as
|
||||
used by the
|
||||
.Xr file 1
|
||||
command, version 5.03.
|
||||
command, version 5.07.
|
||||
The
|
||||
.Xr file 1
|
||||
command identifies the type of a file using,
|
||||
@ -53,9 +53,9 @@ A 64-bit double precision IEEE floating point number in this machine's native by
|
||||
.It Dv string
|
||||
A string of bytes.
|
||||
The string type specification can be optionally followed
|
||||
by /[Bbc]*.
|
||||
by /[WwcCtb]*.
|
||||
The
|
||||
.Dq B
|
||||
.Dq W
|
||||
flag compacts whitespace in the target, which must
|
||||
contain at least one whitespace character.
|
||||
If the magic has
|
||||
@ -64,18 +64,55 @@ consecutive blanks, the target needs at least
|
||||
.Dv n
|
||||
consecutive blanks to match.
|
||||
The
|
||||
.Dq b
|
||||
.Dq w
|
||||
flag treats every blank in the target as an optional blank.
|
||||
Finally the
|
||||
The
|
||||
.Dq c
|
||||
flag, specifies case insensitive matching: lowercase
|
||||
flag, specifies case insensitive matching: lower case
|
||||
characters in the magic match both lower and upper case characters in the
|
||||
target, whereas upper case characters in the magic only match uppercase
|
||||
target, whereas upper case characters in the magic only match upper case
|
||||
characters in the target.
|
||||
The
|
||||
.Dq C
|
||||
flag, specifies case insensitive matching: upper case
|
||||
characters in the magic match both lower and upper case characters in the
|
||||
target, whereas lower case characters in the magic only match upper case
|
||||
characters in the target.
|
||||
To do a complete case insensitive match, specify both
|
||||
.Dq c
|
||||
and
|
||||
.Dq C .
|
||||
The
|
||||
.Dq t
|
||||
flag, forces the test to be done for text files, while the
|
||||
.Dq b
|
||||
flag, forces the test to be done for binary files.
|
||||
.It Dv pstring
|
||||
A Pascal-style string where the first byte is interpreted as the an
|
||||
A Pascal-style string where the first byte/short/int is interpreted as the an
|
||||
unsigned length.
|
||||
The length defaults to byte and can be specified as a modifier.
|
||||
The following modifiers are supported:
|
||||
.Bl -tag -compact -width B
|
||||
.It B
|
||||
A byte length (default).
|
||||
.It H
|
||||
A 2 byte big endian length.
|
||||
.It h
|
||||
A 2 byte big little length.
|
||||
.It L
|
||||
A 4 byte big endian length.
|
||||
.It l
|
||||
A 4 byte big little length.
|
||||
.It J
|
||||
The length includes itself in its count.
|
||||
.El
|
||||
The string is not NUL terminated.
|
||||
.Dq J
|
||||
is used rather than the more
|
||||
valuable
|
||||
.Dq I
|
||||
because this type of length is a feature of the JPEG
|
||||
format.
|
||||
.It Dv date
|
||||
A four-byte value interpreted as a UNIX date.
|
||||
.It Dv qdate
|
||||
@ -292,7 +329,7 @@ then print the string), with
|
||||
The special test
|
||||
.Em x
|
||||
always evaluates to true.
|
||||
.Dv message
|
||||
.It Dv message
|
||||
The message to be printed if the comparison succeeds.
|
||||
If the string contains a
|
||||
.Xr printf 3
|
||||
@ -353,11 +390,11 @@ on the line indicates the level of the test; a line with no
|
||||
.Em \*[Gt]
|
||||
at the beginning is considered to be at level 0.
|
||||
Tests are arranged in a tree-like hierarchy:
|
||||
If a the test on a line at level
|
||||
if the test on a line at level
|
||||
.Em n
|
||||
succeeds, all following tests at level
|
||||
.Em n+1
|
||||
are performed, and the messages printed if the tests succeed, untile a line
|
||||
are performed, and the messages printed if the tests succeed, until a line
|
||||
with level
|
||||
.Em n
|
||||
(or less) appears.
|
||||
@ -374,7 +411,7 @@ being examined.
|
||||
If the first character following the last
|
||||
.Em \*[Gt]
|
||||
is a
|
||||
.Em (
|
||||
.Em \&(
|
||||
then the string after the parenthesis is interpreted as an indirect offset.
|
||||
That means that the number after the parenthesis is used as an offset in
|
||||
the file.
|
||||
|
114
external/bsd/file/dist/file2netbsd
vendored
114
external/bsd/file/dist/file2netbsd
vendored
@ -1,114 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# $NetBSD: file2netbsd,v 1.2 2009/05/08 16:40:10 christos Exp $
|
||||
#
|
||||
# Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# file2netbsd: convert a file source tree into a
|
||||
# format suitable for import. Works on current dir.
|
||||
# You can run this only once if you want it to work.
|
||||
#
|
||||
# based on texinfo2netbsd
|
||||
#
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Usage $0: <file-version>" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
file_vers="$1"
|
||||
|
||||
#
|
||||
# (usually) NO NEED TO EDIT BELOW THIS LINE
|
||||
#
|
||||
|
||||
### Wipe out stuff we don't want
|
||||
rm -f .cvsignore
|
||||
|
||||
### Remove the $'s around RCS tags
|
||||
find . -type f -print | xargs egrep -l '\$(Id|Date|Header|Log|Revision)'\
|
||||
| while read f; do
|
||||
sed -e 's/\$\(Id.*\) \$/\1/' \
|
||||
-e 's/\$\(Date.*\) \$/\1/' \
|
||||
-e 's/\$\(Header.*\) \$/\1/' \
|
||||
-e 's/\$\(Log.*\) \$/\1/' \
|
||||
-e 's/\$\(Revision.*\) \$/\1/' \
|
||||
$f > /tmp/file2$$ && mv /tmp/file2$$ $f && \
|
||||
echo removed RCS tag from $f
|
||||
done
|
||||
|
||||
### Add NetBSD RCS Id
|
||||
find . -type f -name '*.[chly]' -print | while read c; do
|
||||
sed -e '1{/$NetBSD/!{i\
|
||||
/* \$NetBSD\$ */\
|
||||
|
||||
};}
|
||||
/#ifndef[ ]lint/{N;/FILE_RCSID/s/\n/\
|
||||
#if 0\
|
||||
/
|
||||
a\
|
||||
#else\
|
||||
__RCSID("\$NetBSD\$");\
|
||||
#endif
|
||||
}' $c > /tmp/file3$$
|
||||
mv /tmp/file3$$ $c && echo did source mods for $c
|
||||
done
|
||||
|
||||
#### Move files to proper names
|
||||
mv -f doc/file.man doc/file.1
|
||||
mv -f doc/libmagic.man doc/libmagic.3
|
||||
mv -f doc/magic.man doc/magic.5
|
||||
|
||||
#### Add RCS tags to man pages
|
||||
find . -type f -name '*.[0-9]' -print | while read m; do
|
||||
sed -e '1{/$NetBSD/!i\
|
||||
.\\" \$NetBSD\$\
|
||||
.\\"
|
||||
|
||||
}' -e 's/__CSECTION__/1/g' \
|
||||
-e 's/__FSECTION__/5/g' \
|
||||
-e 's/__VERSION__/'"${file_vers}/g" \
|
||||
-e 's,__MAGIC__,/usr/share/misc/magic,g' \
|
||||
$m > /tmp/file4$$
|
||||
mv /tmp/file4$$ $m && echo did manpage mods for $m
|
||||
done
|
||||
|
||||
#### de-"capsize" the magdir
|
||||
mv magic/Magdir magic/magdir
|
||||
|
||||
#### Make building easier, don't build magic and doc
|
||||
echo '/^SUBDIRS/
|
||||
t.
|
||||
s/^/#/
|
||||
-
|
||||
s/ magic.*//
|
||||
wq' | ed Makefile.in > /dev/null 2>&1
|
||||
|
||||
echo done
|
||||
|
||||
echo You can import now. Use the following command:
|
||||
echo cvs import src/external/bsd/file/dist CHRISTOS FILE${file_vers%.*}_${file_vers#*.}
|
||||
|
||||
exit 0
|
36
external/bsd/file/dist/magic/Makefile.am
vendored
36
external/bsd/file/dist/magic/Makefile.am
vendored
@ -1,18 +1,20 @@
|
||||
#
|
||||
# $File: Makefile.am,v 1.45 2009/03/05 22:40:59 christos Exp $
|
||||
# $File: Makefile.am,v 1.66 2011/05/10 17:01:57 christos Exp $
|
||||
#
|
||||
MAGIC_FRAGMENT_BASE = magdir
|
||||
MAGIC_FRAGMENT_DIR = $(top_srcdir)/magic/$(MAGIC_FRAGMENT_BASE)
|
||||
MAGIC_DIR = $(top_srcdir)/magic
|
||||
MAGIC_FRAGMENT_DIR = $(MAGIC_DIR)/$(MAGIC_FRAGMENT_BASE)
|
||||
|
||||
pkgdata_DATA = magic.mgc
|
||||
|
||||
EXTRA_DIST = Header Localstuff \
|
||||
EXTRA_DIST = \
|
||||
$(MAGIC_DIR)/Header \
|
||||
$(MAGIC_DIR)/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 \
|
||||
@ -25,10 +27,12 @@ $(MAGIC_FRAGMENT_DIR)/att3b \
|
||||
$(MAGIC_FRAGMENT_DIR)/audio \
|
||||
$(MAGIC_FRAGMENT_DIR)/basis \
|
||||
$(MAGIC_FRAGMENT_DIR)/bflt \
|
||||
$(MAGIC_FRAGMENT_DIR)/blcr \
|
||||
$(MAGIC_FRAGMENT_DIR)/blender \
|
||||
$(MAGIC_FRAGMENT_DIR)/blit \
|
||||
$(MAGIC_FRAGMENT_DIR)/bout \
|
||||
$(MAGIC_FRAGMENT_DIR)/bsdi \
|
||||
$(MAGIC_FRAGMENT_DIR)/bsi \
|
||||
$(MAGIC_FRAGMENT_DIR)/btsnoop \
|
||||
$(MAGIC_FRAGMENT_DIR)/c-lang \
|
||||
$(MAGIC_FRAGMENT_DIR)/c64 \
|
||||
@ -56,6 +60,7 @@ $(MAGIC_FRAGMENT_DIR)/digital \
|
||||
$(MAGIC_FRAGMENT_DIR)/dolby \
|
||||
$(MAGIC_FRAGMENT_DIR)/dump \
|
||||
$(MAGIC_FRAGMENT_DIR)/dyadic \
|
||||
$(MAGIC_FRAGMENT_DIR)/ebml \
|
||||
$(MAGIC_FRAGMENT_DIR)/editors \
|
||||
$(MAGIC_FRAGMENT_DIR)/efi \
|
||||
$(MAGIC_FRAGMENT_DIR)/elf \
|
||||
@ -73,6 +78,7 @@ $(MAGIC_FRAGMENT_DIR)/freebsd \
|
||||
$(MAGIC_FRAGMENT_DIR)/fsav \
|
||||
$(MAGIC_FRAGMENT_DIR)/games \
|
||||
$(MAGIC_FRAGMENT_DIR)/gcc \
|
||||
$(MAGIC_FRAGMENT_DIR)/geo \
|
||||
$(MAGIC_FRAGMENT_DIR)/geos \
|
||||
$(MAGIC_FRAGMENT_DIR)/gimp \
|
||||
$(MAGIC_FRAGMENT_DIR)/gnome-keyring \
|
||||
@ -93,6 +99,7 @@ $(MAGIC_FRAGMENT_DIR)/intel \
|
||||
$(MAGIC_FRAGMENT_DIR)/interleaf \
|
||||
$(MAGIC_FRAGMENT_DIR)/island \
|
||||
$(MAGIC_FRAGMENT_DIR)/ispell \
|
||||
$(MAGIC_FRAGMENT_DIR)/isz \
|
||||
$(MAGIC_FRAGMENT_DIR)/java \
|
||||
$(MAGIC_FRAGMENT_DIR)/jpeg \
|
||||
$(MAGIC_FRAGMENT_DIR)/karma \
|
||||
@ -116,6 +123,7 @@ $(MAGIC_FRAGMENT_DIR)/mathematica \
|
||||
$(MAGIC_FRAGMENT_DIR)/matroska \
|
||||
$(MAGIC_FRAGMENT_DIR)/mcrypt \
|
||||
$(MAGIC_FRAGMENT_DIR)/mercurial \
|
||||
$(MAGIC_FRAGMENT_DIR)/metastore \
|
||||
$(MAGIC_FRAGMENT_DIR)/mime \
|
||||
$(MAGIC_FRAGMENT_DIR)/mips \
|
||||
$(MAGIC_FRAGMENT_DIR)/mirage \
|
||||
@ -127,6 +135,7 @@ $(MAGIC_FRAGMENT_DIR)/modem \
|
||||
$(MAGIC_FRAGMENT_DIR)/motorola \
|
||||
$(MAGIC_FRAGMENT_DIR)/mozilla \
|
||||
$(MAGIC_FRAGMENT_DIR)/msdos \
|
||||
$(MAGIC_FRAGMENT_DIR)/msooxml \
|
||||
$(MAGIC_FRAGMENT_DIR)/msvc \
|
||||
$(MAGIC_FRAGMENT_DIR)/mup \
|
||||
$(MAGIC_FRAGMENT_DIR)/natinst \
|
||||
@ -136,6 +145,7 @@ $(MAGIC_FRAGMENT_DIR)/netscape \
|
||||
$(MAGIC_FRAGMENT_DIR)/netware \
|
||||
$(MAGIC_FRAGMENT_DIR)/news \
|
||||
$(MAGIC_FRAGMENT_DIR)/nitpicker \
|
||||
$(MAGIC_FRAGMENT_DIR)/oasis \
|
||||
$(MAGIC_FRAGMENT_DIR)/ocaml \
|
||||
$(MAGIC_FRAGMENT_DIR)/octave \
|
||||
$(MAGIC_FRAGMENT_DIR)/ole2compounddocs \
|
||||
@ -146,6 +156,7 @@ $(MAGIC_FRAGMENT_DIR)/os9 \
|
||||
$(MAGIC_FRAGMENT_DIR)/osf1 \
|
||||
$(MAGIC_FRAGMENT_DIR)/palm \
|
||||
$(MAGIC_FRAGMENT_DIR)/parix \
|
||||
$(MAGIC_FRAGMENT_DIR)/parrot \
|
||||
$(MAGIC_FRAGMENT_DIR)/pbm \
|
||||
$(MAGIC_FRAGMENT_DIR)/pdf \
|
||||
$(MAGIC_FRAGMENT_DIR)/pdp \
|
||||
@ -157,12 +168,12 @@ $(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)/rinex \
|
||||
$(MAGIC_FRAGMENT_DIR)/rpm \
|
||||
$(MAGIC_FRAGMENT_DIR)/rtf \
|
||||
$(MAGIC_FRAGMENT_DIR)/ruby \
|
||||
@ -170,12 +181,14 @@ $(MAGIC_FRAGMENT_DIR)/sc \
|
||||
$(MAGIC_FRAGMENT_DIR)/sccs \
|
||||
$(MAGIC_FRAGMENT_DIR)/scientific \
|
||||
$(MAGIC_FRAGMENT_DIR)/securitycerts \
|
||||
$(MAGIC_FRAGMENT_DIR)/selinux \
|
||||
$(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)/sisu \
|
||||
$(MAGIC_FRAGMENT_DIR)/sketch \
|
||||
$(MAGIC_FRAGMENT_DIR)/smalltalk \
|
||||
$(MAGIC_FRAGMENT_DIR)/sniffer \
|
||||
@ -183,8 +196,11 @@ $(MAGIC_FRAGMENT_DIR)/softquad \
|
||||
$(MAGIC_FRAGMENT_DIR)/spec \
|
||||
$(MAGIC_FRAGMENT_DIR)/spectrum \
|
||||
$(MAGIC_FRAGMENT_DIR)/sql \
|
||||
$(MAGIC_FRAGMENT_DIR)/ssh \
|
||||
$(MAGIC_FRAGMENT_DIR)/ssl \
|
||||
$(MAGIC_FRAGMENT_DIR)/sun \
|
||||
$(MAGIC_FRAGMENT_DIR)/sysex \
|
||||
$(MAGIC_FRAGMENT_DIR)/tcl \
|
||||
$(MAGIC_FRAGMENT_DIR)/teapot \
|
||||
$(MAGIC_FRAGMENT_DIR)/terminfo \
|
||||
$(MAGIC_FRAGMENT_DIR)/tex \
|
||||
@ -201,6 +217,7 @@ $(MAGIC_FRAGMENT_DIR)/varied.out \
|
||||
$(MAGIC_FRAGMENT_DIR)/varied.script \
|
||||
$(MAGIC_FRAGMENT_DIR)/vax \
|
||||
$(MAGIC_FRAGMENT_DIR)/vicar \
|
||||
$(MAGIC_FRAGMENT_DIR)/virtual \
|
||||
$(MAGIC_FRAGMENT_DIR)/virtutech \
|
||||
$(MAGIC_FRAGMENT_DIR)/visx \
|
||||
$(MAGIC_FRAGMENT_DIR)/vms \
|
||||
@ -212,6 +229,7 @@ $(MAGIC_FRAGMENT_DIR)/weak \
|
||||
$(MAGIC_FRAGMENT_DIR)/windows \
|
||||
$(MAGIC_FRAGMENT_DIR)/wireless \
|
||||
$(MAGIC_FRAGMENT_DIR)/wordprocessors \
|
||||
$(MAGIC_FRAGMENT_DIR)/wsdl \
|
||||
$(MAGIC_FRAGMENT_DIR)/xdelta \
|
||||
$(MAGIC_FRAGMENT_DIR)/xenix \
|
||||
$(MAGIC_FRAGMENT_DIR)/xilinx \
|
||||
@ -221,7 +239,7 @@ $(MAGIC_FRAGMENT_DIR)/zilog \
|
||||
$(MAGIC_FRAGMENT_DIR)/zyxel
|
||||
|
||||
MAGIC = magic.mgc
|
||||
CLEANFILES = ${MAGIC}
|
||||
CLEANFILES = ${MAGIC} $(MAGIC_FRAGMENT_DIR)/Localstuff
|
||||
|
||||
# FIXME: Build file natively as well so that it can be used to compile
|
||||
# the target's magic file
|
||||
@ -234,5 +252,7 @@ FILE_COMPILE_DEP = $(FILE_COMPILE)
|
||||
endif
|
||||
|
||||
${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP)
|
||||
$(FILE_COMPILE) -C -m $(MAGIC_FRAGMENT_DIR)
|
||||
@mv $(MAGIC_FRAGMENT_BASE).mgc $@
|
||||
@rm -fr magic
|
||||
@mkdir magic && cp -p $(EXTRA_DIST) magic
|
||||
$(FILE_COMPILE) -C -m magic
|
||||
@rm -fr magic
|
||||
|
62
external/bsd/file/dist/magic/Makefile.in
vendored
62
external/bsd/file/dist/magic/Makefile.in
vendored
@ -34,8 +34,10 @@ host_triplet = @host@
|
||||
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.ac
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
|
||||
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
|
||||
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
@ -66,38 +68,40 @@ CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
FFLAGS = @FFLAGS@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MINGW = @MINGW@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
@ -117,8 +121,7 @@ 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@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
@ -150,6 +153,7 @@ libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
lt_ECHO = @lt_ECHO@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
@ -166,18 +170,20 @@ top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
#
|
||||
# $File: Makefile.am,v 1.45 2009/03/05 22:40:59 christos Exp $
|
||||
# $File: Makefile.am,v 1.66 2011/05/10 17:01:57 christos Exp $
|
||||
#
|
||||
MAGIC_FRAGMENT_BASE = magdir
|
||||
MAGIC_FRAGMENT_DIR = $(top_srcdir)/magic/$(MAGIC_FRAGMENT_BASE)
|
||||
MAGIC_DIR = $(top_srcdir)/magic
|
||||
MAGIC_FRAGMENT_DIR = $(MAGIC_DIR)/$(MAGIC_FRAGMENT_BASE)
|
||||
pkgdata_DATA = magic.mgc
|
||||
EXTRA_DIST = Header Localstuff \
|
||||
EXTRA_DIST = \
|
||||
$(MAGIC_DIR)/Header \
|
||||
$(MAGIC_DIR)/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 \
|
||||
@ -190,10 +196,12 @@ $(MAGIC_FRAGMENT_DIR)/att3b \
|
||||
$(MAGIC_FRAGMENT_DIR)/audio \
|
||||
$(MAGIC_FRAGMENT_DIR)/basis \
|
||||
$(MAGIC_FRAGMENT_DIR)/bflt \
|
||||
$(MAGIC_FRAGMENT_DIR)/blcr \
|
||||
$(MAGIC_FRAGMENT_DIR)/blender \
|
||||
$(MAGIC_FRAGMENT_DIR)/blit \
|
||||
$(MAGIC_FRAGMENT_DIR)/bout \
|
||||
$(MAGIC_FRAGMENT_DIR)/bsdi \
|
||||
$(MAGIC_FRAGMENT_DIR)/bsi \
|
||||
$(MAGIC_FRAGMENT_DIR)/btsnoop \
|
||||
$(MAGIC_FRAGMENT_DIR)/c-lang \
|
||||
$(MAGIC_FRAGMENT_DIR)/c64 \
|
||||
@ -221,6 +229,7 @@ $(MAGIC_FRAGMENT_DIR)/digital \
|
||||
$(MAGIC_FRAGMENT_DIR)/dolby \
|
||||
$(MAGIC_FRAGMENT_DIR)/dump \
|
||||
$(MAGIC_FRAGMENT_DIR)/dyadic \
|
||||
$(MAGIC_FRAGMENT_DIR)/ebml \
|
||||
$(MAGIC_FRAGMENT_DIR)/editors \
|
||||
$(MAGIC_FRAGMENT_DIR)/efi \
|
||||
$(MAGIC_FRAGMENT_DIR)/elf \
|
||||
@ -238,6 +247,7 @@ $(MAGIC_FRAGMENT_DIR)/freebsd \
|
||||
$(MAGIC_FRAGMENT_DIR)/fsav \
|
||||
$(MAGIC_FRAGMENT_DIR)/games \
|
||||
$(MAGIC_FRAGMENT_DIR)/gcc \
|
||||
$(MAGIC_FRAGMENT_DIR)/geo \
|
||||
$(MAGIC_FRAGMENT_DIR)/geos \
|
||||
$(MAGIC_FRAGMENT_DIR)/gimp \
|
||||
$(MAGIC_FRAGMENT_DIR)/gnome-keyring \
|
||||
@ -258,6 +268,7 @@ $(MAGIC_FRAGMENT_DIR)/intel \
|
||||
$(MAGIC_FRAGMENT_DIR)/interleaf \
|
||||
$(MAGIC_FRAGMENT_DIR)/island \
|
||||
$(MAGIC_FRAGMENT_DIR)/ispell \
|
||||
$(MAGIC_FRAGMENT_DIR)/isz \
|
||||
$(MAGIC_FRAGMENT_DIR)/java \
|
||||
$(MAGIC_FRAGMENT_DIR)/jpeg \
|
||||
$(MAGIC_FRAGMENT_DIR)/karma \
|
||||
@ -281,6 +292,7 @@ $(MAGIC_FRAGMENT_DIR)/mathematica \
|
||||
$(MAGIC_FRAGMENT_DIR)/matroska \
|
||||
$(MAGIC_FRAGMENT_DIR)/mcrypt \
|
||||
$(MAGIC_FRAGMENT_DIR)/mercurial \
|
||||
$(MAGIC_FRAGMENT_DIR)/metastore \
|
||||
$(MAGIC_FRAGMENT_DIR)/mime \
|
||||
$(MAGIC_FRAGMENT_DIR)/mips \
|
||||
$(MAGIC_FRAGMENT_DIR)/mirage \
|
||||
@ -292,6 +304,7 @@ $(MAGIC_FRAGMENT_DIR)/modem \
|
||||
$(MAGIC_FRAGMENT_DIR)/motorola \
|
||||
$(MAGIC_FRAGMENT_DIR)/mozilla \
|
||||
$(MAGIC_FRAGMENT_DIR)/msdos \
|
||||
$(MAGIC_FRAGMENT_DIR)/msooxml \
|
||||
$(MAGIC_FRAGMENT_DIR)/msvc \
|
||||
$(MAGIC_FRAGMENT_DIR)/mup \
|
||||
$(MAGIC_FRAGMENT_DIR)/natinst \
|
||||
@ -301,6 +314,7 @@ $(MAGIC_FRAGMENT_DIR)/netscape \
|
||||
$(MAGIC_FRAGMENT_DIR)/netware \
|
||||
$(MAGIC_FRAGMENT_DIR)/news \
|
||||
$(MAGIC_FRAGMENT_DIR)/nitpicker \
|
||||
$(MAGIC_FRAGMENT_DIR)/oasis \
|
||||
$(MAGIC_FRAGMENT_DIR)/ocaml \
|
||||
$(MAGIC_FRAGMENT_DIR)/octave \
|
||||
$(MAGIC_FRAGMENT_DIR)/ole2compounddocs \
|
||||
@ -311,6 +325,7 @@ $(MAGIC_FRAGMENT_DIR)/os9 \
|
||||
$(MAGIC_FRAGMENT_DIR)/osf1 \
|
||||
$(MAGIC_FRAGMENT_DIR)/palm \
|
||||
$(MAGIC_FRAGMENT_DIR)/parix \
|
||||
$(MAGIC_FRAGMENT_DIR)/parrot \
|
||||
$(MAGIC_FRAGMENT_DIR)/pbm \
|
||||
$(MAGIC_FRAGMENT_DIR)/pdf \
|
||||
$(MAGIC_FRAGMENT_DIR)/pdp \
|
||||
@ -322,12 +337,12 @@ $(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)/rinex \
|
||||
$(MAGIC_FRAGMENT_DIR)/rpm \
|
||||
$(MAGIC_FRAGMENT_DIR)/rtf \
|
||||
$(MAGIC_FRAGMENT_DIR)/ruby \
|
||||
@ -335,12 +350,14 @@ $(MAGIC_FRAGMENT_DIR)/sc \
|
||||
$(MAGIC_FRAGMENT_DIR)/sccs \
|
||||
$(MAGIC_FRAGMENT_DIR)/scientific \
|
||||
$(MAGIC_FRAGMENT_DIR)/securitycerts \
|
||||
$(MAGIC_FRAGMENT_DIR)/selinux \
|
||||
$(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)/sisu \
|
||||
$(MAGIC_FRAGMENT_DIR)/sketch \
|
||||
$(MAGIC_FRAGMENT_DIR)/smalltalk \
|
||||
$(MAGIC_FRAGMENT_DIR)/sniffer \
|
||||
@ -348,8 +365,11 @@ $(MAGIC_FRAGMENT_DIR)/softquad \
|
||||
$(MAGIC_FRAGMENT_DIR)/spec \
|
||||
$(MAGIC_FRAGMENT_DIR)/spectrum \
|
||||
$(MAGIC_FRAGMENT_DIR)/sql \
|
||||
$(MAGIC_FRAGMENT_DIR)/ssh \
|
||||
$(MAGIC_FRAGMENT_DIR)/ssl \
|
||||
$(MAGIC_FRAGMENT_DIR)/sun \
|
||||
$(MAGIC_FRAGMENT_DIR)/sysex \
|
||||
$(MAGIC_FRAGMENT_DIR)/tcl \
|
||||
$(MAGIC_FRAGMENT_DIR)/teapot \
|
||||
$(MAGIC_FRAGMENT_DIR)/terminfo \
|
||||
$(MAGIC_FRAGMENT_DIR)/tex \
|
||||
@ -366,6 +386,7 @@ $(MAGIC_FRAGMENT_DIR)/varied.out \
|
||||
$(MAGIC_FRAGMENT_DIR)/varied.script \
|
||||
$(MAGIC_FRAGMENT_DIR)/vax \
|
||||
$(MAGIC_FRAGMENT_DIR)/vicar \
|
||||
$(MAGIC_FRAGMENT_DIR)/virtual \
|
||||
$(MAGIC_FRAGMENT_DIR)/virtutech \
|
||||
$(MAGIC_FRAGMENT_DIR)/visx \
|
||||
$(MAGIC_FRAGMENT_DIR)/vms \
|
||||
@ -377,6 +398,7 @@ $(MAGIC_FRAGMENT_DIR)/weak \
|
||||
$(MAGIC_FRAGMENT_DIR)/windows \
|
||||
$(MAGIC_FRAGMENT_DIR)/wireless \
|
||||
$(MAGIC_FRAGMENT_DIR)/wordprocessors \
|
||||
$(MAGIC_FRAGMENT_DIR)/wsdl \
|
||||
$(MAGIC_FRAGMENT_DIR)/xdelta \
|
||||
$(MAGIC_FRAGMENT_DIR)/xenix \
|
||||
$(MAGIC_FRAGMENT_DIR)/xilinx \
|
||||
@ -386,7 +408,7 @@ $(MAGIC_FRAGMENT_DIR)/zilog \
|
||||
$(MAGIC_FRAGMENT_DIR)/zyxel
|
||||
|
||||
MAGIC = magic.mgc
|
||||
CLEANFILES = ${MAGIC}
|
||||
CLEANFILES = ${MAGIC} $(MAGIC_FRAGMENT_DIR)/Localstuff
|
||||
@IS_CROSS_COMPILE_FALSE@FILE_COMPILE = $(top_builddir)/src/file
|
||||
|
||||
# FIXME: Build file natively as well so that it can be used to compile
|
||||
@ -584,8 +606,10 @@ uninstall-am: uninstall-pkgdataDATA
|
||||
|
||||
|
||||
${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE_DEP)
|
||||
$(FILE_COMPILE) -C -m $(MAGIC_FRAGMENT_DIR)
|
||||
@mv $(MAGIC_FRAGMENT_BASE).mgc $@
|
||||
@rm -fr magic
|
||||
@mkdir magic && cp -p $(EXTRA_DIST) magic
|
||||
$(FILE_COMPILE) -C -m magic
|
||||
@rm -fr magic
|
||||
# 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:
|
||||
|
30
external/bsd/file/dist/magic/magdir/alpha
vendored
30
external/bsd/file/dist/magic/magdir/alpha
vendored
@ -1,30 +0,0 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# alpha architecture description
|
||||
#
|
||||
|
||||
0 leshort 0603 COFF format alpha
|
||||
>22 leshort&030000 !020000 executable
|
||||
>24 leshort 0410 pure
|
||||
>24 leshort 0413 paged
|
||||
>22 leshort&020000 !0 dynamically linked
|
||||
>16 lelong !0 not stripped
|
||||
>16 lelong 0 stripped
|
||||
>22 leshort&030000 020000 shared library
|
||||
>24 leshort 0407 object
|
||||
>27 byte x - version %d
|
||||
>26 byte x .%d
|
||||
>28 byte x -%d
|
||||
|
||||
# Basic recognition of Digital UNIX core dumps - Mike Bremford <mike@opac.bl.uk>
|
||||
#
|
||||
# The actual magic number is just "Core", followed by a 2-byte version
|
||||
# number; however, treating any file that begins with "Core" as a Digital
|
||||
# UNIX core dump file may produce too many false hits, so we include one
|
||||
# byte of the version number as well; DU 5.0 appears only to be up to
|
||||
# version 2.
|
||||
#
|
||||
0 string Core\001 Alpha COFF format core dump (Digital UNIX)
|
||||
>24 string >\0 \b, from '%s'
|
||||
0 string Core\002 Alpha COFF format core dump (Digital UNIX)
|
||||
>24 string >\0 \b, from '%s'
|
||||
|
257
external/bsd/file/dist/magic/magdir/archive
vendored
257
external/bsd/file/dist/magic/magdir/archive
vendored
@ -1,4 +1,5 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: archive,v 1.63 2011/04/23 15:02:48 christos Exp $
|
||||
# archive: file(1) magic for archive formats (see also "msdos" for self-
|
||||
# extracting compressed archives)
|
||||
#
|
||||
@ -243,13 +244,13 @@
|
||||
# MS Compress
|
||||
4 string \x88\xf0\x27 MS Compress archive data
|
||||
# updated by Joerg Jenderek
|
||||
>9 string \0
|
||||
>>0 string KWAJ
|
||||
>9 string \0
|
||||
>>0 string KWAJ
|
||||
>>>7 string \321\003 MS Compress archive data
|
||||
>>>>14 ulong >0 \b, original size: %ld bytes
|
||||
>>>>18 ubyte >0x65
|
||||
>>>>>18 string x \b, was %.8s
|
||||
>>>>>(10.b-4) string x \b.%.3s
|
||||
>>>>18 ubyte >0x65
|
||||
>>>>>18 string x \b, was %.8s
|
||||
>>>>>(10.b-4) string x \b.%.3s
|
||||
# MP3 (archiver, not lossy audio compression)
|
||||
0 string MP3\x1a MP3-Archiver archive data
|
||||
# ZET
|
||||
@ -274,7 +275,7 @@
|
||||
# Splint
|
||||
0 string \x93\xb9\x06 Splint archive data
|
||||
# InstallShield
|
||||
0 string \x13\x5d\x65\x8c InstallShield Z archive Data
|
||||
0 string \x13\x5d\x65\x8c InstallShield Z archive Data
|
||||
# Gather
|
||||
1 string GTH Gather archive data
|
||||
# BOA
|
||||
@ -533,7 +534,7 @@
|
||||
>20 byte x - header level %d
|
||||
# taken from idarc [JW]
|
||||
2 string -lZ PUT archive data
|
||||
2 string -lz LZS archive data
|
||||
2 string -lz LZS archive data
|
||||
2 string -sw1- Swag archive data
|
||||
|
||||
# RAR archiver (Greg Roelofs, newt@uchicago.edu)
|
||||
@ -560,80 +561,139 @@
|
||||
# [JW] see exe section for self-extracting version
|
||||
0 string UC2\x1a UC2 archive data
|
||||
|
||||
# ZIP archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu)
|
||||
# PKZIP multi-volume archive
|
||||
0 string PK\x07\x08PK\x03\x04 Zip multi-volume archive data, at least PKZIP v2.50 to extract
|
||||
!:mime application/zip
|
||||
|
||||
# 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>
|
||||
>4 byte 0x14
|
||||
>>30 string mimetype
|
||||
# Specialised zip formats which start with a member named 'mimetype'
|
||||
# (stored uncompressed, with no 'extra field') containing the file's MIME type.
|
||||
# Check for have 8-byte name, 0-byte extra field, name "mimetype", and
|
||||
# contents starting with "application/":
|
||||
>26 string \x8\0\0\0mimetypeapplication/
|
||||
|
||||
# KOffice (1.2 or above) formats
|
||||
>>>50 string vnd.kde. KOffice (>=1.2)
|
||||
>>>>58 string karbon Karbon document
|
||||
>>>>58 string kchart KChart document
|
||||
>>>>58 string kformula KFormula document
|
||||
>>>>58 string kivio Kivio document
|
||||
>>>>58 string kontour Kontour document
|
||||
>>>>58 string kpresenter KPresenter document
|
||||
>>>>58 string kspread KSpread document
|
||||
>>>>58 string kword KWord document
|
||||
# KOffice / OpenOffice & StarOffice / OpenDocument formats
|
||||
# From: Abel Cheung <abel@oaka.org>
|
||||
|
||||
# OpenOffice formats (for OpenOffice 1.x / StarOffice 6/7)
|
||||
>>>50 string vnd.sun.xml. OpenOffice.org 1.x
|
||||
>>>>62 string writer Writer
|
||||
>>>>>68 byte !0x2e document
|
||||
>>>>>68 string .template template
|
||||
>>>>>68 string .global global document
|
||||
>>>>62 string calc Calc
|
||||
>>>>>66 byte !0x2e spreadsheet
|
||||
>>>>>66 string .template template
|
||||
>>>>62 string draw Draw
|
||||
>>>>>66 byte !0x2e document
|
||||
>>>>>66 string .template template
|
||||
>>>>62 string impress Impress
|
||||
>>>>>69 byte !0x2e presentation
|
||||
>>>>>69 string .template template
|
||||
>>>>62 string math Math document
|
||||
>>>>62 string base Database file
|
||||
# KOffice (1.2 or above) formats
|
||||
# (mimetype contains "application/vnd.kde.<SUBTYPE>")
|
||||
>>50 string vnd.kde. KOffice (>=1.2)
|
||||
>>>58 string karbon Karbon document
|
||||
>>>58 string kchart KChart document
|
||||
>>>58 string kformula KFormula document
|
||||
>>>58 string kivio Kivio document
|
||||
>>>58 string kontour Kontour document
|
||||
>>>58 string kpresenter KPresenter document
|
||||
>>>58 string kspread KSpread document
|
||||
>>>58 string kword KWord document
|
||||
|
||||
# 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
|
||||
# OpenOffice formats (for OpenOffice 1.x / StarOffice 6/7)
|
||||
# (mimetype contains "application/vnd.sun.xml.<SUBTYPE>")
|
||||
>>50 string vnd.sun.xml. OpenOffice.org 1.x
|
||||
>>>62 string writer Writer
|
||||
>>>>68 byte !0x2e document
|
||||
>>>>68 string .template template
|
||||
>>>>68 string .global global document
|
||||
>>>62 string calc Calc
|
||||
>>>>66 byte !0x2e spreadsheet
|
||||
>>>>66 string .template template
|
||||
>>>62 string draw Draw
|
||||
>>>>66 byte !0x2e document
|
||||
>>>>66 string .template template
|
||||
>>>62 string impress Impress
|
||||
>>>>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
|
||||
# (mimetype contains "application/vnd.oasis.opendocument.<SUBTYPE>")
|
||||
>>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
|
||||
>>>>73 string graphics Drawing
|
||||
>>>>>81 string -template Template
|
||||
>>>>73 string presentation Presentation
|
||||
>>>>>85 string -template Template
|
||||
>>>>73 string spreadsheet Spreadsheet
|
||||
>>>>>84 string -template Template
|
||||
>>>>73 string chart Chart
|
||||
>>>>>78 string -template Template
|
||||
>>>>73 string formula Formula
|
||||
>>>>>80 string -template Template
|
||||
>>>>73 string database Database
|
||||
>>>>73 string image Image
|
||||
>>>>77 string -template Text Template
|
||||
!:mime application/vnd.oasis.opendocument.text-template
|
||||
>>>>77 string -web HTML Document Template
|
||||
!:mime application/vnd.oasis.opendocument.text-web
|
||||
>>>>77 string -master Master Document
|
||||
!:mime application/vnd.oasis.opendocument.text-master
|
||||
>>>73 string graphics
|
||||
>>>>81 byte !0x2d Drawing
|
||||
!:mime application/vnd.oasis.opendocument.graphics
|
||||
>>>>81 string -template Template
|
||||
!:mime application/vnd.oasis.opendocument.graphics-template
|
||||
>>>73 string presentation
|
||||
>>>>85 byte !0x2d Presentation
|
||||
!:mime application/vnd.oasis.opendocument.presentation
|
||||
>>>>85 string -template Template
|
||||
!:mime application/vnd.oasis.opendocument.presentation-template
|
||||
>>>73 string spreadsheet
|
||||
>>>>84 byte !0x2d Spreadsheet
|
||||
!:mime application/vnd.oasis.opendocument.spreadsheet
|
||||
>>>>84 string -template Template
|
||||
!:mime application/vnd.oasis.opendocument.spreadsheet-template
|
||||
>>>73 string chart
|
||||
>>>>78 byte !0x2d Chart
|
||||
!:mime application/vnd.oasis.opendocument.chart
|
||||
>>>>78 string -template Template
|
||||
!:mime application/vnd.oasis.opendocument.chart-template
|
||||
>>>73 string formula
|
||||
>>>>80 byte !0x2d Formula
|
||||
!:mime application/vnd.oasis.opendocument.formula
|
||||
>>>>80 string -template Template
|
||||
!:mime application/vnd.oasis.opendocument.formula-template
|
||||
>>>73 string database Database
|
||||
!:mime application/vnd.oasis.opendocument.database
|
||||
>>>73 string image
|
||||
>>>>78 byte !0x2d Image
|
||||
!:mime application/vnd.oasis.opendocument.image
|
||||
>>>>78 string -template Template
|
||||
!:mime application/vnd.oasis.opendocument.image-template
|
||||
|
||||
# StarView Metafile
|
||||
# From Pierre Ducroquet <pinaraf@pinaraf.info>
|
||||
0 string VCLMTF StarView MetaFile
|
||||
>6 beshort x \b, version %d
|
||||
>8 belong x \b, size %d
|
||||
|
||||
# EPUB (OEBPS) books using OCF (OEBPS Container Format)
|
||||
# From: Adam Buchbinder <adam.buchbinder@gmail.com>
|
||||
# http://www.idpf.org/ocf/ocf1.0/download/ocf10.htm, section 4.
|
||||
# (mimetype contains "application/epub+zip")
|
||||
>>50 string epub+zip EPUB ebook data
|
||||
!:mime application/epub+zip
|
||||
|
||||
# Catch other ZIP-with-mimetype formats
|
||||
# In a ZIP file, the bytes immediately after a member's contents are
|
||||
# always "PK". The 2 regex rules here print the "mimetype" member's
|
||||
# contents up to the first 'P'. Luckily, most MIME types don't contain
|
||||
# any capital 'P's. This is a kludge.
|
||||
# (mimetype contains "application/<OTHER>")
|
||||
>>50 string !epub+zip
|
||||
>>>50 string !vnd.oasis.opendocument.
|
||||
>>>>50 string !vnd.sun.xml.
|
||||
>>>>>50 string !vnd.kde.
|
||||
>>>>>>38 regex [!-OQ-~]+ Zip data (MIME type "%s"?)
|
||||
!:mime application/zip
|
||||
# (mimetype contents other than "application/*")
|
||||
>26 string \x8\0\0\0mimetype
|
||||
>>38 string !application/
|
||||
>>>38 regex [!-OQ-~]+ Zip data (MIME type "%s"?)
|
||||
!:mime application/zip
|
||||
|
||||
# Generic zip archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu)
|
||||
# Next line excludes specialized formats:
|
||||
>26 string !\x8\0\0\0mimetype Zip archive data
|
||||
!:mime application/zip
|
||||
>>4 byte 0x09 \b, at least v0.9 to extract
|
||||
>>4 byte 0x0a \b, at least v1.0 to extract
|
||||
>>4 byte 0x0b \b, at least v1.1 to extract
|
||||
>>0x161 string WINZIP \b, WinZIP self-extracting
|
||||
>>4 byte 0x14 \b, at least v2.0 to extract
|
||||
|
||||
# Zoo archiver
|
||||
20 lelong 0xfdc4a7dc Zoo archive data
|
||||
@ -652,7 +712,7 @@
|
||||
!:mime application/octet-stream
|
||||
|
||||
#
|
||||
# LBR. NB: May conflict with the questionable
|
||||
# LBR. NB: May conflict with the questionable
|
||||
# "binary Computer Graphics Metafile" format.
|
||||
#
|
||||
0 string \0\ \ \ \ \ \ \ \ \ \ \ \0\0 LBR archive data
|
||||
@ -668,10 +728,10 @@
|
||||
# From Rafael Laboissiere <rafael@laboissiere.net>
|
||||
# The Project Revision Control System (see
|
||||
# http://prcs.sourceforge.net) generates a packaged project
|
||||
# file which is recognized by the following entry:
|
||||
# file which is recognized by the following entry:
|
||||
0 leshort 0xeb81 PRCS packaged project
|
||||
|
||||
# Microsoft cabinets
|
||||
# Microsoft cabinets
|
||||
# by David Necas (Yeti) <yeti@physics.muni.cz>
|
||||
#0 string MSCF\0\0\0\0 Microsoft cabinet file data,
|
||||
#>25 byte x v%d
|
||||
@ -679,7 +739,7 @@
|
||||
# MPi: All CABs have version 1.3, so this is pointless.
|
||||
# Better magic in debian-additions.
|
||||
|
||||
# GTKtalog catalogs
|
||||
# GTKtalog catalogs
|
||||
# by David Necas (Yeti) <yeti@physics.muni.cz>
|
||||
4 string gtktalog\ GTKtalog catalog data,
|
||||
>13 string 3 version 3
|
||||
@ -698,12 +758,12 @@
|
||||
!:mime application/x-bittorrent
|
||||
|
||||
# Atari MSA archive - Teemu Hukkanen <tjhukkan@iki.fi>
|
||||
0 beshort 0x0e0f Atari MSA archive data
|
||||
>2 beshort x \b, %d sectors per track
|
||||
>4 beshort 0 \b, 1 sided
|
||||
>4 beshort 1 \b, 2 sided
|
||||
>6 beshort x \b, starting track: %d
|
||||
>8 beshort x \b, ending track: %d
|
||||
0 beshort 0x0e0f Atari MSA archive data
|
||||
>2 beshort x \b, %d sectors per track
|
||||
>4 beshort 0 \b, 1 sided
|
||||
>4 beshort 1 \b, 2 sided
|
||||
>6 beshort x \b, starting track: %d
|
||||
>8 beshort x \b, ending track: %d
|
||||
|
||||
# Alternate ZIP string (amc@arwen.cs.berkeley.edu)
|
||||
0 string PK00PK\003\004 Zip archive data
|
||||
@ -748,7 +808,7 @@
|
||||
|
||||
# DR-DOS 7.03 Packed File *.??_
|
||||
0 string Packed\ File\ Personal NetWare Packed File
|
||||
>12 string x \b, was "%.12s"
|
||||
>12 string x \b, was "%.12s"
|
||||
|
||||
# EET archive
|
||||
# From: Tilman Sauerbeck <tilman@code-monkey.de>
|
||||
@ -804,3 +864,28 @@
|
||||
>24 belong 1 SHA-1 checksum
|
||||
>24 belong 2 MD5 checksum
|
||||
|
||||
# Type: Parity Archive
|
||||
# From: Daniel van Eeden <daniel_e@dds.nl>
|
||||
0 string PAR2 Parity Archive Volume Set
|
||||
|
||||
# Bacula volume format. (Volumes always start with a block header.)
|
||||
# URL: http://bacula.org/3.0.x-manuals/en/developers/developers/Block_Header.html
|
||||
# From: Adam Buchbinder <adam.buchbinder@gmail.com>
|
||||
12 string BB02 Bacula volume
|
||||
>20 bedate x \b, started %s
|
||||
|
||||
# ePub is XHTML + XML inside a ZIP archive. The first member of the
|
||||
# archive must be an uncompressed file called 'mimetype' with contents
|
||||
# 'application/epub+zip'
|
||||
|
||||
# start by checking that this is a ZIP archive, then check for the
|
||||
# proper mimetype file
|
||||
# From: Ralf Brown <ralf.brown@gmail.com>
|
||||
0 string PK\003\004
|
||||
>0x1E string mimetypeapplication/epub+zip EPUB document
|
||||
!:mime application/epub+zip
|
||||
|
||||
# From: "Michał Górny" <mgorny@gentoo.org>
|
||||
# ZPAQ: http://mattmahoney.net/dc/zpaq.html
|
||||
0 string zPQ ZPAQ stream
|
||||
>3 byte x \b, level %d
|
||||
|
18
external/bsd/file/dist/magic/magdir/diff
vendored
18
external/bsd/file/dist/magic/magdir/diff
vendored
@ -1,4 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: diff,v 1.12 2010/12/07 16:52:52 christos Exp $
|
||||
# diff: file(1) magic for diff(1) output
|
||||
#
|
||||
0 search/1 diff\ diff output text
|
||||
@ -12,8 +14,16 @@
|
||||
|
||||
0 search/1 Index: RCS/CVS diff output text
|
||||
!:mime text/x-diff
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# bsdiff: file(1) magic for bsdiff(1) output
|
||||
#
|
||||
0 string BSDIFF40 bsdiff(1) patch file
|
||||
0 string/t BSDIFF40 bsdiff(1) patch file
|
||||
|
||||
|
||||
# unified diff
|
||||
0 search/4096 ---\
|
||||
>&0 search/1024 \n
|
||||
>>&0 search/1 +++\
|
||||
>>>&0 search/1024 \n
|
||||
>>>>&0 search/1 @@ unified diff output text
|
||||
!:mime text/x-diff
|
||||
!:strength + 90
|
||||
|
258
external/bsd/file/dist/magic/magdir/filesystems
vendored
258
external/bsd/file/dist/magic/magdir/filesystems
vendored
@ -1,5 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: filesystems,v 1.61 2011/01/10 14:01:10 christos Exp $
|
||||
# filesystems: file(1) magic for different filesystems
|
||||
#
|
||||
0 string \366\366\366\366 PC formatted floppy with no filesystem
|
||||
@ -882,13 +883,41 @@
|
||||
|
||||
|
||||
# Minix filesystems - Juan Cespedes <cespedes@debian.org>
|
||||
0x410 leshort 0x137f Minix filesystem
|
||||
0x410 beshort 0x137f Minix filesystem (big endian)
|
||||
>0x402 beshort !0 \b, %d zones
|
||||
0x410 leshort 0x137f
|
||||
!:strength / 2
|
||||
>0x402 beshort < 100 Minix filesystem, V1, %d zones
|
||||
>0x1e string minix \b, bootable
|
||||
0x410 beshort 0x137f
|
||||
!:strength / 2
|
||||
>0x402 beshort < 100 Minix filesystem, V1 (big endian), %d zones
|
||||
>0x1e string minix \b, bootable
|
||||
0x410 leshort 0x138f
|
||||
!:strength / 2
|
||||
>0x402 beshort < 100 Minix filesystem, V1, 30 char names, %d zones
|
||||
>0x1e string minix \b, bootable
|
||||
0x410 beshort 0x138f
|
||||
!:strength / 2
|
||||
>0x402 beshort < 100 Minix filesystem, V1, 30 char names (big endian), %d zones
|
||||
>0x1e string minix \b, bootable
|
||||
0x410 leshort 0x2468
|
||||
>0x402 beshort < 100 Minix filesystem, V2, %d zones
|
||||
>0x1e string minix \b, bootable
|
||||
0x410 beshort 0x2468
|
||||
>0x402 beshort < 100 Minix filesystem, V2 (big endian), %d zones
|
||||
>0x1e string minix \b, bootable
|
||||
|
||||
0x410 leshort 0x2478
|
||||
>0x402 beshort < 100 Minix filesystem, V2, 30 char names, %d zones
|
||||
>0x1e string minix \b, bootable
|
||||
0x410 leshort 0x2478
|
||||
>0x402 beshort < 100 Minix filesystem, V2, 30 char names, %d zones
|
||||
>0x1e string minix \b, bootable
|
||||
0x410 beshort 0x2478
|
||||
>0x402 beshort !0 Minix filesystem, V2, 30 char names (big endian), %d zones
|
||||
>0x1e string minix \b, bootable
|
||||
0x410 leshort 0x4d5a
|
||||
>0x402 beshort !0 Minix filesystem, V3, %d zones
|
||||
>0x1e string minix \b, bootable
|
||||
0x410 leshort 0x138f Minix filesystem, 30 char names
|
||||
0x410 leshort 0x2468 Minix filesystem, version 2
|
||||
0x410 leshort 0x2478 Minix filesystem, version 2, 30 char names
|
||||
|
||||
# romfs filesystems - Juan Cespedes <cespedes@debian.org>
|
||||
0 string -rom1fs- romfs filesystem, version 1
|
||||
@ -1084,6 +1113,8 @@
|
||||
|
||||
# ext2/ext3 filesystems - Andreas Dilger <adilger@dilger.ca>
|
||||
# ext4 filesystem - Eric Sandeen <sandeen@sandeen.net>
|
||||
# volume label and UUID Russell Coker
|
||||
# http://etbe.coker.com.au/2008/07/08/label-vs-uuid-vs-device/
|
||||
0x438 leshort 0xEF53 Linux
|
||||
>0x44c lelong x rev %d
|
||||
>0x43e leshort x \b.%d
|
||||
@ -1099,25 +1130,32 @@
|
||||
# else large RO_COMPAT?
|
||||
>>>0x464 lelong >0x0000007 ext4 filesystem data
|
||||
# else large INCOMPAT?
|
||||
>>0x460 lelong >0x000003f ext4 filesystem data
|
||||
>>0x460 lelong >0x000003f ext4 filesystem data
|
||||
>0x468 belong x \b, UUID=%08x
|
||||
>0x46c beshort x \b-%04x
|
||||
>0x46e beshort x \b-%04x
|
||||
>0x470 beshort x \b-%04x
|
||||
>0x472 belong x \b-%08x
|
||||
>0x476 beshort x \b%04x
|
||||
>0x478 string >0 \b, volume name "%s"
|
||||
# General flags for any ext* fs
|
||||
>0x460 lelong &0x0000004 (needs journal recovery)
|
||||
>0x43a leshort &0x0000002 (errors)
|
||||
>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)
|
||||
>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)
|
||||
#>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)
|
||||
@ -1195,7 +1233,7 @@
|
||||
|
||||
# CDROM Filesystems
|
||||
# Modified for UDF by gerardo.cacciari@gmail.com
|
||||
32769 string CD001
|
||||
32769 string CD001 #
|
||||
!:mime application/x-iso9660-image
|
||||
>38913 string !NSR0 ISO 9660 CD-ROM filesystem data
|
||||
>38913 string NSR0 UDF filesystem data
|
||||
@ -1238,6 +1276,7 @@
|
||||
# reiserfs - russell@coker.com.au
|
||||
0x10034 string ReIsErFs ReiserFS V3.5
|
||||
0x10034 string ReIsEr2Fs ReiserFS V3.6
|
||||
0x10034 string ReIsEr3Fs ReiserFS V3.6.19
|
||||
>0x1002c leshort x block size %d
|
||||
>0x10032 leshort &2 (mounted or unclean)
|
||||
>0x10000 lelong x num blocks %d
|
||||
@ -1258,11 +1297,70 @@
|
||||
0 string VoIP\ Startup\ and Aculab VoIP firmware
|
||||
>35 string x format %s
|
||||
|
||||
# u-boot/PPCBoot image file
|
||||
# From: Mark Brown <broonie@sirena.org.uk>
|
||||
0 belong 0x27051956 u-boot/PPCBoot image
|
||||
>4 string PPCBoot
|
||||
>>12 string x version %s
|
||||
# From: Mark Brown <broonie@sirena.org.uk> [old]
|
||||
# From: Behan Webster <behanw@websterwood.com>
|
||||
0 belong 0x27051956 u-boot legacy uImage,
|
||||
>32 string x %s,
|
||||
>28 byte 0 Invalid os/
|
||||
>28 byte 1 OpenBSD/
|
||||
>28 byte 2 NetBSD/
|
||||
>28 byte 3 FreeBSD/
|
||||
>28 byte 4 4.4BSD/
|
||||
>28 byte 5 Linux/
|
||||
>28 byte 6 SVR4/
|
||||
>28 byte 7 Esix/
|
||||
>28 byte 8 Solaris/
|
||||
>28 byte 9 Irix/
|
||||
>28 byte 10 SCO/
|
||||
>28 byte 11 Dell/
|
||||
>28 byte 12 NCR/
|
||||
>28 byte 13 LynxOS/
|
||||
>28 byte 14 VxWorks/
|
||||
>28 byte 15 pSOS/
|
||||
>28 byte 16 QNX/
|
||||
>28 byte 17 Firmware/
|
||||
>28 byte 18 RTEMS/
|
||||
>28 byte 19 ARTOS/
|
||||
>28 byte 20 Unity OS/
|
||||
>28 byte 21 INTEGRITY/
|
||||
>29 byte 0 \bInvalid CPU,
|
||||
>29 byte 1 \bAlpha,
|
||||
>29 byte 2 \bARM,
|
||||
>29 byte 3 \bIntel x86,
|
||||
>29 byte 4 \bIA64,
|
||||
>29 byte 5 \bMIPS,
|
||||
>29 byte 6 \bMIPS 64-bit,
|
||||
>29 byte 7 \bPowerPC,
|
||||
>29 byte 8 \bIBM S390,
|
||||
>29 byte 9 \bSuperH,
|
||||
>29 byte 10 \bSparc,
|
||||
>29 byte 11 \bSparc 64-bit,
|
||||
>29 byte 12 \bM68K,
|
||||
>29 byte 13 \bNios-32,
|
||||
>29 byte 14 \bMicroBlaze,
|
||||
>29 byte 15 \bNios-II,
|
||||
>29 byte 16 \bBlackfin,
|
||||
>29 byte 17 \bAVR32,
|
||||
>29 byte 18 \bSTMicroelectronics ST200,
|
||||
>30 byte 0 Invalid Image
|
||||
>30 byte 1 Standalone Program
|
||||
>30 byte 2 OS Kernel Image
|
||||
>30 byte 3 RAMDisk Image
|
||||
>30 byte 4 Multi-File Image
|
||||
>30 byte 5 Firmware Image
|
||||
>30 byte 6 Script File
|
||||
>30 byte 7 Filesystem Image (any type)
|
||||
>30 byte 8 Binary Flat Device Tree BLOB
|
||||
>31 byte 0 (Not compressed),
|
||||
>31 byte 1 (gzip),
|
||||
>31 byte 2 (bzip2),
|
||||
>31 byte 3 (lzma),
|
||||
>12 belong x %d bytes,
|
||||
>8 bedate x %s,
|
||||
>16 belong x Load Address: 0x%08X,
|
||||
>20 belong x Entry Point: 0x%08X,
|
||||
>4 belong x Header CRC: 0x%08X,
|
||||
>24 belong x Data CRC: 0x%08X
|
||||
|
||||
# JFFS2 file system
|
||||
0 leshort 0x1984 Linux old jffs2 filesystem data little endian
|
||||
@ -1275,28 +1373,46 @@
|
||||
>28 beshort <3
|
||||
>>8 belong x %d bytes,
|
||||
>28 beshort >2
|
||||
>>63 bequad x %lld bytes,
|
||||
>>28 beshort <4
|
||||
>>>63 bequad x %lld bytes,
|
||||
>>28 beshort >3
|
||||
>>>40 bequad x %lld bytes,
|
||||
#>>67 belong x %d bytes,
|
||||
>4 belong x %d inodes,
|
||||
>28 beshort <2
|
||||
>>32 beshort x blocksize: %d bytes,
|
||||
>28 beshort >1
|
||||
>>51 belong x blocksize: %d bytes,
|
||||
>39 bedate x created: %s
|
||||
>>28 beshort <4
|
||||
>>>51 belong x blocksize: %d bytes,
|
||||
>>28 beshort >3
|
||||
>>>12 belong x blocksize: %d bytes,
|
||||
>28 beshort <4
|
||||
>>39 bedate x created: %s
|
||||
>28 beshort >3
|
||||
>>8 bedate x created: %s
|
||||
0 string hsqs Squashfs filesystem, little endian,
|
||||
>28 leshort x version %d.
|
||||
>30 leshort x \b%d,
|
||||
>28 leshort <3
|
||||
>>8 lelong x %d bytes,
|
||||
>28 leshort >2
|
||||
>>63 lequad x %lld bytes,
|
||||
>>28 leshort <4
|
||||
>>>63 lequad x %lld bytes,
|
||||
>>28 leshort >3
|
||||
>>>40 lequad x %lld bytes,
|
||||
#>>63 lelong x %d bytes,
|
||||
>4 lelong x %d inodes,
|
||||
>28 leshort <2
|
||||
>>32 leshort x blocksize: %d bytes,
|
||||
>28 leshort >1
|
||||
>>51 lelong x blocksize: %d bytes,
|
||||
>39 ledate x created: %s
|
||||
>>28 leshort <4
|
||||
>>>51 lelong x blocksize: %d bytes,
|
||||
>>28 leshort >3
|
||||
>>>12 lelong x blocksize: %d bytes,
|
||||
>28 leshort <4
|
||||
>>39 ledate x created: %s
|
||||
>28 leshort >3
|
||||
>>8 ledate x created: %s
|
||||
|
||||
0 string td\000 floppy image data (TeleDisk)
|
||||
|
||||
@ -1315,6 +1431,10 @@
|
||||
>>>>>>>>&0 bedate !0 incremental since: %s
|
||||
|
||||
#----------------------------------------------------------
|
||||
#delta ISO Daniel Novotny (dnovotny@redhat.com)
|
||||
0 string DISO Delta ISO data
|
||||
>4 belong x version %d
|
||||
|
||||
# VMS backup savesets - gerardo.cacciari@gmail.com
|
||||
#
|
||||
4 string \x01\x00\x01\x00\x01\x00
|
||||
@ -1359,13 +1479,17 @@
|
||||
0 string CPQRFBLO Compaq/HP RILOE floppy image
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Files-11 On-Disk Structure (OpenVMS file system) - gerardo.cacciari@gmail.com
|
||||
# These bits come from LBN 1 (home block) of ODS-2 and ODS-5 volumes, which is
|
||||
# mapped to VBN 2 of [000000]INDEXF.SYS;1
|
||||
# Files-11 On-Disk Structure (File system for various RSX-11 and VMS flavours).
|
||||
# These bits come from LBN 1 (home block) of ODS-1, ODS-2 and ODS-5 volumes,
|
||||
# which is mapped to VBN 2 of [000000]INDEXF.SYS;1 - gerardo.cacciari@gmail.com
|
||||
#
|
||||
1008 string DECFILE11B Files-11 On-Disk Structure
|
||||
1008 string DECFILE11 Files-11 On-Disk Structure
|
||||
>525 byte x Level %d
|
||||
>525 byte x (ODS-%d OpenVMS file system),
|
||||
>525 byte x (ODS-%d);
|
||||
>1017 string A RSX-11, VAX/VMS or OpenVMS VAX file system;
|
||||
>1017 string B
|
||||
>>525 byte 2 VAX/VMS or OpenVMS file system;
|
||||
>>525 byte 5 OpenVMS Alpha or Itanium file system;
|
||||
>984 string x volume label is '%-12.12s'
|
||||
|
||||
# From: Thomas Klausner <wiz@NetBSD.org>
|
||||
@ -1380,9 +1504,13 @@
|
||||
|
||||
# From Eric Sandeen
|
||||
# GFS2
|
||||
0x10000 belong 0x01161970 GFS2 Filesystem
|
||||
>0x10024 belong x (blocksize %d,
|
||||
>0x10060 string >\0 lockproto %s)
|
||||
0x10000 belong 0x01161970
|
||||
>0x10018 belong 0x0000051d GFS1 Filesystem
|
||||
>>0x10024 belong x (blocksize %d,
|
||||
>>0x10060 string >\0 lockproto %s)
|
||||
>0x10018 belong 0x00000709 GFS2 Filesystem
|
||||
>>0x10024 belong x (blocksize %d,
|
||||
>>0x10060 string >\0 lockproto %s)
|
||||
|
||||
# BTRFS
|
||||
0x10040 string _BHRfS_M BTRFS Filesystem
|
||||
@ -1395,3 +1523,49 @@
|
||||
# dvdisaster's .ecc
|
||||
# From: "Nelson A. de Oliveira" <naoliv@gmail.com>
|
||||
0 string *dvdisaster* dvdisaster error correction file
|
||||
|
||||
# xfs metadump image
|
||||
# mb_magic XFSM at 0; superblock magic XFSB at 1 << mb_blocklog
|
||||
# but can we do the << ? For now it's always 512 (0x200) anyway.
|
||||
0 string XFSM
|
||||
>0x200 string XFSB XFS filesystem metadump image
|
||||
|
||||
# Type: CROM filesystem
|
||||
# From: Werner Fink <werner@suse.de>
|
||||
0 string CROMFS CROMFS
|
||||
>6 string >\0 \b version %2.2s,
|
||||
>8 ulequad >0 \b block data at %lld,
|
||||
>16 ulequad >0 \b fblock table at %lld,
|
||||
>24 ulequad >0 \b inode table at %lld,
|
||||
>32 ulequad >0 \b root at %lld,
|
||||
>40 ulelong >0 \b fblock size = %ld,
|
||||
>44 ulelong >0 \b block size = %ld,
|
||||
>48 ulequad >0 \b bytes = %lld
|
||||
|
||||
# Type: xfs metadump image
|
||||
# From: Daniel Novotny <dnovotny@redhat.com>
|
||||
# mb_magic XFSM at 0; superblock magic XFSB at 1 << mb_blocklog
|
||||
# but can we do the << ? For now it's always 512 (0x200) anyway.
|
||||
0 string XFSM
|
||||
>0x200 string XFSB XFS filesystem metadump image
|
||||
|
||||
# Type: delta ISO
|
||||
# From: Daniel Novotny <dnovotny@redhat.com>
|
||||
0 string DISO Delta ISO data,
|
||||
>4 belong x version %d
|
||||
|
||||
# JFS2 (Journaling File System) image. (Old JFS1 has superblock at 0x1000.)
|
||||
# See linux/fs/jfs/jfs_superblock.h for layout; see jfs_filsys.h for flags.
|
||||
# From: Adam Buchbinder <adam.buchbinder@gmail.com>
|
||||
0x8000 string JFS1
|
||||
# Because it's text-only magic, check a binary value (version) to be sure.
|
||||
# Should always be 2, but mkfs.jfs writes it as 1. Needs to be 2 or 1 to be
|
||||
# mountable.
|
||||
>&0 lelong <3 JFS2 filesystem image
|
||||
# Label is followed by a UUID; we have to limit string length to avoid
|
||||
# appending the UUID in the case of a 16-byte label.
|
||||
>>&144 regex [\x20-\x7E]{1,16} (label "%s")
|
||||
>>&0 lequad x \b, %lld blocks
|
||||
>>&8 lelong x \b, blocksize %d
|
||||
>>&32 lelong&0x00000006 >0 (dirty)
|
||||
>>&36 lelong >0 (compressed)
|
||||
|
3
external/bsd/file/dist/magic/magdir/os9
vendored
3
external/bsd/file/dist/magic/magdir/os9
vendored
@ -1,3 +1,6 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# $File: os9,v 1.6 2009/09/19 16:28:11 christos Exp $
|
||||
#
|
||||
# Copyright (c) 1996 Ignatios Souvatzis. All rights reserved.
|
||||
#
|
||||
|
43
external/bsd/file/dist/magic/magdir/psion
vendored
43
external/bsd/file/dist/magic/magdir/psion
vendored
@ -1,43 +0,0 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# psion: file(1) magic for Psion handhelds data
|
||||
# from: Peter Breitenlohner <peb@mppmu.mpg.de>
|
||||
#
|
||||
0 lelong 0x10000037 Psion Series 5
|
||||
>4 lelong 0x10000039 font file
|
||||
>4 lelong 0x1000003A printer driver
|
||||
>4 lelong 0x1000003B clipboard
|
||||
>4 lelong 0x10000042 multi-bitmap image
|
||||
>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
|
||||
>>8 lelong 0x10000088 sheet file
|
||||
>>8 lelong 0x100001C4 EasyFax initialisation file
|
||||
>4 lelong 0x10000073 OPO module
|
||||
>4 lelong 0x10000074 OPL application
|
||||
>4 lelong 0x1000008A exported multi-bitmap image
|
||||
|
||||
0 lelong 0x10000041 Psion Series 5 ROM multi-bitmap image
|
||||
|
||||
0 lelong 0x10000050 Psion Series 5
|
||||
>4 lelong 0x1000006D database
|
||||
>4 lelong 0x100000E4 ini file
|
||||
|
||||
0 lelong 0x10000079 Psion Series 5 binary:
|
||||
>4 lelong 0x00000000 DLL
|
||||
>4 lelong 0x10000049 comms hardware library
|
||||
>4 lelong 0x1000004A comms protocol library
|
||||
>4 lelong 0x1000005D OPX
|
||||
>4 lelong 0x1000006C application
|
||||
>4 lelong 0x1000008D DLL
|
||||
>4 lelong 0x100000AC logical device driver
|
||||
>4 lelong 0x100000AD physical device driver
|
||||
>4 lelong 0x100000E5 file transfer protocol
|
||||
>4 lelong 0x100000E5 file transfer protocol
|
||||
>4 lelong 0x10000140 printer definition
|
||||
>4 lelong 0x10000141 printer definition
|
||||
|
||||
0 lelong 0x1000007A Psion Series 5 executable
|
353
external/bsd/file/dist/python/py_magic.c
vendored
353
external/bsd/file/dist/python/py_magic.c
vendored
@ -1,353 +0,0 @@
|
||||
/* $NetBSD: py_magic.c,v 1.1.1.1 2009/05/08 16:35:10 christos Exp $ */
|
||||
|
||||
/*
|
||||
Python wrappers for magic functions.
|
||||
|
||||
Copyright (C) Brett Funderburg, Deepfile Corp. Austin, TX, US 2003
|
||||
|
||||
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.
|
||||
3. 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 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 <Python.h>
|
||||
#include <magic.h>
|
||||
#include "py_magic.h"
|
||||
|
||||
/* Exceptions raised by this module */
|
||||
|
||||
PyObject* magic_error_obj;
|
||||
|
||||
/* Create a new magic_cookie_hnd object */
|
||||
PyObject* new_magic_cookie_handle(magic_t cookie)
|
||||
{
|
||||
magic_cookie_hnd* mch;
|
||||
|
||||
mch = PyObject_New(magic_cookie_hnd, &magic_cookie_type);
|
||||
|
||||
mch->cookie = cookie;
|
||||
|
||||
return (PyObject*)mch;
|
||||
}
|
||||
|
||||
static char _magic_open__doc__[] =
|
||||
"Returns a magic cookie on success and None on failure.\n";
|
||||
static PyObject* py_magic_open(PyObject* self, PyObject* args)
|
||||
{
|
||||
int flags = 0;
|
||||
magic_t cookie;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "i", &flags))
|
||||
return NULL;
|
||||
|
||||
if(!(cookie = magic_open(flags))) {
|
||||
PyErr_SetString(magic_error_obj, "failure initializing magic cookie");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return new_magic_cookie_handle(cookie);
|
||||
}
|
||||
|
||||
static char _magic_close__doc__[] =
|
||||
"Closes the magic database and deallocates any resources used.\n";
|
||||
static PyObject* py_magic_close(PyObject* self, PyObject* args)
|
||||
{
|
||||
magic_cookie_hnd* hnd = (magic_cookie_hnd*)self;
|
||||
|
||||
magic_close(hnd->cookie);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static char _magic_error__doc__[] =
|
||||
"Returns a textual explanation of the last error or None \
|
||||
if there was no error.\n";
|
||||
static PyObject* py_magic_error(PyObject* self, PyObject* args)
|
||||
{
|
||||
magic_cookie_hnd* hnd = (magic_cookie_hnd*)self;
|
||||
const char* message = NULL;
|
||||
PyObject* result = Py_None;
|
||||
|
||||
message = magic_error(hnd->cookie);
|
||||
|
||||
if(message != NULL)
|
||||
result = PyString_FromString(message);
|
||||
else
|
||||
Py_INCREF(Py_None);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static char _magic_errno__doc__[] =
|
||||
"Returns a numeric error code. If return value is 0, an internal \
|
||||
magic error occurred. If return value is non-zero, the value is \
|
||||
an OS error code. Use the errno module or os.strerror() can be used \
|
||||
to provide detailed error information.\n";
|
||||
static PyObject* py_magic_errno(PyObject* self, PyObject* args)
|
||||
{
|
||||
magic_cookie_hnd* hnd = (magic_cookie_hnd*)self;
|
||||
return PyInt_FromLong(magic_errno(hnd->cookie));
|
||||
}
|
||||
|
||||
static char _magic_file__doc__[] =
|
||||
"Returns a textual description of the contents of the argument passed \
|
||||
as a filename or None if an error occurred and the MAGIC_ERROR flag \
|
||||
is set. A call to errno() will return the numeric error code.\n";
|
||||
static PyObject* py_magic_file(PyObject* self, PyObject* args)
|
||||
{
|
||||
magic_cookie_hnd* hnd = (magic_cookie_hnd*)self;
|
||||
char* filename = NULL;
|
||||
const char* message = NULL;
|
||||
PyObject* result = Py_None;
|
||||
|
||||
if(!(PyArg_ParseTuple(args, "s", &filename)))
|
||||
return NULL;
|
||||
|
||||
message = magic_file(hnd->cookie, filename);
|
||||
|
||||
if(message != NULL)
|
||||
result = PyString_FromString(message);
|
||||
else
|
||||
Py_INCREF(Py_None);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static char _magic_buffer__doc__[] =
|
||||
"Returns a textual description of the contents of the argument passed \
|
||||
as a buffer or None if an error occurred and the MAGIC_ERROR flag \
|
||||
is set. A call to errno() will return the numeric error code.\n";
|
||||
static PyObject* py_magic_buffer(PyObject* self, PyObject* args)
|
||||
{
|
||||
magic_cookie_hnd* hnd = (magic_cookie_hnd*)self;
|
||||
void* buffer = NULL;
|
||||
int buffer_length = 0;
|
||||
const char* message = NULL;
|
||||
PyObject* result = Py_None;
|
||||
|
||||
if(!(PyArg_ParseTuple(args, "s#", (char**)&buffer, &buffer_length)))
|
||||
return NULL;
|
||||
|
||||
message = magic_buffer(hnd->cookie, buffer, buffer_length);
|
||||
|
||||
if(message != NULL)
|
||||
result = PyString_FromString(message);
|
||||
else
|
||||
Py_INCREF(Py_None);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static char _magic_setflags__doc__[] =
|
||||
"Set flags on the cookie object.\n \
|
||||
Returns -1 on systems that don't support utime(2) or utimes(2) \
|
||||
when MAGIC_PRESERVE_ATIME is set.\n";
|
||||
static PyObject* py_magic_setflags(PyObject* self, PyObject* args)
|
||||
{
|
||||
magic_cookie_hnd* hnd = (magic_cookie_hnd*)self;
|
||||
int flags;
|
||||
int result;
|
||||
|
||||
if(!(PyArg_ParseTuple(args, "i", &flags)))
|
||||
return NULL;
|
||||
|
||||
result = magic_setflags(hnd->cookie, flags);
|
||||
|
||||
return PyInt_FromLong(result);
|
||||
}
|
||||
|
||||
static char _magic_check__doc__[] =
|
||||
"Check the validity of entries in the colon separated list of \
|
||||
database files passed as argument or the default database file \
|
||||
if no argument.\n Returns 0 on success and -1 on failure.\n";
|
||||
static PyObject* py_magic_check(PyObject* self, PyObject* args)
|
||||
{
|
||||
magic_cookie_hnd* hnd = (magic_cookie_hnd*)self;
|
||||
char* filename = NULL;
|
||||
int result;
|
||||
|
||||
if(!(PyArg_ParseTuple(args, "|s", &filename)))
|
||||
return NULL;
|
||||
|
||||
result = magic_check(hnd->cookie, filename);
|
||||
|
||||
return PyInt_FromLong(result);
|
||||
}
|
||||
|
||||
static char _magic_compile__doc__[] =
|
||||
"Compile entries in the colon separated list of database files \
|
||||
passed as argument or the default database file if no argument.\n \
|
||||
Returns 0 on success and -1 on failure.\n \
|
||||
The compiled files created are named from the basename(1) of each file \
|
||||
argument with \".mgc\" appended to it.\n";
|
||||
static PyObject* py_magic_compile(PyObject* self, PyObject* args)
|
||||
{
|
||||
magic_cookie_hnd* hnd = (magic_cookie_hnd*)self;
|
||||
char* filename = NULL;
|
||||
int result;
|
||||
|
||||
if(!(PyArg_ParseTuple(args, "|s", &filename)))
|
||||
return NULL;
|
||||
|
||||
result = magic_compile(hnd->cookie, filename);
|
||||
|
||||
return PyInt_FromLong(result);
|
||||
}
|
||||
|
||||
static char _magic_load__doc__[] =
|
||||
"Must be called to load entries in the colon separated list of database files \
|
||||
passed as argument or the default database file if no argument before \
|
||||
any magic queries can be performed.\n \
|
||||
Returns 0 on success and -1 on failure.\n";
|
||||
static PyObject* py_magic_load(PyObject* self, PyObject* args)
|
||||
{
|
||||
magic_cookie_hnd* hnd = (magic_cookie_hnd*)self;
|
||||
char* filename = NULL;
|
||||
int result;
|
||||
|
||||
if(!(PyArg_ParseTuple(args, "|s", &filename)))
|
||||
return NULL;
|
||||
|
||||
result = magic_load(hnd->cookie, filename);
|
||||
|
||||
return PyInt_FromLong(result);
|
||||
}
|
||||
|
||||
/* object methods */
|
||||
|
||||
static PyMethodDef magic_cookie_hnd_methods[] = {
|
||||
{ "close", (PyCFunction)py_magic_close,
|
||||
METH_NOARGS, _magic_close__doc__ },
|
||||
{ "error", (PyCFunction)py_magic_error,
|
||||
METH_NOARGS, _magic_error__doc__ },
|
||||
{ "file", (PyCFunction)py_magic_file,
|
||||
METH_VARARGS, _magic_file__doc__ },
|
||||
{ "buffer", (PyCFunction)py_magic_buffer,
|
||||
METH_VARARGS, _magic_buffer__doc__ },
|
||||
{ "setflags", (PyCFunction)py_magic_setflags,
|
||||
METH_VARARGS, _magic_setflags__doc__ },
|
||||
{ "check", (PyCFunction)py_magic_check,
|
||||
METH_VARARGS, _magic_check__doc__ },
|
||||
{ "compile", (PyCFunction)py_magic_compile,
|
||||
METH_VARARGS, _magic_compile__doc__ },
|
||||
{ "load", (PyCFunction)py_magic_load,
|
||||
METH_VARARGS, _magic_load__doc__ },
|
||||
{ "errno", (PyCFunction)py_magic_errno,
|
||||
METH_NOARGS, _magic_errno__doc__ },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/* module level methods */
|
||||
|
||||
static PyMethodDef magic_methods[] = {
|
||||
{ "open", (PyCFunction)py_magic_open,
|
||||
METH_VARARGS, _magic_open__doc__ },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void py_magic_dealloc(PyObject* self)
|
||||
{
|
||||
PyObject_Del(self);
|
||||
}
|
||||
|
||||
static PyObject* py_magic_getattr(PyObject* self, char* attrname)
|
||||
{
|
||||
return Py_FindMethod(magic_cookie_hnd_methods, self, attrname);
|
||||
}
|
||||
|
||||
PyTypeObject magic_cookie_type = {
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0,
|
||||
"Magic cookie",
|
||||
sizeof(magic_cookie_hnd),
|
||||
0,
|
||||
py_magic_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
py_magic_getattr, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
0, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_hash */
|
||||
};
|
||||
|
||||
/* Initialize constants */
|
||||
|
||||
static struct const_vals {
|
||||
const char* const name;
|
||||
unsigned int value;
|
||||
} module_const_vals[] = {
|
||||
{ "MAGIC_NONE", MAGIC_NONE },
|
||||
{ "MAGIC_DEBUG", MAGIC_DEBUG },
|
||||
{ "MAGIC_SYMLINK", MAGIC_SYMLINK },
|
||||
{ "MAGIC_COMPRESS", MAGIC_COMPRESS },
|
||||
{ "MAGIC_DEVICES", MAGIC_DEVICES },
|
||||
{ "MAGIC_MIME", MAGIC_MIME },
|
||||
{ "MAGIC_CONTINUE", MAGIC_CONTINUE },
|
||||
{ "MAGIC_CHECK", MAGIC_CHECK },
|
||||
{ "MAGIC_PRESERVE_ATIME", MAGIC_PRESERVE_ATIME },
|
||||
{ "MAGIC_ERROR", MAGIC_ERROR},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static void const_init(PyObject* dict)
|
||||
{
|
||||
struct const_vals* tmp;
|
||||
PyObject *obj;
|
||||
|
||||
for(tmp = module_const_vals; tmp->name; ++tmp) {
|
||||
obj = PyInt_FromLong(tmp->value);
|
||||
PyDict_SetItemString(dict, tmp->name, obj);
|
||||
Py_DECREF(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Module initialization
|
||||
*/
|
||||
|
||||
void initmagic(void)
|
||||
{
|
||||
PyObject* module;
|
||||
PyObject* dict;
|
||||
|
||||
/* Initialize module */
|
||||
|
||||
module = Py_InitModule("magic", magic_methods);
|
||||
dict = PyModule_GetDict(module);
|
||||
|
||||
magic_error_obj = PyErr_NewException("magic.error", NULL, NULL);
|
||||
PyDict_SetItemString(dict, "error", magic_error_obj);
|
||||
|
||||
magic_cookie_type.ob_type = &PyType_Type;
|
||||
|
||||
/* Initialize constants */
|
||||
|
||||
const_init(dict);
|
||||
|
||||
if(PyErr_Occurred())
|
||||
Py_FatalError("can't initialize module magic");
|
||||
}
|
43
external/bsd/file/dist/python/py_magic.h
vendored
43
external/bsd/file/dist/python/py_magic.h
vendored
@ -1,43 +0,0 @@
|
||||
/* $NetBSD: py_magic.h,v 1.1.1.1 2009/05/08 16:35:10 christos Exp $ */
|
||||
|
||||
/*
|
||||
Python wrappers for magic functions.
|
||||
|
||||
Copyright (C) Brett Funderburg, Deepfile Corp. Austin, TX, US 2003
|
||||
|
||||
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.
|
||||
3. 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 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.
|
||||
*/
|
||||
|
||||
#ifndef _PY_MAGIC_H
|
||||
#define _PY_MAGIC_H
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
magic_t cookie;
|
||||
} magic_cookie_hnd;
|
||||
|
||||
extern PyTypeObject magic_cookie_type;
|
||||
|
||||
#endif /* _PY_MAGIC_H */
|
358
external/bsd/file/dist/src/apprentice.c
vendored
358
external/bsd/file/dist/src/apprentice.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: apprentice.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */
|
||||
/* $NetBSD: apprentice.c,v 1.3 2011/05/13 01:52:13 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
@ -35,14 +35,13 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: apprentice.c,v 1.151 2009/03/18 15:19:23 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: apprentice.c,v 1.169 2011/05/10 17:08:13 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: apprentice.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
__RCSID("$NetBSD: apprentice.c,v 1.3 2011/05/13 01:52:13 christos Exp $");
|
||||
#endif
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
#include "patchlevel.h"
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
@ -78,10 +77,6 @@ __RCSID("$NetBSD: apprentice.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
#define MAP_FILE 0
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
struct magic_entry {
|
||||
struct magic *mp;
|
||||
uint32_t cont_count;
|
||||
@ -103,6 +98,7 @@ 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 void apprentice_list(struct mlist *, int );
|
||||
private int apprentice_load(struct magic_set *, struct magic **, uint32_t *,
|
||||
const char *, int);
|
||||
private void byteswap(struct magic *, uint32_t);
|
||||
@ -320,6 +316,13 @@ apprentice_1(struct magic_set *ms, const char *fn, int action,
|
||||
ml->next = mlist;
|
||||
mlist->prev = ml;
|
||||
|
||||
if (action == FILE_LIST) {
|
||||
printf("Binary patterns:\n");
|
||||
apprentice_list(mlist, BINTEST);
|
||||
printf("Text patterns:\n");
|
||||
apprentice_list(mlist, TEXTTEST);
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif /* COMPILE_ONLY */
|
||||
}
|
||||
@ -359,12 +362,10 @@ file_apprentice(struct magic_set *ms, const char *fn, int action)
|
||||
int file_err, errs = -1;
|
||||
struct mlist *mlist;
|
||||
|
||||
init_file_tables();
|
||||
if ((fn = magic_getpath(fn, action)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (fn == NULL)
|
||||
fn = getenv("MAGIC");
|
||||
if (fn == NULL)
|
||||
fn = MAGIC;
|
||||
init_file_tables();
|
||||
|
||||
if ((mfn = strdup(fn)) == NULL) {
|
||||
file_oomem(ms, strlen(fn));
|
||||
@ -556,6 +557,43 @@ apprentice_sort(const void *a, const void *b)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shows sorted patterns list in the order which is used for the matching
|
||||
*/
|
||||
private void
|
||||
apprentice_list(struct mlist *mlist, int mode)
|
||||
{
|
||||
uint32_t magindex = 0;
|
||||
struct mlist *ml;
|
||||
for (ml = mlist->next; ml != mlist; ml = ml->next) {
|
||||
for (magindex = 0; magindex < ml->nmagic; magindex++) {
|
||||
struct magic *m = &ml->magic[magindex];
|
||||
if ((m->flag & mode) != mode) {
|
||||
/* Skip sub-tests */
|
||||
while (magindex + 1 < ml->nmagic &&
|
||||
ml->magic[magindex + 1].cont_level != 0)
|
||||
++magindex;
|
||||
continue; /* Skip to next top-level test*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to iterate over the tree until we find item with
|
||||
* description/mimetype.
|
||||
*/
|
||||
while (magindex + 1 < ml->nmagic &&
|
||||
ml->magic[magindex + 1].cont_level != 0 &&
|
||||
*ml->magic[magindex].desc == '\0' &&
|
||||
*ml->magic[magindex].mimetype == '\0')
|
||||
magindex++;
|
||||
|
||||
printf("Strength = %3" SIZE_T_FORMAT "u : %s [%s]\n",
|
||||
apprentice_magic_strength(m),
|
||||
ml->magic[magindex].desc,
|
||||
ml->magic[magindex].mimetype);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void
|
||||
set_test_type(struct magic *mstart, struct magic *m)
|
||||
{
|
||||
@ -591,19 +629,35 @@ set_test_type(struct magic *mstart, struct magic *m)
|
||||
case FILE_DOUBLE:
|
||||
case FILE_BEDOUBLE:
|
||||
case FILE_LEDOUBLE:
|
||||
mstart->flag |= BINTEST;
|
||||
break;
|
||||
case FILE_STRING:
|
||||
case FILE_PSTRING:
|
||||
case FILE_BESTRING16:
|
||||
case FILE_LESTRING16:
|
||||
/* binary test, set flag */
|
||||
mstart->flag |= BINTEST;
|
||||
/* Allow text overrides */
|
||||
if (mstart->str_flags & STRING_TEXTTEST)
|
||||
mstart->flag |= TEXTTEST;
|
||||
else
|
||||
mstart->flag |= BINTEST;
|
||||
break;
|
||||
case FILE_REGEX:
|
||||
case FILE_SEARCH:
|
||||
/* Check for override */
|
||||
if (mstart->str_flags & STRING_BINTEST)
|
||||
mstart->flag |= BINTEST;
|
||||
if (mstart->str_flags & STRING_TEXTTEST)
|
||||
mstart->flag |= TEXTTEST;
|
||||
|
||||
if (mstart->flag & (TEXTTEST|BINTEST))
|
||||
break;
|
||||
|
||||
/* binary test if pattern is not text */
|
||||
if (file_looks_utf8(m->value.us, (size_t)m->vallen, NULL,
|
||||
NULL) <= 0)
|
||||
mstart->flag |= BINTEST;
|
||||
else
|
||||
mstart->flag |= TEXTTEST;
|
||||
break;
|
||||
case FILE_DEFAULT:
|
||||
/* can't deduce anything; we shouldn't see this at the
|
||||
@ -623,36 +677,38 @@ private void
|
||||
load_1(struct magic_set *ms, int action, const char *fn, int *errs,
|
||||
struct magic_entry **marray, uint32_t *marraycount)
|
||||
{
|
||||
char line[BUFSIZ];
|
||||
size_t lineno = 0;
|
||||
size_t lineno = 0, llen = 0;
|
||||
char *line = NULL;
|
||||
ssize_t len;
|
||||
|
||||
FILE *f = fopen(ms->file = fn, "r");
|
||||
if (f == NULL) {
|
||||
if (errno != ENOENT)
|
||||
file_error(ms, errno, "cannot read magic file `%s'",
|
||||
fn);
|
||||
(*errs)++;
|
||||
} else {
|
||||
/* read and parse this file */
|
||||
for (ms->line = 1;
|
||||
fgets(line, CAST(int, 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] == ':') {
|
||||
return;
|
||||
}
|
||||
|
||||
/* read and parse this file */
|
||||
for (ms->line = 1; (len = getline(&line, &llen, f)) != -1;
|
||||
ms->line++) {
|
||||
if (len == 0) /* null line, garbage, etc */
|
||||
continue;
|
||||
if (line[len - 1] == '\n') {
|
||||
lineno++;
|
||||
line[len - 1] = '\0'; /* delete newline */
|
||||
}
|
||||
switch (line[0]) {
|
||||
case '\0': /* empty, do not parse */
|
||||
case '#': /* comment, do not parse */
|
||||
continue;
|
||||
case '!':
|
||||
if (line[1] == ':') {
|
||||
size_t i;
|
||||
|
||||
for (i = 0; bang[i].name != NULL; i++) {
|
||||
if (len - 2 > bang[i].len &&
|
||||
if ((size_t)(len - 2) > bang[i].len &&
|
||||
memcmp(bang[i].name, line + 2,
|
||||
bang[i].len) == 0)
|
||||
break;
|
||||
@ -678,19 +734,29 @@ load_1(struct magic_set *ms, int action, const char *fn, int *errs,
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/*FALLTHROUGH*/
|
||||
default:
|
||||
if (parse(ms, marray, marraycount, line, lineno,
|
||||
action) != 0)
|
||||
(*errs)++;
|
||||
break;
|
||||
}
|
||||
|
||||
(void)fclose(f);
|
||||
}
|
||||
if (line)
|
||||
free(line);
|
||||
(void)fclose(f);
|
||||
}
|
||||
|
||||
/*
|
||||
* parse a file or directory of files
|
||||
* const char *fn: name of magic file or directory
|
||||
*/
|
||||
private int
|
||||
cmpstrp(const void *p1, const void *p2)
|
||||
{
|
||||
return strcmp(*(char *const *)p1, *(char *const *)p2);
|
||||
}
|
||||
|
||||
private int
|
||||
apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
|
||||
const char *fn, int action)
|
||||
@ -698,8 +764,8 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
|
||||
int errs = 0;
|
||||
struct magic_entry *marray;
|
||||
uint32_t marraycount, i, mentrycount = 0, starttest;
|
||||
size_t slen;
|
||||
char subfn[MAXPATHLEN];
|
||||
size_t slen, files = 0, maxfiles = 0;
|
||||
char **filearr = NULL, *mfn;
|
||||
struct stat st;
|
||||
DIR *dir;
|
||||
struct dirent *d;
|
||||
@ -719,23 +785,45 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
|
||||
(void)fprintf(stderr, "%s\n", usg_hdr);
|
||||
|
||||
/* load directory or file */
|
||||
/* FIXME: Read file names and sort them to prevent
|
||||
non-determinism. See Debian bug #488562. */
|
||||
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);
|
||||
if (!dir) {
|
||||
errs++;
|
||||
goto out;
|
||||
}
|
||||
while ((d = readdir(dir)) != NULL) {
|
||||
if (asprintf(&mfn, "%s/%s", fn, d->d_name) < 0) {
|
||||
file_oomem(ms,
|
||||
strlen(fn) + strlen(d->d_name) + 2);
|
||||
errs++;
|
||||
goto out;
|
||||
}
|
||||
if (stat(mfn, &st) == -1 || !S_ISREG(st.st_mode)) {
|
||||
free(mfn);
|
||||
continue;
|
||||
}
|
||||
if (files >= maxfiles) {
|
||||
size_t mlen;
|
||||
maxfiles = (maxfiles + 1) * 2;
|
||||
mlen = maxfiles * sizeof(*filearr);
|
||||
if ((filearr = CAST(char **,
|
||||
realloc(filearr, mlen))) == NULL) {
|
||||
file_oomem(ms, mlen);
|
||||
free(mfn);
|
||||
errs++;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
} else
|
||||
errs++;
|
||||
filearr[files++] = mfn;
|
||||
}
|
||||
closedir(dir);
|
||||
qsort(filearr, files, sizeof(*filearr), cmpstrp);
|
||||
for (i = 0; i < files; i++) {
|
||||
load_1(ms, action, filearr[i], &errs, &marray,
|
||||
&marraycount);
|
||||
free(filearr[i]);
|
||||
}
|
||||
free(filearr);
|
||||
} else
|
||||
load_1(ms, action, fn, &errs, &marray, &marraycount);
|
||||
if (errs)
|
||||
@ -787,7 +875,8 @@ apprentice_load(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
|
||||
if (marray[i].mp->cont_level == 0)
|
||||
break;
|
||||
if (i != marraycount) {
|
||||
ms->line = marray[i].mp->lineno; /* XXX - Ugh! */
|
||||
/* XXX - Ugh! */
|
||||
ms->line = marray[i].mp->lineno;
|
||||
file_magwarn(ms,
|
||||
"level 0 \"default\" did not sort last");
|
||||
}
|
||||
@ -903,6 +992,11 @@ string_modifier_check(struct magic_set *ms, struct magic *m)
|
||||
if ((ms->flags & MAGIC_CHECK) == 0)
|
||||
return 0;
|
||||
|
||||
if (m->type != FILE_PSTRING && (m->str_flags & PSTRING_LEN) != 0) {
|
||||
file_magwarn(ms,
|
||||
"'/BHhLl' modifiers are only allowed for pascal strings\n");
|
||||
return -1;
|
||||
}
|
||||
switch (m->type) {
|
||||
case FILE_BESTRING16:
|
||||
case FILE_LESTRING16:
|
||||
@ -931,14 +1025,14 @@ string_modifier_check(struct magic_set *ms, struct magic *m)
|
||||
}
|
||||
break;
|
||||
case FILE_REGEX:
|
||||
if ((m->str_flags & STRING_COMPACT_BLANK) != 0) {
|
||||
if ((m->str_flags & STRING_COMPACT_WHITESPACE) != 0) {
|
||||
file_magwarn(ms, "'/%c' not allowed on regex\n",
|
||||
CHAR_COMPACT_BLANK);
|
||||
CHAR_COMPACT_WHITESPACE);
|
||||
return -1;
|
||||
}
|
||||
if ((m->str_flags & STRING_COMPACT_OPTIONAL_BLANK) != 0) {
|
||||
if ((m->str_flags & STRING_COMPACT_OPTIONAL_WHITESPACE) != 0) {
|
||||
file_magwarn(ms, "'/%c' not allowed on regex\n",
|
||||
CHAR_COMPACT_OPTIONAL_BLANK);
|
||||
CHAR_COMPACT_OPTIONAL_WHITESPACE);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
@ -1279,8 +1373,7 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
|
||||
++l;
|
||||
}
|
||||
m->str_range = 0;
|
||||
m->str_flags = 0;
|
||||
m->num_mask = 0;
|
||||
m->str_flags = m->type == FILE_PSTRING ? PSTRING_1_LE : 0;
|
||||
if ((op = get_op(*l)) != -1) {
|
||||
if (!IS_STRING(m->type)) {
|
||||
uint64_t val;
|
||||
@ -1311,12 +1404,13 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
|
||||
"zero range");
|
||||
l = t - 1;
|
||||
break;
|
||||
case CHAR_COMPACT_BLANK:
|
||||
m->str_flags |= STRING_COMPACT_BLANK;
|
||||
break;
|
||||
case CHAR_COMPACT_OPTIONAL_BLANK:
|
||||
case CHAR_COMPACT_WHITESPACE:
|
||||
m->str_flags |=
|
||||
STRING_COMPACT_OPTIONAL_BLANK;
|
||||
STRING_COMPACT_WHITESPACE;
|
||||
break;
|
||||
case CHAR_COMPACT_OPTIONAL_WHITESPACE:
|
||||
m->str_flags |=
|
||||
STRING_COMPACT_OPTIONAL_WHITESPACE;
|
||||
break;
|
||||
case CHAR_IGNORE_LOWERCASE:
|
||||
m->str_flags |= STRING_IGNORE_LOWERCASE;
|
||||
@ -1327,11 +1421,48 @@ parse(struct magic_set *ms, struct magic_entry **mentryp, uint32_t *nmentryp,
|
||||
case CHAR_REGEX_OFFSET_START:
|
||||
m->str_flags |= REGEX_OFFSET_START;
|
||||
break;
|
||||
case CHAR_BINTEST:
|
||||
m->str_flags |= STRING_BINTEST;
|
||||
break;
|
||||
case CHAR_TEXTTEST:
|
||||
m->str_flags |= STRING_TEXTTEST;
|
||||
break;
|
||||
case CHAR_PSTRING_1_LE:
|
||||
if (m->type != FILE_PSTRING)
|
||||
goto bad;
|
||||
m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_1_LE;
|
||||
break;
|
||||
case CHAR_PSTRING_2_BE:
|
||||
if (m->type != FILE_PSTRING)
|
||||
goto bad;
|
||||
m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_2_BE;
|
||||
break;
|
||||
case CHAR_PSTRING_2_LE:
|
||||
if (m->type != FILE_PSTRING)
|
||||
goto bad;
|
||||
m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_2_LE;
|
||||
break;
|
||||
case CHAR_PSTRING_4_BE:
|
||||
if (m->type != FILE_PSTRING)
|
||||
goto bad;
|
||||
m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_4_BE;
|
||||
break;
|
||||
case CHAR_PSTRING_4_LE:
|
||||
if (m->type != FILE_PSTRING)
|
||||
goto bad;
|
||||
m->str_flags = (m->str_flags & ~PSTRING_LEN) | PSTRING_4_LE;
|
||||
break;
|
||||
case CHAR_PSTRING_LENGTH_INCLUDES_ITSELF:
|
||||
if (m->type != FILE_PSTRING)
|
||||
goto bad;
|
||||
m->str_flags |= PSTRING_LENGTH_INCLUDES_ITSELF;
|
||||
break;
|
||||
bad:
|
||||
default:
|
||||
if (ms->flags & MAGIC_CHECK)
|
||||
file_magwarn(ms,
|
||||
"string extension `%c' invalid",
|
||||
*l);
|
||||
"string extension `%c' "
|
||||
"invalid", *l);
|
||||
return -1;
|
||||
}
|
||||
/* allow multiple '/' for readability */
|
||||
@ -1498,7 +1629,8 @@ out:
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse an Apple CREATOR/TYPE annotation from magic file and put it into magic[index - 1]
|
||||
* Parse an Apple CREATOR/TYPE annotation from magic file and put it into
|
||||
* magic[index - 1]
|
||||
*/
|
||||
private int
|
||||
parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line)
|
||||
@ -1508,19 +1640,21 @@ parse_apple(struct magic_set *ms, struct magic_entry *me, const char *line)
|
||||
struct magic *m = &me->mp[me->cont_count == 0 ? 0 : me->cont_count - 1];
|
||||
|
||||
if (m->apple[0] != '\0') {
|
||||
file_magwarn(ms, "Current entry already has a APPLE type `%.8s',"
|
||||
" new type `%s'", m->mimetype, l);
|
||||
file_magwarn(ms, "Current entry already has a APPLE type "
|
||||
"`%.8s', 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->apple); m->apple[i++] = *l++)
|
||||
for (i = 0; *l && ((isascii((unsigned char)*l) &&
|
||||
isalnum((unsigned char)*l)) || strchr("-+/.", *l)) &&
|
||||
i < sizeof(m->apple); m->apple[i++] = *l++)
|
||||
continue;
|
||||
if (i == sizeof(m->apple) && *l) {
|
||||
/* We don't need to NUL terminate here, printing handles it */
|
||||
if (ms->flags & MAGIC_CHECK)
|
||||
file_magwarn(ms, "APPLE type `%s' truncated %zu",
|
||||
line, i);
|
||||
file_magwarn(ms, "APPLE type `%s' truncated %"
|
||||
SIZE_T_FORMAT "u", line, i);
|
||||
}
|
||||
|
||||
if (i > 0)
|
||||
@ -1547,14 +1681,15 @@ parse_mime(struct magic_set *ms, struct magic_entry *me, const char *line)
|
||||
}
|
||||
|
||||
EATAB;
|
||||
for (i = 0; *l && ((isascii((unsigned char)*l) && isalnum((unsigned char)*l))
|
||||
|| strchr("-+/.", *l)) && i < sizeof(m->mimetype); m->mimetype[i++] = *l++)
|
||||
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';
|
||||
m->mimetype[sizeof(m->mimetype) - 1] = '\0';
|
||||
if (ms->flags & MAGIC_CHECK)
|
||||
file_magwarn(ms, "MIME type `%s' truncated %zu",
|
||||
m->mimetype, i);
|
||||
file_magwarn(ms, "MIME type `%s' truncated %"
|
||||
SIZE_T_FORMAT "u", m->mimetype, i);
|
||||
} else
|
||||
m->mimetype[i] = '\0';
|
||||
|
||||
@ -1843,8 +1978,10 @@ getstr(struct magic_set *ms, struct magic *m, const char *s, int warn)
|
||||
if (isprint((unsigned char)c)) {
|
||||
/* Allow escaping of
|
||||
* ``relations'' */
|
||||
if (strchr("<>&^=!", c)
|
||||
== NULL) {
|
||||
if (strchr("<>&^=!", c) == NULL
|
||||
&& (m->type != FILE_REGEX ||
|
||||
strchr("[]().*?^$|{}", c)
|
||||
== NULL)) {
|
||||
file_magwarn(ms, "no "
|
||||
"need to escape "
|
||||
"`%c'", c);
|
||||
@ -1954,7 +2091,7 @@ out:
|
||||
*p = '\0';
|
||||
m->vallen = CAST(unsigned char, (p - origp));
|
||||
if (m->type == FILE_PSTRING)
|
||||
m->vallen++;
|
||||
m->vallen += file_pstring_length_size(m);
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -1984,14 +2121,15 @@ file_showstr(FILE *fp, const char *s, size_t len)
|
||||
char c;
|
||||
|
||||
for (;;) {
|
||||
c = *s++;
|
||||
if (len == ~0U) {
|
||||
c = *s++;
|
||||
if (c == '\0')
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (len-- == 0)
|
||||
break;
|
||||
c = *s++;
|
||||
}
|
||||
if (c >= 040 && c <= 0176) /* TODO isprint && !iscntrl */
|
||||
(void) fputc(c, fp);
|
||||
@ -2126,8 +2264,8 @@ apprentice_map(struct magic_set *ms, struct magic **magicp, uint32_t *nmagicp,
|
||||
else
|
||||
version = ptr[1];
|
||||
if (version != VERSIONNO) {
|
||||
file_error(ms, 0, "File %d.%d supports only version %d magic "
|
||||
"files. `%s' is version %d", FILE_VERSION_MAJOR, patchlevel,
|
||||
file_error(ms, 0, "File %s supports only version %d magic "
|
||||
"files. `%s' is version %d", VERSION,
|
||||
VERSIONNO, dbname, version);
|
||||
goto error1;
|
||||
}
|
||||
@ -2334,6 +2472,8 @@ 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)) {
|
||||
if (m->type == FILE_PSTRING)
|
||||
printf("flags! %d\n", m->str_flags);
|
||||
m->str_range = swap4(m->str_range);
|
||||
m->str_flags = swap4(m->str_flags);
|
||||
}
|
||||
@ -2342,3 +2482,51 @@ bs1(struct magic *m)
|
||||
m->num_mask = swap8(m->num_mask);
|
||||
}
|
||||
}
|
||||
|
||||
protected size_t
|
||||
file_pstring_length_size(const struct magic *m)
|
||||
{
|
||||
switch (m->str_flags & PSTRING_LEN) {
|
||||
case PSTRING_1_LE:
|
||||
return 1;
|
||||
case PSTRING_2_LE:
|
||||
case PSTRING_2_BE:
|
||||
return 2;
|
||||
case PSTRING_4_LE:
|
||||
case PSTRING_4_BE:
|
||||
return 4;
|
||||
default:
|
||||
abort(); /* Impossible */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
protected size_t
|
||||
file_pstring_get_length(const struct magic *m, const char *s)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
||||
switch (m->str_flags & PSTRING_LEN) {
|
||||
case PSTRING_1_LE:
|
||||
len = *s;
|
||||
break;
|
||||
case PSTRING_2_LE:
|
||||
len = (s[1] << 8) | s[0];
|
||||
break;
|
||||
case PSTRING_2_BE:
|
||||
len = (s[0] << 8) | s[1];
|
||||
break;
|
||||
case PSTRING_4_LE:
|
||||
len = (s[3] << 24) | (s[2] << 16) | (s[1] << 8) | s[0];
|
||||
break;
|
||||
case PSTRING_4_BE:
|
||||
len = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
|
||||
break;
|
||||
default:
|
||||
abort(); /* Impossible */
|
||||
}
|
||||
|
||||
if (m->str_flags & PSTRING_LENGTH_INCLUDES_ITSELF)
|
||||
len -= file_pstring_length_size(m);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
206
external/bsd/file/dist/src/cdf.c
vendored
206
external/bsd/file/dist/src/cdf.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cdf.c,v 1.3 2009/05/08 17:43:54 christos Exp $ */
|
||||
/* $NetBSD: cdf.c,v 1.4 2011/05/13 01:52:13 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 Christos Zoulas
|
||||
@ -26,18 +26,21 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
/*
|
||||
* Parse composite document files, the format used in Microsoft Office
|
||||
* document files before they switched to zipped xml.
|
||||
* Parse Composite Document Files, the format used in Microsoft Office
|
||||
* document files before they switched to zipped XML.
|
||||
* Info from: http://sc.openoffice.org/compdocfileformat.pdf
|
||||
*
|
||||
* N.B. This is the "Composite Document File" format, and not the
|
||||
* "Compound Document Format", nor the "Channel Definition Format".
|
||||
*/
|
||||
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: cdf.c,v 1.30 2009/05/06 14:29:47 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: cdf.c,v 1.43 2011/03/30 19:48:13 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: cdf.c,v 1.3 2009/05/08 17:43:54 christos Exp $");
|
||||
__RCSID("$NetBSD: cdf.c,v 1.4 2011/05/13 01:52:13 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -50,6 +53,9 @@ __RCSID("$NetBSD: cdf.c,v 1.3 2009/05/08 17:43:54 christos Exp $");
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef EFTYPE
|
||||
#define EFTYPE EINVAL
|
||||
@ -77,6 +83,19 @@ static union {
|
||||
#define CDF_TOLE8(x) ((uint64_t)(NEED_SWAP ? cdf_tole8(x) : (uint64_t)(x)))
|
||||
#define CDF_TOLE4(x) ((uint32_t)(NEED_SWAP ? cdf_tole4(x) : (uint32_t)(x)))
|
||||
#define CDF_TOLE2(x) ((uint16_t)(NEED_SWAP ? cdf_tole2(x) : (uint16_t)(x)))
|
||||
#define CDF_GETUINT32(x, y) cdf_getuint32(x, y)
|
||||
|
||||
/*
|
||||
* grab a uint32_t from a possibly unaligned address, and return it in
|
||||
* the native host order.
|
||||
*/
|
||||
static uint32_t
|
||||
cdf_getuint32(const uint8_t *p, size_t offs)
|
||||
{
|
||||
uint32_t rv;
|
||||
(void)memcpy(&rv, p + offs * sizeof(uint32_t), sizeof(rv));
|
||||
return CDF_TOLE4(rv);
|
||||
}
|
||||
|
||||
/*
|
||||
* swap a short
|
||||
@ -85,8 +104,8 @@ uint16_t
|
||||
cdf_tole2(uint16_t sv)
|
||||
{
|
||||
uint16_t rv;
|
||||
uint8_t *s = (uint8_t *)(void *)&sv;
|
||||
uint8_t *d = (uint8_t *)(void *)&rv;
|
||||
uint8_t *s = (uint8_t *)(void *)&sv;
|
||||
uint8_t *d = (uint8_t *)(void *)&rv;
|
||||
d[0] = s[1];
|
||||
d[1] = s[0];
|
||||
return rv;
|
||||
@ -99,8 +118,8 @@ uint32_t
|
||||
cdf_tole4(uint32_t sv)
|
||||
{
|
||||
uint32_t rv;
|
||||
uint8_t *s = (uint8_t *)(void *)&sv;
|
||||
uint8_t *d = (uint8_t *)(void *)&rv;
|
||||
uint8_t *s = (uint8_t *)(void *)&sv;
|
||||
uint8_t *d = (uint8_t *)(void *)&rv;
|
||||
d[0] = s[3];
|
||||
d[1] = s[2];
|
||||
d[2] = s[1];
|
||||
@ -115,8 +134,8 @@ uint64_t
|
||||
cdf_tole8(uint64_t sv)
|
||||
{
|
||||
uint64_t rv;
|
||||
uint8_t *s = (uint8_t *)(void *)&sv;
|
||||
uint8_t *d = (uint8_t *)(void *)&rv;
|
||||
uint8_t *s = (uint8_t *)(void *)&sv;
|
||||
uint8_t *d = (uint8_t *)(void *)&rv;
|
||||
d[0] = s[7];
|
||||
d[1] = s[6];
|
||||
d[2] = s[5];
|
||||
@ -234,14 +253,18 @@ cdf_unpack_dir(cdf_directory_t *d, char *buf)
|
||||
}
|
||||
|
||||
static int
|
||||
cdf_check_stream_offset(const cdf_stream_t *sst, const void *p, size_t tail)
|
||||
cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
|
||||
const void *p, size_t tail, int line)
|
||||
{
|
||||
const char *b = (const char *)sst->sst_tab;
|
||||
const char *e = ((const char *)p) + tail;
|
||||
if (e >= b && (size_t)(e - b) < sst->sst_dirlen * sst->sst_len)
|
||||
(void)&line;
|
||||
if (e >= b && (size_t)(e - b) < CDF_SEC_SIZE(h) * sst->sst_len)
|
||||
return 0;
|
||||
DPRINTF((stderr, "offset begin %p end %p %zu >= %zu\n", b, e,
|
||||
(size_t)(e - b), sst->sst_dirlen * sst->sst_len));
|
||||
DPRINTF(("%d: offset begin %p end %p %" SIZE_T_FORMAT "u"
|
||||
" >= %" SIZE_T_FORMAT "u [%" SIZE_T_FORMAT "u %"
|
||||
SIZE_T_FORMAT "u]\n", line, b, e, (size_t)(e - b),
|
||||
CDF_SEC_SIZE(h) * sst->sst_len, CDF_SEC_SIZE(h), sst->sst_len));
|
||||
errno = EFTYPE;
|
||||
return -1;
|
||||
}
|
||||
@ -284,7 +307,8 @@ cdf_read_header(const cdf_info_t *info, cdf_header_t *h)
|
||||
cdf_unpack_header(h, buf);
|
||||
cdf_swap_header(h);
|
||||
if (h->h_magic != CDF_MAGIC) {
|
||||
DPRINTF(("Bad magic 0x%llx != 0x%llx\n",
|
||||
DPRINTF(("Bad magic 0x%" INT64_T_FORMAT "x != 0x%"
|
||||
INT64_T_FORMAT "x\n",
|
||||
(unsigned long long)h->h_magic,
|
||||
(unsigned long long)CDF_MAGIC));
|
||||
goto out;
|
||||
@ -342,15 +366,17 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
|
||||
#define CDF_SEC_LIMIT (UINT32_MAX / (4 * ss))
|
||||
if (h->h_num_sectors_in_master_sat > CDF_SEC_LIMIT / nsatpersec ||
|
||||
i > CDF_SEC_LIMIT) {
|
||||
DPRINTF(("Number of sectors in master SAT too big %u %zu\n",
|
||||
h->h_num_sectors_in_master_sat, i));
|
||||
DPRINTF(("Number of sectors in master SAT too big %u %"
|
||||
SIZE_T_FORMAT "u\n", h->h_num_sectors_in_master_sat, i));
|
||||
errno = EFTYPE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
sat->sat_len = h->h_num_sectors_in_master_sat * nsatpersec + i;
|
||||
DPRINTF(("sat_len = %zu ss = %zu\n", sat->sat_len, ss));
|
||||
if ((sat->sat_tab = calloc(sat->sat_len, ss)) == NULL)
|
||||
DPRINTF(("sat_len = %" SIZE_T_FORMAT "u ss = %" SIZE_T_FORMAT "u\n",
|
||||
sat->sat_len, ss));
|
||||
if ((sat->sat_tab = CAST(cdf_secid_t *, calloc(sat->sat_len, ss)))
|
||||
== NULL)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < __arraycount(h->h_master_sat); i++) {
|
||||
@ -363,7 +389,7 @@ cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat)
|
||||
}
|
||||
}
|
||||
|
||||
if ((msa = calloc(1, ss)) == NULL)
|
||||
if ((msa = CAST(cdf_secid_t *, calloc(1, ss))) == NULL)
|
||||
goto out1;
|
||||
|
||||
mid = h->h_secid_first_sector_in_master_sat;
|
||||
@ -526,7 +552,7 @@ cdf_read_sector_chain(const cdf_info_t *info, const cdf_header_t *h,
|
||||
cdf_secid_t sid, size_t len, cdf_stream_t *scn)
|
||||
{
|
||||
|
||||
if (len < h->h_min_size_standard_stream)
|
||||
if (len < h->h_min_size_standard_stream && sst->sst_tab != NULL)
|
||||
return cdf_read_short_sector_chain(h, ssat, sst, sid, len,
|
||||
scn);
|
||||
else
|
||||
@ -549,11 +575,12 @@ cdf_read_dir(const cdf_info_t *info, const cdf_header_t *h,
|
||||
nd = ss / CDF_DIRECTORY_SIZE;
|
||||
|
||||
dir->dir_len = ns * nd;
|
||||
dir->dir_tab = calloc(dir->dir_len, sizeof(dir->dir_tab[0]));
|
||||
dir->dir_tab = CAST(cdf_directory_t *,
|
||||
calloc(dir->dir_len, sizeof(dir->dir_tab[0])));
|
||||
if (dir->dir_tab == NULL)
|
||||
return -1;
|
||||
|
||||
if ((buf = malloc(ss)) == NULL) {
|
||||
if ((buf = CAST(char *, malloc(ss))) == NULL) {
|
||||
free(dir->dir_tab);
|
||||
return -1;
|
||||
}
|
||||
@ -598,7 +625,7 @@ cdf_read_ssat(const cdf_info_t *info, const cdf_header_t *h,
|
||||
if (ssat->sat_len == (size_t)-1)
|
||||
return -1;
|
||||
|
||||
ssat->sat_tab = calloc(ssat->sat_len, ss);
|
||||
ssat->sat_tab = CAST(cdf_secid_t *, calloc(ssat->sat_len, ss));
|
||||
if (ssat->sat_tab == NULL)
|
||||
return -1;
|
||||
|
||||
@ -647,7 +674,7 @@ cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h,
|
||||
if (d->d_stream_first_sector < 0)
|
||||
goto out;
|
||||
|
||||
return cdf_read_long_sector_chain(info, h, sat,
|
||||
return cdf_read_long_sector_chain(info, h, sat,
|
||||
d->d_stream_first_sector, d->d_size, scn);
|
||||
out:
|
||||
scn->sst_tab = NULL;
|
||||
@ -674,44 +701,45 @@ cdf_read_summary_info(const cdf_info_t *info, const cdf_header_t *h,
|
||||
const cdf_directory_t *d;
|
||||
static const char name[] = "\05SummaryInformation";
|
||||
|
||||
for (i = 0; i < dir->dir_len; i++)
|
||||
if (dir->dir_tab[i].d_type == CDF_DIR_TYPE_USER_STREAM &&
|
||||
cdf_namecmp(name, dir->dir_tab[i].d_name, sizeof(name))
|
||||
for (i = dir->dir_len; i > 0; i--)
|
||||
if (dir->dir_tab[i - 1].d_type == CDF_DIR_TYPE_USER_STREAM &&
|
||||
cdf_namecmp(name, dir->dir_tab[i - 1].d_name, sizeof(name))
|
||||
== 0)
|
||||
break;
|
||||
|
||||
if (i == dir->dir_len) {
|
||||
if (i == 0) {
|
||||
DPRINTF(("Cannot find summary information section\n"));
|
||||
errno = EFTYPE;
|
||||
errno = ESRCH;
|
||||
return -1;
|
||||
}
|
||||
d = &dir->dir_tab[i];
|
||||
d = &dir->dir_tab[i - 1];
|
||||
return cdf_read_sector_chain(info, h, sat, ssat, sst,
|
||||
d->d_stream_first_sector, d->d_size, scn);
|
||||
}
|
||||
|
||||
int
|
||||
cdf_read_property_info(const cdf_stream_t *sst, uint32_t offs,
|
||||
cdf_property_info_t **info, size_t *count, size_t *maxcount)
|
||||
cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h,
|
||||
uint32_t offs, cdf_property_info_t **info, size_t *count, size_t *maxcount)
|
||||
{
|
||||
const cdf_section_header_t *shp;
|
||||
cdf_section_header_t sh;
|
||||
const uint32_t *p, *q, *e;
|
||||
const uint8_t *p, *q, *e;
|
||||
int16_t s16;
|
||||
int32_t s32;
|
||||
uint32_t u32;
|
||||
int64_t s64;
|
||||
uint64_t u64;
|
||||
cdf_timestamp_t tp;
|
||||
size_t i, o, nelements, j;
|
||||
size_t i, o, o4, nelements, j;
|
||||
cdf_property_info_t *inp;
|
||||
|
||||
if (offs > UINT32_MAX / 4) {
|
||||
errno = EFTYPE;
|
||||
goto out;
|
||||
}
|
||||
shp = (const void *)((const char *)sst->sst_tab + offs);
|
||||
if (cdf_check_stream_offset(sst, shp, sizeof(*shp)) == -1)
|
||||
shp = CAST(const cdf_section_header_t *, (const void *)
|
||||
((const char *)sst->sst_tab + offs));
|
||||
if (cdf_check_stream_offset(sst, h, shp, sizeof(*shp), __LINE__) == -1)
|
||||
goto out;
|
||||
sh.sh_len = CDF_TOLE4(shp->sh_len);
|
||||
#define CDF_SHLEN_LIMIT (UINT32_MAX / 8)
|
||||
@ -729,84 +757,92 @@ cdf_read_property_info(const cdf_stream_t *sst, uint32_t offs,
|
||||
if (*maxcount > CDF_PROP_LIMIT)
|
||||
goto out;
|
||||
*maxcount += sh.sh_properties;
|
||||
inp = realloc(*info, *maxcount * sizeof(*inp));
|
||||
inp = CAST(cdf_property_info_t *,
|
||||
realloc(*info, *maxcount * sizeof(*inp)));
|
||||
} else {
|
||||
*maxcount = sh.sh_properties;
|
||||
inp = malloc(*maxcount * sizeof(*inp));
|
||||
inp = CAST(cdf_property_info_t *,
|
||||
malloc(*maxcount * sizeof(*inp)));
|
||||
}
|
||||
if (inp == NULL)
|
||||
goto out;
|
||||
*info = inp;
|
||||
inp += *count;
|
||||
*count += sh.sh_properties;
|
||||
p = (const void *)((const char *)(const void *)sst->sst_tab +
|
||||
offs + sizeof(sh));
|
||||
e = (const void *)(((const char *)(const void *)shp) + sh.sh_len);
|
||||
if (cdf_check_stream_offset(sst, e, 0) == -1)
|
||||
p = CAST(const uint8_t *, (const void *)
|
||||
((const char *)(const void *)sst->sst_tab +
|
||||
offs + sizeof(sh)));
|
||||
e = CAST(const uint8_t *, (const void *)
|
||||
(((const char *)(const void *)shp) + sh.sh_len));
|
||||
if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1)
|
||||
goto out;
|
||||
for (i = 0; i < sh.sh_properties; i++) {
|
||||
q = (const uint32_t *)(const void *)
|
||||
q = (const uint8_t *)(const void *)
|
||||
((const char *)(const void *)p +
|
||||
CDF_TOLE4(p[(i << 1) + 1])) - 2;
|
||||
CDF_GETUINT32(p, (i << 1) + 1)) - 2 * sizeof(uint32_t);
|
||||
if (q > e) {
|
||||
DPRINTF(("Ran of the end %p > %p\n", q, e));
|
||||
goto out;
|
||||
}
|
||||
inp[i].pi_id = CDF_TOLE4(p[i << 1]);
|
||||
inp[i].pi_type = CDF_TOLE4(q[0]);
|
||||
DPRINTF(("%d) id=%x type=%x offs=%x\n", i, inp[i].pi_id,
|
||||
inp[i].pi_type, (const char *)q - (const char *)p));
|
||||
inp[i].pi_id = CDF_GETUINT32(p, i << 1);
|
||||
inp[i].pi_type = CDF_GETUINT32(q, 0);
|
||||
DPRINTF(("%d) id=%x type=%x offs=%x,%d\n", i, inp[i].pi_id,
|
||||
inp[i].pi_type, q - p, CDF_GETUINT32(p, (i << 1) + 1)));
|
||||
if (inp[i].pi_type & CDF_VECTOR) {
|
||||
nelements = CDF_TOLE4(q[1]);
|
||||
nelements = CDF_GETUINT32(q, 1);
|
||||
o = 2;
|
||||
} else {
|
||||
nelements = 1;
|
||||
o = 1;
|
||||
}
|
||||
o4 = o * sizeof(uint32_t);
|
||||
if (inp[i].pi_type & (CDF_ARRAY|CDF_BYREF|CDF_RESERVED))
|
||||
goto unknown;
|
||||
switch (inp[i].pi_type & CDF_TYPEMASK) {
|
||||
case CDF_NULL:
|
||||
case CDF_EMPTY:
|
||||
break;
|
||||
case CDF_SIGNED16:
|
||||
if (inp[i].pi_type & CDF_VECTOR)
|
||||
goto unknown;
|
||||
(void)memcpy(&s16, &q[o], sizeof(s16));
|
||||
(void)memcpy(&s16, &q[o4], sizeof(s16));
|
||||
inp[i].pi_s16 = CDF_TOLE2(s16);
|
||||
break;
|
||||
case CDF_SIGNED32:
|
||||
if (inp[i].pi_type & CDF_VECTOR)
|
||||
goto unknown;
|
||||
(void)memcpy(&s32, &q[o], sizeof(s32));
|
||||
(void)memcpy(&s32, &q[o4], sizeof(s32));
|
||||
inp[i].pi_s32 = CDF_TOLE4((uint32_t)s32);
|
||||
break;
|
||||
case CDF_BOOL:
|
||||
case CDF_UNSIGNED32:
|
||||
if (inp[i].pi_type & CDF_VECTOR)
|
||||
goto unknown;
|
||||
(void)memcpy(&u32, &q[o], sizeof(u32));
|
||||
(void)memcpy(&u32, &q[o4], sizeof(u32));
|
||||
inp[i].pi_u32 = CDF_TOLE4(u32);
|
||||
break;
|
||||
case CDF_SIGNED64:
|
||||
if (inp[i].pi_type & CDF_VECTOR)
|
||||
goto unknown;
|
||||
(void)memcpy(&s64, &q[o], sizeof(s64));
|
||||
(void)memcpy(&s64, &q[o4], sizeof(s64));
|
||||
inp[i].pi_s64 = CDF_TOLE8((uint64_t)s64);
|
||||
break;
|
||||
case CDF_UNSIGNED64:
|
||||
if (inp[i].pi_type & CDF_VECTOR)
|
||||
goto unknown;
|
||||
(void)memcpy(&u64, &q[o], sizeof(u64));
|
||||
(void)memcpy(&u64, &q[o4], sizeof(u64));
|
||||
inp[i].pi_u64 = CDF_TOLE8((uint64_t)u64);
|
||||
break;
|
||||
case CDF_LENGTH32_STRING:
|
||||
case CDF_LENGTH32_WSTRING:
|
||||
if (nelements > 1) {
|
||||
size_t nelem = inp - *info;
|
||||
if (*maxcount > CDF_PROP_LIMIT
|
||||
|| nelements > CDF_PROP_LIMIT)
|
||||
goto out;
|
||||
*maxcount += nelements;
|
||||
inp = realloc(*info, *maxcount * sizeof(*inp));
|
||||
inp = CAST(cdf_property_info_t *,
|
||||
realloc(*info, *maxcount * sizeof(*inp)));
|
||||
if (inp == NULL)
|
||||
goto out;
|
||||
*info = inp;
|
||||
@ -814,22 +850,23 @@ cdf_read_property_info(const cdf_stream_t *sst, uint32_t offs,
|
||||
}
|
||||
DPRINTF(("nelements = %d\n", nelements));
|
||||
for (j = 0; j < nelements; j++, i++) {
|
||||
uint32_t l = CDF_TOLE4(q[o]);
|
||||
uint32_t l = CDF_GETUINT32(q, o);
|
||||
inp[i].pi_str.s_len = l;
|
||||
inp[i].pi_str.s_buf =
|
||||
(const char *)(const void *)(&q[o+1]);
|
||||
inp[i].pi_str.s_buf = (const char *)
|
||||
(const void *)(&q[o4 + sizeof(l)]);
|
||||
DPRINTF(("l = %d, r = %d, s = %s\n", l,
|
||||
CDF_ROUND(l, sizeof(l)),
|
||||
inp[i].pi_str.s_buf));
|
||||
l = 4 + (uint32_t)CDF_ROUND(l, sizeof(l));
|
||||
o += l >> 2;
|
||||
o4 = o * sizeof(uint32_t);
|
||||
}
|
||||
i--;
|
||||
break;
|
||||
case CDF_FILETIME:
|
||||
if (inp[i].pi_type & CDF_VECTOR)
|
||||
goto unknown;
|
||||
(void)memcpy(&tp, &q[o], sizeof(tp));
|
||||
(void)memcpy(&tp, &q[o4], sizeof(tp));
|
||||
inp[i].pi_tp = CDF_TOLE8((uint64_t)tp);
|
||||
break;
|
||||
case CDF_CLIPBOARD:
|
||||
@ -850,16 +887,18 @@ out:
|
||||
}
|
||||
|
||||
int
|
||||
cdf_unpack_summary_info(const cdf_stream_t *sst, cdf_summary_info_header_t *ssi,
|
||||
cdf_property_info_t **info, size_t *count)
|
||||
cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
|
||||
cdf_summary_info_header_t *ssi, cdf_property_info_t **info, size_t *count)
|
||||
{
|
||||
size_t i, maxcount;
|
||||
const cdf_summary_info_header_t *si = sst->sst_tab;
|
||||
const cdf_section_declaration_t *sd = (const void *)
|
||||
((const char *)sst->sst_tab + CDF_SECTION_DECLARATION_OFFSET);
|
||||
const cdf_summary_info_header_t *si =
|
||||
CAST(const cdf_summary_info_header_t *, sst->sst_tab);
|
||||
const cdf_section_declaration_t *sd =
|
||||
CAST(const cdf_section_declaration_t *, (const void *)
|
||||
((const char *)sst->sst_tab + CDF_SECTION_DECLARATION_OFFSET));
|
||||
|
||||
if (cdf_check_stream_offset(sst, si, sizeof(*si)) == -1 ||
|
||||
cdf_check_stream_offset(sst, sd, sizeof(*sd)) == -1)
|
||||
if (cdf_check_stream_offset(sst, h, si, sizeof(*si), __LINE__) == -1 ||
|
||||
cdf_check_stream_offset(sst, h, sd, sizeof(*sd), __LINE__) == -1)
|
||||
return -1;
|
||||
ssi->si_byte_order = CDF_TOLE2(si->si_byte_order);
|
||||
ssi->si_os_version = CDF_TOLE2(si->si_os_version);
|
||||
@ -876,7 +915,7 @@ cdf_unpack_summary_info(const cdf_stream_t *sst, cdf_summary_info_header_t *ssi,
|
||||
errno = EFTYPE;
|
||||
return -1;
|
||||
}
|
||||
if (cdf_read_property_info(sst, CDF_TOLE4(sd->sd_offset),
|
||||
if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset),
|
||||
info, count, &maxcount) == -1)
|
||||
return -1;
|
||||
}
|
||||
@ -1003,7 +1042,8 @@ cdf_dump_sat(const char *prefix, const cdf_sat_t *sat, size_t size)
|
||||
size_t i, j, s = size / sizeof(cdf_secid_t);
|
||||
|
||||
for (i = 0; i < sat->sat_len; i++) {
|
||||
(void)fprintf(stderr, "%s[%zu]:\n%.6d: ", prefix, i, i * s);
|
||||
(void)fprintf(stderr, "%s[%" SIZE_T_FORMAT "u]:\n%.6d: ",
|
||||
prefix, i, i * s);
|
||||
for (j = 0; j < s; j++) {
|
||||
(void)fprintf(stderr, "%5d, ",
|
||||
CDF_TOLE4(sat->sat_tab[s * i + j]));
|
||||
@ -1060,7 +1100,8 @@ cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,
|
||||
d = &dir->dir_tab[i];
|
||||
for (j = 0; j < sizeof(name); j++)
|
||||
name[j] = (char)CDF_TOLE2(d->d_name[j]);
|
||||
(void)fprintf(stderr, "Directory %zu: %s\n", i, name);
|
||||
(void)fprintf(stderr, "Directory %" SIZE_T_FORMAT "u: %s\n",
|
||||
i, name);
|
||||
if (d->d_type < __arraycount(types))
|
||||
(void)fprintf(stderr, "Type: %s\n", types[d->d_type]);
|
||||
else
|
||||
@ -1071,9 +1112,9 @@ cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,
|
||||
(void)fprintf(stderr, "Right child: %d\n", d->d_right_child);
|
||||
(void)fprintf(stderr, "Flags: 0x%x\n", d->d_flags);
|
||||
cdf_timestamp_to_timespec(&ts, d->d_created);
|
||||
(void)fprintf(stderr, "Created %s", ctime(&ts.tv_sec));
|
||||
(void)fprintf(stderr, "Created %s", cdf_ctime(&ts.tv_sec));
|
||||
cdf_timestamp_to_timespec(&ts, d->d_modified);
|
||||
(void)fprintf(stderr, "Modified %s", ctime(&ts.tv_sec));
|
||||
(void)fprintf(stderr, "Modified %s", cdf_ctime(&ts.tv_sec));
|
||||
(void)fprintf(stderr, "Stream %d\n", d->d_stream_first_sector);
|
||||
(void)fprintf(stderr, "Size %d\n", d->d_size);
|
||||
switch (d->d_type) {
|
||||
@ -1095,7 +1136,7 @@ cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1105,12 +1146,14 @@ cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
|
||||
cdf_timestamp_t tp;
|
||||
struct timespec ts;
|
||||
char buf[64];
|
||||
size_t i;
|
||||
size_t i, j;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
|
||||
(void)fprintf(stderr, "%zu) %s: ", i, buf);
|
||||
(void)fprintf(stderr, "%" SIZE_T_FORMAT "u) %s: ", i, buf);
|
||||
switch (info[i].pi_type) {
|
||||
case CDF_NULL:
|
||||
break;
|
||||
case CDF_SIGNED16:
|
||||
(void)fprintf(stderr, "signed 16 [%hd]\n",
|
||||
info[i].pi_s16);
|
||||
@ -1128,6 +1171,13 @@ cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
|
||||
info[i].pi_str.s_len,
|
||||
info[i].pi_str.s_len, info[i].pi_str.s_buf);
|
||||
break;
|
||||
case CDF_LENGTH32_WSTRING:
|
||||
(void)fprintf(stderr, "string %u [",
|
||||
info[i].pi_str.s_len);
|
||||
for (j = 0; j < info[i].pi_str.s_len - 1; j++)
|
||||
(void)fputc(info[i].pi_str.s_buf[j << 1], stderr);
|
||||
(void)fprintf(stderr, "]\n");
|
||||
break;
|
||||
case CDF_FILETIME:
|
||||
tp = info[i].pi_tp;
|
||||
if (tp < 1000000000000000LL) {
|
||||
@ -1136,7 +1186,7 @@ cdf_dump_property_info(const cdf_property_info_t *info, size_t count)
|
||||
} else {
|
||||
cdf_timestamp_to_timespec(&ts, tp);
|
||||
(void)fprintf(stderr, "timestamp %s",
|
||||
ctime(&ts.tv_sec));
|
||||
cdf_ctime(&ts.tv_sec));
|
||||
}
|
||||
break;
|
||||
case CDF_CLIPBOARD:
|
||||
@ -1212,7 +1262,7 @@ main(int argc, char *argv[])
|
||||
if (cdf_read_ssat(&info, &h, &sat, &ssat) == -1)
|
||||
err(1, "Cannot read ssat");
|
||||
#ifdef CDF_DEBUG
|
||||
cdf_dump_sat("SSAT", &h, &ssat, CDF_SHORT_SEC_SIZE(&h));
|
||||
cdf_dump_sat("SSAT", &ssat, CDF_SHORT_SEC_SIZE(&h));
|
||||
#endif
|
||||
|
||||
if (cdf_read_dir(&info, &h, &sat, &dir) == -1)
|
||||
|
20
external/bsd/file/dist/src/cdf_time.c
vendored
20
external/bsd/file/dist/src/cdf_time.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cdf_time.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */
|
||||
/* $NetBSD: cdf_time.c,v 1.3 2011/05/13 01:52:13 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 Christos Zoulas
|
||||
@ -30,9 +30,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: cdf_time.c,v 1.6 2009/03/10 11:44:29 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: cdf_time.c,v 1.10 2011/02/10 17:03:16 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: cdf_time.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
__RCSID("$NetBSD: cdf_time.c,v 1.3 2011/05/13 01:52:13 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -171,6 +171,18 @@ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
cdf_ctime(const time_t *sec)
|
||||
{
|
||||
static char ctbuf[26];
|
||||
char *ptr = ctime(sec);
|
||||
if (ptr != NULL)
|
||||
return ptr;
|
||||
(void)snprintf(ctbuf, sizeof(ctbuf), "*Bad* 0x%16.16llx\n",
|
||||
(long long)*sec);
|
||||
return ctbuf;
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST
|
||||
int
|
||||
@ -182,7 +194,7 @@ main(int argc, char *argv[])
|
||||
char *p, *q;
|
||||
|
||||
cdf_timestamp_to_timespec(&ts, tst);
|
||||
p = ctime(&ts.tv_sec);
|
||||
p = cdf_ctime(&ts.tv_sec);
|
||||
if ((q = strchr(p, '\n')) != NULL)
|
||||
*q = '\0';
|
||||
if (strcmp(ref, p) != 0)
|
||||
|
31
external/bsd/file/dist/src/compress.c
vendored
31
external/bsd/file/dist/src/compress.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: compress.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */
|
||||
/* $NetBSD: compress.c,v 1.3 2011/05/13 01:52:13 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
@ -38,9 +38,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: compress.c,v 1.63 2009/03/23 14:21:51 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: compress.c,v 1.66 2011/03/08 00:39:47 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: compress.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
__RCSID("$NetBSD: compress.c,v 1.3 2011/05/13 01:52:13 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -51,7 +51,9 @@ __RCSID("$NetBSD: compress.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#ifndef __MINGW32__
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_WAIT_H
|
||||
#include <sys/wait.h>
|
||||
#endif
|
||||
@ -83,14 +85,14 @@ private const struct {
|
||||
{ "BZh", 3, { "bzip2", "-cd", NULL }, 1 }, /* bzip2-ed */
|
||||
{ "LZIP", 4, { "lzip", "-cdq", NULL }, 1 },
|
||||
{ "\3757zXZ\0",6,{ "xz", "-cd", NULL }, 1 }, /* XZ Utils */
|
||||
{ "LRZI", 4, { "lrzip", "-dqo-", NULL }, 1 }, /* LRZIP */
|
||||
};
|
||||
|
||||
private size_t ncompr = sizeof(compr) / sizeof(compr[0]);
|
||||
|
||||
#define NODATA ((size_t)~0)
|
||||
|
||||
|
||||
private ssize_t swrite(int, const void *, size_t);
|
||||
#if HAVE_FORK
|
||||
private size_t ncompr = sizeof(compr) / sizeof(compr[0]);
|
||||
private size_t uncompressbuf(struct magic_set *, int, size_t,
|
||||
const unsigned char *, unsigned char **, size_t);
|
||||
#ifdef BUILTIN_DECOMPRESS
|
||||
@ -143,7 +145,7 @@ error:
|
||||
ms->flags |= MAGIC_COMPRESS;
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endif
|
||||
/*
|
||||
* `safe' write for sockets and pipes.
|
||||
*/
|
||||
@ -173,9 +175,12 @@ swrite(int fd, const void *buf, size_t n)
|
||||
* `safe' read for sockets and pipes.
|
||||
*/
|
||||
protected ssize_t
|
||||
sread(int fd, void *buf, size_t n, int canbepipe)
|
||||
sread(int fd, void *buf, size_t n, int canbepipe __attribute__ ((unused)))
|
||||
{
|
||||
ssize_t rv, cnt;
|
||||
ssize_t rv;
|
||||
#ifdef FD_ZERO
|
||||
ssize_t cnt;
|
||||
#endif
|
||||
#ifdef FIONREAD
|
||||
int t = 0;
|
||||
#endif
|
||||
@ -242,7 +247,10 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
|
||||
{
|
||||
char buf[4096];
|
||||
ssize_t r;
|
||||
int tfd, te;
|
||||
int tfd;
|
||||
#ifdef HAVE_MKSTEMP
|
||||
int te;
|
||||
#endif
|
||||
|
||||
(void)strlcpy(buf, "/tmp/file.XXXXXX", sizeof buf);
|
||||
#ifndef HAVE_MKSTEMP
|
||||
@ -300,7 +308,7 @@ file_pipe2file(struct magic_set *ms, int fd, const void *startbuf,
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
#if HAVE_FORK
|
||||
#ifdef BUILTIN_DECOMPRESS
|
||||
|
||||
#define FHCRC (1 << 1)
|
||||
@ -500,3 +508,4 @@ err:
|
||||
return n;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
88
external/bsd/file/dist/src/file.h
vendored
88
external/bsd/file/dist/src/file.h
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: file.h,v 1.3 2009/05/15 12:06:09 christos Exp $ */
|
||||
/* $NetBSD: file.h,v 1.4 2011/05/13 01:52:13 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
@ -29,7 +29,7 @@
|
||||
*/
|
||||
/*
|
||||
* file.h - definitions for file(1) program
|
||||
* @(#)$File: file.h,v 1.119 2009/02/04 18:24:32 christos Exp $
|
||||
* @(#)$File: file.h,v 1.132 2011/03/20 20:36:52 christos Exp $
|
||||
*/
|
||||
|
||||
#ifndef __file_h__
|
||||
@ -39,10 +39,25 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN64
|
||||
#define SIZE_T_FORMAT "I64"
|
||||
#else
|
||||
#define SIZE_T_FORMAT ""
|
||||
#endif
|
||||
#define INT64_T_FORMAT "I64"
|
||||
#else
|
||||
#define SIZE_T_FORMAT "z"
|
||||
#define INT64_T_FORMAT "ll"
|
||||
#endif
|
||||
|
||||
#include <stdio.h> /* Include that here, to make sure __P gets defined */
|
||||
#include <errno.h>
|
||||
#include <fcntl.h> /* For open and flags */
|
||||
#ifdef HAVE_STDINT_H
|
||||
#ifndef __STDC_LIMIT_MACROS
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
@ -61,7 +76,7 @@
|
||||
#define MAGIC "/etc/magic"
|
||||
#endif
|
||||
|
||||
#ifdef __EMX__
|
||||
#if defined(__EMX__) || defined (WIN32)
|
||||
#define PATHSEP ';'
|
||||
#else
|
||||
#define PATHSEP ':'
|
||||
@ -103,15 +118,16 @@
|
||||
#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 MAXstring 64 /* max leng of "string" types */
|
||||
|
||||
#define MAGICNO 0xF11E041C
|
||||
#define VERSIONNO 7
|
||||
#define FILE_MAGICSIZE 200
|
||||
#define VERSIONNO 8
|
||||
#define FILE_MAGICSIZE 232
|
||||
|
||||
#define FILE_LOAD 0
|
||||
#define FILE_CHECK 1
|
||||
#define FILE_COMPILE 2
|
||||
#define FILE_LIST 3
|
||||
|
||||
union VALUETYPE {
|
||||
uint8_t b;
|
||||
@ -138,7 +154,7 @@ struct magic {
|
||||
#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 */
|
||||
#define TEXTTEST 0x40 /* for passing to file_softmagic */
|
||||
|
||||
uint8_t factor;
|
||||
|
||||
@ -264,25 +280,45 @@ struct magic {
|
||||
#define str_flags _u._s._flags
|
||||
/* Words 9-16 */
|
||||
union VALUETYPE value; /* either number or string */
|
||||
/* Words 17-24 */
|
||||
/* Words 17-32 */
|
||||
char desc[MAXDESC]; /* description */
|
||||
/* Words 25-32 */
|
||||
/* Words 33-48 */
|
||||
char mimetype[MAXDESC]; /* MIME type */
|
||||
/* Words 33-34 */
|
||||
/* Words 49-50 */
|
||||
char apple[8];
|
||||
};
|
||||
|
||||
#define BIT(A) (1 << (A))
|
||||
#define STRING_COMPACT_BLANK BIT(0)
|
||||
#define STRING_COMPACT_OPTIONAL_BLANK BIT(1)
|
||||
#define STRING_IGNORE_LOWERCASE BIT(2)
|
||||
#define STRING_IGNORE_UPPERCASE BIT(3)
|
||||
#define REGEX_OFFSET_START BIT(4)
|
||||
#define CHAR_COMPACT_BLANK 'B'
|
||||
#define CHAR_COMPACT_OPTIONAL_BLANK 'b'
|
||||
#define CHAR_IGNORE_LOWERCASE 'c'
|
||||
#define CHAR_IGNORE_UPPERCASE 'C'
|
||||
#define CHAR_REGEX_OFFSET_START 's'
|
||||
#define STRING_COMPACT_WHITESPACE BIT(0)
|
||||
#define STRING_COMPACT_OPTIONAL_WHITESPACE BIT(1)
|
||||
#define STRING_IGNORE_LOWERCASE BIT(2)
|
||||
#define STRING_IGNORE_UPPERCASE BIT(3)
|
||||
#define REGEX_OFFSET_START BIT(4)
|
||||
#define STRING_TEXTTEST BIT(5)
|
||||
#define STRING_BINTEST BIT(6)
|
||||
#define PSTRING_1_BE BIT(7)
|
||||
#define PSTRING_1_LE BIT(7)
|
||||
#define PSTRING_2_BE BIT(8)
|
||||
#define PSTRING_2_LE BIT(9)
|
||||
#define PSTRING_4_BE BIT(10)
|
||||
#define PSTRING_4_LE BIT(11)
|
||||
#define PSTRING_LEN \
|
||||
(PSTRING_1_BE|PSTRING_2_LE|PSTRING_2_BE|PSTRING_4_LE|PSTRING_4_BE)
|
||||
#define PSTRING_LENGTH_INCLUDES_ITSELF BIT(12)
|
||||
#define CHAR_COMPACT_WHITESPACE 'W'
|
||||
#define CHAR_COMPACT_OPTIONAL_WHITESPACE 'w'
|
||||
#define CHAR_IGNORE_LOWERCASE 'c'
|
||||
#define CHAR_IGNORE_UPPERCASE 'C'
|
||||
#define CHAR_REGEX_OFFSET_START 's'
|
||||
#define CHAR_TEXTTEST 't'
|
||||
#define CHAR_BINTEST 'b'
|
||||
#define CHAR_PSTRING_1_BE 'B'
|
||||
#define CHAR_PSTRING_1_LE 'B'
|
||||
#define CHAR_PSTRING_2_BE 'H'
|
||||
#define CHAR_PSTRING_2_LE 'h'
|
||||
#define CHAR_PSTRING_4_BE 'L'
|
||||
#define CHAR_PSTRING_4_LE 'l'
|
||||
#define CHAR_PSTRING_LENGTH_INCLUDES_ITSELF 'J'
|
||||
#define STRING_IGNORE_CASE (STRING_IGNORE_LOWERCASE|STRING_IGNORE_UPPERCASE)
|
||||
#define STRING_DEFAULT_RANGE 100
|
||||
|
||||
@ -352,6 +388,8 @@ protected int file_buffer(struct magic_set *, int, const char *, const void *,
|
||||
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_vprintf(struct magic_set *, const char *, va_list);
|
||||
protected size_t file_printedlen(const struct magic_set *);
|
||||
protected int file_replace(struct magic_set *, const char *, const char *);
|
||||
protected int file_printf(struct magic_set *, const char *, ...)
|
||||
__attribute__((__format__(__printf__, 2, 3)));
|
||||
protected int file_reset(struct magic_set *);
|
||||
@ -359,8 +397,10 @@ protected int file_tryelf(struct magic_set *, int, const unsigned char *,
|
||||
size_t);
|
||||
protected int file_trycdf(struct magic_set *, int, const unsigned char *,
|
||||
size_t);
|
||||
#if HAVE_FORK
|
||||
protected int file_zmagic(struct magic_set *, int, const char *,
|
||||
const unsigned char *, size_t);
|
||||
#endif
|
||||
protected int file_ascmagic(struct magic_set *, const unsigned char *, size_t);
|
||||
protected int file_ascmagic_with_encoding(struct magic_set *,
|
||||
const unsigned char *, size_t, unichar *, size_t, const char *,
|
||||
@ -391,6 +431,8 @@ 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 *);
|
||||
protected size_t file_pstring_length_size(const struct magic *);
|
||||
protected size_t file_pstring_get_length(const struct magic *, const char *);
|
||||
#ifdef __EMX__
|
||||
protected int file_os2_apptype(struct magic_set *, const char *, const void *,
|
||||
size_t);
|
||||
@ -426,6 +468,10 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
|
||||
#ifndef HAVE_STRLCAT
|
||||
size_t strlcat(char *dst, const char *src, size_t siz);
|
||||
#endif
|
||||
#ifndef HAVE_GETLINE
|
||||
ssize_t getline(char **dst, size_t *len, FILE *fp);
|
||||
ssize_t getdelim(char **dst, size_t *len, int delimiter, FILE *fp);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_MMAP) && defined(HAVE_SYS_MMAN_H) && !defined(QUICK)
|
||||
#define QUICK
|
||||
@ -436,7 +482,7 @@ size_t strlcat(char *dst, const char *src, size_t siz);
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 3)
|
||||
#define FILE_RCSID(id) \
|
||||
static const char rcsid[] __attribute__((__used__)) = id;
|
||||
#else
|
||||
|
13
external/bsd/file/dist/src/fsmagic.c
vendored
13
external/bsd/file/dist/src/fsmagic.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fsmagic.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */
|
||||
/* $NetBSD: fsmagic.c,v 1.3 2011/05/13 01:52:13 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
@ -35,9 +35,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: fsmagic.c,v 1.59 2009/02/03 20:27:51 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: fsmagic.c,v 1.62 2010/09/20 20:16:08 rrt Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: fsmagic.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
__RCSID("$NetBSD: fsmagic.c,v 1.3 2011/05/13 01:52:13 christos Exp $");
|
||||
#endif
|
||||
#endif /* lint */
|
||||
|
||||
@ -65,7 +65,7 @@ __RCSID("$NetBSD: fsmagic.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
# define minor(dev) ((dev) & 0xff)
|
||||
#endif
|
||||
#undef HAVE_MAJOR
|
||||
|
||||
#ifdef S_IFLNK
|
||||
private int
|
||||
bad_link(struct magic_set *ms, int err, char *buf)
|
||||
{
|
||||
@ -89,7 +89,7 @@ bad_link(struct magic_set *ms, int err, char *buf)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
private int
|
||||
handle_mime(struct magic_set *ms, int mime, const char *str)
|
||||
{
|
||||
@ -140,7 +140,8 @@ file_fsmagic(struct magic_set *ms, const char *fn, struct stat *sb)
|
||||
if (file_printf(ms, "cannot open `%s' (%s)",
|
||||
fn, strerror(errno)) == -1)
|
||||
return -1;
|
||||
return 1;
|
||||
ms->event_flags |= EVENT_HAD_ERR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!mime) {
|
||||
|
57
external/bsd/file/dist/src/funcs.c
vendored
57
external/bsd/file/dist/src/funcs.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: funcs.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */
|
||||
/* $NetBSD: funcs.c,v 1.3 2011/05/13 01:52:13 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Christos Zoulas 2003.
|
||||
@ -30,9 +30,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: funcs.c,v 1.53 2009/04/07 11:07:00 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: funcs.c,v 1.57 2011/05/11 01:02:41 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: funcs.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
__RCSID("$NetBSD: funcs.c,v 1.3 2011/05/13 01:52:13 christos Exp $");
|
||||
#endif
|
||||
#endif /* lint */
|
||||
|
||||
@ -109,7 +109,7 @@ file_error_core(struct magic_set *ms, int error, const char *f, va_list va,
|
||||
if (lineno != 0) {
|
||||
free(ms->o.buf);
|
||||
ms->o.buf = NULL;
|
||||
file_printf(ms, "line %zu: ", lineno);
|
||||
file_printf(ms, "line %" SIZE_T_FORMAT "u: ", lineno);
|
||||
}
|
||||
file_vprintf(ms, f, va);
|
||||
if (error > 0)
|
||||
@ -144,7 +144,8 @@ file_magerror(struct magic_set *ms, const char *f, ...)
|
||||
protected void
|
||||
file_oomem(struct magic_set *ms, size_t len)
|
||||
{
|
||||
file_error(ms, errno, "cannot allocate %zu bytes", len);
|
||||
file_error(ms, errno, "cannot allocate %" SIZE_T_FORMAT "u bytes",
|
||||
len);
|
||||
}
|
||||
|
||||
protected void
|
||||
@ -160,9 +161,10 @@ file_badread(struct magic_set *ms)
|
||||
}
|
||||
|
||||
#ifndef COMPILE_ONLY
|
||||
/*ARGSUSED*/
|
||||
protected int
|
||||
file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
|
||||
size_t nb)
|
||||
file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((__unused__)),
|
||||
const void *buf, size_t nb)
|
||||
{
|
||||
int m = 0, rv = 0, looks_text = 0;
|
||||
int mime = ms->flags & MAGIC_MIME;
|
||||
@ -206,7 +208,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAVE_FORK
|
||||
/* try compression stuff */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_COMPRESS) == 0)
|
||||
if ((m = file_zmagic(ms, fd, inname, ubuf, nb)) != 0) {
|
||||
@ -214,7 +216,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname, const void *buf,
|
||||
(void)fprintf(stderr, "zmagic %d\n", m);
|
||||
goto done;
|
||||
}
|
||||
|
||||
#endif
|
||||
/* Check if we have a tar file */
|
||||
if ((ms->flags & MAGIC_NO_CHECK_TAR) == 0)
|
||||
if ((m = file_is_tar(ms, ubuf, nb)) != 0) {
|
||||
@ -397,9 +399,9 @@ file_getbuffer(struct magic_set *ms)
|
||||
}
|
||||
#endif
|
||||
|
||||
for (np = ms->o.pbuf, op = ms->o.buf; *op; op++) {
|
||||
for (np = ms->o.pbuf, op = ms->o.buf; *op;) {
|
||||
if (isprint((unsigned char)*op)) {
|
||||
*np++ = *op;
|
||||
*np++ = *op++;
|
||||
} else {
|
||||
OCTALIFY(np, op);
|
||||
}
|
||||
@ -430,3 +432,36 @@ file_check_mem(struct magic_set *ms, unsigned int level)
|
||||
#endif /* ENABLE_CONDITIONALS */
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected size_t
|
||||
file_printedlen(const struct magic_set *ms)
|
||||
{
|
||||
return ms->o.buf == NULL ? 0 : strlen(ms->o.buf);
|
||||
}
|
||||
|
||||
protected int
|
||||
file_replace(struct magic_set *ms, const char *pat, const char *rep)
|
||||
{
|
||||
regex_t rx;
|
||||
int rc;
|
||||
|
||||
rc = regcomp(&rx, pat, REG_EXTENDED);
|
||||
if (rc) {
|
||||
char errmsg[512];
|
||||
(void)regerror(rc, &rx, errmsg, sizeof(errmsg));
|
||||
file_magerror(ms, "regex error %d, (%s)", rc, errmsg);
|
||||
return -1;
|
||||
} else {
|
||||
regmatch_t rm;
|
||||
int nm = 0;
|
||||
while (regexec(&rx, ms->o.buf, 1, &rm, 0) == 0) {
|
||||
ms->o.buf[rm.rm_so] = '\0';
|
||||
if (file_printf(ms, "%s%s", rep,
|
||||
rm.rm_eo != 0 ? ms->o.buf + rm.rm_eo : "") == -1)
|
||||
return -1;
|
||||
nm++;
|
||||
}
|
||||
regfree(&rx);
|
||||
return nm;
|
||||
}
|
||||
}
|
||||
|
164
external/bsd/file/dist/src/magic.c
vendored
164
external/bsd/file/dist/src/magic.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: magic.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */
|
||||
/* $NetBSD: magic.c,v 1.3 2011/05/13 01:52:13 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Christos Zoulas 2003.
|
||||
@ -27,13 +27,18 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
#endif
|
||||
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: magic.c,v 1.62 2009/03/20 21:25:41 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: magic.c,v 1.73 2011/05/10 17:08:14 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: magic.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
__RCSID("$NetBSD: magic.c,v 1.3 2011/05/13 01:52:13 christos Exp $");
|
||||
#endif
|
||||
#endif /* lint */
|
||||
|
||||
@ -63,10 +68,6 @@ __RCSID("$NetBSD: magic.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
#include <unistd.h> /* for read() */
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h> /* for byte swapping */
|
||||
|
||||
#include "patchlevel.h"
|
||||
|
||||
#ifndef PIPE_BUF
|
||||
/* Get the PIPE_BUF from pathconf */
|
||||
#ifdef _PC_PIPE_BUF
|
||||
@ -80,6 +81,7 @@ private void free_mlist(struct mlist *);
|
||||
private void close_and_restore(const struct magic_set *, const char *, int,
|
||||
const struct stat *);
|
||||
private int unreadable_info(struct magic_set *, mode_t, const char *);
|
||||
private const char* get_default_magic(void);
|
||||
#ifndef COMPILE_ONLY
|
||||
private const char *file_or_fd(struct magic_set *, const char *, int);
|
||||
#endif
|
||||
@ -88,6 +90,144 @@ private const char *file_or_fd(struct magic_set *, const char *, int);
|
||||
#define STDIN_FILENO 0
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL,
|
||||
DWORD fdwReason __attribute__((__unused__)),
|
||||
LPVOID lpvReserved __attribute__((__unused__)));
|
||||
|
||||
CHAR dllpath[MAX_PATH + 1] = { 0 };
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL,
|
||||
DWORD fdwReason __attribute__((__unused__)),
|
||||
LPVOID lpvReserved __attribute__((__unused__)))
|
||||
{
|
||||
if (dllpath[0] == 0 &&
|
||||
GetModuleFileNameA(hinstDLL, dllpath, MAX_PATH) != 0)
|
||||
PathRemoveFileSpecA(dllpath);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
private const char *
|
||||
get_default_magic(void)
|
||||
{
|
||||
static const char hmagic[] = "/.magic/magic.mgc";
|
||||
static char *default_magic;
|
||||
char *home, *hmagicpath;
|
||||
|
||||
#ifndef WIN32
|
||||
struct stat st;
|
||||
|
||||
if (default_magic) {
|
||||
free(default_magic);
|
||||
default_magic = NULL;
|
||||
}
|
||||
if ((home = getenv("HOME")) == NULL)
|
||||
return MAGIC;
|
||||
|
||||
if (asprintf(&hmagicpath, "%s/.magic", home) < 0)
|
||||
return MAGIC;
|
||||
if (stat(hmagicpath, &st) == -1)
|
||||
goto out;
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
free(hmagicpath);
|
||||
if (asprintf(&hmagicpath, "%s/%s", home, hmagic) < 0)
|
||||
return MAGIC;
|
||||
if (access(hmagicpath, R_OK) == -1)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (asprintf(&default_magic, "%s:%s", hmagicpath, MAGIC) < 0)
|
||||
goto out;
|
||||
free(hmagicpath);
|
||||
return default_magic;
|
||||
out:
|
||||
default_magic = NULL;
|
||||
free(hmagicpath);
|
||||
return MAGIC;
|
||||
#else
|
||||
char *hmagicp = hmagicpath;
|
||||
char *tmppath = NULL;
|
||||
|
||||
#define APPENDPATH() \
|
||||
do { \
|
||||
if (tmppath && access(tmppath, R_OK) != -1) { \
|
||||
if (hmagicpath == NULL) { \
|
||||
hmagicpath = tmppath; \
|
||||
tmppath = NULL; \
|
||||
} else { \
|
||||
free(tmppath); \
|
||||
if (asprintf(&hmagicp, "%s%c%s", hmagicpath, \
|
||||
PATHSEP, tmppath) >= 0) { \
|
||||
free(hmagicpath); \
|
||||
hmagicpath = hmagicp; \
|
||||
} \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
if (default_magic) {
|
||||
free(default_magic);
|
||||
default_magic = NULL;
|
||||
}
|
||||
|
||||
/* First, try to get user-specific magic file */
|
||||
if ((home = getenv("LOCALAPPDATA")) == NULL) {
|
||||
if ((home = getenv("USERPROFILE")) != NULL)
|
||||
if (asprintf(&tmppath,
|
||||
"%s/Local Settings/Application Data%s", home,
|
||||
hmagic) < 0)
|
||||
tmppath = NULL;
|
||||
} else {
|
||||
if (asprintf(&tmppath, "%s%s", home, hmagic) < 0)
|
||||
tmppath = NULL;
|
||||
}
|
||||
|
||||
APPENDPATH();
|
||||
|
||||
/* Second, try to get a magic file from Common Files */
|
||||
if ((home = getenv("COMMONPROGRAMFILES")) != NULL) {
|
||||
if (asprintf(&tmppath, "%s%s", home, hmagic) >= 0)
|
||||
APPENDPATH();
|
||||
}
|
||||
|
||||
|
||||
/* Third, try to get magic file relative to dll location */
|
||||
if (dllpath[0] != 0) {
|
||||
if (strlen(dllpath) > 3 &&
|
||||
stricmp(&dllpath[strlen(dllpath) - 3], "bin") == 0) {
|
||||
if (asprintf(&tmppath,
|
||||
"%s/../share/misc/magic.mgc", dllpath) >= 0)
|
||||
APPENDPATH();
|
||||
} else {
|
||||
if (asprintf(&tmppath,
|
||||
"%s/share/misc/magic.mgc", dllpath) >= 0)
|
||||
APPENDPATH();
|
||||
else if (asprintf(&tmppath,
|
||||
"%s/magic.mgc", dllpath) >= 0)
|
||||
APPENDPATH();
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't put MAGIC constant - it likely points to a file within MSys
|
||||
tree */
|
||||
default_magic = hmagicpath;
|
||||
return default_magic;
|
||||
#endif
|
||||
}
|
||||
|
||||
public const char *
|
||||
magic_getpath(const char *magicfile, int action)
|
||||
{
|
||||
if (magicfile != NULL)
|
||||
return magicfile;
|
||||
|
||||
magicfile = getenv("MAGIC");
|
||||
if (magicfile != NULL)
|
||||
return magicfile;
|
||||
|
||||
return action == FILE_LOAD ? get_default_magic() : MAGIC;
|
||||
}
|
||||
|
||||
public struct magic_set *
|
||||
magic_open(int flags)
|
||||
{
|
||||
@ -197,6 +337,14 @@ magic_check(struct magic_set *ms, const char *magicfile)
|
||||
return ml ? 0 : -1;
|
||||
}
|
||||
|
||||
public int
|
||||
magic_list(struct magic_set *ms, const char *magicfile)
|
||||
{
|
||||
struct mlist *ml = file_apprentice(ms, magicfile, FILE_LIST);
|
||||
free_mlist(ml);
|
||||
return ml ? 0 : -1;
|
||||
}
|
||||
|
||||
private void
|
||||
close_and_restore(const struct magic_set *ms, const char *name, int fd,
|
||||
const struct stat *sb)
|
||||
@ -287,7 +435,9 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd)
|
||||
int flags = O_RDONLY|O_BINARY;
|
||||
|
||||
if (stat(inname, &sb) == 0 && S_ISFIFO(sb.st_mode)) {
|
||||
#ifdef O_NONBLOCK
|
||||
flags |= O_NONBLOCK;
|
||||
#endif
|
||||
ispipe = 1;
|
||||
}
|
||||
|
||||
|
354
external/bsd/file/dist/src/patchlevel.h
vendored
354
external/bsd/file/dist/src/patchlevel.h
vendored
@ -1,354 +0,0 @@
|
||||
/* $NetBSD: patchlevel.h,v 1.1.1.1 2009/05/08 16:35:06 christos Exp $ */
|
||||
|
||||
#define FILE_VERSION_MAJOR 5
|
||||
#define patchlevel 3
|
||||
|
||||
/*
|
||||
* Patchlevel file for Ian Darwin's MAGIC command.
|
||||
* $File: patchlevel.h,v 1.74 2009/05/06 20:32:48 christos Exp $
|
||||
*
|
||||
* Log: patchlevel.h,v
|
||||
* Revision 1.74 2009/05/06 20:32:48 christos
|
||||
* welcome to 5.03
|
||||
*
|
||||
* Revision 1.73 2009/05/04 15:15:13 christos
|
||||
* 5.02...
|
||||
*
|
||||
* Revision 1.72 2009/04/30 21:20:15 christos
|
||||
* 5.01 we are almost here.
|
||||
*
|
||||
* Revision 1.71 2009/01/21 19:09:42 christos
|
||||
* file 5.0
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Revision 1.66 2007/12/27 16:38:24 christos
|
||||
* welcome to 4.22
|
||||
*
|
||||
* Revision 1.65 2007/05/24 17:22:27 christos
|
||||
* Welcome to 4.21
|
||||
*
|
||||
* Revision 1.64 2007/03/01 22:14:55 christos
|
||||
* welcome to 4.20
|
||||
*
|
||||
* Revision 1.63 2007/01/12 17:38:28 christos
|
||||
* Use File id.
|
||||
*
|
||||
* Revision 1.62 2006/12/11 21:49:58 christos
|
||||
* time for 4.19
|
||||
*
|
||||
* Revision 1.61 2006/10/31 21:18:09 christos
|
||||
* bump
|
||||
*
|
||||
* Revision 1.60 2006/03/02 22:15:12 christos
|
||||
* welcome to 4.17
|
||||
*
|
||||
* Revision 1.59 2005/10/17 17:15:21 christos
|
||||
* welcome to 4.16
|
||||
*
|
||||
* Revision 1.58 2005/08/18 15:52:56 christos
|
||||
* welcome to 4.15
|
||||
*
|
||||
* Revision 1.57 2005/06/25 15:52:14 christos
|
||||
* Welcome to 4.14
|
||||
*
|
||||
* Revision 1.56 2005/02/09 19:25:13 christos
|
||||
* Welcome to 4.13
|
||||
*
|
||||
* Revision 1.55 2004/11/24 18:57:47 christos
|
||||
* Re-do the autoconf stuff once more; passes make dist now.
|
||||
*
|
||||
* Revision 1.54 2004/11/21 05:52:05 christos
|
||||
* ready for 4.11
|
||||
*
|
||||
* Revision 1.53 2004/07/24 20:40:46 christos
|
||||
* welcome to 4.10
|
||||
*
|
||||
* Revision 1.52 2004/04/07 00:32:25 christos
|
||||
* welcome to 4.09
|
||||
*
|
||||
* Revision 1.51 2004/03/22 21:17:11 christos
|
||||
* welcome to 4.08.
|
||||
*
|
||||
* Revision 1.50 2003/12/23 17:34:04 christos
|
||||
* 4.07
|
||||
*
|
||||
* Revision 1.49 2003/10/15 02:08:27 christos
|
||||
* welcome to 4.06
|
||||
*
|
||||
* Revision 1.48 2003/09/12 19:41:14 christos
|
||||
* this is 4.04
|
||||
*
|
||||
* Revision 1.47 2003/05/23 21:38:21 christos
|
||||
* welcome to 4.03
|
||||
*
|
||||
* Revision 1.46 2003/04/02 18:57:43 christos
|
||||
* prepare for 4.02
|
||||
*
|
||||
* Revision 1.45 2003/03/26 15:37:25 christos
|
||||
* - Pass lint
|
||||
* - make NULL in magic_file mean stdin
|
||||
* - Fix "-" argument to file to pass NULL to magic_file
|
||||
* - avoid pointer casts by using memcpy
|
||||
* - rename magic_buf -> magic_buffer
|
||||
* - keep only the first error
|
||||
* - manual page: new sentence, new line
|
||||
* - fix typo in api function (magic_buf -> magic_buffer)
|
||||
*
|
||||
* Revision 1.44 2003/03/23 22:23:31 christos
|
||||
* finish librarification.
|
||||
*
|
||||
* Revision 1.43 2003/03/23 21:16:26 christos
|
||||
* update copyrights.
|
||||
*
|
||||
* Revision 1.42 2003/03/23 04:06:05 christos
|
||||
* Library re-organization
|
||||
*
|
||||
* Revision 1.41 2003/02/27 20:53:45 christos
|
||||
* - fix memory allocation problem (Jeff Johnson)
|
||||
* - fix stack overflow corruption (David Endler)
|
||||
* - fixes from NetBSD source (Antti Kantee)
|
||||
* - magic fixes
|
||||
*
|
||||
* Revision 1.40 2003/02/08 18:33:53 christos
|
||||
* - detect inttypes.h too (Dave Love <d.love@dl.ac.uk>)
|
||||
* - eliminate unsigned char warnings (Petter Reinholdtsen <pere@hungry.com>)
|
||||
* - better elf PT_NOTE handling (Nalin Dahyabhai <nalin@redhat.com>)
|
||||
* - add options to format the output differently
|
||||
* - much more magic.
|
||||
*
|
||||
* Revision 1.39 2002/07/03 18:57:52 christos
|
||||
* - ansify/c99ize
|
||||
* - more magic
|
||||
* - better COMPILE_ONLY support.
|
||||
* - new magic files.
|
||||
* - fix solaris compilation problems.
|
||||
*
|
||||
* Revision 1.38 2002/05/16 18:45:56 christos
|
||||
* - pt_note elf additions from NetBSD
|
||||
* - EMX os specific changes (Alexander Mai)
|
||||
* - stdint.h detection, acconfig.h fixes (Maciej W. Rozycki, Franz Korntner)
|
||||
* - regex file additions (Kim Cromie)
|
||||
* - getopt_long support and misc cleanups (Michael Piefel)
|
||||
* - many magic fixes and additions
|
||||
*
|
||||
* Revision 1.37 2001/09/03 14:44:22 christos
|
||||
* daylight/tm_isdst detection
|
||||
* magic fixes
|
||||
* don't eat the whole file if it has only nulls
|
||||
*
|
||||
* Revision 1.36 2001/07/22 21:04:15 christos
|
||||
* - magic fixes
|
||||
* - add new operators, pascal strings, UTC date printing, $HOME/.magic
|
||||
* [from "Tom N Harris" <telliamed@mac.com>]
|
||||
*
|
||||
* Revision 1.35 2001/04/24 14:40:25 christos
|
||||
* - rename magic file sgi to mips and fix it
|
||||
* - add support for building magic.mgc
|
||||
* - portability fixes for mmap()
|
||||
* - try gzip before uncompress, because uncompress sometimes hangs
|
||||
* - be more conservative about pipe reads and writes
|
||||
* - many magic fixes
|
||||
*
|
||||
* Revision 1.34 2001/03/12 05:05:57 christos
|
||||
* - new compiled magic format
|
||||
* - lots of magic additions
|
||||
*
|
||||
* Revision 1.33 2000/11/13 00:30:50 christos
|
||||
* - wordperfect magic fix: freebsd pr 9388
|
||||
* - more msdos fixes from freebsd pr's 20131 and 20812
|
||||
* - sas and spss magic [Bruce Foster]
|
||||
* - mkinstalldirs [John Fremlin]
|
||||
* - sgi opengl fixes [Michael Pruett]
|
||||
* - netbsd magic fixes [Ignatios Souvatzis]
|
||||
* - audio additions [Michael Pruett]
|
||||
* - fix problem with non ansi RCSID [Andreas Ley]
|
||||
* - oggs magic [Felix von Leitner]
|
||||
* - gmon magic [Eugen Dedu]
|
||||
* - TNEF magic [Joomy]
|
||||
* - netpbm magic and misc other image stuff [Bryan Henderson]
|
||||
*
|
||||
* Revision 1.32 2000/08/05 18:24:18 christos
|
||||
* Correct indianness detection in elf (Charles Hannum)
|
||||
* FreeBSD elf core support (Guy Harris)
|
||||
* Use gzip in systems that don't have uncompress (Anthon van der Neut)
|
||||
* Internationalization/EBCDIC support (Eric Fisher)
|
||||
* Many many magic changes
|
||||
*
|
||||
* Revision 1.31 2000/05/14 17:58:36 christos
|
||||
* - new magic for claris files
|
||||
* - new magic for mathematica and maple files
|
||||
* - new magic for msvc files
|
||||
* - new -k flag to keep going matching all possible entries
|
||||
* - add the word executable on #! magic files, and fix the usage of
|
||||
* the word script
|
||||
* - lots of other magic fixes
|
||||
* - fix typo test -> text
|
||||
*
|
||||
* Revision 1.30 2000/04/11 02:41:17 christos
|
||||
* - add support for mime output (-i)
|
||||
* - make sure we free memory in case realloc fails
|
||||
* - magic fixes
|
||||
*
|
||||
* Revision 1.29 1999/11/28 20:02:29 christos
|
||||
* new string/[Bcb] magic from anthon, and adjustments to the magic files to
|
||||
* use it.
|
||||
*
|
||||
* Revision 1.28 1999/10/31 22:11:48 christos
|
||||
* - add "char" type for compatibility with HP/UX
|
||||
* - recognize HP/UX syntax &=n etc.
|
||||
* - include errno.h for CYGWIN
|
||||
* - conditionalize the S_IS* macros
|
||||
* - revert the SHT_DYNSYM test that broke the linux stripped binaries test
|
||||
* - lots of Magdir changes
|
||||
*
|
||||
* Revision 1.27 1999/02/14 17:21:41 christos
|
||||
* Automake support and misc cleanups from Rainer Orth
|
||||
* Enable reading character and block special files from Dale R. Worley
|
||||
*
|
||||
* Revision 1.26 1998/09/12 13:19:39 christos
|
||||
* - add support for bi-endian indirect offsets (Richard Verhoeven)
|
||||
* - add recognition for bcpl (Joseph Myers)
|
||||
* - remove non magic files from Magdir to avoid difficulties building
|
||||
* on os2 where files are case independent
|
||||
* - magic fixes.
|
||||
*
|
||||
* Revision 1.25 1998/06/27 14:04:04 christos
|
||||
* OLF patch Guy Harris
|
||||
* Recognize java/html (debian linux)
|
||||
* Const poisoning (debian linux)
|
||||
* More magic!
|
||||
*
|
||||
* Revision 1.24 1998/02/15 23:20:38 christos
|
||||
* Autoconf patch: Felix von Leitner <leitner@math.fu-berlin.de>
|
||||
* More magic fixes
|
||||
* Elf64 fixes
|
||||
*
|
||||
* Revision 1.23 1997/11/05 16:03:37 christos
|
||||
* - correct elf prps offset for SunOS-2.5.1 [guy@netapp.com]
|
||||
* - handle 64 bit time_t's correctly [ewt@redhat.com]
|
||||
* - new mime style magic [clarosse@netvista.net]
|
||||
* - new TI calculator magic [rmcguire@freenet.columbus.oh.us]
|
||||
* - new figlet fonts [obrien@freebsd.org]
|
||||
* - new cisco magic, and elf fixes [jhawk@bbnplanet.com]
|
||||
* - -b flag addition, and x86 filesystem magic [vax@linkhead.paranoia.com]
|
||||
* - s/Mpeg/MPEG, header and elf typo fixes [guy@netapp.com]
|
||||
* - Windows/NT registry files, audio code [guy@netapp.com]
|
||||
* - libGrx graphics lib fonts [guy@netapp.com]
|
||||
* - PNG fixes [guy@netapp.com]
|
||||
* - more m$ document magic [guy@netapp.com]
|
||||
* - PPD files [guy@netapp.com]
|
||||
* - archive magic cleanup [guy@netapp.com]
|
||||
* - linux kernel magic cleanup [guy@netapp.com]
|
||||
* - lecter magic [guy@netapp.com]
|
||||
* - vgetty magic [guy@netapp.com]
|
||||
* - sniffer additions [guy@netapp.com]
|
||||
*
|
||||
* Revision 1.22 1997/01/15 17:23:24 christos
|
||||
* - add support for elf core files: find the program name under SVR4 [Ken Pizzini]
|
||||
* - print strings only up to the first carriage return [various]
|
||||
* - freebsd international ascii support [J Wunsch]
|
||||
* - magic fixes and additions [Guy Harris]
|
||||
* - 64 bit fixes [Larry Schwimmer]
|
||||
* - support for both utime and utimes, but don't restore file access times
|
||||
* by default [various]
|
||||
* - \xXX only takes 2 hex digits, not 3.
|
||||
* - re-implement support for core files [Guy Harris]
|
||||
*
|
||||
* Revision 1.21 1996/10/05 18:15:29 christos
|
||||
* Segregate elf stuff and conditionally enable it with -DBUILTIN_ELF
|
||||
* More magic fixes
|
||||
*
|
||||
* Revision 1.20 1996/06/22 22:15:52 christos
|
||||
* - support relative offsets of the form >&
|
||||
* - fix bug with truncating magic strings that contain \n
|
||||
* - file -f - did not read from stdin as documented
|
||||
* - support elf file parsing using our own elf support.
|
||||
* - as always magdir fixes and additions.
|
||||
*
|
||||
* Revision 1.19 1995/10/27 23:14:46 christos
|
||||
* Ability to parse colon separated list of magic files
|
||||
* New LEGAL.NOTICE
|
||||
* Various magic file changes
|
||||
*
|
||||
* Revision 1.18 1995/05/20 22:09:21 christos
|
||||
* Passed incorrect argument to eatsize().
|
||||
* Use %ld and %lx where appropriate.
|
||||
* Remove unused variables
|
||||
* ELF support for both big and little endian
|
||||
* Fixes for small files again.
|
||||
*
|
||||
* Revision 1.17 1995/04/28 17:29:13 christos
|
||||
* - Incorrect nroff detection fix from der Mouse
|
||||
* - Lost and incorrect magic entries.
|
||||
* - Added ELF stripped binary detection [in C; ugh]
|
||||
* - Look for $MAGIC to find the magic file.
|
||||
* - Eat trailing size specifications from numbers i.e. ignore 10L
|
||||
* - More fixes for very short files
|
||||
*
|
||||
* Revision 1.16 1995/03/25 22:06:45 christos
|
||||
* - use strtoul() where it exists.
|
||||
* - fix sign-extend bug
|
||||
* - try to detect tar archives before nroff files, otherwise
|
||||
* tar files where the first file starts with a . will not work
|
||||
*
|
||||
* Revision 1.15 1995/01/21 21:03:35 christos
|
||||
* Added CSECTION for the file man page
|
||||
* Added version flag -v
|
||||
* Fixed bug with -f input flag (from iorio@violet.berkeley.edu)
|
||||
* Lots of magic fixes and reorganization...
|
||||
*
|
||||
* Revision 1.14 1994/05/03 17:58:23 christos
|
||||
* changes from mycroft@gnu.ai.mit.edu (Charles Hannum) for unsigned
|
||||
*
|
||||
* Revision 1.13 1994/01/21 01:27:01 christos
|
||||
* Fixed null termination bug from Don Seeley at BSDI in ascmagic.c
|
||||
*
|
||||
* Revision 1.12 1993/10/27 20:59:05 christos
|
||||
* Changed -z flag to understand gzip format too.
|
||||
* Moved builtin compression detection to a table, and move
|
||||
* the compress magic entry out of the source.
|
||||
* Made printing of numbers unsigned, and added the mask to it.
|
||||
* Changed the buffer size to 8k, because gzip will refuse to
|
||||
* unzip just a few bytes.
|
||||
*
|
||||
* Revision 1.11 1993/09/24 18:49:06 christos
|
||||
* Fixed small bug in softmagic.c introduced by
|
||||
* copying the data to be examined out of the input
|
||||
* buffer. Changed the Makefile to use sed to create
|
||||
* the correct man pages.
|
||||
*
|
||||
* Revision 1.10 1993/09/23 21:56:23 christos
|
||||
* Passed purify. Fixed indirections. Fixed byte order printing.
|
||||
* Fixed segmentation faults caused by referencing past the end
|
||||
* of the magic buffer. Fixed bus errors caused by referencing
|
||||
* unaligned shorts or longs.
|
||||
*
|
||||
* Revision 1.9 1993/03/24 14:23:40 ian
|
||||
* Batch of minor changes from several contributors.
|
||||
*
|
||||
* Revision 1.8 93/02/19 15:01:26 ian
|
||||
* Numerous changes from Guy Harris too numerous to mention but including
|
||||
* byte-order independance, fixing "old-style masking", etc. etc. A bugfix
|
||||
* for broken symlinks from martin@@d255s004.zfe.siemens.de.
|
||||
*
|
||||
* Revision 1.7 93/01/05 14:57:27 ian
|
||||
* Couple of nits picked by Christos (again, thanks).
|
||||
*
|
||||
* Revision 1.6 93/01/05 13:51:09 ian
|
||||
* Lotsa work on the Magic directory.
|
||||
*
|
||||
* Revision 1.5 92/09/14 14:54:51 ian
|
||||
* Fix a tiny null-pointer bug in previous fix for tar archive + uncompress.
|
||||
*
|
||||
*/
|
390
external/bsd/file/dist/src/readcdf.c
vendored
390
external/bsd/file/dist/src/readcdf.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: readcdf.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */
|
||||
/* $NetBSD: readcdf.c,v 1.3 2011/05/13 01:52:13 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 Christos Zoulas
|
||||
@ -29,9 +29,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: readcdf.c,v 1.18 2009/05/06 20:48:22 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: readcdf.c,v 1.25 2011/02/10 21:35:05 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: readcdf.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
__RCSID("$NetBSD: readcdf.c,v 1.3 2011/05/13 01:52:13 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -50,226 +50,242 @@ private int
|
||||
cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
|
||||
size_t count)
|
||||
{
|
||||
size_t i;
|
||||
cdf_timestamp_t tp;
|
||||
struct timespec ts;
|
||||
char buf[64];
|
||||
const char *str = "vnd.ms-office";
|
||||
const char *s;
|
||||
int len;
|
||||
size_t i;
|
||||
cdf_timestamp_t tp;
|
||||
struct timespec ts;
|
||||
char buf[64];
|
||||
const char *str = "vnd.ms-office";
|
||||
const char *s;
|
||||
int len;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
|
||||
switch (info[i].pi_type) {
|
||||
case CDF_SIGNED16:
|
||||
if (NOTMIME(ms) && file_printf(ms, ", %s: %hd", buf,
|
||||
info[i].pi_s16) == -1)
|
||||
return -1;
|
||||
break;
|
||||
case CDF_SIGNED32:
|
||||
if (NOTMIME(ms) && file_printf(ms, ", %s: %d", buf,
|
||||
info[i].pi_s32) == -1)
|
||||
return -1;
|
||||
break;
|
||||
case CDF_UNSIGNED32:
|
||||
if (NOTMIME(ms) && file_printf(ms, ", %s: %u", buf,
|
||||
info[i].pi_u32) == -1)
|
||||
return -1;
|
||||
break;
|
||||
case CDF_LENGTH32_STRING:
|
||||
len = info[i].pi_str.s_len;
|
||||
if (len > 1) {
|
||||
s = info[i].pi_str.s_buf;
|
||||
if (NOTMIME(ms)) {
|
||||
char vbuf[1024];
|
||||
size_t j;
|
||||
for (j = 0; j < sizeof(vbuf) && len--;
|
||||
j++, s++) {
|
||||
if (*s == '\0')
|
||||
break;
|
||||
if (isprint((unsigned char)*s))
|
||||
vbuf[j] = *s;
|
||||
}
|
||||
if (j == sizeof(vbuf))
|
||||
--j;
|
||||
vbuf[j] = '\0';
|
||||
if (vbuf[0]) {
|
||||
if (file_printf(ms, ", %s: %s",
|
||||
buf, vbuf) == -1)
|
||||
return -1;
|
||||
}
|
||||
} else if (info[i].pi_id ==
|
||||
CDF_PROPERTY_NAME_OF_APPLICATION) {
|
||||
if (strstr(s, "Word"))
|
||||
str = "msword";
|
||||
else if (strstr(s, "Excel"))
|
||||
str = "vnd.ms-excel";
|
||||
else if (strstr(s, "Powerpoint"))
|
||||
str = "vnd.ms-powerpoint";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CDF_FILETIME:
|
||||
tp = info[i].pi_tp;
|
||||
if (tp != 0) {
|
||||
if (tp < 1000000000000000LL) {
|
||||
char tbuf[64];
|
||||
cdf_print_elapsed_time(tbuf,
|
||||
sizeof(tbuf), tp);
|
||||
if (NOTMIME(ms) && file_printf(ms,
|
||||
", %s: %s", buf, tbuf) == -1)
|
||||
return -1;
|
||||
} else {
|
||||
char *c, *ec;
|
||||
cdf_timestamp_to_timespec(&ts, tp);
|
||||
c = ctime(&ts.tv_sec);
|
||||
if ((ec = strchr(c, '\n')) != NULL)
|
||||
*ec = '\0';
|
||||
for (i = 0; i < count; i++) {
|
||||
cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
|
||||
switch (info[i].pi_type) {
|
||||
case CDF_NULL:
|
||||
break;
|
||||
case CDF_SIGNED16:
|
||||
if (NOTMIME(ms) && file_printf(ms, ", %s: %hd", buf,
|
||||
info[i].pi_s16) == -1)
|
||||
return -1;
|
||||
break;
|
||||
case CDF_SIGNED32:
|
||||
if (NOTMIME(ms) && file_printf(ms, ", %s: %d", buf,
|
||||
info[i].pi_s32) == -1)
|
||||
return -1;
|
||||
break;
|
||||
case CDF_UNSIGNED32:
|
||||
if (NOTMIME(ms) && file_printf(ms, ", %s: %u", buf,
|
||||
info[i].pi_u32) == -1)
|
||||
return -1;
|
||||
break;
|
||||
case CDF_LENGTH32_STRING:
|
||||
case CDF_LENGTH32_WSTRING:
|
||||
len = info[i].pi_str.s_len;
|
||||
if (len > 1) {
|
||||
char vbuf[1024];
|
||||
size_t j, k = 1;
|
||||
|
||||
if (NOTMIME(ms) && file_printf(ms,
|
||||
", %s: %s", buf, c) == -1)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CDF_CLIPBOARD:
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!NOTMIME(ms)) {
|
||||
if (file_printf(ms, "application/%s", str) == -1)
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
if (info[i].pi_type == CDF_LENGTH32_WSTRING)
|
||||
k++;
|
||||
s = info[i].pi_str.s_buf;
|
||||
for (j = 0; j < sizeof(vbuf) && len--;
|
||||
j++, s += k) {
|
||||
if (*s == '\0')
|
||||
break;
|
||||
if (isprint((unsigned char)*s))
|
||||
vbuf[j] = *s;
|
||||
}
|
||||
if (j == sizeof(vbuf))
|
||||
--j;
|
||||
vbuf[j] = '\0';
|
||||
if (NOTMIME(ms)) {
|
||||
if (vbuf[0]) {
|
||||
if (file_printf(ms, ", %s: %s",
|
||||
buf, vbuf) == -1)
|
||||
return -1;
|
||||
}
|
||||
} else if (info[i].pi_id ==
|
||||
CDF_PROPERTY_NAME_OF_APPLICATION) {
|
||||
if (strstr(vbuf, "Word"))
|
||||
str = "msword";
|
||||
else if (strstr(vbuf, "Excel"))
|
||||
str = "vnd.ms-excel";
|
||||
else if (strstr(vbuf, "Powerpoint"))
|
||||
str = "vnd.ms-powerpoint";
|
||||
else if (strstr(vbuf,
|
||||
"Crystal Reports"))
|
||||
str = "x-rpt";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CDF_FILETIME:
|
||||
tp = info[i].pi_tp;
|
||||
if (tp != 0) {
|
||||
if (tp < 1000000000000000LL) {
|
||||
char tbuf[64];
|
||||
cdf_print_elapsed_time(tbuf,
|
||||
sizeof(tbuf), tp);
|
||||
if (NOTMIME(ms) && file_printf(ms,
|
||||
", %s: %s", buf, tbuf) == -1)
|
||||
return -1;
|
||||
} else {
|
||||
char *c, *ec;
|
||||
cdf_timestamp_to_timespec(&ts, tp);
|
||||
c = cdf_ctime(&ts.tv_sec);
|
||||
if ((ec = strchr(c, '\n')) != NULL)
|
||||
*ec = '\0';
|
||||
|
||||
if (NOTMIME(ms) && file_printf(ms,
|
||||
", %s: %s", buf, c) == -1)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CDF_CLIPBOARD:
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!NOTMIME(ms)) {
|
||||
if (file_printf(ms, "application/%s", str) == -1)
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private int
|
||||
cdf_file_summary_info(struct magic_set *ms, const cdf_stream_t *sst)
|
||||
cdf_file_summary_info(struct magic_set *ms, const cdf_header_t *h,
|
||||
const cdf_stream_t *sst)
|
||||
{
|
||||
cdf_summary_info_header_t si;
|
||||
cdf_property_info_t *info;
|
||||
size_t count;
|
||||
int m;
|
||||
cdf_summary_info_header_t si;
|
||||
cdf_property_info_t *info;
|
||||
size_t count;
|
||||
int m;
|
||||
|
||||
if (cdf_unpack_summary_info(sst, &si, &info, &count) == -1)
|
||||
return -1;
|
||||
if (cdf_unpack_summary_info(sst, h, &si, &info, &count) == -1)
|
||||
return -1;
|
||||
|
||||
if (NOTMIME(ms)) {
|
||||
if (file_printf(ms, "CDF V2 Document") == -1)
|
||||
return -1;
|
||||
if (NOTMIME(ms)) {
|
||||
if (file_printf(ms, "Composite Document File V2 Document") == -1)
|
||||
return -1;
|
||||
|
||||
if (file_printf(ms, ", %s Endian",
|
||||
si.si_byte_order == 0xfffe ? "Little" : "Big") == -1)
|
||||
return -1;
|
||||
switch (si.si_os) {
|
||||
case 2:
|
||||
if (file_printf(ms, ", Os: Windows, Version %d.%d",
|
||||
si.si_os_version & 0xff,
|
||||
(uint32_t)si.si_os_version >> 8) == -1)
|
||||
return -1;
|
||||
break;
|
||||
case 1:
|
||||
if (file_printf(ms, ", Os: MacOS, Version %d.%d",
|
||||
(uint32_t)si.si_os_version >> 8,
|
||||
si.si_os_version & 0xff) == -1)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
if (file_printf(ms, ", Os %d, Version: %d.%d", si.si_os,
|
||||
si.si_os_version & 0xff,
|
||||
(uint32_t)si.si_os_version >> 8) == -1)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (file_printf(ms, ", %s Endian",
|
||||
si.si_byte_order == 0xfffe ? "Little" : "Big") == -1)
|
||||
return -1;
|
||||
switch (si.si_os) {
|
||||
case 2:
|
||||
if (file_printf(ms, ", Os: Windows, Version %d.%d",
|
||||
si.si_os_version & 0xff,
|
||||
(uint32_t)si.si_os_version >> 8) == -1)
|
||||
return -1;
|
||||
break;
|
||||
case 1:
|
||||
if (file_printf(ms, ", Os: MacOS, Version %d.%d",
|
||||
(uint32_t)si.si_os_version >> 8,
|
||||
si.si_os_version & 0xff) == -1)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
if (file_printf(ms, ", Os %d, Version: %d.%d", si.si_os,
|
||||
si.si_os_version & 0xff,
|
||||
(uint32_t)si.si_os_version >> 8) == -1)
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m = cdf_file_property_info(ms, info, count);
|
||||
free(info);
|
||||
m = cdf_file_property_info(ms, info, count);
|
||||
free(info);
|
||||
|
||||
return m;
|
||||
return m;
|
||||
}
|
||||
|
||||
protected int
|
||||
file_trycdf(struct magic_set *ms, int fd, const unsigned char *buf,
|
||||
size_t nbytes)
|
||||
{
|
||||
cdf_info_t info;
|
||||
cdf_header_t h;
|
||||
cdf_sat_t sat, ssat;
|
||||
cdf_stream_t sst, scn;
|
||||
cdf_dir_t dir;
|
||||
int i;
|
||||
const char *expn = "";
|
||||
cdf_info_t info;
|
||||
cdf_header_t h;
|
||||
cdf_sat_t sat, ssat;
|
||||
cdf_stream_t sst, scn;
|
||||
cdf_dir_t dir;
|
||||
int i;
|
||||
const char *expn = "";
|
||||
const char *corrupt = "corrupt: ";
|
||||
|
||||
info.i_fd = fd;
|
||||
info.i_buf = buf;
|
||||
info.i_len = nbytes;
|
||||
if (ms->flags & MAGIC_APPLE)
|
||||
return 0;
|
||||
if (cdf_read_header(&info, &h) == -1)
|
||||
return 0;
|
||||
info.i_fd = fd;
|
||||
info.i_buf = buf;
|
||||
info.i_len = nbytes;
|
||||
if (ms->flags & MAGIC_APPLE)
|
||||
return 0;
|
||||
if (cdf_read_header(&info, &h) == -1)
|
||||
return 0;
|
||||
#ifdef CDF_DEBUG
|
||||
cdf_dump_header(&h);
|
||||
cdf_dump_header(&h);
|
||||
#endif
|
||||
|
||||
if ((i = cdf_read_sat(&info, &h, &sat)) == -1) {
|
||||
expn = "Can't read SAT";
|
||||
goto out0;
|
||||
}
|
||||
if ((i = cdf_read_sat(&info, &h, &sat)) == -1) {
|
||||
expn = "Can't read SAT";
|
||||
goto out0;
|
||||
}
|
||||
#ifdef CDF_DEBUG
|
||||
cdf_dump_sat("SAT", &sat, CDF_SEC_SIZE(&h));
|
||||
cdf_dump_sat("SAT", &sat, CDF_SEC_SIZE(&h));
|
||||
#endif
|
||||
|
||||
if ((i = cdf_read_ssat(&info, &h, &sat, &ssat)) == -1) {
|
||||
expn = "Can't read SSAT";
|
||||
goto out1;
|
||||
}
|
||||
if ((i = cdf_read_ssat(&info, &h, &sat, &ssat)) == -1) {
|
||||
expn = "Can't read SSAT";
|
||||
goto out1;
|
||||
}
|
||||
#ifdef CDF_DEBUG
|
||||
cdf_dump_sat("SSAT", &ssat, CDF_SHORT_SEC_SIZE(&h));
|
||||
cdf_dump_sat("SSAT", &ssat, CDF_SHORT_SEC_SIZE(&h));
|
||||
#endif
|
||||
|
||||
if ((i = cdf_read_dir(&info, &h, &sat, &dir)) == -1) {
|
||||
expn = "Can't read directory";
|
||||
goto out2;
|
||||
}
|
||||
if ((i = cdf_read_dir(&info, &h, &sat, &dir)) == -1) {
|
||||
expn = "Can't read directory";
|
||||
goto out2;
|
||||
}
|
||||
|
||||
if ((i = cdf_read_short_stream(&info, &h, &sat, &dir, &sst)) == -1) {
|
||||
expn = "Cannot read short stream";
|
||||
goto out3;
|
||||
}
|
||||
if ((i = cdf_read_short_stream(&info, &h, &sat, &dir, &sst)) == -1) {
|
||||
expn = "Cannot read short stream";
|
||||
goto out3;
|
||||
}
|
||||
#ifdef CDF_DEBUG
|
||||
cdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir);
|
||||
cdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir);
|
||||
#endif
|
||||
|
||||
if ((i = cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
|
||||
&scn)) == -1) {
|
||||
expn = "Cannot read summary info";
|
||||
goto out4;
|
||||
}
|
||||
if ((i = cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
|
||||
&scn)) == -1) {
|
||||
if (errno == ESRCH) {
|
||||
corrupt = expn;
|
||||
expn = "No summary info";
|
||||
} else {
|
||||
expn = "Cannot read summary info";
|
||||
}
|
||||
goto out4;
|
||||
}
|
||||
#ifdef CDF_DEBUG
|
||||
cdf_dump_summary_info(&h, &scn);
|
||||
cdf_dump_summary_info(&h, &scn);
|
||||
#endif
|
||||
if ((i = cdf_file_summary_info(ms, &scn)) == -1)
|
||||
expn = "Can't expand summary_info";
|
||||
free(scn.sst_tab);
|
||||
if ((i = cdf_file_summary_info(ms, &h, &scn)) == -1)
|
||||
expn = "Can't expand summary_info";
|
||||
free(scn.sst_tab);
|
||||
out4:
|
||||
free(sst.sst_tab);
|
||||
free(sst.sst_tab);
|
||||
out3:
|
||||
free(dir.dir_tab);
|
||||
free(dir.dir_tab);
|
||||
out2:
|
||||
free(ssat.sat_tab);
|
||||
free(ssat.sat_tab);
|
||||
out1:
|
||||
free(sat.sat_tab);
|
||||
free(sat.sat_tab);
|
||||
out0:
|
||||
if (i != 1) {
|
||||
if (file_printf(ms, "CDF V2 Document") == -1)
|
||||
return -1;
|
||||
if (*expn)
|
||||
if (file_printf(ms, ", corrupt: %s", expn) == -1)
|
||||
return -1;
|
||||
i = 1;
|
||||
}
|
||||
return i;
|
||||
if (i != 1) {
|
||||
if (file_printf(ms, "Composite Document File V2 Document") == -1)
|
||||
return -1;
|
||||
if (*expn)
|
||||
if (file_printf(ms, ", %s%s", corrupt, expn) == -1)
|
||||
return -1;
|
||||
i = 1;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
41
external/bsd/file/dist/src/readelf.c
vendored
41
external/bsd/file/dist/src/readelf.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: readelf.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */
|
||||
/* $NetBSD: readelf.c,v 1.3 2011/05/13 01:52:13 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Christos Zoulas 2003.
|
||||
@ -30,9 +30,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: readelf.c,v 1.81 2008/11/04 16:38:28 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: readelf.c,v 1.86 2010/07/21 16:47:18 christos Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: readelf.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
__RCSID("$NetBSD: readelf.c,v 1.3 2011/05/13 01:52:13 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -292,6 +292,7 @@ private const char os_style_names[][8] = {
|
||||
#define FLAGS_DID_CORE 1
|
||||
#define FLAGS_DID_NOTE 2
|
||||
#define FLAGS_DID_CORE_STYLE 4
|
||||
#define FLAGS_IS_CORE 8
|
||||
|
||||
private int
|
||||
dophn_core(struct magic_set *ms, int clazz, int swap, int fd, off_t off,
|
||||
@ -682,7 +683,7 @@ core:
|
||||
break;
|
||||
|
||||
default:
|
||||
if (xnh_type == NT_PRPSINFO) {
|
||||
if (xnh_type == NT_PRPSINFO && *flags & FLAGS_IS_CORE) {
|
||||
size_t i, j;
|
||||
unsigned char c;
|
||||
/*
|
||||
@ -699,6 +700,7 @@ core:
|
||||
unsigned char *cname, *cp;
|
||||
size_t reloffset = prpsoffsets(i);
|
||||
size_t noffset = doff + reloffset;
|
||||
size_t k;
|
||||
for (j = 0; j < 16; j++, noffset++,
|
||||
reloffset++) {
|
||||
/*
|
||||
@ -744,6 +746,24 @@ core:
|
||||
/*
|
||||
* Well, that worked.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Try next offsets, in case this match is
|
||||
* in the middle of a string.
|
||||
*/
|
||||
for (k = i + 1 ; k < NOFFSETS ; k++) {
|
||||
size_t no;
|
||||
int adjust = 1;
|
||||
if (prpsoffsets(k) >= prpsoffsets(i))
|
||||
continue;
|
||||
for (no = doff + prpsoffsets(k);
|
||||
no < doff + prpsoffsets(i); no++)
|
||||
adjust = adjust
|
||||
&& isprint(nbuf[no]);
|
||||
if (adjust)
|
||||
i = k;
|
||||
}
|
||||
|
||||
cname = (unsigned char *)
|
||||
&nbuf[doff + prpsoffsets(i)];
|
||||
for (cp = cname; *cp && isprint(*cp); cp++)
|
||||
@ -915,7 +935,7 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
Elf64_Cap cap64;
|
||||
char cbuf[/*CONSTCOND*/
|
||||
MAX(sizeof cap32, sizeof cap64)];
|
||||
if ((coff += xcap_sizeof) >= (off_t)xsh_size)
|
||||
if ((coff += xcap_sizeof) > (off_t)xsh_size)
|
||||
break;
|
||||
if (read(fd, cbuf, (size_t)xcap_sizeof) !=
|
||||
(ssize_t)xcap_sizeof) {
|
||||
@ -935,7 +955,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
default:
|
||||
if (file_printf(ms,
|
||||
", with unknown capability "
|
||||
"0x%llx = 0x%llx",
|
||||
"0x%" INT64_T_FORMAT "x = 0x%"
|
||||
INT64_T_FORMAT "x",
|
||||
(unsigned long long)xcap_tag,
|
||||
(unsigned long long)xcap_val) == -1)
|
||||
return -1;
|
||||
@ -983,12 +1004,13 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
}
|
||||
if (cap_hw1)
|
||||
if (file_printf(ms,
|
||||
" unknown hardware capability 0x%llx",
|
||||
" unknown hardware capability 0x%"
|
||||
INT64_T_FORMAT "x",
|
||||
(unsigned long long)cap_hw1) == -1)
|
||||
return -1;
|
||||
} else {
|
||||
if (file_printf(ms,
|
||||
" hardware capability 0x%llx",
|
||||
" hardware capability 0x%" INT64_T_FORMAT "x",
|
||||
(unsigned long long)cap_hw1) == -1)
|
||||
return -1;
|
||||
}
|
||||
@ -1004,7 +1026,8 @@ doshn(struct magic_set *ms, int clazz, int swap, int fd, off_t off, int num,
|
||||
cap_sf1 &= ~SF1_SUNW_MASK;
|
||||
if (cap_sf1)
|
||||
if (file_printf(ms,
|
||||
", with unknown software capability 0x%llx",
|
||||
", with unknown software capability 0x%"
|
||||
INT64_T_FORMAT "x",
|
||||
(unsigned long long)cap_sf1) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
103
external/bsd/file/dist/src/softmagic.c
vendored
103
external/bsd/file/dist/src/softmagic.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: softmagic.c,v 1.2 2009/05/08 17:28:01 christos Exp $ */
|
||||
/* $NetBSD: softmagic.c,v 1.3 2011/05/13 01:52:13 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) Ian F. Darwin 1986-1995.
|
||||
@ -35,9 +35,9 @@
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.135 2009/03/27 22:42:49 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.144 2011/01/07 23:22:28 rrt Exp $")
|
||||
#else
|
||||
__RCSID("$NetBSD: softmagic.c,v 1.2 2009/05/08 17:28:01 christos Exp $");
|
||||
__RCSID("$NetBSD: softmagic.c,v 1.3 2011/05/13 01:52:13 christos Exp $");
|
||||
#endif
|
||||
#endif /* lint */
|
||||
|
||||
@ -129,7 +129,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
int flush = 0;
|
||||
struct magic *m = &magic[magindex];
|
||||
|
||||
if ((m->flag & BINTEST) != mode) {
|
||||
if ((m->flag & mode) != mode) {
|
||||
/* Skip sub-tests */
|
||||
while (magic[magindex + 1].cont_level != 0 &&
|
||||
++magindex < nmagic)
|
||||
@ -150,7 +150,7 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
default:
|
||||
if (m->type == FILE_INDIRECT)
|
||||
returnval = 1;
|
||||
|
||||
|
||||
switch (magiccheck(ms, m)) {
|
||||
case -1:
|
||||
return -1;
|
||||
@ -174,6 +174,8 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((e = handle_annotation(ms, m)) != 0)
|
||||
return e;
|
||||
/*
|
||||
* If we are going to print something, we'll need to print
|
||||
* a blank before we print something else.
|
||||
@ -181,8 +183,6 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
if (*m->desc) {
|
||||
need_separator = 1;
|
||||
printed_something = 1;
|
||||
if ((e = handle_annotation(ms, m)) != 0)
|
||||
return e;
|
||||
if (print_sep(ms, firstline) == -1)
|
||||
return -1;
|
||||
}
|
||||
@ -257,13 +257,13 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
|
||||
ms->c.li[cont_level].got_match = 0;
|
||||
break;
|
||||
}
|
||||
if ((e = handle_annotation(ms, m)) != 0)
|
||||
return e;
|
||||
/*
|
||||
* If we are going to print something,
|
||||
* make sure that we have a separator first.
|
||||
*/
|
||||
if (*m->desc) {
|
||||
if ((e = handle_annotation(ms, m)) != 0)
|
||||
return e;
|
||||
if (!printed_something) {
|
||||
printed_something = 1;
|
||||
if (print_sep(ms, firstline)
|
||||
@ -455,7 +455,7 @@ mprint(struct magic_set *ms, struct magic *m)
|
||||
return -1;
|
||||
t = ms->offset + strlen(p->s);
|
||||
if (m->type == FILE_PSTRING)
|
||||
t++;
|
||||
t += file_pstring_length_size(m);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -620,7 +620,7 @@ moffset(struct magic_set *ms, struct magic *m)
|
||||
p->s[strcspn(p->s, "\n")] = '\0';
|
||||
t = CAST(uint32_t, (ms->offset + strlen(p->s)));
|
||||
if (m->type == FILE_PSTRING)
|
||||
t++;
|
||||
t += file_pstring_length_size(m);
|
||||
return t;
|
||||
}
|
||||
|
||||
@ -796,28 +796,16 @@ mconvert(struct magic_set *ms, struct magic *m)
|
||||
case FILE_LESTRING16: {
|
||||
/* 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: {
|
||||
char *ptr1 = p->s, *ptr2 = ptr1 + 1;
|
||||
size_t len = *p->s;
|
||||
char *ptr1 = p->s, *ptr2 = ptr1 + file_pstring_length_size(m);
|
||||
size_t len = file_pstring_get_length(m, ptr1);
|
||||
if (len >= sizeof(p->s))
|
||||
len = sizeof(p->s) - 1;
|
||||
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:
|
||||
@ -951,9 +939,11 @@ mcopy(struct magic_set *ms, union VALUETYPE *p, int type, int indir,
|
||||
buf = CAST(const char *, s) + offset;
|
||||
end = last = CAST(const char *, s) + nbytes;
|
||||
/* mget() guarantees buf <= last */
|
||||
for (lines = linecnt, b = buf; lines &&
|
||||
((b = memchr(c = b, '\n', CAST(size_t, (end - b))))
|
||||
|| (b = memchr(c, '\r', CAST(size_t, (end - c)))));
|
||||
for (lines = linecnt, b = buf; lines && b < end &&
|
||||
((b = CAST(const char *,
|
||||
memchr(c = b, '\n', CAST(size_t, (end - b)))))
|
||||
|| (b = CAST(const char *,
|
||||
memchr(c, '\r', CAST(size_t, (end - c))))));
|
||||
lines--, b++) {
|
||||
last = b;
|
||||
if (b[0] == '\r' && b[1] == '\n')
|
||||
@ -1589,7 +1579,7 @@ mget(struct magic_set *ms, const unsigned char *s,
|
||||
|
||||
case FILE_INDIRECT:
|
||||
if ((ms->flags & (MAGIC_MIME|MAGIC_APPLE)) == 0 &&
|
||||
file_printf(ms, m->desc) == -1)
|
||||
file_printf(ms, "%s", m->desc) == -1)
|
||||
return -1;
|
||||
if (nbytes < offset)
|
||||
return 0;
|
||||
@ -1640,19 +1630,20 @@ file_strncmp(const char *s1, const char *s2, size_t len, uint32_t flags)
|
||||
if ((v = toupper(*b++) - *a++) != '\0')
|
||||
break;
|
||||
}
|
||||
else if ((flags & STRING_COMPACT_BLANK) &&
|
||||
else if ((flags & STRING_COMPACT_WHITESPACE) &&
|
||||
isspace(*a)) {
|
||||
a++;
|
||||
if (isspace(*b++)) {
|
||||
while (isspace(*b))
|
||||
b++;
|
||||
if (!isspace(*a))
|
||||
while (isspace(*b))
|
||||
b++;
|
||||
}
|
||||
else {
|
||||
v = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ((flags & STRING_COMPACT_OPTIONAL_BLANK) &&
|
||||
else if ((flags & STRING_COMPACT_OPTIONAL_WHITESPACE) &&
|
||||
isspace(*a)) {
|
||||
a++;
|
||||
while (isspace(*b))
|
||||
@ -1906,39 +1897,41 @@ magiccheck(struct magic_set *ms, struct magic *m)
|
||||
switch (m->reln) {
|
||||
case 'x':
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%llu == *any* = 1\n",
|
||||
(unsigned long long)v);
|
||||
(void) fprintf(stderr, "%" INT64_T_FORMAT
|
||||
"u == *any* = 1\n", (unsigned long long)v);
|
||||
matched = 1;
|
||||
break;
|
||||
|
||||
case '!':
|
||||
matched = v != l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%llu != %llu = %d\n",
|
||||
(unsigned long long)v, (unsigned long long)l,
|
||||
matched);
|
||||
(void) fprintf(stderr, "%" INT64_T_FORMAT "u != %"
|
||||
INT64_T_FORMAT "u = %d\n", (unsigned long long)v,
|
||||
(unsigned long long)l, matched);
|
||||
break;
|
||||
|
||||
case '=':
|
||||
matched = v == l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%llu == %llu = %d\n",
|
||||
(unsigned long long)v, (unsigned long long)l,
|
||||
matched);
|
||||
(void) fprintf(stderr, "%" INT64_T_FORMAT "u == %"
|
||||
INT64_T_FORMAT "u = %d\n", (unsigned long long)v,
|
||||
(unsigned long long)l, matched);
|
||||
break;
|
||||
|
||||
case '>':
|
||||
if (m->flag & UNSIGNED) {
|
||||
matched = v > l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%llu > %llu = %d\n",
|
||||
(void) fprintf(stderr, "%" INT64_T_FORMAT
|
||||
"u > %" INT64_T_FORMAT "u = %d\n",
|
||||
(unsigned long long)v,
|
||||
(unsigned long long)l, matched);
|
||||
}
|
||||
else {
|
||||
matched = (int64_t) v > (int64_t) l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%lld > %lld = %d\n",
|
||||
(void) fprintf(stderr, "%" INT64_T_FORMAT
|
||||
"d > %" INT64_T_FORMAT "d = %d\n",
|
||||
(long long)v, (long long)l, matched);
|
||||
}
|
||||
break;
|
||||
@ -1947,32 +1940,38 @@ magiccheck(struct magic_set *ms, struct magic *m)
|
||||
if (m->flag & UNSIGNED) {
|
||||
matched = v < l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%llu < %llu = %d\n",
|
||||
(void) fprintf(stderr, "%" INT64_T_FORMAT
|
||||
"u < %" INT64_T_FORMAT "u = %d\n",
|
||||
(unsigned long long)v,
|
||||
(unsigned long long)l, matched);
|
||||
}
|
||||
else {
|
||||
matched = (int64_t) v < (int64_t) l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "%lld < %lld = %d\n",
|
||||
(long long)v, (long long)l, matched);
|
||||
(void) fprintf(stderr, "%" INT64_T_FORMAT
|
||||
"d < %" INT64_T_FORMAT "d = %d\n",
|
||||
(long long)v, (long long)l, matched);
|
||||
}
|
||||
break;
|
||||
|
||||
case '&':
|
||||
matched = (v & l) == l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "((%llx & %llx) == %llx) = %d\n",
|
||||
(unsigned long long)v, (unsigned long long)l,
|
||||
(unsigned long long)l, matched);
|
||||
(void) fprintf(stderr, "((%" INT64_T_FORMAT "x & %"
|
||||
INT64_T_FORMAT "x) == %" INT64_T_FORMAT
|
||||
"x) = %d\n", (unsigned long long)v,
|
||||
(unsigned long long)l, (unsigned long long)l,
|
||||
matched);
|
||||
break;
|
||||
|
||||
case '^':
|
||||
matched = (v & l) != l;
|
||||
if ((ms->flags & MAGIC_DEBUG) != 0)
|
||||
(void) fprintf(stderr, "((%llx & %llx) != %llx) = %d\n",
|
||||
(unsigned long long)v, (unsigned long long)l,
|
||||
(unsigned long long)l, matched);
|
||||
(void) fprintf(stderr, "((%" INT64_T_FORMAT "x & %"
|
||||
INT64_T_FORMAT "x) != %" INT64_T_FORMAT
|
||||
"x) = %d\n", (unsigned long long)v,
|
||||
(unsigned long long)l, (unsigned long long)l,
|
||||
matched);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
4
external/bsd/file/lib/shlib_version
vendored
4
external/bsd/file/lib/shlib_version
vendored
@ -1,4 +1,4 @@
|
||||
# $NetBSD: shlib_version,v 1.1 2009/05/08 17:28:02 christos Exp $
|
||||
# $NetBSD: shlib_version,v 1.2 2011/05/13 01:52:13 christos Exp $
|
||||
#
|
||||
major=3
|
||||
minor=0
|
||||
minor=1
|
||||
|
Loading…
Reference in New Issue
Block a user