#ifndef _DB_TCL_DB_H_
#define _DB_TCL_DB_H_
#if defined(__cplusplus)
extern "C" {
#endif
#define MSG_SIZE 100
enum INFOTYPE {
I_ENV, I_DB, I_DBC, I_TXN, I_MP, I_PG, I_LOCK, I_LOGC, I_NDBM, I_SEQ};
#define MAX_ID 8
#define DBTCL_PREP 64
#define DBTCL_DBM 1
#define DBTCL_NDBM 2
#define DBTCL_GETCLOCK 0
#define DBTCL_GETLIMIT 1
#define DBTCL_GETREQ 2
typedef struct dbtcl_info {
LIST_ENTRY(dbtcl_info) entries;
Tcl_Interp *i_interp;
char *i_name;
enum INFOTYPE i_type;
union infop {
DB *dbp;
DBC *dbcp;
DB_ENV *envp;
DB_LOCK *lock;
DB_LOGC *logc;
DB_MPOOLFILE *mp;
DB_TXN *txnp;
void *anyp;
} un;
union data {
int anydata;
db_pgno_t pgno;
u_int32_t lockid;
} und;
union data2 {
int anydata;
int pagesz;
DB_COMPACT *c_data;
} und2;
DBT i_lockobj;
FILE *i_err;
char *i_errpfx;
Tcl_Obj *i_compare;
Tcl_Obj *i_dupcompare;
Tcl_Obj *i_event;
Tcl_Obj *i_hashproc;
Tcl_Obj *i_rep_send;
Tcl_Obj *i_second_call;
Tcl_Obj *i_rep_eid;
struct dbtcl_info *i_parent;
int i_otherid[MAX_ID];
} DBTCL_INFO;
#define i_anyp un.anyp
#define i_pagep un.anyp
#define i_envp un.envp
#define i_dbp un.dbp
#define i_dbcp un.dbcp
#define i_txnp un.txnp
#define i_mp un.mp
#define i_lock un.lock
#define i_logc un.logc
#define i_data und.anydata
#define i_pgno und.pgno
#define i_locker und.lockid
#define i_data2 und2.anydata
#define i_pgsz und2.pagesz
#define i_cdata und2.c_data
#define i_envtxnid i_otherid[0]
#define i_envmpid i_otherid[1]
#define i_envlockid i_otherid[2]
#define i_envlogcid i_otherid[3]
#define i_mppgid i_otherid[0]
#define i_dbdbcid i_otherid[0]
extern int __debug_on, __debug_print, __debug_stop, __debug_test;
typedef struct dbtcl_global {
LIST_HEAD(infohead, dbtcl_info) g_infohead;
} DBTCL_GLOBAL;
#define __db_infohead __dbtcl_global.g_infohead
extern DBTCL_GLOBAL __dbtcl_global;
#define NewStringObj(a, b) \
Tcl_NewStringObj(a, (int)b)
#define NAME_TO_DB(name) (DB *)_NameToPtr((name))
#define NAME_TO_DBC(name) (DBC *)_NameToPtr((name))
#define NAME_TO_ENV(name) (DB_ENV *)_NameToPtr((name))
#define NAME_TO_LOCK(name) (DB_LOCK *)_NameToPtr((name))
#define NAME_TO_MP(name) (DB_MPOOLFILE *)_NameToPtr((name))
#define NAME_TO_TXN(name) (DB_TXN *)_NameToPtr((name))
#define NAME_TO_SEQUENCE(name) (DB_SEQUENCE *)_NameToPtr((name))
#define MAKE_STAT_LIST(s, v) do { \
result = _SetListElemInt(interp, res, (s), (long)(v)); \
if (result != TCL_OK) \
goto error; \
} while (0)
#define MAKE_WSTAT_LIST(s, v) do { \
result = _SetListElemWideInt(interp, res, (s), (int64_t)(v)); \
if (result != TCL_OK) \
goto error; \
} while (0)
#define MAKE_STAT_LSN(s, lsn) do { \
myobjc = 2; \
myobjv[0] = Tcl_NewLongObj((long)(lsn)->file); \
myobjv[1] = Tcl_NewLongObj((long)(lsn)->offset); \
lsnlist = Tcl_NewListObj(myobjc, myobjv); \
myobjc = 2; \
myobjv[0] = Tcl_NewStringObj((s), (int)strlen(s)); \
myobjv[1] = lsnlist; \
thislist = Tcl_NewListObj(myobjc, myobjv); \
result = Tcl_ListObjAppendElement(interp, res, thislist); \
if (result != TCL_OK) \
goto error; \
} while (0)
#define MAKE_STAT_STRLIST(s,s1) do { \
result = _SetListElem(interp, res, (s), strlen(s), \
(s1), strlen(s1)); \
if (result != TCL_OK) \
goto error; \
} while (0)
#define FLAG_CHECK(flag) do { \
if ((flag) != 0) { \
Tcl_SetResult(interp, \
" Only 1 policy can be specified.\n", \
TCL_STATIC); \
result = TCL_ERROR; \
break; \
} \
} while (0)
#define FLAG_CHECK2(flag, val) do { \
if (((flag) & ~(val)) != 0) { \
Tcl_SetResult(interp, \
" Only 1 policy can be specified.\n", \
TCL_STATIC); \
result = TCL_ERROR; \
break; \
} \
} while (0)
#define IS_HELP(s) \
(strcmp(Tcl_GetStringFromObj(s,NULL), "-?") == 0) ? TCL_OK : TCL_ERROR
#if defined(__cplusplus)
}
#endif
#include "dbinc_auto/tcl_ext.h"
#endif