From 39cf80bb8cf16e6f09d09e551fe0a5bd0f646f7b Mon Sep 17 00:00:00 2001 From: christos Date: Mon, 1 Nov 1999 17:30:12 +0000 Subject: [PATCH] new version of file(1) --- usr.bin/file/config.h | 75 ++++++++++++++++++++++++++++++++++++ usr.bin/file/magdir/gimp | 10 +++-- usr.bin/file/magdir/grace | 20 ++++++++++ usr.bin/file/magdir/jpeg | 61 +++++++++++++++++++++++++++++ usr.bin/file/magdir/mach | 9 ++++- usr.bin/file/magdir/mcrypt | 31 +++++++++++++++ usr.bin/file/magdir/os2 | 24 ++++++++++++ usr.bin/file/magdir/palm | 15 ++++++++ usr.bin/file/magdir/spectrum | 28 ++++++++++++++ 9 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 usr.bin/file/config.h create mode 100644 usr.bin/file/magdir/grace create mode 100644 usr.bin/file/magdir/jpeg create mode 100644 usr.bin/file/magdir/mcrypt create mode 100644 usr.bin/file/magdir/palm create mode 100644 usr.bin/file/magdir/spectrum diff --git a/usr.bin/file/config.h b/usr.bin/file/config.h new file mode 100644 index 000000000000..78c0fd139635 --- /dev/null +++ b/usr.bin/file/config.h @@ -0,0 +1,75 @@ +/* config.h. Generated automatically by configure. */ +/* config.h.in. Generated automatically from configure.in by autoheader. */ + +/* Define to empty if the keyword does not work. */ +/* #undef const */ + +/* Define if your struct stat has st_rdev. */ +#define HAVE_ST_RDEV 1 + +/* Define if you have that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define if major, minor, and makedev are declared in . */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define if major, minor, and makedev are declared in . */ +/* #undef MAJOR_IN_SYSMACROS */ + +/* Define to `long' if doesn't define. */ +/* #undef off_t */ + +/* Define to `unsigned' if doesn't define. */ +/* #undef size_t */ + +/* Define if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Autoheader needs me */ +#define PACKAGE "file" + +/* Autoheader needs me */ +#define VERSION "3.28" + +/* Define if builtin ELF support is enabled. */ +#define BUILTIN_ELF 1 + +/* Define if ELF core file support is enabled. */ +#define ELFCORE 1 + +/* Define if the `long long' type works. */ +#define HAVE_LONG_LONG 1 + +/* Define to `unsigned char' if standard headers don't define. */ +#define uint8_t unsigned char + +/* Define to `unsigned short' if standard headers don't define. */ +#define uint16_t unsigned short + +/* Define to `unsigned int' if standard headers don't define. */ +#define uint32_t unsigned int + +/* Define to `unsigned long long', if available, or `unsigned long', if + standard headers don't define. */ +#define uint64_t unsigned long long + +/* The number of bytes in a uint8_t. */ +#define SIZEOF_UINT8_T 1 + +/* The number of bytes in a uint16_t. */ +#define SIZEOF_UINT16_T 2 + +/* The number of bytes in a uint32_t. */ +#define SIZEOF_UINT32_T 4 + +/* The number of bytes in a uint64_t. */ +#define SIZEOF_UINT64_T 8 + +/* Define if you have the strerror function. */ +#define HAVE_STRERROR 1 + +/* Define if you have the strtoul function. */ +#define HAVE_STRTOUL 1 + +/* Define if you have the header file. */ +#define HAVE_UNISTD_H 1 diff --git a/usr.bin/file/magdir/gimp b/usr.bin/file/magdir/gimp index 286fa9c3448b..9a9d61e2f79c 100644 --- a/usr.bin/file/magdir/gimp +++ b/usr.bin/file/magdir/gimp @@ -9,12 +9,16 @@ # by Spencer Kimball and Peter Mattis # ('Bucky' LaDieu, nega@vt.edu) -0 string gimp\ xcf\ file GIMP XCF image data, ->14 belong x %ld x ->18 belong x %ld, +0 string gimp\ xcf GIMP XCF image data, +>9 string file version 0, +>9 string v version +>>10 string >\0 %s, +>14 belong x %lu x +>18 belong x %lu, >22 belong 0 RGB Color >22 belong 1 Greyscale >22 belong 2 Indexed Color +>22 belong >2 Unknown Image Type. #------------------------------------------------------------------------------ # XCF: file(1) magic for the patterns used in the GIMP, developed diff --git a/usr.bin/file/magdir/grace b/usr.bin/file/magdir/grace new file mode 100644 index 000000000000..a5f143359ec3 --- /dev/null +++ b/usr.bin/file/magdir/grace @@ -0,0 +1,20 @@ + +#------------------------------------------------------------------------------ +# ACE/gr and Grace type files - PLEASE DO NOT REMOVE THIS LINE +# +# ACE/gr binary +0 string \000\000\0001\000\000\0000\000\000\0000\000\000\0002\000\000\0000\000\000\0000\000\000\0003 old ACE/gr binary file +>39 byte >0 - version %c +# ACE/gr ascii +0 string #\ xvgr\ parameter\ file ACE/gr ascii file +0 string #\ xmgr\ parameter\ file ACE/gr ascii file +0 string #\ ACE/gr\ parameter\ file ACE/gr ascii file +# Grace projects +0 string #\ Grace\ project\ file Grace project file +>23 string @version\ (version +>>32 byte >0 %c +>>33 string >\0 \b.%.2s +>>35 string >\0 \b.%.2s) +# ACE/gr fit description files +0 string #\ ACE/gr\ fit\ description\ ACE/gr fit description file +# end of ACE/gr and Grace type files - PLEASE DO NOT REMOVE THIS LINE diff --git a/usr.bin/file/magdir/jpeg b/usr.bin/file/magdir/jpeg new file mode 100644 index 000000000000..089405a68872 --- /dev/null +++ b/usr.bin/file/magdir/jpeg @@ -0,0 +1,61 @@ + +#------------------------------------------------------------------------------ +# JPEG images +# SunOS 5.5.1 had +# +# 0 string \377\330\377\340 JPEG file +# 0 string \377\330\377\356 JPG file +# +# both of which turn into "JPEG image data" here. +# +0 beshort 0xffd8 JPEG image data +>6 string JFIF \b, JFIF standard + +# The following added by Erik Rossen 1999-09-06 +# in a vain attempt to add image size reporting for JFIF. Note that these +# tests are not fool-proof since some perfectly valid JPEGs are currently +# impossible to specify in magic(4) format. +# First, a little JFIF version info: +>11 byte x \b %d. +>12 byte x \b%02d +# Next, the resolution or aspect ratio of the image: +>13 byte 0 \b, aspect ratio +>13 byte 1 \b, resolution (DPI) +>13 byte 2 \b, resolution (DPCM) +>14 beshort x \b X%d: +>16 beshort x \bY%d +#>4 beshort x \b, segment length %d +# Next, show thumbnail info, if it exists: +>18 byte !0 \b, thumbnail %dx +>>19 byte x \b%d +# Here things get sticky. We can do ONE MORE marker segment with +# indirect addressing, and that's all. It would be great if we could +# do pointer arithemetic like in an assembler language. Christos? +# And if there was some sort of looping construct to do searches, plus a few +# named accumulators, it would be even more effective... +# At least we can show a comment if no other segments got inserted before: +>(4.S+5) byte 0xFE +>>(4.S+8) string >\0 \b, "%s" +#>(4.S+5) byte 0xFE \b, comment +#>>(4.S+6) beshort x \b length=%d +#>>(4.S+8) string >\0 \b, "%s" +# Or, we can show the encoding type (I've included only the three most common) +# and image dimensions if we are lucky and the SOFn (image segment) is here: +>(4.S+5) byte 0xC0 \b, baseline +>>(4.S+6) byte x \b, precision %d +>>(4.S+7) beshort x \b, %dx +>>(4.S+9) beshort x \b%d +>(4.S+5) byte 0xC1 \b, extended sequential +>>(4.S+6) byte x \b, precision %d +>>(4.S+7) beshort x \b, %dx +>>(4.S+9) beshort x \b%d +>(4.S+5) byte 0xC2 \b, progressive +>>(4.S+6) byte x \b, precision %d +>>(4.S+7) beshort x \b, %dx +>>(4.S+9) beshort x \b%d +# I've commented-out quantisation table reporting. I doubt anyone cares yet. +#>(4.S+5) byte 0xDB \b, quantisation table +#>>(4.S+6) beshort x \b length=%d + +# HSI is Handmade Software's proprietary JPEG encoding scheme +0 string hsi1 JPEG image data, HSI proprietary diff --git a/usr.bin/file/magdir/mach b/usr.bin/file/magdir/mach index 308325ee4e4e..e0f4808eea5b 100644 --- a/usr.bin/file/magdir/mach +++ b/usr.bin/file/magdir/mach @@ -1,12 +1,12 @@ #------------------------------------------------------------------------------ # mach file description # -0 belong 0xcafebabe mach-o fat file +0 belong 0xcafebabe Mach-O fat file >4 belong 1 with 1 architecture >4 belong >1 >>4 belong x with %ld architectures # -0 belong 0xfeedface mach-o +0 belong 0xfeedface Mach-O >12 belong 1 object >12 belong 2 executable >12 belong 3 shared library @@ -22,6 +22,11 @@ >4 belong 4 ns32032 >4 belong 5 ns32332 >4 belong 6 for m68k architecture +# from NeXTstep 3.0 +# i.e. mc680x0_all, ignore +# >>8 belong 1 (mc68030) +>>8 belong 2 (mc68040) +>>8 belong 3 (mc68030 only) >4 belong 7 i386 >4 belong 8 mips >4 belong 9 ns32532 diff --git a/usr.bin/file/magdir/mcrypt b/usr.bin/file/magdir/mcrypt new file mode 100644 index 000000000000..6416104da46d --- /dev/null +++ b/usr.bin/file/magdir/mcrypt @@ -0,0 +1,31 @@ +#------------------------------------------------------------------------------ +# Mavroyanopoulos Nikos +# mcrypt: file(1) magic for mcrypt 2.2.x; +0 string \0m\2 mcrypt 2.2 encrypted data, +>3 byte 0 algorithm: blowfish-448, +>3 byte 1 algorithm: DES, +>3 byte 2 algorithm: 3DES, +>3 byte 3 algorithm: 3-WAY, +>3 byte 4 algorithm: GOST, +>3 byte 6 algorithm: SAFER-SK64, +>3 byte 7 algorithm: SAFER-SK128, +>3 byte 8 algorithm: CAST-128, +>3 byte 9 algorithm: xTEA, +>3 byte 10 algorithm: TWOFISH-128, +>3 byte 11 algorithm: RC2, +>3 byte 12 algorithm: TWOFISH-192, +>3 byte 13 algorithm: TWOFISH-256, +>3 byte 14 algorithm: blowfish-128, +>3 byte 15 algorithm: blowfish-192, +>3 byte 16 algorithm: blowfish-256, +>3 byte 100 algorithm: RC6, +>3 byte 101 algorithm: IDEA, +>4 byte 0 mode: CBC, +>4 byte 1 mode: ECB, +>4 byte 2 mode: CFB, +>4 byte 3 mode: OFB, +>4 byte 4 mode: nOFB, +>5 byte 0 keymode: 8bit +>5 byte 1 keymode: 4bit +>5 byte 2 keymode: SHA-1 hash +>5 byte 3 keymode: MD5 hash diff --git a/usr.bin/file/magdir/os2 b/usr.bin/file/magdir/os2 index 91ea9e23df71..7ae67c7c4585 100644 --- a/usr.bin/file/magdir/os2 +++ b/usr.bin/file/magdir/os2 @@ -21,3 +21,27 @@ >4 string >\ (FTP) 0 string file: OS/2 URL object text >5 string >\ (Local file) <%s> + +# >>>>> OS/2 INF/HLP <<<<< (source: Daniel Dissett ddissett@netcom.com) +# Carl Hauser (chauser.parc@xerox.com) and +# Marcus Groeber (marcusg@ph-cip.uni-koeln.de) +# list the following header format in inf02a.doc: +# +# int16 ID; // ID magic word (5348h = "HS") +# int8 unknown1; // unknown purpose, could be third letter of ID +# int8 flags; // probably a flag word... +# // bit 0: set if INF style file +# // bit 4: set if HLP style file +# // patching this byte allows reading HLP files +# // using the VIEW command, while help files +# // seem to work with INF settings here as well. +# int16 hdrsize; // total size of header +# int16 unknown2; // unknown purpose +# +0 string HSP\x01\x9b\x00 OS/2 INF +>107 string >0 (%s) +0 string HSP\x10\x9b\x00 OS/2 HLP +>107 string >0 (%s) + +# OS/2 INI (this is a guess) +0 string \xff\xff\xff\xff\x14\0\0\0 OS/2 INI diff --git a/usr.bin/file/magdir/palm b/usr.bin/file/magdir/palm new file mode 100644 index 000000000000..46bc632e1521 --- /dev/null +++ b/usr.bin/file/magdir/palm @@ -0,0 +1,15 @@ + +#------------------------------------------------------------------------------ +# palm: file(1) magic for PalmOS {.prc,.pdb}: applications, docfiles, and hacks +# +# Brian Lalor + +# appl +60 belong 0x6170706c PalmOS application +>0 string >\0 "%s" +# TEXt +60 belong 0x54455874 AportisDoc file +>0 string >\0 "%s" +# HACK +60 belong 0x4841434b HackMaster hack +>0 string >\0 "%s" diff --git a/usr.bin/file/magdir/spectrum b/usr.bin/file/magdir/spectrum new file mode 100644 index 000000000000..e7a5549b675a --- /dev/null +++ b/usr.bin/file/magdir/spectrum @@ -0,0 +1,28 @@ + +#------------------------------------------------------------------------------ +# spectrum: file(1) magic for Spectrum emulator files. +# +# John Elliott + +# +# Spectrum +3DOS header +# +0 string PLUS3DOS\032 Spectrum +3 data +>15 byte 0 - BASIC program +>15 byte 1 - number array +>15 byte 2 - character array +>15 byte 3 - memory block +>>16 belong 0x001B0040 (screen) +>15 byte 4 - Tasword document +>15 string TAPEFILE - ZXT tapefile +# +# Tape file. This assumes the .TAP starts with a Spectrum-format header, +# which nearly all will. +# +0 string \023\000\000 Spectrum .TAP data +>4 string x "%-10.10s" +>3 byte 0 - BASIC program +>3 byte 1 - number array +>3 byte 2 - character array +>3 byte 3 - memory block +>>14 belong 0x001B0040 (screen)