]> granicus.if.org Git - file/commitdiff
Mostly magic fixes. and -n option.
authorChristos Zoulas <christos@zoulas.com>
Thu, 14 Jan 1999 15:53:59 +0000 (15:53 +0000)
committerChristos Zoulas <christos@zoulas.com>
Thu, 14 Jan 1999 15:53:59 +0000 (15:53 +0000)
doc/file.man
magic/Magdir/apple
magic/Magdir/archive
magic/Magdir/compress
magic/Magdir/hp
magic/Magdir/os2
magic/Magdir/sniffer
src/file.c

index e384a27891761dfa42f91b2013c0a4ff1613bd74..c7458e016dbbb073edd5d6a76ae53e37641b4a3c 100644 (file)
@@ -1,12 +1,12 @@
 .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
@@ -105,16 +105,6 @@ archives) and determine whether an unknown file should be
 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
@@ -134,6 +124,21 @@ Either
 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).
index 20231293fe627c5fd6f940d483c323dea3ff586d..1d157f77fd67ac0fede1fc33241ee2aa4bffa18c 100644 (file)
@@ -4,7 +4,6 @@
 #
 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
index 30f0b4840ee99c0dc854c11c265da205db56c996..1b1caf6966e25b662e0f907dcbc41266da683dcb 100644 (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)
index dbc25a798791c02c92bc06fcb9e093bd22d320ff..e0e23c8948ae9a38af9f495d70b723bfa3cf369d 100644 (file)
 
 # 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
index ffcd232cf3eda0e7671e6924d0d3580ebb9f38b5..76c0f0409a67cfc3dfdfc71fa17f8ab6f263660b 100644 (file)
 # 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)
index 91ea9e23df71b96aa416c4e1505e6db2b6e98a81..7ae67c7c458536b1bd89373433443f037ee7902c 100644 (file)
 >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
index 94b55a096e4c174fd028df35cd2980bc280ef31a..0b420c1c8fb8f84261c2d9d46c78a976120f6a2f 100644 (file)
@@ -1,10 +1,10 @@
 
 #------------------------------------------------------------------------------
-# 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
index 1347549fef79967846b523afb2670162db56f39d..40c6cbedf0a89148c325d87fcb33040ee3caaf4c 100644 (file)
@@ -50,7 +50,7 @@
 #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 */
 
 
@@ -68,8 +68,8 @@ int                   /* Global command-line options          */
        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             */
 
@@ -108,7 +108,7 @@ main(argc, argv)
        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,
@@ -120,6 +120,9 @@ main(argc, argv)
                case 'c':
                        ++check;
                        break;
+               case 'n':
+                       ++nobuffer;
+                       break;
                case 'd':
                        ++debug;
                        break;
@@ -215,6 +218,8 @@ char *fn;
        while (fgets(buf, MAXPATHLEN, f) != NULL) {
                buf[strlen(buf)-1] = '\0';
                process(buf, wid);
+               if(nobuffer)
+                       (void) fflush(stdout);
        }
 
        (void) fclose(f);