Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

db4.cpp

00001 /*-
00002  *  Copyright (c) 2004
00003  *  Sleepycat Software.  All rights reserved.
00004  *
00005  *  http://www.apache.org/licenses/LICENSE-2.0.txt
00006  * 
00007  *  authors: George Schlossnagle <[email protected]>
00008  */
00009 
00010 #ifdef HAVE_CONFIG_H
00011 #include "config.h"
00012 #endif
00013 
00014 extern "C"
00015 {
00016 #include "php.h"
00017 #include "php_ini.h"
00018 #include "ext/standard/info.h"
00019 #include "php_db4.h"
00020 }
00021 #ifdef HAVE_MOD_DB4
00022 #include "mod_db4_export.h"
00023 #else
00024 #include "db_cxx.h"
00025 #endif
00026 
00027 #ifdef HAVE_MOD_DB4
00028     #define my_db_create mod_db4_db_create
00029     #define my_db_env_create mod_db4_db_env_create
00030 #else 
00031     #define my_db_create db_create
00032     #define my_db_env_create db_env_create
00033 #endif
00034 
00035 #if PHP_MAJOR_VERSION <= 4
00036 unsigned char second_arg_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };
00037 unsigned char third_arg_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, BYREF_FORCE };
00038 #endif
00039 extern int errno;
00040 
00041 /* True global resources - no need for thread safety here */
00042 static int le_db;
00043 static int le_dbc;
00044 static int le_db_txn;
00045 static int le_dbenv;
00046 
00047 struct php_DB_TXN {
00048     DB_TXN *db_txn;
00049     struct my_llist *open_cursors;
00050     struct my_llist *open_dbs;
00051 };
00052 
00053 struct php_DBC {
00054     DBC *dbc;
00055     struct php_DB_TXN *parent_txn;
00056     struct php_DB *parent_db;
00057 };
00058 
00059 struct php_DB {
00060     DB *db;
00061     struct my_llist *open_cursors;
00062     int autocommit;
00063 };
00064 
00065 struct php_DB_ENV {
00066     DB_ENV *dbenv;
00067     int autocommit;
00068 };
00069 
00070 static void _free_php_db_txn(zend_rsrc_list_entry *rsrc TSRMLS_DC)
00071 {
00072     struct php_DB_TXN *pdbtxn = (struct php_DB_TXN *) rsrc->ptr;
00073     /* should probably iterate over open_cursors */
00074 #ifndef HAVE_MOD_DB4
00075     if(pdbtxn->db_txn) pdbtxn->db_txn->abort(pdbtxn->db_txn);   
00076     pdbtxn->db_txn = NULL;
00077 #endif
00078     if(pdbtxn) efree(pdbtxn);
00079 }
00080 
00081 static void _free_php_dbc(zend_rsrc_list_entry *rsrc TSRMLS_DC)
00082 {
00083     struct php_DBC *pdbc = (struct php_DBC *) rsrc->ptr;
00084 #ifndef HAVE_MOD_DB4
00085     pdbc->dbc = NULL;
00086 #endif
00087     if(pdbc) efree(pdbc);
00088     rsrc->ptr = NULL;
00089 }
00090 
00091 static void _free_php_db(zend_rsrc_list_entry *rsrc TSRMLS_DC)
00092 {
00093     struct php_DB *pdb = (struct php_DB *) rsrc->ptr;
00094 #ifndef HAVE_MOD_DB4
00095     if(pdb->db) pdb->db->close(pdb->db, 0);
00096     pdb->db = NULL;
00097 #endif
00098     if(pdb) efree(pdb);
00099 }
00100 
00101 static void _free_php_dbenv(zend_rsrc_list_entry *rsrc TSRMLS_DC)
00102 {
00103     struct php_DB_ENV *pdb = (struct php_DB_ENV *)rsrc->ptr;
00104 #ifndef HAVE_MOD_DB4
00105     DbEnv *dbe;
00106         if(pdb->dbenv) {
00107                 dbe = DbEnv::get_DbEnv(pdb->dbenv);
00108             if(dbe) dbe->close(0);
00109                 delete dbe;
00110         }
00111 #endif
00112         if(pdb) efree(pdb);
00113 }
00114 
00115 static zend_class_entry *db_txn_ce;
00116 static zend_class_entry *dbc_ce;
00117 static zend_class_entry *db_ce;
00118 static zend_class_entry *db_env_ce;
00119 
00120 /* helpers */
00121 struct my_llist {
00122     void *data;
00123     struct my_llist *next;
00124     struct my_llist *prev;
00125 };
00126 
00127 static struct my_llist *my_llist_add(struct my_llist *list, void *data) {
00128     if(!list) { 
00129         list = (struct my_llist *)emalloc(sizeof(*list));
00130         list->data = data;
00131         list->next = list->prev = NULL;
00132         return list;
00133     } else {
00134         struct my_llist *node;
00135         node = (struct my_llist *)emalloc(sizeof(*node));
00136         node->data = data;
00137         node->next = list;
00138         node->prev = NULL;
00139         return node;
00140     }
00141 }
00142 
00143 static struct my_llist *my_llist_del(struct my_llist *list, void *data) {
00144     struct my_llist *ptr = list;
00145     if(!ptr) return NULL;
00146     if(ptr->data == data) { /* special case, first element */
00147         ptr = ptr->next;
00148         efree(list);
00149         return ptr;
00150     }
00151     while(ptr) {
00152         if(data == ptr->data) {
00153             if(ptr->prev) ptr->prev->next = ptr->next;
00154             if(ptr->next) ptr->next->prev = ptr->prev;
00155             efree(ptr);
00156             break;
00157         }
00158         ptr = ptr->next;
00159     }
00160     return list;
00161 }
00162 
00163 /* {{{ db4_functions[]
00164  *
00165  * Every user visible function must have an entry in db4_functions[].
00166  */
00167 function_entry db4_functions[] = {
00168     /* PHP_FE(db4_dbenv_create, NULL) */
00169     {NULL, NULL, NULL}  /* Must be the last line in db4_functions[] */
00170 };
00171 /* }}} */
00172 
00173 PHP_MINIT_FUNCTION(db4);
00174 PHP_MSHUTDOWN_FUNCTION(db4);
00175 PHP_RINIT_FUNCTION(db4);
00176 PHP_RSHUTDOWN_FUNCTION(db4);
00177 PHP_MINFO_FUNCTION(db4);
00178 
00179 /* {{{ db4_module_entry
00180  */
00181 zend_module_entry db4_module_entry = {
00182 #if ZEND_MODULE_API_NO >= 20010901
00183     STANDARD_MODULE_HEADER,
00184 #endif
00185     "db4",
00186     db4_functions,
00187     PHP_MINIT(db4),
00188     PHP_MSHUTDOWN(db4),
00189     NULL,
00190     NULL,
00191     PHP_MINFO(db4),
00192     "0.9", /* Replace with version number for your extension */
00193     STANDARD_MODULE_PROPERTIES
00194 };
00195 /* }}} */
00196 
00197 /* {{{ class entries 
00198  */
00199 
00200 /* {{{ DB4Txn method forward declarations
00201  */
00202 
00203 zend_class_entry *db_txn_ce_get(void)
00204 {
00205     return db_txn_ce;
00206 }
00207 
00208 ZEND_NAMED_FUNCTION(_wrap_db_txn_abort);
00209 ZEND_NAMED_FUNCTION(_wrap_db_txn_commit);
00210 ZEND_NAMED_FUNCTION(_wrap_db_txn_discard);
00211 ZEND_NAMED_FUNCTION(_wrap_db_txn_id);
00212 ZEND_NAMED_FUNCTION(_wrap_db_txn_set_timeout);
00213 ZEND_NAMED_FUNCTION(_wrap_db_txn_set_name);
00214 ZEND_NAMED_FUNCTION(_wrap_db_txn_get_name);
00215 ZEND_NAMED_FUNCTION(_wrap_new_DbTxn);
00216 
00217 static zend_function_entry DbTxn_functions[] = {
00218         ZEND_NAMED_FE(abort, _wrap_db_txn_abort, NULL)
00219         ZEND_NAMED_FE(commit, _wrap_db_txn_commit, NULL)
00220         ZEND_NAMED_FE(discard, _wrap_db_txn_discard, NULL)
00221         ZEND_NAMED_FE(id, _wrap_db_txn_id, NULL)
00222         ZEND_NAMED_FE(set_timeout, _wrap_db_txn_set_timeout, NULL)
00223         ZEND_NAMED_FE(set_name, _wrap_db_txn_set_name, NULL)
00224         ZEND_NAMED_FE(get_name, _wrap_db_txn_get_name, NULL)
00225         ZEND_NAMED_FE(db4txn, _wrap_new_DbTxn, NULL)
00226         { NULL, NULL, NULL}
00227 };
00228 /* }}} */
00229 
00230 /* {{{ DB4Cursor method forward declarations
00231  */
00232 
00233 zend_class_entry *dbc_ce_get(void)
00234 {
00235     return dbc_ce;
00236 }
00237 
00238 ZEND_NAMED_FUNCTION(_wrap_dbc_close);
00239 ZEND_NAMED_FUNCTION(_wrap_dbc_count);
00240 ZEND_NAMED_FUNCTION(_wrap_dbc_del);
00241 ZEND_NAMED_FUNCTION(_wrap_dbc_dup);
00242 ZEND_NAMED_FUNCTION(_wrap_dbc_get);
00243 ZEND_NAMED_FUNCTION(_wrap_dbc_put);
00244 ZEND_NAMED_FUNCTION(_wrap_dbc_pget);
00245 
00246 #ifdef ZEND_ENGINE_2
00247 ZEND_BEGIN_ARG_INFO(first_and_second_args_force_ref, 0)
00248     ZEND_ARG_PASS_INFO(1)
00249     ZEND_ARG_PASS_INFO(1)
00250 ZEND_END_ARG_INFO();
00251 
00252 ZEND_BEGIN_ARG_INFO(first_and_second_and_third_args_force_ref, 0)
00253     ZEND_ARG_PASS_INFO(1)
00254     ZEND_ARG_PASS_INFO(1)
00255 ZEND_END_ARG_INFO();
00256 
00257 #else
00258 static unsigned char first_and_second_args_force_ref[] = {2, BYREF_FORCE, BYREF_FORCE };
00259 static unsigned char first_and_second_and_third_args_force_ref[] = {3, BYREF_FORCE, BYREF_FORCE, BYREF_FORCE };
00260 #endif
00261 
00262 static zend_function_entry Dbc_functions[] = {
00263         ZEND_NAMED_FE(close, _wrap_dbc_close, NULL)
00264         ZEND_NAMED_FE(count, _wrap_dbc_count, NULL)
00265         ZEND_NAMED_FE(del, _wrap_dbc_del, NULL)
00266         ZEND_NAMED_FE(dup, _wrap_dbc_dup, NULL)
00267         ZEND_NAMED_FE(get, _wrap_dbc_get, first_and_second_args_force_ref)
00268         ZEND_NAMED_FE(put, _wrap_dbc_put, NULL)
00269         ZEND_NAMED_FE(pget, _wrap_dbc_pget, first_and_second_and_third_args_force_ref)
00270         { NULL, NULL, NULL}
00271 };
00272 /* }}} */
00273 
00274 /* {{{ DB4Env method forward declarations 
00275  */
00276 
00277 zend_class_entry *db_env_ce_get(void)
00278 {
00279     return db_env_ce;
00280 }
00281 
00282 ZEND_NAMED_FUNCTION(_wrap_new_DbEnv);
00283 ZEND_NAMED_FUNCTION(_wrap_db_env_close);
00284 ZEND_NAMED_FUNCTION(_wrap_db_env_dbremove);
00285 ZEND_NAMED_FUNCTION(_wrap_db_env_dbrename);
00286 ZEND_NAMED_FUNCTION(_wrap_db_env_open);
00287 ZEND_NAMED_FUNCTION(_wrap_db_env_remove);
00288 ZEND_NAMED_FUNCTION(_wrap_db_env_set_data_dir);
00289 ZEND_NAMED_FUNCTION(_wrap_db_env_txn_begin);
00290 ZEND_NAMED_FUNCTION(_wrap_db_env_txn_checkpoint);
00291 
00292 static zend_function_entry DbEnv_functions[] = {
00293         ZEND_NAMED_FE(db4env, _wrap_new_DbEnv, NULL)
00294         ZEND_NAMED_FE(close, _wrap_db_env_close, NULL)
00295         ZEND_NAMED_FE(dbremove, _wrap_db_env_dbremove, NULL)
00296         ZEND_NAMED_FE(dbrename, _wrap_db_env_dbrename, NULL)
00297         ZEND_NAMED_FE(open, _wrap_db_env_open, NULL)
00298         ZEND_NAMED_FE(remove, _wrap_db_env_remove, NULL)
00299         ZEND_NAMED_FE(set_data_dir, _wrap_db_env_set_data_dir, NULL)
00300         ZEND_NAMED_FE(txn_begin, _wrap_db_env_txn_begin, NULL)
00301         ZEND_NAMED_FE(txn_checkpoint, _wrap_db_env_txn_checkpoint, NULL)
00302         { NULL, NULL, NULL}
00303 };
00304 
00305 /* }}} */
00306 
00307 /* {{{ DB4 method forward declarations
00308  */
00309 
00310 zend_class_entry *db_ce_get(void)
00311 {
00312     return db_ce;
00313 }
00314 
00315 ZEND_NAMED_FUNCTION(_wrap_new_db4);
00316 ZEND_NAMED_FUNCTION(_wrap_db_open);
00317 ZEND_NAMED_FUNCTION(_wrap_db_close);
00318 ZEND_NAMED_FUNCTION(_wrap_db_del);
00319 ZEND_NAMED_FUNCTION(_wrap_db_get);
00320 ZEND_NAMED_FUNCTION(_wrap_db_pget);
00321 ZEND_NAMED_FUNCTION(_wrap_db_get_type);
00322 ZEND_NAMED_FUNCTION(_wrap_db_join);
00323 ZEND_NAMED_FUNCTION(_wrap_db_put);
00324 ZEND_NAMED_FUNCTION(_wrap_db_stat);
00325 ZEND_NAMED_FUNCTION(_wrap_db_sync);
00326 ZEND_NAMED_FUNCTION(_wrap_db_truncate);
00327 ZEND_NAMED_FUNCTION(_wrap_db_cursor);
00328 
00329 static zend_function_entry Db4_functions[] = {
00330         ZEND_NAMED_FE(db4, _wrap_new_db4, NULL)
00331         ZEND_NAMED_FE(open, _wrap_db_open, NULL)
00332         ZEND_NAMED_FE(close, _wrap_db_close, NULL)
00333         ZEND_NAMED_FE(del, _wrap_db_del, NULL)
00334         ZEND_NAMED_FE(get, _wrap_db_get, NULL)
00335         ZEND_NAMED_FE(pget, _wrap_db_pget, second_arg_force_ref)
00336         ZEND_NAMED_FE(get_type, _wrap_db_get_type, NULL)
00337         ZEND_NAMED_FE(put, _wrap_db_put, NULL)
00338         ZEND_NAMED_FE(stat, _wrap_db_stat, NULL) 
00339         ZEND_NAMED_FE(sync, _wrap_db_sync, NULL)
00340         ZEND_NAMED_FE(truncate, _wrap_db_truncate, NULL)
00341         ZEND_NAMED_FE(cursor, _wrap_db_cursor, NULL)
00342         ZEND_NAMED_FE(join, _wrap_db_join, NULL)
00343         { NULL, NULL, NULL}
00344 };
00345 /* }}} */
00346 /* }}} */
00347 
00348 #ifdef COMPILE_DL_DB4
00349 BEGIN_EXTERN_C()
00350 ZEND_GET_MODULE(db4)
00351 END_EXTERN_C()
00352 #endif
00353 
00354 /* {{{ PHP_INI
00355  */
00356 /* Remove comments and fill if you need to have entries in php.ini
00357 PHP_INI_BEGIN()
00358 PHP_INI_END()
00359 */
00360 /* }}} */
00361 
00362 /* {{{ php_db4_init_globals
00363  */
00364 /* Uncomment this function if you have INI entries
00365 static void php_db4_init_globals(zend_db4_globals *db4_globals)
00366 {
00367 }
00368 */
00369 /* }}} */
00370 
00371 /* {{{ PHP_MINIT_FUNCTION
00372  */
00373 PHP_MINIT_FUNCTION(db4)
00374 {
00375     /* If you have INI entries, uncomment these lines 
00376     ZEND_INIT_MODULE_GLOBALS(db4, php_db4_init_globals, NULL);
00377     REGISTER_INI_ENTRIES();
00378     */
00379     static zend_class_entry _db_txn_ce;
00380     static zend_class_entry _dbc_ce;
00381     static zend_class_entry _db_ce;
00382     static zend_class_entry _db_env_ce;
00383 
00384     INIT_CLASS_ENTRY(_db_txn_ce, "db4txn", DbTxn_functions);
00385     db_txn_ce = zend_register_internal_class(&_db_txn_ce TSRMLS_CC);
00386 
00387     INIT_CLASS_ENTRY(_dbc_ce, "db4cursor", Dbc_functions);
00388     dbc_ce = zend_register_internal_class(&_dbc_ce TSRMLS_CC);
00389 
00390     INIT_CLASS_ENTRY(_db_ce, "db4", Db4_functions);
00391     db_ce = zend_register_internal_class(&_db_ce TSRMLS_CC);
00392 
00393     INIT_CLASS_ENTRY(_db_env_ce, "db4env", DbEnv_functions);
00394     db_env_ce = zend_register_internal_class(&_db_env_ce TSRMLS_CC);
00395 
00396     le_db_txn = zend_register_list_destructors_ex(_free_php_db_txn, NULL, "Db4Txn", module_number); 
00397     le_dbc = zend_register_list_destructors_ex(_free_php_dbc, NULL, "Db4Cursor", module_number);    
00398     le_db = zend_register_list_destructors_ex(_free_php_db, NULL, "Db4", module_number);    
00399     le_dbenv = zend_register_list_destructors_ex(_free_php_dbenv, NULL, "Db4Env", module_number);   
00400 
00401     REGISTER_LONG_CONSTANT("DB_VERSION_MAJOR", DB_VERSION_MAJOR, CONST_CS | CONST_PERSISTENT);
00402     REGISTER_LONG_CONSTANT("DB_VERSION_MINOR", DB_VERSION_MINOR, CONST_CS | CONST_PERSISTENT);
00403     REGISTER_LONG_CONSTANT("DB_VERSION_PATCH", DB_VERSION_PATCH, CONST_CS | CONST_PERSISTENT);
00404     REGISTER_STRING_CONSTANT("DB_VERSION_STRING", DB_VERSION_STRING, CONST_CS | CONST_PERSISTENT);
00405     REGISTER_LONG_CONSTANT("DB_MAX_PAGES", DB_MAX_PAGES, CONST_CS | CONST_PERSISTENT);
00406     REGISTER_LONG_CONSTANT("DB_MAX_RECORDS", DB_MAX_RECORDS, CONST_CS | CONST_PERSISTENT);
00407     REGISTER_LONG_CONSTANT("DB_DBT_APPMALLOC", DB_DBT_APPMALLOC, CONST_CS | CONST_PERSISTENT);
00408     REGISTER_LONG_CONSTANT("DB_DBT_ISSET", DB_DBT_ISSET, CONST_CS | CONST_PERSISTENT);
00409     REGISTER_LONG_CONSTANT("DB_DBT_MALLOC", DB_DBT_MALLOC, CONST_CS | CONST_PERSISTENT);
00410     REGISTER_LONG_CONSTANT("DB_DBT_PARTIAL", DB_DBT_PARTIAL, CONST_CS | CONST_PERSISTENT);
00411     REGISTER_LONG_CONSTANT("DB_DBT_REALLOC", DB_DBT_REALLOC, CONST_CS | CONST_PERSISTENT);
00412     REGISTER_LONG_CONSTANT("DB_DBT_USERMEM", DB_DBT_USERMEM, CONST_CS | CONST_PERSISTENT);
00413     REGISTER_LONG_CONSTANT("DB_DBT_DUPOK", DB_DBT_DUPOK, CONST_CS | CONST_PERSISTENT);
00414     REGISTER_LONG_CONSTANT("DB_CREATE", DB_CREATE, CONST_CS | CONST_PERSISTENT);
00415     REGISTER_LONG_CONSTANT("DB_CXX_NO_EXCEPTIONS", DB_CXX_NO_EXCEPTIONS, CONST_CS | CONST_PERSISTENT);
00416     REGISTER_LONG_CONSTANT("DB_FORCE", DB_FORCE, CONST_CS | CONST_PERSISTENT);
00417     REGISTER_LONG_CONSTANT("DB_NOMMAP", DB_NOMMAP, CONST_CS | CONST_PERSISTENT);
00418     REGISTER_LONG_CONSTANT("DB_RDONLY", DB_RDONLY, CONST_CS | CONST_PERSISTENT);
00419     REGISTER_LONG_CONSTANT("DB_RECOVER", DB_RECOVER, CONST_CS | CONST_PERSISTENT);
00420     REGISTER_LONG_CONSTANT("DB_THREAD", DB_THREAD, CONST_CS | CONST_PERSISTENT);
00421     REGISTER_LONG_CONSTANT("DB_TRUNCATE", DB_TRUNCATE, CONST_CS | CONST_PERSISTENT);
00422     REGISTER_LONG_CONSTANT("DB_TXN_NOSYNC", DB_TXN_NOSYNC, CONST_CS | CONST_PERSISTENT);
00423     REGISTER_LONG_CONSTANT("DB_TXN_NOT_DURABLE", DB_TXN_NOT_DURABLE, CONST_CS | CONST_PERSISTENT);
00424     REGISTER_LONG_CONSTANT("DB_USE_ENVIRON", DB_USE_ENVIRON, CONST_CS | CONST_PERSISTENT);
00425     REGISTER_LONG_CONSTANT("DB_USE_ENVIRON_ROOT", DB_USE_ENVIRON_ROOT, CONST_CS | CONST_PERSISTENT);
00426     REGISTER_LONG_CONSTANT("DB_AUTO_COMMIT", DB_AUTO_COMMIT, CONST_CS | CONST_PERSISTENT);
00427     REGISTER_LONG_CONSTANT("DB_DIRTY_READ", DB_DIRTY_READ, CONST_CS | CONST_PERSISTENT);
00428     REGISTER_LONG_CONSTANT("DB_NO_AUTO_COMMIT", DB_NO_AUTO_COMMIT, CONST_CS | CONST_PERSISTENT);
00429     REGISTER_LONG_CONSTANT("DB_RPCCLIENT", DB_RPCCLIENT, CONST_CS | CONST_PERSISTENT);
00430     REGISTER_LONG_CONSTANT("DB_XA_CREATE", DB_XA_CREATE, CONST_CS | CONST_PERSISTENT);
00431     REGISTER_LONG_CONSTANT("DB_INIT_CDB", DB_INIT_CDB, CONST_CS | CONST_PERSISTENT);
00432     REGISTER_LONG_CONSTANT("DB_INIT_LOCK", DB_INIT_LOCK, CONST_CS | CONST_PERSISTENT);
00433     REGISTER_LONG_CONSTANT("DB_INIT_LOG", DB_INIT_LOG, CONST_CS | CONST_PERSISTENT);
00434     REGISTER_LONG_CONSTANT("DB_INIT_MPOOL", DB_INIT_MPOOL, CONST_CS | CONST_PERSISTENT);
00435     REGISTER_LONG_CONSTANT("DB_INIT_REP", DB_INIT_REP, CONST_CS | CONST_PERSISTENT);
00436     REGISTER_LONG_CONSTANT("DB_INIT_TXN", DB_INIT_TXN, CONST_CS | CONST_PERSISTENT);
00437     REGISTER_LONG_CONSTANT("DB_JOINENV", DB_JOINENV, CONST_CS | CONST_PERSISTENT);
00438     REGISTER_LONG_CONSTANT("DB_LOCKDOWN", DB_LOCKDOWN, CONST_CS | CONST_PERSISTENT);
00439     REGISTER_LONG_CONSTANT("DB_PRIVATE", DB_PRIVATE, CONST_CS | CONST_PERSISTENT);
00440     REGISTER_LONG_CONSTANT("DB_RECOVER_FATAL", DB_RECOVER_FATAL, CONST_CS | CONST_PERSISTENT);
00441     REGISTER_LONG_CONSTANT("DB_SYSTEM_MEM", DB_SYSTEM_MEM, CONST_CS | CONST_PERSISTENT);
00442     REGISTER_LONG_CONSTANT("DB_EXCL", DB_EXCL, CONST_CS | CONST_PERSISTENT);
00443     REGISTER_LONG_CONSTANT("DB_FCNTL_LOCKING", DB_FCNTL_LOCKING, CONST_CS | CONST_PERSISTENT);
00444     REGISTER_LONG_CONSTANT("DB_RDWRMASTER", DB_RDWRMASTER, CONST_CS | CONST_PERSISTENT);
00445     REGISTER_LONG_CONSTANT("DB_WRITEOPEN", DB_WRITEOPEN, CONST_CS | CONST_PERSISTENT);
00446     REGISTER_LONG_CONSTANT("DB_TXN_NOWAIT", DB_TXN_NOWAIT, CONST_CS | CONST_PERSISTENT);
00447     REGISTER_LONG_CONSTANT("DB_TXN_SYNC", DB_TXN_SYNC, CONST_CS | CONST_PERSISTENT);
00448     REGISTER_LONG_CONSTANT("DB_ENCRYPT_AES", DB_ENCRYPT_AES, CONST_CS | CONST_PERSISTENT);
00449     REGISTER_LONG_CONSTANT("DB_CDB_ALLDB", DB_CDB_ALLDB, CONST_CS | CONST_PERSISTENT);
00450     REGISTER_LONG_CONSTANT("DB_DIRECT_DB", DB_DIRECT_DB, CONST_CS | CONST_PERSISTENT);
00451     REGISTER_LONG_CONSTANT("DB_DIRECT_LOG", DB_DIRECT_LOG, CONST_CS | CONST_PERSISTENT);
00452     REGISTER_LONG_CONSTANT("DB_LOG_AUTOREMOVE", DB_LOG_AUTOREMOVE, CONST_CS | CONST_PERSISTENT);
00453     REGISTER_LONG_CONSTANT("DB_NOLOCKING", DB_NOLOCKING, CONST_CS | CONST_PERSISTENT);
00454     REGISTER_LONG_CONSTANT("DB_NOPANIC", DB_NOPANIC, CONST_CS | CONST_PERSISTENT);
00455     REGISTER_LONG_CONSTANT("DB_OVERWRITE", DB_OVERWRITE, CONST_CS | CONST_PERSISTENT);
00456     REGISTER_LONG_CONSTANT("DB_PANIC_ENVIRONMENT", DB_PANIC_ENVIRONMENT, CONST_CS | CONST_PERSISTENT);
00457     REGISTER_LONG_CONSTANT("DB_REGION_INIT", DB_REGION_INIT, CONST_CS | CONST_PERSISTENT);
00458     REGISTER_LONG_CONSTANT("DB_TIME_NOTGRANTED", DB_TIME_NOTGRANTED, CONST_CS | CONST_PERSISTENT);
00459     REGISTER_LONG_CONSTANT("DB_TXN_WRITE_NOSYNC", DB_TXN_WRITE_NOSYNC, CONST_CS | CONST_PERSISTENT);
00460     REGISTER_LONG_CONSTANT("DB_YIELDCPU", DB_YIELDCPU, CONST_CS | CONST_PERSISTENT);
00461     REGISTER_LONG_CONSTANT("DB_UPGRADE", DB_UPGRADE, CONST_CS | CONST_PERSISTENT);
00462     REGISTER_LONG_CONSTANT("DB_VERIFY", DB_VERIFY, CONST_CS | CONST_PERSISTENT);
00463     REGISTER_LONG_CONSTANT("DB_DIRECT", DB_DIRECT, CONST_CS | CONST_PERSISTENT);
00464     REGISTER_LONG_CONSTANT("DB_EXTENT", DB_EXTENT, CONST_CS | CONST_PERSISTENT);
00465     REGISTER_LONG_CONSTANT("DB_ODDFILESIZE", DB_ODDFILESIZE, CONST_CS | CONST_PERSISTENT);
00466     REGISTER_LONG_CONSTANT("DB_CHKSUM", DB_CHKSUM, CONST_CS | CONST_PERSISTENT);
00467     REGISTER_LONG_CONSTANT("DB_DUP", DB_DUP, CONST_CS | CONST_PERSISTENT);
00468     REGISTER_LONG_CONSTANT("DB_DUPSORT", DB_DUPSORT, CONST_CS | CONST_PERSISTENT);
00469     REGISTER_LONG_CONSTANT("DB_ENCRYPT", DB_ENCRYPT, CONST_CS | CONST_PERSISTENT);
00470     REGISTER_LONG_CONSTANT("DB_RECNUM", DB_RECNUM, CONST_CS | CONST_PERSISTENT);
00471     REGISTER_LONG_CONSTANT("DB_RENUMBER", DB_RENUMBER, CONST_CS | CONST_PERSISTENT);
00472     REGISTER_LONG_CONSTANT("DB_REVSPLITOFF", DB_REVSPLITOFF, CONST_CS | CONST_PERSISTENT);
00473     REGISTER_LONG_CONSTANT("DB_SNAPSHOT", DB_SNAPSHOT, CONST_CS | CONST_PERSISTENT);
00474     REGISTER_LONG_CONSTANT("DB_STAT_CLEAR", DB_STAT_CLEAR, CONST_CS | CONST_PERSISTENT);
00475     REGISTER_LONG_CONSTANT("DB_JOIN_NOSORT", DB_JOIN_NOSORT, CONST_CS | CONST_PERSISTENT);
00476     REGISTER_LONG_CONSTANT("DB_AGGRESSIVE", DB_AGGRESSIVE, CONST_CS | CONST_PERSISTENT);
00477     REGISTER_LONG_CONSTANT("DB_NOORDERCHK", DB_NOORDERCHK, CONST_CS | CONST_PERSISTENT);
00478     REGISTER_LONG_CONSTANT("DB_ORDERCHKONLY", DB_ORDERCHKONLY, CONST_CS | CONST_PERSISTENT);
00479     REGISTER_LONG_CONSTANT("DB_PR_PAGE", DB_PR_PAGE, CONST_CS | CONST_PERSISTENT);
00480     REGISTER_LONG_CONSTANT("DB_PR_RECOVERYTEST", DB_PR_RECOVERYTEST, CONST_CS | CONST_PERSISTENT);
00481     REGISTER_LONG_CONSTANT("DB_PRINTABLE", DB_PRINTABLE, CONST_CS | CONST_PERSISTENT);
00482     REGISTER_LONG_CONSTANT("DB_SALVAGE", DB_SALVAGE, CONST_CS | CONST_PERSISTENT);
00483     REGISTER_LONG_CONSTANT("DB_REP_NOBUFFER", DB_REP_NOBUFFER, CONST_CS | CONST_PERSISTENT);
00484     REGISTER_LONG_CONSTANT("DB_REP_PERMANENT", DB_REP_PERMANENT, CONST_CS | CONST_PERSISTENT);
00485     REGISTER_LONG_CONSTANT("DB_LOCKVERSION", DB_LOCKVERSION, CONST_CS | CONST_PERSISTENT);
00486     REGISTER_LONG_CONSTANT("DB_FILE_ID_LEN", DB_FILE_ID_LEN, CONST_CS | CONST_PERSISTENT);
00487     REGISTER_LONG_CONSTANT("DB_LOCK_NORUN", DB_LOCK_NORUN, CONST_CS | CONST_PERSISTENT);
00488     REGISTER_LONG_CONSTANT("DB_LOCK_DEFAULT", DB_LOCK_DEFAULT, CONST_CS | CONST_PERSISTENT);
00489     REGISTER_LONG_CONSTANT("DB_LOCK_EXPIRE", DB_LOCK_EXPIRE, CONST_CS | CONST_PERSISTENT);
00490     REGISTER_LONG_CONSTANT("DB_LOCK_MAXLOCKS", DB_LOCK_MAXLOCKS, CONST_CS | CONST_PERSISTENT);
00491     REGISTER_LONG_CONSTANT("DB_LOCK_MINLOCKS", DB_LOCK_MINLOCKS, CONST_CS | CONST_PERSISTENT);
00492     REGISTER_LONG_CONSTANT("DB_LOCK_MINWRITE", DB_LOCK_MINWRITE, CONST_CS | CONST_PERSISTENT);
00493     REGISTER_LONG_CONSTANT("DB_LOCK_OLDEST", DB_LOCK_OLDEST, CONST_CS | CONST_PERSISTENT);
00494     REGISTER_LONG_CONSTANT("DB_LOCK_RANDOM", DB_LOCK_RANDOM, CONST_CS | CONST_PERSISTENT);
00495     REGISTER_LONG_CONSTANT("DB_LOCK_YOUNGEST", DB_LOCK_YOUNGEST, CONST_CS | CONST_PERSISTENT);
00496     REGISTER_LONG_CONSTANT("DB_LOCK_NOWAIT", DB_LOCK_NOWAIT, CONST_CS | CONST_PERSISTENT);
00497     REGISTER_LONG_CONSTANT("DB_LOCK_RECORD", DB_LOCK_RECORD, CONST_CS | CONST_PERSISTENT);
00498     REGISTER_LONG_CONSTANT("DB_LOCK_SET_TIMEOUT", DB_LOCK_SET_TIMEOUT, CONST_CS | CONST_PERSISTENT);
00499     REGISTER_LONG_CONSTANT("DB_LOCK_SWITCH", DB_LOCK_SWITCH, CONST_CS | CONST_PERSISTENT);
00500     REGISTER_LONG_CONSTANT("DB_LOCK_UPGRADE", DB_LOCK_UPGRADE, CONST_CS | CONST_PERSISTENT);
00501     REGISTER_LONG_CONSTANT("DB_HANDLE_LOCK", DB_HANDLE_LOCK, CONST_CS | CONST_PERSISTENT);
00502     REGISTER_LONG_CONSTANT("DB_RECORD_LOCK", DB_RECORD_LOCK, CONST_CS | CONST_PERSISTENT);
00503     REGISTER_LONG_CONSTANT("DB_PAGE_LOCK", DB_PAGE_LOCK, CONST_CS | CONST_PERSISTENT);
00504     REGISTER_LONG_CONSTANT("DB_LOGVERSION", DB_LOGVERSION, CONST_CS | CONST_PERSISTENT);
00505     REGISTER_LONG_CONSTANT("DB_LOGOLDVER", DB_LOGOLDVER, CONST_CS | CONST_PERSISTENT);
00506     REGISTER_LONG_CONSTANT("DB_LOGMAGIC", DB_LOGMAGIC, CONST_CS | CONST_PERSISTENT);
00507     REGISTER_LONG_CONSTANT("DB_ARCH_ABS", DB_ARCH_ABS, CONST_CS | CONST_PERSISTENT);
00508     REGISTER_LONG_CONSTANT("DB_ARCH_DATA", DB_ARCH_DATA, CONST_CS | CONST_PERSISTENT);
00509     REGISTER_LONG_CONSTANT("DB_ARCH_LOG", DB_ARCH_LOG, CONST_CS | CONST_PERSISTENT);
00510     REGISTER_LONG_CONSTANT("DB_ARCH_REMOVE", DB_ARCH_REMOVE, CONST_CS | CONST_PERSISTENT);
00511     REGISTER_LONG_CONSTANT("DB_FLUSH", DB_FLUSH, CONST_CS | CONST_PERSISTENT);
00512     REGISTER_LONG_CONSTANT("DB_LOG_CHKPNT", DB_LOG_CHKPNT, CONST_CS | CONST_PERSISTENT);
00513     REGISTER_LONG_CONSTANT("DB_LOG_COMMIT", DB_LOG_COMMIT, CONST_CS | CONST_PERSISTENT);
00514     REGISTER_LONG_CONSTANT("DB_LOG_NOCOPY", DB_LOG_NOCOPY, CONST_CS | CONST_PERSISTENT);
00515     REGISTER_LONG_CONSTANT("DB_LOG_NOT_DURABLE", DB_LOG_NOT_DURABLE, CONST_CS | CONST_PERSISTENT);
00516     REGISTER_LONG_CONSTANT("DB_LOG_PERM", DB_LOG_PERM, CONST_CS | CONST_PERSISTENT);
00517     REGISTER_LONG_CONSTANT("DB_LOG_WRNOSYNC", DB_LOG_WRNOSYNC, CONST_CS | CONST_PERSISTENT);
00518     REGISTER_LONG_CONSTANT("DB_user_BEGIN", DB_user_BEGIN, CONST_CS | CONST_PERSISTENT);
00519     REGISTER_LONG_CONSTANT("DB_debug_FLAG", DB_debug_FLAG, CONST_CS | CONST_PERSISTENT);
00520     REGISTER_LONG_CONSTANT("DB_LOGC_BUF_SIZE", DB_LOGC_BUF_SIZE, CONST_CS | CONST_PERSISTENT);
00521     REGISTER_LONG_CONSTANT("DB_LOG_DISK", DB_LOG_DISK, CONST_CS | CONST_PERSISTENT);
00522     REGISTER_LONG_CONSTANT("DB_LOG_LOCKED", DB_LOG_LOCKED, CONST_CS | CONST_PERSISTENT);
00523     REGISTER_LONG_CONSTANT("DB_LOG_SILENT_ERR", DB_LOG_SILENT_ERR, CONST_CS | CONST_PERSISTENT);
00524     REGISTER_LONG_CONSTANT("DB_MPOOL_CREATE", DB_MPOOL_CREATE, CONST_CS | CONST_PERSISTENT);
00525     REGISTER_LONG_CONSTANT("DB_MPOOL_LAST", DB_MPOOL_LAST, CONST_CS | CONST_PERSISTENT);
00526     REGISTER_LONG_CONSTANT("DB_MPOOL_NEW", DB_MPOOL_NEW, CONST_CS | CONST_PERSISTENT);
00527     REGISTER_LONG_CONSTANT("DB_MPOOL_CLEAN", DB_MPOOL_CLEAN, CONST_CS | CONST_PERSISTENT);
00528     REGISTER_LONG_CONSTANT("DB_MPOOL_DIRTY", DB_MPOOL_DIRTY, CONST_CS | CONST_PERSISTENT);
00529     REGISTER_LONG_CONSTANT("DB_MPOOL_DISCARD", DB_MPOOL_DISCARD, CONST_CS | CONST_PERSISTENT);
00530     REGISTER_LONG_CONSTANT("DB_MPOOL_NOFILE", DB_MPOOL_NOFILE, CONST_CS | CONST_PERSISTENT);
00531     REGISTER_LONG_CONSTANT("DB_MPOOL_UNLINK", DB_MPOOL_UNLINK, CONST_CS | CONST_PERSISTENT);
00532     REGISTER_LONG_CONSTANT("DB_TXNVERSION", DB_TXNVERSION, CONST_CS | CONST_PERSISTENT);
00533     REGISTER_LONG_CONSTANT("DB_XIDDATASIZE", DB_XIDDATASIZE, CONST_CS | CONST_PERSISTENT);
00534     REGISTER_LONG_CONSTANT("DB_EID_BROADCAST", DB_EID_BROADCAST, CONST_CS | CONST_PERSISTENT);
00535     REGISTER_LONG_CONSTANT("DB_EID_INVALID", DB_EID_INVALID, CONST_CS | CONST_PERSISTENT);
00536     REGISTER_LONG_CONSTANT("DB_REP_CLIENT", DB_REP_CLIENT, CONST_CS | CONST_PERSISTENT);
00537     REGISTER_LONG_CONSTANT("DB_REP_MASTER", DB_REP_MASTER, CONST_CS | CONST_PERSISTENT);
00538     REGISTER_LONG_CONSTANT("DB_RENAMEMAGIC", DB_RENAMEMAGIC, CONST_CS | CONST_PERSISTENT);
00539     REGISTER_LONG_CONSTANT("DB_BTREEVERSION", DB_BTREEVERSION, CONST_CS | CONST_PERSISTENT);
00540     REGISTER_LONG_CONSTANT("DB_BTREEOLDVER", DB_BTREEOLDVER, CONST_CS | CONST_PERSISTENT);
00541     REGISTER_LONG_CONSTANT("DB_BTREEMAGIC", DB_BTREEMAGIC, CONST_CS | CONST_PERSISTENT);
00542     REGISTER_LONG_CONSTANT("DB_HASHVERSION", DB_HASHVERSION, CONST_CS | CONST_PERSISTENT);
00543     REGISTER_LONG_CONSTANT("DB_HASHOLDVER", DB_HASHOLDVER, CONST_CS | CONST_PERSISTENT);
00544     REGISTER_LONG_CONSTANT("DB_HASHMAGIC", DB_HASHMAGIC, CONST_CS | CONST_PERSISTENT);
00545     REGISTER_LONG_CONSTANT("DB_QAMVERSION", DB_QAMVERSION, CONST_CS | CONST_PERSISTENT);
00546     REGISTER_LONG_CONSTANT("DB_QAMOLDVER", DB_QAMOLDVER, CONST_CS | CONST_PERSISTENT);
00547     REGISTER_LONG_CONSTANT("DB_QAMMAGIC", DB_QAMMAGIC, CONST_CS | CONST_PERSISTENT);
00548     REGISTER_LONG_CONSTANT("DB_AFTER", DB_AFTER, CONST_CS | CONST_PERSISTENT);
00549     REGISTER_LONG_CONSTANT("DB_APPEND", DB_APPEND, CONST_CS | CONST_PERSISTENT);
00550     REGISTER_LONG_CONSTANT("DB_BEFORE", DB_BEFORE, CONST_CS | CONST_PERSISTENT);
00551     REGISTER_LONG_CONSTANT("DB_CACHED_COUNTS", DB_CACHED_COUNTS, CONST_CS | CONST_PERSISTENT);
00552     REGISTER_LONG_CONSTANT("DB_CONSUME", DB_CONSUME, CONST_CS | CONST_PERSISTENT);
00553     REGISTER_LONG_CONSTANT("DB_CONSUME_WAIT", DB_CONSUME_WAIT, CONST_CS | CONST_PERSISTENT);
00554     REGISTER_LONG_CONSTANT("DB_CURRENT", DB_CURRENT, CONST_CS | CONST_PERSISTENT);
00555     REGISTER_LONG_CONSTANT("DB_FAST_STAT", DB_FAST_STAT, CONST_CS | CONST_PERSISTENT);
00556     REGISTER_LONG_CONSTANT("DB_FIRST", DB_FIRST, CONST_CS | CONST_PERSISTENT);
00557     REGISTER_LONG_CONSTANT("DB_GET_BOTH", DB_GET_BOTH, CONST_CS | CONST_PERSISTENT);
00558     REGISTER_LONG_CONSTANT("DB_GET_BOTHC", DB_GET_BOTHC, CONST_CS | CONST_PERSISTENT);
00559     REGISTER_LONG_CONSTANT("DB_GET_BOTH_RANGE", DB_GET_BOTH_RANGE, CONST_CS | CONST_PERSISTENT);
00560     REGISTER_LONG_CONSTANT("DB_GET_RECNO", DB_GET_RECNO, CONST_CS | CONST_PERSISTENT);
00561     REGISTER_LONG_CONSTANT("DB_JOIN_ITEM", DB_JOIN_ITEM, CONST_CS | CONST_PERSISTENT);
00562     REGISTER_LONG_CONSTANT("DB_KEYFIRST", DB_KEYFIRST, CONST_CS | CONST_PERSISTENT);
00563     REGISTER_LONG_CONSTANT("DB_KEYLAST", DB_KEYLAST, CONST_CS | CONST_PERSISTENT);
00564     REGISTER_LONG_CONSTANT("DB_LAST", DB_LAST, CONST_CS | CONST_PERSISTENT);
00565     REGISTER_LONG_CONSTANT("DB_NEXT", DB_NEXT, CONST_CS | CONST_PERSISTENT);
00566     REGISTER_LONG_CONSTANT("DB_NEXT_DUP", DB_NEXT_DUP, CONST_CS | CONST_PERSISTENT);
00567     REGISTER_LONG_CONSTANT("DB_NEXT_NODUP", DB_NEXT_NODUP, CONST_CS | CONST_PERSISTENT);
00568     REGISTER_LONG_CONSTANT("DB_NODUPDATA", DB_NODUPDATA, CONST_CS | CONST_PERSISTENT);
00569     REGISTER_LONG_CONSTANT("DB_NOOVERWRITE", DB_NOOVERWRITE, CONST_CS | CONST_PERSISTENT);
00570     REGISTER_LONG_CONSTANT("DB_NOSYNC", DB_NOSYNC, CONST_CS | CONST_PERSISTENT);
00571     REGISTER_LONG_CONSTANT("DB_POSITION", DB_POSITION, CONST_CS | CONST_PERSISTENT);
00572     REGISTER_LONG_CONSTANT("DB_PREV", DB_PREV, CONST_CS | CONST_PERSISTENT);
00573     REGISTER_LONG_CONSTANT("DB_PREV_NODUP", DB_PREV_NODUP, CONST_CS | CONST_PERSISTENT);
00574     REGISTER_LONG_CONSTANT("DB_RECORDCOUNT", DB_RECORDCOUNT, CONST_CS | CONST_PERSISTENT);
00575     REGISTER_LONG_CONSTANT("DB_SET", DB_SET, CONST_CS | CONST_PERSISTENT);
00576     REGISTER_LONG_CONSTANT("DB_SET_LOCK_TIMEOUT", DB_SET_LOCK_TIMEOUT, CONST_CS | CONST_PERSISTENT);
00577     REGISTER_LONG_CONSTANT("DB_SET_RANGE", DB_SET_RANGE, CONST_CS | CONST_PERSISTENT);
00578     REGISTER_LONG_CONSTANT("DB_SET_RECNO", DB_SET_RECNO, CONST_CS | CONST_PERSISTENT);
00579     REGISTER_LONG_CONSTANT("DB_SET_TXN_NOW", DB_SET_TXN_NOW, CONST_CS | CONST_PERSISTENT);
00580     REGISTER_LONG_CONSTANT("DB_SET_TXN_TIMEOUT", DB_SET_TXN_TIMEOUT, CONST_CS | CONST_PERSISTENT);
00581     REGISTER_LONG_CONSTANT("DB_UPDATE_SECONDARY", DB_UPDATE_SECONDARY, CONST_CS | CONST_PERSISTENT);
00582     REGISTER_LONG_CONSTANT("DB_WRITECURSOR", DB_WRITECURSOR, CONST_CS | CONST_PERSISTENT);
00583     REGISTER_LONG_CONSTANT("DB_WRITELOCK", DB_WRITELOCK, CONST_CS | CONST_PERSISTENT);
00584     REGISTER_LONG_CONSTANT("DB_OPFLAGS_MASK", DB_OPFLAGS_MASK, CONST_CS | CONST_PERSISTENT);
00585     REGISTER_LONG_CONSTANT("DB_MULTIPLE", DB_MULTIPLE, CONST_CS | CONST_PERSISTENT);
00586     REGISTER_LONG_CONSTANT("DB_MULTIPLE_KEY", DB_MULTIPLE_KEY, CONST_CS | CONST_PERSISTENT);
00587     REGISTER_LONG_CONSTANT("DB_RMW", DB_RMW, CONST_CS | CONST_PERSISTENT);
00588     REGISTER_LONG_CONSTANT("DB_DONOTINDEX", DB_DONOTINDEX, CONST_CS | CONST_PERSISTENT);
00589     REGISTER_LONG_CONSTANT("DB_KEYEMPTY", DB_KEYEMPTY, CONST_CS | CONST_PERSISTENT);
00590     REGISTER_LONG_CONSTANT("DB_KEYEXIST", DB_KEYEXIST, CONST_CS | CONST_PERSISTENT);
00591     REGISTER_LONG_CONSTANT("DB_LOCK_DEADLOCK", DB_LOCK_DEADLOCK, CONST_CS | CONST_PERSISTENT);
00592     REGISTER_LONG_CONSTANT("DB_LOCK_NOTGRANTED", DB_LOCK_NOTGRANTED, CONST_CS | CONST_PERSISTENT);
00593     REGISTER_LONG_CONSTANT("DB_NOSERVER", DB_NOSERVER, CONST_CS | CONST_PERSISTENT);
00594     REGISTER_LONG_CONSTANT("DB_NOSERVER_HOME", DB_NOSERVER_HOME, CONST_CS | CONST_PERSISTENT);
00595     REGISTER_LONG_CONSTANT("DB_NOSERVER_ID", DB_NOSERVER_ID, CONST_CS | CONST_PERSISTENT);
00596     REGISTER_LONG_CONSTANT("DB_NOTFOUND", DB_NOTFOUND, CONST_CS | CONST_PERSISTENT);
00597     REGISTER_LONG_CONSTANT("DB_OLD_VERSION", DB_OLD_VERSION, CONST_CS | CONST_PERSISTENT);
00598     REGISTER_LONG_CONSTANT("DB_PAGE_NOTFOUND", DB_PAGE_NOTFOUND, CONST_CS | CONST_PERSISTENT);
00599     REGISTER_LONG_CONSTANT("DB_REP_DUPMASTER", DB_REP_DUPMASTER, CONST_CS | CONST_PERSISTENT);
00600     REGISTER_LONG_CONSTANT("DB_REP_HANDLE_DEAD", DB_REP_HANDLE_DEAD, CONST_CS | CONST_PERSISTENT);
00601     REGISTER_LONG_CONSTANT("DB_REP_HOLDELECTION", DB_REP_HOLDELECTION, CONST_CS | CONST_PERSISTENT);
00602     REGISTER_LONG_CONSTANT("DB_REP_ISPERM", DB_REP_ISPERM, CONST_CS | CONST_PERSISTENT);
00603     REGISTER_LONG_CONSTANT("DB_REP_NEWMASTER", DB_REP_NEWMASTER, CONST_CS | CONST_PERSISTENT);
00604     REGISTER_LONG_CONSTANT("DB_REP_NEWSITE", DB_REP_NEWSITE, CONST_CS | CONST_PERSISTENT);
00605     REGISTER_LONG_CONSTANT("DB_REP_NOTPERM", DB_REP_NOTPERM, CONST_CS | CONST_PERSISTENT);
00606     REGISTER_LONG_CONSTANT("DB_REP_UNAVAIL", DB_REP_UNAVAIL, CONST_CS | CONST_PERSISTENT);
00607     REGISTER_LONG_CONSTANT("DB_RUNRECOVERY", DB_RUNRECOVERY, CONST_CS | CONST_PERSISTENT);
00608     REGISTER_LONG_CONSTANT("DB_SECONDARY_BAD", DB_SECONDARY_BAD, CONST_CS | CONST_PERSISTENT);
00609     REGISTER_LONG_CONSTANT("DB_VERIFY_BAD", DB_VERIFY_BAD, CONST_CS | CONST_PERSISTENT);
00610     REGISTER_LONG_CONSTANT("DB_ALREADY_ABORTED", DB_ALREADY_ABORTED, CONST_CS | CONST_PERSISTENT);
00611     REGISTER_LONG_CONSTANT("DB_DELETED", DB_DELETED, CONST_CS | CONST_PERSISTENT);
00612     REGISTER_LONG_CONSTANT("DB_NEEDSPLIT", DB_NEEDSPLIT, CONST_CS | CONST_PERSISTENT);
00613     REGISTER_LONG_CONSTANT("DB_SURPRISE_KID", DB_SURPRISE_KID, CONST_CS | CONST_PERSISTENT);
00614     REGISTER_LONG_CONSTANT("DB_SWAPBYTES", DB_SWAPBYTES, CONST_CS | CONST_PERSISTENT);
00615     REGISTER_LONG_CONSTANT("DB_TIMEOUT", DB_TIMEOUT, CONST_CS | CONST_PERSISTENT);
00616     REGISTER_LONG_CONSTANT("DB_TXN_CKP", DB_TXN_CKP, CONST_CS | CONST_PERSISTENT);
00617     REGISTER_LONG_CONSTANT("DB_VERIFY_FATAL", DB_VERIFY_FATAL, CONST_CS | CONST_PERSISTENT);
00618     REGISTER_LONG_CONSTANT("DB_LOGFILEID_INVALID", DB_LOGFILEID_INVALID, CONST_CS | CONST_PERSISTENT);
00619     REGISTER_LONG_CONSTANT("DB_OK_BTREE", DB_OK_BTREE, CONST_CS | CONST_PERSISTENT);
00620     REGISTER_LONG_CONSTANT("DB_OK_HASH", DB_OK_HASH, CONST_CS | CONST_PERSISTENT);
00621     REGISTER_LONG_CONSTANT("DB_OK_QUEUE", DB_OK_QUEUE, CONST_CS | CONST_PERSISTENT);
00622     REGISTER_LONG_CONSTANT("DB_OK_RECNO", DB_OK_RECNO, CONST_CS | CONST_PERSISTENT);
00623     REGISTER_LONG_CONSTANT("DB_AM_CHKSUM", DB_AM_CHKSUM, CONST_CS | CONST_PERSISTENT);
00624     REGISTER_LONG_CONSTANT("DB_AM_CL_WRITER", DB_AM_CL_WRITER, CONST_CS | CONST_PERSISTENT);
00625     REGISTER_LONG_CONSTANT("DB_AM_COMPENSATE", DB_AM_COMPENSATE, CONST_CS | CONST_PERSISTENT);
00626     REGISTER_LONG_CONSTANT("DB_AM_CREATED", DB_AM_CREATED, CONST_CS | CONST_PERSISTENT);
00627     REGISTER_LONG_CONSTANT("DB_AM_CREATED_MSTR", DB_AM_CREATED_MSTR, CONST_CS | CONST_PERSISTENT);
00628     REGISTER_LONG_CONSTANT("DB_AM_DBM_ERROR", DB_AM_DBM_ERROR, CONST_CS | CONST_PERSISTENT);
00629     REGISTER_LONG_CONSTANT("DB_AM_DELIMITER", DB_AM_DELIMITER, CONST_CS | CONST_PERSISTENT);
00630     REGISTER_LONG_CONSTANT("DB_AM_DISCARD", DB_AM_DISCARD, CONST_CS | CONST_PERSISTENT);
00631     REGISTER_LONG_CONSTANT("DB_AM_DUP", DB_AM_DUP, CONST_CS | CONST_PERSISTENT);
00632     REGISTER_LONG_CONSTANT("DB_AM_DUPSORT", DB_AM_DUPSORT, CONST_CS | CONST_PERSISTENT);
00633     REGISTER_LONG_CONSTANT("DB_AM_ENCRYPT", DB_AM_ENCRYPT, CONST_CS | CONST_PERSISTENT);
00634     REGISTER_LONG_CONSTANT("DB_AM_FIXEDLEN", DB_AM_FIXEDLEN, CONST_CS | CONST_PERSISTENT);
00635     REGISTER_LONG_CONSTANT("DB_AM_INMEM", DB_AM_INMEM, CONST_CS | CONST_PERSISTENT);
00636     REGISTER_LONG_CONSTANT("DB_AM_IN_RENAME", DB_AM_IN_RENAME, CONST_CS | CONST_PERSISTENT);
00637     REGISTER_LONG_CONSTANT("DB_AM_NOT_DURABLE", DB_AM_NOT_DURABLE, CONST_CS | CONST_PERSISTENT);
00638     REGISTER_LONG_CONSTANT("DB_AM_OPEN_CALLED", DB_AM_OPEN_CALLED, CONST_CS | CONST_PERSISTENT);
00639     REGISTER_LONG_CONSTANT("DB_AM_PAD", DB_AM_PAD, CONST_CS | CONST_PERSISTENT);
00640     REGISTER_LONG_CONSTANT("DB_AM_PGDEF", DB_AM_PGDEF, CONST_CS | CONST_PERSISTENT);
00641     REGISTER_LONG_CONSTANT("DB_AM_RDONLY", DB_AM_RDONLY, CONST_CS | CONST_PERSISTENT);
00642     REGISTER_LONG_CONSTANT("DB_AM_RECNUM", DB_AM_RECNUM, CONST_CS | CONST_PERSISTENT);
00643     REGISTER_LONG_CONSTANT("DB_AM_RECOVER", DB_AM_RECOVER, CONST_CS | CONST_PERSISTENT);
00644     REGISTER_LONG_CONSTANT("DB_AM_RENUMBER", DB_AM_RENUMBER, CONST_CS | CONST_PERSISTENT);
00645     REGISTER_LONG_CONSTANT("DB_AM_REVSPLITOFF", DB_AM_REVSPLITOFF, CONST_CS | CONST_PERSISTENT);
00646     REGISTER_LONG_CONSTANT("DB_AM_SECONDARY", DB_AM_SECONDARY, CONST_CS | CONST_PERSISTENT);
00647     REGISTER_LONG_CONSTANT("DB_AM_SNAPSHOT", DB_AM_SNAPSHOT, CONST_CS | CONST_PERSISTENT);
00648     REGISTER_LONG_CONSTANT("DB_AM_SUBDB", DB_AM_SUBDB, CONST_CS | CONST_PERSISTENT);
00649     REGISTER_LONG_CONSTANT("DB_AM_SWAP", DB_AM_SWAP, CONST_CS | CONST_PERSISTENT);
00650     REGISTER_LONG_CONSTANT("DB_AM_TXN", DB_AM_TXN, CONST_CS | CONST_PERSISTENT);
00651     REGISTER_LONG_CONSTANT("DB_AM_VERIFYING", DB_AM_VERIFYING, CONST_CS | CONST_PERSISTENT);
00652     REGISTER_LONG_CONSTANT("DB_REGION_MAGIC", DB_REGION_MAGIC, CONST_CS | CONST_PERSISTENT);
00653     REGISTER_LONG_CONSTANT("DB_VERB_DEADLOCK", DB_VERB_DEADLOCK, CONST_CS | CONST_PERSISTENT);
00654     REGISTER_LONG_CONSTANT("DB_VERB_RECOVERY", DB_VERB_RECOVERY, CONST_CS | CONST_PERSISTENT);
00655     REGISTER_LONG_CONSTANT("DB_VERB_REPLICATION", DB_VERB_REPLICATION, CONST_CS | CONST_PERSISTENT);
00656     REGISTER_LONG_CONSTANT("DB_VERB_WAITSFOR", DB_VERB_WAITSFOR, CONST_CS | CONST_PERSISTENT);
00657     REGISTER_LONG_CONSTANT("DB_TEST_ELECTINIT", DB_TEST_ELECTINIT, CONST_CS | CONST_PERSISTENT);
00658     REGISTER_LONG_CONSTANT("DB_TEST_POSTDESTROY", DB_TEST_POSTDESTROY, CONST_CS | CONST_PERSISTENT);
00659     REGISTER_LONG_CONSTANT("DB_TEST_POSTLOG", DB_TEST_POSTLOG, CONST_CS | CONST_PERSISTENT);
00660     REGISTER_LONG_CONSTANT("DB_TEST_POSTLOGMETA", DB_TEST_POSTLOGMETA, CONST_CS | CONST_PERSISTENT);
00661     REGISTER_LONG_CONSTANT("DB_TEST_POSTOPEN", DB_TEST_POSTOPEN, CONST_CS | CONST_PERSISTENT);
00662     REGISTER_LONG_CONSTANT("DB_TEST_POSTSYNC", DB_TEST_POSTSYNC, CONST_CS | CONST_PERSISTENT);
00663     REGISTER_LONG_CONSTANT("DB_TEST_PREDESTROY", DB_TEST_PREDESTROY, CONST_CS | CONST_PERSISTENT);
00664     REGISTER_LONG_CONSTANT("DB_TEST_PREOPEN", DB_TEST_PREOPEN, CONST_CS | CONST_PERSISTENT);
00665     REGISTER_LONG_CONSTANT("DB_TEST_SUBDB_LOCKS", DB_TEST_SUBDB_LOCKS, CONST_CS | CONST_PERSISTENT);
00666     REGISTER_LONG_CONSTANT("DB_ENV_AUTO_COMMIT", DB_ENV_AUTO_COMMIT, CONST_CS | CONST_PERSISTENT);
00667     REGISTER_LONG_CONSTANT("DB_ENV_CDB", DB_ENV_CDB, CONST_CS | CONST_PERSISTENT);
00668     REGISTER_LONG_CONSTANT("DB_ENV_CDB_ALLDB", DB_ENV_CDB_ALLDB, CONST_CS | CONST_PERSISTENT);
00669     REGISTER_LONG_CONSTANT("DB_ENV_CREATE", DB_ENV_CREATE, CONST_CS | CONST_PERSISTENT);
00670     REGISTER_LONG_CONSTANT("DB_ENV_DBLOCAL", DB_ENV_DBLOCAL, CONST_CS | CONST_PERSISTENT);
00671     REGISTER_LONG_CONSTANT("DB_ENV_DIRECT_DB", DB_ENV_DIRECT_DB, CONST_CS | CONST_PERSISTENT);
00672     REGISTER_LONG_CONSTANT("DB_ENV_DIRECT_LOG", DB_ENV_DIRECT_LOG, CONST_CS | CONST_PERSISTENT);
00673     REGISTER_LONG_CONSTANT("DB_ENV_FATAL", DB_ENV_FATAL, CONST_CS | CONST_PERSISTENT);
00674     REGISTER_LONG_CONSTANT("DB_ENV_LOCKDOWN", DB_ENV_LOCKDOWN, CONST_CS | CONST_PERSISTENT);
00675     REGISTER_LONG_CONSTANT("DB_ENV_LOG_AUTOREMOVE", DB_ENV_LOG_AUTOREMOVE, CONST_CS | CONST_PERSISTENT);
00676     REGISTER_LONG_CONSTANT("DB_ENV_NOLOCKING", DB_ENV_NOLOCKING, CONST_CS | CONST_PERSISTENT);
00677     REGISTER_LONG_CONSTANT("DB_ENV_NOMMAP", DB_ENV_NOMMAP, CONST_CS | CONST_PERSISTENT);
00678     REGISTER_LONG_CONSTANT("DB_ENV_NOPANIC", DB_ENV_NOPANIC, CONST_CS | CONST_PERSISTENT);
00679     REGISTER_LONG_CONSTANT("DB_ENV_OPEN_CALLED", DB_ENV_OPEN_CALLED, CONST_CS | CONST_PERSISTENT);
00680     REGISTER_LONG_CONSTANT("DB_ENV_OVERWRITE", DB_ENV_OVERWRITE, CONST_CS | CONST_PERSISTENT);
00681     REGISTER_LONG_CONSTANT("DB_ENV_PRIVATE", DB_ENV_PRIVATE, CONST_CS | CONST_PERSISTENT);
00682     REGISTER_LONG_CONSTANT("DB_ENV_REGION_INIT", DB_ENV_REGION_INIT, CONST_CS | CONST_PERSISTENT);
00683     REGISTER_LONG_CONSTANT("DB_ENV_RPCCLIENT", DB_ENV_RPCCLIENT, CONST_CS | CONST_PERSISTENT);
00684     REGISTER_LONG_CONSTANT("DB_ENV_RPCCLIENT_GIVEN", DB_ENV_RPCCLIENT_GIVEN, CONST_CS | CONST_PERSISTENT);
00685     REGISTER_LONG_CONSTANT("DB_ENV_SYSTEM_MEM", DB_ENV_SYSTEM_MEM, CONST_CS | CONST_PERSISTENT);
00686     REGISTER_LONG_CONSTANT("DB_ENV_THREAD", DB_ENV_THREAD, CONST_CS | CONST_PERSISTENT);
00687     REGISTER_LONG_CONSTANT("DB_ENV_TIME_NOTGRANTED", DB_ENV_TIME_NOTGRANTED, CONST_CS | CONST_PERSISTENT);
00688     REGISTER_LONG_CONSTANT("DB_ENV_TXN_NOSYNC", DB_ENV_TXN_NOSYNC, CONST_CS | CONST_PERSISTENT);
00689     REGISTER_LONG_CONSTANT("DB_ENV_TXN_WRITE_NOSYNC", DB_ENV_TXN_WRITE_NOSYNC, CONST_CS | CONST_PERSISTENT);
00690     REGISTER_LONG_CONSTANT("DB_ENV_YIELDCPU", DB_ENV_YIELDCPU, CONST_CS | CONST_PERSISTENT);
00691     REGISTER_LONG_CONSTANT("DB_DBM_HSEARCH", DB_DBM_HSEARCH, CONST_CS | CONST_PERSISTENT);
00692 }
00693 /* }}} */
00694 
00695 /* {{{ PHP_MSHUTDOWN_FUNCTION
00696  */
00697 PHP_MSHUTDOWN_FUNCTION(db4)
00698 {
00699     /* uncomment this line if you have INI entries
00700     UNREGISTER_INI_ENTRIES();
00701     */
00702     return SUCCESS;
00703 }
00704 /* }}} */
00705 
00706 /* {{{ PHP_MINFO_FUNCTION
00707  */
00708 PHP_MINFO_FUNCTION(db4)
00709 {
00710     php_info_print_table_start();
00711     php_info_print_table_header(2, "db4 support", "enabled");
00712     php_info_print_table_end();
00713 
00714     /* Remove comments if you have entries in php.ini
00715     DISPLAY_INI_ENTRIES();
00716     */
00717 }
00718 /* }}} */
00719 
00720 
00721 /* {{{ resource accessors 
00722  */
00723 void setDbEnv(zval *z, DB_ENV *dbenv TSRMLS_DC)
00724 {
00725     long rsrc_id;
00726         struct php_DB_ENV *pdb = (struct php_DB_ENV *) emalloc(sizeof(*pdb));
00727         pdb->dbenv = dbenv;
00728     rsrc_id = zend_register_resource(NULL, pdb, le_dbenv);
00729     zend_list_addref(rsrc_id);
00730     add_property_resource(z, "_dbenv_ptr", rsrc_id);
00731 }
00732 
00733 DB_ENV *php_db4_getDbEnvFromObj(zval *z TSRMLS_DC)
00734 {
00735     struct php_DB_ENV *pdb;
00736     zval **rsrc;
00737     if(zend_hash_find(HASH_OF(z), "_dbenv_ptr", sizeof("_dbenv_ptr"), 
00738           (void **) &rsrc) == SUCCESS) 
00739     {
00740         pdb = (struct php_DB_ENV *) zend_fetch_resource(rsrc TSRMLS_CC, -1, "Db4Env", NULL, 1, le_dbenv);
00741         return pdb->dbenv;
00742     }
00743     return NULL;
00744 }
00745 
00746 struct php_DB_ENV *php_db4_getPhpDbEnvFromObj(zval *z TSRMLS_DC)
00747 {
00748     struct php_DB_ENV *pdb;
00749     zval **rsrc;
00750     if(zend_hash_find(HASH_OF(z), "_dbenv_ptr", sizeof("_dbenv_ptr"), 
00751           (void **) &rsrc) == SUCCESS) 
00752     {
00753         pdb = (struct php_DB_ENV *) zend_fetch_resource(rsrc TSRMLS_CC, -1, "Db4Env", NULL, 1, le_dbenv);
00754         return pdb;
00755     }
00756     return NULL;
00757 }
00758 
00759 #define getDbEnvFromThis(a)        \
00760 do { \
00761   zval *_self = getThis(); \
00762   if(!_self) { \
00763     php_error_docref(NULL TSRMLS_CC, E_WARNING, "must be called as a method"); \
00764     RETURN_FALSE; \
00765   } \
00766   (a) = php_db4_getDbEnvFromObj(_self TSRMLS_CC); \
00767   if(!(a)) { \
00768     php_error_docref(NULL TSRMLS_CC, E_WARNING, "not a valid db4Env object"); \
00769     RETURN_FALSE; \
00770   } \
00771 } while(0)
00772 
00773 void setDb(zval *z, DB *db, int autocommit TSRMLS_DC)
00774 {
00775     long rsrc_id;
00776     struct php_DB *pdb = (struct php_DB *) emalloc(sizeof(*pdb));
00777     memset(pdb, 0, sizeof(*pdb));
00778     pdb->db = db;
00779     pdb->autocommit = autocommit;
00780     rsrc_id = ZEND_REGISTER_RESOURCE(NULL, pdb, le_db);
00781     add_property_resource(z, "_db_ptr", rsrc_id);
00782 }
00783 
00784 struct php_DB *getPhpDbFromObj(zval *z TSRMLS_DC)
00785 {
00786     struct php_DB *pdb;
00787     zval **rsrc;
00788     if(zend_hash_find(HASH_OF(z), "_db_ptr", sizeof("_db_ptr"), (void **) &rsrc) == SUCCESS) {
00789         pdb = (struct php_DB *) zend_fetch_resource(rsrc TSRMLS_CC, -1, "Db4", NULL, 1, le_db);
00790         return pdb;
00791     }
00792     return NULL;
00793 }
00794 
00795 DB *php_db4_getDbFromObj(zval *z TSRMLS_DC)
00796 {
00797     struct php_DB *pdb;
00798     zval **rsrc;
00799     if(zend_hash_find(HASH_OF(z), "_db_ptr", sizeof("_db_ptr"), (void **) &rsrc) == SUCCESS) {
00800         pdb = (struct php_DB *) zend_fetch_resource(rsrc TSRMLS_CC, -1, "Db4", NULL, 1, le_db);
00801         return pdb->db;
00802     }
00803     return NULL;
00804 }
00805 
00806 #define getDbFromThis(a, b)        \
00807 do { \
00808   struct php_DB *pdb; \
00809   zval *_self = getThis(); \
00810   if(!_self) { \
00811     php_error_docref(NULL TSRMLS_CC, E_WARNING, "must be called as a method"); \
00812     RETURN_FALSE; \
00813   } \
00814    pdb = getPhpDbFromObj(_self TSRMLS_CC); \
00815   if(!pdb || !pdb->db) { \
00816     assert(0); \
00817     php_error_docref(NULL TSRMLS_CC, E_WARNING, "not a valid db4 object"); \
00818     RETURN_FALSE; \
00819   } \
00820   (a) = pdb->db; \
00821   (b) = pdb->autocommit; \
00822 } while(0)
00823 
00824 #define getPhpDbFromThis(a)        \
00825 do { \
00826   struct php_DB *pdb; \
00827   zval *_self = getThis(); \
00828   if(!_self) { \
00829     php_error_docref(NULL TSRMLS_CC, E_WARNING, "must be called as a method"); \
00830     RETURN_FALSE; \
00831   } \
00832    pdb = getPhpDbFromObj(_self TSRMLS_CC); \
00833   if(!pdb) { \
00834     assert(0); \
00835     php_error_docref(NULL TSRMLS_CC, E_WARNING, "not a valid db4 object"); \
00836     RETURN_FALSE; \
00837   } \
00838   (a) = pdb; \
00839 } while(0)
00840 
00841 void setDbTxn(zval *z, DB_TXN *dbtxn TSRMLS_DC)
00842 {
00843     long rsrc_id;
00844     struct php_DB_TXN *txn = (struct php_DB_TXN *) emalloc(sizeof(*txn));
00845     memset(txn, 0, sizeof(*txn));
00846     txn->db_txn = dbtxn;
00847     rsrc_id = ZEND_REGISTER_RESOURCE(NULL, txn, le_db_txn);
00848     zend_list_addref(rsrc_id);
00849     add_property_resource(z, "_dbtxn_ptr", rsrc_id);
00850 }
00851 
00852 DB_TXN *php_db4_getDbTxnFromObj(zval *z TSRMLS_DC)
00853 {
00854     struct php_DB_TXN *pdbtxn;
00855     zval **rsrc;
00856     if(zend_hash_find(HASH_OF(z), "_dbtxn_ptr", sizeof("_dbtxn_ptr"), 
00857           (void **) &rsrc) == SUCCESS) 
00858     {
00859         pdbtxn = (struct php_DB_TXN *) zend_fetch_resource(rsrc TSRMLS_CC, -1, "Db4Txn", NULL, 1, le_db_txn);
00860         return pdbtxn->db_txn;
00861     }
00862     return NULL;
00863 }
00864 
00865 struct php_DB_TXN *getPhpDbTxnFromObj(zval *z TSRMLS_DC)
00866 {
00867     struct php_DB_TXN *pdbtxn;
00868     zval **rsrc;
00869     if(zend_hash_find(HASH_OF(z), "_dbtxn_ptr", sizeof("_dbtxn_ptr"), 
00870           (void **) &rsrc) == SUCCESS) 
00871     {
00872         pdbtxn = (struct php_DB_TXN *) zend_fetch_resource(rsrc TSRMLS_CC, -1, "Db4Txn", NULL, 1, le_db_txn);
00873         return pdbtxn;
00874     }
00875     return NULL;
00876 }
00877 
00878 #define getDbTxnFromThis(a)        \
00879 do { \
00880   zval *_self = getThis(); \
00881   if(!_self) { \
00882     php_error_docref(NULL TSRMLS_CC, E_WARNING, "must be called as a method"); \
00883     RETURN_FALSE; \
00884   } \
00885   (a) = php_db4_getDbTxnFromObj(_self TSRMLS_CC); \
00886   if(!(a)) { \
00887     php_error_docref(NULL TSRMLS_CC, E_WARNING, "not a valid db4txn object"); \
00888     RETURN_FALSE; \
00889   } \
00890 } while(0)
00891 
00892 #define getPhpDbTxnFromThis(a)        \
00893 do { \
00894   zval *_self = getThis(); \
00895   if(!_self) { \
00896     php_error_docref(NULL TSRMLS_CC, E_WARNING, "must be called as a method"); \
00897     RETURN_FALSE; \
00898   } \
00899   (a) = getPhpDbTxnFromObj(_self TSRMLS_CC); \
00900   if(!(a) || !(a)->db_txn) { \
00901     php_error_docref(NULL TSRMLS_CC, E_WARNING, "not a valid db4txn object"); \
00902     RETURN_FALSE; \
00903   } \
00904 } while(0)
00905 
00906 void closeDbTxnDependencies(zval *obj TSRMLS_DC) {
00907     struct php_DB_TXN *pdbtxn = getPhpDbTxnFromObj(obj TSRMLS_CC);
00908     if(pdbtxn) {
00909         while(pdbtxn->open_cursors) {
00910             struct my_llist *el = pdbtxn->open_cursors;
00911             struct php_DBC *pdbc = (struct php_DBC *) el->data;
00912             if(pdbc) {
00913                 if(pdbc->dbc) {
00914                     pdbc->dbc->c_close(pdbc->dbc);
00915                     pdbc->dbc = NULL;
00916                 }
00917                 pdbc->parent_txn = NULL;
00918             }
00919 //          efree(el->data);
00920             pdbtxn->open_cursors = el->next;
00921             efree(el);
00922             php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempting to end a transaction without closing it's child cursors.");
00923         }
00924         /* should handle open dbs with pending transactions */
00925     }
00926 }
00927 
00928 
00929 void setDbc(zval *z, DBC *dbc, struct php_DB_TXN *txn TSRMLS_DC)
00930 {
00931     long rsrc_id;
00932     struct php_DBC *pdbc = (struct php_DBC *) emalloc(sizeof(*pdbc));
00933     memset(pdbc, 0, sizeof(*pdbc));
00934     pdbc->dbc = dbc;
00935     if(txn) {
00936         pdbc->parent_txn = txn;
00937         txn->open_cursors = my_llist_add(txn->open_cursors, pdbc);
00938     }
00939     rsrc_id = zend_register_resource(NULL, pdbc, le_dbc);
00940     zend_list_addref(rsrc_id);
00941     add_property_resource(z, "_dbc_ptr", rsrc_id);
00942 }
00943 
00944 DBC *php_db4_getDbcFromObj(zval *z TSRMLS_DC)
00945 {
00946     struct php_DBC *pdbc;
00947     zval **rsrc;
00948     if(zend_hash_find(HASH_OF(z), "_dbc_ptr", sizeof("_dbc_ptr"), 
00949           (void **) &rsrc) == SUCCESS) 
00950     {
00951         pdbc = (struct php_DBC *) zend_fetch_resource(rsrc TSRMLS_CC, -1, "Db4Cursor", NULL, 1, le_dbc);
00952         return pdbc->dbc;
00953     }
00954     return NULL;
00955 }
00956 
00957 struct php_DBC *getPhpDbcFromObj(zval *z TSRMLS_DC)
00958 {
00959     struct php_DBC *pdbc;
00960     zval **rsrc;
00961     if(zend_hash_find(HASH_OF(z), "_dbc_ptr", sizeof("_dbc_ptr"), 
00962           (void **) &rsrc) == SUCCESS) 
00963     {
00964         pdbc = (struct php_DBC *) zend_fetch_resource(rsrc TSRMLS_CC, -1, "Db4Cursor", NULL, 1, le_dbc);
00965         return pdbc;
00966     }
00967     return NULL;
00968 }
00969 
00970 #define getDbcFromThis(a)        \
00971 do { \
00972   zval *_self = getThis(); \
00973   if(!_self) { \
00974     php_error_docref(NULL TSRMLS_CC, E_WARNING, "must be called as a method"); \
00975     RETURN_FALSE; \
00976   } \
00977   (a) = php_db4_getDbcFromObj(_self TSRMLS_CC); \
00978   if(!(a)) { \
00979     php_error_docref(NULL TSRMLS_CC, E_WARNING, "not a valid db4Cursor object"); \
00980     RETURN_FALSE; \
00981   } \
00982 } while(0)
00983 
00984 int closeDbc(zval *obj TSRMLS_DC)
00985 {
00986     int ret = 0;
00987     struct php_DBC *pdbc = getPhpDbcFromObj(obj TSRMLS_CC);
00988     if(pdbc) {
00989         if(pdbc->parent_txn) {
00990             pdbc->parent_txn->open_cursors = 
00991                 my_llist_del(pdbc->parent_txn->open_cursors, pdbc);
00992         }
00993         ret = pdbc->dbc->c_close(pdbc->dbc);
00994         pdbc->dbc = NULL;
00995         pdbc->parent_txn = NULL;
00996     }
00997     return ret;
00998 }
00999 
01000 /* }}} */
01001 
01002 /* {{{ DB4Txn method definitions 
01003  */
01004 
01005 /* {{{ proto bool Db4Txn::abort()
01006  */
01007 ZEND_NAMED_FUNCTION(_wrap_db_txn_abort)
01008 {
01009     struct php_DB_TXN *ptxn;
01010     zval **open_cursors;
01011     zval *self;
01012     int ret;
01013 
01014     if(ZEND_NUM_ARGS()) {
01015         WRONG_PARAM_COUNT;
01016     }
01017     self = getThis();
01018     getPhpDbTxnFromThis(ptxn);
01019     closeDbTxnDependencies(self TSRMLS_CC);
01020     if((ret = ptxn->db_txn->abort(ptxn->db_txn)) != 0) {
01021         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01022         RETURN_FALSE;
01023     }
01024     ptxn->db_txn = NULL;
01025     RETURN_TRUE;
01026 }
01027 /* }}} */
01028 
01029 /* {{{ proto bool Db4Txn::commit()
01030  */
01031 ZEND_NAMED_FUNCTION(_wrap_db_txn_commit)
01032 {
01033     struct php_DB_TXN *ptxn;
01034     u_int32_t flags = 0;
01035     int ret;
01036     zval *self;
01037     zval **open_cursors;
01038 
01039     self = getThis();
01040     getPhpDbTxnFromThis(ptxn);
01041     closeDbTxnDependencies(self TSRMLS_CC);
01042     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE)
01043     {
01044         return;
01045     }
01046     if((ret = ptxn->db_txn->commit(ptxn->db_txn, flags)) != 0) {
01047         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01048         RETURN_FALSE;
01049     }
01050     ptxn->db_txn = NULL;
01051     RETURN_TRUE;
01052 }
01053 /* }}} */
01054 
01055 /* {{{ proto bool Db4Txn::discard()
01056  */
01057 ZEND_NAMED_FUNCTION(_wrap_db_txn_discard)
01058 {
01059     struct php_DB_TXN *ptxn;
01060     int ret;
01061     zval *self;
01062     zval **open_cursors;
01063 
01064     self = getThis();
01065     getPhpDbTxnFromThis(ptxn);
01066     closeDbTxnDependencies(self TSRMLS_CC);
01067     if(ZEND_NUM_ARGS()) WRONG_PARAM_COUNT;
01068     if((ret = ptxn->db_txn->discard(ptxn->db_txn, 0)) != 0) {
01069         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01070         RETURN_FALSE;
01071     }
01072     ptxn->db_txn = NULL;
01073     /* FIXME should destroy $self */
01074     RETURN_TRUE;
01075 }
01076 /* }}} */
01077 
01078 /* {{{ proto long Db4Txn::id()
01079  */
01080 ZEND_NAMED_FUNCTION(_wrap_db_txn_id)
01081 {
01082     DB_TXN *txn;
01083     int ret;
01084 
01085     getDbTxnFromThis(txn);
01086     if(ZEND_NUM_ARGS()) WRONG_PARAM_COUNT;
01087     RETURN_LONG(txn->id(txn));
01088 }
01089 /* }}} */
01090 
01091 /* {{{ proto bool Db4Txn::set_timeout(long $timeout [, long $flags])
01092  */
01093 ZEND_NAMED_FUNCTION(_wrap_db_txn_set_timeout)
01094 {
01095     DB_TXN *txn;
01096     u_int32_t flags = 0;
01097     long timeout;
01098     int ret;
01099 
01100     getDbTxnFromThis(txn);
01101     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &timeout, &flags) == FAILURE)
01102     {
01103         return;
01104     }
01105     if((ret = txn->set_timeout(txn, timeout, flags)) != 0) {
01106         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01107         RETURN_FALSE;
01108     }
01109     RETURN_TRUE;
01110 }
01111 /* }}} */
01112 
01113 /* {{{ proto bool Db4Txn::set_name(string $name) 
01114  */
01115 ZEND_NAMED_FUNCTION(_wrap_db_txn_set_name)
01116 {
01117     DB_TXN *txn;
01118     char *name;
01119     int name_len;
01120     int ret;
01121 
01122     getDbTxnFromThis(txn);
01123     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE)
01124     {
01125         return;
01126     }
01127     txn->set_name(txn, name);
01128     RETURN_TRUE;
01129 }
01130 /* }}} */
01131 
01132 /* {{{ proto bool Db4Txn::get_name() 
01133  */
01134 ZEND_NAMED_FUNCTION(_wrap_db_txn_get_name)
01135 {
01136     DB_TXN *txn;
01137     const char *name;
01138     int ret;
01139 
01140     getDbTxnFromThis(txn);
01141     if(ZEND_NUM_ARGS())
01142     {
01143                 WRONG_PARAM_COUNT;
01144     }
01145     if((ret = txn->get_name(txn, &name)) != 0) {
01146         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01147         RETURN_FALSE;
01148     }
01149     RETURN_STRING((char *)name, 1);
01150 }
01151 /* }}} */
01152 
01153 /* {{{ private Db4Txn::Db4Txn()
01154  */
01155 ZEND_NAMED_FUNCTION(_wrap_new_DbTxn)
01156 {
01157     php_error_docref(NULL TSRMLS_CC, E_ERROR, "DB4Txn objects must be created with Db4Env::begin_txn()");
01158 }
01159 /* }}} */
01160 
01161 /* }}} */
01162 
01163 
01164 /* {{{ DB4 method definitions
01165  */
01166 
01167 /* {{{ proto object DB4::DB4([object $dbenv])
01168  */
01169 ZEND_NAMED_FUNCTION(_wrap_new_db4)
01170 {
01171     DB *db;
01172     DB_ENV *dbenv = NULL;
01173     zval *dbenv_obj = NULL;
01174     zval *self;
01175     int ret, autocommit = 0;
01176 
01177     self = getThis();
01178     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|O",
01179                              &dbenv_obj, db_env_ce) == FAILURE) 
01180     {
01181         return;
01182     }
01183     if(dbenv_obj) {
01184         dbenv = php_db4_getDbEnvFromObj(dbenv_obj TSRMLS_CC);
01185         zval_add_ref(&dbenv_obj);
01186         add_property_zval(self, "dbenv", dbenv_obj);
01187         autocommit = 1;
01188     }
01189     if((ret = my_db_create(&db, dbenv, 0)) != 0) {
01190         php_error_docref(NULL TSRMLS_CC,
01191                          E_WARNING, "error occurred during open");
01192         RETURN_FALSE;
01193     }
01194     setDb(self, db, autocommit TSRMLS_CC);
01195 }
01196 /* }}} */
01197 
01198 /* {{{ proto bool DB4::open([object $txn [, string $file [, string $database [, long $flags [, long $mode]]]]]) 
01199  */
01200 ZEND_NAMED_FUNCTION(_wrap_db_open)
01201 {
01202     DB *db = NULL;
01203     DB_TXN *dbtxn = NULL;
01204     zval *dbtxn_obj = NULL;
01205     char *file = NULL, *database = NULL;
01206     long filelen = 0, databaselen = 0;
01207     DBTYPE type = DB_BTREE;
01208     u_int32_t flags = DB_CREATE;
01209     int mode = 0;
01210     int ret;
01211     u_int32_t autocommit;
01212     
01213     zval *self;
01214     self = getThis();
01215     getDbFromThis(db, autocommit);
01216     
01217     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|O!sslll",
01218                              &dbtxn_obj, db_txn_ce,
01219                              &file, &filelen,
01220                              &database, &databaselen,
01221                              &type, &flags, &mode) == FAILURE) 
01222     {
01223         return;
01224     }
01225     if(dbtxn_obj) {
01226         dbtxn = php_db4_getDbTxnFromObj(dbtxn_obj TSRMLS_CC);
01227     } else if(autocommit) {
01228         flags |= DB_AUTO_COMMIT;
01229     }
01230     add_property_string(self, "file", file, 1);
01231     add_property_string(self, "database", database, 1);
01232     if(strcmp(file, "") == 0) file = NULL;
01233     if(strcmp(database, "") == 0) database = NULL;
01234     /* add type and other introspection data */
01235     if((ret = db->open(db, dbtxn, file, database, type, flags, mode)) == 0) {
01236         RETURN_TRUE;
01237     }
01238     else {
01239         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01240         add_property_string(self, "lastError", db_strerror(ret), 1);
01241         RETURN_FALSE;
01242     }
01243 }
01244 /* }}} */
01245 
01246 /* {{{ proto bool DB4::close()
01247  */
01248 ZEND_NAMED_FUNCTION(_wrap_db_close)
01249 {
01250     struct php_DB *pdb = NULL;
01251     int autocommit;
01252     getPhpDbFromThis(pdb);
01253 
01254     if(ZEND_NUM_ARGS()) {
01255         WRONG_PARAM_COUNT;
01256     }
01257         if(pdb && pdb->db) {
01258       pdb->db->close(pdb->db, 0);
01259           pdb->db = NULL;
01260         }
01261     RETURN_TRUE;
01262 }
01263 /* }}} */
01264 
01265 /* {{{ proto bool DB4::del(string $key [, object $txn])
01266  */
01267 ZEND_NAMED_FUNCTION(_wrap_db_del)
01268 {
01269     DB *db = NULL;
01270     DB_TXN *txn = NULL;
01271     zval *txn_obj = NULL;
01272     u_int32_t flags;
01273     DBT key;
01274     char *keyname;
01275     int keylen, autocommit;
01276 
01277     getDbFromThis(db, autocommit);
01278     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|O", &keyname, &keylen, 
01279                              &txn_obj, db_txn_ce) == FAILURE) 
01280     {
01281         return;
01282     }
01283     if(txn_obj) {
01284         getDbTxnFromThis(txn);
01285         flags = 0;
01286     } else if(autocommit) {
01287         flags = DB_AUTO_COMMIT;
01288     }
01289     memset(&key, 0, sizeof(DBT));
01290     key.data = keyname;
01291     key.size = keylen;
01292     RETURN_LONG(db->del(db, txn, &key, flags));
01293 }
01294 /* }}} */
01295 
01296 /* {{{ proto string DB4::get(string $key [,object $txn [, long flags]])
01297  */
01298 ZEND_NAMED_FUNCTION(_wrap_db_get)
01299 {
01300     DB *db = NULL;
01301     DB_TXN *txn = NULL;
01302     zval *txn_obj = NULL;
01303     DBT key, value;
01304     char *keyname;
01305     int keylen, autocommit;
01306     u_int32_t flags = 0;
01307 
01308     getDbFromThis(db, autocommit);
01309     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Ol", &keyname, &keylen, 
01310                              &txn_obj, db_txn_ce, &flags) == FAILURE) 
01311     {
01312         return;
01313     }
01314     if(txn_obj) {
01315         txn = php_db4_getDbTxnFromObj(txn_obj);
01316     } else if (((flags & DB_CONSUME) || (flags & DB_CONSUME_WAIT)) && autocommit) {
01317         flags |= DB_AUTO_COMMIT;
01318     }
01319     memset(&key, 0, sizeof(DBT));
01320     key.data = keyname;
01321     key.size = keylen;
01322     memset(&value, 0, sizeof(DBT));
01323     if(db->get(db, txn, &key, &value, flags) == 0) {
01324         RETURN_STRINGL((char *)value.data, value.size, 1);
01325     }
01326     RETURN_FALSE;
01327 }
01328 /* }}} */
01329 
01330 /* {{{ proto string DB4::pget(string $key, string &$pkey [,object $txn [, long flags]])
01331  */
01332 ZEND_NAMED_FUNCTION(_wrap_db_pget)
01333 {
01334     DB *db = NULL;
01335     DB_TXN *txn = NULL;
01336     zval *txn_obj = NULL;
01337     DBT key, value, pkey;
01338     char *keyname;
01339     int keylen, autocommit;
01340     zval *z_pkey;
01341     u_int32_t flags = 0;
01342 
01343     getDbFromThis(db, autocommit);
01344     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|Ol", 
01345                              &keyname, &keylen, &z_pkey,
01346                              &txn_obj, db_txn_ce, &flags) == FAILURE) 
01347     {
01348         return;
01349     }
01350     if(txn_obj) {
01351         txn = php_db4_getDbTxnFromObj(txn_obj);
01352     } else if (((flags & DB_CONSUME) || (flags & DB_CONSUME_WAIT)) && autocommit) {
01353         flags |= DB_AUTO_COMMIT;
01354     }
01355     memset(&key, 0, sizeof(DBT));
01356     key.data = keyname;
01357     key.size = keylen;
01358     memset(&pkey, 0, sizeof(DBT));
01359     memset(&value, 0, sizeof(DBT));
01360     if(db->pget(db, txn, &key, &pkey, &value, flags) == 0) {
01361         if(Z_STRLEN_P(z_pkey) == 0) {
01362             Z_STRVAL_P(z_pkey) = (char *) emalloc(pkey.size);
01363         } else {
01364             Z_STRVAL_P(z_pkey) = (char *) erealloc(Z_STRVAL_P(z_pkey), pkey.size);
01365         }
01366         memcpy(Z_STRVAL_P(z_pkey), pkey.data, pkey.size);
01367         Z_STRLEN_P(z_pkey) = pkey.size;
01368         RETURN_STRINGL((char *)value.data, value.size, 1);
01369     }
01370     RETURN_FALSE;
01371 }
01372 /* }}} */
01373 
01374 /* {{{ proto string DB4::get_type() 
01375  */
01376 ZEND_NAMED_FUNCTION(_wrap_db_get_type)
01377 {
01378     DB *db = NULL;
01379     DBTYPE type;
01380     int autocommit;
01381 
01382     getDbFromThis(db, autocommit);
01383     if(db->get_type(db, &type)) { 
01384         RETURN_FALSE; 
01385     }
01386     switch(type) {
01387         case DB_BTREE:
01388             RETURN_STRING("DB_BTREE", 1);
01389             break;
01390         case DB_HASH:
01391             RETURN_STRING("DB_HASH", 1);
01392             break;
01393         case DB_RECNO:
01394             RETURN_STRING("DB_RECNO", 1);
01395             break;
01396         case DB_QUEUE:
01397             RETURN_STRING("DB_QUEUE", 1);
01398             break;
01399         default:
01400             RETURN_STRING("UNKNOWN", 1);
01401             break;
01402     }
01403 }
01404 /* }}} */
01405 
01406 /* {{{ proto array DB4::stat([object $txn [, long flags]])
01407  */
01408 ZEND_NAMED_FUNCTION(_wrap_db_stat)
01409 {
01410     DB *db = NULL;
01411     DB_TXN *txn = NULL;
01412     zval *txn_obj = NULL;
01413     DBTYPE type;
01414     int autocommit;
01415     u_int32_t flags = 0;
01416 
01417     getDbFromThis(db, autocommit);
01418     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|zl", &txn_obj, db_txn_ce, &flags) == FAILURE) {
01419         return;
01420     }
01421     if(db->get_type(db, &type)) { 
01422         RETURN_FALSE; 
01423     }
01424     if(txn_obj) {
01425         txn = php_db4_getDbTxnFromObj(txn_obj);
01426         }
01427     switch(type) {
01428 #define ADD_STAT_LONG(a)  add_assoc_long(return_value, #a, sb.a)
01429         case DB_HASH: 
01430         {
01431             DB_HASH_STAT sb;
01432             if(db->stat(db, txn, (void *)&sb, flags)) {
01433                 RETURN_FALSE;
01434             }
01435             array_init(return_value);
01436             if(flags & DB_FAST_STAT) {
01437                 ADD_STAT_LONG(hash_magic);
01438                 ADD_STAT_LONG(hash_version);
01439                 ADD_STAT_LONG(hash_nkeys);
01440                 ADD_STAT_LONG(hash_ndata);
01441                 ADD_STAT_LONG(hash_pagesize);
01442                 ADD_STAT_LONG(hash_ffactor);
01443                 ADD_STAT_LONG(hash_buckets);
01444             }
01445             ADD_STAT_LONG(hash_free);
01446             ADD_STAT_LONG(hash_bfree);
01447             ADD_STAT_LONG(hash_bigpages);
01448             ADD_STAT_LONG(hash_bfree);
01449             ADD_STAT_LONG(hash_overflows);
01450             ADD_STAT_LONG(hash_ovfl_free);
01451             ADD_STAT_LONG(hash_dup);
01452             ADD_STAT_LONG(hash_dup_free);
01453         }
01454             break;
01455         case DB_BTREE:
01456         case DB_RECNO:
01457         {
01458             DB_BTREE_STAT sb;
01459             if(db->stat(db, txn, (void *)&sb, flags)) {
01460                 RETURN_FALSE;
01461             }
01462             array_init(return_value);
01463             if(flags & DB_FAST_STAT) {
01464                 ADD_STAT_LONG(bt_magic);
01465                 ADD_STAT_LONG(bt_version);
01466                 ADD_STAT_LONG(bt_nkeys);
01467                 ADD_STAT_LONG(bt_ndata);
01468                 ADD_STAT_LONG(bt_pagesize);
01469                 ADD_STAT_LONG(bt_minkey);
01470                 ADD_STAT_LONG(bt_re_len);
01471                 ADD_STAT_LONG(bt_re_pad);
01472             }
01473             ADD_STAT_LONG(bt_levels);
01474             ADD_STAT_LONG(bt_int_pg);
01475             ADD_STAT_LONG(bt_leaf_pg);
01476             ADD_STAT_LONG(bt_dup_pg);
01477             ADD_STAT_LONG(bt_over_pg);
01478             ADD_STAT_LONG(bt_free);
01479             ADD_STAT_LONG(bt_int_pgfree);
01480             ADD_STAT_LONG(bt_leaf_pgfree);
01481             ADD_STAT_LONG(bt_dup_pgfree);
01482             ADD_STAT_LONG(bt_over_pgfree);
01483         }
01484             break;
01485         case DB_QUEUE:
01486         {
01487             DB_QUEUE_STAT sb;
01488             if(db->stat(db, txn, (void *)&sb, flags)) {
01489                 RETURN_FALSE;
01490             }
01491             array_init(return_value);
01492             if(flags & DB_FAST_STAT) {
01493                 ADD_STAT_LONG(qs_magic);
01494                 ADD_STAT_LONG(qs_version);
01495                 ADD_STAT_LONG(qs_nkeys);
01496                 ADD_STAT_LONG(qs_ndata);
01497                 ADD_STAT_LONG(qs_pagesize);
01498                 ADD_STAT_LONG(qs_extentsize);
01499                 ADD_STAT_LONG(qs_re_len);
01500                 ADD_STAT_LONG(qs_re_pad);
01501                 ADD_STAT_LONG(qs_first_recno);
01502                 ADD_STAT_LONG(qs_cur_recno);
01503             }
01504             ADD_STAT_LONG(qs_pages);
01505             ADD_STAT_LONG(qs_pgfree);
01506             break;
01507         }
01508         default:
01509             RETURN_FALSE;
01510     }
01511 }
01512 /* }}} */
01513 
01514 /* {{{ proto DBCursor DB4::join(array $curslist [, long $flags])
01515  */
01516 ZEND_NAMED_FUNCTION(_wrap_db_join) 
01517 { 
01518     DB *db = NULL;
01519     DBC *dbcp;
01520     DBC **curslist;
01521     zval *z_array;
01522     HashTable *array;
01523     HashPosition pos;
01524     zval **z_cursor;
01525     int num_cursors, rv, autocommit, i;
01526 
01527     u_int32_t flags = 0;
01528 
01529     getDbFromThis(db, autocommit);
01530     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a|l", 
01531                              &z_array, &flags) == FAILURE) 
01532     {
01533         return;
01534     }
01535     array = HASH_OF(z_array);
01536     num_cursors = zend_hash_num_elements(array);
01537     curslist = (DBC **) calloc(sizeof(DBC *), num_cursors + 1);
01538     for(zend_hash_internal_pointer_reset_ex(array, &pos), i=0;
01539         zend_hash_get_current_data_ex(array, (void **) &z_cursor, &pos) == SUCCESS;
01540         zend_hash_move_forward_ex(array, &pos), i++) {
01541         curslist[i] = php_db4_getDbcFromObj(*z_cursor);
01542     }
01543     rv = db->join(db, curslist, &dbcp, flags);
01544     free(curslist);
01545     if(rv) {
01546         RETURN_FALSE;
01547     } else {
01548         object_init_ex(return_value, dbc_ce);
01549         setDbc(return_value, dbcp, NULL TSRMLS_CC);
01550     }
01551 }
01552 /* }}} */
01553 
01554 /* {{{ proto bool DB4::put(string $key, string $value [, object $txn [, long flags]])
01555  */
01556 ZEND_NAMED_FUNCTION(_wrap_db_put)
01557 {
01558     DB *db = NULL;
01559     DB_TXN *txn = NULL;
01560     zval *txn_obj = NULL;
01561     DBT key, value;
01562     char *keyname, *dataname;
01563     int keylen, datalen;
01564     int ret, autocommit;
01565     zval *self;
01566     long flags = 0;
01567 
01568     self = getThis();
01569     getDbFromThis(db, autocommit);
01570     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|Ol", &keyname, &keylen, 
01571                              &dataname, &datalen, &txn_obj, db_txn_ce, &flags) == FAILURE) 
01572     {
01573         return;
01574     }
01575     if(txn_obj) {
01576         txn = php_db4_getDbTxnFromObj(txn_obj TSRMLS_CC);
01577     } else if (autocommit) {
01578         flags |= DB_AUTO_COMMIT;
01579     }
01580     memset(&key, 0, sizeof(DBT));
01581     key.data = keyname;
01582     key.size = keylen;
01583     memset(&value, 0, sizeof(DBT));
01584     value.data = dataname;
01585     value.size = datalen;
01586     if((ret = db->put(db, txn, &key, &value, flags)) != 0) {
01587         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01588         add_property_string(self, "lastError", db_strerror(ret), 1);
01589         RETURN_FALSE;
01590     }
01591     RETURN_TRUE;
01592 }
01593 /* }}} */
01594 
01595 /* {{{ proto bool DB4::sync()
01596  */
01597 ZEND_NAMED_FUNCTION(_wrap_db_sync)
01598 {
01599     int autocommit;
01600     DB *db = NULL;
01601     getDbFromThis(db, autocommit);
01602     if(ZEND_NUM_ARGS()) {
01603         WRONG_PARAM_COUNT;
01604     }
01605     db->sync(db, 0);
01606     RETURN_TRUE;
01607 }
01608 /* }}} */
01609 
01610 /* {{{ proto bool DB4::truncate([object $txn [, long $flags]])
01611  */
01612 ZEND_NAMED_FUNCTION(_wrap_db_truncate)
01613 {
01614     DB *db = NULL;
01615     DB_TXN *txn = NULL;
01616     zval *txn_obj = NULL;
01617     long flags = DB_AUTO_COMMIT;
01618     int autocommit;
01619     u_int32_t countp;
01620 
01621     getDbFromThis(db, autocommit);
01622     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Ol", 
01623                              &txn_obj, db_txn_ce, &flags) == FAILURE) 
01624     {
01625         return;
01626     }
01627     if(txn_obj) {
01628         txn = php_db4_getDbTxnFromObj(txn_obj TSRMLS_CC);
01629         flags = 0;
01630     } else if (autocommit) {
01631         flags = DB_AUTO_COMMIT;
01632     }
01633     if(db->truncate(db, txn, &countp, flags) == 0) {
01634         RETURN_LONG(countp);
01635     }
01636     RETURN_FALSE;
01637 }
01638 /* }}} */
01639 
01640 /* {{{ proto DB4Cursor DB4::cursor([object $txn [, long flags]])
01641  */
01642 ZEND_NAMED_FUNCTION(_wrap_db_cursor)
01643 {
01644     DB *db;
01645     DB_TXN *txn = NULL;
01646     zval *txn_obj = NULL, *self;
01647     DBC *cursor = NULL;
01648     u_int32_t flags = 0;
01649     int ret, autocommit;
01650 
01651     self = getThis();
01652     getDbFromThis(db, autocommit);
01653     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Ol", &txn_obj, db_txn_ce, &flags) == FAILURE) 
01654     {
01655         return;
01656     }
01657     if(txn_obj) {
01658         txn = php_db4_getDbTxnFromObj(txn_obj TSRMLS_CC);
01659     }
01660     if((ret = db->cursor(db, txn, &cursor, flags)) != 0 ) {
01661         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01662         add_property_string(self, "lastError", db_strerror(ret), 1);
01663         RETURN_FALSE;
01664     }
01665     else {
01666         object_init_ex(return_value, dbc_ce);
01667         setDbc(return_value, cursor, txn_obj?getPhpDbTxnFromObj(txn_obj TSRMLS_CC):NULL TSRMLS_CC);
01668     }
01669         
01670 }
01671 /* }}} */
01672 
01673 /* }}} end DB4 method definitions */
01674 
01675 /* {{{ DB4Cursor method definitions 
01676  */
01677 
01678 /* {{{ proto bool Db4Cursor::close()
01679  */
01680 ZEND_NAMED_FUNCTION(_wrap_dbc_close)
01681 {
01682     DBC *dbc;
01683     int ret;
01684     zval **parent_txn, **open_cursors;
01685     zval *self;
01686     HashPosition pos;
01687     
01688     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) return;
01689     self = getThis();
01690     getDbcFromThis(dbc);
01691     if((ret = closeDbc(self TSRMLS_CC)) != 0) {
01692         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01693         RETURN_FALSE;
01694     }
01695     RETURN_TRUE;
01696 }
01697 /* }}} */
01698 
01699 /* {{{ proto long Db4Cursor::count()
01700  */
01701 ZEND_NAMED_FUNCTION(_wrap_dbc_count)
01702 {
01703     DBC *dbc;
01704     db_recno_t count;
01705     int ret;
01706 
01707     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) return;
01708     getDbcFromThis(dbc);
01709     if((ret = dbc->c_count(dbc, &count, 0)) != 0) {
01710         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01711         RETURN_FALSE;
01712     }
01713     RETURN_LONG(count);
01714 }
01715 /* }}} */
01716 
01717 /* {{{ proto bool Db4Cursor::del()
01718  */
01719 ZEND_NAMED_FUNCTION(_wrap_dbc_del)
01720 {
01721     DBC *dbc;
01722     int ret;
01723 
01724     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) return;
01725     getDbcFromThis(dbc);
01726     if((ret = dbc->c_del(dbc, 0)) != 0) {
01727         if(ret != DB_KEYEMPTY) {
01728             php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01729         }
01730         RETURN_FALSE;
01731     }
01732     RETURN_TRUE;
01733 }
01734 /* }}} */
01735 
01736 /* {{{ proto object Db4Cursor::dup([long $flags]) 
01737  */
01738 ZEND_NAMED_FUNCTION(_wrap_dbc_dup)
01739 {
01740     DBC *dbc, *newdbc;
01741     u_int32_t flags = 0;
01742     int ret;
01743 
01744     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) return;
01745     getDbcFromThis(dbc);
01746     if((ret = dbc->c_dup(dbc, &newdbc, flags)) != 0) {
01747         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01748         RETURN_FALSE;
01749     }
01750     object_init_ex(return_value, dbc_ce);
01751     /* FIXME should pass in dbc's parent txn */
01752     setDbc(return_value, newdbc, NULL TSRMLS_CC);
01753 }
01754 /* }}} */
01755 
01756 /* {{{ proto string Db4Cursor::get(string &$key, string &$data [, long $flags])
01757  */
01758 ZEND_NAMED_FUNCTION(_wrap_dbc_get)
01759 {
01760     DBC *dbc;
01761     DBT key, value;
01762     zval *zkey, *zvalue;
01763     u_int32_t flags = DB_NEXT;
01764     zval *self;
01765     int ret;
01766     
01767     self = getThis();
01768     getDbcFromThis(dbc);
01769     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/z/|l", &zkey, &zvalue, &flags) == FAILURE) 
01770     {
01771         return;
01772     }
01773     memset(&key, 0, sizeof(DBT));
01774         key.data = Z_STRVAL_P(zkey);
01775         key.size = Z_STRLEN_P(zkey);
01776     memset(&value, 0, sizeof(DBT));
01777         value.data = Z_STRVAL_P(zvalue);
01778         value.size = Z_STRLEN_P(zvalue);
01779     if((ret = dbc->c_get(dbc, &key, &value, flags)) == 0) {
01780                 zval_dtor(zkey); ZVAL_STRINGL(zkey, (char *) key.data, key.size, 1);
01781                 zval_dtor(zvalue); ZVAL_STRINGL(zvalue, (char *) value.data, value.size, 1);
01782                 RETURN_LONG(0);
01783     } 
01784         if(ret != DB_NOTFOUND) {
01785         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01786         add_property_string(self, "lastError", db_strerror(ret), 1);
01787     }
01788     RETURN_LONG(1);
01789 }
01790 /* }}} */
01791 
01792 /* {{{ proto string Db4Cursor::pget(string &$key, string &$pkey, string &$data [, long $flags])
01793  */
01794 ZEND_NAMED_FUNCTION(_wrap_dbc_pget)
01795 {
01796     DBC *dbc;
01797     DBT key, pkey, value;
01798     zval *zkey, *zvalue, *zpkey;
01799     u_int32_t flags = DB_NEXT;
01800     zval *self;
01801     int ret;
01802     
01803     self = getThis();
01804     getDbcFromThis(dbc);
01805     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/z/z/|l", &zkey, &zpkey, &zvalue, &flags) == FAILURE) 
01806     {
01807         return;
01808     }
01809     memset(&key, 0, sizeof(DBT));
01810         key.data = Z_STRVAL_P(zkey);
01811         key.size = Z_STRLEN_P(zkey);
01812     memset(&pkey, 0, sizeof(DBT));
01813         pkey.data = Z_STRVAL_P(zpkey);
01814         pkey.size = Z_STRLEN_P(zpkey);
01815     memset(&value, 0, sizeof(DBT));
01816         value.data = Z_STRVAL_P(zvalue);
01817         value.size = Z_STRLEN_P(zvalue);
01818     if((ret = dbc->c_pget(dbc, &key, &pkey, &value, flags)) == 0) {
01819                 zval_dtor(zkey); ZVAL_STRINGL(zkey, (char *) key.data, key.size, 1);
01820                 zval_dtor(zpkey); ZVAL_STRINGL(zpkey, (char *) pkey.data, pkey.size, 1);
01821                 zval_dtor(zvalue); ZVAL_STRINGL(zvalue, (char *) value.data, value.size, 1);
01822                 RETURN_LONG(0);
01823     } 
01824         if(ret != DB_NOTFOUND) {
01825         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01826         add_property_string(self, "lastError", db_strerror(ret), 1);
01827     }
01828     RETURN_LONG(1);
01829 }
01830 /* }}} */
01831 
01832 /* {{{ proto bool Db4Cursor::put(string $key, string $data [, long $flags])
01833  */
01834 ZEND_NAMED_FUNCTION(_wrap_dbc_put)
01835 {
01836     DBC *dbc;
01837     DBT key, value;
01838     char *keyname, *dataname;
01839     int keylen, datalen;
01840     u_int32_t flags = 0;
01841     int ret;
01842 
01843     getDbcFromThis(dbc);
01844     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &keyname, &keylen, 
01845           &dataname, &datalen, &flags) == FAILURE) 
01846     {
01847         return;
01848     }
01849     memset(&key, 0, sizeof(DBT));
01850     key.data = keyname;
01851     key.size = keylen;
01852     memset(&value, 0, sizeof(DBT));
01853     value.data = dataname;
01854     value.size = datalen;
01855     if((ret = dbc->c_put(dbc, &key, &value, flags)) == 0) {
01856         RETURN_TRUE;
01857     }
01858     php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
01859     RETURN_FALSE;
01860     
01861 }
01862 /* }}} */
01863 
01864 /* }}} */
01865 
01866 /* {{{ DB4Env method definitions
01867  */
01868 
01869 /* {{{ php_db4_error ( zend_error wrapper )
01870  */
01871 
01872 void php_db4_error(const DB_ENV *dp, const char *errpfx, const char *msg)
01873 {
01874         TSRMLS_FETCH();
01875     php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s %s\n", errpfx, msg);
01876 }
01877 /* }}} */
01878 
01879 /* {{{ proto object DB4Env::Db4Env([long $flags])
01880  */
01881 ZEND_NAMED_FUNCTION(_wrap_new_DbEnv) 
01882 {
01883     DB_ENV *dbenv;
01884     u_int32_t flags = 0;
01885 
01886     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE)
01887     {
01888         return;
01889     }
01890     if(my_db_env_create(&dbenv, flags) != 0) {
01891         php_error_docref(NULL TSRMLS_CC, E_WARNING, "bad things here: %s:%d\n", __FILE__, __LINE__);
01892         RETURN_FALSE;
01893     }
01894 #ifndef HAVE_MOD_DB4
01895         DbEnv::wrap_DB_ENV(dbenv);
01896 #endif  
01897     dbenv->set_errcall(dbenv, php_db4_error);
01898     setDbEnv(this_ptr, dbenv TSRMLS_CC);
01899 }
01900 /* }}} */
01901 
01902 /* {{{ proto bool DB4Env::close([long $flags])
01903  */
01904 ZEND_NAMED_FUNCTION(_wrap_db_env_close) 
01905 {
01906     struct php_DB_ENV *pdb;
01907     DbEnv *dbe;
01908     u_int32_t flags = 0;
01909     int ret;
01910     
01911     pdb = php_db4_getPhpDbEnvFromObj(getThis() TSRMLS_CC);
01912     if(!pdb || !pdb->dbenv) { 
01913       RETURN_FALSE;
01914     }
01915     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) {
01916         RETURN_FALSE;
01917     }
01918     dbe = DbEnv::get_DbEnv(pdb->dbenv);
01919     dbe->close(flags);
01920     pdb->dbenv = NULL;
01921     RETURN_TRUE;
01922 }
01923 /* }}} */
01924 
01925 /* {{{ proto bool DB4Env::dbremove(object $txn, string $file [, string $database [, long flags]])
01926  */
01927 ZEND_NAMED_FUNCTION(_wrap_db_env_dbremove) 
01928 {
01929     DB_ENV *dbenv;
01930     DB_TXN *txn;
01931     zval *txn_obj;
01932     char *filename=NULL, *database=NULL;
01933     int filenamelen, databaselen;
01934     u_int32_t flags = 0;
01935 
01936     getDbEnvFromThis(dbenv);
01937     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O!s|sl", &txn_obj, db_txn_ce, 
01938          &filename, &filenamelen, &database, &databaselen, &flags) == FAILURE) 
01939     {
01940         return;
01941     }
01942     if(txn_obj) {
01943         txn = php_db4_getDbTxnFromObj(txn_obj TSRMLS_CC);
01944         flags = 0;
01945     }
01946     if(dbenv->dbremove(dbenv, txn, filename, database, flags) == 0) {
01947         RETURN_TRUE;
01948     }
01949     RETURN_FALSE;
01950 }
01951 /* }}} */
01952 
01953 /* {{{ proto bool DB4Env::dbrename(object $txn, string $file, string $database, string $newdatabase [, long flags])
01954  */
01955 ZEND_NAMED_FUNCTION(_wrap_db_env_dbrename) 
01956 {
01957     DB_ENV *dbenv;
01958     DB_TXN *txn;
01959     zval *txn_obj;
01960     char *filename=NULL, *database=NULL, *newname=NULL;
01961     int filenamelen, databaselen, newnamelen;
01962     u_int32_t flags = 0;
01963 
01964     getDbEnvFromThis(dbenv);
01965     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O!sss|l", &txn_obj, db_txn_ce, 
01966          &filename, &filenamelen, &database, &databaselen, 
01967          &newname, &newnamelen, &flags) == FAILURE) 
01968     {
01969         return;
01970     }
01971     if(txn_obj) {
01972         txn = php_db4_getDbTxnFromObj(txn_obj TSRMLS_CC);
01973         flags = 0;
01974     }
01975     if(dbenv->dbrename(dbenv, txn, filename, database, newname, flags) == 0) {
01976         RETURN_TRUE;
01977     }
01978     RETURN_FALSE;
01979 }
01980 /* }}} */
01981 
01982 /* {{{ proto bool DB4Env::open(string $home [, long flags [, long mode]])
01983  */
01984 ZEND_NAMED_FUNCTION(_wrap_db_env_open) 
01985 {
01986     DB_ENV *dbenv;
01987     zval *self;
01988     char *home = NULL;
01989     long  homelen;
01990     u_int32_t flags = DB_CREATE  | DB_INIT_LOCK | DB_INIT_LOG | \
01991             DB_INIT_MPOOL | DB_INIT_TXN ;
01992     int mode = 0666;
01993     int ret;
01994 
01995     getDbEnvFromThis(dbenv);
01996     self = getThis();
01997     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!ll", &home, &homelen, 
01998         &flags, &mode) == FAILURE)
01999     {
02000         return;
02001     }
02002     if((ret = dbenv->open(dbenv, home, flags, mode) != 0)) {
02003         php_error_docref(NULL TSRMLS_CC, E_WARNING, "open(%s, %d, %o) failed: %s (%d) %s:%d\n", home, flags, mode, strerror(ret), ret, __FILE__, __LINE__);
02004         RETURN_FALSE;
02005     }
02006         if(home) add_property_stringl(self, "home", home, homelen, 1);
02007 }
02008 /* }}} */
02009 
02010 /* {{{ proto bool DB4Env::remove(string $home [, long flags])
02011  */
02012 ZEND_NAMED_FUNCTION(_wrap_db_env_remove)
02013 {
02014     DB_ENV *dbenv;
02015         DbEnv *dbe;
02016     zval *self;
02017     char *home;
02018     long homelen;
02019     u_int32_t flags = 0;
02020     self = getThis();
02021     getDbEnvFromThis(dbenv);
02022         dbe = DbEnv::get_DbEnv(dbenv);
02023     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &home, &homelen, &flags) == FAILURE)
02024     {
02025         return;
02026     }
02027     RETURN_BOOL(dbe->remove(home, flags)?0:1);
02028 }
02029 /* }}} */
02030 
02031 /* {{{ proto bool DB4Env::set_data_dir(string $dir)
02032  */
02033 ZEND_NAMED_FUNCTION(_wrap_db_env_set_data_dir)
02034 {
02035     DB_ENV *dbenv;
02036     zval *self;
02037     char *dir;
02038     long dirlen;
02039     self = getThis();
02040     getDbEnvFromThis(dbenv);
02041     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &dir, &dirlen) == FAILURE)
02042     {
02043         return;
02044     }
02045     RETURN_BOOL(dbenv->set_data_dir(dbenv, dir)?0:1);
02046 }
02047 /* }}} */
02048 
02049 /* {{{ proto object Db4Env::txn_begin([object $parent_txn [, long $flags]])
02050  */
02051 ZEND_NAMED_FUNCTION(_wrap_db_env_txn_begin) 
02052 {
02053     DB_ENV *dbenv;
02054     DB_TXN *txn, *parenttxn = NULL;
02055     zval *self;
02056     zval *cursor_array;
02057     zval *parenttxn_obj = NULL;
02058     u_int32_t flags = 0;
02059     int ret;
02060 
02061     self = getThis();
02062     getDbEnvFromThis(dbenv);
02063     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|Ol", &parenttxn_obj, db_txn_ce, 
02064          &flags) == FAILURE) 
02065     {
02066         return;
02067     }
02068     if(parenttxn_obj) {
02069         parenttxn = php_db4_getDbTxnFromObj(parenttxn_obj TSRMLS_CC);
02070     }
02071     if((ret = dbenv->txn_begin(dbenv, parenttxn, &txn, flags)) != 0) {
02072         php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", db_strerror(ret));
02073         add_property_string(self, "lastError", db_strerror(ret), 1);
02074         RETURN_FALSE;
02075     }
02076     object_init_ex(return_value, db_txn_ce);
02077     MAKE_STD_ZVAL(cursor_array);
02078     array_init(cursor_array);
02079     add_property_zval(return_value, "openCursors", cursor_array);
02080     setDbTxn(return_value, txn TSRMLS_CC);
02081 }
02082 /* }}} */
02083 
02084 /* {{{ Db4Env::txn_checkpoint(long $kbytes, long $minutes [, long $flags])
02085  */
02086 ZEND_NAMED_FUNCTION(_wrap_db_env_txn_checkpoint)
02087 {
02088     DB_ENV *dbenv;
02089     zval *self;
02090     u_int32_t kbytes = 0;
02091     u_int32_t mins = 0;
02092     u_int32_t flags = 0;
02093     int ret;
02094 
02095     self = getThis();
02096     getDbEnvFromThis(dbenv);
02097     if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|l", &kbytes, &mins, &flags) == FAILURE) 
02098     {
02099         return;
02100     }
02101     if((ret = dbenv->txn_checkpoint(dbenv, kbytes, mins, flags)) != 0) {
02102         add_property_string(self, "lastError", db_strerror(ret), 1);
02103         RETURN_FALSE;
02104     }
02105     RETURN_TRUE;
02106 }
02107 /* }}} */
02108 
02109 /* }}} end db4env */
02110 
02111 /*
02112  * Local variables:
02113  * tab-width: 4
02114   c-basic-offset: 4
02115  * End:
02116  * vim600: noet sw=4 ts=4 fdm=marker
02117  * vim<600: noet sw=4 ts=4
02118  */

Generated on Sun Dec 25 12:14:43 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2