document w (wildcard MX) and k (checkpoint interval) options
[unix-history] / usr / src / include / db.h
index a145b5b..e1c81bb 100644 (file)
@@ -4,14 +4,19 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)db.h        5.1 (Berkeley) %G%
+ *     @(#)db.h        5.10 (Berkeley) %G%
  */
 
  */
 
+#ifndef _DB_H_
+#define        _DB_H_
+
+#include <sys/cdefs.h>
+
 /* flags for DB.put() call */
 #define        R_IBEFORE       1               /* RECNO */
 #define        R_IAFTER        2               /* RECNO */
 #define        R_NOOVERWRITE   3               /* BTREE, HASH, RECNO */
 /* flags for DB.put() call */
 #define        R_IBEFORE       1               /* RECNO */
 #define        R_IAFTER        2               /* RECNO */
 #define        R_NOOVERWRITE   3               /* BTREE, HASH, RECNO */
-#define        R_PUT           4
+#define        R_PUT           4               /* BTREE, HASH, RECNO */
 
 /* flags for DB.seq() call */
 #define        R_CURSOR        1               /* BTREE, RECNO */
 
 /* flags for DB.seq() call */
 #define        R_CURSOR        1               /* BTREE, RECNO */
 
 /* key/data structure -- a data-base thang */
 typedef struct {
 
 /* key/data structure -- a data-base thang */
 typedef struct {
-       char *data;
+       void *data;
        int size;
 } DBT;
 
 /* access method description structure */
        int size;
 } DBT;
 
 /* access method description structure */
-typedef struct {
-       char *internal;         /* access method private; really void * */
-       int (*close)();
-       int (*delete)();
-       int (*get)();
-       int (*put)();
-       int (*seq)();
-       int (*sync)();
+typedef struct __db {
+       void *internal;         /* access method private */
+#define        DB_BTREE        1
+#define        DB_HASH         2
+#define        DB_RECNO        3
+       int type;               /* type of underlying db */
+       int (*close) __P((const struct __db *));
+       int (*del) __P((const struct __db *, const DBT *, unsigned int));
+       int (*get) __P((const struct __db *, DBT *, DBT *, unsigned int));
+       int (*put) __P((const struct __db *, const DBT *, const DBT *,
+               unsigned int));
+       int (*seq) __P((const struct __db *, DBT *, DBT *, unsigned int));
+       int (*sync) __P((const struct __db *));
 } DB;
 
 #define        BTREEMAGIC      0x053162
 } DB;
 
 #define        BTREEMAGIC      0x053162
+#define        BTREEVERSION    2
 
 /* structure used to pass parameters to the btree routines */
 typedef struct {
 
 /* structure used to pass parameters to the btree routines */
 typedef struct {
@@ -46,17 +57,20 @@ typedef struct {
        int cachesize;          /* bytes to cache */
        int psize;              /* page size */
        int (*compare)();       /* compare function */
        int cachesize;          /* bytes to cache */
        int psize;              /* page size */
        int (*compare)();       /* compare function */
+       int lorder;             /* byte order */
 } BTREEINFO;
 
 #define        HASHMAGIC       0x061561
 } BTREEINFO;
 
 #define        HASHMAGIC       0x061561
+#define        HASHVERSION     1
 
 /* structure used to pass parameters to the hashing routines */
 typedef struct {
        int bsize;              /* bucket size */
        int ffactor;            /* fill factor */
        int nelem;              /* number of elements */
 
 /* structure used to pass parameters to the hashing routines */
 typedef struct {
        int bsize;              /* bucket size */
        int ffactor;            /* fill factor */
        int nelem;              /* number of elements */
-       int ncached;            /* bytes to cache */
+       int cachesize;          /* bytes to cache */
        int (*hash)();          /* hash function */
        int (*hash)();          /* hash function */
+       int lorder;             /* byte order */
 } HASHINFO;
 
 /* structure used to pass parameters to the record routines */
 } HASHINFO;
 
 /* structure used to pass parameters to the record routines */
@@ -79,12 +93,40 @@ typedef struct {
        u_char valid;
 } RECNOKEY;
 
        u_char valid;
 } RECNOKEY;
 
-#if __STDC__ || c_plusplus
-DB *btree_open(const char *file, int flags, int mode, const BTREEINFO *private);
-DB *hash_open(const char *file, int flags, int mode, const HASHINFO *private);
-DB *recno_open(const char *file, int flags, int mode, const RECNOINFO *private);
-#else
-DB *btree_open();
-DB *hash_open();
-DB *recno_open();
-#endif
+/* Little endian <--> big endian long swap macros. */
+#define BLSWAP(a) { \
+       u_long _tmp = a; \
+       ((char *)&a)[0] = ((char *)&_tmp)[3]; \
+       ((char *)&a)[1] = ((char *)&_tmp)[2]; \
+       ((char *)&a)[2] = ((char *)&_tmp)[1]; \
+       ((char *)&a)[3] = ((char *)&_tmp)[0]; \
+}
+#define        BLSWAP_COPY(a,b) { \
+       ((char *)&(b))[0] = ((char *)&(a))[3]; \
+       ((char *)&(b))[1] = ((char *)&(a))[2]; \
+       ((char *)&(b))[2] = ((char *)&(a))[1]; \
+       ((char *)&(b))[3] = ((char *)&(a))[0]; \
+}
+
+
+/* Little endian <--> big endian short swap macros. */
+#define BSSWAP(a) { \
+       u_short _tmp = a; \
+       ((char *)&a)[0] = ((char *)&_tmp)[1]; \
+       ((char *)&a)[1] = ((char *)&_tmp)[0]; \
+}
+#define BSSWAP_COPY(a,b) { \
+       ((char *)&(b))[0] = ((char *)&(a))[1]; \
+       ((char *)&(b))[1] = ((char *)&(a))[0]; \
+}
+
+__BEGIN_DECLS
+DB     *btree_open
+           __P((const char *, int, int, const BTREEINFO *));
+DB     *hash_open
+           __P((const char *, int, int, const HASHINFO *));
+DB     *recno_open
+           __P((const char *, int, int, const RECNOINFO *));
+__END_DECLS
+
+#endif /* !_DB_H_ */