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
data/ext/depot/MANIFEST
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
dir_config("depot")
|
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_depot")
|
@@ -0,0 +1,488 @@
|
|
1
|
+
/*************************************************************************************************
|
2
|
+
* Implementation of Depot 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 <stdlib.h>
|
20
|
+
#include <unistd.h>
|
21
|
+
#include <sys/types.h>
|
22
|
+
#include <sys/stat.h>
|
23
|
+
|
24
|
+
#define MAXOPEN 1024
|
25
|
+
|
26
|
+
#ifndef RUBY_19
|
27
|
+
#ifndef RSTRING_LEN
|
28
|
+
#define RSTRING_LEN(v) (RSTRING(v)->len)
|
29
|
+
#endif
|
30
|
+
#endif
|
31
|
+
|
32
|
+
VALUE cdepoterror;
|
33
|
+
VALUE cdepoterror_ENOERR;
|
34
|
+
VALUE cdepoterror_EFATAL;
|
35
|
+
VALUE cdepoterror_EMODE;
|
36
|
+
VALUE cdepoterror_EBROKEN;
|
37
|
+
VALUE cdepoterror_EKEEP;
|
38
|
+
VALUE cdepoterror_ENOITEM;
|
39
|
+
VALUE cdepoterror_EALLOC;
|
40
|
+
VALUE cdepoterror_EMAP;
|
41
|
+
VALUE cdepoterror_EOPEN;
|
42
|
+
VALUE cdepoterror_ECLOSE;
|
43
|
+
VALUE cdepoterror_ETRUNC;
|
44
|
+
VALUE cdepoterror_ESYNC;
|
45
|
+
VALUE cdepoterror_ESTAT;
|
46
|
+
VALUE cdepoterror_ESEEK;
|
47
|
+
VALUE cdepoterror_EREAD;
|
48
|
+
VALUE cdepoterror_EWRITE;
|
49
|
+
VALUE cdepoterror_ELOCK;
|
50
|
+
VALUE cdepoterror_EUNLINK;
|
51
|
+
VALUE cdepoterror_EMKDIR;
|
52
|
+
VALUE cdepoterror_ERMDIR;
|
53
|
+
VALUE cdepoterror_EMISC;
|
54
|
+
VALUE mdepot;
|
55
|
+
DEPOT *dptable[MAXOPEN];
|
56
|
+
char dpsltable[MAXOPEN];
|
57
|
+
|
58
|
+
|
59
|
+
static void dpinit(void);
|
60
|
+
static int getnewindex(void);
|
61
|
+
static int checkdup(const char *name);
|
62
|
+
static void myerror(int ecode);
|
63
|
+
static VALUE rbdpversion(VALUE vself);
|
64
|
+
static VALUE rbdperrmsg(VALUE vself, VALUE vecode);
|
65
|
+
static VALUE rbdpopen(VALUE vself, VALUE vname, VALUE vomode, VALUE vbnum);
|
66
|
+
static VALUE rbdpclose(VALUE vself, VALUE vindex);
|
67
|
+
static VALUE rbdpsetsilent(VALUE vself, VALUE vindex, VALUE vvalue);
|
68
|
+
static VALUE rbdpput(VALUE vself, VALUE vindex, VALUE vkey, VALUE vval, VALUE vdmode);
|
69
|
+
static VALUE rbdpout(VALUE vself, VALUE vindex, VALUE vkey);
|
70
|
+
static VALUE rbdpget(VALUE vself, VALUE vindex, VALUE vkey, VALUE vstart, VALUE vmax);
|
71
|
+
static VALUE rbdpvsiz(VALUE vself, VALUE vindex, VALUE vkey);
|
72
|
+
static VALUE rbdpiterinit(VALUE vself, VALUE vindex);
|
73
|
+
static VALUE rbdpiternext(VALUE vself, VALUE vindex);
|
74
|
+
static VALUE rbdpsetalign(VALUE vself, VALUE vindex, VALUE valign);
|
75
|
+
static VALUE rbdpsetfbpsiz(VALUE vself, VALUE vindex, VALUE vsize);
|
76
|
+
static VALUE rbdpsync(VALUE vself, VALUE vindex);
|
77
|
+
static VALUE rbdpoptimize(VALUE vself, VALUE vindex, VALUE vbnum);
|
78
|
+
static VALUE rbdpfsiz(VALUE vself, VALUE vindex);
|
79
|
+
static VALUE rbdpbnum(VALUE vself, VALUE vindex);
|
80
|
+
static VALUE rbdprnum(VALUE vself, VALUE vindex);
|
81
|
+
static VALUE rbdpwritable(VALUE vself, VALUE vindex);
|
82
|
+
static VALUE rbdpfatalerror(VALUE vself, VALUE vindex);
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
/*************************************************************************************************
|
87
|
+
* public objects
|
88
|
+
*************************************************************************************************/
|
89
|
+
|
90
|
+
|
91
|
+
Init_mod_depot(){
|
92
|
+
dpinit();
|
93
|
+
cdepoterror = rb_define_class("DepotError", rb_eStandardError);
|
94
|
+
cdepoterror_ENOERR = rb_define_class("DepotError_ENOERR", cdepoterror);
|
95
|
+
cdepoterror_EFATAL = rb_define_class("DepotError_EFATAL", cdepoterror);
|
96
|
+
cdepoterror_EMODE = rb_define_class("DepotError_EMODE", cdepoterror);
|
97
|
+
cdepoterror_EBROKEN = rb_define_class("DepotError_EBROKEN", cdepoterror);
|
98
|
+
cdepoterror_EKEEP = rb_define_class("DepotError_EKEEP", cdepoterror);
|
99
|
+
cdepoterror_ENOITEM = rb_define_class("DepotError_ENOITEM", cdepoterror);
|
100
|
+
cdepoterror_EALLOC = rb_define_class("DepotError_EALLOC", cdepoterror);
|
101
|
+
cdepoterror_EMAP = rb_define_class("DepotError_EMAP", cdepoterror);
|
102
|
+
cdepoterror_EOPEN = rb_define_class("DepotError_EOPEN", cdepoterror);
|
103
|
+
cdepoterror_ECLOSE = rb_define_class("DepotError_ECLOSE", cdepoterror);
|
104
|
+
cdepoterror_ETRUNC = rb_define_class("DepotError_ETRUNC", cdepoterror);
|
105
|
+
cdepoterror_ESYNC = rb_define_class("DepotError_ESYNC", cdepoterror);
|
106
|
+
cdepoterror_ESTAT = rb_define_class("DepotError_ESTAT", cdepoterror);
|
107
|
+
cdepoterror_ESEEK = rb_define_class("DepotError_ESEEK", cdepoterror);
|
108
|
+
cdepoterror_EREAD = rb_define_class("DepotError_EREAD", cdepoterror);
|
109
|
+
cdepoterror_EWRITE = rb_define_class("DepotError_EWRITE", cdepoterror);
|
110
|
+
cdepoterror_ELOCK = rb_define_class("DepotError_ELOCK", cdepoterror);
|
111
|
+
cdepoterror_EUNLINK = rb_define_class("DepotError_EUNLINK", cdepoterror);
|
112
|
+
cdepoterror_EMKDIR = rb_define_class("DepotError_EMKDIR", cdepoterror);
|
113
|
+
cdepoterror_ERMDIR = rb_define_class("DepotError_ERMDIR", cdepoterror);
|
114
|
+
cdepoterror_EMISC = rb_define_class("DepotError_EMISC", cdepoterror);
|
115
|
+
mdepot = rb_define_module("Mod_Depot");
|
116
|
+
rb_define_const(mdepot, "EANY", cdepoterror);
|
117
|
+
rb_define_const(mdepot, "ENOERR", cdepoterror_ENOERR);
|
118
|
+
rb_define_const(mdepot, "EFATAL", cdepoterror_EFATAL);
|
119
|
+
rb_define_const(mdepot, "EMODE", cdepoterror_EMODE);
|
120
|
+
rb_define_const(mdepot, "EBROKEN", cdepoterror_EBROKEN);
|
121
|
+
rb_define_const(mdepot, "EKEEP", cdepoterror_EKEEP);
|
122
|
+
rb_define_const(mdepot, "ENOITEM", cdepoterror_ENOITEM);
|
123
|
+
rb_define_const(mdepot, "EALLOC", cdepoterror_EALLOC);
|
124
|
+
rb_define_const(mdepot, "EMAP", cdepoterror_EMAP);
|
125
|
+
rb_define_const(mdepot, "EOPEN", cdepoterror_EOPEN);
|
126
|
+
rb_define_const(mdepot, "ECLOSE", cdepoterror_ECLOSE);
|
127
|
+
rb_define_const(mdepot, "ETRUNC", cdepoterror_ETRUNC);
|
128
|
+
rb_define_const(mdepot, "ESYNC", cdepoterror_ESYNC);
|
129
|
+
rb_define_const(mdepot, "ESTAT", cdepoterror_ESTAT);
|
130
|
+
rb_define_const(mdepot, "ESEEK", cdepoterror_ESEEK);
|
131
|
+
rb_define_const(mdepot, "EREAD", cdepoterror_EREAD);
|
132
|
+
rb_define_const(mdepot, "EWRITE", cdepoterror_EWRITE);
|
133
|
+
rb_define_const(mdepot, "ELOCK", cdepoterror_ELOCK);
|
134
|
+
rb_define_const(mdepot, "EUNLINK", cdepoterror_EUNLINK);
|
135
|
+
rb_define_const(mdepot, "EMKDIR", cdepoterror_EMKDIR);
|
136
|
+
rb_define_const(mdepot, "ERMDIR", cdepoterror_ERMDIR);
|
137
|
+
rb_define_const(mdepot, "EMISC", cdepoterror_EMISC);
|
138
|
+
rb_define_const(mdepot, "OREADER", INT2FIX(DP_OREADER));
|
139
|
+
rb_define_const(mdepot, "OWRITER", INT2FIX(DP_OWRITER));
|
140
|
+
rb_define_const(mdepot, "OCREAT", INT2FIX(DP_OCREAT));
|
141
|
+
rb_define_const(mdepot, "OTRUNC", INT2FIX(DP_OTRUNC));
|
142
|
+
rb_define_const(mdepot, "ONOLCK", INT2FIX(DP_ONOLCK));
|
143
|
+
rb_define_const(mdepot, "OLCKNB", INT2FIX(DP_OLCKNB));
|
144
|
+
rb_define_const(mdepot, "OSPARSE", INT2FIX(DP_OSPARSE));
|
145
|
+
rb_define_const(mdepot, "DOVER", INT2FIX(DP_DOVER));
|
146
|
+
rb_define_const(mdepot, "DKEEP", INT2FIX(DP_DKEEP));
|
147
|
+
rb_define_const(mdepot, "DCAT", INT2FIX(DP_DCAT));
|
148
|
+
rb_define_module_function(mdepot, "mod_open", rbdpopen, 3);
|
149
|
+
rb_define_module_function(mdepot, "mod_close", rbdpclose, 1);
|
150
|
+
rb_define_module_function(mdepot, "mod_setsilent", rbdpsetsilent, 2);
|
151
|
+
rb_define_module_function(mdepot, "mod_put", rbdpput, 4);
|
152
|
+
rb_define_module_function(mdepot, "mod_out", rbdpout, 2);
|
153
|
+
rb_define_module_function(mdepot, "mod_get", rbdpget, 4);
|
154
|
+
rb_define_module_function(mdepot, "mod_vsiz", rbdpvsiz, 2);
|
155
|
+
rb_define_module_function(mdepot, "mod_iterinit", rbdpiterinit, 1);
|
156
|
+
rb_define_module_function(mdepot, "mod_iternext", rbdpiternext, 1);
|
157
|
+
rb_define_module_function(mdepot, "mod_setalign", rbdpsetalign, 2);
|
158
|
+
rb_define_module_function(mdepot, "mod_setfbpsiz", rbdpsetfbpsiz, 2);
|
159
|
+
rb_define_module_function(mdepot, "mod_sync", rbdpsync, 1);
|
160
|
+
rb_define_module_function(mdepot, "mod_optimize", rbdpoptimize, 2);
|
161
|
+
rb_define_module_function(mdepot, "mod_fsiz", rbdpfsiz, 1);
|
162
|
+
rb_define_module_function(mdepot, "mod_bnum", rbdpbnum, 1);
|
163
|
+
rb_define_module_function(mdepot, "mod_rnum", rbdprnum, 1);
|
164
|
+
rb_define_module_function(mdepot, "mod_writable", rbdpwritable, 1);
|
165
|
+
rb_define_module_function(mdepot, "mod_fatalerror", rbdpfatalerror, 1);
|
166
|
+
}
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
/*************************************************************************************************
|
171
|
+
* private objects
|
172
|
+
*************************************************************************************************/
|
173
|
+
|
174
|
+
|
175
|
+
static void dpinit(void){
|
176
|
+
int i;
|
177
|
+
for(i = 0; i < MAXOPEN; i++){
|
178
|
+
dptable[i] = NULL;
|
179
|
+
dpsltable[i] = 0;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
|
184
|
+
static int getnewindex(void){
|
185
|
+
int i;
|
186
|
+
for(i = 0; i < MAXOPEN; i++){
|
187
|
+
if(dptable[i] == NULL) return i;
|
188
|
+
}
|
189
|
+
return -1;
|
190
|
+
}
|
191
|
+
|
192
|
+
|
193
|
+
static int checkdup(const char *name){
|
194
|
+
struct stat sbuf;
|
195
|
+
int i, inode;
|
196
|
+
if(stat(name, &sbuf) == -1) return 0;
|
197
|
+
inode = sbuf.st_ino;
|
198
|
+
for(i = 0; i < MAXOPEN; i++){
|
199
|
+
if(dptable[i] != NULL && dpinode(dptable[i]) == inode) return -1;
|
200
|
+
}
|
201
|
+
return 0;
|
202
|
+
}
|
203
|
+
|
204
|
+
|
205
|
+
static void myerror(int ecode){
|
206
|
+
VALUE verr;
|
207
|
+
switch(ecode){
|
208
|
+
case DP_ENOERR: verr = cdepoterror_ENOERR; break;
|
209
|
+
case DP_EFATAL: verr = cdepoterror_EFATAL; break;
|
210
|
+
case DP_EMODE: verr = cdepoterror_EMODE; break;
|
211
|
+
case DP_EBROKEN: verr = cdepoterror_EBROKEN; break;
|
212
|
+
case DP_EKEEP: verr = cdepoterror_EKEEP; break;
|
213
|
+
case DP_ENOITEM: verr = cdepoterror_ENOITEM; break;
|
214
|
+
case DP_EALLOC: verr = cdepoterror_EALLOC; break;
|
215
|
+
case DP_EMAP: verr = cdepoterror_EMAP; break;
|
216
|
+
case DP_EOPEN: verr = cdepoterror_EOPEN; break;
|
217
|
+
case DP_ECLOSE: verr = cdepoterror_ECLOSE; break;
|
218
|
+
case DP_ETRUNC: verr = cdepoterror_ETRUNC; break;
|
219
|
+
case DP_ESYNC: verr = cdepoterror_ESYNC; break;
|
220
|
+
case DP_ESTAT: verr = cdepoterror_ESTAT; break;
|
221
|
+
case DP_ESEEK: verr = cdepoterror_ESEEK; break;
|
222
|
+
case DP_EREAD: verr = cdepoterror_EREAD; break;
|
223
|
+
case DP_EWRITE: verr = cdepoterror_EWRITE; break;
|
224
|
+
case DP_ELOCK: verr = cdepoterror_ELOCK; break;
|
225
|
+
case DP_EUNLINK: verr = cdepoterror_EUNLINK; break;
|
226
|
+
case DP_EMKDIR: verr = cdepoterror_EMKDIR; break;
|
227
|
+
case DP_ERMDIR: verr = cdepoterror_ERMDIR; break;
|
228
|
+
case DP_EMISC: verr = cdepoterror_EMISC; break;
|
229
|
+
default: verr = cdepoterror; break;
|
230
|
+
}
|
231
|
+
rb_raise(verr, "%s", dperrmsg(ecode));
|
232
|
+
}
|
233
|
+
|
234
|
+
|
235
|
+
static VALUE rbdpopen(VALUE vself, VALUE vname, VALUE vomode, VALUE vbnum){
|
236
|
+
DEPOT *depot;
|
237
|
+
const char *name;
|
238
|
+
int index, omode, bnum;
|
239
|
+
if((index = getnewindex()) == -1) myerror(DP_EMISC);
|
240
|
+
name = StringValuePtr(vname);
|
241
|
+
FIXNUM_P(vomode);
|
242
|
+
omode = FIX2INT(vomode);
|
243
|
+
FIXNUM_P(vbnum);
|
244
|
+
bnum = FIX2INT(vbnum);
|
245
|
+
if(checkdup(name) == -1) myerror(DP_EMISC);
|
246
|
+
depot = dpopen(name, omode, bnum);
|
247
|
+
if(!depot) myerror(dpecode);
|
248
|
+
dptable[index] = depot;
|
249
|
+
dpsltable[index] = 0;
|
250
|
+
return INT2FIX(index);
|
251
|
+
}
|
252
|
+
|
253
|
+
|
254
|
+
static VALUE rbdpclose(VALUE vself, VALUE vindex){
|
255
|
+
DEPOT *depot;
|
256
|
+
int index;
|
257
|
+
FIXNUM_P(vindex);
|
258
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
259
|
+
depot = dptable[index];
|
260
|
+
dptable[index] = NULL;
|
261
|
+
if(!dpclose(depot)) myerror(dpecode);
|
262
|
+
return Qtrue;
|
263
|
+
}
|
264
|
+
|
265
|
+
|
266
|
+
static VALUE rbdpsetsilent(VALUE vself, VALUE vindex, VALUE vvalue){
|
267
|
+
int index;
|
268
|
+
FIXNUM_P(vindex);
|
269
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
270
|
+
dpsltable[index] = FIX2INT(vvalue);
|
271
|
+
return Qnil;
|
272
|
+
}
|
273
|
+
|
274
|
+
|
275
|
+
static VALUE rbdpput(VALUE vself, VALUE vindex, VALUE vkey, VALUE vval, VALUE vdmode){
|
276
|
+
DEPOT *depot;
|
277
|
+
const char *kbuf, *vbuf;
|
278
|
+
int index, ksiz, vsiz, dmode;
|
279
|
+
FIXNUM_P(vindex);
|
280
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
281
|
+
kbuf = StringValuePtr(vkey);
|
282
|
+
ksiz = RSTRING_LEN(vkey);
|
283
|
+
vbuf = StringValuePtr(vval);
|
284
|
+
vsiz = RSTRING_LEN(vval);
|
285
|
+
FIXNUM_P(vdmode);
|
286
|
+
dmode = FIX2INT(vdmode);
|
287
|
+
depot = dptable[index];
|
288
|
+
if(!dpput(depot, kbuf, ksiz, vbuf, vsiz, dmode)){
|
289
|
+
if(dpsltable[index] && dpecode == DP_EKEEP) return Qfalse;
|
290
|
+
myerror(dpecode);
|
291
|
+
}
|
292
|
+
return Qtrue;
|
293
|
+
}
|
294
|
+
|
295
|
+
|
296
|
+
static VALUE rbdpout(VALUE vself, VALUE vindex, VALUE vkey){
|
297
|
+
DEPOT *depot;
|
298
|
+
const char *kbuf;
|
299
|
+
int index, ksiz;
|
300
|
+
FIXNUM_P(vindex);
|
301
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
302
|
+
kbuf = StringValuePtr(vkey);
|
303
|
+
ksiz = RSTRING_LEN(vkey);
|
304
|
+
depot = dptable[index];
|
305
|
+
if(!dpout(depot, kbuf, ksiz)){
|
306
|
+
if(dpsltable[index] && dpecode == DP_ENOITEM) return Qfalse;
|
307
|
+
myerror(dpecode);
|
308
|
+
}
|
309
|
+
return Qtrue;
|
310
|
+
}
|
311
|
+
|
312
|
+
|
313
|
+
static VALUE rbdpget(VALUE vself, VALUE vindex, VALUE vkey, VALUE vstart, VALUE vmax){
|
314
|
+
DEPOT *depot;
|
315
|
+
const char *kbuf;
|
316
|
+
char *vbuf;
|
317
|
+
int index, ksiz, start, max, vsiz;
|
318
|
+
VALUE vval;
|
319
|
+
FIXNUM_P(vindex);
|
320
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
321
|
+
kbuf = StringValuePtr(vkey);
|
322
|
+
ksiz = RSTRING_LEN(vkey);
|
323
|
+
FIXNUM_P(vstart);
|
324
|
+
start = FIX2INT(vstart);
|
325
|
+
FIXNUM_P(vmax);
|
326
|
+
max = FIX2INT(vmax);
|
327
|
+
depot = dptable[index];
|
328
|
+
if(!(vbuf = dpget(depot, kbuf, ksiz, start, max, &vsiz))){
|
329
|
+
if(dpsltable[index] && dpecode == DP_ENOITEM) return Qnil;
|
330
|
+
myerror(dpecode);
|
331
|
+
}
|
332
|
+
vval = rb_str_new(vbuf, vsiz);
|
333
|
+
free(vbuf);
|
334
|
+
return vval;
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
static VALUE rbdpvsiz(VALUE vself, VALUE vindex, VALUE vkey){
|
339
|
+
DEPOT *depot;
|
340
|
+
const char *kbuf;
|
341
|
+
int index, ksiz, vsiz;
|
342
|
+
FIXNUM_P(vindex);
|
343
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
344
|
+
kbuf = StringValuePtr(vkey);
|
345
|
+
ksiz = RSTRING_LEN(vkey);
|
346
|
+
depot = dptable[index];
|
347
|
+
if((vsiz = dpvsiz(depot, kbuf, ksiz)) == -1){
|
348
|
+
if(dpsltable[index] && dpecode == DP_ENOITEM) return INT2FIX(-1);
|
349
|
+
myerror(dpecode);
|
350
|
+
}
|
351
|
+
return INT2FIX(vsiz);
|
352
|
+
}
|
353
|
+
|
354
|
+
|
355
|
+
static VALUE rbdpiterinit(VALUE vself, VALUE vindex){
|
356
|
+
DEPOT *depot;
|
357
|
+
int index;
|
358
|
+
FIXNUM_P(vindex);
|
359
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
360
|
+
depot = dptable[index];
|
361
|
+
if(!dpiterinit(depot)) myerror(dpecode);
|
362
|
+
return Qtrue;
|
363
|
+
}
|
364
|
+
|
365
|
+
|
366
|
+
static VALUE rbdpiternext(VALUE vself, VALUE vindex){
|
367
|
+
DEPOT *depot;
|
368
|
+
char *kbuf;
|
369
|
+
int index, ksiz;
|
370
|
+
VALUE vkey;
|
371
|
+
FIXNUM_P(vindex);
|
372
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
373
|
+
depot = dptable[index];
|
374
|
+
if(!(kbuf = dpiternext(depot, &ksiz))){
|
375
|
+
if(dpsltable[index] && dpecode == DP_ENOITEM) return Qnil;
|
376
|
+
myerror(dpecode);
|
377
|
+
}
|
378
|
+
vkey = rb_str_new(kbuf, ksiz);
|
379
|
+
free(kbuf);
|
380
|
+
return vkey;
|
381
|
+
}
|
382
|
+
|
383
|
+
|
384
|
+
static VALUE rbdpsetalign(VALUE vself, VALUE vindex, VALUE valign){
|
385
|
+
DEPOT *depot;
|
386
|
+
int index, align;
|
387
|
+
FIXNUM_P(vindex);
|
388
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
389
|
+
FIXNUM_P(valign);
|
390
|
+
align = FIX2INT(valign);
|
391
|
+
depot = dptable[index];
|
392
|
+
if(!dpsetalign(depot, align)) myerror(dpecode);
|
393
|
+
return Qtrue;
|
394
|
+
}
|
395
|
+
|
396
|
+
|
397
|
+
static VALUE rbdpsetfbpsiz(VALUE vself, VALUE vindex, VALUE vsize){
|
398
|
+
DEPOT *depot;
|
399
|
+
int index, size;
|
400
|
+
FIXNUM_P(vindex);
|
401
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
402
|
+
FIXNUM_P(vsize);
|
403
|
+
size = FIX2INT(vsize);
|
404
|
+
depot = dptable[index];
|
405
|
+
if(!dpsetfbpsiz(depot, size)) myerror(dpecode);
|
406
|
+
return Qtrue;
|
407
|
+
}
|
408
|
+
|
409
|
+
|
410
|
+
static VALUE rbdpsync(VALUE vself, VALUE vindex){
|
411
|
+
DEPOT *depot;
|
412
|
+
int index;
|
413
|
+
FIXNUM_P(vindex);
|
414
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
415
|
+
depot = dptable[index];
|
416
|
+
if(!dpsync(depot)) myerror(dpecode);
|
417
|
+
return Qtrue;
|
418
|
+
}
|
419
|
+
|
420
|
+
|
421
|
+
static VALUE rbdpoptimize(VALUE vself, VALUE vindex, VALUE vbnum){
|
422
|
+
DEPOT *depot;
|
423
|
+
int index, bnum;
|
424
|
+
FIXNUM_P(vindex);
|
425
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
426
|
+
FIXNUM_P(vbnum);
|
427
|
+
bnum = FIX2INT(vbnum);
|
428
|
+
depot = dptable[index];
|
429
|
+
if(!dpoptimize(depot, bnum)) myerror(dpecode);
|
430
|
+
return Qtrue;
|
431
|
+
}
|
432
|
+
|
433
|
+
|
434
|
+
static VALUE rbdpfsiz(VALUE vself, VALUE vindex){
|
435
|
+
DEPOT *depot;
|
436
|
+
int index, fsiz;
|
437
|
+
FIXNUM_P(vindex);
|
438
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
439
|
+
depot = dptable[index];
|
440
|
+
if((fsiz = dpfsiz(depot)) == -1) myerror(dpecode);
|
441
|
+
return INT2FIX(fsiz);
|
442
|
+
}
|
443
|
+
|
444
|
+
|
445
|
+
static VALUE rbdpbnum(VALUE vself, VALUE vindex){
|
446
|
+
DEPOT *depot;
|
447
|
+
int index, bnum;
|
448
|
+
FIXNUM_P(vindex);
|
449
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
450
|
+
depot = dptable[index];
|
451
|
+
if((bnum = dpbnum(depot)) == -1) myerror(dpecode);
|
452
|
+
return INT2FIX(bnum);
|
453
|
+
}
|
454
|
+
|
455
|
+
|
456
|
+
static VALUE rbdprnum(VALUE vself, VALUE vindex){
|
457
|
+
DEPOT *depot;
|
458
|
+
int index, rnum;
|
459
|
+
FIXNUM_P(vindex);
|
460
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
461
|
+
depot = dptable[index];
|
462
|
+
if((rnum = dprnum(depot)) == -1) myerror(dpecode);
|
463
|
+
return INT2FIX(rnum);
|
464
|
+
}
|
465
|
+
|
466
|
+
|
467
|
+
static VALUE rbdpwritable(VALUE vself, VALUE vindex){
|
468
|
+
DEPOT *depot;
|
469
|
+
int index;
|
470
|
+
FIXNUM_P(vindex);
|
471
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
472
|
+
depot = dptable[index];
|
473
|
+
return dpwritable(depot) ? Qtrue : Qfalse;
|
474
|
+
}
|
475
|
+
|
476
|
+
|
477
|
+
static VALUE rbdpfatalerror(VALUE vself, VALUE vindex){
|
478
|
+
DEPOT *depot;
|
479
|
+
int index;
|
480
|
+
FIXNUM_P(vindex);
|
481
|
+
if((index = FIX2INT(vindex)) == -1) myerror(DP_EMISC);
|
482
|
+
depot = dptable[index];
|
483
|
+
return dpfatalerror(depot) ? Qtrue : Qfalse;
|
484
|
+
}
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
/* END OF FILE */
|