bdb/ext/bdb.h

103 lines
1.7 KiB
C
Raw Normal View History

2006-02-14 03:56:36 +01:00
#ifndef BDB2_H
#define BDB2_H
#include <ruby.h>
2008-11-07 22:53:02 +01:00
#ifdef stat
#undef stat
#endif
#ifdef close
#undef close
#endif
#ifdef rename
#undef rename
#endif
2006-02-14 03:56:36 +01:00
#include <version.h>
2006-03-06 18:44:47 +01:00
#include <db.h>
2006-02-14 03:56:36 +01:00
#define NOTXN NULL
2006-05-15 23:28:29 +02:00
#ifdef OPEN_MAX
#define LMAXFD OPEN_MAX
2006-05-15 23:22:43 +02:00
#else
2006-05-15 23:28:29 +02:00
#ifdef FOPEN_MAX
#define LMAXFD FOPEN_MAX
#endif
#endif
#ifndef LMAXFD
2006-05-15 23:22:43 +02:00
#error "No max fd define available."
#endif
2006-02-14 03:56:36 +01:00
#define FNLEN 40
#define filename_copy(fp,fv) \
2008-11-07 22:16:45 +01:00
strncpy(fp,RSTRING_PTR(fv),FNLEN);
2006-02-14 03:56:36 +01:00
#define filename_dup(fpd,fps) \
strncpy(fpd,fps,FNLEN);
typedef struct s_envh {
VALUE self;
DB_ENV *env;
VALUE adb; /* Ruby array holding opened databases */
VALUE atxn; /* Ruby array holding open transactions */
} t_envh;
2006-02-14 03:56:36 +01:00
typedef struct s_dbh {
VALUE self;
DB *db;
int db_opened;
2006-02-14 03:56:36 +01:00
VALUE aproc;
t_envh *env; /* Parent environment, NULL if not opened from one */
VALUE adbc; /* Ruby array holding opened cursor */
2006-02-14 03:56:36 +01:00
char filename[FNLEN+1];
} t_dbh;
typedef struct s_dbch {
VALUE self;
2006-02-14 03:56:36 +01:00
DBC *dbc;
t_dbh *db;
2006-02-14 03:56:36 +01:00
char filename[FNLEN+1];
} t_dbch;
typedef struct s_txnh {
VALUE self;
DB_TXN *txn;
t_envh *env;
} t_txnh;
2006-02-14 03:56:36 +01:00
2008-12-28 03:12:49 +01:00
#define cu(b,m) \
2008-11-07 22:16:45 +01:00
rb_define_const(b,#m,UINT2NUM(m))
2008-12-28 03:12:49 +01:00
#define ci(b,m) \
2008-11-07 22:16:45 +01:00
rb_define_const(b,#m,INT2NUM(m))
2006-02-14 03:56:36 +01:00
#define cs(b,m) \
rb_define_const(b,#m,rb_str_new2(m))
#define simple_set(fname) \
VALUE db_ ## fname ## _eq(VALUE obj, VALUE v) \
{ \
rb_ivar_set(obj,fv_ ## fname,v); \
return obj; \
}
#define attr_writer(fname) \
VALUE fname ## _writer(VALUE obj, VALUE v) \
{ \
2008-12-28 03:12:49 +01:00
rb_ivar_set(obj,fv_ ## fname,v); \
return obj; \
}
#define attr_reader(fname) \
VALUE fname ## _reader(VALUE obj) \
2008-12-28 03:12:49 +01:00
{ \
return rb_ivar_get(obj,fv_ ## fname); \
}
2006-02-14 03:56:36 +01:00
#endif