X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=ext%2FDB_File%2FDB_File.xs;h=7cbe5e8d6c9b08401b59aad5e79da9a41171772e;hb=798b63bc924a07589315b3229311582adce06136;hp=eb83670338d0f42538a83ca845f87e1814de05b2;hpb=9c095db2b2b99b70926d6f45029789d614441504;p=p5sagit%2Fp5-mst-13.2.git diff --git a/ext/DB_File/DB_File.xs b/ext/DB_File/DB_File.xs index eb83670..7cbe5e8 100644 --- a/ext/DB_File/DB_File.xs +++ b/ext/DB_File/DB_File.xs @@ -3,12 +3,12 @@ DB_File.xs -- Perl 5 interface to Berkeley DB written by Paul Marquess - last modified 20th June 2004 - version 1.809 + last modified 11th November 2005 + version 1.814 All comments/suggestions/problems are welcome - Copyright (c) 1995-2004 Paul Marquess. All rights reserved. + Copyright (c) 1995-2005 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. @@ -109,6 +109,11 @@ 1.807 - no change 1.808 - leak fixed in ParseOpenInfo 1.809 - no change + 1.810 - no change + 1.811 - no change + 1.812 - no change + 1.813 - no change + 1.814 - no change */ @@ -190,10 +195,22 @@ # define AT_LEAST_DB_3_2 #endif +#if DB_VERSION_MAJOR > 3 || (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR >= 3) +# define AT_LEAST_DB_3_3 +#endif + #if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1) # define AT_LEAST_DB_4_1 #endif +#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3) +# define AT_LEAST_DB_4_3 +#endif + +#ifdef AT_LEAST_DB_3_3 +# define WANT_ERROR +#endif + /* map version 2 features & constants onto their version 1 equivalent */ #ifdef DB_Prefix_t @@ -393,12 +410,13 @@ typedef struct { typedef DB_File_type * DB_File ; typedef DBT DBTKEY ; -#define my_sv_setpvn(sv, d, s) sv_setpvn(sv, (s ? d : (void*)""), s) +#define my_sv_setpvn(sv, d, s) sv_setpvn(sv, (s ? d : (const char *)""), s) #define OutputValue(arg, name) \ { if (RETVAL == 0) { \ - my_sv_setpvn(arg, name.data, name.size) ; \ - TAINT; \ + SvGETMAGIC(arg) ; \ + my_sv_setpvn(arg, (const char *)name.data, name.size) ; \ + TAINT; \ SvTAINTED_on(arg); \ SvUTF8_off(arg); \ DBM_ckFilter(arg, filter_fetch_value,"filter_fetch_value") ; \ @@ -408,12 +426,13 @@ typedef DBT DBTKEY ; #define OutputKey(arg, name) \ { if (RETVAL == 0) \ { \ + SvGETMAGIC(arg) ; \ if (db->type != DB_RECNO) { \ - my_sv_setpvn(arg, name.data, name.size); \ + my_sv_setpvn(arg, (const char *)name.data, name.size); \ } \ else \ sv_setiv(arg, (I32)*(I32*)name.data - 1); \ - TAINT; \ + TAINT; \ SvTAINTED_on(arg); \ SvUTF8_off(arg); \ DBM_ckFilter(arg, filter_fetch_key,"filter_fetch_key") ; \ @@ -578,8 +597,8 @@ const DBT * key2 ; PUSHMARK(SP) ; EXTEND(SP,2) ; - PUSHs(sv_2mortal(newSVpvn(data1,key1->size))); - PUSHs(sv_2mortal(newSVpvn(data2,key2->size))); + PUSHs(sv_2mortal(newSVpvn((const char*)data1,key1->size))); + PUSHs(sv_2mortal(newSVpvn((const char*)data2,key2->size))); PUTBACK ; count = perl_call_sv(CurrentDB->compare, G_SCALAR); @@ -765,14 +784,13 @@ HASH_CB_SIZE_TYPE size ; return (retval) ; } -#if 0 +#ifdef WANT_ERROR + static void -#ifdef CAN_PROTOTYPE -db_errcall_cb(const char * db_errpfx, char * buffer) +#ifdef AT_LEAST_DB_4_3 +db_errcall_cb(const DB_ENV* dbenv, const char * db_errpfx, const char * buffer) #else -db_errcall_cb(db_errpfx, buffer) -const char * db_errpfx; -char * buffer; +db_errcall_cb(const char * db_errpfx, char * buffer) #endif { #ifdef dTHX @@ -1232,6 +1250,9 @@ SV * sv ; } dbp = RETVAL->dbp ; +#ifdef WANT_ERROR + RETVAL->dbp->set_errcall(RETVAL->dbp, db_errcall_cb) ; +#endif if (sv) { if (! SvROK(sv) ) @@ -1426,6 +1447,12 @@ SV * sv ; Flags |= DB_TRUNCATE ; #endif +#ifdef AT_LEAST_DB_4_4 + /* need this for recno */ + if ((flags & O_TRUNC) == O_TRUNC) + Flags |= DB_CREATE ; +#endif + #ifdef AT_LEAST_DB_4_1 status = (RETVAL->dbp->open)(RETVAL->dbp, NULL, name, NULL, RETVAL->type, Flags, mode) ; @@ -1436,7 +1463,6 @@ SV * sv ; /* printf("open returned %d %s\n", status, db_strerror(status)) ; */ if (status == 0) { - /* RETVAL->dbp->set_errcall(RETVAL->dbp, db_errcall_cb) ;*/ status = (RETVAL->dbp->cursor)(RETVAL->dbp, NULL, &RETVAL->cursor, 0) ; @@ -1466,7 +1492,9 @@ BOOT: #ifdef dTHX dTHX; #endif - /* SV * sv_err = perl_get_sv(ERR_BUFF, GV_ADD|GV_ADDMULTI) ; */ +#ifdef WANT_ERROR + SV * sv_err = perl_get_sv(ERR_BUFF, GV_ADD|GV_ADDMULTI) ; +#endif MY_CXT_INIT; __getBerkeleyDBInfo() ;