/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
#include "config.h"
#ifndef lint
static const char sccsid[] = "@(#)db_appinit.c 10.66 (Sleepycat) 12/7/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#endif
#include "db_int.h"
#include "shqueue.h"
#include "db_page.h"
#include "btree.h"
#include "hash.h"
#include "log.h"
#include "txn.h"
#include "clib_ext.h"
#include "common_ext.h"
static int __db_home __P((DB_ENV *, const char *, u_int32_t));
static int __db_parse __P((DB_ENV *, char *));
static int __db_tmp_open __P((DB_ENV *, u_int32_t, char *, int *));
/*
* This conflict array is used for concurrent db access (cdb). It
* uses the same locks as the db_rw_conflict array, but adds an IW
* mode to be used for write cursors.
*/
static u_int8_t const db_cdb_conflicts[] = {
/* N R W IW */
/* N */ 0, 0, 0, 0,
/* R */ 0, 0, 1, 0,
/* W */ 0, 1, 1, 1,
/* IW */ 0, 0, 1, 1
};
/*
* db_version --
* Return version information.
*/
char *
db_version(majverp, minverp, patchp)
int *majverp, *minverp, *patchp;
{
if (majverp != NULL)
*majverp = DB_VERSION_MAJOR;
if (minverp != NULL)
*minverp = DB_VERSION_MINOR;
if (patchp != NULL)
*patchp = DB_VERSION_PATCH;
return ((char *)DB_VERSION_STRING);
}
/*
* db_appinit --
* Initialize the application environment.
*/
int
db_appinit(db_home, db_config, dbenv, flags)
const char *db_home;
char * const *db_config;
DB_ENV *dbenv;
u_int32_t flags;
{
FILE *fp;
int mode, ret;
char * const *p;
char *lp, buf[MAXPATHLEN * 2];
fp = NULL;
/* Validate arguments. */
if (dbenv == NULL)
return (EINVAL);
#ifdef HAVE_SPINLOCKS
#define OKFLAGS \
(DB_CREATE | DB_INIT_CDB | DB_INIT_LOCK | DB_INIT_LOG | \
DB_INIT_MPOOL | DB_INIT_TXN | DB_MPOOL_PRIVATE | DB_NOMMAP | \
DB_RECOVER | DB_RECOVER_FATAL | DB_THREAD | DB_TXN_NOSYNC | \
DB_USE_ENVIRON | DB_USE_ENVIRON_ROOT)
#else
#define OKFLAGS \