2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1996, 1997, 1998
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. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * @(#)db_185.h.src 8.7 (Sleepycat) 4/10/98
45 #include <sys/types.h>
51 * Handle function prototypes and the keyword "const". This steps on name
52 * space that DB doesn't control, but all of the other solutions are worse.
55 #if defined(__STDC__) || defined(__cplusplus)
56 #define __P(protos) protos /* ANSI C prototypes */
59 #define __P(protos) () /* K&R C preprocessor */
62 #define RET_ERROR -1 /* Return values. */
66 #ifndef __BIT_TYPES_DEFINED__
67 #define __BIT_TYPES_DEFINED__
77 * SGI/IRIX already has a pgno_t.
80 #define pgno_t db_pgno_t
83 #define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */
84 typedef u_int32_t pgno_t
;
85 #define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */
86 typedef u_int16_t indx_t
;
87 #define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */
88 typedef u_int32_t recno_t
;
90 /* Key/data structure -- a Data-Base Thang. */
92 void *data
; /* data */
93 size_t size
; /* data length */
97 #define R_CURSOR 1 /* del, put, seq */
98 #define __R_UNUSED 2 /* UNUSED */
99 #define R_FIRST 3 /* seq */
100 #define R_IAFTER 4 /* put (RECNO) */
101 #define R_IBEFORE 5 /* put (RECNO) */
102 #define R_LAST 6 /* seq (BTREE, RECNO) */
103 #define R_NEXT 7 /* seq */
104 #define R_NOOVERWRITE 8 /* put */
105 #define R_PREV 9 /* seq (BTREE, RECNO) */
106 #define R_SETCURSOR 10 /* put (RECNO) */
107 #define R_RECNOSYNC 11 /* sync (RECNO) */
109 typedef enum { DB_BTREE
, DB_HASH
, DB_RECNO
} DBTYPE
;
111 /* Access method description structure. */
112 typedef struct __db
{
113 DBTYPE type
; /* Underlying db type. */
114 int (*close
) __P((struct __db
*));
115 int (*del
) __P((const struct __db
*, const DBT
*, u_int
));
116 int (*get
) __P((const struct __db
*, const DBT
*, DBT
*, u_int
));
117 int (*put
) __P((const struct __db
*, DBT
*, const DBT
*, u_int
));
118 int (*seq
) __P((const struct __db
*, DBT
*, DBT
*, u_int
));
119 int (*sync
) __P((const struct __db
*, u_int
));
120 void *internal
; /* Access method private. */
121 int (*fd
) __P((const struct __db
*));
124 #define BTREEMAGIC 0x053162
125 #define BTREEVERSION 3
127 /* Structure used to pass parameters to the btree routines. */
129 #define R_DUP 0x01 /* duplicate keys */
131 u_int32_t cachesize
; /* bytes to cache */
132 u_int32_t maxkeypage
; /* maximum keys per page */
133 u_int32_t minkeypage
; /* minimum keys per page */
134 u_int32_t psize
; /* page size */
135 int (*compare
) /* comparison function */
136 __P((const DBT
*, const DBT
*));
137 size_t (*prefix
) /* prefix function */
138 __P((const DBT
*, const DBT
*));
139 int lorder
; /* byte order */
142 #define HASHMAGIC 0x061561
143 #define HASHVERSION 2
145 /* Structure used to pass parameters to the hashing routines. */
147 u_int32_t bsize
; /* bucket size */
148 u_int32_t ffactor
; /* fill factor */
149 u_int32_t nelem
; /* number of elements */
150 u_int32_t cachesize
; /* bytes to cache */
151 u_int32_t
/* hash function */
152 (*hash
) __P((const void *, size_t));
153 int lorder
; /* byte order */
156 /* Structure used to pass parameters to the record routines. */
158 #define R_FIXEDLEN 0x01 /* fixed-length records */
159 #define R_NOKEY 0x02 /* key not required */
160 #define R_SNAPSHOT 0x04 /* snapshot the input */
162 u_int32_t cachesize
; /* bytes to cache */
163 u_int32_t psize
; /* page size */
164 int lorder
; /* byte order */
165 size_t reclen
; /* record length (fixed-length records) */
166 u_char bval
; /* delimiting byte (variable-length records */
167 char *bfname
; /* btree file name */
170 #if defined(__cplusplus)
173 DB
*dbopen
__P((const char *, int, int, DBTYPE
, const void *));
175 #if defined(__cplusplus)
178 #endif /* !_DB_185_H_ */