]> granicus.if.org Git - file/commitdiff
Added CSECTION for the file man page
authorChristos Zoulas <christos@zoulas.com>
Sat, 21 Jan 1995 21:03:35 +0000 (21:03 +0000)
committerChristos Zoulas <christos@zoulas.com>
Sat, 21 Jan 1995 21:03:35 +0000 (21:03 +0000)
Added version flag -v
Fixed bug with -f input flag (from iorio@violet.berkeley.edu)
Lots of magic fixes and reorganization...

doc/file.man
doc/magic.man
src/Makefile
src/file.c
src/fsmagic.c
src/patchlevel.h

index c10b221c26ca2b678eeb176de14625cabaad19fd..51aa64351445908fa623f4c2d961fcf98db09031 100644 (file)
@@ -1,18 +1,12 @@
-.TH FILE 1 "Copyright but distributable"
-.\# $Id: file.man,v 1.23 1993/09/24 18:50:48 christos Exp $
+.TH FILE __CSECTION__ "Copyright but distributable"
+.\" $Id: file.man,v 1.24 1995/01/21 21:03:35 christos Exp $
 .SH NAME
-.I file
+file
 \- determine file type
 .SH SYNOPSIS
 .B file
 [
-.B \-c
-]
-[
-.B \-z
-]
-[
-.B \-L
+.B \-vczL
 ]
 [
 .B \-f
@@ -101,44 +95,42 @@ The language test routines also test for some miscellany
 .I tar
 archives) and determine whether an unknown file should be
 labelled as `ascii text' or `data'. 
-.PP
-Use
-.B \-m
-.I file
-to specify an alternate file of magic numbers.
-.PP
-The
+.SH OPTIONS
+.TP 8
+.B \-v
+Print the version of the program and exit.
+.TP 8
+.B \-m file
+Specify an alternate file of magic numbers.
+.TP 8
 .B \-z
-tries to look inside compressed files.
-.PP
-The
+Try to look inside compressed files.
+.TP 8
 .B \-c
-option causes a checking printout of the parsed form of the magic file.
+Cause a checking printout of the parsed form of the magic file.
 This is usually used in conjunction with 
 .B \-m
 to debug a new magic file before installing it.
-.PP
-The 
-.B \-f
-.I namefile
-option specifies that the names of the files to be examined
-are to be read (one per line) from 
+.TP 8
+.B \-f namefile
+Read the names of the files to be examined from 
 .I namefile
+(one per line) 
 before the argument list.
 Either 
 .I namefile
 or at least one filename argument must be present;
 to test the standard input, use ``-'' as a filename argument.
-.PP
-The 
+.TP 8
 .B \-L
 option causes symlinks to be followed, as the like-named option in
 .IR ls (1).
+(on systems that support symbolic links).
 .SH FILES
 .I __MAGIC__
 \- default list of magic numbers
 .SH SEE ALSO
-.IR magic (__SECTION__)
+.IR magic (__FSECTION__)
 \- description of magic file format.
 .br
 .IR Strings (1), " od" (1)
index 7c2788e9b434e0cb94c299c93b87e33d97c8457e..2ae8e69996a4d13fd6cc46c77f964fc8da642382 100644 (file)
@@ -1,10 +1,10 @@
-.TH MAGIC __SECTION__ "Public Domain"
+.TH MAGIC __FSECTION__ "Public Domain"
 .\" install as magic.4 on USG, magic.5 on V7 or Berkeley systems.
 .SH NAME
 magic \- file command's magic number file
 .SH DESCRIPTION
 The
-.IR file (1)
+.IR file (__CSECTION__)
 command identifies the type of a file using,
 among other tests,
 a test for whether the file begins with a certain
@@ -79,10 +79,13 @@ value,
 .BR & ,
 to specify that the value from the file must have set all of the bits 
 that are set in the specified value,
-or
 .BR ^ ,
 to specify that the value from the file must have clear any of the bits 
-that are set in the specified value.
+that are set in the specified value, or
+.BR x ,
+to specify that any value will match. If the character is omitted,
+it is assumed to be
+.BR = .
 .IP
 Numeric values are specified in C form; e.g.
 .B 13
@@ -91,9 +94,6 @@ is decimal,
 is octal, and
 .B 0x13
 is hexadecimal.
