DB_File

 view release on metacpan or  search on metacpan

DB_File.xs  view on Meta::CPAN


#define db_seq(db, key, value, flags)   do_SEQ(db, key, value, flags)

typedef struct {
    DBTYPE  type ;
    DB *    dbp ;
    SV *    compare ;
    bool    in_compare ;
    SV *    prefix ;
    bool    in_prefix ;
    SV *    hash ;
    bool    in_hash ;
    bool    aborted ;
    int in_memory ;
#ifdef BERKELEY_DB_1_OR_2
    INFO    info ;
#endif
#ifdef DB_VERSION_MAJOR
    DBC *   cursor ;
#endif
    SV *    filter_fetch_key ;
    SV *    filter_store_key ;
    SV *    filter_fetch_value ;
    SV *    filter_store_value ;
    int     filtering ;

    } DB_File_type;

typedef DB_File_type * DB_File ;
typedef DBT DBTKEY ;

#define my_sv_setpvn(sv, d, s) sv_setpvn(sv, (s ? d : (const char *)""), s)

#define OutputValue(arg, name)                                              \
    { if (RETVAL == 0) {                                                    \
          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") ;      \
      }                                                                     \
    }

#define OutputKey(arg, name)                                          \
    { if (RETVAL == 0)                                                \
      {                                                               \
          SvGETMAGIC(arg) ;                                           \
          if (db->type != DB_RECNO) {                                 \
              my_sv_setpvn(arg, (const char *)name.data, name.size);  \
          }                                                           \
          else                                                        \
              sv_setiv(arg, (I32)*(I32*)name.data - 1);               \
          TAINT;                                                      \
          SvTAINTED_on(arg);                                          \
          SvUTF8_off(arg);                                            \
          DBM_ckFilter(arg, filter_fetch_key,"filter_fetch_key") ;    \
      }                                                               \
    }

/* Macro err_close only for use in croak_and_free */
#ifdef BERKELEY_DB_1_OR_2 /* Berkeley DB Version 1  or 2 */
#  define err_close(r)
#else
#  define err_close(r) db_close(r)
#endif

/* Macro croak_and_free only for use in ParseOpenInfo */
#define croak_and_free(x)                                             \
    do                                                                \
    {                                                                 \
        if (RETVAL->dbp) { err_close(RETVAL) ; }                      \
        Safefree(RETVAL);                                             \
        croak(x);                                                     \
    } while (0)

#define my_SvUV32(sv) ((u_int32_t)SvUV(sv))

#ifdef CAN_PROTOTYPE
extern void __getBerkeleyDBInfo(void);
#endif

/* Internal Global Data */

#define MY_CXT_KEY "DB_File::_guts" XS_VERSION

typedef struct {
    recno_t x_Value;
    recno_t x_zero;
    DB_File x_CurrentDB;
    DBTKEY  x_empty;
} my_cxt_t;

START_MY_CXT

#define Value       (MY_CXT.x_Value)
#define zero        (MY_CXT.x_zero)
#define CurrentDB   (MY_CXT.x_CurrentDB)
#define empty       (MY_CXT.x_empty)

#define ERR_BUFF "DB_File::Error"

#ifdef DB_VERSION_MAJOR

static int
#ifdef CAN_PROTOTYPE
db_put(DB_File db, DBTKEY key, DBT value, u_int flags)
#else
db_put(db, key, value, flags)
DB_File     db ;
DBTKEY      key ;
DBT         value ;
u_int       flags ;
#endif
{
    int status ;

    if (flagSet(flags, R_IAFTER) || flagSet(flags, R_IBEFORE)) {
        DBC * temp_cursor ;
        DBT l_key, l_value;

#if DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR < 6
        if (((db->dbp)->cursor)(db->dbp, NULL, &temp_cursor) != 0)
#else
        if (((db->dbp)->cursor)(db->dbp, NULL, &temp_cursor, 0) != 0)
#endif
            return (-1) ;



( run in 1.089 second using v1.01-cache-2.11-cpan-e1769b4cff6 )