1 # DB_File.pm -- Perl 5 interface to Berkeley DB
3 # written by Paul Marquess (pmarquess@bfsec.bt.co.uk)
4 # last modified 23rd June 1994
7 package DB_File::HASHINFO ;
15 %elements = ( 'bsize' => 0,
25 return $_[0]{$_[1]} if defined $elements{$_[1]} ;
27 croak "DB_File::HASHINFO::FETCH - Unknown element '$_[1]'" ;
33 if ( defined $elements{$_[1]} )
35 $_[0]{$_[1]} = $_[2] ;
39 croak "DB_File::HASHINFO::STORE - Unknown element '$_[1]'" ;
44 if ( defined $elements{$_[1]} )
46 delete ${$_[0]}{$_[1]} ;
50 croak "DB_File::HASHINFO::DELETE - Unknown element '$_[1]'" ;
54 sub DESTROY {undef %{$_[0]} }
55 sub FIRSTKEY { croak "DB_File::HASHINFO::FIRSTKEY is not implemented" }
56 sub NEXTKEY { croak "DB_File::HASHINFO::NEXTKEY is not implemented" }
57 sub EXISTS { croak "DB_File::HASHINFO::EXISTS is not implemented" }
58 sub CLEAR { croak "DB_File::HASHINFO::CLEAR is not implemented" }
60 package DB_File::BTREEINFO ;
68 %elements = ( 'flags' => 0,
80 return $_[0]{$_[1]} if defined $elements{$_[1]} ;
82 croak "DB_File::BTREEINFO::FETCH - Unknown element '$_[1]'" ;
88 if ( defined $elements{$_[1]} )
90 $_[0]{$_[1]} = $_[2] ;
94 croak "DB_File::BTREEINFO::STORE - Unknown element '$_[1]'" ;
99 if ( defined $elements{$_[1]} )
101 delete ${$_[0]}{$_[1]} ;
105 croak "DB_File::BTREEINFO::DELETE - Unknown element '$_[1]'" ;
109 sub DESTROY {undef %{$_[0]} }
110 sub FIRSTKEY { croak "DB_File::BTREEINFO::FIRSTKEY is not implemented" }
111 sub NEXTKEY { croak "DB_File::BTREEINFO::NEXTKEY is not implemented" }
112 sub EXISTS { croak "DB_File::BTREEINFO::EXISTS is not implemented" }
113 sub CLEAR { croak "DB_File::BTREEINFO::CLEAR is not implemented" }
115 package DB_File::RECNOINFO ;
123 %elements = ( 'bval' => 0,
133 return $_[0]{$_[1]} if defined $elements{$_[1]} ;
135 croak "DB_File::RECNOINFO::FETCH - Unknown element '$_[1]'" ;
141 if ( defined $elements{$_[1]} )
143 $_[0]{$_[1]} = $_[2] ;
147 croak "DB_File::RECNOINFO::STORE - Unknown element '$_[1]'" ;
152 if ( defined $elements{$_[1]} )
154 delete ${$_[0]}{$_[1]} ;
158 croak "DB_File::RECNOINFO::DELETE - Unknown element '$_[1]'" ;
162 sub DESTROY {undef %{$_[0]} }
163 sub FIRSTKEY { croak "DB_File::RECNOINFO::FIRSTKEY is not implemented" }
164 sub NEXTKEY { croak "DB_File::RECNOINFO::NEXTKEY is not implemented" }
165 sub EXISTS { croak "DB_File::BTREEINFO::EXISTS is not implemented" }
166 sub CLEAR { croak "DB_File::BTREEINFO::CLEAR is not implemented" }
173 #typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE;
174 $DB_BTREE = TIEHASH DB_File::BTREEINFO ;
175 $DB_HASH = TIEHASH DB_File::HASHINFO ;
176 $DB_RECNO = TIEHASH DB_File::RECNOINFO ;
182 @ISA = qw(TieHash Exporter DynaLoader);
184 $DB_BTREE $DB_HASH $DB_RECNO
217 ($constname = $AUTOLOAD) =~ s/.*:://;
218 $val = constant($constname, @_ ? $_[0] : 0);
220 if ($! =~ /Invalid/) {
221 $AutoLoader::AUTOLOAD = $AUTOLOAD;
222 goto &AutoLoader::AUTOLOAD;
225 ($pack,$file,$line) = caller;
226 croak "Your vendor has not defined DB macro $constname, used at $file line $line.
230 eval "sub $AUTOLOAD { $val }";
235 @liblist = split ' ', $Config::Config{"DB_File_loadlibs"}
236 if defined $Config::Config{"DB_File_loadlibs"};
238 bootstrap DB_File @liblist;
240 # Preloaded methods go here. Autoload methods go after __END__, and are
241 # processed by the autosplit program.