#include #include #include #include #include "scheme48.h" #include "db.h" /* record types */ static s48_value bdb_db_record_type = S48_FALSE; static s48_value bdb_env_record_type = S48_FALSE; static s48_value bdb_lock_record_type = S48_FALSE; static s48_value bdb_mpoolfile_record_type = S48_FALSE; static s48_value bdb_txn_record_type = S48_FALSE; static s48_value bdb_dbc_record_type = S48_FALSE; /* prototypes and macros */ s48_value scsh_enter_db(DB *h); #define scsh_extract_db(x) \ ((DB *) s48_extract_integer(S48_RECORD_REF(x, 0))) s48_value scsh_enter_txnid(DB_TXN *txnid); #define scsh_extract_txnid(x) \ ((DB_TXN *) s48_extract_integer(S48_RECORD_REF(x, 0))) s48_value scsh_enter_cursor(DBC *dbc); #define scsh_extract_cursor(x) \ ((DBC *) s48_extract_integer(S48_RECORD_REF(x, 0))) s48_value scsh_enter_dbenv(DB_ENV *h); #define scsh_extract_dbenv(x) \ ((DB_ENV *) s48_extract_integer(S48_RECORD_REF(x, 0))) s48_value scsh_enter_lock(DB_LOCK *l); #define scsh_extract_lock(x) \ ((DB_LOCK *) s48_extract_integer(S48_RECORD_REF(x, 0))) s48_value scsh_enter_DBT_as_bytevector(DBT* dt); void scsh_extract_bytevector_as_DBT(s48_value bytevector, DBT* dt); #define CHECK_BDB_RESULT_CODE(res) \ do { \ if (res != 0) \ fprintf(stderr, "scsh-bdb: %s\n", db_strerror(res)); \ if (res > 0) \ s48_raise_os_error(res); \ if (res < 0) \ return s48_enter_integer(res); \ } while (0); #define EXTRACT_OPTIONAL_STRING(string) \ ((string == S48_FALSE) ? NULL : s48_extract_string(string)) #define EXTRACT_OPTIONAL_TXNID(txnid) \ ((txnid == S48_FALSE) ? NULL : scsh_extract_txnid(txnid)) #define EXTRACT_OPTIONAL_ENV(env) \ ((env == S48_FALSE) ? NULL : scsh_extract_dbenv(env)) #define ENTER_INTEGER_CONSTANT(scm_value, c_value) \ S48_GC_PROTECT_GLOBAL(scm_value); \ scm_value = s48_enter_integer(c_value); \ s48_define_exported_binding(#scm_value, scm_value);