Ruby
1.9.3p551(2014-11-13revision48407)
Main Page
Modules
Data Structures
Files
File List
Globals
ext
sdbm
sdbm.h
Go to the documentation of this file.
1
/*
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.
6
*/
7
#ifndef _SDBM_H_
8
#define _SDBM_H_
9
10
#include <stdio.h>
11
12
#define DBLKSIZ 4096
13
#define PBLKSIZ 1024
14
#define PAIRMAX 1008
/* arbitrary on PBLKSIZ-N */
15
#define SPLTMAX 10
/* maximum allowed splits */
16
/* for a single insertion */
17
#define DIRFEXT ".dir"
18
#define PAGFEXT ".pag"
19
20
typedef
struct
{
21
int
dirf
;
/* directory file descriptor */
22
int
pagf
;
/* page file descriptor */
23
int
flags
;
/* status/error flags, see below */
24
int
keyptr
;
/* current key for nextkey */
25
off_t
maxbno
;
/* size of dirfile in bits */
26
long
curbit
;
/* current bit number */
27
long
hmask
;
/* current hash mask */
28
long
blkptr
;
/* current block for nextkey */
29
long
blkno
;
/* current page to read/write */
30
long
pagbno
;
/* current page in pagbuf */
31
char
pagbuf[
PBLKSIZ
];
/* page file block buffer */
32
long
dirbno
;
/* current block in dirbuf */
33
char
dirbuf[
DBLKSIZ
];
/* directory file block buffer */
34
}
DBM
;
35
36
#define DBM_RDONLY 0x1
/* data base open read-only */
37
#define DBM_IOERR 0x2
/* data base I/O error */
38
39
/*
40
* utility macros
41
*/
42
#define sdbm_rdonly(db) ((db)->flags & DBM_RDONLY)
43
#define sdbm_error(db) ((db)->flags & DBM_IOERR)
44
45
#define sdbm_clearerr(db) ((db)->flags &= ~DBM_IOERR)
/* ouch */
46
47
#define sdbm_dirfno(db) ((db)->dirf)
48
#define sdbm_pagfno(db) ((db)->pagf)
49
50
typedef
struct
{
51
char
*
dptr
;
52
int
dsize
;
53
}
datum
;
54
55
extern
datum
nullitem
;
56
57
#if defined(__STDC__)
58
#define proto(p) p
59
#else
60
#define proto(p) ()
61
#endif
62
63
/*
64
* flags to sdbm_store
65
*/
66
#define DBM_INSERT 0
67
#define DBM_REPLACE 1
68
69
/*
70
* ndbm interface
71
*/
72
extern
DBM
*
sdbm_open
proto
((
char
*,
int
,
int
));
73
extern
void
sdbm_close
proto
((
DBM
*));
74
extern
datum
sdbm_fetch
proto
((
DBM
*,
datum
));
75
extern
int
sdbm_delete
proto
((
DBM
*,
datum
));
76
extern
int
sdbm_store
proto
((
DBM
*,
datum
,
datum
,
int
));
77
extern
datum
sdbm_firstkey
proto
((
DBM
*));
78
extern
datum
sdbm_nextkey
proto
((
DBM
*));
79
80
/*
81
* other
82
*/
83
extern
DBM
*
sdbm_prep
proto
((
char
*,
char
*,
int
,
int
));
84
extern
long
sdbm_hash
proto
((
char
*,
int
));
85
86
#endif
/* _SDBM_H_ */
87
Generated on Fri Nov 14 2014 16:04:02 for Ruby by
1.8.3