1 /*- 2 * Copyright (c) 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)db.c 5.2 (Berkeley) 09/11/91"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 #include <sys/types.h> 13 #define __DBINTERFACE_PRIVATE 14 #include <db.h> 15 #include <stdio.h> 16 #include <stddef.h> 17 #include <errno.h> 18 #include "../btree/btree.h" 19 20 DB * 21 dbopen(fname, flags, mode, type, openinfo) 22 const char *fname; 23 int flags, mode; 24 DBTYPE type; 25 const void *openinfo; 26 { 27 switch (type) { 28 case DB_BTREE: 29 return (__bt_open(fname, flags, mode, openinfo)); 30 case DB_HASH: 31 return (__hash_open(fname, flags, mode, openinfo)); 32 case DB_RECNO: 33 return (__rec_open(fname, flags, mode, openinfo)); 34 } 35 errno = EINVAL; 36 return (NULL); 37 } 38 39 static int __db_edel __P((const DB *, const DBT *, u_int)); 40 static int __db_eget __P((const DB *, const DBT *, DBT *, u_int)); 41 static int __db_eput __P((const DB *dbp, const DBT *, const DBT *, u_int)); 42 static int __db_eseq __P((const DB *, DBT *, DBT *, u_int)); 43 static int __db_esync __P((const DB *)); 44 45 /* 46 * __DBPANIC -- Stop. 47 * 48 * Parameters: 49 * dbp: pointer to the DB structure. 50 */ 51 void 52 __dbpanic(dbp) 53 DB *dbp; 54 { 55 /* The only thing that can succeed is a close. */ 56 dbp->del = __db_edel; 57 dbp->get = __db_eget; 58 dbp->put = __db_eput; 59 dbp->seq = __db_eseq; 60 dbp->sync = __db_esync; 61 } 62 63 static int 64 __db_edel(dbp, key, flags) 65 const DB *dbp; 66 const DBT *key; 67 u_int flags; 68 { 69 return (RET_ERROR); 70 } 71 72 static int 73 __db_eget(dbp, key, data, flag) 74 const DB *dbp; 75 const DBT *key; 76 DBT *data; 77 u_int flag; 78 { 79 return (RET_ERROR); 80 } 81 82 static int 83 __db_eput(dbp, key, data, uflags) 84 const DB *dbp; 85 const DBT *key, *data; 86 u_int uflags; 87 { 88 return (RET_ERROR); 89 } 90 91 static int 92 __db_eseq(dbp, key, data, flags) 93 const DB *dbp; 94 DBT *key, *data; 95 u_int flags; 96 { 97 return (RET_ERROR); 98 } 99 100 static int 101 __db_esync(dbp) 102 const DB *dbp; 103 { 104 return (RET_ERROR); 105 } 106