db.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*
* @(#)db.h 10.174 (Sleepycat) 1/3/99
*/
#ifndef _DB_H_
#define _DB_H_
#ifndef __NO_SYSTEM_INCLUDES
#include <stdio.h>
#endif
/*
* XXX
* MacOS: ensure that Metrowerks C makes enumeration types int sized.
*/
#ifdef __MWERKS__
#pragma enumsalwaysint on
#endif
/*
* XXX
* Handle function prototypes and the keyword "const". This steps on name
* space that DB doesn't control, but all of the other solutions are worse.
*
* XXX
* While Microsoft's compiler is ANSI C compliant, it doesn't have _STDC_
* defined by default, you specify a command line flag or #pragma to turn
* it on. Don't do that, however, because some of Microsoft's own header
* files won't compile.
*/
#else
#define const
#endif
/*
* !!!
* DB needs basic information about specifically sized types. If they're
* not provided by the system, typedef them here.
*
* We protect them against multiple inclusion using __BIT_TYPES_DEFINED__,
* as does BIND and Kerberos, since we don't know for sure what #include
* files the user is using.
*
* !!!
* We also provide the standard u_int, u_long etc., if they're not provided
* by the system.
*/
#ifndef __BIT_TYPES_DEFINED__
#define __BIT_TYPES_DEFINED__
typedef unsigned char u_int8_t;
typedef unsigned short u_int16_t;
typedef unsigned int u_int32_t;
#endif
#define DB_VERSION_MAJOR 2
#define DB_VERSION_MINOR 7
#define DB_VERSION_PATCH 7
#define DB_VERSION_STRING "Sleepycat Software: Berkeley DB 2.7.7: (08/20/99)"
/* Forward structure declarations, so applications get type checking. */
#ifdef DB_DBM_HSEARCH
#endif
struct __db_dbt {
};
/*
* DB run-time interface configuration.
*
* There are a set of functions that the application can replace with its
* own versions, and some other knobs which can be turned at run-time.
*/
/*
* Database configuration and initialization.
*/
/*
* Flags understood by both db_open(3) and db_appinit(3).
*/
/*
* Flags understood by db_appinit(3).
*/
/* 0x000007 COMMON MASK. */
/*
* Flags understood by db_open(3).
*
* DB_EXCL and DB_TEMPORARY are internal only, and are not documented.
* DB_SEQUENTIAL is currently internal, but may be exported some day.
*/
/* 0x000007 COMMON MASK. */
/* 0x001fff ALREADY USED. */
/*
* Deadlock detector modes; used in the DBENV structure to configure the
* locking subsystem.
*/
#define DB_LOCK_NORUN 0
struct __db_env {
int db_lorder; /* Byte order. */
/* Error message callback. */
void (*db_errcall) __P((const char *, char *));
const char *db_errpfx; /* Error message prefix. */
int db_verbose; /* Generate debugging messages. */
int db_panic; /* Panic flag, callback function. */
/* User paths. */
char *db_home; /* Database home. */
char *db_log_dir; /* Database log file directory. */
char *db_tmp_dir; /* Database tmp file directory. */
char **db_data_dir; /* Database data file directories. */
int data_cnt; /* Database data file slots. */
int data_next; /* Next Database data file slot. */
/* Locking. */
/* Logging. */
/* Memory pool. */
/* Transactions. */
int (*tx_recover) /* Dispatch function for recovery. */
/*
* XA support.
*
* !!!
* Explicit representations of structures in queue.h.
*
* TAILQ_ENTRY(__db_env);
*/
struct {
} links;
int xa_rmid; /* XA Resource Manager ID. */
};
/*******************************************************
* Access methods.
*******************************************************/
/*
* !!!
*/
typedef enum {
DB_HASH, /* Extended Linear Hashing. */
DB_RECNO, /* Fixed and variable-length records. */
DB_UNKNOWN /* Figure it out on open. */
} DBTYPE;
#define DB_BTREEMAGIC 0x053162
#define DB_HASHMAGIC 0x061561
#define DB_LOGMAGIC 0x040988
struct __db_info {
int db_lorder; /* Byte order. */
/* Local heap allocation. */
int (*dup_compare) /* Duplicate compare function. */
/* Btree access method. */
int (*bt_compare) /* Comparison function. */
/* Hash access method. */
/* Recno access method. */
int re_pad; /* Fixed-length padding byte. */
int re_delim; /* Variable-length delimiting byte. */
char *re_source; /* Source file name. */
};
/*
* DB access method and cursor operation values. Each value is an operation
* code to which additional bit flags are added.
*/
/*
* DB (user visible) error return codes.
*
* !!!
* Changes to any of the user visible error return codes must be reflected
*/
was never created by the user. */
/* DB (private) error return codes. */
/* DB access method description structure. */
struct __db {
void *mutexp; /* Synchronization for free threading */
/* Documented, returned information. */
int byteswapped; /* Database byte order is swapped. */
int saved_open_fd; /* For fcntl lock preservation. */
void *internal; /* Access method private. */
/*
* !!!
* Explicit representations of structures in queue.h.
*
* TAILQ_HEAD(free_queue, __dbc);
* TAILQ_HEAD(active_queue, __dbc);
*/
struct {
} free_queue;
struct {
} active_queue;
locking. */
/* Local heap allocation. */
int (*dup_compare) /* Duplicate compare function. */
/* Functions. */
};
struct __db_ilock { /* Internal DB access method lock. */
};
/* Cursor description structure. */
struct __dbc {
/*
* !!!
* Explicit representations of structures in queue.h.
*
* TAILQ_ENTRY(__dbc);
*/
struct {
} links;
void *internal; /* Access method private. */
};
struct __db_bt_stat {
};
/* Hash statistics structure. */
struct __db_h_stat {
};
#if defined(__cplusplus)
extern "C" {
#endif
int db_jump_set __P((void *, int));
int db_value_set __P((int, int));
char *db_version __P((int *, int *, int *));
int db_xa_open __P((const char *,
#if defined(__cplusplus)
}
#endif
/*******************************************************
* Locking
*******************************************************/
#define DB_LOCKVERSION 1
#define DB_LOCKMAGIC 0x090193
/* Flag values for lock_vec(), lock_get(). */
of granting a new one (internal). */
/* Flag values for lock_detect(). */
/*
* Request types.
*
* !!!
*/
typedef enum {
DB_LOCK_DUMP=0, /* Display held locks. */
DB_LOCK_GET, /* Get the lock. */
DB_LOCK_INHERIT, /* Pass locks to parent. */
DB_LOCK_PUT, /* Release the lock. */
DB_LOCK_PUT_ALL, /* Release locker's locks. */
DB_LOCK_PUT_OBJ /* Release locker's locks on obj. */
} db_lockop_t;
/*
* Simple R/W lock modes and for multi-granularity intention locking.
*
* !!!
* These values are NOT random, as they are used as an index into the lock
* conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD
* must be == 4.
*
* !!!
*/
typedef enum {
DB_LOCK_NG=0, /* Not granted. */
DB_LOCK_READ, /* Shared/read. */
DB_LOCK_WRITE, /* Exclusive/write. */
DB_LOCK_IWRITE, /* Intent exclusive/write. */
DB_LOCK_IREAD, /* Intent to share/read. */
DB_LOCK_IWR /* Intent to read and write. */
/*
* Status of a lock.
*/
typedef enum {
DB_LSTAT_ABORTED, /* Lock belongs to an aborted txn. */
DB_LSTAT_ERR, /* Lock is bad. */
DB_LSTAT_FREE, /* Lock is unallocated. */
DB_LSTAT_HELD, /* Lock is currently held. */
DB_LSTAT_NOGRANT, /* Lock was not granted. */
DB_LSTAT_PENDING, /* Lock was waiting and has been
* promoted; waiting for the owner
* to run and upgrade it to held. */
DB_LSTAT_WAITING /* Lock is on the wait queue. */
} db_status_t;
/* Lock request structure. */
struct __db_lockreq {
};
/*
* Commonly used conflict matrices.
*
*/
#define DB_LOCK_RW_N 3
extern const u_int8_t db_rw_conflicts[];
/* Multi-granularity locking. */
#define DB_LOCK_RIW_N 6
extern const u_int8_t db_riw_conflicts[];
struct __db_lock_stat {
};
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(__cplusplus)
}
#endif
/*******************************************************
* Logging.
*******************************************************/
/* Flag values for log_archive(). */
/*
* A DB_LSN has two parts, a fileid which identifies a specific file, and an
* offset within that file. The fileid is an unsigned 4-byte quantity that
* uniquely identifies a file within the log directory -- currently a simple
* counter inside the log. The offset is also an unsigned 4-byte value. The
* log manager guarantees the offset is never more than 4 bytes by switching
* to a new log file before the maximum length imposed by an unsigned 4-byte
* offset is reached.
*/
struct __db_lsn {
};
/* Log statistics structure. */
struct __db_log_stat {
int st_mode; /* Log file mode. */
};
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(__cplusplus)
}
#endif
/*******************************************************
* Mpool
*******************************************************/
/* Flag values for memp_fget(). */
/* Flag values for memp_fput(), memp_fset(). */
/* Mpool statistics structure. */
struct __db_mpool_stat {
};
/* Mpool file open information structure. */
struct __db_mpool_finfo {
int ftype; /* File type. */
};
/* Mpool file statistics structure. */
struct __db_mpool_fstat {
char *file_name; /* File name. */
};
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(__cplusplus)
}
#endif
/*******************************************************
* Transactions.
*******************************************************/
#define DB_TXNVERSION 1
#define DB_TXNMAGIC 0x041593
/* Operations values to the tx_recover() function. */
/* Internal transaction status values. */
/* Transaction statistics structure. */
struct __db_txn_active {
};
struct __db_txn_stat {
*st_txnarray; /* array of active transactions */
};
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(__cplusplus)
}
#endif
#ifndef DB_DBM_HSEARCH
#define DB_DBM_HSEARCH 0 /* No historic interfaces by default. */
#endif
#if DB_DBM_HSEARCH != 0
/*******************************************************
*******************************************************/
#define DBM_INSERT 0 /* Flags to dbm_store(). */
#define DBM_REPLACE 1
/*
* The db(3) support for ndbm(3) always appends this suffix to the
* file name to avoid overwriting the user's original database.
*/
#define DBM_SUFFIX ".db"
#if defined(_XPG4_2)
typedef struct {
char *dptr;
} datum;
#else
typedef struct {
char *dptr;
int dsize;
} datum;
#endif
/*
* Translate DBM calls into DB calls so that DB doesn't step on the
* application's name space.
*
* The global variables dbrdonly, dirf and pagf were not retained when
* 4BSD replaced the dbm interface with ndbm, and are not support here.
*/
#define dbminit(a) __db_dbm_init(a)
#define dbmclose __db_dbm_close
#if !defined(__cplusplus)
#define delete(a) __db_dbm_delete(a)
#endif
#define fetch(a) __db_dbm_fetch(a)
#define firstkey __db_dbm_firstkey
#define nextkey(a) __db_dbm_nextkey(a)
#define store(a, b) __db_dbm_store(a, b)
/* Prototype the DB calls. */
#if defined(__cplusplus)
extern "C" {
#endif
int __db_dbm_close __P((void));
int __db_dbm_dbrdonly __P((void));
int __db_dbm_dirf __P((void));
int __db_dbm_init __P((char *));
int __db_dbm_pagf __P((void));
#if defined(__cplusplus)
}
#endif
/*
* Translate NDBM calls into DB calls so that DB doesn't step on the
* application's name space.
*/
#define dbm_clearerr(a) __db_ndbm_clearerr(a)
#define dbm_close(a) __db_ndbm_close(a)
#define dbm_delete(a, b) __db_ndbm_delete(a, b)
#define dbm_dirfno(a) __db_ndbm_dirfno(a)
#define dbm_error(a) __db_ndbm_error(a)
#define dbm_fetch(a, b) __db_ndbm_fetch(a, b)
#define dbm_firstkey(a) __db_ndbm_firstkey(a)
#define dbm_nextkey(a) __db_ndbm_nextkey(a)
#define dbm_open(a, b, c) __db_ndbm_open(a, b, c)
#define dbm_pagfno(a) __db_ndbm_pagfno(a)
#define dbm_rdonly(a) __db_ndbm_rdonly(a)
#define dbm_store(a, b, c, d) __db_ndbm_store(a, b, c, d)
/* Prototype the DB calls. */
#if defined(__cplusplus)
extern "C" {
#endif
#if defined(__cplusplus)
}
#endif
/*******************************************************
* Hsearch historic interface.
*******************************************************/
typedef enum {
} ACTION;
typedef struct entry {
char *key;
char *data;
} ENTRY;
/*
* Translate HSEARCH calls into DB calls so that DB doesn't step on the
* application's name space.
*/
#define hcreate(a) __db_hcreate(a)
#define hdestroy __db_hdestroy
#define hsearch(a, b) __db_hsearch(a, b)
/* Prototype the DB calls. */
#if defined(__cplusplus)
extern "C" {
#endif
void __db_hdestroy __P((void));
#if defined(__cplusplus)
}
#endif
#endif /* DB_DBM_HSEARCH */
/*
* XXX
* MacOS: Reset Metrowerks C enum sizes.
*/
#ifdef __MWERKS__
#pragma enumsalwaysint reset
#endif
#endif /* !_DB_H_ */