#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; static s48_value scheme_DB_DONOTINDEX = S48_FALSE; static s48_value scheme_DB_FILEOPEN = S48_FALSE; static s48_value scheme_DB_KEYEMPTY = S48_FALSE; static s48_value scheme_DB_KEYEXIST = S48_FALSE; static s48_value scheme_DB_LOCK_DEADLOCK = S48_FALSE; static s48_value scheme_DB_LOCK_NOTGRANTED = S48_FALSE; static s48_value scheme_DB_NOSERVER = S48_FALSE; static s48_value scheme_DB_NOSERVER_HOME = S48_FALSE; static s48_value scheme_DB_NOSERVER_ID = S48_FALSE; static s48_value scheme_DB_NOTFOUND = S48_FALSE; static s48_value scheme_DB_OLD_VERSION = S48_FALSE; static s48_value scheme_DB_PAGE_NOTFOUND = S48_FALSE; static s48_value scheme_DB_REP_DUPMASTER = S48_FALSE; static s48_value scheme_DB_REP_HANDLE_DEAD = S48_FALSE; static s48_value scheme_DB_REP_HOLDELECTION = S48_FALSE; static s48_value scheme_DB_REP_ISPERM = S48_FALSE; static s48_value scheme_DB_REP_NEWMASTER = S48_FALSE; static s48_value scheme_DB_REP_NEWSITE = S48_FALSE; static s48_value scheme_DB_REP_NOTPERM = S48_FALSE; static s48_value scheme_DB_REP_OUTDATED = S48_FALSE; static s48_value scheme_DB_REP_UNAVAIL = S48_FALSE; static s48_value scheme_DB_RUNRECOVERY = S48_FALSE; static s48_value scheme_DB_SECONDARY_BAD = S48_FALSE; static s48_value scheme_DB_VERIFY_BAD = 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_dbenv(dbenv); } /* close an environment */ s48_value scsh_bdb_env_close(s48_value env) { int res; DB_ENV *dbenv; S48_DECLARE_GC_PROTECT(1); S48_GC_PROTECT_1(env); dbenv = scsh_extract_dbenv(env); S48_GC_UNPROTECT(); res = dbenv->close(dbenv, 0); CHECK_BDB_RESULT_CODE(res); return S48_TRUE; } /* remove a database */ /* s48_value scsh_bdb_dbremove(s48_value senv_handle, s48_value stxnid, */ /* s48_value sfile, s48_value sdatabase, */ /* s48_value sflags) */ /* { */ /* DB_ENV *dbenv; */ /* DB_TXN *txnid; */ /* DB *dbp; */ /* char *file; */ /* u_int32_t flags; */ /* int res; */ /* S48_DECLARE_GC_PROTECT(5); */ /* S48_GC_PROTECT_5(senv_handle, stxnid, sfile, sdatabase, sflags); */ /* dbenv = scsh_extract_dbenv(senv_handle); */ /* txnid = EXTRACT_OPTIONAL_TXNID(stxnid); */ /* file = s48_extract_string(sfile); */ /* dbp = scsh_extract_db(sdatabase); */ /* flags = s48_extract_integer(sflags); */ /* S48_GC_UNPROTECT(); */ /* res = DB_ENV->dbremove(dbenv, txnid, file, dbp, flags); */ /* CHECK_BDB_RESULT_CODE(res); */ /* } */ /* rename a database */ /* s48_value scsh_bdb_dbrename(s48_value senv_handle, s48_value stxnid, */ /* s48_value sfile, s48_value sdatabase, */ /* s48_value snewname, s48_value sflags) */ /* { */ /* DB_ENV *dbenv; */ /* DB_TXN *txnid; */ /* char *file, *database, *newname; */ /* u_int32_t flags; */ /* S48_DECLARE_GC_PROTECT(6); */ /* S48_GC_UNPROTECT_6(senv_handle, stxnid, sfile, sdatabase, snewname, sflags); */ /* 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_enter_integer(res); } 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 S48_TRUE; } /* 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); switch (res) { case DB_NOTFOUND: case DB_KEYEMPTY: return s48_enter_integer(res); break; default: 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); } s48_value scsh_bdb_close_cursor(s48_value scursor) { int res; DBC *cursor; S48_DECLARE_GC_PROTECT(1); S48_GC_PROTECT_1(scursor); cursor = scsh_extract_cursor(scursor); S48_GC_UNPROTECT(); res = cursor->c_close(cursor); CHECK_BDB_RESULT_CODE(res); return s48_enter_integer(res); } /* 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_dbenv(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 */ ENTER_INTEGER_CONSTANT(scheme_DB_RPCCLIENT, DB_RPCCLIENT); ENTER_INTEGER_CONSTANT(scheme_DB_INIT_LOCK, DB_INIT_LOCK); ENTER_INTEGER_CONSTANT(scheme_DB_JOINENV, DB_JOINENV); ENTER_INTEGER_CONSTANT(scheme_DB_INIT_MPOOL, DB_INIT_MPOOL); ENTER_INTEGER_CONSTANT(scheme_DB_INIT_LOG, DB_INIT_LOG); ENTER_INTEGER_CONSTANT(scheme_DB_INIT_REP, DB_INIT_REP); ENTER_INTEGER_CONSTANT(scheme_DB_INIT_TXN, DB_INIT_TXN); ENTER_INTEGER_CONSTANT(scheme_DB_RECOVER, DB_RECOVER); ENTER_INTEGER_CONSTANT(scheme_DB_RECOVER_FATAL, DB_RECOVER_FATAL); ENTER_INTEGER_CONSTANT(scheme_DB_USE_ENVIRON, DB_USE_ENVIRON); ENTER_INTEGER_CONSTANT(scheme_DB_USE_ENVIRON_ROOT, DB_USE_ENVIRON_ROOT); ENTER_INTEGER_CONSTANT(scheme_DB_CREATE, DB_CREATE); ENTER_INTEGER_CONSTANT(scheme_DB_LOCKDOWN, DB_LOCKDOWN); ENTER_INTEGER_CONSTANT(scheme_DB_PRIVATE, DB_PRIVATE); ENTER_INTEGER_CONSTANT(scheme_DB_SYSTEM_MEM, DB_SYSTEM_MEM); ENTER_INTEGER_CONSTANT(scheme_DB_THREAD, DB_THREAD); ENTER_INTEGER_CONSTANT(scheme_DB_AUTO_COMMIT, DB_AUTO_COMMIT); ENTER_INTEGER_CONSTANT(scheme_DB_DIRTY_READ, DB_DIRTY_READ); ENTER_INTEGER_CONSTANT(scheme_DB_EXCL, DB_EXCL); ENTER_INTEGER_CONSTANT(scheme_DB_NOMMAP, DB_NOMMAP); ENTER_INTEGER_CONSTANT(scheme_DB_RDONLY, DB_RDONLY); ENTER_INTEGER_CONSTANT(scheme_DB_SYSTEM_MEM, DB_SYSTEM_MEM); ENTER_INTEGER_CONSTANT(scheme_DB_TRUNCATE, DB_TRUNCATE); ENTER_INTEGER_CONSTANT(scheme_DB_NOSYNC, DB_NOSYNC); ENTER_INTEGER_CONSTANT(scheme_DB_CONSUME, DB_CONSUME); ENTER_INTEGER_CONSTANT(scheme_DB_CONSUME_WAIT, DB_CONSUME_WAIT); ENTER_INTEGER_CONSTANT(scheme_DB_GET_BOTH, DB_GET_BOTH); ENTER_INTEGER_CONSTANT(scheme_DB_RMW, DB_RMW); ENTER_INTEGER_CONSTANT(scheme_DB_MULTIPLE, DB_MULTIPLE); ENTER_INTEGER_CONSTANT(scheme_DB_SET_RECNO, DB_SET_RECNO); ENTER_INTEGER_CONSTANT(scheme_DB_APPEND, DB_APPEND); ENTER_INTEGER_CONSTANT(scheme_DB_NODUPDATA, DB_NODUPDATA); ENTER_INTEGER_CONSTANT(scheme_DB_NOOVERWRITE, DB_NOOVERWRITE); ENTER_INTEGER_CONSTANT(scheme_DB_CURRENT, DB_CURRENT); ENTER_INTEGER_CONSTANT(scheme_DB_FIRST, DB_FIRST); ENTER_INTEGER_CONSTANT(scheme_DB_WRITECURSOR, DB_WRITECURSOR); ENTER_INTEGER_CONSTANT(scheme_DB_GET_BOTH_RANGE, DB_GET_BOTH_RANGE); ENTER_INTEGER_CONSTANT(scheme_DB_GET_RECNO, DB_GET_RECNO); ENTER_INTEGER_CONSTANT(scheme_DB_JOIN_ITEM, DB_JOIN_ITEM); ENTER_INTEGER_CONSTANT(scheme_DB_LAST, DB_LAST); ENTER_INTEGER_CONSTANT(scheme_DB_NEXT, DB_NEXT); ENTER_INTEGER_CONSTANT(scheme_DB_NEXT_DUP, DB_NEXT_DUP); ENTER_INTEGER_CONSTANT(scheme_DB_NEXT_NODUP, DB_NEXT_NODUP); ENTER_INTEGER_CONSTANT(scheme_DB_PREV, DB_PREV); ENTER_INTEGER_CONSTANT(scheme_DB_SET, DB_SET); ENTER_INTEGER_CONSTANT(scheme_DB_SET_RANGE, DB_SET_RANGE); ENTER_INTEGER_CONSTANT(scheme_DB_MULTIPLE_KEY, DB_MULTIPLE_KEY); ENTER_INTEGER_CONSTANT(scheme_DB_TXN_NOSYNC, DB_TXN_NOSYNC); ENTER_INTEGER_CONSTANT(scheme_DB_TXN_NOWAIT, DB_TXN_NOWAIT); ENTER_INTEGER_CONSTANT(scheme_DB_TXN_SYNC, DB_TXN_SYNC); ENTER_INTEGER_CONSTANT(scheme_DB_BTREE, DB_BTREE); ENTER_INTEGER_CONSTANT(scheme_DB_HASH, DB_HASH); ENTER_INTEGER_CONSTANT(scheme_DB_QUEUE, DB_QUEUE); ENTER_INTEGER_CONSTANT(scheme_DB_RECNO, DB_RECNO); ENTER_INTEGER_CONSTANT(scheme_DB_UNKNOWN, DB_UNKNOWN); /* return codes */ ENTER_INTEGER_CONSTANT(scheme_DB_DONOTINDEX, DB_DONOTINDEX); ENTER_INTEGER_CONSTANT(scheme_DB_FILEOPEN, DB_FILEOPEN); ENTER_INTEGER_CONSTANT(scheme_DB_KEYEMPTY, DB_KEYEMPTY); ENTER_INTEGER_CONSTANT(scheme_DB_KEYEXIST, DB_KEYEXIST); ENTER_INTEGER_CONSTANT(scheme_DB_LOCK_DEADLOCK, DB_LOCK_DEADLOCK); ENTER_INTEGER_CONSTANT(scheme_DB_LOCK_NOTGRANTED, DB_LOCK_NOTGRANTED); ENTER_INTEGER_CONSTANT(scheme_DB_NOSERVER, DB_NOSERVER); ENTER_INTEGER_CONSTANT(scheme_DB_NOSERVER_HOME, DB_NOSERVER_HOME); ENTER_INTEGER_CONSTANT(scheme_DB_NOSERVER_ID, DB_NOSERVER_ID); ENTER_INTEGER_CONSTANT(scheme_DB_NOTFOUND, DB_NOTFOUND); ENTER_INTEGER_CONSTANT(scheme_DB_OLD_VERSION, DB_OLD_VERSION); ENTER_INTEGER_CONSTANT(scheme_DB_PAGE_NOTFOUND, DB_PAGE_NOTFOUND); ENTER_INTEGER_CONSTANT(scheme_DB_REP_DUPMASTER, DB_REP_DUPMASTER); ENTER_INTEGER_CONSTANT(scheme_DB_REP_HANDLE_DEAD, DB_REP_HANDLE_DEAD); ENTER_INTEGER_CONSTANT(scheme_DB_REP_HOLDELECTION, DB_REP_HOLDELECTION); ENTER_INTEGER_CONSTANT(scheme_DB_REP_ISPERM, DB_REP_ISPERM); ENTER_INTEGER_CONSTANT(scheme_DB_REP_NEWMASTER, DB_REP_NEWMASTER); ENTER_INTEGER_CONSTANT(scheme_DB_REP_NEWSITE, DB_REP_NEWSITE); ENTER_INTEGER_CONSTANT(scheme_DB_REP_NOTPERM, DB_REP_NOTPERM); ENTER_INTEGER_CONSTANT(scheme_DB_REP_OUTDATED, DB_REP_OUTDATED); ENTER_INTEGER_CONSTANT(scheme_DB_REP_UNAVAIL, DB_REP_UNAVAIL); ENTER_INTEGER_CONSTANT(scheme_DB_RUNRECOVERY, DB_RUNRECOVERY); ENTER_INTEGER_CONSTANT(scheme_DB_SECONDARY_BAD, DB_SECONDARY_BAD); ENTER_INTEGER_CONSTANT(scheme_DB_VERIFY_BAD, DB_VERIFY_BAD); /* 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_close_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); }