00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _DB_TCL_DB_H_
00011 #define _DB_TCL_DB_H_
00012
00013 #define MSG_SIZE 100
00014
00015 enum INFOTYPE {
00016 I_ENV, I_DB, I_DBC, I_TXN, I_MP, I_PG, I_LOCK, I_LOGC, I_NDBM, I_SEQ};
00017
00018 #define MAX_ID 8
00019 #define DBTCL_PREP 64
00020
00021 #define DBTCL_DBM 1
00022 #define DBTCL_NDBM 2
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 typedef struct dbtcl_info {
00053 LIST_ENTRY(dbtcl_info) entries;
00054 Tcl_Interp *i_interp;
00055 char *i_name;
00056 enum INFOTYPE i_type;
00057 union infop {
00058 DB *dbp;
00059 DBC *dbcp;
00060 DB_ENV *envp;
00061 DB_LOCK *lock;
00062 DB_LOGC *logc;
00063 DB_MPOOLFILE *mp;
00064 DB_TXN *txnp;
00065 void *anyp;
00066 } un;
00067 union data {
00068 int anydata;
00069 db_pgno_t pgno;
00070 u_int32_t lockid;
00071 } und;
00072 union data2 {
00073 int anydata;
00074 int pagesz;
00075 DB_COMPACT *c_data;
00076 } und2;
00077 DBT i_lockobj;
00078 FILE *i_err;
00079 char *i_errpfx;
00080
00081
00082 Tcl_Obj *i_btcompare;
00083 Tcl_Obj *i_dupcompare;
00084 Tcl_Obj *i_hashproc;
00085 Tcl_Obj *i_rep_send;
00086 Tcl_Obj *i_second_call;
00087
00088
00089 Tcl_Obj *i_rep_eid;
00090
00091 struct dbtcl_info *i_parent;
00092 int i_otherid[MAX_ID];
00093 } DBTCL_INFO;
00094
00095 #define i_anyp un.anyp
00096 #define i_pagep un.anyp
00097 #define i_envp un.envp
00098 #define i_dbp un.dbp
00099 #define i_dbcp un.dbcp
00100 #define i_txnp un.txnp
00101 #define i_mp un.mp
00102 #define i_lock un.lock
00103 #define i_logc un.logc
00104
00105 #define i_data und.anydata
00106 #define i_pgno und.pgno
00107 #define i_locker und.lockid
00108 #define i_data2 und2.anydata
00109 #define i_pgsz und2.pagesz
00110 #define i_cdata und2.c_data
00111
00112 #define i_envtxnid i_otherid[0]
00113 #define i_envmpid i_otherid[1]
00114 #define i_envlockid i_otherid[2]
00115 #define i_envlogcid i_otherid[3]
00116
00117 #define i_mppgid i_otherid[0]
00118
00119 #define i_dbdbcid i_otherid[0]
00120
00121 extern int __debug_on, __debug_print, __debug_stop, __debug_test;
00122
00123 typedef struct dbtcl_global {
00124 LIST_HEAD(infohead, dbtcl_info) g_infohead;
00125 } DBTCL_GLOBAL;
00126 #define __db_infohead __dbtcl_global.g_infohead
00127
00128 extern DBTCL_GLOBAL __dbtcl_global;
00129
00130
00131
00132
00133
00134
00135 #define NewStringObj(a, b) \
00136 Tcl_NewStringObj(a, (int)b)
00137
00138 #define NAME_TO_DB(name) (DB *)_NameToPtr((name))
00139 #define NAME_TO_DBC(name) (DBC *)_NameToPtr((name))
00140 #define NAME_TO_ENV(name) (DB_ENV *)_NameToPtr((name))
00141 #define NAME_TO_LOCK(name) (DB_LOCK *)_NameToPtr((name))
00142 #define NAME_TO_MP(name) (DB_MPOOLFILE *)_NameToPtr((name))
00143 #define NAME_TO_TXN(name) (DB_TXN *)_NameToPtr((name))
00144 #define NAME_TO_SEQUENCE(name) (DB_SEQUENCE *)_NameToPtr((name))
00145
00146
00147
00148
00149
00150
00151
00152
00153 #define MAKE_STAT_LIST(s, v) do { \
00154 result = _SetListElemInt(interp, res, (s), (long)(v)); \
00155 if (result != TCL_OK) \
00156 goto error; \
00157 } while (0)
00158
00159 #define MAKE_WSTAT_LIST(s, v) do { \
00160 result = _SetListElemWideInt(interp, res, (s), (int64_t)(v)); \
00161 if (result != TCL_OK) \
00162 goto error; \
00163 } while (0)
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 #define MAKE_STAT_LSN(s, lsn) do { \
00174 myobjc = 2; \
00175 myobjv[0] = Tcl_NewLongObj((long)(lsn)->file); \
00176 myobjv[1] = Tcl_NewLongObj((long)(lsn)->offset); \
00177 lsnlist = Tcl_NewListObj(myobjc, myobjv); \
00178 myobjc = 2; \
00179 myobjv[0] = Tcl_NewStringObj((s), (int)strlen(s)); \
00180 myobjv[1] = lsnlist; \
00181 thislist = Tcl_NewListObj(myobjc, myobjv); \
00182 result = Tcl_ListObjAppendElement(interp, res, thislist); \
00183 if (result != TCL_OK) \
00184 goto error; \
00185 } while (0)
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 #define MAKE_STAT_STRLIST(s,s1) do { \
00196 result = _SetListElem(interp, res, (s), strlen(s), \
00197 (s1), strlen(s1)); \
00198 if (result != TCL_OK) \
00199 goto error; \
00200 } while (0)
00201
00202
00203
00204
00205
00206 #define FLAG_CHECK(flag) do { \
00207 if ((flag) != 0) { \
00208 Tcl_SetResult(interp, \
00209 " Only 1 policy can be specified.\n", \
00210 TCL_STATIC); \
00211 result = TCL_ERROR; \
00212 break; \
00213 } \
00214 } while (0)
00215
00216
00217
00218
00219
00220
00221 #define FLAG_CHECK2(flag, val) do { \
00222 if (((flag) & ~(val)) != 0) { \
00223 Tcl_SetResult(interp, \
00224 " Only 1 policy can be specified.\n", \
00225 TCL_STATIC); \
00226 result = TCL_ERROR; \
00227 break; \
00228 } \
00229 } while (0)
00230
00231
00232
00233
00234
00235
00236
00237 #define IS_HELP(s) \
00238 (strcmp(Tcl_GetStringFromObj(s,NULL), "-?") == 0) ? TCL_OK : TCL_ERROR
00239
00240 #include "dbinc_auto/tcl_ext.h"
00241 #endif