diff options
author | markm <markm@FreeBSD.org> | 2002-03-16 20:14:30 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2002-03-16 20:14:30 +0000 |
commit | 3eac21f49bc763a6c0044b4afbc0c7ece760144f (patch) | |
tree | 4cf1274fa3ca68f7ecf6a3051e0c2243e378afc5 /contrib/perl5/ext/NDBM_File | |
parent | 259bd53c06712c4ffb0ab7e06898c19ebf221b21 (diff) | |
download | FreeBSD-src-3eac21f49bc763a6c0044b4afbc0c7ece760144f.zip FreeBSD-src-3eac21f49bc763a6c0044b4afbc0c7ece760144f.tar.gz |
Vendor import Perl 5.6.1
Diffstat (limited to 'contrib/perl5/ext/NDBM_File')
-rw-r--r-- | contrib/perl5/ext/NDBM_File/Makefile.PL | 1 | ||||
-rw-r--r-- | contrib/perl5/ext/NDBM_File/NDBM_File.pm | 99 | ||||
-rw-r--r-- | contrib/perl5/ext/NDBM_File/NDBM_File.xs | 5 | ||||
-rw-r--r-- | contrib/perl5/ext/NDBM_File/typemap | 10 |
4 files changed, 101 insertions, 14 deletions
diff --git a/contrib/perl5/ext/NDBM_File/Makefile.PL b/contrib/perl5/ext/NDBM_File/Makefile.PL index 6ceab55..7b58601 100644 --- a/contrib/perl5/ext/NDBM_File/Makefile.PL +++ b/contrib/perl5/ext/NDBM_File/Makefile.PL @@ -5,4 +5,5 @@ WriteMakefile( MAN3PODS => {}, # Pods will be built by installman. XSPROTOARG => '-noprototypes', # XXX remove later? VERSION_FROM => 'NDBM_File.pm', + INC => ($^O eq "MacOS" ? "-i ::::db:include" : "") ); diff --git a/contrib/perl5/ext/NDBM_File/NDBM_File.pm b/contrib/perl5/ext/NDBM_File/NDBM_File.pm index f98669f..b280459 100644 --- a/contrib/perl5/ext/NDBM_File/NDBM_File.pm +++ b/contrib/perl5/ext/NDBM_File/NDBM_File.pm @@ -1,16 +1,13 @@ package NDBM_File; -BEGIN { - if ($] >= 5.002) { - use strict; - } -} +use strict; +use warnings; require Tie::Hash; use XSLoader (); our @ISA = qw(Tie::Hash); -our $VERSION = "1.03"; +our $VERSION = "1.04"; XSLoader::load 'NDBM_File', $VERSION; @@ -24,15 +21,93 @@ NDBM_File - Tied access to ndbm files =head1 SYNOPSIS - use NDBM_File; - use Fcntl; # for O_ constants + use Fcntl; # For O_RDWR, O_CREAT, etc. + use NDBM_File; - tie(%h, 'NDBM_File', 'Op.dbmx', O_RDWR|O_CREAT, 0640); + # Now read and change the hash + $h{newkey} = newvalue; + print $h{oldkey}; + ... + + untie %h; + +=head1 DESCRIPTION + +C<NDBM_File> establishes a connection between a Perl hash variable and +a file in NDBM_File format;. You can manipulate the data in the file +just as if it were in a Perl hash, but when your program exits, the +data will remain in the file, to be used the next time your program +runs. - untie %h; +Use C<NDBM_File> with the Perl built-in C<tie> function to establish +the connection between the variable and the file. The arguments to +C<tie> should be: -=head1 DESCRIPTION +=over 4 + +=item 1. + +The hash variable you want to tie. + +=item 2. + +The string C<"NDBM_File">. (Ths tells Perl to use the C<NDBM_File> +package to perform the functions of the hash.) + +=item 3. + +The name of the file you want to tie to the hash. + +=item 4. + +Flags. Use one of: + +=over 2 + +=item C<O_RDONLY> + +Read-only access to the data in the file. + +=item C<O_WRONLY> + +Write-only access to the data in the file. + +=item C<O_RDWR> + +Both read and write access. + +=back + +If you want to create the file if it does not exist, add C<O_CREAT> to +any of these, as in the example. If you omit C<O_CREAT> and the file +does not already exist, the C<tie> call will fail. + +=item 5. + +The default permissions to use if a new file is created. The actual +permissions will be modified by the user's umask, so you should +probably use 0666 here. (See L<perlfunc/umask>.) + +=back + +=head1 DIAGNOSTICS + +On failure, the C<tie> call returns an undefined value and probably +sets C<$!> to contain the reason the file could not be tied. + +=head2 C<ndbm store returned -1, errno 22, key "..." at ...> + +This warning is emmitted when you try to store a key or a value that +is too long. It means that the change was not recorded in the +database. See BUGS AND WARNINGS below. + +=head1 BUGS AND WARNINGS + +There are a number of limits on the size of the data that you can +store in the NDBM file. The most important is that the length of a +key, plus the length of its associated value, may not exceed 1008 +bytes. -See L<perlfunc/tie>, L<perldbmfilter> +See L<perlfunc/tie>, L<perldbmfilter>, L<Fcntl> =cut diff --git a/contrib/perl5/ext/NDBM_File/NDBM_File.xs b/contrib/perl5/ext/NDBM_File/NDBM_File.xs index 49a1db5..c417eb6 100644 --- a/contrib/perl5/ext/NDBM_File/NDBM_File.xs +++ b/contrib/perl5/ext/NDBM_File/NDBM_File.xs @@ -1,6 +1,11 @@ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +/* If using the DB3 emulation, ENTER is defined both + * by DB3 and Perl. We drop the Perl definition now. + * See also INSTALL section on DB3. + * -- Stanislav Brabec <utx@penguin.cz> */ +#undef ENTER #include <ndbm.h> typedef struct { diff --git a/contrib/perl5/ext/NDBM_File/typemap b/contrib/perl5/ext/NDBM_File/typemap index eeb5d59..40b95f2 100644 --- a/contrib/perl5/ext/NDBM_File/typemap +++ b/contrib/perl5/ext/NDBM_File/typemap @@ -20,8 +20,14 @@ T_DATUM_K $var.dsize = (int)PL_na; T_DATUM_V ckFilter($arg, filter_store_value, \"filter_store_value\"); - $var.dptr = SvPV($arg, PL_na); - $var.dsize = (int)PL_na; + if (SvOK($arg)) { + $var.dptr = SvPV($arg, PL_na); + $var.dsize = (int)PL_na; + } + else { + $var.dptr = \"\"; + $var.dsize = 0; + } T_GDATUM UNIMPLEMENTED OUTPUT |