Virgin import of Christos Zoulas's FILE 3.34.
This commit is contained in:
parent
ebb4cbb2d0
commit
adef7cde57
@ -140,3 +140,33 @@
|
||||
0 string MOVI Silicon Graphics movie file
|
||||
4 string moov Apple QuickTime movie file (moov)
|
||||
4 string mdat Apple QuickTime movie file (mdat)
|
||||
|
||||
# iso 13818 transport stream
|
||||
#
|
||||
# from Oskar Schirmer <schirmer@scara.com> Feb 3, 2001 (ISO 13818.1)
|
||||
# (the following is a little bit restrictive and works fine for a stream
|
||||
# that starts with PAT properly. it won't work for stream data, that is
|
||||
# cut from an input device data right in the middle, but this shouldn't
|
||||
# disturb)
|
||||
# syncbyte 8 bit 0x47
|
||||
# error_ind 1 bit -
|
||||
# payload_start 1 bit 1
|
||||
# priority 1 bit -
|
||||
# PID 13 bit 0x0000
|
||||
# scrambling 2 bit -
|
||||
# adaptfld_ctrl 2 bit 1 or 3
|
||||
# conti_count 4 bit 0
|
||||
0 belong&0xFF5FFF1F 0x47400010 MPEG transport stream data
|
||||
>188 byte !0x47 CORRUPTED
|
||||
|
||||
# ATARI ST relocatable PRG
|
||||
#
|
||||
# from Oskar Schirmer <schirmer@scara.com> Feb 3, 2001
|
||||
# (according to Roland Waldi, Oct 21, 1987)
|
||||
# besides the magic 0x601a, the text segment size is checked to be
|
||||
# not larger than 1 MB (which is a lot on ST).
|
||||
0 belong&0xFFFFFFF0 0x601A0000 Atari ST M68K executable
|
||||
>2 belong x (txt=%ld,
|
||||
>6 belong x dat=%ld,
|
||||
>10 belong x bss=%ld,
|
||||
>14 belong x sym=%ld)
|
||||
|
@ -234,3 +234,18 @@
|
||||
# http://www.XCF.Berkeley.EDU/~jmacd/prcs.html) generates a packaged project
|
||||
# file which is recognized by the following entry:
|
||||
0 leshort 0xeb81 PRCS packaged project
|
||||
|
||||
# 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
|
||||
>24 byte x \b.%d
|
||||
|
||||
# GTKtalog catalogs
|
||||
# by David Necas (Yeti) <yeti@physics.muni.cz>
|
||||
0 lelong <20
|
||||
>4 string gtktalog\ GTKtalog catalog data,
|
||||
>>13 string 3 version 3
|
||||
>>>14 beshort 0x677a (gzipped)
|
||||
>>>14 beshort !0x677a (not gzipped)
|
||||
>>13 string >3 version %s
|
||||
|
12
contrib/file/Magdir/dyadic
Normal file
12
contrib/file/Magdir/dyadic
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Dyadic: file(1) magic for Dyalog APL.
|
||||
#
|
||||
0 byte 0xaa
|
||||
>1 byte <4 Dyalog APL
|
||||
>>1 byte 0x00 incomplete workspace
|
||||
>>1 byte 0x01 component file
|
||||
>>1 byte 0x02 external variable
|
||||
>>1 byte 0x03 workspace
|
||||
>>2 byte x version %d
|
||||
>>3 byte x .%d
|
9
contrib/file/Magdir/editors
Normal file
9
contrib/file/Magdir/editors
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# T602 editor documents
|
||||
# by David Necas <yeti@physics.muni.cz>
|
||||
0 string @CT\ T602 document data,
|
||||
>4 string 0 Kamenicky
|
||||
>4 string 1 CP 852
|
||||
>4 string 2 KOI8-CS
|
||||
>4 string >2 unknown encoding
|
@ -61,6 +61,8 @@
|
||||
>>18 leshort 10 MIPS R3000_LE,
|
||||
>>18 leshort 11 RS6000 - invalid byte order,
|
||||
>>18 leshort 15 PA-RISC - invalid byte order,
|
||||
>>>50 leshort 0x0214 2.0
|
||||
>>>48 leshort &0x0008 (LP64),
|
||||
>>18 leshort 16 nCUBE,
|
||||
>>18 leshort 17 Fujitsu VPP500,
|
||||
>>18 leshort 18 SPARC32PLUS,
|
||||
@ -89,6 +91,20 @@
|
||||
>>20 lelong 1 version 1
|
||||
>>36 lelong 1 MathCoPro/FPU/MAU Required
|
||||
>8 string >\0 (%s)
|
||||
>8 string \0
|
||||
>>7 byte 0 (SYSV)
|
||||
>>7 byte 1 (HP-UX)
|
||||
>>7 byte 2 (NetBSD)
|
||||
>>7 byte 3 (GNU/Linux)
|
||||
>>7 byte 4 (GNU/Hurd)
|
||||
>>7 byte 5 (86Open)
|
||||
>>7 byte 6 (Solaris)
|
||||
>>7 byte 7 (Monterey)
|
||||
>>7 byte 8 (IRIX)
|
||||
>>7 byte 9 (FreeBSD)
|
||||
>>7 byte 10 (Tru64)
|
||||
>>7 byte 97 (ARM)
|
||||
>>7 byte 255 (embedded)
|
||||
>5 byte 2 MSB
|
||||
# only for MIPS R3000_BE
|
||||
>>18 beshort 8
|
||||
@ -128,7 +144,9 @@
|
||||
>>18 beshort 9 Amdahl,
|
||||
>>18 beshort 10 MIPS R3000_LE - invalid byte order,
|
||||
>>18 beshort 11 RS6000,
|
||||
>>18 beshort 15 PA-RISC,
|
||||
>>18 beshort 15 PA-RISC
|
||||
>>>50 beshort 0x0214 2.0
|
||||
>>>48 beshort &0x0008 (LP64)
|
||||
>>18 beshort 16 nCUBE,
|
||||
>>18 beshort 17 Fujitsu VPP500,
|
||||
>>18 beshort 18 SPARC32PLUS,
|
||||
|
18
contrib/file/Magdir/hitachi-sh
Normal file
18
contrib/file/Magdir/hitachi-sh
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# hitach-sh: file(1) magic for Hitachi Super-H
|
||||
#
|
||||
# Super-H COFF
|
||||
#
|
||||
0 beshort 0x0500 Hitachi SH big-endian COFF
|
||||
>18 beshort&0x0002 =0x0000 object
|
||||
>18 beshort&0x0002 =0x0002 executable
|
||||
>18 beshort&0x0008 =0x0000 \b, stripped
|
||||
>18 beshort&0x0008 =0x0008 \b, not stripped
|
||||
#
|
||||
0 leshort 0x0550 Hitachi SH little-endian COFF
|
||||
>18 leshort&0x0002 =0x0000 object
|
||||
>18 leshort&0x0002 =0x0002 executable
|
||||
>18 leshort&0x0008 =0x0000 \b, stripped
|
||||
>18 leshort&0x0008 =0x0008 \b, not stripped
|
||||
|
@ -249,3 +249,143 @@
|
||||
>2 beshort 0407 impure binary
|
||||
>2 beshort 0410 read-only binary
|
||||
>2 beshort 0413 demand paged binary
|
||||
#
|
||||
# From David Gero <dgero@nortelnetworks.com>
|
||||
# HP-UX 10.20 core file format from /usr/include/sys/core.h
|
||||
# Unfortunately, HP-UX uses corehead blocks without specifying the order
|
||||
# There are four we care about:
|
||||
# CORE_KERNEL, which starts with the string "HP-UX"
|
||||
# CORE_EXEC, which contains the name of the command
|
||||
# CORE_PROC, which contains the signal number that caused the core dump
|
||||
# CORE_FORMAT, which contains the version of the core file format (== 1)
|
||||
# The only observed order in real core files is KERNEL, EXEC, FORMAT, PROC
|
||||
# but we include all 6 variations of the order of the first 3, and
|
||||
# assume that PROC will always be last
|
||||
# Order 1: KERNEL, EXEC, FORMAT, PROC
|
||||
0x10 string HP-UX
|
||||
>0 belong 2
|
||||
>>0xC belong 0x3C
|
||||
>>>0x4C belong 0x100
|
||||
>>>>0x58 belong 0x44
|
||||
>>>>>0xA0 belong 1
|
||||
>>>>>>0xAC belong 4
|
||||
>>>>>>>0xB0 belong 1
|
||||
>>>>>>>>0xB4 belong 4 core file
|
||||
>>>>>>>>>0x90 string >\0 from '%s'
|
||||
>>>>>>>>>0xC4 belong 3 - received SIGQUIT
|
||||
>>>>>>>>>0xC4 belong 4 - received SIGILL
|
||||
>>>>>>>>>0xC4 belong 5 - received SIGTRAP
|
||||
>>>>>>>>>0xC4 belong 6 - received SIGABRT
|
||||
>>>>>>>>>0xC4 belong 7 - received SIGEMT
|
||||
>>>>>>>>>0xC4 belong 8 - received SIGFPE
|
||||
>>>>>>>>>0xC4 belong 10 - received SIGBUS
|
||||
>>>>>>>>>0xC4 belong 11 - received SIGSEGV
|
||||
>>>>>>>>>0xC4 belong 12 - received SIGSYS
|
||||
>>>>>>>>>0xC4 belong 33 - received SIGXCPU
|
||||
>>>>>>>>>0xC4 belong 34 - received SIGXFSZ
|
||||
# Order 2: KERNEL, FORMAT, EXEC, PROC
|
||||
>>>0x4C belong 1
|
||||
>>>>0x58 belong 4
|
||||
>>>>>0x5C belong 1
|
||||
>>>>>>0x60 belong 0x100
|
||||
>>>>>>>0x6C belong 0x44
|
||||
>>>>>>>>0xB4 belong 4 core file
|
||||
>>>>>>>>>0xA4 string >\0 from '%s'
|
||||
>>>>>>>>>0xC4 belong 3 - received SIGQUIT
|
||||
>>>>>>>>>0xC4 belong 4 - received SIGILL
|
||||
>>>>>>>>>0xC4 belong 5 - received SIGTRAP
|
||||
>>>>>>>>>0xC4 belong 6 - received SIGABRT
|
||||
>>>>>>>>>0xC4 belong 7 - received SIGEMT
|
||||
>>>>>>>>>0xC4 belong 8 - received SIGFPE
|
||||
>>>>>>>>>0xC4 belong 10 - received SIGBUS
|
||||
>>>>>>>>>0xC4 belong 11 - received SIGSEGV
|
||||
>>>>>>>>>0xC4 belong 12 - received SIGSYS
|
||||
>>>>>>>>>0xC4 belong 33 - received SIGXCPU
|
||||
>>>>>>>>>0xC4 belong 34 - received SIGXFSZ
|
||||
# Order 3: FORMAT, KERNEL, EXEC, PROC
|
||||
0x24 string HP-UX
|
||||
>0 belong 1
|
||||
>>0xC belong 4
|
||||
>>>0x10 belong 1
|
||||
>>>>0x14 belong 2
|
||||
>>>>>0x20 belong 0x3C
|
||||
>>>>>>0x60 belong 0x100
|
||||
>>>>>>>0x6C belong 0x44
|
||||
>>>>>>>>0xB4 belong 4 core file
|
||||
>>>>>>>>>0xA4 string >\0 from '%s'
|
||||
>>>>>>>>>0xC4 belong 3 - received SIGQUIT
|
||||
>>>>>>>>>0xC4 belong 4 - received SIGILL
|
||||
>>>>>>>>>0xC4 belong 5 - received SIGTRAP
|
||||
>>>>>>>>>0xC4 belong 6 - received SIGABRT
|
||||
>>>>>>>>>0xC4 belong 7 - received SIGEMT
|
||||
>>>>>>>>>0xC4 belong 8 - received SIGFPE
|
||||
>>>>>>>>>0xC4 belong 10 - received SIGBUS
|
||||
>>>>>>>>>0xC4 belong 11 - received SIGSEGV
|
||||
>>>>>>>>>0xC4 belong 12 - received SIGSYS
|
||||
>>>>>>>>>0xC4 belong 33 - received SIGXCPU
|
||||
>>>>>>>>>0xC4 belong 34 - received SIGXFSZ
|
||||
# Order 4: EXEC, KERNEL, FORMAT, PROC
|
||||
0x64 string HP-UX
|
||||
>0 belong 0x100
|
||||
>>0xC belong 0x44
|
||||
>>>0x54 belong 2
|
||||
>>>>0x60 belong 0x3C
|
||||
>>>>>0xA0 belong 1
|
||||
>>>>>>0xAC belong 4
|
||||
>>>>>>>0xB0 belong 1
|
||||
>>>>>>>>0xB4 belong 4 core file
|
||||
>>>>>>>>>0x44 string >\0 from '%s'
|
||||
>>>>>>>>>0xC4 belong 3 - received SIGQUIT
|
||||
>>>>>>>>>0xC4 belong 4 - received SIGILL
|
||||
>>>>>>>>>0xC4 belong 5 - received SIGTRAP
|
||||
>>>>>>>>>0xC4 belong 6 - received SIGABRT
|
||||
>>>>>>>>>0xC4 belong 7 - received SIGEMT
|
||||
>>>>>>>>>0xC4 belong 8 - received SIGFPE
|
||||
>>>>>>>>>0xC4 belong 10 - received SIGBUS
|
||||
>>>>>>>>>0xC4 belong 11 - received SIGSEGV
|
||||
>>>>>>>>>0xC4 belong 12 - received SIGSYS
|
||||
>>>>>>>>>0xC4 belong 33 - received SIGXCPU
|
||||
>>>>>>>>>0xC4 belong 34 - received SIGXFSZ
|
||||
# Order 5: FORMAT, EXEC, KERNEL, PROC
|
||||
0x78 string HP-UX
|
||||
>0 belong 1
|
||||
>>0xC belong 4
|
||||
>>>0x10 belong 1
|
||||
>>>>0x14 belong 0x100
|
||||
>>>>>0x20 belong 0x44
|
||||
>>>>>>0x68 belong 2
|
||||
>>>>>>>0x74 belong 0x3C
|
||||
>>>>>>>>0xB4 belong 4 core file
|
||||
>>>>>>>>>0x58 string >\0 from '%s'
|
||||
>>>>>>>>>0xC4 belong 3 - received SIGQUIT
|
||||
>>>>>>>>>0xC4 belong 4 - received SIGILL
|
||||
>>>>>>>>>0xC4 belong 5 - received SIGTRAP
|
||||
>>>>>>>>>0xC4 belong 6 - received SIGABRT
|
||||
>>>>>>>>>0xC4 belong 7 - received SIGEMT
|
||||
>>>>>>>>>0xC4 belong 8 - received SIGFPE
|
||||
>>>>>>>>>0xC4 belong 10 - received SIGBUS
|
||||
>>>>>>>>>0xC4 belong 11 - received SIGSEGV
|
||||
>>>>>>>>>0xC4 belong 12 - received SIGSYS
|
||||
>>>>>>>>>0xC4 belong 33 - received SIGXCPU
|
||||
>>>>>>>>>0xC4 belong 34 - received SIGXFSZ
|
||||
# Order 6: EXEC, FORMAT, KERNEL, PROC
|
||||
>0 belong 0x100
|
||||
>>0xC belong 0x44
|
||||
>>>0x54 belong 1
|
||||
>>>>0x60 belong 4
|
||||
>>>>>0x64 belong 1
|
||||
>>>>>>0x68 belong 2
|
||||
>>>>>>>0x74 belong 0x2C
|
||||
>>>>>>>>0xB4 belong 4 core file
|
||||
>>>>>>>>>0x44 string >\0 from '%s'
|
||||
>>>>>>>>>0xC4 belong 3 - received SIGQUIT
|
||||
>>>>>>>>>0xC4 belong 4 - received SIGILL
|
||||
>>>>>>>>>0xC4 belong 5 - received SIGTRAP
|
||||
>>>>>>>>>0xC4 belong 6 - received SIGABRT
|
||||
>>>>>>>>>0xC4 belong 7 - received SIGEMT
|
||||
>>>>>>>>>0xC4 belong 8 - received SIGFPE
|
||||
>>>>>>>>>0xC4 belong 10 - received SIGBUS
|
||||
>>>>>>>>>0xC4 belong 11 - received SIGSEGV
|
||||
>>>>>>>>>0xC4 belong 12 - received SIGSYS
|
||||
>>>>>>>>>0xC4 belong 33 - received SIGXCPU
|
||||
>>>>>>>>>0xC4 belong 34 - received SIGXFSZ
|
||||
|
@ -162,19 +162,6 @@
|
||||
# Conflicts with other entries [BABYL]
|
||||
#0 string BA PC bitmap array data
|
||||
|
||||
# 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
|
||||
# HSI is Handmade Software's proprietary JPEG encoding scheme
|
||||
0 string hsi1 JPEG image data, HSI proprietary
|
||||
|
||||
# XPM icons (Greg Roelofs, newt@uchicago.edu)
|
||||
# note possible collision with C/REXX entry in c-lang; currently commented out
|
||||
0 string /*\ XPM\ */ X pixmap image text
|
||||
@ -274,3 +261,42 @@
|
||||
|
||||
# DICOM medical imaging data
|
||||
128 string DICM DICOM medical imaging data
|
||||
|
||||
# XWD - X-Windows Dump file.
|
||||
# As described in /usr/X11R6/include/X11/XWDFile.h
|
||||
# used by the xwd program.
|
||||
# Bradford Castalia, idaeim, 1/01
|
||||
4 belong 7 XWD X-Widows Dump image data
|
||||
>100 string >\0 \b, "%s"
|
||||
>16 belong x \b, %dx
|
||||
>20 belong x \b%dx
|
||||
>12 belong x \b%d
|
||||
|
||||
# PDS - Planetary Data System
|
||||
# These files use Parameter Value Language in the header section.
|
||||
# Unfortunately, there is no certain magic, but the following
|
||||
# strings have been found to be most likely.
|
||||
0 string NJPL1I00 PDS (JPL) image data
|
||||
2 string NJPL1I PDS (JPL) image data
|
||||
0 string CCSD3ZF PDS (CCSD) image data
|
||||
2 string CCSD3Z PDS (CCSD) image data
|
||||
0 string PDS_ PDS image data
|
||||
0 string LBLSIZE= PDS (VICAR) image data
|
||||
|
||||
0 string GSTIm GNU SmallTalk image file
|
||||
|
||||
# pM8x: ATARI STAD compressed bitmap format
|
||||
#
|
||||
# from Oskar Schirmer <schirmer@scara.com> Feb 2, 2001
|
||||
# p M 8 5/6 xx yy zz data...
|
||||
# Atari ST STAD bitmap is always 640x400, bytewise runlength compressed.
|
||||
# bytes either run horizontally (pM85) or vertically (pM86). yy is the
|
||||
# most frequent byte, xx and zz are runlength escape codes, where xx is
|
||||
# used for runs of yy.
|
||||
#
|
||||
0 string pM85 Atari ST STAD bitmap image data (hor)
|
||||
>5 byte 0x00 (white background)
|
||||
>5 byte 0xFF (black background)
|
||||
0 string pM86 Atari ST STAD bitmap image data (vert)
|
||||
>5 byte 0x00 (white background)
|
||||
>5 byte 0xFF (black background)
|
||||
|
@ -10,7 +10,6 @@
|
||||
#
|
||||
0 beshort 0xffd8 JPEG image data
|
||||
>6 string JFIF \b, JFIF standard
|
||||
|
||||
# The following added by Erik Rossen <rossen@freesurf.ch> 1999-09-06
|
||||
# in a vain attempt to add image size reporting for JFIF. Note that these
|
||||
# tests are not fool-proof since some perfectly valid JPEGs are currently
|
||||
@ -22,8 +21,8 @@
|
||||
>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
|
||||
>14 beshort x \b, %d x
|
||||
>16 beshort x \b %d
|
||||
#>4 beshort x \b, segment length %d
|
||||
# Next, show thumbnail info, if it exists:
|
||||
>18 byte !0 \b, thumbnail %dx
|
||||
|
@ -6,8 +6,9 @@
|
||||
0 string ;; Lisp/Scheme program text
|
||||
# Emacs 18 - this is always correct, but not very magical.
|
||||
0 string \012( byte-compiled Emacs-Lisp program data
|
||||
# Emacs 19
|
||||
0 string ;ELC\023\000\000\000 byte-compiled Emacs-Lisp program data
|
||||
# Emacs 19+ - ver. recognition added by Ian Springer
|
||||
0 string ;ELC byte-compiled Emacs-Lisp program data,
|
||||
>4 byte >0 version %d
|
||||
#
|
||||
# Files produced by CLISP Common Lisp From: Bruno Haible <haible@ilog.fr>
|
||||
0 string (SYSTEM::VERSION\040' CLISP byte-compiled Lisp program text
|
||||
|
@ -3,3 +3,5 @@
|
||||
# magic: file(1) magic for magic files
|
||||
#
|
||||
0 string #\ Magic magic text file for file(1) cmd
|
||||
0 lelong 0xF11E041C magic binary file for file(1) cmd
|
||||
>4 lelong x (version %d)
|
||||
|
@ -224,12 +224,14 @@
|
||||
0 string \114\000\000\000\001\024\002\000\000\000\000\000\300\000\000\000\000\000\000\106 ms-Windows shortcut
|
||||
|
||||
#ico files
|
||||
0 string \000\000\001\000\001\000\040\040\020\000\000\000\000\000\350\002\000\000 Icon for ms-windows
|
||||
0 string \000\000\001\000\004\000\040\040\020\000\000\000\000\000\350\002 Icon for ms-windows
|
||||
0 string \102\101\050\000\000\000\056\000\000\000\000\000\000\000 Icon for ms-windows
|
||||
0 string \000\000\001\000\002\000\040\040\010\000\000\000\000\000\350\002 Icon for ms-windows
|
||||
0 string \000\000\001\000\006\000\020\020\020\000\000\000\000\000\050\001 Icon for ms-windows
|
||||
0 string \000\000\001\000\002\000\020\020\020\000\000\000\000\000\050\001 Icon for ms-windows
|
||||
0 string \000\000\001\000 ms-windows icon resource
|
||||
>4 byte 1 - 1 icon
|
||||
>4 byte >1 - %d icons
|
||||
>>6 byte >0 \b, %dx
|
||||
>>>7 byte >0 \b%d
|
||||
>>8 byte 0 \b, 256-colors
|
||||
>>8 byte >0 \b, %d-colors
|
||||
|
||||
|
||||
# True Type fonts currently misidentified as raw G3 data
|
||||
|
@ -223,9 +223,9 @@
|
||||
|
||||
0 belong&0377777777 043600413 NetBSD/arm32 demand paged
|
||||
>0 byte &0x80
|
||||
>>20 lelong <8192 shared library
|
||||
>>20 lelong =8192 dynamically linked executable
|
||||
>>20 lelong >8192 dynamically linked executable
|
||||
>>20 lelong <4096 shared library
|
||||
>>20 lelong =4096 dynamically linked executable
|
||||
>>20 lelong >4096 dynamically linked executable
|
||||
>0 byte ^0x80 executable
|
||||
>16 lelong >0 not stripped
|
||||
0 belong&0377777777 043600410 NetBSD/arm32 pure
|
||||
|
@ -1,6 +1,4 @@
|
||||
#
|
||||
# $NetBSD: os9,v 1.2 1997/01/09 20:19:04 tls Exp $
|
||||
#
|
||||
# Copyright (c) 1996 Ignatios Souvatzis. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
12
contrib/file/Magdir/parix
Normal file
12
contrib/file/Magdir/parix
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Parix COFF executables
|
||||
# From: Ignatios Souvatzis <ignatios@cs.uni-bonn.de>
|
||||
#
|
||||
0 beshort&0xfff 0xACE PARIX
|
||||
>0 byte&0xf0 0x80 T800
|
||||
>0 byte&0xf0 0x90 T9000
|
||||
>19 byte&0x02 0x02 executable
|
||||
>19 byte&0x02 0x00 object
|
||||
>19 byte&0x0c 0x00 not stripped
|
7
contrib/file/Magdir/tuxedo
Normal file
7
contrib/file/Magdir/tuxedo
Normal file
@ -0,0 +1,7 @@
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
# tuxedo: file(1) magic for BEA TUXEDO data files
|
||||
#
|
||||
# from Ian Springer <ispringer@hotmail.com>
|
||||
#
|
||||
0 string \0\0\1\236\0\0\0\0\0\0\0\0\0\0\0\0 BEA TUXEDO DES mask data
|
@ -6,7 +6,7 @@ bin_PROGRAMS = file
|
||||
data_DATA = magic magic.mime
|
||||
|
||||
MAGIC = @datadir@/magic
|
||||
CPPFLAGS = -DMAGIC='"$(MAGIC)"'
|
||||
CPPFLAGS = -DMAGIC='"$(MAGIC)"' -DQUICK
|
||||
|
||||
man_MANS = file.1 magic.4
|
||||
|
||||
|
@ -72,7 +72,7 @@ bin_PROGRAMS = file
|
||||
data_DATA = magic magic.mime
|
||||
|
||||
MAGIC = @datadir@/magic
|
||||
CPPFLAGS = -DMAGIC='"$(MAGIC)"'
|
||||
CPPFLAGS = -DMAGIC='"$(MAGIC)"' -DQUICK
|
||||
|
||||
man_MANS = file.1 magic.4
|
||||
|
||||
@ -119,7 +119,7 @@ missing mkinstalldirs
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
SOURCES = $(file_SOURCES)
|
||||
OBJECTS = $(file_OBJECTS)
|
||||
|
@ -1,5 +1,5 @@
|
||||
** README for file(1) Command **
|
||||
@(#) $Id: README,v 1.23 2000/08/05 18:25:29 christos Exp $
|
||||
@(#) $Id: README,v 1.24 2001/03/12 05:05:57 christos Exp $
|
||||
|
||||
This is Release 3.x of Ian Darwin's (copyright but distributable)
|
||||
file(1) command. This version is the standard "file" command for Linux,
|
||||
@ -89,3 +89,12 @@ Cres, # 810, Toronto, Ontario CANADA M8X 2W4. Phone: 416-239-4801 or
|
||||
800-387-2777. Email: mail@sq.com. Call for information on SGML editing
|
||||
and browsing, Unix text processing, and customised products on Unix,
|
||||
DOS and Mac.
|
||||
|
||||
From Kees Zeelenberg
|
||||
|
||||
File 3.33 is available from Simtelnet and its mirrors:
|
||||
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2apps/file333b.zip
|
||||
Documentation and sources are available from the same folder.
|
||||
File determines the file type of a given file. It is an implementation
|
||||
of the Unix file(1) command. It knows the 'magic number' of some 4000
|
||||
files.
|
||||
|
4
contrib/file/aclocal.m4
vendored
4
contrib/file/aclocal.m4
vendored
@ -1,4 +1,4 @@
|
||||
dnl aclocal.m4 generated automatically by aclocal 1.4a
|
||||
dnl aclocal.m4 generated automatically by aclocal 1.4
|
||||
|
||||
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
@ -101,8 +101,6 @@ dnl AM_INIT_AUTOMAKE(package,version, [no-define])
|
||||
|
||||
AC_DEFUN(AM_INIT_AUTOMAKE,
|
||||
[AC_REQUIRE([AC_PROG_INSTALL])
|
||||
dnl We require 2.13 because we rely on SHELL being computed by configure.
|
||||
AC_PREREQ([2.13])
|
||||
PACKAGE=[$1]
|
||||
AC_SUBST(PACKAGE)
|
||||
VERSION=[$2]
|
||||
|
@ -30,10 +30,15 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#ifdef QUICK
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$Id: apprentice.c,v 1.33 2000/08/05 17:36:47 christos Exp $")
|
||||
FILE_RCSID("@(#)$Id: apprentice.c,v 1.34 2001/03/11 20:29:16 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#define EATAB {while (isascii((unsigned char) *l) && \
|
||||
@ -52,27 +57,94 @@ FILE_RCSID("@(#)$Id: apprentice.c,v 1.33 2000/08/05 17:36:47 christos Exp $")
|
||||
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 int parse __P((struct magic **, uint32 *, char *, int));
|
||||
static void eatsize __P((char **));
|
||||
static int apprentice_1 __P((const char *, int));
|
||||
static int apprentice_file __P((struct magic **, uint32 *,
|
||||
const char *, int));
|
||||
#ifdef QUICK
|
||||
static void byteswap __P((struct magic *, uint32));
|
||||
static void bs1 __P((struct magic *));
|
||||
static uint16 swap2 __P((uint16));
|
||||
static uint32 swap4 __P((uint32));
|
||||
static char * mkdbname __P((const char *));
|
||||
static int apprentice_map __P((struct magic **, uint32 *,
|
||||
const char *, int));
|
||||
static int apprentice_compile __P((struct magic **, uint32 *,
|
||||
const char *, int));
|
||||
#endif
|
||||
|
||||
static int maxmagic = 0;
|
||||
|
||||
static int apprentice_1 __P((const char *, int));
|
||||
struct mlist mlist;
|
||||
|
||||
|
||||
/*
|
||||
* Handle one file.
|
||||
*/
|
||||
static int
|
||||
apprentice_1(fn, action)
|
||||
const char *fn;
|
||||
int action;
|
||||
{
|
||||
struct magic *magic = NULL;
|
||||
uint32 nmagic = 0;
|
||||
struct mlist *ml;
|
||||
int rv = -1;
|
||||
|
||||
#ifdef QUICK
|
||||
if (action == COMPILE) {
|
||||
rv = apprentice_file(&magic, &nmagic, fn, action);
|
||||
if (rv == 0)
|
||||
return apprentice_compile(&magic, &nmagic, fn, action);
|
||||
else
|
||||
return rv;
|
||||
}
|
||||
if ((rv = apprentice_map(&magic, &nmagic, fn, action)) != 0)
|
||||
(void)fprintf(stderr, "%s: Using regular magic file `%s'\n",
|
||||
progname, fn);
|
||||
#endif
|
||||
|
||||
if (rv != 0)
|
||||
rv = apprentice_file(&magic, &nmagic, fn, action);
|
||||
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
|
||||
if ((ml = malloc(sizeof(*ml))) == NULL) {
|
||||
(void) fprintf(stderr, "%s: Out of memory.\n", progname);
|
||||
if (action == CHECK)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (magic == NULL || nmagic == 0)
|
||||
return rv;
|
||||
|
||||
ml->magic = magic;
|
||||
ml->nmagic = nmagic;
|
||||
|
||||
mlist.prev->next = ml;
|
||||
ml->prev = mlist.prev;
|
||||
ml->next = &mlist;
|
||||
mlist.prev = ml;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
apprentice(fn, check)
|
||||
apprentice(fn, action)
|
||||
const char *fn; /* list of magic files */
|
||||
int check; /* non-zero? checking-only run. */
|
||||
int action;
|
||||
{
|
||||
char *p, *mfn;
|
||||
int file_err, errs = -1;
|
||||
|
||||
maxmagic = MAXMAGIS;
|
||||
magic = (struct magic *) calloc(sizeof(struct magic), maxmagic);
|
||||
mlist.next = mlist.prev = &mlist;
|
||||
mfn = malloc(strlen(fn)+1);
|
||||
if (magic == NULL || mfn == NULL) {
|
||||
if (mfn == NULL) {
|
||||
(void) fprintf(stderr, "%s: Out of memory.\n", progname);
|
||||
if (check)
|
||||
if (action == CHECK)
|
||||
return -1;
|
||||
else
|
||||
exit(1);
|
||||
@ -83,25 +155,30 @@ apprentice(fn, check)
|
||||
p = strchr(fn, PATHSEP);
|
||||
if (p)
|
||||
*p++ = '\0';
|
||||
file_err = apprentice_1(fn, check);
|
||||
file_err = apprentice_1(fn, action);
|
||||
if (file_err > errs)
|
||||
errs = file_err;
|
||||
fn = p;
|
||||
}
|
||||
if (errs == -1)
|
||||
(void) fprintf(stderr, "%s: couldn't find any magic files!\n",
|
||||
progname);
|
||||
if (!check && errs)
|
||||
progname);
|
||||
if (action == CHECK && errs)
|
||||
exit(1);
|
||||
|
||||
free(mfn);
|
||||
return errs;
|
||||
}
|
||||
|
||||
/*
|
||||
* parse from a file
|
||||
*/
|
||||
static int
|
||||
apprentice_1(fn, check)
|
||||
apprentice_file(magicp, nmagicp, fn, action)
|
||||
struct magic **magicp;
|
||||
uint32 *nmagicp;
|
||||
const char *fn; /* name of magic file */
|
||||
int check; /* non-zero? checking-only run. */
|
||||
int action;
|
||||
{
|
||||
static const char hdr[] =
|
||||
"cont\toffset\ttype\topcode\tmask\tvalue\tdesc";
|
||||
@ -110,7 +187,7 @@ apprentice_1(fn, check)
|
||||
int errs = 0;
|
||||
|
||||
f = fopen(fn, "r");
|
||||
if (f==NULL) {
|
||||
if (f == NULL) {
|
||||
if (errno != ENOENT)
|
||||
(void) fprintf(stderr,
|
||||
"%s: can't read magic file %s (%s)\n",
|
||||
@ -118,8 +195,16 @@ apprentice_1(fn, check)
|
||||
return -1;
|
||||
}
|
||||
|
||||
maxmagic = MAXMAGIS;
|
||||
*magicp = (struct magic *) calloc(sizeof(struct magic), maxmagic);
|
||||
if (*magicp == NULL) {
|
||||
(void) fprintf(stderr, "%s: Out of memory.\n", progname);
|
||||
if (action == CHECK)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* parse it */
|
||||
if (check) /* print silly verbose header for USG compat. */
|
||||
if (action == CHECK) /* print silly verbose header for USG compat. */
|
||||
(void) printf("%s\n", hdr);
|
||||
|
||||
for (lineno = 1;fgets(line, BUFSIZ, f) != NULL; lineno++) {
|
||||
@ -128,11 +213,16 @@ apprentice_1(fn, check)
|
||||
if (strlen(line) <= (unsigned)1) /* null line, garbage, etc */
|
||||
continue;
|
||||
line[strlen(line)-1] = '\0'; /* delete newline */
|
||||
if (parse(line, &nmagic, check) != 0)
|
||||
if (parse(magicp, nmagicp, line, action) != 0)
|
||||
errs = 1;
|
||||
}
|
||||
|
||||
(void) fclose(f);
|
||||
if (errs) {
|
||||
free(*magicp);
|
||||
*magicp = NULL;
|
||||
*nmagicp = 0;
|
||||
}
|
||||
return errs;
|
||||
}
|
||||
|
||||
@ -181,32 +271,35 @@ signextend(m, v)
|
||||
* parse one line from magic file, put into magic[index++] if valid
|
||||
*/
|
||||
static int
|
||||
parse(l, ndx, check)
|
||||
parse(magicp, nmagicp, l, action)
|
||||
struct magic **magicp;
|
||||
uint32 *nmagicp;
|
||||
char *l;
|
||||
int *ndx, check;
|
||||
int action;
|
||||
{
|
||||
int i = 0, nd = *ndx;
|
||||
int i = 0;
|
||||
struct magic *m;
|
||||
char *t, *s;
|
||||
|
||||
#define ALLOC_INCR 200
|
||||
if (nd+1 >= maxmagic){
|
||||
if (*nmagicp + 1 >= maxmagic){
|
||||
maxmagic += ALLOC_INCR;
|
||||
if ((m = (struct magic *) realloc(magic, sizeof(struct magic) *
|
||||
maxmagic)) == NULL) {
|
||||
if ((m = (struct magic *) realloc(*magicp,
|
||||
sizeof(struct magic) * maxmagic)) == NULL) {
|
||||
(void) fprintf(stderr, "%s: Out of memory.\n",
|
||||
progname);
|
||||
if (magic)
|
||||
free(magic);
|
||||
if (check)
|
||||
if (*magicp)
|
||||
free(*magicp);
|
||||
if (action == CHECK)
|
||||
return -1;
|
||||
else
|
||||
exit(1);
|
||||
}
|
||||
magic = m;
|
||||
memset(&magic[*ndx], 0, sizeof(struct magic) * ALLOC_INCR);
|
||||
*magicp = m;
|
||||
memset(&(*magicp)[*nmagicp], 0, sizeof(struct magic)
|
||||
* ALLOC_INCR);
|
||||
}
|
||||
m = &magic[*ndx];
|
||||
m = &(*magicp)[*nmagicp];
|
||||
m->flag = 0;
|
||||
m->cont_level = 0;
|
||||
|
||||
@ -231,8 +324,8 @@ parse(l, ndx, check)
|
||||
l = t;
|
||||
|
||||
if (m->flag & INDIR) {
|
||||
m->in.type = LONG;
|
||||
m->in.offset = 0;
|
||||
m->in_type = LONG;
|
||||
m->in_offset = 0;
|
||||
/*
|
||||
* read [.lbs][+-]nnnnn)
|
||||
*/
|
||||
@ -240,24 +333,24 @@ parse(l, ndx, check)
|
||||
l++;
|
||||
switch (*l) {
|
||||
case 'l':
|
||||
m->in.type = LELONG;
|
||||
m->in_type = LELONG;
|
||||
break;
|
||||
case 'L':
|
||||
m->in.type = BELONG;
|
||||
m->in_type = BELONG;
|
||||
break;
|
||||
case 'h':
|
||||
case 's':
|
||||
m->in.type = LESHORT;
|
||||
m->in_type = LESHORT;
|
||||
break;
|
||||
case 'H':
|
||||
case 'S':
|
||||
m->in.type = BESHORT;
|
||||
m->in_type = BESHORT;
|
||||
break;
|
||||
case 'c':
|
||||
case 'b':
|
||||
case 'C':
|
||||
case 'B':
|
||||
m->in.type = BYTE;
|
||||
m->in_type = BYTE;
|
||||
break;
|
||||
default:
|
||||
magwarn("indirect offset type %c invalid", *l);
|
||||
@ -268,8 +361,8 @@ parse(l, ndx, check)
|
||||
s = l;
|
||||
if (*l == '+' || *l == '-') l++;
|
||||
if (isdigit((unsigned char)*l)) {
|
||||
m->in.offset = strtoul(l, &t, 0);
|
||||
if (*s == '-') m->in.offset = - m->in.offset;
|
||||
m->in_offset = strtoul(l, &t, 0);
|
||||
if (*s == '-') m->in_offset = - m->in_offset;
|
||||
}
|
||||
else
|
||||
t = l;
|
||||
@ -430,10 +523,10 @@ parse(l, ndx, check)
|
||||
while ((m->desc[i++] = *l++) != '\0' && i<MAXDESC)
|
||||
/* NULLBODY */;
|
||||
|
||||
if (check) {
|
||||
if (action == CHECK) {
|
||||
mdump(m);
|
||||
}
|
||||
++(*ndx); /* make room for next */
|
||||
++(*nmagicp); /* make room for next */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -670,3 +763,200 @@ eatsize(p)
|
||||
|
||||
*p = l;
|
||||
}
|
||||
|
||||
#ifdef QUICK
|
||||
/*
|
||||
* handle an mmaped file.
|
||||
*/
|
||||
static int
|
||||
apprentice_map(magicp, nmagicp, fn, action)
|
||||
struct magic **magicp;
|
||||
uint32 *nmagicp;
|
||||
const char *fn;
|
||||
int action;
|
||||
{
|
||||
int fd;
|
||||
struct stat st;
|
||||
uint32 *ptr;
|
||||
uint32 version;
|
||||
int needsbyteswap;
|
||||
char *dbname = mkdbname(fn);
|
||||
|
||||
if ((fd = open(dbname, O_RDONLY)) == -1)
|
||||
return -1;
|
||||
|
||||
if (fstat(fd, &st) == -1) {
|
||||
(void)fprintf(stderr, "%s: Cannot stat `%s' (%s)\n",
|
||||
progname, dbname, strerror(errno));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((*magicp = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
|
||||
MAP_PRIVATE|MAP_FILE, fd, (off_t)0)) == MAP_FAILED) {
|
||||
(void)fprintf(stderr, "%s: Cannot map `%s' (%s)\n",
|
||||
progname, dbname, strerror(errno));
|
||||
goto error;
|
||||
}
|
||||
(void)close(fd);
|
||||
ptr = (uint32 *) *magicp;
|
||||
if (*ptr != MAGICNO) {
|
||||
if (swap4(*ptr) != MAGICNO) {
|
||||
(void)fprintf(stderr, "%s: Bad magic in `%s'\n",
|
||||
progname, dbname);
|
||||
goto error;
|
||||
}
|
||||
needsbyteswap = 1;
|
||||
} else
|
||||
needsbyteswap = 0;
|
||||
if (needsbyteswap)
|
||||
version = swap4(ptr[1]);
|
||||
else
|
||||
version = ptr[1];
|
||||
if (version != VERSIONNO) {
|
||||
(void)fprintf(stderr,
|
||||
"%s: version mismatch (%d != %d) in `%s'\n",
|
||||
progname, version, VERSION, dbname);
|
||||
goto error;
|
||||
}
|
||||
*nmagicp = (st.st_size / sizeof(struct magic)) - 1;
|
||||
(*magicp)++;
|
||||
if (needsbyteswap)
|
||||
byteswap(*magicp, *nmagicp);
|
||||
return 0;
|
||||
|
||||
error:
|
||||
if (fd != -1)
|
||||
(void)close(fd);
|
||||
if (*magicp)
|
||||
(void)munmap(*magicp, (size_t)st.st_size);
|
||||
else {
|
||||
*magicp = NULL;
|
||||
*nmagicp = 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* handle an mmaped file.
|
||||
*/
|
||||
static int
|
||||
apprentice_compile(magicp, nmagicp, fn, action)
|
||||
struct magic **magicp;
|
||||
uint32 *nmagicp;
|
||||
const char *fn;
|
||||
int action;
|
||||
{
|
||||
int fd;
|
||||
char *dbname = mkdbname(fn);
|
||||
static const uint32 ar[] = {
|
||||
MAGICNO, VERSIONNO
|
||||
};
|
||||
|
||||
if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) {
|
||||
(void)fprintf(stderr, "%s: Cannot open `%s' (%s)\n",
|
||||
progname, dbname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (write(fd, ar, sizeof(ar)) != sizeof(ar)) {
|
||||
(void)fprintf(stderr, "%s: error writing `%s' (%s)\n",
|
||||
progname, dbname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lseek(fd, sizeof(struct magic), SEEK_SET) != sizeof(struct magic)) {
|
||||
(void)fprintf(stderr, "%s: error seeking `%s' (%s)\n",
|
||||
progname, dbname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (write(fd, *magicp, sizeof(struct magic) * *nmagicp)
|
||||
!= sizeof(struct magic) * *nmagicp) {
|
||||
(void)fprintf(stderr, "%s: error writing `%s' (%s)\n",
|
||||
progname, dbname, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
(void)close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* make a dbname
|
||||
*/
|
||||
char *
|
||||
mkdbname(fn)
|
||||
const char *fn;
|
||||
{
|
||||
static const char ext[] = ".mgc";
|
||||
static char *buf = NULL;
|
||||
size_t len = strlen(fn) + sizeof(ext) + 1;
|
||||
if (buf == NULL)
|
||||
buf = malloc(len);
|
||||
else
|
||||
buf = realloc(buf, len);
|
||||
(void)strcpy(buf, fn);
|
||||
(void)strcat(buf, ext);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Byteswap an mmap'ed file if needed
|
||||
*/
|
||||
static void
|
||||
byteswap(magic, nmagic)
|
||||
struct magic *magic;
|
||||
uint32 nmagic;
|
||||
{
|
||||
uint32 i;
|
||||
for (i = 0; i < nmagic; i++)
|
||||
bs1(&magic[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
* swap a short
|
||||
*/
|
||||
static uint16
|
||||
swap2(sv)
|
||||
uint16 sv;
|
||||
{
|
||||
uint16 rv;
|
||||
uint8 *s = (uint8 *) &sv;
|
||||
uint8 *d = (uint8 *) &rv;
|
||||
d[0] = s[1];
|
||||
d[1] = s[0];
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* swap an int
|
||||
*/
|
||||
static uint32
|
||||
swap4(sv)
|
||||
uint32 sv;
|
||||
{
|
||||
uint32 rv;
|
||||
uint8 *s = (uint8 *) &sv;
|
||||
uint8 *d = (uint8 *) &rv;
|
||||
d[0] = s[3];
|
||||
d[1] = s[2];
|
||||
d[2] = s[1];
|
||||
d[3] = s[0];
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* byteswap a single magic entry
|
||||
*/
|
||||
static
|
||||
void bs1(m)
|
||||
struct magic *m;
|
||||
{
|
||||
m->cont_level = swap2(m->cont_level);
|
||||
m->offset = swap4(m->offset);
|
||||
m->in_offset = swap4(m->in_offset);
|
||||
if (m->type != STRING)
|
||||
m->value.l = swap4(m->value.l);
|
||||
m->mask = swap4(m->mask);
|
||||
}
|
||||
#endif
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include "patchlevel.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$Id: file.c,v 1.55 2000/08/05 19:00:12 christos Exp $")
|
||||
FILE_RCSID("@(#)$Id: file.c,v 1.56 2001/03/11 20:29:16 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
|
||||
@ -97,6 +97,7 @@ int lineno; /* line number in the magic file */
|
||||
|
||||
|
||||
static void unwrap __P((char *fn));
|
||||
static void usage __P((void));
|
||||
#if 0
|
||||
static int byteconv4 __P((int, int, int));
|
||||
static short byteconv2 __P((int, int, int));
|
||||
@ -113,7 +114,7 @@ main(argc, argv)
|
||||
char *argv[];
|
||||
{
|
||||
int c;
|
||||
int check = 0, didsomefiles = 0, errflg = 0, ret = 0, app = 0;
|
||||
int action = 0, didsomefiles = 0, errflg = 0, ret = 0, app = 0;
|
||||
char *mime;
|
||||
|
||||
#ifdef LC_CTYPE
|
||||
@ -128,21 +129,24 @@ main(argc, argv)
|
||||
if (!(magicfile = getenv("MAGIC")))
|
||||
magicfile = default_magicfile;
|
||||
|
||||
while ((c = getopt(argc, argv, "bcdf:ikm:nsvzL")) != EOF)
|
||||
while ((c = getopt(argc, argv, "bcdf:ikm:nsvzCL")) != EOF)
|
||||
switch (c) {
|
||||
case 'b':
|
||||
++bflag;
|
||||
break;
|
||||
case 'c':
|
||||
++check;
|
||||
action = CHECK;
|
||||
break;
|
||||
case 'C':
|
||||
action = COMPILE;
|
||||
break;
|
||||
case 'd':
|
||||
++debug;
|
||||
break;
|
||||
case 'f':
|
||||
if (!app) {
|
||||
ret = apprentice(magicfile, check);
|
||||
if (check)
|
||||
ret = apprentice(magicfile, action);
|
||||
if (action)
|
||||
exit(ret);
|
||||
app = 1;
|
||||
}
|
||||
@ -190,21 +194,19 @@ main(argc, argv)
|
||||
}
|
||||
|
||||
if (errflg) {
|
||||
(void) fprintf(stderr, USAGE, progname);
|
||||
exit(2);
|
||||
usage();
|
||||
}
|
||||
|
||||
if (!app) {
|
||||
ret = apprentice(magicfile, check);
|
||||
if (check)
|
||||
ret = apprentice(magicfile, action);
|
||||
if (action)
|
||||
exit(ret);
|
||||
app = 1;
|
||||
}
|
||||
|
||||
if (optind == argc) {
|
||||
if (!didsomefiles) {
|
||||
(void)fprintf(stderr, USAGE, progname);
|
||||
exit(2);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -451,3 +453,13 @@ tryit(buf, nb, zflag)
|
||||
ckfputs("data", stdout);
|
||||
return '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr, USAGE, progname);
|
||||
#ifdef QUICK
|
||||
(void)fprintf(stderr, "Usage: %s -C [-m magic]\n", progname);
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* file.h - definitions for file(1) program
|
||||
* @(#)$Id: file.h,v 1.34 2000/11/13 00:30:49 christos Exp $
|
||||
* @(#)$Id: file.h,v 1.35 2001/03/11 20:29:16 christos Exp $
|
||||
*
|
||||
* Copyright (c) Ian F. Darwin, 1987.
|
||||
* Written by Ian F. Darwin.
|
||||
@ -35,6 +35,10 @@
|
||||
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
typedef short int16;
|
||||
typedef unsigned short uint16;
|
||||
typedef char int8;
|
||||
typedef unsigned char uint8;
|
||||
|
||||
#ifndef HOWMANY
|
||||
# define HOWMANY 16384 /* how much of the file to look at */
|
||||
@ -43,20 +47,23 @@ typedef unsigned int uint32;
|
||||
#define MAXDESC 50 /* max leng of text description */
|
||||
#define MAXstring 32 /* max leng of "string" types */
|
||||
|
||||
#define MAGICNO 0xF11E041C
|
||||
#define VERSIONNO 1
|
||||
|
||||
#define CHECK 1
|
||||
#define COMPILE 2
|
||||
|
||||
struct magic {
|
||||
short flag;
|
||||
uint16 cont_level;/* level of ">" */
|
||||
uint8 nospflag; /* supress space character */
|
||||
uint8 flag;
|
||||
#define INDIR 1 /* if '>(...)' appears, */
|
||||
#define UNSIGNED 2 /* comparison is unsigned */
|
||||
#define ADD 4 /* if '>&' appears, */
|
||||
short cont_level; /* level of ">" */
|
||||
struct {
|
||||
unsigned char type; /* byte short long */
|
||||
int32 offset; /* offset from indirection */
|
||||
} in;
|
||||
int32 offset; /* offset to magic number */
|
||||
unsigned char reln; /* relation (0=eq, '>'=gt, etc) */
|
||||
unsigned char type; /* int, short, long or string. */
|
||||
char vallen; /* length of string value, if any */
|
||||
uint8 reln; /* relation (0=eq, '>'=gt, etc) */
|
||||
uint8 vallen; /* length of string value, if any */
|
||||
uint8 type; /* int, short, long or string. */
|
||||
uint8 in_type; /* type of indirrection */
|
||||
#define BYTE 1
|
||||
#define SHORT 2
|
||||
#define LONG 4
|
||||
@ -68,16 +75,17 @@ struct magic {
|
||||
#define LESHORT 10
|
||||
#define LELONG 11
|
||||
#define LEDATE 12
|
||||
int32 offset; /* offset to magic number */
|
||||
int32 in_offset; /* offset from indirection */
|
||||
union VALUETYPE {
|
||||
unsigned char b;
|
||||
unsigned short h;
|
||||
uint32 l;
|
||||
char s[MAXstring];
|
||||
unsigned char hs[2]; /* 2 bytes of a fixed-endian "short" */
|
||||
unsigned char hl[4]; /* 2 bytes of a fixed-endian "long" */
|
||||
unsigned char hl[4]; /* 4 bytes of a fixed-endian "long" */
|
||||
} value; /* either number or string */
|
||||
uint32 mask; /* mask before comparison with value */
|
||||
char nospflag; /* supress space character */
|
||||
char desc[MAXDESC]; /* description */
|
||||
};
|
||||
|
||||
@ -90,6 +98,13 @@ struct magic {
|
||||
#define CHAR_COMPACT_OPTIONAL_BLANK 'b'
|
||||
|
||||
|
||||
/* list of magic entries */
|
||||
struct mlist {
|
||||
struct magic *magic; /* array of magic entries */
|
||||
uint32 nmagic; /* number of entries in array */
|
||||
struct mlist *next, *prev;
|
||||
};
|
||||
|
||||
#include <stdio.h> /* Include that here, to make sure __P gets defined */
|
||||
#include <errno.h>
|
||||
|
||||
@ -125,9 +140,7 @@ extern char *progname; /* the program name */
|
||||
extern const char *magicfile; /* name of the magic file */
|
||||
extern int lineno; /* current line number in magic file */
|
||||
|
||||
extern struct magic *magic; /* array of magic entries */
|
||||
extern int nmagic; /* number of valid magic[]s */
|
||||
|
||||
extern struct mlist mlist; /* list of arrays of magic entries */
|
||||
|
||||
extern int debug; /* enable debugging? */
|
||||
extern int zflag; /* process compressed files? */
|
||||
|
@ -1,5 +1,5 @@
|
||||
.TH FILE __CSECTION__ "Copyright but distributable"
|
||||
.\" $Id: file.man,v 1.37 2000/08/07 20:08:55 christos Exp $
|
||||
.\" $Id: file.man,v 1.38 2001/03/11 20:37:08 christos Exp $
|
||||
.SH NAME
|
||||
file
|
||||
\- determine file type
|
||||
@ -15,6 +15,12 @@ namefile ]
|
||||
.B \-m
|
||||
magicfiles ]
|
||||
file ...
|
||||
.br
|
||||
.B file
|
||||
.B -C
|
||||
[
|
||||
.B \-m
|
||||
magicfile ]
|
||||
.SH DESCRIPTION
|
||||
This manual page documents version __VERSION__ of the
|
||||
.B file
|
||||
@ -85,8 +91,12 @@ that the file is a binary executable, and which of several types thereof.
|
||||
The concept of `magic number' has been applied by extension to data files.
|
||||
Any file with some invariant identifier at a small fixed
|
||||
offset into the file can usually be described in this way.
|
||||
The information identifying these files is read from the magic file
|
||||
.I __MAGIC__.
|
||||
The information identifying these files is read from the compiled
|
||||
magic file
|
||||
.I __MAGIC__.mgc ,
|
||||
or
|
||||
.I __MAGIC__
|
||||
if the compile file does not exist.
|
||||
.PP
|
||||
If a file does not match any of the entries in the magic file,
|
||||
it is examined to see if it seems to be a text file.
|
||||
@ -142,6 +152,9 @@ Do not prepend filenames to output lines (brief mode).
|
||||
.B \-c
|
||||
Cause a checking printout of the parsed form of the magic file.
|
||||
This is usually used in conjunction with
|
||||
.B \-C
|
||||
Write a magic.mgc output file that contains a pre-parsed version of
|
||||
file.
|
||||
.B \-m
|
||||
to debug a new magic file before installing it.
|
||||
.TP 8
|
||||
@ -210,6 +223,9 @@ to disregard the file size as reported by
|
||||
.BR stat (2)
|
||||
since on some systems it reports a zero size for raw disk partitions.
|
||||
.SH FILES
|
||||
.I __MAGIC__.mgc
|
||||
\- defaults compiled list of magic numbers
|
||||
.PP
|
||||
.I __MAGIC__
|
||||
\- default list of magic numbers
|
||||
.PP
|
||||
|
@ -89,6 +89,7 @@
|
||||
0 string RIFF audio/unknown
|
||||
# - WAVE format
|
||||
>8 string WAVE audio/x-wav
|
||||
>8 string AVI video/x-msvideo
|
||||
#
|
||||
0 belong 0x2e7261fd application/x-realaudio
|
||||
|
||||
@ -104,6 +105,9 @@
|
||||
# ideally should go into "images", but entries below would tag XPM as C source
|
||||
0 string /*\ XPM image/x-xpm 7bit
|
||||
|
||||
# 3DS (3d Studio files)
|
||||
16 beshort 0x3d3d image/x-3ds
|
||||
|
||||
# this first will upset you if you're a PL/1 shop... (are there any left?)
|
||||
# in which case rm it; ascmagic will catch real C programs
|
||||
# C or REXX program text
|
||||
@ -463,7 +467,8 @@
|
||||
#
|
||||
# animation formats, originally from vax@ccwf.cc.utexas.edu (VaX#n8)
|
||||
# MPEG file
|
||||
0 string \000\000\001\263 video/mpeg
|
||||
0 belong 0x000001b3 video/mpeg
|
||||
0 belong 0x000001ba video/mpeg
|
||||
# FLI animation format
|
||||
0 leshort 0xAF11 video/fli
|
||||
# FLC animation format
|
||||
|
@ -1,11 +1,15 @@
|
||||
#define FILE_VERSION_MAJOR 3
|
||||
#define patchlevel 33
|
||||
#define patchlevel 34
|
||||
|
||||
/*
|
||||
* Patchlevel file for Ian Darwin's MAGIC command.
|
||||
* $Id: patchlevel.h,v 1.33 2000/11/13 00:30:50 christos Exp $
|
||||
* $Id: patchlevel.h,v 1.34 2001/03/12 05:05:57 christos Exp $
|
||||
*
|
||||
* $Log: patchlevel.h,v $
|
||||
* 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
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$Id: print.c,v 1.31 2000/08/05 17:36:49 christos Exp $")
|
||||
FILE_RCSID("@(#)$Id: print.c,v 1.32 2001/03/11 20:29:16 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
|
||||
@ -61,9 +61,9 @@ mdump(m)
|
||||
if (m->flag & INDIR)
|
||||
(void) fprintf(stderr, "(%s,%d),",
|
||||
/* Note: in.type is unsigned */
|
||||
(m->in.type < SZOF(typ)) ?
|
||||
typ[m->in.type] : "*bad*",
|
||||
m->in.offset);
|
||||
(m->in_type < SZOF(typ)) ?
|
||||
typ[m->in_type] : "*bad*",
|
||||
m->in_offset);
|
||||
|
||||
(void) fprintf(stderr, " %s%s", (m->flag & UNSIGNED) ? "u" : "",
|
||||
/* Note: type is unsigned */
|
||||
|
@ -35,10 +35,10 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$Id: softmagic.c,v 1.42 2000/08/05 17:36:49 christos Exp $")
|
||||
FILE_RCSID("@(#)$Id: softmagic.c,v 1.43 2001/03/11 20:29:16 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
static int match __P((unsigned char *, int));
|
||||
static int match __P((struct magic *, uint32, unsigned char *, int));
|
||||
static int mget __P((union VALUETYPE *,
|
||||
unsigned char *, struct magic *, int));
|
||||
static int mcheck __P((union VALUETYPE *, struct magic *));
|
||||
@ -57,8 +57,11 @@ softmagic(buf, nbytes)
|
||||
unsigned char *buf;
|
||||
int nbytes;
|
||||
{
|
||||
if (match(buf, nbytes))
|
||||
return 1;
|
||||
struct mlist *ml;
|
||||
|
||||
for (ml = mlist.next; ml != &mlist; ml = ml->next)
|
||||
if (match(ml->magic, ml->nmagic, buf, nbytes))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -91,7 +94,9 @@ softmagic(buf, nbytes)
|
||||
* so that higher-level continuations are processed.
|
||||
*/
|
||||
static int
|
||||
match(s, nbytes)
|
||||
match(magic, nmagic, s, nbytes)
|
||||
struct magic *magic;
|
||||
uint32 nmagic;
|
||||
unsigned char *s;
|
||||
int nbytes;
|
||||
{
|
||||
@ -105,6 +110,7 @@ match(s, nbytes)
|
||||
int returnval = 0; /* if a match is found it is set to 1*/
|
||||
extern int kflag;
|
||||
int firstline = 1; /* a flag to print X\n X\n- X */
|
||||
struct mlist *ml;
|
||||
|
||||
if (tmpoff == NULL)
|
||||
if ((tmpoff = (int32 *) malloc(tmplen = 20)) == NULL)
|
||||
@ -153,7 +159,8 @@ match(s, nbytes)
|
||||
}
|
||||
if (magic[magindex].flag & ADD) {
|
||||
oldoff=magic[magindex].offset;
|
||||
magic[magindex].offset += tmpoff[cont_level-1];
|
||||
magic[magindex].offset +=
|
||||
tmpoff[cont_level-1];
|
||||
}
|
||||
if (mget(&p, s, &magic[magindex], nbytes) &&
|
||||
mcheck(&p, &magic[magindex])) {
|
||||
@ -172,7 +179,8 @@ match(s, nbytes)
|
||||
(void) putchar(' ');
|
||||
need_separator = 0;
|
||||
}
|
||||
tmpoff[cont_level] = mprint(&p, &magic[magindex]);
|
||||
tmpoff[cont_level] =
|
||||
mprint(&p, &magic[magindex]);
|
||||
if (magic[magindex].desc[0])
|
||||
need_separator = 1;
|
||||
|
||||
@ -361,33 +369,33 @@ mget(p, s, m, nbytes)
|
||||
|
||||
if (m->flag & INDIR) {
|
||||
|
||||
switch (m->in.type) {
|
||||
switch (m->in_type) {
|
||||
case BYTE:
|
||||
offset = p->b + m->in.offset;
|
||||
offset = p->b + m->in_offset;
|
||||
break;
|
||||
case BESHORT:
|
||||
offset = (short)((p->hs[0]<<8)|(p->hs[1]))+
|
||||
m->in.offset;
|
||||
m->in_offset;
|
||||
break;
|
||||
case LESHORT:
|
||||
offset = (short)((p->hs[1]<<8)|(p->hs[0]))+
|
||||
m->in.offset;
|
||||
m->in_offset;
|
||||
break;
|
||||
case SHORT:
|
||||
offset = p->h + m->in.offset;
|
||||
offset = p->h + m->in_offset;
|
||||
break;
|
||||
case BELONG:
|
||||
offset = (int32)((p->hl[0]<<24)|(p->hl[1]<<16)|
|
||||
(p->hl[2]<<8)|(p->hl[3]))+
|
||||
m->in.offset;
|
||||
m->in_offset;
|
||||
break;
|
||||
case LELONG:
|
||||
offset = (int32)((p->hl[3]<<24)|(p->hl[2]<<16)|
|
||||
(p->hl[1]<<8)|(p->hl[0]))+
|
||||
m->in.offset;
|
||||
m->in_offset;
|
||||
break;
|
||||
case LONG:
|
||||
offset = p->l + m->in.offset;
|
||||
offset = p->l + m->in_offset;
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user