xref: /onnv-gate/usr/src/lib/gss_mechs/mech_krb5/include/db.h (revision 7934:6aeeafc994de)
10Sstevel@tonic-gate /*-
20Sstevel@tonic-gate  * Copyright (c) 1990, 1993, 1994
30Sstevel@tonic-gate  *	The Regents of the University of California.  All rights reserved.
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
60Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
70Sstevel@tonic-gate  * are met:
80Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
90Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
100Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
110Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
120Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
130Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
140Sstevel@tonic-gate  *    must display the following acknowledgement:
150Sstevel@tonic-gate  *	This product includes software developed by the University of
160Sstevel@tonic-gate  *	California, Berkeley and its contributors.
170Sstevel@tonic-gate  * 4. Neither the name of the University nor the names of its contributors
180Sstevel@tonic-gate  *    may be used to endorse or promote products derived from this software
190Sstevel@tonic-gate  *    without specific prior written permission.
200Sstevel@tonic-gate  *
210Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
220Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
230Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
240Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
250Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
260Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
270Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
280Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
290Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
300Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
310Sstevel@tonic-gate  * SUCH DAMAGE.
320Sstevel@tonic-gate  *
330Sstevel@tonic-gate  *	@(#)db.h	8.8 (Berkeley) 11/2/95
340Sstevel@tonic-gate  */
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #ifndef _DB_H_
370Sstevel@tonic-gate #define	_DB_H_
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #include <db-config.h>
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #include <sys/types.h>
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #define	RET_ERROR	-1		/* Return values. */
440Sstevel@tonic-gate #define	RET_SUCCESS	 0
450Sstevel@tonic-gate #define	RET_SPECIAL	 1
460Sstevel@tonic-gate 
470Sstevel@tonic-gate /* Key/data structure -- a Data-Base Thang. */
480Sstevel@tonic-gate typedef struct {
490Sstevel@tonic-gate 	void	*data;			/* data */
500Sstevel@tonic-gate 	size_t	 size;			/* data length */
510Sstevel@tonic-gate } DBT;
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /* Routine flags. */
540Sstevel@tonic-gate #define	R_CURSOR	1		/* del, put, seq */
550Sstevel@tonic-gate #define	__R_UNUSED	2		/* UNUSED */
560Sstevel@tonic-gate #define	R_FIRST		3		/* seq */
570Sstevel@tonic-gate #define	R_IAFTER	4		/* put (RECNO) */
580Sstevel@tonic-gate #define	R_IBEFORE	5		/* put (RECNO) */
590Sstevel@tonic-gate #define	R_LAST		6		/* seq (BTREE, RECNO) */
600Sstevel@tonic-gate #define	R_NEXT		7		/* seq */
610Sstevel@tonic-gate #define	R_NOOVERWRITE	8		/* put */
620Sstevel@tonic-gate #define	R_PREV		9		/* seq (BTREE, RECNO) */
630Sstevel@tonic-gate #define	R_SETCURSOR	10		/* put (RECNO) */
640Sstevel@tonic-gate #define	R_RECNOSYNC	11		/* sync (RECNO) */
650Sstevel@tonic-gate 
660Sstevel@tonic-gate typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate /*
690Sstevel@tonic-gate  * !!!
700Sstevel@tonic-gate  * The following flags are included in the dbopen(3) call as part of the
710Sstevel@tonic-gate  * open(2) flags.  In order to avoid conflicts with the open flags, start
720Sstevel@tonic-gate  * at the top of the 16 or 32-bit number space and work our way down.  If
730Sstevel@tonic-gate  * the open flags were significantly expanded in the future, it could be
740Sstevel@tonic-gate  * a problem.  Wish I'd left another flags word in the dbopen call.
750Sstevel@tonic-gate  *
760Sstevel@tonic-gate  * !!!
770Sstevel@tonic-gate  * None of this stuff is implemented yet.  The only reason that it's here
780Sstevel@tonic-gate  * is so that the access methods can skip copying the key/data pair when
790Sstevel@tonic-gate  * the DB_LOCK flag isn't set.
800Sstevel@tonic-gate  */
81*7934SMark.Phalan@Sun.COM #if UINT_MAX >= 0xffffffffUL
820Sstevel@tonic-gate #define	DB_LOCK		0x20000000	/* Do locking. */
830Sstevel@tonic-gate #define	DB_SHMEM	0x40000000	/* Use shared memory. */
840Sstevel@tonic-gate #define	DB_TXN		0x80000000	/* Do transactions. */
850Sstevel@tonic-gate #else
860Sstevel@tonic-gate #define	DB_LOCK		    0x2000	/* Do locking. */
870Sstevel@tonic-gate #define	DB_SHMEM	    0x4000	/* Use shared memory. */
880Sstevel@tonic-gate #define	DB_TXN		    0x8000	/* Do transactions. */
890Sstevel@tonic-gate #endif
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /* deal with turning prototypes on and off */
920Sstevel@tonic-gate 
930Sstevel@tonic-gate #ifndef __P
940Sstevel@tonic-gate #if defined(__STDC__) || defined(__cplusplus)
950Sstevel@tonic-gate #define	__P(protos)	protos		/* full-blown ANSI C */
960Sstevel@tonic-gate #else	/* !(__STDC__ || __cplusplus) */
970Sstevel@tonic-gate #define	__P(protos)	()		/* traditional C preprocessor */
980Sstevel@tonic-gate #endif
990Sstevel@tonic-gate #endif /* no __P from system */
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate /* Access method description structure. */
1020Sstevel@tonic-gate typedef struct __db {
1030Sstevel@tonic-gate 	DBTYPE type;			/* Underlying db type. */
1040Sstevel@tonic-gate 	int (*close)	__P((struct __db *));
1050Sstevel@tonic-gate 	int (*del)	__P((const struct __db *, const DBT *, u_int));
1060Sstevel@tonic-gate 	int (*get)	__P((const struct __db *, const DBT *, DBT *, u_int));
1070Sstevel@tonic-gate 	int (*put)	__P((const struct __db *, DBT *, const DBT *, u_int));
1080Sstevel@tonic-gate 	int (*seq)	__P((const struct __db *, DBT *, DBT *, u_int));
1090Sstevel@tonic-gate 	int (*sync)	__P((const struct __db *, u_int));
1100Sstevel@tonic-gate 	void *internal;			/* Access method private. */
1110Sstevel@tonic-gate 	int (*fd)	__P((const struct __db *));
1120Sstevel@tonic-gate } DB;
1130Sstevel@tonic-gate 
1140Sstevel@tonic-gate #define	BTREEMAGIC	0x053162
1150Sstevel@tonic-gate #define	BTREEVERSION	3
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate /* Structure used to pass parameters to the btree routines. */
1180Sstevel@tonic-gate typedef struct {
1190Sstevel@tonic-gate #define	R_DUP		0x01	/* duplicate keys */
1200Sstevel@tonic-gate 	u_long	flags;
1210Sstevel@tonic-gate 	u_int	cachesize;	/* bytes to cache */
1220Sstevel@tonic-gate 	int	maxkeypage;	/* maximum keys per page */
1230Sstevel@tonic-gate 	int	minkeypage;	/* minimum keys per page */
1240Sstevel@tonic-gate 	u_int	psize;		/* page size */
1250Sstevel@tonic-gate 	int	(*compare)	/* comparison function */
1260Sstevel@tonic-gate 	    __P((const DBT *, const DBT *));
1270Sstevel@tonic-gate 	size_t	(*prefix)	/* prefix function */
1280Sstevel@tonic-gate 	    __P((const DBT *, const DBT *));
1290Sstevel@tonic-gate 	int	lorder;		/* byte order */
1300Sstevel@tonic-gate } BTREEINFO;
1310Sstevel@tonic-gate 
1320Sstevel@tonic-gate #define	HASHMAGIC	0x061561
1330Sstevel@tonic-gate #define	HASHVERSION	3
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate /* Structure used to pass parameters to the hashing routines. */
1360Sstevel@tonic-gate typedef struct {
1370Sstevel@tonic-gate 	u_int	bsize;		/* bucket size */
1380Sstevel@tonic-gate 	u_int	ffactor;	/* fill factor */
1390Sstevel@tonic-gate 	u_int	nelem;		/* number of elements */
1400Sstevel@tonic-gate 	u_int	cachesize;	/* bytes to cache */
1410Sstevel@tonic-gate 	u_int32_t		/* hash function */
1420Sstevel@tonic-gate 		(*hash) __P((const void *, size_t));
1430Sstevel@tonic-gate 	int	lorder;		/* byte order */
1440Sstevel@tonic-gate } HASHINFO;
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate /* Structure used to pass parameters to the record routines. */
1470Sstevel@tonic-gate typedef struct {
1480Sstevel@tonic-gate #define	R_FIXEDLEN	0x01	/* fixed-length records */
1490Sstevel@tonic-gate #define	R_NOKEY		0x02	/* key not required */
1500Sstevel@tonic-gate #define	R_SNAPSHOT	0x04	/* snapshot the input */
1510Sstevel@tonic-gate 	u_long	flags;
1520Sstevel@tonic-gate 	u_int	cachesize;	/* bytes to cache */
1530Sstevel@tonic-gate 	u_int	psize;		/* page size */
1540Sstevel@tonic-gate 	int	lorder;		/* byte order */
1550Sstevel@tonic-gate 	size_t	reclen;		/* record length (fixed-length records) */
1560Sstevel@tonic-gate 	u_char	bval;		/* delimiting byte (variable-length records */
1570Sstevel@tonic-gate 	char	*bfname;	/* btree file name */
1580Sstevel@tonic-gate } RECNOINFO;
1590Sstevel@tonic-gate 
1600Sstevel@tonic-gate #if defined(__cplusplus)
1610Sstevel@tonic-gate #define	__BEGIN_DECLS	extern "C" {
1620Sstevel@tonic-gate #define	__END_DECLS	};
1630Sstevel@tonic-gate #else
1640Sstevel@tonic-gate #define	__BEGIN_DECLS
1650Sstevel@tonic-gate #define	__END_DECLS
1660Sstevel@tonic-gate #endif
1670Sstevel@tonic-gate 
1680Sstevel@tonic-gate #define dbopen	kdb2_dbopen
1690Sstevel@tonic-gate #define bt_rseq		kdb2_bt_rseq /* XXX kludge */
1700Sstevel@tonic-gate __BEGIN_DECLS
1710Sstevel@tonic-gate DB *dbopen __P((const char *, int, int, DBTYPE, const void *));
1720Sstevel@tonic-gate int	 bt_rseq(const DB*, DBT *, DBT *, void **, u_int); /* XXX kludge */
1730Sstevel@tonic-gate __END_DECLS
1740Sstevel@tonic-gate 
1750Sstevel@tonic-gate #endif /* !_DB_H_ */
176