about summary refs log tree commit diff
path: root/db2/db185
diff options
context:
space:
mode:
Diffstat (limited to 'db2/db185')
-rw-r--r--db2/db185/db185.c28
-rw-r--r--db2/db185/db185_int.h28
2 files changed, 34 insertions, 22 deletions
diff --git a/db2/db185/db185.c b/db2/db185/db185.c
index 7f6a16de49..893dfa3c7f 100644
--- a/db2/db185/db185.c
+++ b/db2/db185/db185.c
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1996, 1997
+ * Copyright (c) 1996, 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 
@@ -9,9 +9,9 @@
 
 #ifndef lint
 static const char copyright[] =
-"@(#) Copyright (c) 1997\n\
+"@(#) Copyright (c) 1996, 1997, 1998\n\
 	Sleepycat Software Inc.  All rights reserved.\n";
-static const char sccsid[] = "@(#)db185.c	8.14 (Sleepycat) 10/25/97";
+static const char sccsid[] = "@(#)db185.c	8.17 (Sleepycat) 5/7/98";
 #endif
 
 #ifndef NO_SYSTEM_INCLUDES
@@ -20,7 +20,6 @@ static const char sccsid[] = "@(#)db185.c	8.14 (Sleepycat) 10/25/97";
 #include <errno.h>
 #include <fcntl.h>
 #include <stdlib.h>
-#include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 #endif
@@ -114,6 +113,16 @@ __dbopen(file, oflags, mode, type, openinfo)
 		 * and DB 2.0 doesn't.
 		 *
 		 * !!!
+		 * Setting the file name to NULL specifies that we're creating
+		 * a temporary backing file, in DB 2.X.  If we're opening the
+		 * DB file read-only, change the flags to read-write, because
+		 * temporary backing files cannot be opened read-only, and DB
+		 * 2.X will return an error.  We are cheating here -- if the
+		 * application does a put on the database, it will succeed --
+		 * although that would be a stupid thing for the application
+		 * to do.
+		 *
+		 * !!!
 		 * Note, the file name in DB 1.85 was a const -- we don't do
 		 * that in DB 2.0, so do that cast.
 		 */
@@ -122,6 +131,10 @@ __dbopen(file, oflags, mode, type, openinfo)
 				(void)__os_close(__os_open(file, oflags, mode));
 			dbinfop->re_source = (char *)file;
 			file = NULL;
+
+			if (O_RDONLY)
+				oflags &= ~O_RDONLY;
+			oflags |= O_RDWR;
 		}
 
 		if ((ri = openinfo) != NULL) {
@@ -181,15 +194,14 @@ __dbopen(file, oflags, mode, type, openinfo)
 	 * Store the returned pointer to the real DB 2.0 structure in the
 	 * internal pointer.  Ugly, but we're not going for pretty, here.
 	 */
-	if ((__set_errno(db_open(file,
-	    type, __db_oflags(oflags), mode, NULL, dbinfop, &dbp))) != 0) {
+	if ((errno = db_open(file,
+	    type, __db_oflags(oflags), mode, NULL, dbinfop, &dbp)) != 0) {
 		__db_free(db185p);
 		return (NULL);
 	}
 
 	/* Create the cursor used for sequential ops. */
-	if ((__set_errno(dbp->cursor(dbp, NULL, &((DB185 *)db185p)->dbc)))
-	    != 0) {
+	if ((errno = dbp->cursor(dbp, NULL, &((DB185 *)db185p)->dbc)) != 0) {
 		s_errno = errno;
 		(void)dbp->close(dbp, 0);
 		__db_free(db185p);
diff --git a/db2/db185/db185_int.h b/db2/db185/db185_int.h
index f3e24b9026..f7d7af5347 100644
--- a/db2/db185/db185_int.h
+++ b/db2/db185/db185_int.h
@@ -1,7 +1,7 @@
 /*-
  * See the file LICENSE for redistribution information.
  *
- * Copyright (c) 1997
+ * Copyright (c) 1997, 1998
  *	Sleepycat Software.  All rights reserved.
  */
 /*
@@ -40,7 +40,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	@(#)db185_int.h	8.4 (Sleepycat) 7/27/97
+ *	@(#)db185_int.h	8.7 (Sleepycat) 4/10/98
  */
 
 #ifndef _DB185_H_
@@ -90,11 +90,11 @@ typedef struct __db185 {
 /* Structure used to pass parameters to the btree routines. */
 typedef struct {
 #define	R_DUP		0x01	/* duplicate keys */
-	u_long	flags;
-	u_int	cachesize;	/* bytes to cache */
-	int	maxkeypage;	/* maximum keys per page */
-	int	minkeypage;	/* minimum keys per page */
-	u_int	psize;		/* page size */
+	u_int32_t flags;
+	u_int32_t cachesize;	/* bytes to cache */
+	u_int32_t maxkeypage;	/* maximum keys per page */
+	u_int32_t minkeypage;	/* minimum keys per page */
+	u_int32_t psize;	/* page size */
 	int	(*compare)	/* comparison function */
 	    __P((const DBT *, const DBT *));
 	size_t	(*prefix)	/* prefix function */
@@ -104,10 +104,10 @@ typedef struct {
 
 /* Structure used to pass parameters to the hashing routines. */
 typedef struct {
-	u_int	bsize;		/* bucket size */
-	u_int	ffactor;	/* fill factor */
-	u_int	nelem;		/* number of elements */
-	u_int	cachesize;	/* bytes to cache */
+	u_int32_t bsize;	/* bucket size */
+	u_int32_t ffactor;	/* fill factor */
+	u_int32_t nelem;	/* number of elements */
+	u_int32_t cachesize;	/* bytes to cache */
 	u_int32_t		/* hash function */
 		(*hash) __P((const void *, size_t));
 	int	lorder;		/* byte order */
@@ -118,9 +118,9 @@ typedef struct {
 #define	R_FIXEDLEN	0x01	/* fixed-length records */
 #define	R_NOKEY		0x02	/* key not required */
 #define	R_SNAPSHOT	0x04	/* snapshot the input */
-	u_long	flags;
-	u_int	cachesize;	/* bytes to cache */
-	u_int	psize;		/* page size */
+	u_int32_t flags;
+	u_int32_t cachesize;	/* bytes to cache */
+	u_int32_t psize;	/* page size */
 	int	lorder;		/* byte order */
 	size_t	reclen;		/* record length (fixed-length records) */
 	u_char	bval;		/* delimiting byte (variable-length records */