2 * sdbm - ndbm work-alike hashed database library
3 * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
4 * author: oz@nexus.yorku.ca
5 * status: public domain.
12 #define PAIRMAX 1008 /* arbitrary on PBLKSIZ-N */
13 #define SPLTMAX 10 /* maximum allowed splits */
14 /* for a single insertion */
15 #define DIRFEXT ".dir"
16 #define PAGFEXT ".pag"
19 int dirf
; /* directory file descriptor */
20 int pagf
; /* page file descriptor */
21 int flags
; /* status/error flags, see below */
22 long maxbno
; /* size of dirfile in bits */
23 long curbit
; /* current bit number */
24 long hmask
; /* current hash mask */
25 long blkptr
; /* current block for nextkey */
26 int keyptr
; /* current key for nextkey */
27 long blkno
; /* current page to read/write */
28 long pagbno
; /* current page in pagbuf */
29 char pagbuf
[PBLKSIZ
]; /* page file block buffer */
30 long dirbno
; /* current block in dirbuf */
31 char dirbuf
[DBLKSIZ
]; /* directory file block buffer */
34 #define DBM_RDONLY 0x1 /* data base open read-only */
35 #define DBM_IOERR 0x2 /* data base I/O error */
40 #define sdbm_rdonly(db) ((db)->flags & DBM_RDONLY)
41 #define sdbm_error(db) ((db)->flags & DBM_IOERR)
43 #define sdbm_clearerr(db) ((db)->flags &= ~DBM_IOERR) /* ouch */
45 #define sdbm_dirfno(db) ((db)->dirf)
46 #define sdbm_pagfno(db) ((db)->pagf)
53 extern datum nullitem
;
55 #if defined(__STDC__) || defined(MSDOS)
70 extern DBM
*sdbm_open
proto((char *, int, int));
71 extern void sdbm_close
proto((DBM
*));
72 extern datum sdbm_fetch
proto((DBM
*, datum
));
73 extern int sdbm_delete
proto((DBM
*, datum
));
74 extern int sdbm_store
proto((DBM
*, datum
, datum
, int));
75 extern datum sdbm_firstkey
proto((DBM
*));
76 extern datum sdbm_nextkey
proto((DBM
*));
81 extern DBM
*sdbm_prep
proto((char *, char *, int, int));
82 extern long sdbm_hash
proto((char *, int));