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