db.h revision 1
1N/A/*-
1N/A * See the file LICENSE for redistribution information.
1N/A *
1N/A * Copyright (c) 1996, 1997, 1998
1N/A * Sleepycat Software. All rights reserved.
1N/A *
1N/A * @(#)db.h 10.174 (Sleepycat) 1/3/99
1N/A */
1N/A
1N/A#ifndef _DB_H_
1N/A#define _DB_H_
1N/A
1N/A#ifndef __NO_SYSTEM_INCLUDES
1N/A#include <sys/types.h>
1N/A
1N/A#include <stdio.h>
1N/A#endif
1N/A
1N/A/*
1N/A * XXX
1N/A * MacOS: ensure that Metrowerks C makes enumeration types int sized.
1N/A */
1N/A#ifdef __MWERKS__
1N/A#pragma enumsalwaysint on
1N/A#endif
1N/A
1N/A/*
1N/A * XXX
1N/A * Handle function prototypes and the keyword "const". This steps on name
1N/A * space that DB doesn't control, but all of the other solutions are worse.
1N/A *
1N/A * XXX
1N/A * While Microsoft's compiler is ANSI C compliant, it doesn't have _STDC_
1N/A * defined by default, you specify a command line flag or #pragma to turn
1N/A * it on. Don't do that, however, because some of Microsoft's own header
1N/A * files won't compile.
1N/A */
1N/A#undef __P
1N/A#if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER)
1N/A#define __P(protos) protos /* ANSI C prototypes */
1N/A#else
1N/A#define const
1N/A#define __P(protos) () /* K&R C preprocessor */
1N/A#endif
1N/A
1N/A/*
1N/A * !!!
1N/A * DB needs basic information about specifically sized types. If they're
1N/A * not provided by the system, typedef them here.
1N/A *
1N/A * We protect them against multiple inclusion using __BIT_TYPES_DEFINED__,
1N/A * as does BIND and Kerberos, since we don't know for sure what #include
1N/A * files the user is using.
1N/A *
1N/A * !!!
1N/A * We also provide the standard u_int, u_long etc., if they're not provided
1N/A * by the system.
1N/A */
1N/A#ifndef __BIT_TYPES_DEFINED__
1N/A#define __BIT_TYPES_DEFINED__
1N/Atypedef unsigned char u_int8_t;
1N/A
1N/Atypedef unsigned short u_int16_t;
1N/A
1N/Atypedef unsigned int u_int32_t;
1N/A#endif
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A#define DB_VERSION_MAJOR 2
1N/A#define DB_VERSION_MINOR 7
1N/A#define DB_VERSION_PATCH 7
1N/A#define DB_VERSION_STRING "Sleepycat Software: Berkeley DB 2.7.7: (08/20/99)"
1N/A
1N/Atypedef u_int32_t db_pgno_t; /* Page number type. */
1N/Atypedef u_int16_t db_indx_t; /* Page offset type. */
1N/A#define DB_MAX_PAGES 0xffffffff /* >= # of pages in a file */
1N/A
1N/Atypedef u_int32_t db_recno_t; /* Record number type. */
1N/A#define DB_MAX_RECORDS 0xffffffff /* >= # of records in a tree */
1N/A
1N/Atypedef size_t DB_LOCK; /* Object returned by lock manager. */
1N/A
1N/A/* Forward structure declarations, so applications get type checking. */
1N/Astruct __db; typedef struct __db DB;
1N/A#ifdef DB_DBM_HSEARCH
1N/A typedef struct __db DBM;
1N/A#endif
1N/Astruct __db_bt_stat; typedef struct __db_bt_stat DB_BTREE_STAT;
1N/Astruct __db_dbt; typedef struct __db_dbt DBT;
1N/Astruct __db_env; typedef struct __db_env DB_ENV;
1N/Astruct __db_ilock; typedef struct __db_ilock DB_LOCK_ILOCK;
1N/Astruct __db_info; typedef struct __db_info DB_INFO;
1N/Astruct __db_lock_stat; typedef struct __db_lock_stat DB_LOCK_STAT;
1N/Astruct __db_lockregion; typedef struct __db_lockregion DB_LOCKREGION;
1N/Astruct __db_lockreq; typedef struct __db_lockreq DB_LOCKREQ;
1N/Astruct __db_locktab; typedef struct __db_locktab DB_LOCKTAB;
1N/Astruct __db_log; typedef struct __db_log DB_LOG;
1N/Astruct __db_log_stat; typedef struct __db_log_stat DB_LOG_STAT;
1N/Astruct __db_lsn; typedef struct __db_lsn DB_LSN;
1N/Astruct __db_mpool; typedef struct __db_mpool DB_MPOOL;
1N/Astruct __db_mpool_finfo;typedef struct __db_mpool_finfo DB_MPOOL_FINFO;
1N/Astruct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT;
1N/Astruct __db_mpool_stat; typedef struct __db_mpool_stat DB_MPOOL_STAT;
1N/Astruct __db_mpoolfile; typedef struct __db_mpoolfile DB_MPOOLFILE;
1N/Astruct __db_txn; typedef struct __db_txn DB_TXN;
1N/Astruct __db_txn_active; typedef struct __db_txn_active DB_TXN_ACTIVE;
1N/Astruct __db_txn_stat; typedef struct __db_txn_stat DB_TXN_STAT;
1N/Astruct __db_txnmgr; typedef struct __db_txnmgr DB_TXNMGR;
1N/Astruct __db_txnregion; typedef struct __db_txnregion DB_TXNREGION;
1N/Astruct __dbc; typedef struct __dbc DBC;
1N/A
1N/A/* Key/data structure -- a Data-Base Thang. */
1N/Astruct __db_dbt {
1N/A void *data; /* key/data */
1N/A u_int32_t size; /* key/data length */
1N/A u_int32_t ulen; /* RO: length of user buffer. */
1N/A u_int32_t dlen; /* RO: get/put record length. */
1N/A u_int32_t doff; /* RO: get/put record offset. */
1N/A
1N/A#define DB_DBT_INTERNAL 0x01 /* Ignore user's malloc (internal). */
1N/A#define DB_DBT_MALLOC 0x02 /* Return in allocated memory. */
1N/A#define DB_DBT_PARTIAL 0x04 /* Partial put/get. */
1N/A#define DB_DBT_USERMEM 0x08 /* Return in user's memory. */
1N/A u_int32_t flags;
1N/A};
1N/A
1N/A/*
1N/A * DB run-time interface configuration.
1N/A *
1N/A * There are a set of functions that the application can replace with its
1N/A * own versions, and some other knobs which can be turned at run-time.
1N/A */
1N/A#define DB_FUNC_CLOSE 1 /* POSIX 1003.1 close. */
1N/A#define DB_FUNC_DIRFREE 2 /* DB: free directory list. */
1N/A#define DB_FUNC_DIRLIST 3 /* DB: create directory list. */
1N/A#define DB_FUNC_EXISTS 4 /* DB: return if file exists. */
1N/A#define DB_FUNC_FREE 5 /* ANSI C free. */
1N/A#define DB_FUNC_FSYNC 6 /* POSIX 1003.1 fsync. */
1N/A#define DB_FUNC_IOINFO 7 /* DB: return file I/O information. */
1N/A#define DB_FUNC_MALLOC 8 /* ANSI C malloc. */
1N/A#define DB_FUNC_MAP 9 /* DB: map file into shared memory. */
1N/A#define DB_FUNC_OPEN 10 /* POSIX 1003.1 open. */
1N/A#define DB_FUNC_READ 11 /* POSIX 1003.1 read. */
1N/A#define DB_FUNC_REALLOC 12 /* ANSI C realloc. */
1N/A#define DB_FUNC_RUNLINK 13 /* DB: remove a shared region. */
1N/A#define DB_FUNC_SEEK 14 /* POSIX 1003.1 lseek. */
1N/A#define DB_FUNC_SLEEP 15 /* DB: sleep secs/usecs. */
1N/A#define DB_FUNC_UNLINK 16 /* POSIX 1003.1 unlink. */
1N/A#define DB_FUNC_UNMAP 17 /* DB: unmap shared memory file. */
1N/A#define DB_FUNC_WRITE 18 /* POSIX 1003.1 write. */
1N/A#define DB_FUNC_YIELD 19 /* DB: yield thread to scheduler. */
1N/A#define DB_MUTEXLOCKS 20 /* DB: turn off all mutex locks. */
1N/A#define DB_PAGEYIELD 21 /* DB: yield the CPU on pool get. */
1N/A#define DB_REGION_ANON 22 /* DB: anonymous, unnamed regions. */
1N/A#define DB_REGION_INIT 23 /* DB: page-fault regions in create. */
1N/A#define DB_REGION_NAME 24 /* DB: anonymous, named regions. */
1N/A#define DB_TSL_SPINS 25 /* DB: initialize spin count. */
1N/A
1N/A/*
1N/A * Database configuration and initialization.
1N/A */
1N/A /*
1N/A * Flags understood by both db_open(3) and db_appinit(3).
1N/A */
1N/A#define DB_CREATE 0x000001 /* O_CREAT: create file as necessary. */
1N/A#define DB_NOMMAP 0x000002 /* Don't mmap underlying file. */
1N/A#define DB_THREAD 0x000004 /* Free-thread DB package handles. */
1N/A
1N/A/*
1N/A * Flags understood by db_appinit(3).
1N/A */
1N/A/* 0x000007 COMMON MASK. */
1N/A#define DB_INIT_CDB 0x000008 /* Concurrent Access Methods. */
1N/A#define DB_INIT_LOCK 0x000010 /* Initialize locking. */
1N/A#define DB_INIT_LOG 0x000020 /* Initialize logging. */
1N/A#define DB_INIT_MPOOL 0x000040 /* Initialize mpool. */
1N/A#define DB_INIT_TXN 0x000080 /* Initialize transactions. */
1N/A#define DB_MPOOL_PRIVATE 0x000100 /* Mpool: private memory pool. */
1N/A#define DB_RECOVER 0x000200 /* Run normal recovery. */
1N/A#define DB_RECOVER_FATAL 0x000400 /* Run catastrophic recovery. */
1N/A#define DB_TXN_NOSYNC 0x000800 /* Do not sync log on commit. */
1N/A#define DB_USE_ENVIRON 0x001000 /* Use the environment. */
1N/A#define DB_USE_ENVIRON_ROOT 0x002000 /* Use the environment if root. */
1N/A
1N/A/*
1N/A * Flags understood by db_open(3).
1N/A *
1N/A * DB_EXCL and DB_TEMPORARY are internal only, and are not documented.
1N/A * DB_SEQUENTIAL is currently internal, but may be exported some day.
1N/A */
1N/A/* 0x000007 COMMON MASK. */
1N/A/* 0x001fff ALREADY USED. */
1N/A#define DB_EXCL 0x002000 /* O_EXCL: exclusive open (internal). */
1N/A#define DB_RDONLY 0x004000 /* O_RDONLY: read-only. */
1N/A#define DB_SEQUENTIAL 0x008000 /* Sequential access (internal). */
1N/A#define DB_TEMPORARY 0x010000 /* Remove on last close (internal). */
1N/A#define DB_TRUNCATE 0x020000 /* O_TRUNCATE: replace existing DB. */
1N/A#define DB_FCNTL_LOCKING 0x040000 /* Undocumented: fcntl(2) locking. */
1N/A
1N/A/*
1N/A * Deadlock detector modes; used in the DBENV structure to configure the
1N/A * locking subsystem.
1N/A */
1N/A#define DB_LOCK_NORUN 0
1N/A#define DB_LOCK_DEFAULT 1 /* Default policy. */
1N/A#define DB_LOCK_OLDEST 2 /* Abort oldest transaction. */
1N/A#define DB_LOCK_RANDOM 3 /* Abort random transaction. */
1N/A#define DB_LOCK_YOUNGEST 4 /* Abort youngest transaction. */
1N/A
1N/Astruct __db_env {
1N/A int db_lorder; /* Byte order. */
1N/A
1N/A /* Error message callback. */
1N/A void (*db_errcall) __P((const char *, char *));
1N/A FILE *db_errfile; /* Error message file stream. */
1N/A const char *db_errpfx; /* Error message prefix. */
1N/A int db_verbose; /* Generate debugging messages. */
1N/A int db_panic; /* Panic flag, callback function. */
1N/A void (*db_paniccall) __P((DB_ENV *, int));
1N/A
1N/A /* User paths. */
1N/A char *db_home; /* Database home. */
1N/A char *db_log_dir; /* Database log file directory. */
1N/A char *db_tmp_dir; /* Database tmp file directory. */
1N/A
1N/A char **db_data_dir; /* Database data file directories. */
1N/A int data_cnt; /* Database data file slots. */
1N/A int data_next; /* Next Database data file slot. */
1N/A
1N/A /* Locking. */
1N/A DB_LOCKTAB *lk_info; /* Return from lock_open(). */
1N/A const u_int8_t *lk_conflicts; /* Two dimensional conflict matrix. */
1N/A u_int32_t lk_modes; /* Number of lock modes in table. */
1N/A u_int32_t lk_max; /* Maximum number of locks. */
1N/A u_int32_t lk_detect; /* Deadlock detect on all conflicts. */
1N/A
1N/A /* Logging. */
1N/A DB_LOG *lg_info; /* Return from log_open(). */
1N/A u_int32_t lg_max; /* Maximum file size. */
1N/A
1N/A /* Memory pool. */
1N/A DB_MPOOL *mp_info; /* Return from memp_open(). */
1N/A size_t mp_mmapsize; /* Maximum file size for mmap. */
1N/A size_t mp_size; /* Bytes in the mpool cache. */
1N/A
1N/A /* Transactions. */
1N/A DB_TXNMGR *tx_info; /* Return from txn_open(). */
1N/A u_int32_t tx_max; /* Maximum number of transactions. */
1N/A int (*tx_recover) /* Dispatch function for recovery. */
1N/A __P((DB_LOG *, DBT *, DB_LSN *, int, void *));
1N/A
1N/A /*
1N/A * XA support.
1N/A *
1N/A * !!!
1N/A * Explicit representations of structures in queue.h.
1N/A *
1N/A * TAILQ_ENTRY(__db_env);
1N/A */
1N/A struct {
1N/A struct __db_env *tqe_next;
1N/A struct __db_env **tqe_prev;
1N/A } links;
1N/A int xa_rmid; /* XA Resource Manager ID. */
1N/A DB_TXN *xa_txn; /* XA Current transaction. */
1N/A
1N/A#define DB_ENV_APPINIT 0x01 /* Paths initialized by db_appinit(). */
1N/A#define DB_ENV_CDB 0x02 /* Concurrent DB product. */
1N/A#define DB_ENV_STANDALONE 0x04 /* Test: freestanding environment. */
1N/A#define DB_ENV_THREAD 0x08 /* DB_ENV is multi-threaded. */
1N/A u_int32_t flags; /* Flags. */
1N/A};
1N/A
1N/A/*******************************************************
1N/A * Access methods.
1N/A *******************************************************/
1N/A/*
1N/A * !!!
1N/A * Changes here must be reflected in java/src/com/sleepycat/db/Db.java.
1N/A */
1N/Atypedef enum {
1N/A DB_BTREE=1, /* B+tree. */
1N/A DB_HASH, /* Extended Linear Hashing. */
1N/A DB_RECNO, /* Fixed and variable-length records. */
1N/A DB_UNKNOWN /* Figure it out on open. */
1N/A} DBTYPE;
1N/A
1N/A#define DB_BTREEVERSION 6 /* Current btree version. */
1N/A#define DB_BTREEOLDVER 6 /* Oldest btree version supported. */
1N/A#define DB_BTREEMAGIC 0x053162
1N/A
1N/A#define DB_HASHVERSION 5 /* Current hash version. */
1N/A#define DB_HASHOLDVER 4 /* Oldest hash version supported. */
1N/A#define DB_HASHMAGIC 0x061561
1N/A
1N/A#define DB_LOGVERSION 2 /* Current log version. */
1N/A#define DB_LOGOLDVER 2 /* Oldest log version supported. */
1N/A#define DB_LOGMAGIC 0x040988
1N/A
1N/Astruct __db_info {
1N/A int db_lorder; /* Byte order. */
1N/A size_t db_cachesize; /* Underlying cache size. */
1N/A size_t db_pagesize; /* Underlying page size. */
1N/A
1N/A /* Local heap allocation. */
1N/A void *(*db_malloc) __P((size_t));
1N/A int (*dup_compare) /* Duplicate compare function. */
1N/A __P((const DBT *, const DBT *));
1N/A
1N/A /* Btree access method. */
1N/A u_int32_t bt_maxkey; /* Maximum keys per page. */
1N/A u_int32_t bt_minkey; /* Minimum keys per page. */
1N/A int (*bt_compare) /* Comparison function. */
1N/A __P((const DBT *, const DBT *));
1N/A size_t (*bt_prefix) /* Prefix function. */
1N/A __P((const DBT *, const DBT *));
1N/A
1N/A /* Hash access method. */
1N/A u_int32_t h_ffactor; /* Fill factor. */
1N/A u_int32_t h_nelem; /* Number of elements. */
1N/A u_int32_t (*h_hash) /* Hash function. */
1N/A __P((const void *, u_int32_t));
1N/A
1N/A /* Recno access method. */
1N/A int re_pad; /* Fixed-length padding byte. */
1N/A int re_delim; /* Variable-length delimiting byte. */
1N/A u_int32_t re_len; /* Length for fixed-length records. */
1N/A char *re_source; /* Source file name. */
1N/A
1N/A#define DB_DELIMITER 0x0001 /* Recno: re_delim set. */
1N/A#define DB_DUP 0x0002 /* Btree, Hash: duplicate keys. */
1N/A#define DB_DUPSORT 0x0004 /* Btree, Hash: duplicate keys. */
1N/A#define DB_FIXEDLEN 0x0008 /* Recno: fixed-length records. */
1N/A#define DB_PAD 0x0010 /* Recno: re_pad set. */
1N/A#define DB_RECNUM 0x0020 /* Btree: record numbers. */
1N/A#define DB_RENUMBER 0x0040 /* Recno: renumber on insert/delete. */
1N/A#define DB_SNAPSHOT 0x0080 /* Recno: snapshot the input. */
1N/A u_int32_t flags;
1N/A};
1N/A
1N/A/*
1N/A * DB access method and cursor operation values. Each value is an operation
1N/A * code to which additional bit flags are added.
1N/A */
1N/A#define DB_AFTER 1 /* c_put() */
1N/A#define DB_APPEND 2 /* put() */
1N/A#define DB_BEFORE 3 /* c_put() */
1N/A#define DB_CHECKPOINT 4 /* log_put(), log_get() */
1N/A#define DB_CURLSN 5 /* log_put() */
1N/A#define DB_CURRENT 6 /* c_get(), c_put(), log_get() */
1N/A#define DB_FIRST 7 /* c_get(), log_get() */
1N/A#define DB_FLUSH 8 /* log_put() */
1N/A#define DB_GET_BOTH 9 /* get(), c_get() */
1N/A#define DB_GET_RECNO 10 /* c_get() */
1N/A#define DB_JOIN_ITEM 11 /* c_get(); do not do primary lookup */
1N/A#define DB_KEYFIRST 12 /* c_put() */
1N/A#define DB_KEYLAST 13 /* c_put() */
1N/A#define DB_LAST 14 /* c_get(), log_get() */
1N/A#define DB_NEXT 15 /* c_get(), log_get() */
1N/A#define DB_NEXT_DUP 16 /* c_get() */
1N/A#define DB_NOOVERWRITE 17 /* put() */
1N/A#define DB_NOSYNC 18 /* close() */
1N/A#define DB_PREV 19 /* c_get(), log_get() */
1N/A#define DB_RECORDCOUNT 20 /* stat() */
1N/A#define DB_SET 21 /* c_get(), log_get() */
1N/A#define DB_SET_RANGE 22 /* c_get() */
1N/A#define DB_SET_RECNO 23 /* get(), c_get() */
1N/A#define DB_WRITELOCK 24 /* cursor() (internal) */
1N/A
1N/A#define DB_OPFLAGS_MASK 0x1f /* Mask for operations flags. */
1N/A#define DB_RMW 0x80000000 /* Acquire write flag immediately. */
1N/A
1N/A/*
1N/A * DB (user visible) error return codes.
1N/A *
1N/A * !!!
1N/A * Changes to any of the user visible error return codes must be reflected
1N/A * in java/src/com/sleepycat/db/Db.java.
1N/A */
1N/A#define DB_INCOMPLETE ( -1) /* Sync didn't finish. */
1N/A#define DB_KEYEMPTY ( -2) /* The key/data pair was deleted or
1N/A was never created by the user. */
1N/A#define DB_KEYEXIST ( -3) /* The key/data pair already exists. */
1N/A#define DB_LOCK_DEADLOCK ( -4) /* Locker killed to resolve deadlock. */
1N/A#define DB_LOCK_NOTGRANTED ( -5) /* Lock unavailable, no-wait set. */
1N/A#define DB_LOCK_NOTHELD ( -6) /* Lock not held by locker. */
1N/A#define DB_NOTFOUND ( -7) /* Key/data pair not found (EOF). */
1N/A#define DB_RUNRECOVERY ( -8) /* Panic return. */
1N/A
1N/A/* DB (private) error return codes. */
1N/A#define DB_DELETED ( -9) /* Recovery file marked deleted. */
1N/A#define DB_NEEDSPLIT (-10) /* Page needs to be split. */
1N/A#define DB_SWAPBYTES (-11) /* Database needs byte swapping. */
1N/A#define DB_TXN_CKP (-12) /* Encountered ckp record in log. */
1N/A
1N/A#define DB_FILE_ID_LEN 20 /* DB file ID length. */
1N/A
1N/A/* DB access method description structure. */
1N/Astruct __db {
1N/A void *mutexp; /* Synchronization for free threading */
1N/A
1N/A /* Documented, returned information. */
1N/A DBTYPE type; /* DB access method. */
1N/A int byteswapped; /* Database byte order is swapped. */
1N/A int saved_open_fd; /* For fcntl lock preservation. */
1N/A
1N/A DB_ENV *dbenv; /* DB_ENV structure. */
1N/A DB_ENV *mp_dbenv; /* DB_ENV for local mpool creation. */
1N/A
1N/A void *internal; /* Access method private. */
1N/A
1N/A DB_MPOOL *mp; /* The access method's mpool. */
1N/A DB_MPOOLFILE *mpf; /* The access method's mpool file. */
1N/A
1N/A /*
1N/A * !!!
1N/A * Explicit representations of structures in queue.h.
1N/A *
1N/A * TAILQ_HEAD(free_queue, __dbc);
1N/A * TAILQ_HEAD(active_queue, __dbc);
1N/A */
1N/A struct {
1N/A struct __dbc *tqh_first;
1N/A struct __dbc **tqh_last;
1N/A } free_queue;
1N/A struct {
1N/A struct __dbc *tqh_first;
1N/A struct __dbc **tqh_last;
1N/A } active_queue;
1N/A
1N/A u_int8_t fileid[DB_FILE_ID_LEN]; /* Uniquely identify this file for
1N/A locking. */
1N/A u_int32_t log_fileid; /* Logging file id. */
1N/A size_t pgsize; /* Logical page size of file. */
1N/A
1N/A /* Local heap allocation. */
1N/A void *(*db_malloc) __P((size_t));
1N/A int (*dup_compare) /* Duplicate compare function. */
1N/A __P((const DBT *, const DBT *));
1N/A u_int32_t (*h_hash) /* Hash function. */
1N/A __P((const void *, u_int32_t));
1N/A
1N/A /* Functions. */
1N/A int (*am_close) __P((DB *));
1N/A int (*close) __P((DB *, u_int32_t));
1N/A int (*cursor) __P((DB *, DB_TXN *, DBC **, u_int32_t));
1N/A int (*del) __P((DB *, DB_TXN *, DBT *, u_int32_t));
1N/A int (*fd) __P((DB *, int *));
1N/A int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
1N/A int (*join) __P((DB *, DBC **, u_int32_t, DBC **));
1N/A int (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
1N/A int (*stat) __P((DB *, void *, void *(*)(size_t), u_int32_t));
1N/A int (*sync) __P((DB *, u_int32_t));
1N/A
1N/A#define DB_AM_CDB 0x000001 /* Concurrent Access Methods. */
1N/A#define DB_AM_DUP 0x000002 /* DB_DUP (internal). */
1N/A#define DB_AM_INMEM 0x000004 /* In-memory; no sync on close. */
1N/A#define DB_AM_LOCKING 0x000008 /* Perform locking. */
1N/A#define DB_AM_LOGGING 0x000010 /* Perform logging. */
1N/A#define DB_AM_MLOCAL 0x000020 /* Database memory pool is local. */
1N/A#define DB_AM_PGDEF 0x000040 /* Page size was defaulted. */
1N/A#define DB_AM_RDONLY 0x000080 /* Database is readonly. */
1N/A#define DB_AM_SWAP 0x000100 /* Pages need to be byte-swapped. */
1N/A#define DB_AM_THREAD 0x000200 /* DB is multi-threaded. */
1N/A#define DB_BT_RECNUM 0x000400 /* DB_RECNUM (internal). */
1N/A#define DB_DBM_ERROR 0x000800 /* Error in DBM/NDBM database. */
1N/A#define DB_RE_DELIMITER 0x001000 /* DB_DELIMITER (internal). */
1N/A#define DB_RE_FIXEDLEN 0x002000 /* DB_FIXEDLEN (internal). */
1N/A#define DB_RE_PAD 0x004000 /* DB_PAD (internal). */
1N/A#define DB_RE_RENUMBER 0x008000 /* DB_RENUMBER (internal). */
1N/A#define DB_RE_SNAPSHOT 0x010000 /* DB_SNAPSHOT (internal). */
1N/A u_int32_t flags;
1N/A};
1N/A
1N/Astruct __db_ilock { /* Internal DB access method lock. */
1N/A db_pgno_t pgno; /* Page being locked. */
1N/A u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */
1N/A};
1N/A
1N/A/* Cursor description structure. */
1N/Astruct __dbc {
1N/A DB *dbp; /* Related DB access method. */
1N/A DB_TXN *txn; /* Associated transaction. */
1N/A
1N/A /*
1N/A * !!!
1N/A * Explicit representations of structures in queue.h.
1N/A *
1N/A * TAILQ_ENTRY(__dbc);
1N/A */
1N/A struct {
1N/A struct __dbc *tqe_next;
1N/A struct __dbc **tqe_prev;
1N/A } links;
1N/A
1N/A u_int32_t lid; /* Default process' locker id. */
1N/A u_int32_t locker; /* Locker for this operation. */
1N/A DBT lock_dbt; /* DBT referencing lock. */
1N/A DB_LOCK_ILOCK lock; /* Object to be locked. */
1N/A DB_LOCK mylock; /* Lock held on this cursor. */
1N/A
1N/A DBT rkey; /* Returned key. */
1N/A DBT rdata; /* Returned data. */
1N/A
1N/A int (*c_am_close) __P((DBC *));
1N/A int (*c_am_destroy) __P((DBC *));
1N/A int (*c_close) __P((DBC *));
1N/A int (*c_del) __P((DBC *, u_int32_t));
1N/A int (*c_get) __P((DBC *, DBT *, DBT *, u_int32_t));
1N/A int (*c_put) __P((DBC *, DBT *, DBT *, u_int32_t));
1N/A
1N/A void *internal; /* Access method private. */
1N/A
1N/A#define DBC_CONTINUE 0x001 /* Continue dup search: next item. */
1N/A#define DBC_KEYSET 0x002 /* Continue dup search: current item. */
1N/A#define DBC_RECOVER 0x004 /* In recovery (do not log or lock). */
1N/A#define DBC_RMW 0x008 /* Acquire write flag in read op. */
1N/A#define DBC_WRITER 0x010 /* Cursor immediately writing (CDB). */
1N/A u_int32_t flags;
1N/A};
1N/A
1N/A/* Btree/recno statistics structure. */
1N/Astruct __db_bt_stat {
1N/A u_int32_t bt_flags; /* Open flags. */
1N/A u_int32_t bt_maxkey; /* Maxkey value. */
1N/A u_int32_t bt_minkey; /* Minkey value. */
1N/A u_int32_t bt_re_len; /* Fixed-length record length. */
1N/A u_int32_t bt_re_pad; /* Fixed-length record pad. */
1N/A u_int32_t bt_pagesize; /* Page size. */
1N/A u_int32_t bt_levels; /* Tree levels. */
1N/A u_int32_t bt_nrecs; /* Number of records. */
1N/A u_int32_t bt_int_pg; /* Internal pages. */
1N/A u_int32_t bt_leaf_pg; /* Leaf pages. */
1N/A u_int32_t bt_dup_pg; /* Duplicate pages. */
1N/A u_int32_t bt_over_pg; /* Overflow pages. */
1N/A u_int32_t bt_free; /* Pages on the free list. */
1N/A u_int32_t bt_int_pgfree; /* Bytes free in internal pages. */
1N/A u_int32_t bt_leaf_pgfree; /* Bytes free in leaf pages. */
1N/A u_int32_t bt_dup_pgfree; /* Bytes free in duplicate pages. */
1N/A u_int32_t bt_over_pgfree; /* Bytes free in overflow pages. */
1N/A u_int32_t bt_magic; /* Magic number. */
1N/A u_int32_t bt_version; /* Version number. */
1N/A};
1N/A
1N/A/* Hash statistics structure. */
1N/Astruct __db_h_stat {
1N/A u_int32_t hash_accesses; /* Number of accesses to this table. */
1N/A u_int32_t hash_collisions; /* Number of collisions on search. */
1N/A u_int32_t hash_expansions; /* Number of times we added a bucket. */
1N/A u_int32_t hash_overflows; /* Number of overflow pages. */
1N/A u_int32_t hash_bigpages; /* Number of big key/data pages. */
1N/A u_int32_t hash_dup; /* Number of dup pages. */
1N/A u_int32_t hash_free; /* Pages on the free list. */
1N/A u_int32_t hash_bfree; /* Bytes free on bucket pages. */
1N/A u_int32_t hash_dup_free; /* Bytes free on duplicate pages. */
1N/A u_int32_t hash_big_bfree; /* Bytes free on big item pages. */
1N/A u_int32_t hash_buckets; /* Number of hash buckets. */
1N/A u_int32_t hash_put; /* Number of puts. */
1N/A u_int32_t hash_deleted; /* Number of deletes. */
1N/A u_int32_t hash_get; /* Number of gets. */
1N/A u_int32_t hash_magic; /* Magic number. */
1N/A u_int32_t hash_version; /* Version number. */
1N/A u_int32_t hash_pagesize; /* Page size. */
1N/A u_int32_t hash_nrecs; /* Number of records. */
1N/A};
1N/A
1N/A#if defined(__cplusplus)
1N/Aextern "C" {
1N/A#endif
1N/Aint db_appinit __P((const char *, char * const *, DB_ENV *, u_int32_t));
1N/Aint db_appexit __P((DB_ENV *));
1N/Aint db_jump_set __P((void *, int));
1N/Aint db_open __P((const char *,
1N/A DBTYPE, u_int32_t, int, DB_ENV *, DB_INFO *, DB **));
1N/Aint db_value_set __P((int, int));
1N/Achar *db_version __P((int *, int *, int *));
1N/Aint db_xa_open __P((const char *,
1N/A DBTYPE, u_int32_t, int, DB_INFO *, DB **));
1N/A#if defined(__cplusplus)
1N/A}
1N/A#endif
1N/A
1N/A/*******************************************************
1N/A * Locking
1N/A *******************************************************/
1N/A#define DB_LOCKVERSION 1
1N/A#define DB_LOCKMAGIC 0x090193
1N/A
1N/A/* Flag values for lock_vec(), lock_get(). */
1N/A#define DB_LOCK_NOWAIT 0x01 /* Don't wait on unavailable lock. */
1N/A#define DB_LOCK_UPGRADE 0x02 /* Upgrade an existing lock instead
1N/A of granting a new one (internal). */
1N/A
1N/A/* Flag values for lock_detect(). */
1N/A#define DB_LOCK_CONFLICT 0x01 /* Run on any conflict. */
1N/A
1N/A/*
1N/A * Request types.
1N/A *
1N/A * !!!
1N/A * Changes here must be reflected in java/src/com/sleepycat/db/Db.java.
1N/A */
1N/Atypedef enum {
1N/A DB_LOCK_DUMP=0, /* Display held locks. */
1N/A DB_LOCK_GET, /* Get the lock. */
1N/A DB_LOCK_INHERIT, /* Pass locks to parent. */
1N/A DB_LOCK_PUT, /* Release the lock. */
1N/A DB_LOCK_PUT_ALL, /* Release locker's locks. */
1N/A DB_LOCK_PUT_OBJ /* Release locker's locks on obj. */
1N/A} db_lockop_t;
1N/A
1N/A/*
1N/A * Simple R/W lock modes and for multi-granularity intention locking.
1N/A *
1N/A * !!!
1N/A * These values are NOT random, as they are used as an index into the lock
1N/A * conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD
1N/A * must be == 4.
1N/A *
1N/A * !!!
1N/A * Changes here must be reflected in java/src/com/sleepycat/db/Db.java.
1N/A */
1N/Atypedef enum {
1N/A DB_LOCK_NG=0, /* Not granted. */
1N/A DB_LOCK_READ, /* Shared/read. */
1N/A DB_LOCK_WRITE, /* Exclusive/write. */
1N/A DB_LOCK_IWRITE, /* Intent exclusive/write. */
1N/A DB_LOCK_IREAD, /* Intent to share/read. */
1N/A DB_LOCK_IWR /* Intent to read and write. */
1N/A} db_lockmode_t;
1N/A
1N/A/*
1N/A * Status of a lock.
1N/A */
1N/Atypedef enum {
1N/A DB_LSTAT_ABORTED, /* Lock belongs to an aborted txn. */
1N/A DB_LSTAT_ERR, /* Lock is bad. */
1N/A DB_LSTAT_FREE, /* Lock is unallocated. */
1N/A DB_LSTAT_HELD, /* Lock is currently held. */
1N/A DB_LSTAT_NOGRANT, /* Lock was not granted. */
1N/A DB_LSTAT_PENDING, /* Lock was waiting and has been
1N/A * promoted; waiting for the owner
1N/A * to run and upgrade it to held. */
1N/A DB_LSTAT_WAITING /* Lock is on the wait queue. */
1N/A} db_status_t;
1N/A
1N/A/* Lock request structure. */
1N/Astruct __db_lockreq {
1N/A db_lockop_t op; /* Operation. */
1N/A db_lockmode_t mode; /* Requested mode. */
1N/A u_int32_t locker; /* Locker identity. */
1N/A DBT *obj; /* Object being locked. */
1N/A DB_LOCK lock; /* Lock returned. */
1N/A};
1N/A
1N/A/*
1N/A * Commonly used conflict matrices.
1N/A *
1N/A * Standard Read/Write (or exclusive/shared) locks.
1N/A */
1N/A#define DB_LOCK_RW_N 3
1N/Aextern const u_int8_t db_rw_conflicts[];
1N/A
1N/A/* Multi-granularity locking. */
1N/A#define DB_LOCK_RIW_N 6
1N/Aextern const u_int8_t db_riw_conflicts[];
1N/A
1N/Astruct __db_lock_stat {
1N/A u_int32_t st_magic; /* Lock file magic number. */
1N/A u_int32_t st_version; /* Lock file version number. */
1N/A u_int32_t st_maxlocks; /* Maximum number of locks in table. */
1N/A u_int32_t st_nmodes; /* Number of lock modes. */
1N/A u_int32_t st_numobjs; /* Number of objects. */
1N/A u_int32_t st_nlockers; /* Number of lockers. */
1N/A u_int32_t st_nconflicts; /* Number of lock conflicts. */
1N/A u_int32_t st_nrequests; /* Number of lock gets. */
1N/A u_int32_t st_nreleases; /* Number of lock puts. */
1N/A u_int32_t st_ndeadlocks; /* Number of lock deadlocks. */
1N/A u_int32_t st_region_wait; /* Region lock granted after wait. */
1N/A u_int32_t st_region_nowait; /* Region lock granted without wait. */
1N/A u_int32_t st_refcnt; /* Region reference count. */
1N/A u_int32_t st_regsize; /* Region size. */
1N/A};
1N/A
1N/A#if defined(__cplusplus)
1N/Aextern "C" {
1N/A#endif
1N/Aint lock_close __P((DB_LOCKTAB *));
1N/Aint lock_detect __P((DB_LOCKTAB *, u_int32_t, u_int32_t));
1N/Aint lock_get __P((DB_LOCKTAB *,
1N/A u_int32_t, u_int32_t, const DBT *, db_lockmode_t, DB_LOCK *));
1N/Aint lock_id __P((DB_LOCKTAB *, u_int32_t *));
1N/Aint lock_open __P((const char *,
1N/A u_int32_t, int, DB_ENV *, DB_LOCKTAB **));
1N/Aint lock_put __P((DB_LOCKTAB *, DB_LOCK));
1N/Aint lock_tget __P((DB_LOCKTAB *,
1N/A DB_TXN *, u_int32_t, const DBT *, db_lockmode_t, DB_LOCK *));
1N/Aint lock_stat __P((DB_LOCKTAB *, DB_LOCK_STAT **, void *(*)(size_t)));
1N/Aint lock_unlink __P((const char *, int, DB_ENV *));
1N/Aint lock_vec __P((DB_LOCKTAB *,
1N/A u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **));
1N/Aint lock_tvec __P((DB_LOCKTAB *,
1N/A DB_TXN *, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **));
1N/A#if defined(__cplusplus)
1N/A}
1N/A#endif
1N/A
1N/A/*******************************************************
1N/A * Logging.
1N/A *******************************************************/
1N/A/* Flag values for log_archive(). */
1N/A#define DB_ARCH_ABS 0x001 /* Absolute pathnames. */
1N/A#define DB_ARCH_DATA 0x002 /* Data files. */
1N/A#define DB_ARCH_LOG 0x004 /* Log files. */
1N/A
1N/A/*
1N/A * A DB_LSN has two parts, a fileid which identifies a specific file, and an
1N/A * offset within that file. The fileid is an unsigned 4-byte quantity that
1N/A * uniquely identifies a file within the log directory -- currently a simple
1N/A * counter inside the log. The offset is also an unsigned 4-byte value. The
1N/A * log manager guarantees the offset is never more than 4 bytes by switching
1N/A * to a new log file before the maximum length imposed by an unsigned 4-byte
1N/A * offset is reached.
1N/A */
1N/Astruct __db_lsn {
1N/A u_int32_t file; /* File ID. */
1N/A u_int32_t offset; /* File offset. */
1N/A};
1N/A
1N/A/* Log statistics structure. */
1N/Astruct __db_log_stat {
1N/A u_int32_t st_magic; /* Log file magic number. */
1N/A u_int32_t st_version; /* Log file version number. */
1N/A int st_mode; /* Log file mode. */
1N/A u_int32_t st_lg_max; /* Maximum log file size. */
1N/A u_int32_t st_w_bytes; /* Bytes to log. */
1N/A u_int32_t st_w_mbytes; /* Megabytes to log. */
1N/A u_int32_t st_wc_bytes; /* Bytes to log since checkpoint. */
1N/A u_int32_t st_wc_mbytes; /* Megabytes to log since checkpoint. */
1N/A u_int32_t st_wcount; /* Total syncs to the log. */
1N/A u_int32_t st_scount; /* Total writes to the log. */
1N/A u_int32_t st_region_wait; /* Region lock granted after wait. */
1N/A u_int32_t st_region_nowait; /* Region lock granted without wait. */
1N/A u_int32_t st_cur_file; /* Current log file number. */
1N/A u_int32_t st_cur_offset; /* Current log file offset. */
1N/A u_int32_t st_refcnt; /* Region reference count. */
1N/A u_int32_t st_regsize; /* Region size. */
1N/A};
1N/A
1N/A#if defined(__cplusplus)
1N/Aextern "C" {
1N/A#endif
1N/Aint log_archive __P((DB_LOG *, char **[], u_int32_t, void *(*)(size_t)));
1N/Aint log_close __P((DB_LOG *));
1N/Aint log_compare __P((const DB_LSN *, const DB_LSN *));
1N/Aint log_file __P((DB_LOG *, const DB_LSN *, char *, size_t));
1N/Aint log_flush __P((DB_LOG *, const DB_LSN *));
1N/Aint log_get __P((DB_LOG *, DB_LSN *, DBT *, u_int32_t));
1N/Aint log_open __P((const char *, u_int32_t, int, DB_ENV *, DB_LOG **));
1N/Aint log_put __P((DB_LOG *, DB_LSN *, const DBT *, u_int32_t));
1N/Aint log_register __P((DB_LOG *, DB *, const char *, DBTYPE, u_int32_t *));
1N/Aint log_stat __P((DB_LOG *, DB_LOG_STAT **, void *(*)(size_t)));
1N/Aint log_unlink __P((const char *, int, DB_ENV *));
1N/Aint log_unregister __P((DB_LOG *, u_int32_t));
1N/A#if defined(__cplusplus)
1N/A}
1N/A#endif
1N/A
1N/A/*******************************************************
1N/A * Mpool
1N/A *******************************************************/
1N/A/* Flag values for memp_fget(). */
1N/A#define DB_MPOOL_CREATE 0x001 /* Create a page. */
1N/A#define DB_MPOOL_LAST 0x002 /* Return the last page. */
1N/A#define DB_MPOOL_NEW 0x004 /* Create a new page. */
1N/A
1N/A/* Flag values for memp_fput(), memp_fset(). */
1N/A#define DB_MPOOL_CLEAN 0x001 /* Clear modified bit. */
1N/A#define DB_MPOOL_DIRTY 0x002 /* Page is modified. */
1N/A#define DB_MPOOL_DISCARD 0x004 /* Don't cache the page. */
1N/A
1N/A/* Mpool statistics structure. */
1N/Astruct __db_mpool_stat {
1N/A size_t st_cachesize; /* Cache size. */
1N/A u_int32_t st_cache_hit; /* Pages found in the cache. */
1N/A u_int32_t st_cache_miss; /* Pages not found in the cache. */
1N/A u_int32_t st_map; /* Pages from mapped files. */
1N/A u_int32_t st_page_create; /* Pages created in the cache. */
1N/A u_int32_t st_page_in; /* Pages read in. */
1N/A u_int32_t st_page_out; /* Pages written out. */
1N/A u_int32_t st_ro_evict; /* Clean pages forced from the cache. */
1N/A u_int32_t st_rw_evict; /* Dirty pages forced from the cache. */
1N/A u_int32_t st_hash_buckets; /* Number of hash buckets. */
1N/A u_int32_t st_hash_searches; /* Total hash chain searches. */
1N/A u_int32_t st_hash_longest; /* Longest hash chain searched. */
1N/A u_int32_t st_hash_examined; /* Total hash entries searched. */
1N/A u_int32_t st_page_clean; /* Clean pages. */
1N/A u_int32_t st_page_dirty; /* Dirty pages. */
1N/A u_int32_t st_page_trickle; /* Pages written by memp_trickle. */
1N/A u_int32_t st_region_wait; /* Region lock granted after wait. */
1N/A u_int32_t st_region_nowait; /* Region lock granted without wait. */
1N/A u_int32_t st_refcnt; /* Region reference count. */
1N/A u_int32_t st_regsize; /* Region size. */
1N/A};
1N/A
1N/A/* Mpool file open information structure. */
1N/Astruct __db_mpool_finfo {
1N/A int ftype; /* File type. */
1N/A DBT *pgcookie; /* Byte-string passed to pgin/pgout. */
1N/A u_int8_t *fileid; /* Unique file ID. */
1N/A int32_t lsn_offset; /* LSN offset in page. */
1N/A u_int32_t clear_len; /* Cleared length on created pages. */
1N/A};
1N/A
1N/A/* Mpool file statistics structure. */
1N/Astruct __db_mpool_fstat {
1N/A char *file_name; /* File name. */
1N/A size_t st_pagesize; /* Page size. */
1N/A u_int32_t st_cache_hit; /* Pages found in the cache. */
1N/A u_int32_t st_cache_miss; /* Pages not found in the cache. */
1N/A u_int32_t st_map; /* Pages from mapped files. */
1N/A u_int32_t st_page_create; /* Pages created in the cache. */
1N/A u_int32_t st_page_in; /* Pages read in. */
1N/A u_int32_t st_page_out; /* Pages written out. */
1N/A};
1N/A
1N/A#if defined(__cplusplus)
1N/Aextern "C" {
1N/A#endif
1N/Aint memp_close __P((DB_MPOOL *));
1N/Aint memp_fclose __P((DB_MPOOLFILE *));
1N/Aint memp_fget __P((DB_MPOOLFILE *, db_pgno_t *, u_int32_t, void *));
1N/Aint memp_fopen __P((DB_MPOOL *, const char *,
1N/A u_int32_t, int, size_t, DB_MPOOL_FINFO *, DB_MPOOLFILE **));
1N/Aint memp_fput __P((DB_MPOOLFILE *, void *, u_int32_t));
1N/Aint memp_fset __P((DB_MPOOLFILE *, void *, u_int32_t));
1N/Aint memp_fsync __P((DB_MPOOLFILE *));
1N/Aint memp_open __P((const char *, u_int32_t, int, DB_ENV *, DB_MPOOL **));
1N/Aint memp_register __P((DB_MPOOL *, int,
1N/A int (*)(db_pgno_t, void *, DBT *),
1N/A int (*)(db_pgno_t, void *, DBT *)));
1N/Aint memp_stat __P((DB_MPOOL *,
1N/A DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, void *(*)(size_t)));
1N/Aint memp_sync __P((DB_MPOOL *, DB_LSN *));
1N/Aint memp_trickle __P((DB_MPOOL *, int, int *));
1N/Aint memp_unlink __P((const char *, int, DB_ENV *));
1N/A#if defined(__cplusplus)
1N/A}
1N/A#endif
1N/A
1N/A/*******************************************************
1N/A * Transactions.
1N/A *******************************************************/
1N/A#define DB_TXNVERSION 1
1N/A#define DB_TXNMAGIC 0x041593
1N/A
1N/A/* Operations values to the tx_recover() function. */
1N/A#define DB_TXN_BACKWARD_ROLL 1 /* Read the log backwards. */
1N/A#define DB_TXN_FORWARD_ROLL 2 /* Read the log forwards. */
1N/A#define DB_TXN_OPENFILES 3 /* Read for open files. */
1N/A#define DB_TXN_REDO 4 /* Redo the operation. */
1N/A#define DB_TXN_UNDO 5 /* Undo the operation. */
1N/A
1N/A/* Internal transaction status values. */
1N/A
1N/A/* Transaction statistics structure. */
1N/Astruct __db_txn_active {
1N/A u_int32_t txnid; /* Transaction ID */
1N/A DB_LSN lsn; /* Lsn of the begin record */
1N/A};
1N/A
1N/Astruct __db_txn_stat {
1N/A DB_LSN st_last_ckp; /* lsn of the last checkpoint */
1N/A DB_LSN st_pending_ckp; /* last checkpoint did not finish */
1N/A time_t st_time_ckp; /* time of last checkpoint */
1N/A u_int32_t st_last_txnid; /* last transaction id given out */
1N/A u_int32_t st_maxtxns; /* maximum number of active txns */
1N/A u_int32_t st_naborts; /* number of aborted transactions */
1N/A u_int32_t st_nbegins; /* number of begun transactions */
1N/A u_int32_t st_ncommits; /* number of committed transactions */
1N/A u_int32_t st_nactive; /* number of active transactions */
1N/A DB_TXN_ACTIVE
1N/A *st_txnarray; /* array of active transactions */
1N/A u_int32_t st_region_wait; /* Region lock granted after wait. */
1N/A u_int32_t st_region_nowait; /* Region lock granted without wait. */
1N/A u_int32_t st_refcnt; /* Region reference count. */
1N/A u_int32_t st_regsize; /* Region size. */
1N/A};
1N/A
1N/A#if defined(__cplusplus)
1N/Aextern "C" {
1N/A#endif
1N/Aint txn_abort __P((DB_TXN *));
1N/Aint txn_begin __P((DB_TXNMGR *, DB_TXN *, DB_TXN **));
1N/Aint txn_checkpoint __P((const DB_TXNMGR *, u_int32_t, u_int32_t));
1N/Aint txn_commit __P((DB_TXN *));
1N/Aint txn_close __P((DB_TXNMGR *));
1N/Au_int32_t txn_id __P((DB_TXN *));
1N/Aint txn_open __P((const char *, u_int32_t, int, DB_ENV *, DB_TXNMGR **));
1N/Aint txn_prepare __P((DB_TXN *));
1N/Aint txn_stat __P((DB_TXNMGR *, DB_TXN_STAT **, void *(*)(size_t)));
1N/Aint txn_unlink __P((const char *, int, DB_ENV *));
1N/A#if defined(__cplusplus)
1N/A}
1N/A#endif
1N/A
1N/A#ifndef DB_DBM_HSEARCH
1N/A#define DB_DBM_HSEARCH 0 /* No historic interfaces by default. */
1N/A#endif
1N/A#if DB_DBM_HSEARCH != 0
1N/A/*******************************************************
1N/A * Dbm/Ndbm historic interfaces.
1N/A *******************************************************/
1N/A#define DBM_INSERT 0 /* Flags to dbm_store(). */
1N/A#define DBM_REPLACE 1
1N/A
1N/A/*
1N/A * The db(3) support for ndbm(3) always appends this suffix to the
1N/A * file name to avoid overwriting the user's original database.
1N/A */
1N/A#define DBM_SUFFIX ".db"
1N/A
1N/Atypedef struct {
1N/A void *dptr;
1N/A size_t dsize;
1N/A} datum;
1N/A
1N/A/*
1N/A * Translate DBM calls into DB calls so that DB doesn't step on the
1N/A * application's name space.
1N/A *
1N/A * The global variables dbrdonly, dirf and pagf were not retained when
1N/A * 4BSD replaced the dbm interface with ndbm, and are not support here.
1N/A */
1N/A#define dbminit(a) __db_dbm_init(a)
1N/A#define dbmclose __db_dbm_close
1N/A#if !defined(__cplusplus)
1N/A#define delete(a) __db_dbm_delete(a)
1N/A#endif
1N/A#define fetch(a) __db_dbm_fetch(a)
1N/A#define firstkey __db_dbm_firstkey
1N/A#define nextkey(a) __db_dbm_nextkey(a)
1N/A#define store(a, b) __db_dbm_store(a, b)
1N/A
1N/A/* Prototype the DB calls. */
1N/A#if defined(__cplusplus)
1N/Aextern "C" {
1N/A#endif
1N/Aint __db_dbm_close __P((void));
1N/Aint __db_dbm_dbrdonly __P((void));
1N/Aint __db_dbm_delete __P((datum));
1N/Aint __db_dbm_dirf __P((void));
1N/Adatum __db_dbm_fetch __P((datum));
1N/Adatum __db_dbm_firstkey __P((void));
1N/Aint __db_dbm_init __P((char *));
1N/Adatum __db_dbm_nextkey __P((datum));
1N/Aint __db_dbm_pagf __P((void));
1N/Aint __db_dbm_store __P((datum, datum));
1N/A#if defined(__cplusplus)
1N/A}
1N/A#endif
1N/A
1N/A/*
1N/A * Translate NDBM calls into DB calls so that DB doesn't step on the
1N/A * application's name space.
1N/A */
1N/A#define dbm_clearerr(a) __db_ndbm_clearerr(a)
1N/A#define dbm_close(a) __db_ndbm_close(a)
1N/A#define dbm_delete(a, b) __db_ndbm_delete(a, b)
1N/A#define dbm_dirfno(a) __db_ndbm_dirfno(a)
1N/A#define dbm_error(a) __db_ndbm_error(a)
1N/A#define dbm_fetch(a, b) __db_ndbm_fetch(a, b)
1N/A#define dbm_firstkey(a) __db_ndbm_firstkey(a)
1N/A#define dbm_nextkey(a) __db_ndbm_nextkey(a)
1N/A#define dbm_open(a, b, c) __db_ndbm_open(a, b, c)
1N/A#define dbm_pagfno(a) __db_ndbm_pagfno(a)
1N/A#define dbm_rdonly(a) __db_ndbm_rdonly(a)
1N/A#define dbm_store(a, b, c, d) __db_ndbm_store(a, b, c, d)
1N/A
1N/A/* Prototype the DB calls. */
1N/A#if defined(__cplusplus)
1N/Aextern "C" {
1N/A#endif
1N/Aint __db_ndbm_clearerr __P((DBM *));
1N/Avoid __db_ndbm_close __P((DBM *));
1N/Aint __db_ndbm_delete __P((DBM *, datum));
1N/Aint __db_ndbm_dirfno __P((DBM *));
1N/Aint __db_ndbm_error __P((DBM *));
1N/Adatum __db_ndbm_fetch __P((DBM *, datum));
1N/Adatum __db_ndbm_firstkey __P((DBM *));
1N/Adatum __db_ndbm_nextkey __P((DBM *));
1N/ADBM *__db_ndbm_open __P((const char *, int, int));
1N/Aint __db_ndbm_pagfno __P((DBM *));
1N/Aint __db_ndbm_rdonly __P((DBM *));
1N/Aint __db_ndbm_store __P((DBM *, datum, datum, int));
1N/A#if defined(__cplusplus)
1N/A}
1N/A#endif
1N/A
1N/A/*******************************************************
1N/A * Hsearch historic interface.
1N/A *******************************************************/
1N/Atypedef enum {
1N/A FIND, ENTER
1N/A} ACTION;
1N/A
1N/Atypedef struct entry {
1N/A char *key;
1N/A char *data;
1N/A} ENTRY;
1N/A
1N/A/*
1N/A * Translate HSEARCH calls into DB calls so that DB doesn't step on the
1N/A * application's name space.
1N/A */
1N/A#define hcreate(a) __db_hcreate(a)
1N/A#define hdestroy __db_hdestroy
1N/A#define hsearch(a, b) __db_hsearch(a, b)
1N/A
1N/A/* Prototype the DB calls. */
1N/A#if defined(__cplusplus)
1N/Aextern "C" {
1N/A#endif
1N/Aint __db_hcreate __P((size_t));
1N/Avoid __db_hdestroy __P((void));
1N/AENTRY *__db_hsearch __P((ENTRY, ACTION));
1N/A#if defined(__cplusplus)
1N/A}
1N/A#endif
1N/A#endif /* DB_DBM_HSEARCH */
1N/A
1N/A/*
1N/A * XXX
1N/A * MacOS: Reset Metrowerks C enum sizes.
1N/A */
1N/A#ifdef __MWERKS__
1N/A#pragma enumsalwaysint reset
1N/A#endif
1N/A#endif /* !_DB_H_ */