ruby-qdbm 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/Gemfile +13 -0
- data/README.md +37 -0
- data/Rakefile +65 -0
- data/ext/curia/MANIFEST +5 -0
- data/ext/curia/extconf.rb +18 -0
- data/ext/curia/mod_curia.c +491 -0
- data/ext/depot/MANIFEST +5 -0
- data/ext/depot/extconf.rb +18 -0
- data/ext/depot/mod_depot.c +488 -0
- data/ext/villa/MANIFEST +5 -0
- data/ext/villa/extconf.rb +18 -0
- data/ext/villa/mod_villa.c +704 -0
- data/lib/curia.rb +598 -0
- data/lib/depot.rb +594 -0
- data/lib/villa.rb +816 -0
- data/myrbdoc +194 -0
- data/overview +6 -0
- data/rbapidoc/curia.rb.html +430 -0
- data/rbapidoc/depot.rb.html +426 -0
- data/rbapidoc/index.html +46 -0
- data/rbapidoc/villa.rb.html +551 -0
- data/rbspex-ja.html +284 -0
- data/rbspex.html +284 -0
- data/ruby-qdbm.gemspec +36 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5cdd8b88a98aee4df6f87be66e8b2c043af2f9382dd19cf970cb155aaab76cf8
|
4
|
+
data.tar.gz: b4e917cc0fa84b194a5ecfefaa6b5f45fd504afc80387e93f84871827fb1226a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f596c32e805be65b9fd3e915236174c7bac5d2c674a071ffca1256d6eda346093d08a44c763e2e85b8601d17cc57016542cbe25b2988ee9f5f01d84356970c0b
|
7
|
+
data.tar.gz: 8b088c78315242b5dea2b1c4f92add5584e45042cb0a41a194d5b4115aa388a7c6dc647d1b46ce8260968c9183e1ae90c7be85deda0c82b5028df47e813c2088
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in ruby-qdbm.gemspec
|
8
|
+
gemspec
|
9
|
+
|
10
|
+
# Local Variables:
|
11
|
+
# mode: Ruby
|
12
|
+
# indent-tabs-mode: nil
|
13
|
+
# End:
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# ruby-qdbm
|
2
|
+
|
3
|
+
QDBM is Quick Database Manager of https://fallabs.com/qdbm/.
|
4
|
+
This gem provides QDBM ruby extension libraries (depot/curia/villa).
|
5
|
+
|
6
|
+
The modifications from original are as follows.
|
7
|
+
|
8
|
+
1. The Debian patch is applied for the latest version of ruby.
|
9
|
+
2. Repacked to rubygems.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'ruby-qdbm'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install ruby-qdbm
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
See https://fallabs.com/qdbm/rbspex.html.
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/y10k/ruby-qdbm.
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
The gem is available as open source under the terms of the [LGPL-2.1](https://www.gnu.org/licenses/lgpl-2.1.html).
|
data/Rakefile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'rake/extensiontask'
|
6
|
+
|
7
|
+
task :default => :compile
|
8
|
+
|
9
|
+
Rake::ExtensionTask.new do |task|
|
10
|
+
task.name = 'mod_depot'
|
11
|
+
task.ext_dir = 'ext/depot'
|
12
|
+
end
|
13
|
+
|
14
|
+
Rake::ExtensionTask.new do |task|
|
15
|
+
task.name = 'mod_curia'
|
16
|
+
task.ext_dir = 'ext/curia'
|
17
|
+
end
|
18
|
+
|
19
|
+
Rake::ExtensionTask.new do |task|
|
20
|
+
task.name = 'mod_villa'
|
21
|
+
task.ext_dir = 'ext/villa'
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Test'
|
25
|
+
task :test => [ :rbdptest, :rbcrtest, :rbvltest ]
|
26
|
+
|
27
|
+
class QDBMTestTask < Rake::TaskLib
|
28
|
+
def initialize(name, *args)
|
29
|
+
@name = name
|
30
|
+
@args = args
|
31
|
+
define
|
32
|
+
end
|
33
|
+
|
34
|
+
def define
|
35
|
+
desc "#{@name}test"
|
36
|
+
task("#{@name}test") { run }
|
37
|
+
CLOBBER.include "test/#{@name}casket"
|
38
|
+
end
|
39
|
+
private :define
|
40
|
+
|
41
|
+
def run
|
42
|
+
rm_rf "test/#{@name}casket"
|
43
|
+
ruby "test/#{@name}test", 'write', "test/#{@name}casket", *@args
|
44
|
+
ruby "test/#{@name}test", 'read', "test/#{@name}casket"
|
45
|
+
ruby "test/#{@name}test", 'misc', "test/#{@name}casket"
|
46
|
+
end
|
47
|
+
private :run
|
48
|
+
end
|
49
|
+
|
50
|
+
QDBMTestTask.new('rbdp', '10000', '1000')
|
51
|
+
QDBMTestTask.new('rbcr', '10000', '1000', '10')
|
52
|
+
QDBMTestTask.new('rbvl', '10000')
|
53
|
+
|
54
|
+
desc 'Build README.html from markdown source.'
|
55
|
+
task :readme => %w[ README.html ]
|
56
|
+
|
57
|
+
file 'README.html' => [ 'README.md' ] do
|
58
|
+
sh "pandoc --from=markdown --to=html5 --standalone --self-contained --css=$HOME/.pandoc/github.css --output=README.html README.md"
|
59
|
+
end
|
60
|
+
CLOBBER.include 'README.html'
|
61
|
+
|
62
|
+
# Local Variables:
|
63
|
+
# mode: Ruby
|
64
|
+
# indent-tabs-mode: nil
|
65
|
+
# End:
|
data/ext/curia/MANIFEST
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
dir_config("curia")
|
4
|
+
|
5
|
+
home = ENV['HOME']
|
6
|
+
$CFLAGS = "-I. -I#{home}/include -I/usr/local/include " + `pkg-config qdbm --cflags`.chomp
|
7
|
+
$LDFLAGS = "-L#{home}/lib -L/usr/local/lib " + `pkg-config qdbm --libs`.chomp
|
8
|
+
$LIBS = "-L#{home}/lib -L/usr/local/lib " + `pkg-config qdbm --libs`.chomp
|
9
|
+
|
10
|
+
have_library("c", "main")
|
11
|
+
have_library("pthread", "main")
|
12
|
+
have_library("z", "main")
|
13
|
+
have_library("bz2", "main")
|
14
|
+
have_library("lzo2", "main")
|
15
|
+
have_library("iconv", "main")
|
16
|
+
have_library("qdbm", "main")
|
17
|
+
|
18
|
+
create_makefile("mod_curia")
|
@@ -0,0 +1,491 @@
|
|
1
|
+
/*************************************************************************************************
|
2
|
+
* Implementation of Curia for Ruby
|
3
|
+
* Copyright (C) 2000-2006 Mikio Hirabayashi
|
4
|
+
* This file is part of QDBM, Quick Database Manager.
|
5
|
+
* QDBM is free software; you can redistribute it and/or modify it under the terms of the GNU
|
6
|
+
* Lesser General Public License as published by the Free Software Foundation; either version
|
7
|
+
* 2.1 of the License or any later version. QDBM is distributed in the hope that it will be
|
8
|
+
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
9
|
+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
|
10
|
+
* details.
|
11
|
+
* You should have received a copy of the GNU Lesser General Public License along with QDBM; if
|
12
|
+
* not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
13
|
+
* 02111-1307 USA.
|
14
|
+
*************************************************************************************************/
|
15
|
+
|
16
|
+
|
17
|
+
#include "ruby.h"
|
18
|
+
#include <depot.h>
|
19
|
+
#include <curia.h>
|
20
|
+
#include <stdlib.h>
|
21
|
+
#include <unistd.h>
|
22
|
+
#include <sys/types.h>
|
23
|
+
#include <sys/stat.h>
|
24
|
+
|
25
|
+
#define MAXOPEN 1024
|
26
|
+
|
27
|
+
#ifndef RUBY_19
|
28
|
+
#ifndef RSTRING_LEN
|
29
|
+
#define RSTRING_LEN(v) (RSTRING(v)->len)
|
30
|
+
#endif
|
31
|
+
#endif
|
32
|
+
|
33
|
+
VALUE ccuriaerror;
|
34
|
+
VALUE ccuriaerror_ENOERR;
|
35
|
+
VALUE ccuriaerror_EFATAL;
|
36
|
+
VALUE ccuriaerror_EMODE;
|
37
|
+
VALUE ccuriaerror_EBROKEN;
|
38
|
+
VALUE ccuriaerror_EKEEP;
|
39
|
+
VALUE ccuriaerror_ENOITEM;
|
40
|
+
VALUE ccuriaerror_EALLOC;
|
41
|
+
VALUE ccuriaerror_EMAP;
|
42
|
+
VALUE ccuriaerror_EOPEN;
|
43
|
+
VALUE ccuriaerror_ECLOSE;
|
44
|
+
VALUE ccuriaerror_ETRUNC;
|
45
|
+
VALUE ccuriaerror_ESYNC;
|
46
|
+
VALUE ccuriaerror_ESTAT;
|
47
|
+
VALUE ccuriaerror_ESEEK;
|
48
|
+
VALUE ccuriaerror_EREAD;
|
49
|
+
VALUE ccuriaerror_EWRITE;
|
50
|
+
VALUE ccuriaerror_ELOCK;
|
51
|
+
VALUE ccuriaerror_EUNLINK;
|
52
|
+
VALUE ccuriaerror_EMKDIR;
|
53
|
+
VALUE ccuriaerror_ERMDIR;
|
54
|
+
VALUE ccuriaerror_EMISC;
|
55
|
+
VALUE mcuria;
|
56
|
+
CURIA *crtable[MAXOPEN];
|
57
|
+
char crsltable[MAXOPEN];
|
58
|
+
|
59
|
+
|
60
|
+
static void crinit(void);
|
61
|
+
static int getnewindex(void);
|
62
|
+
static int checkdup(const char *name);
|
63
|
+
static void myerror(int ecode);
|
64
|
+
static VALUE rbcrversion(VALUE vself);
|
65
|
+
static VALUE rbcrerrmsg(VALUE vself, VALUE vecode);
|
66
|
+
static VALUE rbcropen(VALUE vself, VALUE vname, VALUE vomode, VALUE vbnum, VALUE vdnum);
|
67
|
+
static VALUE rbcrclose(VALUE vself, VALUE vindex);
|
68
|
+
static VALUE rbcrsetsilent(VALUE vself, VALUE vindex, VALUE vvalue);
|
69
|
+
static VALUE rbcrput(VALUE vself, VALUE vindex, VALUE vkey, VALUE vval, VALUE vdmode);
|
70
|
+
static VALUE rbcrout(VALUE vself, VALUE vindex, VALUE vkey);
|
71
|
+
static VALUE rbcrget(VALUE vself, VALUE vindex, VALUE vkey, VALUE vstart, VALUE vmax);
|
72
|
+
static VALUE rbcrvsiz(VALUE vself, VALUE vindex, VALUE vkey);
|
73
|
+
static VALUE rbcriterinit(VALUE vself, VALUE vindex);
|
74
|
+
static VALUE rbcriternext(VALUE vself, VALUE vindex);
|
75
|
+
static VALUE rbcrsetalign(VALUE vself, VALUE vindex, VALUE valign);
|
76
|
+
static VALUE rbcrsetfbpsiz(VALUE vself, VALUE vindex, VALUE vsize);
|
77
|
+
static VALUE rbcrsync(VALUE vself, VALUE vindex);
|
78
|
+
static VALUE rbcroptimize(VALUE vself, VALUE vindex, VALUE vbnum);
|
79
|
+
static VALUE rbcrfsiz(VALUE vself, VALUE vindex);
|
80
|
+
static VALUE rbcrbnum(VALUE vself, VALUE vindex);
|
81
|
+
static VALUE rbcrrnum(VALUE vself, VALUE vindex);
|
82
|
+
static VALUE rbcrwritable(VALUE vself, VALUE vindex);
|
83
|
+
static VALUE rbcrfatalerror(VALUE vself, VALUE vindex);
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
/*************************************************************************************************
|
88
|
+
* public objects
|
89
|
+
*************************************************************************************************/
|
90
|
+
|
91
|
+
|
92
|
+
Init_mod_curia(){
|
93
|
+
crinit();
|
94
|
+
ccuriaerror = rb_define_class("CuriaError", rb_eStandardError);
|
95
|
+
ccuriaerror_ENOERR = rb_define_class("CuriaError_ENOERR", ccuriaerror);
|
96
|
+
ccuriaerror_EFATAL = rb_define_class("CuriaError_EFATAL", ccuriaerror);
|
97
|
+
ccuriaerror_EMODE = rb_define_class("CuriaError_EMODE", ccuriaerror);
|
98
|
+
ccuriaerror_EBROKEN = rb_define_class("CuriaError_EBROKEN", ccuriaerror);
|
99
|
+
ccuriaerror_EKEEP = rb_define_class("CuriaError_EKEEP", ccuriaerror);
|
100
|
+
ccuriaerror_ENOITEM = rb_define_class("CuriaError_ENOITEM", ccuriaerror);
|
101
|
+
ccuriaerror_EALLOC = rb_define_class("CuriaError_EALLOC", ccuriaerror);
|
102
|
+
ccuriaerror_EMAP = rb_define_class("CuriaError_EMAP", ccuriaerror);
|
103
|
+
ccuriaerror_EOPEN = rb_define_class("CuriaError_EOPEN", ccuriaerror);
|
104
|
+
ccuriaerror_ECLOSE = rb_define_class("CuriaError_ECLOSE", ccuriaerror);
|
105
|
+
ccuriaerror_ETRUNC = rb_define_class("CuriaError_ETRUNC", ccuriaerror);
|
106
|
+
ccuriaerror_ESYNC = rb_define_class("CuriaError_ESYNC", ccuriaerror);
|
107
|
+
ccuriaerror_ESTAT = rb_define_class("CuriaError_ESTAT", ccuriaerror);
|
108
|
+
ccuriaerror_ESEEK = rb_define_class("CuriaError_ESEEK", ccuriaerror);
|
109
|
+
ccuriaerror_EREAD = rb_define_class("CuriaError_EREAD", ccuriaerror);
|
110
|
+
ccuriaerror_EWRITE = rb_define_class("CuriaError_EWRITE", ccuriaerror);
|
111
|
+
ccuriaerror_ELOCK = rb_define_class("CuriaError_ELOCK", ccuriaerror);
|
112
|
+
ccuriaerror_EUNLINK = rb_define_class("CuriaError_EUNLINK", ccuriaerror);
|
113
|
+
ccuriaerror_EMKDIR = rb_define_class("CuriaError_EMKDIR", ccuriaerror);
|
114
|
+
ccuriaerror_ERMDIR = rb_define_class("CuriaError_ERMDIR", ccuriaerror);
|
115
|
+
ccuriaerror_EMISC = rb_define_class("CuriaError_EMISC", ccuriaerror);
|
116
|
+
mcuria = rb_define_module("Mod_Curia");
|
117
|
+
rb_define_const(mcuria, "EANY", ccuriaerror);
|
118
|
+
rb_define_const(mcuria, "ENOERR", ccuriaerror_ENOERR);
|
119
|
+
rb_define_const(mcuria, "EFATAL", ccuriaerror_EFATAL);
|
120
|
+
rb_define_const(mcuria, "EMODE", ccuriaerror_EMODE);
|
121
|
+
rb_define_const(mcuria, "EBROKEN", ccuriaerror_EBROKEN);
|
122
|
+
rb_define_const(mcuria, "EKEEP", ccuriaerror_EKEEP);
|
123
|
+
rb_define_const(mcuria, "ENOITEM", ccuriaerror_ENOITEM);
|
124
|
+
rb_define_const(mcuria, "EALLOC", ccuriaerror_EALLOC);
|
125
|
+
rb_define_const(mcuria, "EMAP", ccuriaerror_EMAP);
|
126
|
+
rb_define_const(mcuria, "EOPEN", ccuriaerror_EOPEN);
|
127
|
+
rb_define_const(mcuria, "ECLOSE", ccuriaerror_ECLOSE);
|
128
|
+
rb_define_const(mcuria, "ETRUNC", ccuriaerror_ETRUNC);
|
129
|
+
rb_define_const(mcuria, "ESYNC", ccuriaerror_ESYNC);
|
130
|
+
rb_define_const(mcuria, "ESTAT", ccuriaerror_ESTAT);
|
131
|
+
rb_define_const(mcuria, "ESEEK", ccuriaerror_ESEEK);
|
132
|
+
rb_define_const(mcuria, "EREAD", ccuriaerror_EREAD);
|
133
|
+
rb_define_const(mcuria, "EWRITE", ccuriaerror_EWRITE);
|
134
|
+
rb_define_const(mcuria, "ELOCK", ccuriaerror_ELOCK);
|
135
|
+
rb_define_const(mcuria, "EUNLINK", ccuriaerror_EUNLINK);
|
136
|
+
rb_define_const(mcuria, "EMKDIR", ccuriaerror_EMKDIR);
|
137
|
+
rb_define_const(mcuria, "ERMDIR", ccuriaerror_ERMDIR);
|
138
|
+
rb_define_const(mcuria, "EMISC", ccuriaerror_EMISC);
|
139
|
+
rb_define_const(mcuria, "OREADER", INT2FIX(CR_OREADER));
|
140
|
+
rb_define_const(mcuria, "OWRITER", INT2FIX(CR_OWRITER));
|
141
|
+
rb_define_const(mcuria, "OCREAT", INT2FIX(CR_OCREAT));
|
142
|
+
rb_define_const(mcuria, "OTRUNC", INT2FIX(CR_OTRUNC));
|
143
|
+
rb_define_const(mcuria, "ONOLCK", INT2FIX(CR_ONOLCK));
|
144
|
+
rb_define_const(mcuria, "OLCKNB", INT2FIX(CR_OLCKNB));
|
145
|
+
rb_define_const(mcuria, "OSPARSE", INT2FIX(CR_OSPARSE));
|
146
|
+
rb_define_const(mcuria, "DOVER", INT2FIX(CR_DOVER));
|
147
|
+
rb_define_const(mcuria, "DKEEP", INT2FIX(CR_DKEEP));
|
148
|
+
rb_define_const(mcuria, "DCAT", INT2FIX(CR_DCAT));
|
149
|
+
rb_define_module_function(mcuria, "mod_open", rbcropen, 4);
|
150
|
+
rb_define_module_function(mcuria, "mod_close", rbcrclose, 1);
|
151
|
+
rb_define_module_function(mcuria, "mod_setsilent", rbcrsetsilent, 2);
|
152
|
+
rb_define_module_function(mcuria, "mod_put", rbcrput, 4);
|
153
|
+
rb_define_module_function(mcuria, "mod_out", rbcrout, 2);
|
154
|
+
rb_define_module_function(mcuria, "mod_get", rbcrget, 4);
|
155
|
+
rb_define_module_function(mcuria, "mod_vsiz", rbcrvsiz, 2);
|
156
|
+
rb_define_module_function(mcuria, "mod_iterinit", rbcriterinit, 1);
|
157
|
+
rb_define_module_function(mcuria, "mod_iternext", rbcriternext, 1);
|
158
|
+
rb_define_module_function(mcuria, "mod_setalign", rbcrsetalign, 2);
|
159
|
+
rb_define_module_function(mcuria, "mod_setfbpsiz", rbcrsetfbpsiz, 2);
|
160
|
+
rb_define_module_function(mcuria, "mod_sync", rbcrsync, 1);
|
161
|
+
rb_define_module_function(mcuria, "mod_optimize", rbcroptimize, 2);
|
162
|
+
rb_define_module_function(mcuria, "mod_fsiz", rbcrfsiz, 1);
|
163
|
+
rb_define_module_function(mcuria, "mod_bnum", rbcrbnum, 1);
|
164
|
+
rb_define_module_function(mcuria, "mod_rnum", rbcrrnum, 1);
|
165
|
+
rb_define_module_function(mcuria, "mod_writable", rbcrwritable, 1);
|
166
|
+
rb_define_module_function(mcuria, "mod_fatalerror", rbcrfatalerror, 1);
|
167
|
+
}
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
/*************************************************************************************************
|
172
|
+
* private objects
|
173
|
+
*************************************************************************************************/
|
174
|
+
|
175
|
+
|
176
|
+
static void crinit(void){
|
177
|
+
int i;
|
178
|
+
for(i = 0; i < MAXOPEN; i++){
|
179
|
+
crtable[i] = NULL;
|
180
|
+
crsltable[i] = 0;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
|
185
|
+
static int getnewindex(void){
|
186
|
+
int i;
|
187
|
+
for(i = 0; i < MAXOPEN; i++){
|
188
|
+
if(crtable[i] == NULL) return i;
|
189
|
+
}
|
190
|
+
return -1;
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
static int checkdup(const char *name){
|
195
|
+
struct stat sbuf;
|
196
|
+
int i, inode;
|
197
|
+
if(stat(name, &sbuf) == -1) return 0;
|
198
|
+
inode = sbuf.st_ino;
|
199
|
+
for(i = 0; i < MAXOPEN; i++){
|
200
|
+
if(crtable[i] != NULL && crinode(crtable[i]) == inode) return -1;
|
201
|
+
}
|
202
|
+
return 0;
|
203
|
+
}
|
204
|
+
|
205
|
+
|
206
|
+
static void myerror(int ecode){
|
207
|
+
VALUE verr;
|
208
|
+
switch(ecode){
|
209
|
+
case DP_ENOERR: verr = ccuriaerror_ENOERR; break;
|
210
|
+
case DP_EFATAL: verr = ccuriaerror_EFATAL; break;
|
211
|
+
case DP_EMODE: verr = ccuriaerror_EMODE; break;
|
212
|
+
case DP_EBROKEN: verr = ccuriaerror_EBROKEN; break;
|
213
|
+
case DP_EKEEP: verr = ccuriaerror_EKEEP; break;
|
214
|
+
case DP_ENOITEM: verr = ccuriaerror_ENOITEM; break;
|
215
|
+
case DP_EALLOC: verr = ccuriaerror_EALLOC; break;
|
216
|
+
case DP_EMAP: verr = ccuriaerror_EMAP; break;
|
217
|
+
case DP_EOPEN: verr = ccuriaerror_EOPEN; break;
|
218
|
+
case DP_ECLOSE: verr = ccuriaerror_ECLOSE; break;
|
219
|
+
case DP_ETRUNC: verr = ccuriaerror_ETRUNC; break;
|
220
|
+
case DP_ESYNC: verr = ccuriaerror_ESYNC; break;
|
221
|
+
case DP_ESTAT: verr = ccuriaerror_ESTAT; break;
|
222
|
+
case DP_ESEEK: verr = ccuriaerror_ESEEK; break;
|
223
|
+
case DP_EREAD: verr = ccuriaerror_EREAD; break;
|
224
|
+
case DP_EWRITE: verr = ccuriaerror_EWRITE; break;
|
225
|
+
case DP_ELOCK: verr = ccuriaerror_ELOCK; break;
|
226
|
+
case DP_EUNLINK: verr = ccuriaerror_EUNLINK; break;
|
227
|
+
case DP_EMKDIR: verr = ccuriaerror_EMKDIR; break;
|
228
|
+
case DP_ERMDIR: verr = ccuriaerror_ERMDIR; break;
|
229
|
+
case DP_EMISC: verr = ccuriaerror_EMISC; break;
|
230
|
+
default: verr = ccuriaerror; break;
|
231
|
+
}
|
232
|
+
rb_raise(verr, "%s", dperrmsg(ecode));
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
static VALUE rbcropen(VALUE vself, VALUE vname, VALUE vomode, VALUE vbnum, VALUE vdnum){
|
237
|
+
CURIA *curia;
|
238
|
+
const char *name;
|
239
|
+
int index, omode, bnum, dnum;
|
240
|
+
if((index = getnewindex()) == -1) myerror(DP_EMISC);
|
241
|
+
name = StringValuePtr(vname);
|
242
|
+
FIXNUM_P(vomode);
|
243
|
+
omode = FIX2INT(vomode);
|
244
|
+
FIXNUM_P(vbnum);
|
245
|
+
bnum = FIX2INT(vbnum);
|
246
|
+
FIXNUM_P(vdnum);
|
247
|
+
dnum = FIX2INT(vdnum);
|
248
|
+
if(checkdup(name) == -1) myerror(DP_EMISC);
|
249
|
+
curia = cropen(name, omode, bnum, dnum);
|
250
|
+
if(!curia) myerror(dpecode);
|
251
|
+
crtable[index] = curia;
|
252
|
+
crsltable[index] = 0;
|
253
|
+
return INT2FIX(index);
|
254
|
+
}
|
255
|
+
|
256
|
+
|
257
|
+
static VALUE rbcrclose(VALUE vself, VALUE vindex){
|
258
|
+
CURIA *curia;
|
259
|
+
int index;
|
260
|
+
FIXNUM_P(vindex);
|
261
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
262
|
+
curia = crtable[index];
|
263
|
+
crtable[index] = NULL;
|
264
|
+
if(!crclose(curia)) myerror(dpecode);
|
265
|
+
return Qtrue;
|
266
|
+
}
|
267
|
+
|
268
|
+
|
269
|
+
static VALUE rbcrsetsilent(VALUE vself, VALUE vindex, VALUE vvalue){
|
270
|
+
int index;
|
271
|
+
FIXNUM_P(vindex);
|
272
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
273
|
+
crsltable[index] = FIX2INT(vvalue);
|
274
|
+
return Qnil;
|
275
|
+
}
|
276
|
+
|
277
|
+
|
278
|
+
static VALUE rbcrput(VALUE vself, VALUE vindex, VALUE vkey, VALUE vval, VALUE vdmode){
|
279
|
+
CURIA *curia;
|
280
|
+
const char *kbuf, *vbuf;
|
281
|
+
int index, ksiz, vsiz, dmode;
|
282
|
+
FIXNUM_P(vindex);
|
283
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
284
|
+
kbuf = StringValuePtr(vkey);
|
285
|
+
ksiz = RSTRING_LEN(vkey);
|
286
|
+
vbuf = StringValuePtr(vval);
|
287
|
+
vsiz = RSTRING_LEN(vval);
|
288
|
+
FIXNUM_P(vdmode);
|
289
|
+
dmode = FIX2INT(vdmode);
|
290
|
+
curia = crtable[index];
|
291
|
+
if(!crput(curia, kbuf, ksiz, vbuf, vsiz, dmode)){
|
292
|
+
if(crsltable[index] && dpecode == DP_EKEEP) return Qfalse;
|
293
|
+
myerror(dpecode);
|
294
|
+
}
|
295
|
+
return Qtrue;
|
296
|
+
}
|
297
|
+
|
298
|
+
|
299
|
+
static VALUE rbcrout(VALUE vself, VALUE vindex, VALUE vkey){
|
300
|
+
CURIA *curia;
|
301
|
+
const char *kbuf;
|
302
|
+
int index, ksiz;
|
303
|
+
FIXNUM_P(vindex);
|
304
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
305
|
+
kbuf = StringValuePtr(vkey);
|
306
|
+
ksiz = RSTRING_LEN(vkey);
|
307
|
+
curia = crtable[index];
|
308
|
+
if(!crout(curia, kbuf, ksiz)){
|
309
|
+
if(crsltable[index] && dpecode == DP_ENOITEM) return Qfalse;
|
310
|
+
myerror(dpecode);
|
311
|
+
}
|
312
|
+
return Qtrue;
|
313
|
+
}
|
314
|
+
|
315
|
+
|
316
|
+
static VALUE rbcrget(VALUE vself, VALUE vindex, VALUE vkey, VALUE vstart, VALUE vmax){
|
317
|
+
CURIA *curia;
|
318
|
+
const char *kbuf;
|
319
|
+
char *vbuf;
|
320
|
+
int index, ksiz, start, max, vsiz;
|
321
|
+
VALUE vval;
|
322
|
+
FIXNUM_P(vindex);
|
323
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
324
|
+
kbuf = StringValuePtr(vkey);
|
325
|
+
ksiz = RSTRING_LEN(vkey);
|
326
|
+
FIXNUM_P(vstart);
|
327
|
+
start = FIX2INT(vstart);
|
328
|
+
FIXNUM_P(vmax);
|
329
|
+
max = FIX2INT(vmax);
|
330
|
+
curia = crtable[index];
|
331
|
+
if(!(vbuf = crget(curia, kbuf, ksiz, start, max, &vsiz))){
|
332
|
+
if(crsltable[index] && dpecode == DP_ENOITEM) return Qnil;
|
333
|
+
myerror(dpecode);
|
334
|
+
}
|
335
|
+
vval = rb_str_new(vbuf, vsiz);
|
336
|
+
free(vbuf);
|
337
|
+
return vval;
|
338
|
+
}
|
339
|
+
|
340
|
+
|
341
|
+
static VALUE rbcrvsiz(VALUE vself, VALUE vindex, VALUE vkey){
|
342
|
+
CURIA *curia;
|
343
|
+
const char *kbuf;
|
344
|
+
int index, ksiz, vsiz;
|
345
|
+
FIXNUM_P(vindex);
|
346
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
347
|
+
kbuf = StringValuePtr(vkey);
|
348
|
+
ksiz = RSTRING_LEN(vkey);
|
349
|
+
curia = crtable[index];
|
350
|
+
if((vsiz = crvsiz(curia, kbuf, ksiz)) == -1){
|
351
|
+
if(crsltable[index] && dpecode == DP_ENOITEM) return INT2FIX(-1);
|
352
|
+
myerror(dpecode);
|
353
|
+
}
|
354
|
+
return INT2FIX(vsiz);
|
355
|
+
}
|
356
|
+
|
357
|
+
|
358
|
+
static VALUE rbcriterinit(VALUE vself, VALUE vindex){
|
359
|
+
CURIA *curia;
|
360
|
+
int index;
|
361
|
+
FIXNUM_P(vindex);
|
362
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
363
|
+
curia = crtable[index];
|
364
|
+
if(!criterinit(curia)) myerror(dpecode);
|
365
|
+
return Qtrue;
|
366
|
+
}
|
367
|
+
|
368
|
+
|
369
|
+
static VALUE rbcriternext(VALUE vself, VALUE vindex){
|
370
|
+
CURIA *curia;
|
371
|
+
char *kbuf;
|
372
|
+
int index, ksiz;
|
373
|
+
VALUE vkey;
|
374
|
+
FIXNUM_P(vindex);
|
375
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
376
|
+
curia = crtable[index];
|
377
|
+
if(!(kbuf = criternext(curia, &ksiz))){
|
378
|
+
if(crsltable[index] && dpecode == DP_ENOITEM) return Qnil;
|
379
|
+
myerror(dpecode);
|
380
|
+
}
|
381
|
+
vkey = rb_str_new(kbuf, ksiz);
|
382
|
+
free(kbuf);
|
383
|
+
return vkey;
|
384
|
+
}
|
385
|
+
|
386
|
+
|
387
|
+
static VALUE rbcrsetalign(VALUE vself, VALUE vindex, VALUE valign){
|
388
|
+
CURIA *curia;
|
389
|
+
int index, align;
|
390
|
+
FIXNUM_P(vindex);
|
391
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
392
|
+
FIXNUM_P(valign);
|
393
|
+
align = FIX2INT(valign);
|
394
|
+
curia = crtable[index];
|
395
|
+
if(!crsetalign(curia, align)) myerror(dpecode);
|
396
|
+
return Qtrue;
|
397
|
+
}
|
398
|
+
|
399
|
+
|
400
|
+
static VALUE rbcrsetfbpsiz(VALUE vself, VALUE vindex, VALUE vsize){
|
401
|
+
CURIA *curia;
|
402
|
+
int index, size;
|
403
|
+
FIXNUM_P(vindex);
|
404
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
405
|
+
FIXNUM_P(vsize);
|
406
|
+
size = FIX2INT(vsize);
|
407
|
+
curia = crtable[index];
|
408
|
+
if(!crsetfbpsiz(curia, size)) myerror(dpecode);
|
409
|
+
return Qtrue;
|
410
|
+
}
|
411
|
+
|
412
|
+
|
413
|
+
static VALUE rbcrsync(VALUE vself, VALUE vindex){
|
414
|
+
CURIA *curia;
|
415
|
+
int index;
|
416
|
+
FIXNUM_P(vindex);
|
417
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
418
|
+
curia = crtable[index];
|
419
|
+
if(!crsync(curia)) myerror(dpecode);
|
420
|
+
return Qtrue;
|
421
|
+
}
|
422
|
+
|
423
|
+
|
424
|
+
static VALUE rbcroptimize(VALUE vself, VALUE vindex, VALUE vbnum){
|
425
|
+
CURIA *curia;
|
426
|
+
int index, bnum;
|
427
|
+
FIXNUM_P(vindex);
|
428
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
429
|
+
FIXNUM_P(vbnum);
|
430
|
+
bnum = FIX2INT(vbnum);
|
431
|
+
curia = crtable[index];
|
432
|
+
if(!croptimize(curia, bnum)) myerror(dpecode);
|
433
|
+
return Qtrue;
|
434
|
+
}
|
435
|
+
|
436
|
+
|
437
|
+
static VALUE rbcrfsiz(VALUE vself, VALUE vindex){
|
438
|
+
CURIA *curia;
|
439
|
+
int index, fsiz;
|
440
|
+
FIXNUM_P(vindex);
|
441
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
442
|
+
curia = crtable[index];
|
443
|
+
if((fsiz = crfsiz(curia)) == -1) myerror(dpecode);
|
444
|
+
return INT2FIX(fsiz);
|
445
|
+
}
|
446
|
+
|
447
|
+
|
448
|
+
static VALUE rbcrbnum(VALUE vself, VALUE vindex){
|
449
|
+
CURIA *curia;
|
450
|
+
int index, bnum;
|
451
|
+
FIXNUM_P(vindex);
|
452
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
453
|
+
curia = crtable[index];
|
454
|
+
if((bnum = crbnum(curia)) == -1) myerror(dpecode);
|
455
|
+
return INT2FIX(bnum);
|
456
|
+
}
|
457
|
+
|
458
|
+
|
459
|
+
static VALUE rbcrrnum(VALUE vself, VALUE vindex){
|
460
|
+
CURIA *curia;
|
461
|
+
int index, rnum;
|
462
|
+
FIXNUM_P(vindex);
|
463
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
464
|
+
curia = crtable[index];
|
465
|
+
if((rnum = crrnum(curia)) == -1) myerror(dpecode);
|
466
|
+
return INT2FIX(rnum);
|
467
|
+
}
|
468
|
+
|
469
|
+
|
470
|
+
static VALUE rbcrwritable(VALUE vself, VALUE vindex){
|
471
|
+
CURIA *curia;
|
472
|
+
int index;
|
473
|
+
FIXNUM_P(vindex);
|
474
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
475
|
+
curia = crtable[index];
|
476
|
+
return crwritable(curia) ? Qtrue : Qfalse;
|
477
|
+
}
|
478
|
+
|
479
|
+
|
480
|
+
static VALUE rbcrfatalerror(VALUE vself, VALUE vindex){
|
481
|
+
CURIA *curia;
|
482
|
+
int index;
|
483
|
+
FIXNUM_P(vindex);
|
484
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
485
|
+
curia = crtable[index];
|
486
|
+
return crfatalerror(curia) ? Qtrue : Qfalse;
|
487
|
+
}
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
/* END OF FILE */
|