-to specify that any value will match.  If the character
-is omitted, it is assumed to be
-.BR = .
 .IP
 For string values, the byte string from the
 file must match the specified byte string. 
@@ -143,7 +143,7 @@ If the first character following the last
 is a
 .B (
 then the string after the parenthesis is interpreted as an indirect offset.
-That means that the number after the parenthesis is used as a offset in
+That means that the number after the parenthesis is used as an offset in
 the file. The value at that offset is read, and is used again as an offset
 in the file. Indirect offsets are of the form:
 .BI (( x [.[bsl]][+-][ y ]).
@@ -168,7 +168,7 @@ The formats
 .IR bedate ,
 and
 .I ledate
-are system-dependant; perhaps they should be specified as a number
+are system-dependent; perhaps they should be specified as a number
 of bytes (2B, 4B, etc), 
 since the files being recognized typically come from
 a system on which the lengths are invariant.
@@ -176,7 +176,7 @@ a system on which the lengths are invariant.
 There is (currently) no support for specified-endian data to be used in
 indirect offsets.
 .SH SEE ALSO
-.IR file (1)
+.IR file (__CSECTION__)
 \- the command that reads this file.
 .\"
 .\" From: guy@sun.uucp (Guy Harris)
@@ -191,4 +191,4 @@ indirect offsets.
 .\" the changes I posted to the S5R2 version.
 .\"
 .\" Modified for Ian Darwin's version of the file command.
-.\" @(#)$Id: magic.man,v 1.11 1994/05/03 17:58:23 christos Exp $
+.\" @(#)$Id: magic.man,v 1.12 1995/01/21 21:03:35 christos Exp $
index d59f490fe23704ca02f18c10df52e8633e9d83bf..ffaad646eb3aed2876ffb83188d9688faad70247 100644 (file)
@@ -1,6 +1,6 @@
 # Makefile for file(1) cmd. 
 # Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE.
-# @(#)$Id: Makefile,v 1.43 1994/05/03 17:57:59 christos Exp $
+# @(#)$Id: Makefile,v 1.44 1995/01/21 21:03:35 christos Exp $
 #
 # This software is not subject to any license of the American Telephone
 # and Telegraph Company or of the Regents of the University of California.
@@ -91,7 +91,7 @@ try:          all $(OFILE)
                what ./file >lastnocore
 
 file:          $(OBJS)
-               $(CC) $(CFLAGS) $(OBJS) -o $@
+               $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
 lint:          $(SRCS)
                lint -ha $(DEFS) $(SRCS) | tee $@
 magic:         Magdir
@@ -119,12 +119,14 @@ clobber:
 
 magic.${MANFEXT} :     Makefile magic.man
                @rm -f $@
-               sed -e s@__SECTION__@${MANFEXT}@g \
+               sed -e s@__CSECTION__@${MANCEXT}@g \
+                   -e s@__FSECTION__@${MANFEXT}@g \
                    -e s@__MAGIC__@${MAGIC}@g magic.man > $@
 
 file.${MANCEXT} :      Makefile file.man
                @rm -f $@
-               sed -e s@__SECTION__@${MANCEXT}@g \
+               sed -e s@__CSECTION__@${MANCEXT}@g \
+                   -e s@__FSECTION__@${MANFEXT}@g \
                    -e s@__MAGIC__@${MAGIC}@g file.man > $@
 
 send:          dist
index a8acdd436b9e3ae12ea6cad1bf660eaea7136190..4fafe9a6dadeacea5967863ada7e086cd43deea0 100644 (file)
@@ -26,7 +26,7 @@
  */
 #ifndef        lint
 static char *moduleid = 
-       "@(#)$Id: file.c,v 1.29 1993/10/27 20:59:05 christos Exp $";
+       "@(#)$Id: file.c,v 1.30 1995/01/21 21:03:35 christos Exp $";
 #endif /* lint */
 
 #include <stdio.h>
@@ -36,15 +36,20 @@ static char *moduleid =
 #include <sys/param.h> /* for MAXPATHLEN */
 #include <sys/stat.h>
 #include <fcntl.h>     /* for open() */
+#if (__COHERENT__ >= 0x420)
+#include <sys/utime.h>
+#else
 #include <utime.h>
+#endif
 #include <unistd.h>    /* for read() */
 
+#include "patchlevel.h"
 #include "file.h"
 
 #ifdef S_IFLNK
-# define USAGE  "Usage: %s [-czL] [-f namefile] [-m magicfile] file...\n"
+# define USAGE  "Usage: %s [-vczL] [-f namefile] [-m magicfile] file...\n"
 #else
-# define USAGE  "Usage: %s [-cz] [-f namefile] [-m magicfile] file...\n"
+# define USAGE  "Usage: %s [-vcz] [-f namefile] [-m magicfile] file...\n"
 #endif
 
 #ifndef MAGIC
@@ -78,15 +83,19 @@ int argc;
 char *argv[];
 {
        int c;
-       int check = 0, didsomefiles = 0, errflg = 0, ret = 0;
+       int check = 0, didsomefiles = 0, errflg = 0, ret = 0, app = 0;
 
        if ((progname = strrchr(argv[0], '/')) != NULL)
                progname++;
        else
                progname = argv[0];
 
-       while ((c = getopt(argc, argv, "cdf:Lm:z")) != EOF)
+       while ((c = getopt(argc, argv, "vcdf:Lm:z")) != EOF)
                switch (c) {
+               case 'v':
+                       (void) fprintf(stdout, "%s-%d.%d\n", progname,
+                                      FILE_VERSION_MAJOR, patchlevel);
+                       return 1;
                case 'c':
                        ++check;
                        break;
@@ -94,6 +103,12 @@ char *argv[];
                        ++debug;
                        break;
                case 'f':
+                       if (!app) {
+                               ret = apprentice(magicfile, check);
+                               if (check)
+                                       exit(ret);
+                               app = 1;
+                       }
                        unwrap(optarg);
                        ++didsomefiles;
                        break;
@@ -113,14 +128,18 @@ char *argv[];
                        errflg++;
                        break;
                }
+
        if (errflg) {
                (void) fprintf(stderr, USAGE, progname);
                exit(2);
        }
 
-       ret = apprentice(magicfile, check);
-       if (check)
-               exit(ret);
+       if (!app) {
+               ret = apprentice(magicfile, check);
+               if (check)
+                       exit(ret);
+               app = 1;
+       }
 
        if (optind == argc) {
                if (!didsomefiles) {
index 684e118df5d77065fd041b4a339aadacee8a9c84..5e00c4f1146f63fb6fdd163266ce3c5795c53664 100644 (file)
@@ -46,7 +46,7 @@
 
 #ifndef        lint
 static char *moduleid = 
-       "@(#)$Id: fsmagic.c,v 1.22 1993/02/19 12:09:04 ian Exp $";
+       "@(#)$Id: fsmagic.c,v 1.23 1995/01/21 21:03:35 christos Exp $";
 #endif /* lint */
 
 int
@@ -151,9 +151,11 @@ struct stat *sb;
                return 1;
 #endif
 #ifdef S_IFSOCK
+#ifndef __COHERENT__
        case S_IFSOCK:
                ckfputs("socket", stdout);
                return 1;
+#endif
 #endif
        case S_IFREG:
                break;
index 490a7d53a2ca30de31d34f7516e65dca5851676b..444bbb259b0f2824915f8dd756e2ed58e94a42ea 100644 (file)
@@ -1,12 +1,18 @@
 #define        FILE_VERSION_MAJOR      3
-#define        patchlevel              14
+#define        patchlevel              15
 
 /*
  * Patchlevel file for Ian Darwin's MAGIC command.
- * $Id: patchlevel.h,v 1.14 1994/05/03 17:58:23 christos Exp $
+ * $Id: patchlevel.h,v 1.15 1995/01/21 21:03:35 christos Exp $
  *
  * $Log: patchlevel.h,v $
- * Revision 1.14  1994/05/03 17:58:23  christos
+ * Revision 1.15  1995/01/21 21:03:35  christos
+ * Added CSECTION for the file man page
+ * Added version flag -v
+ * Fixed bug with -f input flag (from iorio@violet.berkeley.edu)
+ * Lots of magic fixes and reorganization...
+ *
+ * Revision 1.14  1994/05/03  17:58:23  christos
  * changes from mycroft@gnu.ai.mit.edu (Charles Hannum) for unsigned
  *
  * Revision 1.13  1994/01/21  01:27:01  christos