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