*/
#include "file.h"
-#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
#include <ctype.h>
-#include <errno.h>
#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#ifdef QUICK
#include <sys/mman.h>
#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.46 2002/05/16 18:45:56 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.47 2002/06/11 17:31:46 christos Exp $")
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
uint32 version;
int needsbyteswap;
char *dbname = mkdbname(fn);
+ void *mm;
if (dbname == NULL)
return -1;
}
#ifdef QUICK
- if ((*magicp = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
+ if ((mm = mmap(0, (size_t)st.st_size, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FILE, fd, (off_t)0)) == MAP_FAILED) {
(void)fprintf(stderr, "%s: Cannot map `%s' (%s)\n",
progname, dbname, strerror(errno));
goto error;
}
#else
- if ((*magicp = malloc((size_t)st.st_size)) == NULL) {
+ if ((mm = malloc((size_t)st.st_size)) == NULL) {
(void) fprintf(stderr, "%s: Out of memory (%s).\n", progname,
strerror(errno));
goto error;
}
- if (read(fd, *magicp, (size_t)st.st_size) != (size_t)st.st_size) {
+ if (read(fd, mm, (size_t)st.st_size) != (size_t)st.st_size) {
(void) fprintf(stderr, "%s: Read failed (%s).\n", progname,
strerror(errno));
goto error;
}
#endif
+ *magicp = mm;
(void)close(fd);
fd = -1;
ptr = (uint32 *) *magicp;
error:
if (fd != -1)
(void)close(fd);
- if (*magicp) {
+ if (mm) {
#ifdef QUICK
- (void)munmap(*magicp, (size_t)st.st_size);
+ (void)munmap(mm, (size_t)st.st_size);
#else
- free(*magicp);
+ free(mm);
#endif
} else {
*magicp = NULL;
*/
#include "file.h"
-#include <stdio.h>
#include <string.h>
#include <memory.h>
#include <ctype.h>
#include "names.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: ascmagic.c,v 1.30 2001/07/26 13:15:49 christos Exp $")
+FILE_RCSID("@(#)$Id: ascmagic.c,v 1.31 2002/06/11 17:31:46 christos Exp $")
#endif /* lint */
typedef unsigned long unichar;
* using method, return sizeof new
*/
#include "file.h"
-#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: compress.c,v 1.23 2002/05/16 18:57:10 christos Exp $")
+FILE_RCSID("@(#)$Id: compress.c,v 1.24 2002/06/11 17:31:46 christos Exp $")
#endif
*/
#include "file.h"
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
-#include <sys/types.h>
#include <sys/param.h> /* for MAXPATHLEN */
-#include <sys/stat.h>
#include <fcntl.h> /* for open() */
#ifdef RESTORE_TIME
# if (__COHERENT__ >= 0x420)
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: file.c,v 1.63 2002/06/11 17:15:52 christos Exp $")
+FILE_RCSID("@(#)$Id: file.c,v 1.64 2002/06/11 17:31:46 christos Exp $")
#endif /* lint */
/*
* file.h - definitions for file(1) program
- * @(#)$Id: file.h,v 1.40 2002/06/11 17:15:52 christos Exp $
+ * @(#)$Id: file.h,v 1.41 2002/06/11 17:31:46 christos Exp $
*
* Copyright (c) Ian F. Darwin, 1987.
* Written by Ian F. Darwin.
#include <stdio.h> /* Include that here, to make sure __P gets defined */
#include <errno.h>
+/*
+ * Include it here, so that we don't run into problems with silly OS's that
+ * do #define renaming for large file support (Hi Solaris).
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
#ifndef __P
# if defined(__STDC__) || defined(__cplusplus)
extern int ascmagic __P((unsigned char *, int));
extern void error __P((const char *, ...));
extern void ckfputs __P((const char *, FILE *));
-struct stat;
extern int fsmagic __P((const char *, struct stat *));
extern char *fmttime __P((long, int));
extern int is_compress __P((const unsigned char *, int *));
*/
#include "file.h"
-#include <stdio.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#undef HAVE_MAJOR
#ifndef lint
-FILE_RCSID("@(#)$Id: fsmagic.c,v 1.33 2000/08/05 17:36:48 christos Exp $")
+FILE_RCSID("@(#)$Id: fsmagic.c,v 1.34 2002/06/11 17:31:46 christos Exp $")
#endif /* lint */
int
* Public Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
*
* @(#)list.c 1.18 9/23/86 Public Domain - gnu
- * $Id: is_tar.c,v 1.15 2002/06/11 17:15:52 christos Exp $
+ * $Id: is_tar.c,v 1.16 2002/06/11 17:31:46 christos Exp $
*
* Comments changed and some code/comments reformatted
* for file command by Ian Darwin.
#include "file.h"
#include <string.h>
#include <ctype.h>
-#include <sys/types.h>
#include "tar.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: is_tar.c,v 1.15 2002/06/11 17:15:52 christos Exp $")
+FILE_RCSID("@(#)$Id: is_tar.c,v 1.16 2002/06/11 17:31:46 christos Exp $")
#endif
#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
*/
#include "file.h"
-#include <stdio.h>
-#include <errno.h>
#include <string.h>
#ifdef __STDC__
# include <stdarg.h>
#include <time.h>
#ifndef lint
-FILE_RCSID("@(#)$Id: print.c,v 1.35 2002/05/16 18:45:56 christos Exp $")
+FILE_RCSID("@(#)$Id: print.c,v 1.36 2002/06/11 17:31:46 christos Exp $")
#endif /* lint */
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
#include "file.h"
#ifdef BUILTIN_ELF
-#include <sys/types.h>
#include <string.h>
-#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#include <errno.h>
#include "readelf.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: readelf.c,v 1.20 2002/05/16 18:57:11 christos Exp $")
+FILE_RCSID("@(#)$Id: readelf.c,v 1.21 2002/06/11 17:31:46 christos Exp $")
#endif
#ifdef ELFCORE
*/
#include "file.h"
-#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
-#include <sys/types.h>
#include <regex.h>
#ifndef lint
-FILE_RCSID("@(#)$Id: softmagic.c,v 1.49 2002/06/11 17:15:52 christos Exp $")
+FILE_RCSID("@(#)$Id: softmagic.c,v 1.50 2002/06/11 17:31:46 christos Exp $")
#endif /* lint */
static int match __P((struct magic *, uint32, unsigned char *, int));