Conflict resolved.
[platform/upstream/rpm.git] / db / dbinc / db_185.in
1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 1996-2002
5  *      Sleepycat Software.  All rights reserved.
6  */
7 /*
8  * Copyright (c) 1990, 1993, 1994
9  *      The Regents of the University of California.  All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
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.
22  *
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
33  * SUCH DAMAGE.
34  *
35  * Id: db_185.in,v 11.8 2002/01/11 15:52:24 bostic Exp 
36  */
37
38 #ifndef _DB_185_H_
39 #define _DB_185_H_
40
41 #include <sys/types.h>
42
43 #include <limits.h>
44
45 /*
46  * XXX
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.
49  */
50 #undef  __P
51 #if defined(__STDC__) || defined(__cplusplus)
52 #define __P(protos)     protos          /* ANSI C prototypes */
53 #else
54 #define const
55 #define __P(protos)     ()              /* K&R C preprocessor */
56 #endif
57
58 #define RET_ERROR       -1              /* Return values. */
59 #define RET_SUCCESS      0
60 #define RET_SPECIAL      1
61
62 #ifndef __BIT_TYPES_DEFINED__
63 #define __BIT_TYPES_DEFINED__
64 @u_int8_decl@
65 @int16_decl@
66 @u_int16_decl@
67 @int32_decl@
68 @u_int32_decl@
69 #endif
70
71 /*
72  * XXX
73  * SGI/IRIX already has a pgno_t.
74  */
75 #ifdef  sgi
76 #define pgno_t  db_pgno_t
77 #endif
78
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;
85
86 /* Key/data structure -- a Data-Base Thang. */
87 typedef struct {
88         void    *data;                  /* data */
89         size_t   size;                  /* data length */
90 } DBT;
91
92 /* Routine flags. */
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) */
104
105 typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE;
106
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 *));
118 } DB;
119
120 #define BTREEMAGIC      0x053162
121 #define BTREEVERSION    3
122
123 /* Structure used to pass parameters to the btree routines. */
124 typedef struct {
125 #define R_DUP           0x01    /* duplicate keys */
126         u_int32_t flags;
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 */
136 } BTREEINFO;
137
138 #define HASHMAGIC       0x061561
139 #define HASHVERSION     2
140
141 /* Structure used to pass parameters to the hashing routines. */
142 typedef struct {
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 */
150 } HASHINFO;
151
152 /* Structure used to pass parameters to the record routines. */
153 typedef struct {
154 #define R_FIXEDLEN      0x01    /* fixed-length records */
155 #define R_NOKEY         0x02    /* key not required */
156 #define R_SNAPSHOT      0x04    /* snapshot the input */
157         u_int32_t flags;
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 */
164 } RECNOINFO;
165
166 /* Re-define the user's dbopen calls. */
167 #define dbopen __db185_open@DB_VERSION_UNIQUE_NAME@
168
169 #endif /* !_DB_185_H_ */