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.6 (Berkeley) 05/24/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 41 __dberr() 42 { 43 return (RET_ERROR); 44 } 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 = (int (*)())__dberr; 58 dbp->fd = (int (*)())__dberr; 59 dbp->get = (int (*)())__dberr; 60 dbp->put = (int (*)())__dberr; 61 dbp->seq = (int (*)())__dberr; 62 dbp->sync = (int (*)())__dberr; 63 } 64