release
[hcoop/zz_old/debian/djbdns.git] / cdb.h
1 /* Public domain. */
2
3 #ifndef CDB_H
4 #define CDB_H
5
6 #include "uint32.h"
7
8 #define CDB_HASHSTART 5381
9 extern uint32 cdb_hashadd(uint32,unsigned char);
10 extern uint32 cdb_hash(const char *,unsigned int);
11
12 struct cdb {
13 char *map; /* 0 if no map is available */
14 int fd;
15 uint32 size; /* initialized if map is nonzero */
16 uint32 loop; /* number of hash slots searched under this key */
17 uint32 khash; /* initialized if loop is nonzero */
18 uint32 kpos; /* initialized if loop is nonzero */
19 uint32 hpos; /* initialized if loop is nonzero */
20 uint32 hslots; /* initialized if loop is nonzero */
21 uint32 dpos; /* initialized if cdb_findnext() returns 1 */
22 uint32 dlen; /* initialized if cdb_findnext() returns 1 */
23 } ;
24
25 extern void cdb_free(struct cdb *);
26 extern void cdb_init(struct cdb *,int fd);
27
28 extern int cdb_read(struct cdb *,char *,unsigned int,uint32);
29
30 extern void cdb_findstart(struct cdb *);
31 extern int cdb_findnext(struct cdb *,const char *,unsigned int);
32 extern int cdb_find(struct cdb *,const char *,unsigned int);
33
34 #define cdb_datapos(c) ((c)->dpos)
35 #define cdb_datalen(c) ((c)->dlen)
36
37 #endif