Integrated file-3.17

This commit is contained in:
christos 1995-04-28 19:23:38 +00:00
parent 7bfa303f5e
commit 0bb1fbddb3
25 changed files with 346 additions and 175 deletions

View File

@ -33,20 +33,24 @@
#ifndef lint
static char *moduleid =
"@(#)$Id: apprentice.c,v 1.6 1995/03/25 22:35:35 christos Exp $";
"@(#)$Id: apprentice.c,v 1.7 1995/04/28 19:23:38 christos Exp $";
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
isspace((unsigned char) *l)) ++l;}
#define LOWCASE(l) (isupper((unsigned char) (l)) ? \
tolower((unsigned char) (l)) : (l))
static int getvalue __P((struct magic *, char **));
static int hextoint __P((int));
static char *getstr __P((char *, char *, int, int *));
static int parse __P((char *, int *, int));
static void eatsize __P((char **));
static int maxmagic = 0;
int
apprentice(fn, check)
char *fn; /* name of magic file */
@ -186,13 +190,16 @@ int *ndx, check;
* read [.lbs][+-]nnnnn)
*/
if (*l == '.') {
switch (*++l) {
l++;
switch (LOWCASE(*l)) {
case 'l':
m->in.type = LONG;
break;
case 'h':
case 's':
m->in.type = SHORT;
break;
case 'c':
case 'b':
m->in.type = BYTE;
break;
@ -279,6 +286,7 @@ int *ndx, check;
if (*l == '&') {
++l;
m->mask = signextend(m, strtoul(l, &l, 0));
eatsize(&l);
} else
m->mask = ~0L;
EATAB;
@ -360,8 +368,10 @@ char **p;
*p = getstr(*p, m->value.s, sizeof(m->value.s), &slen);
m->vallen = slen;
} else
if (m->reln != 'x')
if (m->reln != 'x') {
m->value.l = signextend(m, strtoul(*p, p, 0));
eatsize(&p);
}
return 0;
}
@ -549,3 +559,30 @@ int len;
}
}
}
/*
* eatsize(): Eat the size spec from a number [eg. 10UL]
*/
static void
eatsize(p)
char **p;
{
char *l = *p;
if (LOWCASE(*l) == 'u')
l++;
switch (LOWCASE(*l)) {
case 'l': /* long */
case 's': /* short */
case 'h': /* short */
case 'b': /* char/byte */
case 'c': /* char/byte */
l++;
/*FALLTHROUGH*/
default:
break;
}
*p = l;
}

View File

