-.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
.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)
-.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
.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
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.
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 ]).
.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.
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)
.\" 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 $
# 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.
what ./file >lastnocore
file: $(OBJS)
- $(CC) $(CFLAGS) $(OBJS) -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
lint: $(SRCS)
lint -ha $(DEFS) $(SRCS) | tee $@
magic: Magdir
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
*/
#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>
#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
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;
++debug;
break;
case 'f':
+ if (!app) {
+ ret = apprentice(magicfile, check);
+ if (check)
+ exit(ret);
+ app = 1;
+ }
unwrap(optarg);
++didsomefiles;
break;
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) {
#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
return 1;
#endif
#ifdef S_IFSOCK
+#ifndef __COHERENT__
case S_IFSOCK:
ckfputs("socket", stdout);
return 1;
+#endif
#endif
case S_IFREG:
break;
#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