54 lines
1.7 KiB
C
54 lines
1.7 KiB
C
#include <sys/types.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#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_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)))
|
|
|
|
#define CHECK_BDB_RESULT_CODE(res) \
|
|
do { \
|
|
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);
|