* btree/bt_open.c: Added O_BINARY for __CYGWIN32__.
authorEzra Peisach <epeisach@mit.edu>
Wed, 21 Jan 1998 16:33:31 +0000 (16:33 +0000)
committerEzra Peisach <epeisach@mit.edu>
Wed, 21 Jan 1998 16:33:31 +0000 (16:33 +0000)
* 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

21 files changed:
src/util/db2/ChangeLog
src/util/db2/btree/bt_open.c
src/util/db2/clib/mkstemp.c
src/util/db2/db/db.c
src/util/db2/hash/dbm.c
src/util/db2/hash/hash.c
src/util/db2/hash/hsearch.c
src/util/db2/include/db-int.h
src/util/db2/recno/rec_open.c
src/util/db2/test/SEQ_TEST/t.c
src/util/db2/test/btree.tests/main.c
src/util/db2/test/dbtest.c
src/util/db2/test/hash1.tests/driver2.c
src/util/db2/test/hash1.tests/tcreat3.c
src/util/db2/test/hash1.tests/tdel.c
src/util/db2/test/hash1.tests/thash4.c
src/util/db2/test/hash1.tests/tread2.c
src/util/db2/test/hash1.tests/tseq.c
src/util/db2/test/hash1.tests/tverify.c
src/util/db2/test/hash2.tests/bigtest.c
src/util/db2/test/hash2.tests/passtest.c

index 7bd6da56528d69d23640006ef9a8d3120087e0c4..d3581d7c2613d4d3dff1266eace3e69cf8e3f252 100644 (file)
@@ -1,4 +1,28 @@
-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)
@@ -55,7 +79,7 @@ Wed Aug 28 17:25:10 1996  Tom Yu  <tlyu@mit.edu>
        * 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.
 
@@ -76,7 +100,7 @@ Fri Jul 26 00:41:45 1996  Theodore Y. Ts'o  <tytso@mit.edu>
        * 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.
index 3a7aa9462763f06edf7445d8ec942813ff563666..50fbe3f00a538ad6fe84b182cf6bb9b4cfd42e5a 100644 (file)
@@ -201,7 +201,7 @@ __bt_open(fname, flags, mode, openinfo, dflags)
                        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 {
@@ -427,6 +427,11 @@ tmp()
 #else
        sigsetmask(oset);
 #endif
+#ifdef __CYGWIN32__
+      /* Ensure the fd is in binary mode. */
+      setmode(fd, O_BINARY);
+#endif /* __CYGWIN32__ */
+
        return(fd);
 }
 
index 07d4186a9d35971ad29a69a2e2bc28d5a9ed4f0b..89251104a56b045ebc181ac46c6332df069de7f3 100644 (file)
@@ -42,6 +42,10 @@ static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93";
 #include <stdio.h>
 #include <ctype.h>
 
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
 static int _gettemp();
 
 mkstemp(path)
@@ -92,7 +96,7 @@ _gettemp(path, doopen)
        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);
index dc38abdc4eaf427f711fec57e8c2e64bfb2c4f2c..e236afbd03266e4cddc9c5a174e635d20286d5a1 100644 (file)
@@ -55,7 +55,7 @@ dbopen(fname, flags, mode, type, openinfo)
 #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) {
index 474512775db155c6332e7ec95e3bd56f1acceb8d..7b83da09dd2cf2632d3e80497e78d610bc1ead23 100644 (file)
@@ -73,9 +73,9 @@ dbminit(file)
 {
        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);
 }
index e52275438d7d50fc77ae0e50e5d13e289466cec3..8e9f7f073dab079788d1ee244ce8850baf6ae5bb 100644 (file)
@@ -140,7 +140,7 @@ __hash_open(file, flags, mode, info, dflags)
                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);
        }
index f257cd6eaadd111b80b89199b5947ead116dfe01..02ff7ef843e0a8afd1d7cb09776737ee3f3c49e1 100644 (file)
@@ -61,7 +61,7 @@ hcreate(nel)
        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);
 }
 
