.TH FILE __CSECTION__ "Copyright but distributable"
-.\" $Id: file.man,v 1.30 1997/11/05 16:03:18 christos Exp $
+.\" $Id: file.man,v 1.31 1998/02/15 23:18:53 christos Exp $
.SH NAME
file
\- determine file type
Altered by Rob McMahon, cudcv@warwick.ac.uk, 1989, to extend the `&' operator
from simple `x&y != 0' to `x&y op z'.
.PP
-Altered by Guy Harris, guy@auspex.com, 1993, to:
+Altered by Guy Harris, guy@netapp.com, 1993, to:
.RS
.PP
put the ``old-style'' `&'
#include <stdio.h>
#include <string.h>
+#include <memory.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#ifndef lint
static char *moduleid =
- "@(#)$Id: ascmagic.c,v 1.21 1997/01/15 17:23:24 christos Exp $";
+ "@(#)$Id: ascmagic.c,v 1.22 1998/02/15 23:18:53 christos Exp $";
#endif /* lint */
/* an optimisation over plain strcmp() */
* information if recognized
* uncompress(method, old, n, newch) - uncompress old into new,
* using method, return sizeof new
- * $Id: compress.c,v 1.9 1995/05/20 22:09:21 christos Exp $
+ * $Id: compress.c,v 1.10 1998/02/15 23:18:53 christos Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
+#endif
#include "file.h"
*/
#ifndef lint
static char *moduleid =
- "@(#)$Id: file.c,v 1.38 1997/01/15 19:28:35 christos Exp $";
+ "@(#)$Id: file.c,v 1.39 1998/02/15 23:18:53 christos Exp $";
#endif /* lint */
#include <stdio.h>
#include "file.h"
#ifdef S_IFLNK
-# define USAGE "Usage: %s [-vczL] [-f namefile] [-m magicfiles] file...\n"
+# define USAGE "Usage: %s [-vbczL] [-f namefile] [-m magicfiles] file...\n"
#else
-# define USAGE "Usage: %s [-vcz] [-f namefile] [-m magicfiles] file...\n"
+# define USAGE "Usage: %s [-vbcz] [-f namefile] [-m magicfiles] file...\n"
#endif
#ifndef MAGIC
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 */
int /* Misc globals */
if (!(magicfile = getenv("MAGIC")))
magicfile = MAGIC;
- while ((c = getopt(argc, argv, "vcdf:Lm:z")) != EOF)
+ while ((c = getopt(argc, argv, "vbcdf:Lm:z")) != EOF)
switch (c) {
case 'v':
(void) fprintf(stdout, "%s-%d.%d\n", progname,
FILE_VERSION_MAJOR, patchlevel);
return 1;
+ case 'b':
+ ++bflag;
+ break;
case 'c':
++check;
break;
inname = stdname;
}
- if (wid > 0)
+ if (wid > 0 && !bflag)
(void) printf("%s:%*s ", inname,
(int) (wid - strlen(inname)), "");
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#ifndef major
# if defined(__SVR4) || defined(_SVR4_SOURCE)
# include <sys/mkdev.h>
#ifndef lint
static char *moduleid =
- "@(#)$Id: fsmagic.c,v 1.25 1997/01/15 19:28:35 christos Exp $";
+ "@(#)$Id: fsmagic.c,v 1.26 1998/02/15 23:18:53 christos Exp $";
#endif /* lint */
int
ckfputs("directory", stdout);
return 1;
case S_IFCHR:
+#ifdef HAVE_ST_RDEV
(void) printf("character special (%ld/%ld)",
(long) major(sb->st_rdev), (long) minor(sb->st_rdev));
+#else
+ (void) printf("character special");
+#endif
return 1;
case S_IFBLK:
+#ifdef HAVE_ST_RDEV
(void) printf("block special (%ld/%ld)",
(long) major(sb->st_rdev), (long) minor(sb->st_rdev));
+#else
+ (void) printf("block special");
+#endif
return 1;
/* TODO add code to handle V7 MUX and Blit MUX files */
#ifdef S_IFIFO
#include "file.h"
#include <string.h>
+#include <memory.h>
#define F 0
#define T 1
*/
for (i = 0; i < nbytes;) {
- cp = memchr(buf, '\n', nbytes - i);
+ cp = (unsigned char *) memchr(buf, '\n', nbytes - i);
if (cp == NULL) {
/* Don't fail if we hit the end of buffer. */
if (i + MAXLINELEN >= nbytes)
#include <unistd.h>
#include <errno.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "readelf.h"
#include "file.h"
if ((u.c[sizeof(long) - 1] + 1) == elfhdr.e_ident[5]) {
#ifdef notyet
if (elfhdr.e_type == ET_CORE)
- dophn_core(fd, elfhdr.e_phoff, elfhdr.e_phnum,
- elfhdr.e_phentsize, buf);
+ dophn_core(fd, elfhdr.e_phoff[1],
+ elfhdr.e_phnum,
+ elfhdr.e_phentsize, buf);
else
#endif
{
#ifdef notyet
if (elfhdr.e_type == ET_EXEC) {
- dophn_exec(fd, elfhdr.e_phoff,
- elfhdr.e_phnum,
- elfhdr.e_phentsize, buf);
+ dophn_exec(fd, elfhdr.e_phoff[1],
+ elfhdr.e_phnum,
+ elfhdr.e_phentsize, buf);
}
#endif
- doshn(fd, elfhdr.e_shoff, elfhdr.e_shnum,
+ doshn(fd, elfhdr.e_shoff[1],
+ elfhdr.e_shnum,
elfhdr.e_shentsize, buf);
}
}
#include <time.h>
#include <sys/types.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "file.h"
#ifndef lint
static char *moduleid =
- "@(#)$Id: softmagic.c,v 1.35 1997/04/13 18:28:30 christos Exp $";
+ "@(#)$Id: softmagic.c,v 1.36 1998/02/15 23:18:53 christos Exp $";
#endif /* lint */
static int match __P((unsigned char *, int));