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