.TH FILE __CSECTION__ "Copyright but distributable"
-.\" $Id: file.man,v 1.31 1998/02/15 23:18:53 christos Exp $
+.\" $Id: file.man,v 1.32 1999/01/14 15:54:00 christos Exp $
.SH NAME
file
\- determine file type
.SH SYNOPSIS
.B file
[
-.B \-vbczL
+.B \-bcnvzL
]
[
.B \-f
labelled as `ascii text' or `data'.
.SH OPTIONS
.TP 8
-.B \-v
-Print the version of the program and exit.
-.TP 8
-.B \-m list
-Specify an alternate list of files containing magic numbers.
-This can be a single file, or a colon-separated list of files.
-.TP 8
-.B \-z
-Try to look inside compressed files.
-.TP 8
.B \-b
Do not prepend filenames to output lines (brief mode).
.TP 8
or at least one filename argument must be present;
to test the standard input, use ``-'' as a filename argument.
.TP 8
+.B \-m list
+Specify an alternate list of files containing magic numbers.
+This can be a single file, or a colon-separated list of files.
+.TP 8
+.B \-n
+Force stdout to be flushed after check a file. This is only useful if
+checking a list of files. It is intended to be used by programs want
+filetype output from a pipe.
+.TP 8
+.B \-v
+Print the version of the program and exit.
+.TP 8
+.B \-z
+Try to look inside compressed files.
+.TP 8
.B \-L
option causes symlinks to be followed, as the like-named option in
.BR ls (1).
#
0 string FiLeStArTfIlEsTaRt binscii (apple ][) text
0 string \x0aGL Binary II (apple ][) data
-0 string \x76\xff Squeezed (apple ][) data
0 string NuFile NuFile archive (apple ][) data
0 string N\xf5F\xe9l\xe5 NuFile archive (apple ][) data
0 belong 0x00051600 AppleSingle encoded Macintosh file
# Shell archives
10 string #\ This\ is\ a\ shell\ archive shell archive text
+
+#
+# LBR. NB: May conflict with the questionable
+# "binary Computer Graphics Metafile" format.
+#
+0 string \0\ \ \ \ \ \ \ \ \ \ \ \0\0 LBR archive data
+#
+# PMA (CP/M derivative of LHA)
+#
+2 string -pm0- PMarc archive data [pm0]
+2 string -pm1- PMarc archive data [pm1]
+2 string -pm2- PMarc archive data [pm2]
+2 string -pms- PMarc SFX archive (CP/M, DOS)
+5 string -pc1- PopCom compressed executable (CP/M)
# squeeze and crunch
# Michael Haardt <michael@cantor.informatik.rwth-aachen.de>
-0 leshort 0xFF76 squeezed data,
+0 beshort 0x76FF squeezed data,
>4 string x original name %s
-0 leshort 0xFE76 crunched data,
+0 beshort 0x76FE crunched data,
>2 string x original name %s
-0 leshort 0xFD76 LZH compressed data,
+0 beshort 0x76FD LZH compressed data,
>2 string x original name %s
# Freeze
# addendum to /etc/magic with HP-48sx file-types by phk@data.fls.dk 1jan92
0 string HPHP48- HP48 binary
>7 byte >0 - Rev %c
->8 short 0x1129 (ADR)
->8 short 0x3329 (REAL)
->8 short 0x5529 (LREAL)
->8 short 0x7729 (COMPLX)
->8 short 0x9d29 (LCOMPLX)
->8 short 0xbf29 (CHAR)
->8 short 0xe829 (ARRAY)
->8 short 0x0a2a (LNKARRAY)
->8 short 0x2c2a (STRING)
->8 short 0x4e2a (HXS)
->8 short 0x742a (LIST)
->8 short 0x962a (DIR)
->8 short 0xb82a (ALG)
->8 short 0xda2a (UNIT)
->8 short 0xfc2a (TAGGED)
->8 short 0x1e2b (GROB)
->8 short 0x402b (LIB)
->8 short 0x622b (BACKUP)
->8 short 0x882b (LIBDATA)
->8 short 0x9d2d (PROG)
->8 short 0xcc2d (CODE)
->8 short 0x482e (GNAME)
->8 short 0x6d2e (LNAME)
->8 short 0x922e (XLIB)
+>8 beshort 0x1129 (ADR)
+>8 beshort 0x3329 (REAL)
+>8 beshort 0x5529 (LREAL)
+>8 beshort 0x7729 (COMPLX)
+>8 beshort 0x9d29 (LCOMPLX)
+>8 beshort 0xbf29 (CHAR)
+>8 beshort 0xe829 (ARRAY)
+>8 beshort 0x0a2a (LNKARRAY)
+>8 beshort 0x2c2a (STRING)
+>8 beshort 0x4e2a (HXS)
+>8 beshort 0x742a (LIST)
+>8 beshort 0x962a (DIR)
+>8 beshort 0xb82a (ALG)
+>8 beshort 0xda2a (UNIT)
+>8 beshort 0xfc2a (TAGGED)
+>8 beshort 0x1e2b (GROB)
+>8 beshort 0x402b (LIB)
+>8 beshort 0x622b (BACKUP)
+>8 beshort 0x882b (LIBDATA)
+>8 beshort 0x9d2d (PROG)
+>8 beshort 0xcc2d (CODE)
+>8 beshort 0x482e (GNAME)
+>8 beshort 0x6d2e (LNAME)
+>8 beshort 0x922e (XLIB)
0 string %%HP: HP48 text
>6 string T(0) - T(0)
>6 string T(1) - T(1)
>4 string >\ (FTP) <ftp:%s>
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
#------------------------------------------------------------------------------
-# sniffer: file(1) magic for packet captured files
+# sniffer: file(1) magic for packet capture files
#
# From: guy@netapp.com (Guy Harris)
#
-# Microsoft NetMon (packet capture/display program) capture files.
+# Microsoft Network Monitor capture files.
#
0 string RTSS NetMon capture file
>4 byte x - version %d
#
# Network General Sniffer capture files.
+# Sorry, make that "Network Associates Sniffer capture files."
#
0 string TRSNIFF\ data\ \ \ \ \032 Sniffer capture file
+>33 byte 2 (compressed)
>23 leshort x - version %d
>25 leshort x \b.%d
->33 byte x (Format %d,
->32 byte 0 Token ring)
->32 byte 1 Ethernet)
->32 byte 2 ARCNET)
->32 byte 3 StarLAN)
->32 byte 4 PC Network broadband)
->32 byte 5 LocalTalk)
->32 byte 6 Znet)
+>32 byte 0 (Token Ring)
+>32 byte 1 (Ethernet)
+>32 byte 2 (ARCNET)
+>32 byte 3 (StarLAN)
+>32 byte 4 (PC Network broadband)
+>32 byte 5 (LocalTalk)
+>32 byte 6 (Znet)
+>32 byte 7 (Internetwork Analyzer)
+>32 byte 9 (FDDI)
+>32 byte 10 (ATM)
#
# Cinco Networks NetXRay capture files.
+# Sorry, make that "Network General Sniffer Basic capture files."
+# Sorry, make that "Network Associates Sniffer Basic capture files."
#
0 string XCP\0 NetXRay capture file
>4 string >\0 - version %s
#
# "libpcap" capture files.
# (We call them "tcpdump capture file(s)" for now, as "tcpdump" is
-# the main program that uses that format, but there's also "tcpview",
-# and there may be others in the future.)
+# the main program that uses that format, but there are other programs
+# that use "libpcap", or that use the same capture file format.)
#
0 ubelong 0xa1b2c3d4 tcpdump capture file (big-endian)
>4 beshort x - version %d
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: file.c,v 1.43 1999/01/13 15:44:03 christos Exp $")
+FILE_RCSID("@(#)$Id: file.c,v 1.44 1999/01/14 15:53:59 christos Exp $")
#endif /* lint */
debug = 0, /* debugging */
lflag = 0, /* follow Symlinks (BSD only) */
bflag = 0, /* brief output format */
- zflag = 0; /* follow (uncompress) compressed files */
-
+ zflag = 0, /* follow (uncompress) compressed files */
+ nobuffer = 0; /* Do not buffer stdout */
int /* Misc globals */
nmagic = 0; /* number of valid magic[]s */
if (!(magicfile = getenv("MAGIC")))
magicfile = MAGIC;
- while ((c = getopt(argc, argv, "vbcdf:Lm:z")) != EOF)
+ while ((c = getopt(argc, argv, "vbcndf:Lm:z")) != EOF)
switch (c) {
case 'v':
(void) fprintf(stdout, "%s-%d.%d\n", progname,
case 'c':
++check;
break;
+ case 'n':
+ ++nobuffer;
+ break;
case 'd':
++debug;
break;
while (fgets(buf, MAXPATHLEN, f) != NULL) {
buf[strlen(buf)-1] = '\0';
process(buf, wid);
+ if(nobuffer)
+ (void) fflush(stdout);
}
(void) fclose(f);