diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2018-07-03 19:48:32 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2018-07-03 22:58:32 +0300 |
commit | f90e8d187d3ca23299c4dad447a4eba0560f84ad (patch) | |
tree | aedc64b78d357efd4478eb41df80d38ea6ad1c35 | |
parent | 7a1740a11031ad380e0d3c488310c389e9ea07f6 (diff) | |
download | GDBM_File-master.tar.gz GDBM_File-master.tar.bz2 |
-rw-r--r-- | GDBM_File.pm | 92 | ||||
-rw-r--r-- | GDBM_File.xs | 91 |
2 files changed, 172 insertions, 11 deletions
diff --git a/GDBM_File.pm b/GDBM_File.pm index b04dd9f..ab25906 100644 --- a/GDBM_File.pm +++ b/GDBM_File.pm @@ -8,5 +8,43 @@ GDBM_File - Perl5 access to the gdbm library. - use GDBM_File ; - tie %hash, 'GDBM_File', $filename, &GDBM_WRCREAT, 0640; + use GDBM_File; + [$db =] tie %hash, 'GDBM_File', $filename, &GDBM_WRCREAT, 0640; # Use the %hash array. + + $e = $db->errno; + $e = $db->syserrno; + $str = $db->strerror; + $bool = $db->needs_recovery; + + $db->clear_error; + + $db->reorganize; + $db->sync; + + $n = $db->count; + + $n = $db->flags; + + $str = $db->dbname; + + $db->cache_size; + $db->cache_size($newsize); + + $n = $db->block_size; + + $bool = $db->sync_mode; + $db->sync_mode($bool); + + $bool = $db->centfree; + $db->centfree($bool); + + $bool = $db->coalesce; + $db->coalesce($bool); + + $bool = $db->mmap; + + $size = $db->mmapsize; + $db->mmapsize($newsize); + + $db->recover(%args); + untie %hash ; @@ -26,2 +64,46 @@ This is a limitation of the gdbm library. +=head1 STATIC METHODS + +=head2 GDBM_version + + $str = GDBM_File->GDBM_version; + @ar = GDBM_File->GDBM_version; + +Returns the version number of the underlying B<libgdbm> library. In scalar +context, returns the library version formatted as string: + + MINOR.MAJOR[.PATCH][ (GUESS)] + +where I<MINOR>, I<MAJOR>, and I<PATCH> are version numbers, and I<GUESS> is +a guess level (see below). + +In list context, returns a list: + + ( MINOR, MAJOR, PATCH [, GUESS] ) + +The I<GUESS> component is present only if B<libgdbm> version is 1.8.3 or +earlier. This is because earlier releases of B<libgdbm> did not include +information about their version and the B<GDBM_File> module has to implement +certain guesswork in order to determine it. I<GUESS> is a textual description +in string context, and a positive number indicating how rough the guess is +in list context. Possible values are: + +=over 4 + +=item 1 - exact guess + +The major and minor version numbers are guaranteed to be correct. The actual +patchlevel is most probably guessed right, but can be 1-2 less than indicated. + +=item 2 - approximate + +The major and minor number are guaranteed to be correct. The patchlevel is +set to the upper bound. + +=item 3 - rough guess + +The version is guaranteed to be not newer than B<I<MAJOR>.I<MINOR>>. + +=back + =head1 METHODS @@ -233,7 +315,7 @@ L<http://www.gnu.org/order/ftp.html>. -=head1 BUGS - =head1 SEE ALSO -L<perl(1)>, L<DB_File(3)>, L<perldbmfilter>. +L<perl(1)>, L<DB_File(3)>, L<perldbmfilter>, +L<gdbm(3)>, +L<https://www.gnu.org.ua/software/gdbm/manual.html>. diff --git a/GDBM_File.xs b/GDBM_File.xs index 669cb8d..ef7bde5 100644 --- a/GDBM_File.xs +++ b/GDBM_File.xs @@ -53,5 +53,48 @@ char const *opt_names[] = { -#ifndef GDBM_VERSION_MAJOR -# define GDBM_VERSION_MAJOR 0 -# define GDBM_VERSION_MINOR 0 +#ifdef GDBM_VERSION_MAJOR +# define GDBM_VERSION_GUESS 0 +#else +/* Try educated guess + * The value of GDBM_VERSION_GUESS indicates how rough the guess is: + * 1 - Precise; based on the CVS logs and existing archives + * 2 - Moderate. The major and minor number are correct. The patchlevel + * is set to the upper bound. + * 3 - Rough; The version is guaranteed to be not newer than major.minor. + */ +# if defined(GDBM_SYNCMODE) +/* CHANGES from 1.7.3 to 1.8 + * 1. Added GDBM_CENTFREE functionality and option. + */ +# define GDBM_VERSION_MAJOR 1 +# define GDBM_VERSION_MINOR 8 +# define GDBM_VERSION_PATCH 3 +# define GDBM_VERSION_GUESS 1 +# elif defined(GDBM_FASTMODE) +/* CHANGES from 1.7.2 to 1.7.3 + * 1. Fixed a couple of last minute problems. (Namely, no autoconf.h in + * version.c, and no GDBM_FASTMODE in gdbm.h!) + */ +# define GDBM_VERSION_MAJOR 1 +# define GDBM_VERSION_MINOR 7 +# define GDBM_VERSION_PATCH 3 +# define GDBM_VERSION_GUESS 1 +# elif defined(GDBM_FAST) +/* From CVS logs: + * Mon May 17 12:32:02 1993 Phil Nelson (phil at cs.wwu.edu) + * + * * gdbm.proto: Added GDBM_FAST to the read_write flags. + */ +# define GDBM_VERSION_MAJOR 1 +# define GDBM_VERSION_MINOR 7 +# define GDBM_VERSION_PATCH 2 +# define GDBM_VERSION_GUESS 2 +# else +# define GDBM_VERSION_MAJOR 1 +# define GDBM_VERSION_MINOR 6 +# define GDBM_VERSION_GUESS 3 +# endif +#endif + +#ifndef GDBM_VERSION_PATCH +# define GDBM_VERSION_PATCH 0 #endif @@ -177,2 +220,37 @@ INCLUDE: const-xs.inc +void +gdbm_GDBM_version(package) + char *package; + PPCODE: + I32 gimme = GIMME_V; + if (gimme == G_VOID) { + /* nothing */; + } else if (gimme == G_SCALAR) { + static char const *guess[] = { + "", + " (exact guess)", + " (approximate)", + " (rough guess)" + }; + if (GDBM_VERSION_PATCH > 0) { + XPUSHs(sv_2mortal(newSVpvf("%d.%d.%d%s", + GDBM_VERSION_MAJOR, + GDBM_VERSION_MINOR, + GDBM_VERSION_PATCH, + guess[GDBM_VERSION_GUESS]))); + } else { + XPUSHs(sv_2mortal(newSVpvf("%d.%d%s", + GDBM_VERSION_MAJOR, + GDBM_VERSION_MINOR, + guess[GDBM_VERSION_GUESS]))); + } + } else { + XPUSHs(sv_2mortal(newSVuv(GDBM_VERSION_MAJOR))); + XPUSHs(sv_2mortal(newSVuv(GDBM_VERSION_MINOR))); + XPUSHs(sv_2mortal(newSVuv(GDBM_VERSION_PATCH))); + if (GDBM_VERSION_GUESS > 0) { + XPUSHs(sv_2mortal(newSVuv(GDBM_VERSION_GUESS))); + } + } + GDBM_File @@ -749,3 +827,3 @@ filter_fetch_key(db, code) SV * RETVAL = &PL_sv_undef ; - ALIAS: + ALIAS: GDBM_File::filter_fetch_key = fetch_key @@ -754,3 +832,4 @@ filter_fetch_key(db, code) GDBM_File::filter_store_value = store_value - CODE: - DBM_setFilter(db->filter[ix], code); + CODE: + DBM_setFilter(db->filter[ix], code); + |