Path: blob/main/crypto/krb5/src/plugins/kdb/db2/libdb2/db/db.c
34928 views
/*-1* Copyright (c) 1991, 19932* The Regents of the University of California. All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. All advertising materials mentioning features or use of this software13* must display the following acknowledgement:14* This product includes software developed by the University of15* California, Berkeley and its contributors.16* 4. Neither the name of the University nor the names of its contributors17* may be used to endorse or promote products derived from this software18* without specific prior written permission.19*20* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*/3233#if defined(LIBC_SCCS) && !defined(lint)34static char sccsid[] = "@(#)db.c 8.4 (Berkeley) 2/21/94";35#endif /* LIBC_SCCS and not lint */3637#include <sys/types.h>3839#include <errno.h>40#include <fcntl.h>41#include <stddef.h>42#include <stdio.h>4344#include "db-int.h"4546DB *47kdb2_dbopen(const char *fname, int flags, int mode, DBTYPE type,48const void *openinfo)49{5051#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN)52#define USE_OPEN_FLAGS \53(O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \54O_RDWR | O_SHLOCK | O_TRUNC | O_BINARY)5556if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)57switch (type) {58case DB_BTREE:59return (__bt_open(fname, flags & USE_OPEN_FLAGS,60mode, openinfo, flags & DB_FLAGS));61case DB_HASH:62return (__hash_open(fname, flags & USE_OPEN_FLAGS,63mode, openinfo, flags & DB_FLAGS));64case DB_RECNO:65return (__rec_open(fname, flags & USE_OPEN_FLAGS,66mode, openinfo, flags & DB_FLAGS));67}68errno = EINVAL;69return (NULL);70}7172static int73__dberr(void)74{75return (RET_ERROR);76}7778/*79* __DBPANIC -- Stop.80*81* Parameters:82* dbp: pointer to the DB structure.83*/84void85__dbpanic(DB *dbp)86{87/* The only thing that can succeed is a close. */88dbp->del = (int (*)(const struct __db *, const DBT *, u_int))__dberr;89dbp->fd = (int (*)(const struct __db *))__dberr;90dbp->get = (int (*)(const struct __db *, const DBT *, DBT *,91u_int))__dberr;92dbp->put = (int (*)(const struct __db *, DBT *, const DBT *,93u_int))__dberr;94dbp->seq = (int (*)(const struct __db *, DBT *, DBT *, u_int))__dberr;95dbp->sync = (int (*)(const struct __db *, u_int))__dberr;96}979899