1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# DB_File.pm -- Perl 5 interface to Berkeley DB
#
# written by Paul Marquess (pmarquess@bfsec.bt.co.uk)
# last modified 23rd June 1994
# version 0.1
package DB_File::HASHINFO ;
use Carp;
sub TIEHASH
{
bless {} ;
}
%elements = ( 'bsize' => 0,
'ffactor' => 0,
'nelem' => 0,
'cachesize' => 0,
'hash' => 0,
'lorder' => 0
) ;
sub FETCH
{
return $_[0]{$_[1]} if defined $elements{$_[1]} ;
croak "DB_File::HASHINFO::FETCH - Unknown element '$_[1]'" ;
}
sub STORE
{
if ( defined $elements{$_[1]} )
{
$_[0]{$_[1]} = $_[2] ;
return ;
}
croak "DB_File::HASHINFO::STORE - Unknown element '$_[1]'" ;
}
sub DELETE
{
if ( defined $elements{$_[1]} )
{
delete ${$_[0]}{$_[1]} ;
return ;
}
croak "DB_File::HASHINFO::DELETE - Unknown element '$_[1]'" ;
}
sub DESTROY {undef %{$_[0]} }
sub FIRSTKEY { croak "DB_File::HASHINFO::FIRSTKEY is not implemented" }
sub NEXTKEY { croak "DB_File::HASHINFO::NEXTKEY is not implemented" }
sub EXISTS { croak "DB_File::HASHINFO::EXISTS is not implemented" }
sub CLEAR { croak "DB_File::HASHINFO::CLEAR is not implemented" }
package DB_File::BTREEINFO ;
use Carp;
sub TIEHASH
{
bless {} ;
}
%elements = ( 'flags' => 0,
'cachesize' => 0,
'maxkeypage' => 0,
'minkeypage' => 0,
'psize' => 0,
'compare' => 0,
'prefix' => 0,
'lorder' => 0
) ;
sub FETCH
{
return $_[0]{$_[1]} if defined $elements{$_[1]} ;
croak "DB_File::BTREEINFO::FETCH - Unknown element '$_[1]'" ;
}
sub STORE
{
if ( defined $elements{$_[1]} )
{
$_[0]{$_[1]} = $_[2] ;
return ;
}
croak "DB_File::BTREEINFO::STORE - Unknown element '$_[1]'" ;
}
sub DELETE
{
if ( defined $elements{$_[1]} )
{
delete ${$_[0]}{$_[1]} ;
return ;
}
croak "DB_File::BTREEINFO::DELETE - Unknown element '$_[1]'" ;
}
sub DESTROY {undef %{$_[0]} }
sub FIRSTKEY { croak "DB_File::BTREEINFO::FIRSTKEY is not implemented" }
sub NEXTKEY { croak "DB_File::BTREEINFO::NEXTKEY is not implemented" }
sub EXISTS { croak "DB_File::BTREEINFO::EXISTS is not implemented" }
sub CLEAR { croak "DB_File::BTREEINFO::CLEAR is not implemented" }
package DB_File::RECNOINFO ;
use Carp;
sub TIEHASH
{
bless {} ;
}
%elements = ( 'bval' => 0,
'cachesize' => 0,
'psize' => 0,
'flags' => 0,
'lorder' => 0,
'reclen' => 0,
'bfname' => 0
) ;
sub FETCH
{
return $_[0]{$_[1]} if defined $elements{$_[1]} ;
croak "DB_File::RECNOINFO::FETCH - Unknown element '$_[1]'" ;
}
sub STORE
{
if ( defined $elements{$_[1]} )
{
$_[0]{$_[1]} = $_[2] ;
return ;
}
croak "DB_File::RECNOINFO::STORE - Unknown element '$_[1]'" ;
}
sub DELETE
{
if ( defined $elements{$_[1]} )
{
delete ${$_[0]}{$_[1]} ;
return ;
}
croak "DB_File::RECNOINFO::DELETE - Unknown element '$_[1]'" ;
}
sub DESTROY {undef %{$_[0]} }
sub FIRSTKEY { croak "DB_File::RECNOINFO::FIRSTKEY is not implemented" }
sub NEXTKEY { croak "DB_File::RECNOINFO::NEXTKEY is not implemented" }
sub EXISTS { croak "DB_File::BTREEINFO::EXISTS is not implemented" }
sub CLEAR { croak "DB_File::BTREEINFO::CLEAR is not implemented" }
package DB_File ;
use Carp;
#typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE;
$DB_BTREE = TIEHASH DB_File::BTREEINFO ;
$DB_HASH = TIEHASH DB_File::HASHINFO ;
$DB_RECNO = TIEHASH DB_File::RECNOINFO ;
require TieHash;
require Exporter;
require AutoLoader;
require DynaLoader;
@ISA = qw(TieHash Exporter DynaLoader);
@EXPORT = qw(
$DB_BTREE $DB_HASH $DB_RECNO
BTREEMAGIC
BTREEVERSION
DB_LOCK
DB_SHMEM
DB_TXN
HASHMAGIC
HASHVERSION
MAX_PAGE_NUMBER
MAX_PAGE_OFFSET
MAX_REC_NUMBER
RET_ERROR
RET_SPECIAL
RET_SUCCESS
R_CURSOR
R_DUP
R_FIRST
R_FIXEDLEN
R_IAFTER
R_IBEFORE
R_LAST
R_NEXT
R_NOKEY
R_NOOVERWRITE
R_PREV
R_RECNOSYNC
R_SETCURSOR
R_SNAPSHOT
__R_UNUSED
);
sub AUTOLOAD {
if (@_ > 1) {
$AutoLoader::AUTOLOAD = $AUTOLOAD;
goto &AutoLoader::AUTOLOAD;
}
local($constname);
($constname = $AUTOLOAD) =~ s/.*:://;
$val = constant($constname, @_ ? $_[0] : 0);
if ($! != 0) {
if ($! =~ /Invalid/) {
$AutoLoader::AUTOLOAD = $AUTOLOAD;
goto &AutoLoader::AUTOLOAD;
}
else {
($pack,$file,$line) = caller;
croak "Your vendor has not defined DB macro $constname, used at $file line $line.
";
}
}
eval "sub $AUTOLOAD { $val }";
goto &$AUTOLOAD;
}
@liblist = ();
@liblist = split ' ', $Config::Config{"DB_File_loadlibs"}
if defined $Config::Config{"DB_File_loadlibs"};
bootstrap DB_File @liblist;
# Preloaded methods go here. Autoload methods go after __END__, and are
# processed by the autosplit program.
1;
__END__
|