2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/*-
2N/A * Copyright (c) 1991, 1993
2N/A * The Regents of the University of California. All rights reserved.
2N/A *
2N/A * Redistribution and use in source and binary forms, with or without
2N/A * modification, are permitted provided that the following conditions
2N/A * are met:
2N/A * 1. Redistributions of source code must retain the above copyright
2N/A * notice, this list of conditions and the following disclaimer.
2N/A * 2. Redistributions in binary form must reproduce the above copyright
2N/A * notice, this list of conditions and the following disclaimer in the
2N/A * documentation and/or other materials provided with the distribution.
2N/A * 3. All advertising materials mentioning features or use of this software
2N/A * must display the following acknowledgement:
2N/A * This product includes software developed by the University of
2N/A * California, Berkeley and its contributors.
2N/A * 4. Neither the name of the University nor the names of its contributors
2N/A * may be used to endorse or promote products derived from this software
2N/A * without specific prior written permission.
2N/A *
2N/A * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2N/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2N/A * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2N/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2N/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2N/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2N/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2N/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2N/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2N/A * SUCH DAMAGE.
2N/A */
2N/A
2N/A#if defined(LIBC_SCCS) && !defined(lint)
2N/Astatic char sccsid[] = "@(#)db.c 8.4 (Berkeley) 2/21/94";
2N/A#endif /* LIBC_SCCS and not lint */
2N/A
2N/A#include <sys/types.h>
2N/A
2N/A#include <errno.h>
2N/A#include <fcntl.h>
2N/A#include <stddef.h>
2N/A#include <stdio.h>
2N/A
2N/A#include "db-int.h"
2N/A
2N/ADB *
2N/Akdb2_dbopen(fname, flags, mode, type, openinfo)
2N/A const char *fname;
2N/A int flags, mode;
2N/A DBTYPE type;
2N/A const void *openinfo;
2N/A{
2N/A
2N/A#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN)
2N/A#define USE_OPEN_FLAGS \
2N/A (O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \
2N/A O_RDWR | O_SHLOCK | O_TRUNC | O_BINARY)
2N/A
2N/A if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)
2N/A switch (type) {
2N/A case DB_BTREE:
2N/A return (__bt_open(fname, flags & USE_OPEN_FLAGS,
2N/A mode, openinfo, flags & DB_FLAGS));
2N/A case DB_HASH:
2N/A return (__hash_open(fname, flags & USE_OPEN_FLAGS,
2N/A mode, openinfo, flags & DB_FLAGS));
2N/A case DB_RECNO:
2N/A return (__rec_open(fname, flags & USE_OPEN_FLAGS,
2N/A mode, openinfo, flags & DB_FLAGS));
2N/A }
2N/A errno = EINVAL;
2N/A return (NULL);
2N/A}
2N/A
2N/Astatic int
2N/A__dberr()
2N/A{
2N/A return (RET_ERROR);
2N/A}
2N/A
2N/A/*
2N/A * __DBPANIC -- Stop.
2N/A *
2N/A * Parameters:
2N/A * dbp: pointer to the DB structure.
2N/A */
2N/Avoid
2N/A__dbpanic(dbp)
2N/A DB *dbp;
2N/A{
2N/A /* The only thing that can succeed is a close. */
2N/A dbp->del = (int (*)())__dberr;
2N/A dbp->fd = (int (*)())__dberr;
2N/A dbp->get = (int (*)())__dberr;
2N/A dbp->put = (int (*)())__dberr;
2N/A dbp->seq = (int (*)())__dberr;
2N/A dbp->sync = (int (*)())__dberr;
2N/A}