1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 1996,2008 Oracle. All rights reserved. 5 */ 6/* 7 * Copyright (c) 1990, 1993, 1994 8 * The Regents of the University of California. All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. Neither the name of the University nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * $Id: db_185.in,v 12.8 2008/01/08 20:58:17 bostic Exp $ 35 */ 36 37#ifndef _DB_185_H_ 38#define _DB_185_H_ 39 40#include <sys/types.h> 41 42#include <limits.h> 43 44#if defined(__cplusplus) 45extern "C" { 46#endif 47 48/* 49 * XXX 50 * Handle function prototypes and the keyword "const". This steps on name 51 * space that DB doesn't control, but all of the other solutions are worse. 52 */ 53#undef __P 54#if defined(__STDC__) || defined(__cplusplus) 55#define __P(protos) protos /* ANSI C prototypes */ 56#else 57#define const 58#define __P(protos) () /* K&R C preprocessor */ 59#endif 60 61#define RET_ERROR -1 /* Return values. */ 62#define RET_SUCCESS 0 63#define RET_SPECIAL 1 64 65#ifndef __BIT_TYPES_DEFINED__ 66#define __BIT_TYPES_DEFINED__ 67@u_int8_decl@ 68@int16_decl@ 69@u_int16_decl@ 70@int32_decl@ 71@u_int32_decl@ 72#endif 73 74/* 75 * XXX 76 * SGI/IRIX already has a pgno_t. 77 */ 78#ifdef __sgi 79#define pgno_t db_pgno_t 80#endif 81 82#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ 83typedef u_int32_t pgno_t; 84#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */ 85typedef u_int16_t indx_t; 86#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */ 87typedef u_int32_t recno_t; 88 89/* Key/data structure -- a Data-Base Thang. */ 90typedef struct { 91 void *data; /* data */ 92 size_t size; /* data length */ 93} DBT; 94 95/* Routine flags. */ 96#define R_CURSOR 1 /* del, put, seq */ 97#define __R_UNUSED 2 /* UNUSED */ 98#define R_FIRST 3 /* seq */ 99#define R_IAFTER 4 /* put (RECNO) */ 100#define R_IBEFORE 5 /* put (RECNO) */ 101#define R_LAST 6 /* seq (BTREE, RECNO) */ 102#define R_NEXT 7 /* seq */ 103#define R_NOOVERWRITE 8 /* put */ 104#define R_PREV 9 /* seq (BTREE, RECNO) */ 105#define R_SETCURSOR 10 /* put (RECNO) */ 106#define R_RECNOSYNC 11 /* sync (RECNO) */ 107 108typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; 109 110/* Access method description structure. */ 111typedef struct __db { 112 DBTYPE type; /* Underlying db type. */ 113 int (*close) __P((struct __db *)); 114 int (*del) __P((const struct __db *, const DBT *, u_int)); 115 int (*get) __P((const struct __db *, const DBT *, DBT *, u_int)); 116 int (*put) __P((const struct __db *, DBT *, const DBT *, u_int)); 117 int (*seq) __P((const struct __db *, DBT *, DBT *, u_int)); 118 int (*sync) __P((const struct __db *, u_int)); 119 void *internal; /* Access method private. */ 120 int (*fd) __P((const struct __db *)); 121} DB; 122 123#define BTREEMAGIC 0x053162 124#define BTREEVERSION 3 125 126/* Structure used to pass parameters to the btree routines. */ 127typedef struct { 128#define R_DUP 0x01 /* duplicate keys */ 129 u_int32_t flags; 130 u_int32_t cachesize; /* bytes to cache */ 131 u_int32_t maxkeypage; /* maximum keys per page */ 132 u_int32_t minkeypage; /* minimum keys per page */ 133 u_int32_t psize; /* page size */ 134 int (*compare) /* comparison function */ 135 __P((const DBT *, const DBT *)); 136 size_t (*prefix) /* prefix function */ 137 __P((const DBT *, const DBT *)); 138 int lorder; /* byte order */ 139} BTREEINFO; 140 141#define HASHMAGIC 0x061561 142#define HASHVERSION 2 143 144/* Structure used to pass parameters to the hashing routines. */ 145typedef struct { 146 u_int32_t bsize; /* bucket size */ 147 u_int32_t ffactor; /* fill factor */ 148 u_int32_t nelem; /* number of elements */ 149 u_int32_t cachesize; /* bytes to cache */ 150 u_int32_t /* hash function */ 151 (*hash) __P((const void *, size_t)); 152 int lorder; /* byte order */ 153} HASHINFO; 154 155/* Structure used to pass parameters to the record routines. */ 156typedef struct { 157#define R_FIXEDLEN 0x01 /* fixed-length records */ 158#define R_NOKEY 0x02 /* key not required */ 159#define R_SNAPSHOT 0x04 /* snapshot the input */ 160 u_int32_t flags; 161 u_int32_t cachesize; /* bytes to cache */ 162 u_int32_t psize; /* page size */ 163 int lorder; /* byte order */ 164 size_t reclen; /* record length (fixed-length records) */ 165 u_char bval; /* delimiting byte (variable-length records */ 166 char *bfname; /* btree file name */ 167} RECNOINFO; 168 169/* Re-define the user's dbopen calls. */ 170#define dbopen __db185_open@DB_VERSION_UNIQUE_NAME@ 171 172#if defined(__cplusplus) 173} 174#endif 175 176#endif /* !_DB_185_H_ */ 177