DB_File.xs -- Perl 5 interface to Berkeley DB
- written by Paul Marquess <pmqs@cpan.org>
- last modified 4th February 2007
- version 1.818
+ Written by Paul Marquess <pmqs@cpan.org>
All comments/suggestions/problems are welcome
- Copyright (c) 1995-2012 Paul Marquess. All rights reserved.
+ Copyright (c) 1995-2018 Paul Marquess. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
# include "ppport.h"
#endif
+int DB_File___unused() { return 0; }
+
/* Mention DB_VERSION_MAJOR_CFG, DB_VERSION_MINOR_CFG, and
DB_VERSION_PATCH_CFG here so that Configure pulls them all in. */
#ifdef COMPAT185
# include <db_185.h>
#else
+
+/* Uncomment one of the lines below */
+/* See the section "At least one secondary cursor must be specified to DB->join"
+ in the README file for the circumstances where you need to uncomment one
+ of the two lines below.
+*/
+
+/* #define time_t __time64_t */
+/* #define time_t __time32_t */
+
# include <db.h>
#endif
+#ifndef PERL_UNUSED_ARG
+# define PERL_UNUSED_ARG(x) ((void)x)
+#endif
+
/* Wall starts with 5.7.x */
#if PERL_REVISION > 5 || (PERL_REVISION == 5 && PERL_VERSION >= 7)
# ifndef DB_VERSION_MAJOR
# undef dNOOP
-# define dNOOP extern int Perl___notused
+# ifdef __cplusplus
+# define dNOOP (void)0
+# else
+# define dNOOP extern int DB_File___notused()
+# endif
/* Ditto for dXSARGS. */
# undef dXSARGS
# define AT_LEAST_DB_4_3
#endif
+#if DB_VERSION_MAJOR >= 6
+# define AT_LEAST_DB_6_0
+#endif
+
#ifdef AT_LEAST_DB_3_3
# define WANT_ERROR
#endif
#if DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR < 5
# define R_SETCURSOR 0x800000
#else
-# define R_SETCURSOR (-100)
+# define R_SETCURSOR (DB_OPFLAGS_MASK)
#endif
#define R_RECNOSYNC 0
#if DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR < 5
# define flagSet(flags, bitmask) ((flags) & (bitmask))
#else
-# define flagSet(flags, bitmask) (((flags) & DB_OPFLAGS_MASK) == (bitmask))
+# define flagSet(flags, bitmask) (((flags) & DB_OPFLAGS_MASK) == (u_int)(bitmask))
#endif
#else /* db version 1.x */
if (flagSet(flags, R_CURSOR)) {
return ((db->cursor)->c_put)(db->cursor, &key, &value, DB_CURRENT);
}
-
if (flagSet(flags, R_SETCURSOR)) {
if ((db->dbp)->put(db->dbp, NULL, &key, &value, 0) != 0)
return -1 ;
static int
+
+#ifdef AT_LEAST_DB_6_0
+#ifdef CAN_PROTOTYPE
+btree_compare(DB * db, const DBT *key1, const DBT *key2, size_t* locp)
+#else
+btree_compare(db, key1, key2, locp)
+DB * db ;
+const DBT * key1 ;
+const DBT * key2 ;
+size_t* locp;
+#endif /* CAN_PROTOTYPE */
+
+#else /* Berkeley DB < 6.0 */
#ifdef AT_LEAST_DB_3_2
#ifdef CAN_PROTOTYPE
#endif
#endif
+#endif
{
#ifdef dTHX
int retval ;
int count ;
+#ifdef AT_LEAST_DB_3_2
+ PERL_UNUSED_ARG(db);
+#endif
+#ifdef AT_LEAST_DB_6_0
+ PERL_UNUSED_ARG(locp);
+#endif
if (CurrentDB->in_compare) {
tidyUp(CurrentDB);
int retval ;
int count ;
+#ifdef AT_LEAST_DB_3_2
+ PERL_UNUSED_ARG(db);
+#endif
+
if (CurrentDB->in_prefix){
tidyUp(CurrentDB);
croak ("DB_File btree_prefix: recursion detected\n") ;
int retval = 0;
int count ;
+#ifdef AT_LEAST_DB_3_2
+ PERL_UNUSED_ARG(db);
+#endif
+
if (CurrentDB->in_hash){
tidyUp(CurrentDB);
croak ("DB_File hash callback: recursion detected\n") ;
dTHX;
#endif
SV * sv = perl_get_sv(ERR_BUFF, FALSE) ;
+#ifdef AT_LEAST_DB_4_3
+ PERL_UNUSED_ARG(dbenv);
+#endif
if (sv) {
if (db_errpfx)
sv_setpvf(sv, "%s: %s", db_errpfx, buffer) ;
value = (int)SvIV(*svp) ;
if (fixed) {
- status = dbp->set_re_pad(dbp, value) ;
+ (void)dbp->set_re_pad(dbp, value) ;
}
else {
- status = dbp->set_re_delim(dbp, value) ;
+ (void)dbp->set_re_delim(dbp, value) ;
}
}
svp = hv_fetch(action, "reclen", 6, FALSE);
if (svp) {
u_int32_t len = my_SvUV32(*svp) ;
- status = dbp->set_re_len(dbp, len) ;
+ (void)dbp->set_re_len(dbp, len) ;
}
}
if (name != NULL) {
- status = dbp->set_re_source(dbp, name) ;
+ (void)dbp->set_re_source(dbp, name) ;
name = NULL ;
}
name = NULL ;
- status = dbp->set_flags(dbp, (u_int32_t)DB_RENUMBER) ;
+ (void)dbp->set_flags(dbp, (u_int32_t)DB_RENUMBER) ;
if (flags){
(void)dbp->set_flags(dbp, (u_int32_t)flags) ;
}
if (status)
+ {
+ db_close(RETVAL); /* close **dbp handle to prevent mem.leak */
RETVAL->dbp = NULL ;
+ }
}
SV * sv_err = perl_get_sv(ERR_BUFF, GV_ADD|GV_ADDMULTI) ;
#endif
MY_CXT_INIT;
+#ifdef WANT_ERROR
+ PERL_UNUSED_VAR(sv_err); /* huh? we just retrieved it... */
+#endif
__getBerkeleyDBInfo() ;
DBT_clear(empty) ;
sv = ST(5) ;
RETVAL = ParseOpenInfo(aTHX_ isHASH, name, flags, mode, sv) ;
+ Trace(("db_DoTie_ %p\n", RETVAL));
if (RETVAL->dbp == NULL) {
Safefree(RETVAL);
RETVAL = NULL ;
PREINIT:
dMY_CXT;
INIT:
+ (void)flags;
CurrentDB = db ;
PREINIT:
dMY_CXT;
INIT:
+ (void)flags;
CurrentDB = db ;