@ -36,7 +36,7 @@
#ifndef lint
static char *moduleid =
"@(#)$Id: ascmagic.c,v 1.5 1995/03/25 22:35:37 christos Exp $";
"@(#)$Id: ascmagic.c,v 1.6 1995/04/28 19:23:43 christos Exp $";
#endif /* lint */
/* an optimisation over plain strcmp() */
@ -77,13 +77,13 @@ int nbytes; /* size actually read */
while (isascii(*tp) && isspace(*tp))
++tp; /* skip leading whitespace */
if ((isascii(*tp) && (isalnum(*tp) || *tp=='\\') &&
isascii(*(tp+1)) && (isalnum(*(tp+1)) || *tp=='"'))) {
isascii(tp[1]) && (isalnum(tp[1]) || tp[1] == '"'))) {
ckfputs("troff or preprocessor input text", stdout);
return 1;
}
}
if ((*buf == 'c' || *buf == 'C') &&
isascii(*(buf + 1)) && isspace(*(buf + 1))) {
isascii(buf[1]) && isspace(buf[1])) {
ckfputs("fortran program text", stdout);
return 1;
}
@ -93,7 +93,7 @@ int nbytes; /* size actually read */
s = (unsigned char*) memcpy(nbuf, buf, nbytes);
s[nbytes] = '\0';
has_escapes = (memchr(s, '\033', nbytes) != NULL);
while ((token = strtok((char*)s, " \t\n\r\f")) != NULL) {
while ((token = strtok((char *) s, " \t\n\r\f")) != NULL) {
s = NULL; /* make strtok() keep on tokin' */
for (p = names; p < names + NNAMES; p++) {
if (STREQ(p->name, token)) {
@ -108,7 +108,7 @@ int nbytes; /* size actually read */
for (i = 0; i < nbytes; i++) {
if (!isascii(*(buf+i)))
if (!isascii(buf[i]))
return 0; /* not all ascii */
}

View File

@ -26,7 +26,7 @@
*/
#ifndef lint
static char *moduleid =
"@(#)$Id: file.c,v 1.4 1995/03/25 22:35:46 christos Exp $";
"@(#)$Id: file.c,v 1.5 1995/04/28 19:23:46 christos Exp $";
#endif /* lint */
#include <stdio.h>
@ -43,6 +43,10 @@ static char *moduleid =
#endif
#include <unistd.h> /* for read() */
#ifdef HAVE_ELF
#include <elf.h>
#endif
#include "patchlevel.h"
#include "file.h"
@ -66,7 +70,7 @@ int /* Misc globals */
struct magic *magic; /* array of magic entries */
char *magicfile = MAGIC;/* where magic be found */
char *magicfile; /* where magic be found */
char *progname; /* used throughout */
int lineno; /* line number in the magic file */
@ -90,6 +94,9 @@ char *argv[];
else
progname = argv[0];
if (!(magicfile = getenv("MAGIC")))
magicfile = MAGIC;
while ((c = getopt(argc, argv, "vcdf:Lm:z")) != EOF)
switch (c) {
case 'v':
@ -254,15 +261,47 @@ int wid;
if (nbytes == 0)
ckfputs("empty", stdout);
else {
buf[nbytes++] = '\0'; /* NULL terminate */
if (nbytes < sizeof(union VALUETYPE)) {
/* The following is to handle *very* short files */
memset(buf + nbytes, 0, sizeof(union VALUETYPE) - nbytes);
nbytes = sizeof(union VALUETYPE);
}
buf[nbytes++] = '\0'; /* NULL terminate */
tryit(buf, nbytes, zflag);
}
#ifdef HAVE_ELF
/*
* ELF executables have multiple section headers in arbitrary
* file locations and thus file(1) cannot determine it from easily.
* Instead we traverse thru all section headers until a symbol table
* one is found or else the binary is stripped.
* XXX: This will not work for binaries of a different byteorder.
* Should come up with a better fix.
*/
if (nbytes > sizeof (Elf32_Ehdr) &&
buf[EI_MAG0] == ELFMAG0 &&
buf[EI_MAG1] == ELFMAG1 &&
buf[EI_MAG2] == ELFMAG2 &&
buf[EI_MAG3] == ELFMAG3 ) {
Elf32_Ehdr elfhdr;
int stripped = 1;
(void) memcpy(&elfhdr, buf, sizeof elfhdr);
if (lseek(fd, elfhdr.e_shoff, SEEK_SET)<0)
error("lseek failed (%s).\n", strerror(errno));
for ( ; elfhdr.e_shnum ; elfhdr.e_shnum--) {
if (read(fd, buf, elfhdr.e_shentsize)<0)
error("read failed (%s).\n", strerror(errno));
if (((Elf32_Shdr *)&buf)->sh_type == SHT_SYMTAB) {
stripped = 0;
break;
}
}
if (stripped)
(void) printf (" - stripped");
}
#endif
if (inname != stdname) {
/*
* Try to restore access, modification times if read it.

View File

@ -1,6 +1,6 @@
/*
* file.h - definitions for file(1) program
* @(#)$Id: file.h,v 1.5 1995/03/25 22:35:51 christos Exp $
* @(#)$Id: file.h,v 1.6 1995/04/28 19:23:48 christos Exp $
*
* Copyright (c) Ian F. Darwin, 1987.
* Written by Ian F. Darwin.
@ -26,7 +26,9 @@
* 4. This notice may not be removed or altered.
*/
#define HOWMANY 8192 /* how much of the file to look at */
#ifndef HOWMANY
# define HOWMANY 8192 /* how much of the file to look at */
#endif
#define MAXMAGIS 1000 /* max entries in /etc/magic */
#define MAXDESC 50 /* max leng of text description */
#define MAXstring 32 /* max leng of "string" types */

View File

@ -46,7 +46,7 @@
#ifndef lint
static char *moduleid =
"@(#)$Id: fsmagic.c,v 1.6 1995/03/25 22:35:58 christos Exp $";
"@(#)$Id: fsmagic.c,v 1.7 1995/04/28 19:23:51 christos Exp $";
#endif /* lint */
int

View File

@ -5,7 +5,7 @@
* Pubic Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
*
* @(#)list.c 1.18 9/23/86 Public Domain - gnu
* $Id: is_tar.c,v 1.4 1995/03/25 22:36:07 christos Exp $
* $Id: is_tar.c,v 1.5 1995/04/28 19:23:54 christos Exp $
*
* Comments changed and some code/comments reformatted
* for file command by Ian Darwin.

View File

@ -2,7 +2,8 @@
#------------------------------------------------------------------------------
# audio: file(1) magic for sound formats
#
# from Jan Nicolai Langfeldt <janl@ifi.uio.no>,
# Jan Nicolai Langfeldt (janl@ifi.uio.no), Dan Quinlan (quinlan@yggdrasil.com),
# and others
#
# Sun/NeXT audio data
@ -66,3 +67,12 @@
>22 short =2 Stereo
>22 short >2 %d Channels
>24 long >0 %d Hz
# Extended MOD format (*.emd) (Greg Roelofs, newt@uchicago.edu); NOT TESTED
# [based on posting 940824 by "Dirk/Elastik", husberg@lehtori.cc.tut.fi]
0 string EMOD Extended MOD sound data,
>4 byte&0xf0 x version %d
>4 byte&0x0f x \b.%d,
>45 byte x %d instruments
>83 byte 0 (module)
>83 byte 1 (song)

View File

@ -43,7 +43,10 @@
>2 belong =1 %d character originally
#
# This magic number is byte-order-independent.
# Are there two types of old packed data? One big endian, one little endian?
#
#0 beshort 017437 old packed data, big endian
#0 leshort 017437 old packed data, little endian
0 short 017437 old packed data
# XXX - why *two* entries for "compacted data", one of which is

View File

@ -4,12 +4,27 @@
#
# extracted from header/code files by Graeme Wilford (eep2gw@ee.surrey.ac.uk)
#
0 long 0x053162 Berkeley db BTREE database
>4 byte 1 (version 1)
>4 byte 2 (version 2)
>4 byte 3 (version 3)
0 long 0x061561 Berkeley db HASH database
>4 byte 1 (version 1)
>4 byte 2 (version 2)
>4 byte 3 (version 3)
0 long 0x13579ace GNU gdbm or ndbm database
#
0 belong 0x061561 Berkeley DB Hash file
>4 belong >0 (Version %d,
>8 belong 1234 Little Endian,
>8 belong 4321 Big Endian,
>12 belong x Bucket Size %d,
>16 belong x Directory Size %d,
>20 belong x Segment Size %d,
>24 belong x Segment Shift %d,
>28 belong x Overflow Point %d,
>32 belong x Last Freed %d,
>36 belong x Max Bucket %d,
>40 belong x High Mask 0x%x,
>44 belong x Low Mask 0x%x,
>48 belong x Fill Factor %d,
>52 belong x Number of Keys %d)
#
0 belong 0x053162 Berkeley DB Btree file
>4 belong >0 (Version %d,
>8 belong x Page Size %d,
>12 belong x Free Page %d,
>16 belong x Number of Records %d,
>20 belong x Flags 0x%x)

View File

@ -5,43 +5,47 @@
# We have to check the byte order flag to see what byte order all the
# other stuff in the header is in.
#
# MIPS, i486 added by Daniel Quinlan (quinlan@yggdrasil.com)
# updated by Daniel Quinlan (quinlan@yggdrasil.com)
0 string \177ELF ELF
>4 byte 0 invalid class
>4 byte 1 32-bit
>4 byte 2 64-bit
>5 byte 0 invalid byte order
>5 byte 1 LSB
>>16 leshort 0 unknown type
>>16 leshort 1 relocatable
>>16 leshort 2 executable
>>16 leshort 3 dynamic lib
>>16 leshort 4 core file
>>18 leshort 0 unknown machine
>>18 leshort 1 WE32100 and up
>>18 leshort 2 SPARC - invalid byte order
>>18 leshort 3 i386 (386 and up)
>>18 leshort 4 M68000 - invalid byte order
>>18 leshort 5 M88000 - invalud byte order
>>18 leshort 6 i486
>>18 leshort 7 i860
>>18 leshort 8 MIPS
>>20 lelong 1 Version 1
>>16 leshort 0 no file type,
>>16 leshort 1 relocatable,
>>16 leshort 2 executable,
>>16 leshort 3 shared object,
>>16 leshort 4 core file,
>>16 leshort &0xff00 processor-specific,
>>18 leshort 0 no machine,
>>18 leshort 1 AT&T WE32100,
>>18 leshort 2 SPARC - invalid byte order,
>>18 leshort 3 Intel 80386,
>>18 leshort 4 Motorola 68000 - invalid byte order,
>>18 leshort 5 Motorola 88000 - invalid byte order,
>>18 leshort 6 Intel 80486,
>>18 leshort 7 Intel 80860,
>>18 leshort 8 MIPS RS3000,
>>20 lelong 0 invalid version
>>20 lelong 1 version 1
>>36 lelong 1 MathCoPro/FPU/MAU Required
>5 byte 2 MSB
>>16 beshort 0 unknown type
>>16 beshort 1 relocatable
>>16 beshort 2 executable
>>16 beshort 3 dynamic lib
>>16 beshort 4 core file
>>18 beshort 0 unknown machine
>>18 beshort 1 WE32100 and up
>>18 beshort 2 SPARC
>>18 beshort 3 i386 (386 and up) - invalid byte order
>>18 beshort 4 M68000
>>18 beshort 5 M88000
>>18 beshort 6 i486 - invalid byte order
>>18 beshort 7 i860
>>18 beshort 8 MIPS
>>20 belong 1 Version 1
>>16 beshort 0 no file type,
>>16 beshort 1 relocatable,
>>16 beshort 2 executable,
>>16 beshort 3 shared object,
>>16 beshort 4 core file,
>>16 beshort &0xff00 processor-specific,
>>18 beshort 0 no machine,
>>18 beshort 1 AT&T WE32100,
>>18 beshort 2 SPARC,
>>18 beshort 3 Intel 80386 - invalid byte order,
>>18 beshort 4 Motorola 68000,
>>18 beshort 5 Motorola 88000,
>>18 beshort 6 Intel 80486 - invalid byte order,
>>18 beshort 7 Intel 80860,
>>18 beshort 8 MIPS RS3000,
>>20 belong 0 invalid version
>>20 belong 1 version 1
>>36 belong 1 MathCoPro/FPU/MAU Required

View File

@ -16,27 +16,25 @@
# UNIX environment atop the "SUN kernel"; dunno whether it was
# big-endian or little-endian.
#
# I'm guessing that the 200 series was 68K-based; the 300 and 400 series
# are.
# Daniel Quinlan (quinlan@yggdrasil.com): hp200 machines are 68010 based;
# hp300 are 68020+68881 based; hp400 are also 68k. The following basic
# HP magic is useful for reference, but using "long" magic is a better
# practice in order to avoid collisions.
#
# Daniel Quinlan (quinlan@yggdrasil.com): hp200 machines are 68010
# based; hp300 are 68020+68881 based. I think the following "basic"
# magic should probably be integrated and the various flavors of
# binaries be implemented with ">2" in case some flavors have been missed.
# 0 beshort 200 hp200 (68010) BSD binary
# 0 beshort 300 hp300 (68020+68881) BSD binary
# 0 beshort 0x20c hp200/300 HP-UX binary
# 0 beshort 0x20b hp800 HP-UX binary
# 0 beshort 200 hp200 (68010) BSD binary
# 0 beshort 300 hp300 (68020+68881) BSD binary
# 0 beshort 0x20c hp200/300 HP-UX binary
# 0 beshort 0x20b hp800 HP-UX binary
#
# The "misc" stuff needs a byte order; the archives look suspiciously
# like the old 177545 archives (0xff65 = 0177545).
#
#### Old Apollo stuff
0 beshort 0627 Apollo m68k COFF executable
>18 beshort ^040000 not stripped
>18 beshort ^040000 not stripped
>22 beshort >0 - version %ld
0 beshort 0624 apollo a88k COFF executable
>18 beshort ^040000 not stripped
>18 beshort ^040000 not stripped
>22 beshort >0 - version %ld
0 long 01203604016 TML 0123 byte-order format
0 long 01702407010 TML 1032 byte-order format

View File

@ -7,7 +7,7 @@
# merging several one- and two-line files into here.
#
# XXX - byte order for GIF and TIFF fields?
# [GRR: TIFF allows both byte orders; GIF is probably little-endian]
# [GRR: TIFF allows both byte orders; GIF is little-endian]
#
# [GRR: what the hell is this doing in here?]
@ -21,28 +21,34 @@
0 string P5 PGM "rawbits" file
0 string P6 PPM "rawbits" file
# NIFF (Navy Interchange File Format, a modification of TIFF)
# [GRR: this *must* go before TIFF]
# NIFF (Navy Interchange File Format, a modification of TIFF) images
# this *must* go before TIFF
0 string IIN1 NIFF raster data
# TIFF and friends
# TIFF images
0 string MM TIFF file, big-endian
>2 short >0 version %d
>2 beshort >0 - version %d
0 string II TIFF file, little-endian
>2 short >0 version %d
>2 leshort >0 - version %d
# possible GIF replacements; none yet released!
# PNG [Portable Network Graphics, or "PNG's Not GIF"] images
# (Greg Roelofs, newt@uchicago.edu)
#
# GRR 950115: this was mine ("Zip GIF"):
0 string GIF94z ZIF image (GIF+deflate alpha)
# 137 P N G \r \n ^Z \n [4-byte length] H E A D [HEAD data] [HEAD crc] ...
#
# GRR 950115: this is Jeremy Wohl's Free Graphics Format (better):
0 string FGF95a FGF image (GIF+deflate beta)
#
# GRR 950115: this is Thomas Boutell's Portable Bitmap Format proposal
# (best; not yet implemented):
0 string .PBF PBF image (deflate compression)
0 string \x89PNG PNG image,
>4 belong !0x0d0a1a0a CORRUPTED,
>16 belong x %ld x
>20 belong x %ld,
>24 byte x %d-bit
>25 byte 0 grayscale,
>25 byte 2 \b/color RGB,
>25 byte 3 colormap,
>25 byte 4 gray+alpha,
>25 byte 6 \b/color RGBA,
#>26 byte 0 deflate/32K,
>28 byte 0 non-interlaced
>28 byte 1 interlaced
# GIF
0 string GIF GIF image
@ -51,7 +57,7 @@
>6 leshort >0 %hd x
>8 leshort >0 %hd,
#>10 byte &0x80 color mapped,
# GRR 950118: the following is not accurate for xv-created GIFs:
# GRR 950330: the following is not accurate for most GIFs:
#>10 byte &0x40 interlaced,
>10 byte&0x07 =0x00 2 colors
>10 byte&0x07 =0x01 4 colors
@ -186,18 +192,24 @@
#>28 belong >0 colormap is %d bytes long
# Daniel Quinlan (quinlan@yggdrasil.com) -- from an SGI machine
0 string IT01 FIT image file
>4 belong x (%d x
>8 belong x %d x
>12 belong x %d)
# There may be a byte swapped version of SGI imagelib images, but
# I haven't seen any evidence of programs that support it.
0 beshort 000732 SGI imagelib image
>6 beshort x \b, %d x
>8 beshort x %d
#
0 string IT02 FIT image file
>4 belong x (%d x
>8 belong x %d x
>12 belong x %d)
0 string IT01 FIT image file
>4 belong x \b, %d x
>8 belong x %d x
>12 belong x %d
#
2048 string PCD_IPI Kodak Photo CD image pack file
0 string PCD_OPA Kodak Photo CD overview pack file
0 string IT02 FIT image file
>4 belong x \b, %d x
>8 belong x %d x
>12 belong x %d
#
2048 string PCD_IPI Kodak Photo CD image pack file
0 string PCD_OPA Kodak Photo CD overview pack file
# Jeff Uphoff <juphoff@tarsier.cv.nrao.edu>
# FITS is the Flexible Image Transport System, the de facto standard for

View File

@ -6,4 +6,3 @@
0 string =<!OPS Interleaf document text
>5 string ,\ Version\ (version
>>14 string >\0 %s)

View File

@ -2,23 +2,53 @@
#------------------------------------------------------------------------------
# ispell: file(1) magic for ispell
#
# XXX - byte order?
# Ispell 3.0 has a magic of 0x9601 and ispell 3.1 has 0x9602. This magic
# will match 0x9600 through 0x9603 in *both* little endian and big endian.
# (No other current magic entries collide.)
#
0 short 0xffff9601 ispell hash file
>2 short 0x00 - 8-bit, no capitalization, 26 flags
>2 short 0x01 - 7-bit, no capitalization, 26 flags
>2 short 0x02 - 8-bit, capitalization, 26 flags
>2 short 0x03 - 7-bit, capitalization, 26 flags
>2 short 0x04 - 8-bit, no capitalization, 52 flags
>2 short 0x05 - 7-bit, no capitalization, 52 flags
>2 short 0x06 - 8-bit, capitalization, 52 flags
>2 short 0x07 - 7-bit, capitalization, 52 flags
>2 short 0x08 - 8-bit, no capitalization, 128 flags
>2 short 0x09 - 7-bit, no capitalization, 128 flags
>2 short 0x0A - 8-bit, capitalization, 128 flags
>2 short 0x0B - 7-bit, capitalization, 128 flags
>2 short 0x0C - 8-bit, no capitalization, 256 flags
>2 short 0x0D - 7-bit, no capitalization, 256 flags
>2 short 0x0E - 8-bit, capitalization, 256 flags
>2 short 0x0F - 7-bit, capitalization, 256 flags
>4 short >0 and %d string characters
# Updated by Daniel Quinlan (quinlan@yggdrasil.com)
#
0 leshort&0xFFFC 0x9600 little endian ispell
>0 byte 0 hash file (?),
>0 byte 1 3.0 hash file,
>0 byte 2 3.1 hash file,
>0 byte 3 hash file (?),
>2 leshort 0x00 8-bit, no capitalization, 26 flags
>2 leshort 0x01 7-bit, no capitalization, 26 flags
>2 leshort 0x02 8-bit, capitalization, 26 flags
>2 leshort 0x03 7-bit, capitalization, 26 flags
>2 leshort 0x04 8-bit, no capitalization, 52 flags
>2 leshort 0x05 7-bit, no capitalization, 52 flags
>2 leshort 0x06 8-bit, capitalization, 52 flags
>2 leshort 0x07 7-bit, capitalization, 52 flags
>2 leshort 0x08 8-bit, no capitalization, 128 flags
>2 leshort 0x09 7-bit, no capitalization, 128 flags
>2 leshort 0x0A 8-bit, capitalization, 128 flags
>2 leshort 0x0B 7-bit, capitalization, 128 flags
>2 leshort 0x0C 8-bit, no capitalization, 256 flags
>2 leshort 0x0D 7-bit, no capitalization, 256 flags
>2 leshort 0x0E 8-bit, capitalization, 256 flags
>2 leshort 0x0F 7-bit, capitalization, 256 flags
>4 leshort >0 and %d string characters
0 beshort&0xFFFC 0x9600 big endian ispell
>1 byte 0 hash file (?),
>1 byte 1 3.0 hash file,
>1 byte 2 3.1 hash file,
>1 byte 3 hash file (?),
>2 beshort 0x00 8-bit, no capitalization, 26 flags
>2 beshort 0x01 7-bit, no capitalization, 26 flags
>2 beshort 0x02 8-bit, capitalization, 26 flags
>2 beshort 0x03 7-bit, capitalization, 26 flags
>2 beshort 0x04 8-bit, no capitalization, 52 flags
>2 beshort 0x05 7-bit, no capitalization, 52 flags
>2 beshort 0x06 8-bit, capitalization, 52 flags
>2 beshort 0x07 7-bit, capitalization, 52 flags
>2 beshort 0x08 8-bit, no capitalization, 128 flags
>2 beshort 0x09 7-bit, no capitalization, 128 flags
>2 beshort 0x0A 8-bit, capitalization, 128 flags
>2 beshort 0x0B 7-bit, capitalization, 128 flags
>2 beshort 0x0C 8-bit, no capitalization, 256 flags
>2 beshort 0x0D 7-bit, no capitalization, 256 flags
>2 beshort 0x0E 8-bit, capitalization, 256 flags
>2 beshort 0x0F 7-bit, capitalization, 256 flags
>4 beshort >0 and %d string characters

View File

@ -2,44 +2,50 @@
#------------------------------------------------------------------------------
# linux: file(1) magic for Linux files
#
# Values for Linux/i386 binaries, from Rik Faith <faith@cs.unc.edu>,
# Peter Tobias <tobias@server.et-inf.fho-emden.de>, and Daniel Quinlan
# <quinlan@yggdrasil.com>
# Values for Linux/i386 binaries, from Daniel Quinlan <quinlan@yggdrasil.com>
# The following basic Linux magic is useful for reference, but using
# "long" magic is a better practice in order to avoid collisions.
#
# 2 leshort 100 Linux/i386
# >0 leshort 0407 impure executable (OMAGIC)
# >0 leshort 0410 pure executable (NMAGIC)
# >0 leshort 0413 demand-paged executable (ZMAGIC)
# >0 leshort 0314 demand-paged executable (QMAGIC)
#
0 lelong 0x00640107 Linux/i386 impure executable (OMAGIC)
>16 lelong 0 - stripped
0 lelong 0x00640108 Linux/i386 pure executable (NMAGIC)
>16 lelong 0 - stripped
0 lelong 0x0064010b Linux/i386 demand-paged executable (ZMAGIC)
>16 lelong 0 - stripped
0 lelong 0x006400cc Linux/i386 demand-paged executable (QMAGIC)
>16 lelong 0 - stripped
#
2 leshort 100 Linux/i386
>0 leshort 0407 impure executable (OMAGIC)
>0 leshort 0410 pure executable (NMAGIC)
>0 leshort 0413 demand-paged executable (ZMAGIC)
>0 leshort 0314 demand-paged executable (QMAGIC)
>16 lelong >0 not stripped
>16 lelong 0 stripped
>0 string Jump jump
# object files
# first entry is absolutely correct, but may conflict with PDP-11 executable
#0 leshort 0407 Linux/i386 object file
0 string \007\001\000 Linux/i386 object file
>20 long >0x1020 - DLL library
>20 lelong >0x1020 - DLL library
# message catalogs, from Mitchum DSouza <m.dsouza@mrc-apu.cam.ac.uk>
0 string *nazgul* compiled message catalog
>8 long >0 - version %ld
>8 lelong >0 - version %ld
# core dump file, from Bill Reynolds <bill@goshawk.lanl.gov>
216 lelong 0421 Linux/i386 core file
>220 string >\0 of '%s'
>200 lelong >0 (signal %d)
#
# LILO boot/chain loaders, from Daniel Quinlan <quinlan@yggdrasil.com>
# this can be overridden by the DOS executable (COM) entry
# XXX - moved to "dos"
2 string LILO Linux/i386 LILO boot/chain loader
#
# Debian Packages, from Peter Tobias <tobias@server.et-inf.fho-emden.de>
0 string 0.9
>8 byte 0x0a Debian Binary Package -
>>3 byte >0 created by dpkg 0.9%c
>>4 byte >0 pl%c
# PSF fonts, from H. Peter Anvin <hpa@yggdrasil.com>
0 leshort 0x0436 Pc Screen Font data
>2 byte 0 - 256 characters, no directory
>2 byte 1 - 512 characters, no directory
>2 byte 2 - 256 characters, Unicode directory
>2 byte 3 - 512 characters, Unicode directory
>3 byte >0 - 8x%d
0 leshort 0x0436 Linux/i386 PC Screen Font data
>2 byte 0 - 256 characters, no directory,
>2 byte 1 - 512 characters, no directory,
>2 byte 2 - 256 characters, Unicode directory,
>2 byte 3 - 512 characters, Unicode directory,
>3 byte >0 8x%d
# Linux swap file, from Daniel Quinlan <quinlan@yggdrasil.com>
4086 string SWAP-SPACE Linux/i386 swap file

View File

@ -1,13 +1,12 @@
#------------------------------------------------------------------------------
# rtf: file(1) magic for RTF (Rich text format)
# rtf: file(1) magic for Rich Text Format (RTF)
#
# This information was gleaned from the version 1 documentation by
# D.P.Simpson@dcs.warwick.ac.uk (Duncan P Simpson)
# Duncan P. Simpson, D.P.Simpson@dcs.warwick.ac.uk
#
0 string {\\rtf Rich Text Format data (version
>5 byte x %c,
>6 string \\mac Apple Macintosh characters)
>6 string \\ansi ANSI characters)
>6 string \\pc IBM PC characters)
>6 string \\pca IBM PS/2 characters)
0 string {\\rtf Rich Text Format data,
>5 byte x version %c,
>6 string \\ansi ANSI
>6 string \\mac Apple Macintosh
>6 string \\pc IBM PC code page 437
>6 string \\pca IBM PC code page 850

View File

@ -152,13 +152,6 @@
0 string SGIAUDIT SGI Audit file
>8 byte x - version %d
>9 byte x .%ld
#
0 beshort 000732 SGI imagelib image
>6 beshort x (%d x
>8 beshort x %d)
0 beshort 0155001 SGI imagelib image byte-swapped
0 beshort 017436 packed data
0 beshort 017037 packed data (byte swapped)
# Are these three SGI-based file types or general ones?
0 string WNGZWZSC Wingz compiled script
0 string WNGZWZSS Wingz spreadsheet

View File

@ -2,7 +2,7 @@
#------------------------------------------------------------------------------
# sgml: file(1) magic for Standard(?) Generalized Mark-up Language
#
# $Id: sgml,v 1.2 1995/03/25 22:39:42 christos Exp $
# $Id: sgml,v 1.3 1995/04/28 19:24:37 christos Exp $
# SGML goop, mostly from rph@sq.
0 string \<!DOCTYPE Exported SGML document
0 string \<!doctype Exported SGML document

View File

@ -2,7 +2,7 @@
#------------------------------------------------------------------------------
# softquad: file(1) magic for SoftQuad Publishing Software
#
# $Id: softquad,v 1.3 1995/03/25 22:39:43 christos Exp $
# $Id: softquad,v 1.4 1995/04/28 19:24:38 christos Exp $
# Author/Editor and RulesBuilder
#
# XXX - byte order?

View File

@ -7,3 +7,10 @@
# and deleted if they duplicate other entries.
#
0 short 0610 Perkin-Elmer executable
# AMD 29K
0 beshort 0572 amd 29k coff noprebar executable
0 beshort 01572 amd 29k coff prebar executable
0 beshort 0160007 amd 29k coff archive
# Cray
6 beshort 0407 unicos (cray) executable

View File

@ -3,7 +3,6 @@
# vms: file(1) magic for VMS executables (experimental)
#
# VMS .exe formats, both VAX and AXP (Greg Roelofs, newt@uchicago.edu)
# This file should be renamed to "vms" eventually...
# GRR 950122: I'm just guessing on these, based on inspection of the headers
# of three executables each for Alpha and VAX architectures. The VAX files

View File

@ -10,7 +10,7 @@
*
* See LEGAL.NOTICE
*
* $Id: names.h,v 1.3 1995/03/25 22:36:22 christos Exp $
* $Id: names.h,v 1.4 1995/04/28 19:23:56 christos Exp $
*/
/* these types are used to index the table 'types': keep em in sync! */
@ -25,13 +25,13 @@
#define L_NEWS 8 /* Usenet Netnews */
static char *types[] = {
"c program text",
"fortran program text",
"C program text",
"FORTRAN program text",
"make commands text" ,
"pl/1 program text",
"PL/1 program text",
"assembler program text",
"English text",
"pascal program text",
"Pascal program text",
"mail text",
"news text",
"can't happen error on names.h/types",
@ -43,7 +43,7 @@ static struct names {
} names[] = {
/* These must be sorted by eye for optimal hit rate */
/* Add to this list only after substantial meditation */
{"/*", L_C}, /* must preced "The", "the", etc. */
{"/*", L_C}, /* must precede "The", "the", etc. */
{"#include", L_C},
{"char", L_C},
{"The", L_ENG},
@ -75,6 +75,7 @@ static struct names {
{".byte", L_MACH},
{".even", L_MACH},
{".globl", L_MACH},
{".text", L_MACH},
{"clr", L_MACH},
{"(input,", L_PAS},
{"dcl", L_PLI},

View File

@ -1,13 +1,21 @@
#define FILE_VERSION_MAJOR 3
#define patchlevel 16
#define patchlevel 17
/*
* Patchlevel file for Ian Darwin's MAGIC command.
* $Id: patchlevel.h,v 1.2 1995/03/25 22:36:27 christos Exp $
* $Id: patchlevel.h,v 1.3 1995/04/28 19:23:58 christos Exp $
*
* $Log: patchlevel.h,v $
* Revision 1.2 1995/03/25 22:36:27 christos
* Updated to file-3.16; fixes PR867
* Revision 1.3 1995/04/28 19:23:58 christos
* Integrated file-3.17
*
* 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.

View File

@ -40,7 +40,7 @@
#ifndef lint
static char *moduleid =
"@(#)$Id: print.c,v 1.6 1995/03/25 22:36:34 christos Exp $";
"@(#)$Id: print.c,v 1.7 1995/04/28 19:24:01 christos Exp $";
#endif /* lint */
#define SZOF(a) (sizeof(a) / sizeof(a[0]))

View File

@ -34,7 +34,7 @@
#ifndef lint
static char *moduleid =
"@(#)$Id: softmagic.c,v 1.6 1995/03/25 22:36:39 christos Exp $";
"@(#)$Id: softmagic.c,v 1.7 1995/04/28 19:24:04 christos Exp $";
#endif /* lint */
static int match __P((unsigned char *, int));
@ -287,11 +287,20 @@ struct magic *m;
int nbytes;
{
long offset = m->offset;
if (offset + sizeof(union VALUETYPE) > nbytes)
return 0;
long diff = nbytes - (offset + sizeof(union VALUETYPE));
if (diff >= 0)
memcpy(p, s + offset, sizeof(union VALUETYPE));
else {
/* Not enough space; zeropad */
long have = sizeof(union VALUETYPE) + diff;
if (have > 0)
memcpy(p, s + offset, have);
else
have = 0;
memset(p + have, 0, sizeof(union VALUETYPE) - have);
}
memcpy(p, s + offset, sizeof(union VALUETYPE));
if (debug) {
mdebug(offset, (char *) p, sizeof(union VALUETYPE));