1 /*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 * 7 * @(#)db.h 5.1 (Berkeley) 12/05/90 8 */ 9 10 /* flags for DB.put() call */ 11 #define R_IBEFORE 1 /* RECNO */ 12 #define R_IAFTER 2 /* RECNO */ 13 #define R_NOOVERWRITE 3 /* BTREE, HASH, RECNO */ 14 #define R_PUT 4 15 16 /* flags for DB.seq() call */ 17 #define R_CURSOR 1 /* BTREE, RECNO */ 18 #define R_FIRST 2 /* BTREE, HASH, RECNO */ 19 #define R_LAST 3 /* BTREE, RECNO */ 20 #define R_NEXT 4 /* BTREE, HASH, RECNO */ 21 #define R_PREV 5 /* BTREE, RECNO */ 22 23 /* key/data structure -- a data-base thang */ 24 typedef struct { 25 char *data; 26 int size; 27 } DBT; 28 29 /* access method description structure */ 30 typedef struct { 31 char *internal; /* access method private; really void * */ 32 int (*close)(); 33 int (*delete)(); 34 int (*get)(); 35 int (*put)(); 36 int (*seq)(); 37 int (*sync)(); 38 } DB; 39 40 #define BTREEMAGIC 0x053162 41 42 /* structure used to pass parameters to the btree routines */ 43 typedef struct { 44 #define R_DUP 0x01 /* duplicate keys */ 45 u_long flags; 46 int cachesize; /* bytes to cache */ 47 int psize; /* page size */ 48 int (*compare)(); /* compare function */ 49 } BTREEINFO; 50 51 #define HASHMAGIC 0x061561 52 53 /* structure used to pass parameters to the hashing routines */ 54 typedef struct { 55 int bsize; /* bucket size */ 56 int ffactor; /* fill factor */ 57 int nelem; /* number of elements */ 58 int ncached; /* bytes to cache */ 59 int (*hash)(); /* hash function */ 60 } HASHINFO; 61 62 /* structure used to pass parameters to the record routines */ 63 typedef struct { 64 #define R_FIXEDLEN 0x01 /* fixed-length records */ 65 u_long flags; 66 int cachesize; /* bytes to cache */ 67 size_t reclen; /* record length (fixed-length records) */ 68 u_char bval; /* delimiting byte (variable-length records */ 69 } RECNOINFO; 70 71 /* key structure for the record routines */ 72 typedef struct { 73 u_long number; 74 u_long offset; 75 u_long length; 76 #define R_LENGTH 0x01 /* length is valid */ 77 #define R_NUMBER 0x02 /* record number is valid */ 78 #define R_OFFSET 0x04 /* offset is valid */ 79 u_char valid; 80 } RECNOKEY; 81 82 #if __STDC__ || c_plusplus 83 DB *btree_open(const char *file, int flags, int mode, const BTREEINFO *private); 84 DB *hash_open(const char *file, int flags, int mode, const HASHINFO *private); 85 DB *recno_open(const char *file, int flags, int mode, const RECNOINFO *private); 86 #else 87 DB *btree_open(); 88 DB *hash_open(); 89 DB *recno_open(); 90 #endif 91