#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: apprentice.c,v 1.84 2005/03/25 18:03:18 christos Exp $")
+FILE_RCSID("@(#)$Id: apprentice.c,v 1.85 2005/10/17 15:31:10 christos Exp $")
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
if (dbname == NULL)
return -1;
- if ((fd = open(dbname, O_RDONLY)) == -1)
+ if ((fd = open(dbname, O_RDONLY|O_BINARY)) == -1)
return -1;
if (fstat(fd, &st) == -1) {
if (dbname == NULL)
return -1;
- if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) {
+ if ((fd = open(dbname, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644)) == -1) {
file_error(ms, errno, "cannot open `%s'", dbname);
return -1;
}
#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 <sys/utime.h>
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: file.c,v 1.97 2005/08/12 14:19:33 christos Exp $")
+FILE_RCSID("@(#)$Id: file.c,v 1.98 2005/10/17 15:31:10 christos Exp $")
#endif /* lint */
*/
/*
* file.h - definitions for file(1) program
- * @(#)$Id: file.h,v 1.70 2005/07/29 17:57:20 christos Exp $
+ * @(#)$Id: file.h,v 1.71 2005/10/17 15:31:10 christos Exp $
*/
#ifndef __file_h__
#include <stdio.h> /* Include that here, to make sure __P gets defined */
#include <errno.h>
+#include <fcntl.h> /* For open and flags
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#define QUICK
#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#define FILE_RCSID(id) \
static const char *rcsid(const char *p) { \
return rcsid(p = id); \
#include <sys/types.h>
#include <sys/param.h> /* for MAXPATHLEN */
#include <sys/stat.h>
-#include <fcntl.h> /* for open() */
#ifdef QUICK
#include <sys/mman.h>
#endif
#include "patchlevel.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: magic.c,v 1.31 2005/10/17 15:14:44 christos Exp $")
+FILE_RCSID("@(#)$Id: magic.c,v 1.32 2005/10/17 15:31:10 christos Exp $")
#endif /* lint */
#ifdef __EMX__
if (inname == NULL)
fd = STDIN_FILENO;
- else if ((fd = open(inname, O_RDONLY)) < 0) {
+ else if ((fd = open(inname, O_RDONLY|O_BINARY)) < 0) {
#ifdef __CYGWIN__
char *tmp = alloca(strlen(inname) + 5);
(void)strcat(strcpy(tmp, inname), ".exe");
- if ((fd = open(tmp, O_RDONLY)) < 0) {
+ if ((fd = open(tmp, O_RDONLY|O_BINARY)) < 0) {
#endif
/* We cannot open it, but we were able to stat it. */
if (sb.st_mode & 0222)