rubysl-sdbm 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +25 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/ext/rubysl/sdbm/_sdbm.c +929 -0
- data/ext/rubysl/sdbm/extconf.rb +4 -0
- data/ext/rubysl/sdbm/init.c +713 -0
- data/ext/rubysl/sdbm/sdbm.h +86 -0
- data/lib/rubysl/sdbm.rb +2 -0
- data/lib/rubysl/sdbm/version.rb +5 -0
- data/lib/sdbm.rb +1 -0
- data/rubysl-sdbm.gemspec +23 -0
- metadata +101 -0
@@ -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_ */
|
data/lib/rubysl/sdbm.rb
ADDED
data/lib/sdbm.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "rubysl/sdbm"
|
data/rubysl-sdbm.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require './lib/rubysl/sdbm/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "rubysl-sdbm"
|
6
|
+
spec.version = RubySL::SDBM::VERSION
|
7
|
+
spec.authors = ["Brian Shirai"]
|
8
|
+
spec.email = ["brixen@gmail.com"]
|
9
|
+
spec.description = %q{Ruby standard library sdbm.}
|
10
|
+
spec.summary = %q{Ruby standard library sdbm.}
|
11
|
+
spec.homepage = "https://github.com/rubysl/rubysl-sdbm"
|
12
|
+
spec.license = "BSD"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.extensions = ["ext/rubysl/sdbm/extconf.rb"]
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "mspec", "~> 1.5"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubysl-sdbm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Shirai
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
description: Ruby standard library sdbm.
|
56
|
+
email:
|
57
|
+
- brixen@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions:
|
60
|
+
- ext/rubysl/sdbm/extconf.rb
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- .travis.yml
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- ext/rubysl/sdbm/_sdbm.c
|
70
|
+
- ext/rubysl/sdbm/extconf.rb
|
71
|
+
- ext/rubysl/sdbm/init.c
|
72
|
+
- ext/rubysl/sdbm/sdbm.h
|
73
|
+
- lib/rubysl/sdbm.rb
|
74
|
+
- lib/rubysl/sdbm/version.rb
|
75
|
+
- lib/sdbm.rb
|
76
|
+
- rubysl-sdbm.gemspec
|
77
|
+
homepage: https://github.com/rubysl/rubysl-sdbm
|
78
|
+
licenses:
|
79
|
+
- BSD
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.0.7
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Ruby standard library sdbm.
|
101
|
+
test_files: []
|