DEFINITIONS
This source file includes following functions.
1
2
3
4
5
6
7 #ifndef _SDBM_H_
8 #define _SDBM_H_
9
10 #define DBLKSIZ 4096
11 #define PBLKSIZ 1024
12 #define PAIRMAX 1008
13 #define SPLTMAX 10
14
15 #define DIRFEXT ".dir"
16 #define PAGFEXT ".pag"
17
18 typedef struct {
19 int dirf;
20 int pagf;
21 int flags;
22 long maxbno;
23 long curbit;
24 long hmask;
25 long blkptr;
26 int keyptr;
27 long blkno;
28 long pagbno;
29 char pagbuf[PBLKSIZ];
30 long dirbno;
31 char dirbuf[DBLKSIZ];
32 } DBM;
33
34 #define DBM_RDONLY 0x1
35 #define DBM_IOERR 0x2
36
37
38
39
40 #define sdbm_rdonly(db) ((db)->flags & DBM_RDONLY)
41 #define sdbm_error(db) ((db)->flags & DBM_IOERR)
42
43 #define sdbm_clearerr(db) ((db)->flags &= ~DBM_IOERR)
44
45 #define sdbm_dirfno(db) ((db)->dirf)
46 #define sdbm_pagfno(db) ((db)->pagf)
47
48 typedef struct {
49 char *dptr;
50 int dsize;
51 } datum;
52
53 extern datum nullitem;
54
55 #if defined(__STDC__) || defined(MSDOS)
56 #define proto(p) p
57 #else
58 #define proto(p) ()
59 #endif
60
61
62
63
64 #define DBM_INSERT 0
65 #define DBM_REPLACE 1
66
67
68
69
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 *));
77
78
79
80
81 extern DBM *sdbm_prep proto((char *, char *, int, int));
82 extern long sdbm_hash proto((char *, int));
83
84 #endif