sdbm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/sdbm/_sdbm.c +952 -0
- data/ext/sdbm/depend +25 -0
- data/ext/sdbm/extconf.rb +5 -0
- data/ext/sdbm/init.c +1067 -0
- data/ext/sdbm/sdbm.h +86 -0
- metadata +78 -0
data/ext/sdbm/sdbm.h
ADDED
@@ -0,0 +1,86 @@
|
|
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_ */
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sdbm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yukihiro Matsumoto
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: test-unit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake-compiler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Provides a simple file-based key-value store with String keys and values.
|
42
|
+
email:
|
43
|
+
- matz@ruby-lang.org
|
44
|
+
executables: []
|
45
|
+
extensions:
|
46
|
+
- ext/sdbm/extconf.rb
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ext/sdbm/_sdbm.c
|
50
|
+
- ext/sdbm/depend
|
51
|
+
- ext/sdbm/extconf.rb
|
52
|
+
- ext/sdbm/init.c
|
53
|
+
- ext/sdbm/sdbm.h
|
54
|
+
homepage: https://www.ruby-lang.org
|
55
|
+
licenses:
|
56
|
+
- BSD-2-Clause
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 2.5.0dev
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 2.6.11
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Provides a simple file-based key-value store with String keys and values.
|
78
|
+
test_files: []
|