* clib/mkstemp.c: Added O_BINARY for __CYGWIN32__.
* db/db.c: Added O_BINARY for __CYGWIN32__.
* hash/dbm.c: Added O_BINARY for __CYGWIN32__.
* hash/hash.c: Added O_BINARY for __CYGWIN32__.
* hash/hsearch.c: Added O_BINARY for __CYGWIN32__.
* include/db-int.h: Added O_BINARY for __CYGWIN32__.
* recno/rec_open.c: Added O_BINARY for __CYGWIN32__.
* test/dbtest.c: Added O_BINARY for __CYGWIN32__.
* test/SEQ_TEST/t.c: Added O_BINARY for __CYGWIN32__.
* test/btree.tests/main.c: Added O_BINARY for __CYGWIN32__.
* test/hash1.tests/driver2.c: Added O_BINARY for __CYGWIN32__.
* test/hash1.tests/tcreat3.c: Added O_BINARY for __CYGWIN32__.
* test/hash1.tests/tdel.c: Added O_BINARY for __CYGWIN32__.
* test/hash1.tests/thash4.c: Added O_BINARY for __CYGWIN32__.
* test/hash1.tests/tread2.c: Added O_BINARY for __CYGWIN32__.
* test/hash1.tests/tseq.c: Added O_BINARY for __CYGWIN32__.
* test/hash1.tests/tverify.c: Added O_BINARY for __CYGWIN32__.
* test/hash2.tests/bigtest.c: Added O_BINARY for __CYGWIN32__.
* test/hash2.tests/passtest.c: Added O_BINARY for __CYGWIN32__.
Changes originally by Jeremy Allison (jra@cygnus.com)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10364
dc483132-0cff-0310-8789-
dd5450dbe970
-Thu Jan 15 11:34:13 1998 Ezra Peisach <epeisach@kangaroo.mit.edu>
+Wed Jan 21 10:17:34 1998 Ezra Peisach <epeisach@mit.edu>
+
+ * btree/bt_open.c: Added O_BINARY for __CYGWIN32__.
+ * clib/mkstemp.c: Added O_BINARY for __CYGWIN32__.
+ * db/db.c: Added O_BINARY for __CYGWIN32__.
+ * hash/dbm.c: Added O_BINARY for __CYGWIN32__.
+ * hash/hash.c: Added O_BINARY for __CYGWIN32__.
+ * hash/hsearch.c: Added O_BINARY for __CYGWIN32__.
+ * include/db-int.h: Added O_BINARY for __CYGWIN32__.
+ * recno/rec_open.c: Added O_BINARY for __CYGWIN32__.
+ * test/dbtest.c: Added O_BINARY for __CYGWIN32__.
+ * test/SEQ_TEST/t.c: Added O_BINARY for __CYGWIN32__.
+ * test/btree.tests/main.c: Added O_BINARY for __CYGWIN32__.
+ * test/hash1.tests/driver2.c: Added O_BINARY for __CYGWIN32__.
+ * test/hash1.tests/tcreat3.c: Added O_BINARY for __CYGWIN32__.
+ * test/hash1.tests/tdel.c: Added O_BINARY for __CYGWIN32__.
+ * test/hash1.tests/thash4.c: Added O_BINARY for __CYGWIN32__.
+ * test/hash1.tests/tread2.c: Added O_BINARY for __CYGWIN32__.
+ * test/hash1.tests/tseq.c: Added O_BINARY for __CYGWIN32__.
+ * test/hash1.tests/tverify.c: Added O_BINARY for __CYGWIN32__.
+ * test/hash2.tests/bigtest.c: Added O_BINARY for __CYGWIN32__.
+ * test/hash2.tests/passtest.c: Added O_BINARY for __CYGWIN32__.
+ Changes originally by Jeremy Allison (jra@cygnus.com)
+
+Thu Jan 15 11:34:13 1998 Ezra Peisach <epeisach@mit.edu>
* hash/hash_bigkey.c (collect_key, collect_data): Cast malloc
return value to correct types. (raeburn@cygnus.com)
* include/db.h: Check SIZEOF_INT rather than UINT_MAX; it's broken
under Ultrix.
-Thu Aug 22 23:13:32 1996 Ezra Peisach <epeisach@kangaroo.mit.edu>
+Thu Aug 22 23:13:32 1996 Ezra Peisach <epeisach@mit.edu>
* Makefile.in: Add dummy rule for Makefiles.
* Makefile.in (install): Add a blank install target to keep the
top-level "make install" happy.
-Tue Jul 23 16:08:43 1996 Ezra Peisach <epeisach@kangaroo.mit.edu>
+Tue Jul 23 16:08:43 1996 Ezra Peisach <epeisach@mit.edu>
* hash/dbm.c: Copy elements from the datum to an internal
DBT. Handles case of differences in size of size fields.
goto einval;
}
- if ((t->bt_fd = open(fname, flags, mode)) < 0)
+ if ((t->bt_fd = open(fname, flags | O_BINARY, mode)) < 0)
goto err;
} else {
#else
sigsetmask(oset);
#endif
+#ifdef __CYGWIN32__
+ /* Ensure the fd is in binary mode. */
+ setmode(fd, O_BINARY);
+#endif /* __CYGWIN32__ */
+
return(fd);
}
#include <stdio.h>
#include <ctype.h>
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
static int _gettemp();
mkstemp(path)
for (;;) {
if (doopen) {
if ((*doopen =
- open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0)
+ open(path, O_CREAT|O_EXCL|O_RDWR|O_BINARY, 0600)) >= 0)
return(1);
if (errno != EEXIST)
return(0);
#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN)
#define USE_OPEN_FLAGS \
(O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \
- O_RDWR | O_SHLOCK | O_TRUNC)
+ O_RDWR | O_SHLOCK | O_TRUNC | O_BINARY)
if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)
switch (type) {
{
if (__cur_db != NULL)
(void)dbm_close(__cur_db);
- if ((__cur_db = dbm_open(file, O_RDWR, 0)) != NULL)
+ if ((__cur_db = dbm_open(file, O_RDWR|O_BINARY, 0)) != NULL)
return (0);
- if ((__cur_db = dbm_open(file, O_RDONLY, 0)) != NULL)
+ if ((__cur_db = dbm_open(file, O_RDONLY|O_BINARY, 0)) != NULL)
return (0);
return (-1);
}
new_table = 1;
}
if (file) {
- if ((hashp->fp = open(file, flags, mode)) == -1)
+ if ((hashp->fp = open(file, flags|O_BINARY, mode)) == -1)
RETURN_ERROR(errno, error0);
(void)fcntl(hashp->fp, F_SETFD, 1);
}
info.cachesize = 0;
info.hash = NULL;
info.lorder = 0;
- dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0);
+ dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR | O_BINARY, 0600, &info, 0);
return (dbp != NULL);
}
#define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */
#endif
+#ifndef O_BINARY
+#define O_BINARY 0 /* Needed for Win32 compiles */
+#endif
#endif /* _DB_INT_H_ */
int rfd, sverrno;
/* Open the user's file -- if this fails, we're done. */
- if (fname != NULL && (rfd = open(fname, flags, mode)) < 0)
+ if (fname != NULL && (rfd = open(fname, flags | O_BINARY, mode)) < 0)
return (NULL);
/* Create a btree in memory (backed by disk). */
btopeninfo.prefix = NULL;
btopeninfo.lorder = openinfo->lorder;
dbp = __bt_open(openinfo->bfname,
- O_RDWR, S_IRUSR | S_IWUSR, &btopeninfo, dflags);
+ O_RDWR | O_BINARY, S_IRUSR | S_IWUSR, &btopeninfo, dflags);
} else
- dbp = __bt_open(NULL, O_RDWR, S_IRUSR | S_IWUSR, NULL, dflags);
+ dbp = __bt_open(NULL, O_RDWR | O_BINARY, S_IRUSR | S_IWUSR, NULL, dflags);
if (dbp == NULL)
goto err;
default:
goto einval;
}
-slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL)
+slow: if ((t->bt_rfp = fdopen(rfd, "rb")) == NULL)
goto err;
F_SET(t, R_CLOSEFP);
t->bt_irec =
printf("Unable to open %s\n","data");
exit(25);
}
- if ((dbp = dbopen("test.db",O_RDWR | O_CREAT, 0664
+ if ((dbp = dbopen("test.db",O_RDWR | O_CREAT | O_BINARY, 0664
, DB_BTREE, NULL )) == NULL) {
printf("\n Open error on test.db %d %s\n",errno,strerror(errno));
exit(25);
printf("%d Records in\n",out);
dbp->close(dbp);
- if ((dbp = dbopen("test.db", O_RDWR, 0664
+ if ((dbp = dbopen("test.db", O_RDWR | O_BINARY, 0664
, DB_BTREE, NULL )) == NULL) {
printf("\n Error on dbopen %d %s\n",errno,strerror(errno));
exit(61);
argv += optind;
if (recno)
- db = dbopen(*argv == NULL ? NULL : *argv, O_RDWR,
+ db = dbopen(*argv == NULL ? NULL : *argv, O_RDWR|O_BINARY,
0, DB_RECNO, NULL);
else
- db = dbopen(*argv == NULL ? NULL : *argv, O_CREAT|O_RDWR,
+ db = dbopen(*argv == NULL ? NULL : *argv, O_CREAT|O_RDWR|O_BINARY,
0600, DB_BTREE, &b);
if (db == NULL) {
infoarg = NULL;
fname = NULL;
- oflags = O_CREAT | O_RDWR;
+ oflags = O_CREAT | O_RDWR | O_BINARY;
sflag = 0;
while ((ch = getopt(argc, argv, "f:i:lo:s")) != EOF)
switch (ch) {
info.hash = my_hash;
#endif
info.lorder = 0;
- if (!(db = dbopen("bigtest", O_RDWR | O_CREAT, 0644, DB_HASH, &info))) {
+ if (!(db = dbopen("bigtest", O_RDWR | O_CREAT | O_BINARY, 0644, DB_HASH, &info))) {
sprintf(buf, "dbopen: failed on file bigtest");
perror(buf);
exit(1);
ctl.nelem = atoi(*argv++);
ctl.lorder = 0;
if (!(dbp = dbopen( "hashtest",
- O_CREAT|O_TRUNC|O_RDWR, 0600, DB_HASH, &ctl))){
+ O_CREAT|O_TRUNC|O_RDWR|O_BINARY, 0600, DB_HASH, &ctl))){
/* create table */
fprintf(stderr, "cannot create: hash table (size %d)\n",
INITIAL);
ctl.cachesize = 1024 * 1024; /* 1 MEG */
ctl.lorder = 0;
argc -= 2;
- if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) {
+ if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR|O_BINARY, 0400, DB_HASH, &ctl))) {
/* create table */
fprintf(stderr, "cannot create: hash table size %d)\n",
INITIAL);
ctl.nelem = atoi(*argv++);
ctl.cachesize = atoi(*argv++);
ctl.lorder = 0;
- if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) {
+ if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR|O_BINARY, 0400, DB_HASH, &ctl))) {
/* create table */
fprintf(stderr, "cannot create: hash table size %d)\n",
INITIAL);
ctl.ffactor = 1;
ctl.cachesize = atoi(*argv++);
ctl.lorder = 0;
- if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) {
+ if (!(dbp = dbopen( "hashtest", O_RDONLY|O_BINARY, 0400, DB_HASH, &ctl))) {
/* create table */
fprintf(stderr, "cannot open: hash table\n" );
exit(1);
FILE *fp;
int stat;
- if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, NULL))) {
+ if (!(dbp = dbopen( "hashtest", O_RDONLY|O_BINARY, 0400, DB_HASH, NULL))) {
/* create table */
fprintf(stderr, "cannot open: hash table\n" );
exit(1);
ctl.ffactor = 1;
ctl.cachesize = 1024 * 1024; /* 1 MEG */
ctl.lorder = 0;
- if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) {
+ if (!(dbp = dbopen( "hashtest", O_RDONLY|O_BINARY, 0400, DB_HASH, &ctl))) {
/* create table */
fprintf(stderr, "cannot open: hash table\n" );
exit(1);
info.nelem = 0;
info.hash = NULL;
- db = dbopen("big2.db", O_RDWR|O_CREAT|O_TRUNC, 0664, DB_HASH, &info);
+ db = dbopen("big2.db", O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0664, DB_HASH, &info);
data = malloc(800 * sizeof(int));
for (n = 0; n < 800; n++)
data[n] = 0xDEADBEEF;
passwd.lorder = 4321;
- db = dbopen("/usr/tmp/passwd.db", O_RDWR|O_CREAT|O_TRUNC, 0664, DB_HASH,
+ db = dbopen("/usr/tmp/passwd.db", O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0664, DB_HASH,
&passwd);
if (!db) {
fprintf(stderr, "create_db: couldn't create database file\n");
get_key = (char *)malloc(100);
get_val = (char *)malloc(300);
- db = dbopen("/usr/tmp/passwd.db", O_RDWR, 0664, DB_HASH, &passwd);
+ db = dbopen("/usr/tmp/passwd.db", O_RDWR|O_BINARY, 0664, DB_HASH, &passwd);
if (!db)
fprintf(stderr, "Could not open db!\n");
n = 0;
keys = fopen("yp.keys", "rt");
vals = fopen("yp.total", "rt");
- db = dbopen("/usr/tmp/passwd.db", O_RDWR, 0664, DB_HASH, &passwd);
+ db = dbopen("/usr/tmp/passwd.db", O_RDWR|O_BINARY, 0664, DB_HASH, &passwd);
n = 0;
while ((get_key = fgets(get_key, 100, keys)) != NULL) {
if (n % 1000 == 0)
keys = fopen("yp.keys", "rt");
vals = fopen("yp.total", "rt");
- db = dbopen("/usr/tmp/passwd.db", O_RDWR, 0664, DB_HASH, &passwd);
+ db = dbopen("/usr/tmp/passwd.db", O_RDWR|O_BINARY, 0664, DB_HASH, &passwd);
n = 0;
while ((get_key = fgets(get_key, 100, keys)) != NULL) {
n += 2;