index 78be4c8a369904e2c7d6cb9f9066e3108313f154..f9da8a2846e2dd433a17acbde3ae2969e0733ec0 100644 (file)
@@ -205,4 +205,7 @@ void         __dbpanic __P((DB *dbp));
 #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_ */
index fccaacc90d796e132212f97f87ed277823742a4c..f18a1cb02880b3b35d9bdde9aeb099cee0af44b1 100644 (file)
@@ -68,7 +68,7 @@ __rec_open(fname, flags, mode, openinfo, dflags)
        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). */
@@ -85,9 +85,9 @@ __rec_open(fname, flags, mode, openinfo, dflags)
                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;
 
@@ -130,7 +130,7 @@ __rec_open(fname, flags, mode, openinfo, dflags)
                        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 =
index ac0fef71ec4002fb6cf95a2ddf9eb2b9556d4a48..31262b2d9adf016668a90e5ec6b82ac1783dc7a1 100644 (file)
@@ -23,7 +23,7 @@ void main(int argc, char *argv[]) {
     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);
@@ -43,7 +43,7 @@ void main(int argc, char *argv[]) {
   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);
index 02f1b96286ff99af0956cbf3302ee48a2091027b..61c9731cc9ab675ff4ff3c26ddb7c76e2ad3ab32 100644 (file)
@@ -169,10 +169,10 @@ main(argc, argv)
        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) {
index f49228165b74b90a0892ceea26a0d0a8cbb23449..170a0ea0f7003445d409cd170cebefe02a49e82d 100644 (file)
@@ -99,7 +99,7 @@ main(argc, argv)
 
        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) {
index 074f9eae06c89a6be9ab34273024d94833decf1b..6a3b432cb686fdf69e51dda7bfd1abb9056d664e 100644 (file)
@@ -81,7 +81,7 @@ main(argc, argv)
        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);
index 3aaab99cbf886ecca0179b67aceb9ca8bc4e8458..f11487b32043a40c8a1c9ffd73509307affe63bb 100644 (file)
@@ -72,7 +72,7 @@ char **argv;
        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);
index b542d8ef3d9c97d6ae190530e795e194a9d2c6c0..826611486d27e1cbe99e483a0b15017c52dbc2a2 100644 (file)
@@ -74,7 +74,7 @@ char **argv;
        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);
index b0d4b42e36ad199424640e463a80fc2a946635cb..b15b617bc7801248db14497a9746b813f5a0b6cb 100644 (file)
@@ -75,7 +75,7 @@ char **argv;
        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);
index 44acaa93dd4ca7e5c46345fb55f6df28b7493d8a..1e2cc4c503e8a6f47b22bf22e7df27c7ccc3aa49 100644 (file)
@@ -74,7 +74,7 @@ char **argv;
        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);
index 5eee5de61cf00158e5d1baa7b4d31babbd1b05a0..d2d36862d1fa2e490d49f3b122a181f4485db46a 100644 (file)
@@ -63,7 +63,7 @@ char **argv;
        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);
index a5a5dfd183d73f40bc16ffea45068d6e17368ecc..4747804f7678aa9ce70067b224215b9f9b947159 100644 (file)
@@ -75,7 +75,7 @@ char **argv;
        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);
index e6d4108b725eb1b019f31fdf66e538ebaa237423..81c559ad2af8f75c9afa631efc7294362f7c8f6e 100644 (file)
@@ -20,7 +20,7 @@ main(void)
        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;
index d6277ca52d923e3f46b04a82bc52230d33c6c61c..adb72c004b0f60db8aa84ed9060f0bb05b2f7d60 100644 (file)
@@ -30,7 +30,7 @@ main(void)
     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");
@@ -66,7 +66,7 @@ main(void)
     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;
@@ -123,7 +123,7 @@ main(void)
     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)
@@ -151,7 +151,7 @@ main(void)
     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;