798 lines
24 KiB
C
798 lines
24 KiB
C
#include "bdb.h"
|
|
|
|
/* initialise flag constants */
|
|
static s48_value scheme_DB_RPCCLIENT = S48_FALSE;
|
|
static s48_value scheme_DB_INIT_LOCK = S48_FALSE;
|
|
static s48_value scheme_DB_JOINENV = S48_FALSE;
|
|
static s48_value scheme_DB_INIT_MPOOL = S48_FALSE;
|
|
static s48_value scheme_DB_INIT_LOG = S48_FALSE;
|
|
static s48_value scheme_DB_INIT_REP = S48_FALSE;
|
|
static s48_value scheme_DB_INIT_TXN = S48_FALSE;
|
|
static s48_value scheme_DB_RECOVER = S48_FALSE;
|
|
static s48_value scheme_DB_RECOVER_FATAL = S48_FALSE;
|
|
static s48_value scheme_DB_USE_ENVIRON = S48_FALSE;
|
|
static s48_value scheme_DB_USE_ENVIRON_ROOT = S48_FALSE;
|
|
static s48_value scheme_DB_CREATE = S48_FALSE;
|
|
static s48_value scheme_DB_LOCKDOWN = S48_FALSE;
|
|
static s48_value scheme_DB_PRIVATE = S48_FALSE;
|
|
static s48_value scheme_DB_SYSTEM_MEM = S48_FALSE;
|
|
static s48_value scheme_DB_THREAD = S48_FALSE;
|
|
static s48_value scheme_DB_XA_CREATE = S48_FALSE;
|
|
static s48_value scheme_DB_AUTO_COMMIT = S48_FALSE;
|
|
static s48_value scheme_DB_DIRTY_READ = S48_FALSE;
|
|
static s48_value scheme_DB_EXCL = S48_FALSE;
|
|
static s48_value scheme_DB_NOMMAP = S48_FALSE;
|
|
static s48_value scheme_DB_RDONLY = S48_FALSE;
|
|
static s48_value scheme_DB_TRUNCATE = S48_FALSE;
|
|
static s48_value scheme_DB_NOSYNC = S48_FALSE;
|
|
static s48_value scheme_DB_CONSUME = S48_FALSE;
|
|
static s48_value scheme_DB_CONSUME_WAIT = S48_FALSE;
|
|
static s48_value scheme_DB_GET_BOTH = S48_FALSE;
|
|
static s48_value scheme_DB_RMW = S48_FALSE;
|
|
static s48_value scheme_DB_MULTIPLE = S48_FALSE;
|
|
static s48_value scheme_DB_SET_RECNO = S48_FALSE;
|
|
static s48_value scheme_DB_APPEND = S48_FALSE;
|
|
static s48_value scheme_DB_NODUPDATA = S48_FALSE;
|
|
static s48_value scheme_DB_NOOVERWRITE = S48_FALSE;
|
|
static s48_value scheme_DB_CURRENT = S48_FALSE;
|
|
static s48_value scheme_DB_FIRST = S48_FALSE;
|
|
static s48_value scheme_DB_WRITECURSOR = S48_FALSE;
|
|
static s48_value scheme_DB_GET_BOTH_RANGE = S48_FALSE;
|
|
static s48_value scheme_DB_GET_RECNO = S48_FALSE;
|
|
static s48_value scheme_DB_JOIN_ITEM = S48_FALSE;
|
|
static s48_value scheme_DB_LAST = S48_FALSE;
|
|
static s48_value scheme_DB_NEXT = S48_FALSE;
|
|
static s48_value scheme_DB_NEXT_DUP = S48_FALSE;
|
|
static s48_value scheme_DB_NEXT_NODUP = S48_FALSE;
|
|
static s48_value scheme_DB_PREV = S48_FALSE;
|
|
static s48_value scheme_DB_SET = S48_FALSE;
|
|
static s48_value scheme_DB_SET_RANGE = S48_FALSE;
|
|
static s48_value scheme_DB_MULTIPLE_KEY = S48_FALSE;
|
|
static s48_value scheme_DB_TXN_NOSYNC = S48_FALSE;
|
|
static s48_value scheme_DB_TXN_NOWAIT = S48_FALSE;
|
|
static s48_value scheme_DB_TXN_SYNC = S48_FALSE;
|
|
|
|
/* initialise DB_TYPES */
|
|
static s48_value scheme_DB_BTREE = S48_FALSE;
|
|
static s48_value scheme_DB_HASH = S48_FALSE;
|
|
static s48_value scheme_DB_QUEUE = S48_FALSE;
|
|
static s48_value scheme_DB_RECNO = S48_FALSE;
|
|
static s48_value scheme_DB_UNKNOWN = S48_FALSE;
|
|
|
|
s48_value scsh_enter_db(DB *h)
|
|
{
|
|
s48_value rec = S48_FALSE;
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
S48_GC_PROTECT_1(rec);
|
|
|
|
rec = s48_make_record(bdb_db_record_type);
|
|
S48_RECORD_SET(rec, 0, s48_enter_integer((long) h));
|
|
|
|
S48_GC_UNPROTECT();
|
|
return rec;
|
|
}
|
|
|
|
s48_value scsh_enter_txnid(DB_TXN *txnid)
|
|
{
|
|
s48_value rec = S48_FALSE;
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
S48_GC_PROTECT_1(rec);
|
|
|
|
rec = s48_make_record(bdb_txn_record_type);
|
|
S48_RECORD_SET(rec, 0, s48_enter_integer((long) txnid));
|
|
|
|
S48_GC_UNPROTECT();
|
|
return rec;
|
|
}
|
|
|
|
s48_value scsh_enter_cursor(DBC *dbc)
|
|
{
|
|
s48_value rec = S48_FALSE;
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
S48_GC_PROTECT_1(rec);
|
|
|
|
rec = s48_make_record(bdb_dbc_record_type);
|
|
S48_RECORD_SET(rec, 0, s48_enter_integer((long) dbc));
|
|
|
|
S48_GC_UNPROTECT();
|
|
return rec;
|
|
}
|
|
|
|
s48_value scsh_enter_dbenv(DB_ENV *h)
|
|
{
|
|
s48_value rec = S48_FALSE;
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
S48_GC_PROTECT_1(rec);
|
|
|
|
rec = s48_make_record(bdb_env_record_type);
|
|
S48_RECORD_SET(rec, 0, s48_enter_integer((long) h));
|
|
|
|
S48_GC_UNPROTECT();
|
|
return rec;
|
|
}
|
|
|
|
/* BDB operations */
|
|
|
|
/* database environment */
|
|
|
|
/* create an environment handle */
|
|
s48_value scsh_bdb_env_create(s48_value sflags)
|
|
{
|
|
|
|
DB_ENV *dbenv;
|
|
int res;
|
|
u_int32_t flags = S48_FALSE;
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
S48_GC_PROTECT_1(sflags);
|
|
flags = s48_extract_integer(sflags);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = db_env_create(&dbenv, flags);
|
|
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return scsh_enter_env(dbenv);
|
|
}
|
|
|
|
/* close an environment */
|
|
s48_value scsh_bdb_env_close(s48_value env, s48_value sflags)
|
|
{
|
|
int res;
|
|
DB_ENV *dbenv;
|
|
u_int32_t flags;
|
|
|
|
S48_DECLARE_GC_PROTECT(2);
|
|
S48_GC_PROTECT_2(env, sflags);
|
|
|
|
dbenv = scsh_extract_dbenv(env);
|
|
flags = s48_extract_integer(sflags);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = dbenv->close(dbenv, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return S48_TRUE;
|
|
}
|
|
|
|
/* remove a database */
|
|
/* s48_value scsh_bdb_dbremove(...) */
|
|
/* { */
|
|
/* DB_ENV->dbremove(); */
|
|
/* } */
|
|
|
|
/* rename a database */
|
|
/* s48_value scsh_bdb_dbrename(...) */
|
|
/* { */
|
|
/* DB_ENV->dbrename(); */
|
|
/* } */
|
|
|
|
/* open an environment */
|
|
s48_value scsh_bdb_env_open(s48_value env_handle, s48_value sdb_home,
|
|
s48_value sflags, s48_value smode)
|
|
{
|
|
int res, mode;
|
|
char *dbhome;
|
|
DB_ENV *dbenv;
|
|
u_int32_t flags;
|
|
|
|
S48_DECLARE_GC_PROTECT(4);
|
|
S48_GC_PROTECT_4(env_handle, sdb_home, sflags, smode);
|
|
|
|
dbhome = s48_extract_string(sdb_home);
|
|
dbenv = scsh_extract_dbenv(env_handle);
|
|
mode = s48_extract_integer(smode);
|
|
//flags = bdb_extract_flags(sflags);
|
|
// as of now default is set to transaction and locking support
|
|
flags = DB_CREATE | DB_INIT_LOG | DB_INIT_LOCK | DB_INIT_TXN;
|
|
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = dbenv->open(dbenv, dbhome, flags, mode);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
|
|
return S48_TRUE;
|
|
}
|
|
|
|
/* remove an environment */
|
|
s48_value scsh_bdb_env_remove(s48_value db_home, s48_value sflags)
|
|
{
|
|
DB_ENV *dbenv;
|
|
int res;
|
|
char *dbhome;
|
|
u_int32_t flags;
|
|
|
|
S48_DECLARE_GC_PROTECT(2);
|
|
S48_GC_PROTECT_2(db_home, sflags);
|
|
dbhome = s48_extract_string(db_home);
|
|
flags = s48_extract_integer(sflags);
|
|
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = dbenv->remove(dbenv, dbhome, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return S48_TRUE;
|
|
}
|
|
|
|
/* environment configuration */
|
|
|
|
/* set the environment data directory */
|
|
/* s48_value scsh_bdb_env_set_data_dir(...) */
|
|
/* { */
|
|
/* DB_ENV->set_data_dir(); */
|
|
/* } */
|
|
|
|
/* set the environment cryptographic key */
|
|
/* s48_value scsh_bdb_env_set_encrypt(...) */
|
|
/* { */
|
|
/* DB_ENV->set_encrypt(); */
|
|
/* } */
|
|
|
|
/* create DB - returns dbp handle */
|
|
s48_value scsh_bdb_create(s48_value env, s48_value sflags)
|
|
{
|
|
DB *dbp;
|
|
DB_ENV *dbenv;
|
|
int res;
|
|
u_int32_t flags;
|
|
|
|
S48_DECLARE_GC_PROTECT(2);
|
|
S48_GC_PROTECT_2(env, sflags);
|
|
flags = s48_extract_integer(sflags);
|
|
dbenv = EXTRACT_OPTIONAL_ENV(env);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = db_create(&dbp, dbenv, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return scsh_enter_db(dbp);
|
|
}
|
|
|
|
/* open DB */
|
|
s48_value scsh_bdb_open(s48_value db, s48_value sfile, s48_value sdatabase,
|
|
s48_value stxnid, s48_value stype, s48_value sflags,
|
|
s48_value smode)
|
|
{
|
|
int res, mode;
|
|
char *dbfile;
|
|
char *database;
|
|
DB *dbp;
|
|
DB_TXN *txnid;
|
|
DBTYPE type;
|
|
u_int32_t flags;
|
|
|
|
S48_DECLARE_GC_PROTECT(7);
|
|
S48_GC_PROTECT_7(db, sfile, sdatabase, stxnid, stype, sflags, smode);
|
|
dbfile = s48_extract_string(sfile);
|
|
database = EXTRACT_OPTIONAL_STRING(sdatabase);
|
|
dbp = scsh_extract_db(db);
|
|
txnid = EXTRACT_OPTIONAL_TXNID(stxnid);
|
|
type = s48_extract_integer(stype);
|
|
flags = s48_extract_integer(sflags);
|
|
mode = s48_extract_integer(smode);
|
|
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = dbp->open(dbp, txnid, dbfile, database, type, flags, mode);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return S48_TRUE;
|
|
}
|
|
|
|
/* close DB */
|
|
s48_value scsh_bdb_close(s48_value db, s48_value sflags)
|
|
{
|
|
int res;
|
|
DB *dbp;
|
|
u_int32_t flags;
|
|
|
|
S48_DECLARE_GC_PROTECT(2);
|
|
S48_GC_PROTECT_2(db, sflags);
|
|
dbp= scsh_extract_db(db);
|
|
flags = s48_extract_integer(sflags);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = dbp->close(dbp, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return S48_TRUE;
|
|
}
|
|
|
|
s48_value scsh_bdb_truncate(s48_value db, s48_value stxnid, s48_value sflags)
|
|
{
|
|
int res;
|
|
DB *dbp;
|
|
u_int32_t flags;
|
|
u_int32_t *countp;
|
|
DB_TXN *txnid;
|
|
|
|
S48_DECLARE_GC_PROTECT(3);
|
|
S48_GC_PROTECT_3(db, stxnid, sflags);
|
|
dbp= scsh_extract_db(db);
|
|
txnid = EXTRACT_OPTIONAL_TXNID(stxnid);
|
|
flags = s48_extract_integer(sflags);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = dbp->truncate(dbp, txnid, countp, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return S48_TRUE;
|
|
}
|
|
|
|
s48_value scsh_bdb_sync(s48_value db)
|
|
{
|
|
int res;
|
|
DB *dbp;
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
S48_GC_PROTECT_1(db);
|
|
dbp = scsh_extract_db(db);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = dbp->sync(dbp, 0);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return S48_TRUE;
|
|
}
|
|
|
|
/* DBT as byte vectors */
|
|
s48_value scsh_enter_DBT_as_bytevector(DBT* dt)
|
|
{
|
|
int i;
|
|
s48_value res = S48_FALSE;
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
S48_GC_PROTECT_1(res);
|
|
|
|
res = s48_make_byte_vector(dt->size, 0);
|
|
i = 0;
|
|
|
|
for (i = 0; i < dt->size; i++)
|
|
S48_BYTE_VECTOR_SET(res, i, ((char*)(dt->data))[i]);
|
|
|
|
S48_GC_UNPROTECT();
|
|
return res;
|
|
}
|
|
|
|
void scsh_extract_bytevector_as_DBT(s48_value bytevector, DBT* dt)
|
|
{
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
|
|
S48_GC_PROTECT_1(bytevector);
|
|
dt->data = s48_extract_byte_vector(bytevector);
|
|
dt->size = S48_BYTE_VECTOR_LENGTH(bytevector);
|
|
S48_GC_UNPROTECT();
|
|
}
|
|
|
|
/* DBT operations */
|
|
|
|
/* Put key and data DBT's in DB */
|
|
s48_value scsh_bdb_put(s48_value db, s48_value skey, s48_value sdata,
|
|
s48_value stxnid, s48_value sflags)
|
|
{
|
|
int res;
|
|
DB *dbp;
|
|
DB_TXN *txnid;
|
|
DBT key, data;
|
|
u_int32_t flags;
|
|
S48_DECLARE_GC_PROTECT(5);
|
|
|
|
S48_GC_PROTECT_5(db, skey, sdata, stxnid, sflags);
|
|
|
|
dbp = scsh_extract_db(db);
|
|
txnid = EXTRACT_OPTIONAL_TXNID(stxnid);
|
|
flags = s48_extract_integer(sflags);
|
|
|
|
scsh_extract_bytevector_as_DBT(skey, &key);
|
|
scsh_extract_bytevector_as_DBT(sdata, &data);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = dbp->put(dbp, txnid, &key, &data, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return scsh_enter_DBT_as_bytevector(&key);
|
|
}
|
|
|
|
/* Get DBT to corresponding key */
|
|
s48_value scsh_bdb_get(s48_value handle, s48_value skey,
|
|
s48_value stxnid, s48_value sflags)
|
|
{
|
|
int res;
|
|
DB *dbp;
|
|
u_int32_t flags;
|
|
DB_TXN *txnid;
|
|
DBT key, data;
|
|
|
|
S48_DECLARE_GC_PROTECT(4);
|
|
S48_GC_PROTECT_4(handle, skey, stxnid, sflags);
|
|
|
|
dbp = scsh_extract_db(handle);
|
|
flags = s48_extract_integer(sflags);
|
|
txnid = EXTRACT_OPTIONAL_TXNID(stxnid);
|
|
scsh_extract_bytevector_as_DBT(skey, &key);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = dbp->get(dbp, txnid, &key, &data, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return scsh_enter_DBT_as_bytevector(&data);
|
|
}
|
|
|
|
/* Delete DBT to corresponding key */
|
|
s48_value scsh_bdb_del(s48_value handle, s48_value skey,
|
|
s48_value stxnid, s48_value sflags)
|
|
{
|
|
int res;
|
|
DB* dbp;
|
|
DB_TXN *txnid;
|
|
DBT key;
|
|
u_int32_t flags;
|
|
|
|
S48_DECLARE_GC_PROTECT(4);
|
|
S48_GC_PROTECT_4(handle, skey, stxnid, sflags);
|
|
|
|
dbp = scsh_extract_db(handle);
|
|
flags = s48_extract_integer(sflags);
|
|
txnid = EXTRACT_OPTIONAL_TXNID(stxnid);
|
|
scsh_extract_bytevector_as_DBT(skey, &key);
|
|
|
|
S48_GC_UNPROTECT();
|
|
res = dbp->del(dbp, txnid, &key, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return S48_TRUE;
|
|
}
|
|
|
|
s48_value scsh_bdb_create_cursor(s48_value handle, s48_value stxnid,
|
|
s48_value sflags)
|
|
{
|
|
int res;
|
|
DB* dbp;
|
|
DBC* dbcp;
|
|
DB_TXN *txnid;
|
|
u_int32_t flags;
|
|
s48_value ret = S48_FALSE;
|
|
|
|
S48_DECLARE_GC_PROTECT(4);
|
|
S48_GC_PROTECT_4(handle, stxnid, sflags, ret);
|
|
|
|
dbp = scsh_extract_db(handle);
|
|
flags = s48_extract_integer(sflags);
|
|
txnid = EXTRACT_OPTIONAL_TXNID(stxnid);
|
|
|
|
S48_GC_UNPROTECT();
|
|
res = dbp->cursor(dbp,txnid, &dbcp, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return scsh_enter_cursor(dbcp);
|
|
}
|
|
|
|
/* retrieve values from cursor */
|
|
s48_value scsh_bdb_cursor_cget(s48_value dbc, s48_value sflags)
|
|
{
|
|
int res;
|
|
DBC* dbcp;
|
|
u_int32_t flags;
|
|
DBT *key, *data;
|
|
|
|
S48_DECLARE_GC_PROTECT(2);
|
|
S48_GC_PROTECT_2(dbc, sflags);
|
|
|
|
dbcp = scsh_extract_cursor(dbc);
|
|
flags = s48_extract_integer(sflags);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = dbcp->c_get(dbcp, key, data, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return scsh_enter_DBT_as_bytevector(data);
|
|
}
|
|
|
|
s48_value scsh_bdb_txn_begin (s48_value handle, s48_value sparent,
|
|
s48_value sflags)
|
|
{
|
|
int res;
|
|
DB_ENV* env;
|
|
DBC* dbcp;
|
|
DB_TXN* parent, *txnid;
|
|
u_int32_t flags;
|
|
s48_value ret = S48_FALSE;
|
|
//parent = NULL; // only for nested transactions
|
|
|
|
S48_DECLARE_GC_PROTECT(3);
|
|
S48_GC_PROTECT_3(handle, sflags, ret);
|
|
|
|
env = scsh_extract_env(handle);
|
|
flags = s48_extract_integer(sflags);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = env->txn_begin(env, NULL, &txnid, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return scsh_enter_txnid(txnid);
|
|
}
|
|
|
|
s48_value scsh_bdb_txn_abort(s48_value stxnid)
|
|
{
|
|
int res;
|
|
DB_TXN *txnid;
|
|
s48_value ret = S48_FALSE;
|
|
|
|
S48_DECLARE_GC_PROTECT(1);
|
|
S48_GC_PROTECT_1(stxnid);
|
|
|
|
txnid = EXTRACT_OPTIONAL_TXNID(stxnid);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = txnid->abort(txnid);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return S48_TRUE;
|
|
}
|
|
|
|
s48_value scsh_bdb_txn_commit(s48_value stxnid, s48_value sflags)
|
|
{
|
|
int res;
|
|
DB_TXN *txnid;
|
|
s48_value ret = S48_FALSE;
|
|
u_int32_t flags;
|
|
S48_DECLARE_GC_PROTECT(2);
|
|
S48_GC_PROTECT_2(stxnid, sflags);
|
|
flags = s48_extract_integer(sflags);
|
|
txnid = EXTRACT_OPTIONAL_TXNID(stxnid);
|
|
S48_GC_UNPROTECT();
|
|
|
|
res = txnid->commit(txnid, flags);
|
|
CHECK_BDB_RESULT_CODE(res);
|
|
return S48_TRUE;
|
|
}
|
|
|
|
/* initialize bindings */
|
|
void scsh_init_bdb_bindings(void)
|
|
{
|
|
/* records */
|
|
S48_GC_PROTECT_GLOBAL(bdb_db_record_type);
|
|
bdb_db_record_type = s48_get_imported_binding("bdb-db");
|
|
|
|
S48_GC_PROTECT_GLOBAL(bdb_env_record_type);
|
|
bdb_env_record_type = s48_get_imported_binding("bdb-env");
|
|
|
|
S48_GC_PROTECT_GLOBAL(bdb_mpoolfile_record_type);
|
|
bdb_mpoolfile_record_type = s48_get_imported_binding("bdb-mpoolfile");
|
|
|
|
S48_GC_PROTECT_GLOBAL(bdb_txn_record_type);
|
|
bdb_txn_record_type = s48_get_imported_binding("bdb-txn");
|
|
|
|
S48_GC_PROTECT_GLOBAL(bdb_dbc_record_type);
|
|
bdb_dbc_record_type = s48_get_imported_binding("bdb-dbc");
|
|
|
|
/* flag constants */
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_RPCCLIENT);
|
|
scheme_DB_RPCCLIENT = s48_enter_integer(DB_RPCCLIENT);
|
|
s48_define_exported_binding("scheme_DB_RPCCLIENT",scheme_DB_RPCCLIENT);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_INIT_LOCK);
|
|
scheme_DB_INIT_LOCK = s48_enter_integer(DB_INIT_LOCK);
|
|
s48_define_exported_binding("scheme_DB_INIT_LOCK",scheme_DB_INIT_LOCK);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_JOINENV);
|
|
scheme_DB_JOINENV = s48_enter_integer(DB_JOINENV);
|
|
s48_define_exported_binding("scheme_DB_JOINENV",scheme_DB_JOINENV);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_INIT_MPOOL);
|
|
scheme_DB_INIT_MPOOL = s48_enter_integer(DB_INIT_MPOOL);
|
|
s48_define_exported_binding("scheme_DB_INIT_MPOOL",scheme_DB_INIT_MPOOL);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_INIT_LOG);
|
|
scheme_DB_INIT_LOG = s48_enter_integer(DB_INIT_LOG);
|
|
s48_define_exported_binding("scheme_DB_INIT_LOG",scheme_DB_INIT_LOG);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_INIT_REP);
|
|
scheme_DB_INIT_REP = s48_enter_integer(DB_INIT_REP);
|
|
s48_define_exported_binding("scheme_DB_INIT_REP",scheme_DB_INIT_REP);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_INIT_TXN);
|
|
scheme_DB_INIT_TXN = s48_enter_integer(DB_INIT_TXN);
|
|
s48_define_exported_binding("scheme_DB_INIT_TXN",scheme_DB_INIT_TXN);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_RECOVER);
|
|
scheme_DB_RECOVER = s48_enter_integer(DB_RECOVER);
|
|
s48_define_exported_binding("scheme_DB_RECOVER",scheme_DB_RECOVER);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_RECOVER_FATAL);
|
|
scheme_DB_RECOVER_FATAL = s48_enter_integer(DB_RECOVER_FATAL);
|
|
s48_define_exported_binding("scheme_DB_RECOVER_FATAL",scheme_DB_RECOVER_FATAL);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_USE_ENVIRON);
|
|
scheme_DB_USE_ENVIRON = s48_enter_integer(DB_USE_ENVIRON);
|
|
s48_define_exported_binding("scheme_DB_USE_ENVIRON",scheme_DB_USE_ENVIRON);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_USE_ENVIRON_ROOT);
|
|
scheme_DB_USE_ENVIRON_ROOT = s48_enter_integer(DB_USE_ENVIRON_ROOT);
|
|
s48_define_exported_binding("scheme_DB_USE_ENVIRON_ROOT",scheme_DB_USE_ENVIRON_ROOT);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_CREATE);
|
|
scheme_DB_CREATE = s48_enter_integer(DB_CREATE);
|
|
s48_define_exported_binding("scheme_DB_CREATE",scheme_DB_CREATE);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_LOCKDOWN);
|
|
scheme_DB_LOCKDOWN = s48_enter_integer(DB_LOCKDOWN);
|
|
s48_define_exported_binding("scheme_DB_LOCKDOWN",scheme_DB_LOCKDOWN);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_PRIVATE);
|
|
scheme_DB_PRIVATE = s48_enter_integer(DB_PRIVATE);
|
|
s48_define_exported_binding("scheme_DB_PRIVATE",scheme_DB_PRIVATE);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_SYSTEM_MEM);
|
|
scheme_DB_SYSTEM_MEM = s48_enter_integer(DB_SYSTEM_MEM);
|
|
s48_define_exported_binding("scheme_DB_SYSTEM_MEM",scheme_DB_SYSTEM_MEM);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_THREAD);
|
|
scheme_DB_THREAD = s48_enter_integer(DB_THREAD);
|
|
s48_define_exported_binding("scheme_DB_THREAD",scheme_DB_THREAD);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_AUTO_COMMIT);
|
|
scheme_DB_AUTO_COMMIT = s48_enter_integer(DB_AUTO_COMMIT);
|
|
s48_define_exported_binding("scheme_DB_AUTO_COMMIT",scheme_DB_AUTO_COMMIT);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_DIRTY_READ);
|
|
scheme_DB_DIRTY_READ = s48_enter_integer(DB_DIRTY_READ);
|
|
s48_define_exported_binding("scheme_DB_DIRTY_READ",scheme_DB_DIRTY_READ);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_EXCL);
|
|
scheme_DB_EXCL = s48_enter_integer(DB_EXCL);
|
|
s48_define_exported_binding("scheme_DB_EXCL",scheme_DB_EXCL);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_NOMMAP);
|
|
scheme_DB_NOMMAP = s48_enter_integer(DB_NOMMAP);
|
|
s48_define_exported_binding("scheme_DB_NOMMAP",scheme_DB_NOMMAP);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_RDONLY);
|
|
scheme_DB_RDONLY = s48_enter_integer(DB_RDONLY);
|
|
s48_define_exported_binding("scheme_DB_RDONLY",scheme_DB_RDONLY);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_SYSTEM_MEM);
|
|
scheme_DB_SYSTEM_MEM = s48_enter_integer(DB_SYSTEM_MEM);
|
|
s48_define_exported_binding("scheme_DB_SYSTEM_MEM",scheme_DB_SYSTEM_MEM);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_TRUNCATE);
|
|
scheme_DB_TRUNCATE = s48_enter_integer(DB_TRUNCATE);
|
|
s48_define_exported_binding("scheme_DB_TRUNCATE",scheme_DB_TRUNCATE);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_NOSYNC);
|
|
scheme_DB_NOSYNC = s48_enter_integer(DB_NOSYNC);
|
|
s48_define_exported_binding("scheme_DB_NOSYNC",scheme_DB_NOSYNC);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_CONSUME);
|
|
scheme_DB_CONSUME = s48_enter_integer(DB_CONSUME);
|
|
s48_define_exported_binding("scheme_DB_CONSUME",scheme_DB_CONSUME);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_CONSUME_WAIT);
|
|
scheme_DB_CONSUME_WAIT = s48_enter_integer(DB_CONSUME_WAIT);
|
|
s48_define_exported_binding("scheme_DB_CONSUME_WAIT",scheme_DB_CONSUME_WAIT);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_GET_BOTH);
|
|
scheme_DB_GET_BOTH = s48_enter_integer(DB_GET_BOTH);
|
|
s48_define_exported_binding("scheme_DB_GET_BOTH",scheme_DB_GET_BOTH);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_RMW);
|
|
scheme_DB_RMW = s48_enter_integer(DB_RMW);
|
|
s48_define_exported_binding("scheme_DB_RMW",scheme_DB_RMW);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_MULTIPLE);
|
|
scheme_DB_MULTIPLE = s48_enter_integer(DB_MULTIPLE);
|
|
s48_define_exported_binding("scheme_DB_MULTIPLE",scheme_DB_MULTIPLE);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_SET_RECNO);
|
|
scheme_DB_SET_RECNO = s48_enter_integer(DB_SET_RECNO);
|
|
s48_define_exported_binding("scheme_DB_SET_RECNO",scheme_DB_SET_RECNO);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_APPEND);
|
|
scheme_DB_APPEND = s48_enter_integer(DB_APPEND);
|
|
s48_define_exported_binding("scheme_DB_APPEND",scheme_DB_APPEND);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_NODUPDATA);
|
|
scheme_DB_NODUPDATA = s48_enter_integer(DB_NODUPDATA);
|
|
s48_define_exported_binding("scheme_DB_NODUPDATA",scheme_DB_NODUPDATA);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_NOOVERWRITE);
|
|
scheme_DB_NOOVERWRITE = s48_enter_integer(DB_NOOVERWRITE);
|
|
s48_define_exported_binding("scheme_DB_NOOVERWRITE",scheme_DB_NOOVERWRITE);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_CURRENT);
|
|
scheme_DB_CURRENT = s48_enter_integer(DB_CURRENT);
|
|
s48_define_exported_binding("scheme_DB_CURRENT",scheme_DB_CURRENT);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_FIRST);
|
|
scheme_DB_FIRST = s48_enter_integer(DB_FIRST);
|
|
s48_define_exported_binding("scheme_DB_FIRST",scheme_DB_FIRST);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_WRITECURSOR);
|
|
scheme_DB_WRITECURSOR = s48_enter_integer(DB_WRITECURSOR);
|
|
s48_define_exported_binding("scheme_DB_WRITECURSOR",scheme_DB_WRITECURSOR);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_GET_BOTH_RANGE);
|
|
scheme_DB_GET_BOTH_RANGE = s48_enter_integer(DB_GET_BOTH_RANGE);
|
|
s48_define_exported_binding("scheme_DB_GET_BOTH_RANGE",scheme_DB_GET_BOTH_RANGE);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_GET_RECNO);
|
|
scheme_DB_GET_RECNO = s48_enter_integer(DB_GET_RECNO);
|
|
s48_define_exported_binding("scheme_DB_GET_RECNO",scheme_DB_GET_RECNO);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_JOIN_ITEM);
|
|
scheme_DB_JOIN_ITEM = s48_enter_integer(DB_JOIN_ITEM);
|
|
s48_define_exported_binding("scheme_DB_JOIN_ITEM",scheme_DB_JOIN_ITEM);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_LAST);
|
|
scheme_DB_LAST = s48_enter_integer(DB_LAST);
|
|
s48_define_exported_binding("scheme_DB_LAST",scheme_DB_LAST);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_NEXT);
|
|
scheme_DB_NEXT = s48_enter_integer(DB_NEXT);
|
|
s48_define_exported_binding("scheme_DB_NEXT",scheme_DB_NEXT);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_NEXT_DUP);
|
|
scheme_DB_NEXT_DUP = s48_enter_integer(DB_NEXT_DUP);
|
|
s48_define_exported_binding("scheme_DB_NEXT_DUP",scheme_DB_NEXT_DUP);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_NEXT_NODUP);
|
|
scheme_DB_NEXT_NODUP = s48_enter_integer(DB_NEXT_NODUP);
|
|
s48_define_exported_binding("scheme_DB_NEXT_NODUP",scheme_DB_NEXT_NODUP);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_PREV);
|
|
scheme_DB_PREV = s48_enter_integer(DB_PREV);
|
|
s48_define_exported_binding("scheme_DB_PREV",scheme_DB_PREV);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_SET);
|
|
scheme_DB_SET = s48_enter_integer(DB_SET);
|
|
s48_define_exported_binding("scheme_DB_SET",scheme_DB_SET);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_SET_RANGE);
|
|
scheme_DB_SET_RANGE = s48_enter_integer(DB_SET_RANGE);
|
|
s48_define_exported_binding("scheme_DB_SET_RANGE",scheme_DB_SET_RANGE);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_MULTIPLE_KEY);
|
|
scheme_DB_MULTIPLE_KEY = s48_enter_integer(DB_MULTIPLE_KEY);
|
|
s48_define_exported_binding("scheme_DB_MULTIPLE_KEY",scheme_DB_MULTIPLE_KEY);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_TXN_NOSYNC);
|
|
scheme_DB_TXN_NOSYNC = s48_enter_integer(DB_TXN_NOSYNC);
|
|
s48_define_exported_binding("scheme_DB_TXN_NOSYNC",scheme_DB_TXN_NOSYNC);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_TXN_NOWAIT);
|
|
scheme_DB_TXN_NOWAIT = s48_enter_integer(DB_TXN_NOWAIT);
|
|
s48_define_exported_binding("scheme_DB_TXN_NOWAIT",scheme_DB_TXN_NOWAIT);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_TXN_SYNC);
|
|
scheme_DB_TXN_SYNC = s48_enter_integer(DB_TXN_SYNC);
|
|
s48_define_exported_binding("scheme_DB_TXN_SYNC",scheme_DB_TXN_SYNC);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_BTREE);
|
|
scheme_DB_BTREE = s48_enter_integer(DB_BTREE);
|
|
s48_define_exported_binding("scheme_DB_BTREE",scheme_DB_BTREE);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_HASH);
|
|
scheme_DB_HASH = s48_enter_integer(DB_HASH);
|
|
s48_define_exported_binding("scheme_DB_HASH",scheme_DB_HASH);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_QUEUE);
|
|
scheme_DB_QUEUE = s48_enter_integer(DB_QUEUE);
|
|
s48_define_exported_binding("scheme_DB_QUEUE",scheme_DB_QUEUE);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_RECNO);
|
|
scheme_DB_RECNO = s48_enter_integer(DB_RECNO);
|
|
s48_define_exported_binding("scheme_DB_RECNO",scheme_DB_RECNO);
|
|
|
|
S48_GC_PROTECT_GLOBAL(scheme_DB_UNKNOWN);
|
|
scheme_DB_UNKNOWN = s48_enter_integer(DB_UNKNOWN);
|
|
s48_define_exported_binding("scheme_DB_UNKNOWN",scheme_DB_UNKNOWN);
|
|
|
|
/* export functions to scheme */
|
|
S48_EXPORT_FUNCTION(scsh_bdb_create);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_open);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_close);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_put);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_get);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_del);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_env_create);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_env_open);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_env_close);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_env_remove);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_truncate);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_sync);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_create_cursor);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_cursor_cget);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_txn_begin);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_txn_abort);
|
|
S48_EXPORT_FUNCTION(scsh_bdb_txn_commit);
|
|
}
|