00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _DB_H_
00012 #define _DB_H_
00013
00014 #ifndef __NO_SYSTEM_INCLUDES
00015 #include <sys/types.h>
00016
00017 #include <stdio.h>
00018 #endif
00019
00020 #if defined(__cplusplus)
00021 extern "C" {
00022 #endif
00023
00024
00025
00026
00027
00028 #ifdef __MWERKS__
00029 #pragma enumsalwaysint on
00030 #endif
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #undef __P
00044 #if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER)
00045 #define __P(protos) protos
00046 #else
00047 #define const
00048 #define __P(protos) ()
00049 #endif
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #ifndef __BIT_TYPES_DEFINED__
00065 #define __BIT_TYPES_DEFINED__
00066 typedef unsigned char u_int8_t;
00067 typedef short int16_t;
00068 typedef unsigned short u_int16_t;
00069 typedef int int32_t;
00070 typedef unsigned int u_int32_t;
00071 #endif
00072
00073 #if !defined(_WINSOCKAPI_)
00074 typedef unsigned char u_char;
00075 typedef unsigned short u_short;
00076 typedef unsigned int u_int;
00077 typedef unsigned long u_long;
00078 #endif
00079 typedef int ssize_t;
00080
00081 #define DB_VERSION_MAJOR 3
00082 #define DB_VERSION_MINOR 1
00083 #define DB_VERSION_PATCH 14
00084 #define DB_VERSION_STRING "Sleepycat Software: Berkeley DB 3.1.14: (June 7, 2000)"
00085
00086 typedef u_int32_t db_pgno_t;
00087 typedef u_int16_t db_indx_t;
00088 #define DB_MAX_PAGES 0xffffffff
00089
00090 typedef u_int32_t db_recno_t;
00091 #define DB_MAX_RECORDS 0xffffffff
00092
00093
00094 struct __db; typedef struct __db DB;
00095 #ifdef DB_DBM_HSEARCH
00096 typedef struct __db DBM;
00097 #endif
00098 struct __db_bt_stat; typedef struct __db_bt_stat DB_BTREE_STAT;
00099 struct __db_dbt; typedef struct __db_dbt DBT;
00100 struct __db_env; typedef struct __db_env DB_ENV;
00101 struct __db_h_stat; typedef struct __db_h_stat DB_HASH_STAT;
00102 struct __db_ilock; typedef struct __db_ilock DB_LOCK_ILOCK;
00103 struct __db_lock_stat; typedef struct __db_lock_stat DB_LOCK_STAT;
00104 struct __db_lock_u; typedef struct __db_lock_u DB_LOCK;
00105 struct __db_lockreq; typedef struct __db_lockreq DB_LOCKREQ;
00106 struct __db_log_stat; typedef struct __db_log_stat DB_LOG_STAT;
00107 struct __db_lsn; typedef struct __db_lsn DB_LSN;
00108 struct __db_mpool_finfo;typedef struct __db_mpool_finfo DB_MPOOL_FINFO;
00109 struct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT;
00110 struct __db_mpool_stat; typedef struct __db_mpool_stat DB_MPOOL_STAT;
00111 struct __db_mpoolfile; typedef struct __db_mpoolfile DB_MPOOLFILE;
00112 struct __db_qam_stat; typedef struct __db_qam_stat DB_QUEUE_STAT;
00113 struct __db_txn; typedef struct __db_txn DB_TXN;
00114 struct __db_txn_active; typedef struct __db_txn_active DB_TXN_ACTIVE;
00115 struct __db_txn_stat; typedef struct __db_txn_stat DB_TXN_STAT;
00116 struct __dbc; typedef struct __dbc DBC;
00117 struct __dbc_internal; typedef struct __dbc_internal DBC_INTERNAL;
00118 struct __fh_t; typedef struct __fh_t DB_FH;
00119 struct __key_range; typedef struct __key_range DB_KEY_RANGE;
00120
00121
00122 struct __db_dbt {
00123
00124
00125
00126 void *data;
00127 u_int32_t size;
00128
00129 u_int32_t ulen;
00130 u_int32_t dlen;
00131 u_int32_t doff;
00132
00133 #define DB_DBT_ISSET 0x001
00134 #define DB_DBT_MALLOC 0x002
00135 #define DB_DBT_PARTIAL 0x004
00136 #define DB_DBT_REALLOC 0x008
00137 #define DB_DBT_USERMEM 0x010
00138 #define DB_DBT_DUPOK 0x020
00139 u_int32_t flags;
00140
00141 void *app_private;
00142 };
00143
00144
00145
00146
00147 #define DB_CXX_NO_EXCEPTIONS 0x000001
00148
00149
00150
00151
00152 #define DB_CLIENT 0x000002
00153
00154
00155
00156
00157 #define DB_XA_CREATE 0x000002
00158
00159
00160
00161
00162 #define DB_CREATE 0x000001
00163 #define DB_NOMMAP 0x000002
00164 #define DB_THREAD 0x000004
00165
00166
00167
00168
00169 #define DB_FORCE 0x000008
00170 #define DB_INIT_CDB 0x000010
00171 #define DB_INIT_LOCK 0x000020
00172 #define DB_INIT_LOG 0x000040
00173 #define DB_INIT_MPOOL 0x000080
00174 #define DB_INIT_TXN 0x000100
00175 #define DB_RECOVER 0x000200
00176 #define DB_RECOVER_FATAL 0x000400
00177 #define DB_SYSTEM_MEM 0x000800
00178 #define DB_TXN_NOSYNC 0x001000
00179 #define DB_USE_ENVIRON 0x002000
00180 #define DB_USE_ENVIRON_ROOT 0x004000
00181
00182
00183
00184
00185 #define DB_LOCKDOWN 0x008000
00186 #define DB_PRIVATE 0x010000
00187
00188
00189
00190
00191
00192 #define DB_TXN_SYNC 0x000001
00193 #define DB_TXN_NOWAIT 0x000002
00194
00195
00196
00197
00198 #define DB_EXCL 0x000008
00199 #define DB_RDONLY 0x000010
00200 #define DB_TRUNCATE 0x000020
00201 #define DB_FCNTL_LOCKING 0x000040
00202 #define DB_ODDFILESIZE 0x000080
00203 #define DB_RDWRMASTER 0x000100
00204
00205
00206
00207
00208
00209
00210
00211
00212 #define DB_AGGRESSIVE 0x0001
00213 #define DB_NOORDERCHK 0x0002
00214 #define DB_ORDERCHKONLY 0x0004
00215 #define DB_PR_PAGE 0x0008
00216 #define DB_PR_HEADERS 0x0010
00217 #define DB_PR_RECOVERYTEST 0x0020
00218 #define DB_SALVAGE 0x0040
00219 #define DB_VRFY_FLAGMASK 0xffff
00220
00221
00222
00223
00224
00225 #define DB_UPGRADE 0x000001
00226
00227
00228
00229
00230
00231 #define DB_LOCK_NORUN 0
00232 #define DB_LOCK_DEFAULT 1
00233 #define DB_LOCK_OLDEST 2
00234 #define DB_LOCK_RANDOM 3
00235 #define DB_LOCK_YOUNGEST 4
00236
00237
00238
00239
00240 #define DB_DUP 0x0001
00241 #define DB_DUPSORT 0x0002
00242 #define DB_RECNUM 0x0004
00243 #define DB_RENUMBER 0x0008
00244 #define DB_REVSPLITOFF 0x0010
00245 #define DB_SNAPSHOT 0x0020
00246
00247
00248
00249
00250 #define DB_JOIN_NOSORT 0x0001
00251
00252 typedef enum {
00253 DB_TXN_ABORT,
00254 DB_TXN_BACKWARD_ROLL,
00255 DB_TXN_FORWARD_ROLL,
00256 DB_TXN_OPENFILES
00257 } db_recops;
00258
00259 #define DB_UNDO(op) ((op) == DB_TXN_ABORT || (op) == DB_TXN_BACKWARD_ROLL)
00260 #define DB_REDO(op) ((op) == DB_TXN_FORWARD_ROLL)
00261
00262 struct __db_env {
00263
00264
00265
00266 FILE *db_errfile;
00267 const char *db_errpfx;
00268
00269 void (*db_errcall) __P((const char *, char *));
00270 void (*db_feedback) __P((DB_ENV *, int, int));
00271 void (*db_paniccall) __P((DB_ENV *, int));
00272 int (*db_recovery_init) __P((DB_ENV *));
00273
00274
00275
00276
00277
00278
00279 #define DB_VERB_CHKPOINT 0x0001
00280 #define DB_VERB_DEADLOCK 0x0002
00281 #define DB_VERB_RECOVERY 0x0004
00282 #define DB_VERB_WAITSFOR 0x0008
00283 u_int32_t verbose;
00284
00285
00286 u_int8_t *lk_conflicts;
00287 u_int32_t lk_modes;
00288 u_int32_t lk_max;
00289 u_int32_t lk_detect;
00290
00291
00292 u_int32_t lg_bsize;
00293 u_int32_t lg_max;
00294
00295
00296 u_int32_t mp_gbytes;
00297 u_int32_t mp_bytes;
00298 size_t mp_size;
00299 int mp_ncache;
00300 size_t mp_mmapsize;
00301
00302
00303 u_int32_t tx_max;
00304 time_t tx_timestamp;
00305 int (*tx_recover)
00306 __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
00307
00308
00309
00310
00311 int db_panic;
00312
00313
00314 char *db_home;
00315 char *db_log_dir;
00316 char *db_tmp_dir;
00317
00318 char **db_data_dir;
00319 int data_cnt;
00320 int data_next;
00321
00322 int db_mode;
00323
00324 void *reginfo;
00325 DB_FH *lockfhp;
00326 long shm_key;
00327
00328 void *lg_handle;
00329
00330 void *lk_handle;
00331
00332 void *mp_handle;
00333
00334 void *tx_handle;
00335
00336 int (**dtab)
00337 __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
00338 size_t dtab_size;
00339
00340 void *cl_handle;
00341 long cl_id;
00342
00343 int dblocal_ref;
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353 struct {
00354 struct __db_env *tqe_next;
00355 struct __db_env **tqe_prev;
00356 } links;
00357 int xa_rmid;
00358 DB_TXN *xa_txn;
00359
00360 void *cj_internal;
00361
00362
00363 int (*close) __P((DB_ENV *, u_int32_t));
00364 void (*err) __P((const DB_ENV *, int, const char *, ...));
00365 void (*errx) __P((const DB_ENV *, const char *, ...));
00366 int (*open) __P((DB_ENV *, const char *, u_int32_t, int));
00367 int (*remove) __P((DB_ENV *, const char *, u_int32_t));
00368 int (*set_data_dir) __P((DB_ENV *, const char *));
00369 void (*set_errcall) __P((DB_ENV *, void (*)(const char *, char *)));
00370 void (*set_errfile) __P((DB_ENV *, FILE *));
00371 void (*set_errpfx) __P((DB_ENV *, const char *));
00372 int (*set_feedback) __P((DB_ENV *, void (*)(DB_ENV *, int, int)));
00373 int (*set_paniccall) __P((DB_ENV *, void (*)(DB_ENV *, int)));
00374 int (*set_recovery_init) __P((DB_ENV *, int (*)(DB_ENV *)));
00375 int (*set_server) __P((DB_ENV *, char *, long, long, u_int32_t));
00376 int (*set_shm_key) __P((DB_ENV *, long));
00377 int (*set_tmp_dir) __P((DB_ENV *, const char *));
00378 int (*set_verbose) __P((DB_ENV *, u_int32_t, int));
00379
00380 int (*set_lg_bsize) __P((DB_ENV *, u_int32_t));
00381 int (*set_lg_dir) __P((DB_ENV *, const char *));
00382 int (*set_lg_max) __P((DB_ENV *, u_int32_t));
00383
00384 int (*set_lk_conflicts) __P((DB_ENV *, u_int8_t *, int));
00385 int (*set_lk_detect) __P((DB_ENV *, u_int32_t));
00386 int (*set_lk_max) __P((DB_ENV *, u_int32_t));
00387
00388 int (*set_mp_mmapsize) __P((DB_ENV *, size_t));
00389 int (*set_cachesize) __P((DB_ENV *, u_int32_t, u_int32_t, int));
00390
00391 int (*set_tx_max) __P((DB_ENV *, u_int32_t));
00392 int (*set_tx_recover) __P((DB_ENV *,
00393 int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *)));
00394 int (*set_tx_timestamp) __P((DB_ENV *, time_t *));
00395
00396 #ifdef CONFIG_TEST
00397 #define DB_TEST_PREOPEN 1
00398 #define DB_TEST_POSTOPEN 2
00399 #define DB_TEST_POSTLOGMETA 3
00400 #define DB_TEST_POSTLOG 4
00401 #define DB_TEST_POSTSYNC 5
00402 #define DB_TEST_PRERENAME 6
00403 #define DB_TEST_POSTRENAME 7
00404 int test_abort;
00405 int test_copy;
00406 #endif
00407
00408 #define DB_ENV_CDB 0x00001
00409 #define DB_ENV_CREATE 0x00002
00410 #define DB_ENV_DBLOCAL 0x00004
00411 #define DB_ENV_LOCKDOWN 0x00008
00412 #define DB_ENV_NOMMAP 0x00010
00413 #define DB_ENV_OPEN_CALLED 0x00020
00414 #define DB_ENV_PRIVATE 0x00040
00415 #define DB_ENV_RPCCLIENT 0x00080
00416 #define DB_ENV_STANDALONE 0x00100
00417 #define DB_ENV_SYSTEM_MEM 0x00200
00418 #define DB_ENV_THREAD 0x00400
00419 #define DB_ENV_TXN_NOSYNC 0x00800
00420 #define DB_ENV_USER_ALLOC 0x01000
00421 u_int32_t flags;
00422 };
00423
00424
00425
00426
00427
00428
00429
00430
00431 typedef enum {
00432 DB_BTREE=1,
00433 DB_HASH,
00434 DB_RECNO,
00435 DB_QUEUE,
00436 DB_UNKNOWN
00437 } DBTYPE;
00438
00439 #define DB_BTREEVERSION 8
00440 #define DB_BTREEOLDVER 6
00441 #define DB_BTREEMAGIC 0x053162
00442
00443 #define DB_HASHVERSION 7
00444 #define DB_HASHOLDVER 4
00445 #define DB_HASHMAGIC 0x061561
00446
00447 #define DB_QAMVERSION 2
00448 #define DB_QAMOLDVER 1
00449 #define DB_QAMMAGIC 0x042253
00450
00451 #define DB_LOGVERSION 2
00452 #define DB_LOGOLDVER 2
00453 #define DB_LOGMAGIC 0x040988
00454
00455
00456
00457
00458
00459 #define DB_AFTER 1
00460 #define DB_APPEND 2
00461 #define DB_BEFORE 3
00462 #define DB_CACHED_COUNTS 4
00463 #define DB_CHECKPOINT 5
00464 #define DB_CONSUME 6
00465 #define DB_CURLSN 7
00466 #define DB_CURRENT 8
00467 #define DB_FIRST 9
00468 #define DB_FLUSH 10
00469 #define DB_GET_BOTH 11
00470 #define DB_GET_BOTHC 12
00471 #define DB_GET_RECNO 13
00472 #define DB_JOIN_ITEM 14
00473 #define DB_KEYFIRST 15
00474 #define DB_KEYLAST 16
00475 #define DB_LAST 17
00476 #define DB_NEXT 18
00477 #define DB_NEXT_DUP 19
00478 #define DB_NEXT_NODUP 20
00479 #define DB_NODUPDATA 21
00480 #define DB_NOOVERWRITE 22
00481 #define DB_NOSYNC 23
00482 #define DB_POSITION 24
00483 #define DB_POSITIONI 25
00484 #define DB_PREV 26
00485 #define DB_PREV_NODUP 27
00486 #define DB_RECORDCOUNT 28
00487 #define DB_SET 29
00488 #define DB_SET_RANGE 30
00489 #define DB_SET_RECNO 31
00490 #define DB_WRITECURSOR 32
00491 #define DB_WRITELOCK 33
00492
00493
00494 #define DB_OPFLAGS_MASK 0x000000ff
00495 #define DB_RMW 0x80000000
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514 #define DB_INCOMPLETE (-30999)
00515 #define DB_KEYEMPTY (-30998)
00516 #define DB_KEYEXIST (-30997)
00517 #define DB_LOCK_DEADLOCK (-30996)
00518 #define DB_LOCK_NOTGRANTED (-30995)
00519 #define DB_NOSERVER (-30994)
00520 #define DB_NOSERVER_HOME (-30993)
00521 #define DB_NOSERVER_ID (-30992)
00522 #define DB_NOTFOUND (-30991)
00523 #define DB_OLD_VERSION (-30990)
00524 #define DB_RUNRECOVERY (-30989)
00525 #define DB_VERIFY_BAD (-30988)
00526
00527
00528 #define DB_DELETED (-30899)
00529 #define DB_NEEDSPLIT (-30898)
00530 #define DB_SWAPBYTES (-30897)
00531 #define DB_TXN_CKP (-30896)
00532 #define DB_VERIFY_FATAL (-30895)
00533
00534 #define DB_FILE_ID_LEN 20
00535
00536
00537 struct __db {
00538
00539
00540
00541 u_int32_t pgsize;
00542
00543
00544 void (*db_feedback) __P((DB *, int, int));
00545 void *(*db_malloc) __P((size_t));
00546 void *(*db_realloc) __P((void *, size_t));
00547 int (*dup_compare) __P((const DBT *, const DBT *));
00548
00549
00550
00551
00552 DB_ENV *dbenv;
00553
00554 DBTYPE type;
00555
00556 DB_MPOOLFILE *mpf;
00557
00558 void *mutexp;
00559
00560 u_int8_t fileid[DB_FILE_ID_LEN];
00561
00562 #define DB_LOGFILEID_INVALID -1
00563 int32_t log_fileid;
00564 db_pgno_t meta_pgno;
00565 DB_TXN *open_txn;
00566
00567 long cl_id;
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582 DB_FH *saved_open_fhp;
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592 struct {
00593 struct __db *tqe_next;
00594 struct __db **tqe_prev;
00595 } links;
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607 struct {
00608 struct __dbc *tqh_first;
00609 struct __dbc **tqh_last;
00610 } free_queue;
00611 struct {
00612 struct __dbc *tqh_first;
00613 struct __dbc **tqh_last;
00614 } active_queue;
00615 struct {
00616 struct __dbc *tqh_first;
00617 struct __dbc **tqh_last;
00618 } join_queue;
00619
00620 void *bt_internal;
00621 void *cj_internal;
00622 void *h_internal;
00623 void *q_internal;
00624 void *xa_internal;
00625
00626
00627 int (*close) __P((DB *, u_int32_t));
00628 int (*cursor) __P((DB *, DB_TXN *, DBC **, u_int32_t));
00629 int (*del) __P((DB *, DB_TXN *, DBT *, u_int32_t));
00630 void (*err) __P((DB *, int, const char *, ...));
00631 void (*errx) __P((DB *, const char *, ...));
00632 int (*fd) __P((DB *, int *));
00633 int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
00634 int (*get_byteswapped) __P((DB *));
00635 DBTYPE
00636 (*get_type) __P((DB *));
00637 int (*join) __P((DB *, DBC **, DBC **, u_int32_t));
00638 int (*key_range) __P((DB *,
00639 DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t));
00640 int (*open) __P((DB *,
00641 const char *, const char *, DBTYPE, u_int32_t, int));
00642 int (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
00643 int (*remove) __P((DB *, const char *, const char *, u_int32_t));
00644 int (*rename) __P((DB *,
00645 const char *, const char *, const char *, u_int32_t));
00646 int (*set_cachesize) __P((DB *, u_int32_t, u_int32_t, int));
00647 int (*set_dup_compare) __P((DB *, int (*)(const DBT *, const DBT *)));
00648 void (*set_errcall) __P((DB *, void (*)(const char *, char *)));
00649 void (*set_errfile) __P((DB *, FILE *));
00650 void (*set_errpfx) __P((DB *, const char *));
00651 int (*set_feedback) __P((DB *, void (*)(DB *, int, int)));
00652 int (*set_flags) __P((DB *, u_int32_t));
00653 int (*set_lorder) __P((DB *, int));
00654 int (*set_malloc) __P((DB *, void *(*)(size_t)));
00655 int (*set_pagesize) __P((DB *, u_int32_t));
00656 int (*set_paniccall) __P((DB *, void (*)(DB_ENV *, int)));
00657 int (*set_realloc) __P((DB *, void *(*)(void *, size_t)));
00658 int (*stat) __P((DB *, void *, void *(*)(size_t), u_int32_t));
00659 int (*sync) __P((DB *, u_int32_t));
00660 int (*upgrade) __P((DB *, const char *, u_int32_t));
00661 int (*verify) __P((DB *,
00662 const char *, const char *, FILE *, u_int32_t));
00663
00664 int (*set_bt_compare) __P((DB *, int (*)(const DBT *, const DBT *)));
00665 int (*set_bt_maxkey) __P((DB *, u_int32_t));
00666 int (*set_bt_minkey) __P((DB *, u_int32_t));
00667 int (*set_bt_prefix) __P((DB *, size_t (*)(const DBT *, const DBT *)));
00668
00669 int (*set_h_ffactor) __P((DB *, u_int32_t));
00670 int (*set_h_hash) __P((DB *, u_int32_t (*)(const void *, u_int32_t)));
00671 int (*set_h_nelem) __P((DB *, u_int32_t));
00672
00673 int (*set_re_delim) __P((DB *, int));
00674 int (*set_re_len) __P((DB *, u_int32_t));
00675 int (*set_re_pad) __P((DB *, int));
00676 int (*set_re_source) __P((DB *, const char *));
00677
00678 #define DB_OK_BTREE 0x01
00679 #define DB_OK_HASH 0x02
00680 #define DB_OK_QUEUE 0x04
00681 #define DB_OK_RECNO 0x08
00682 u_int32_t am_ok;
00683
00684 #define DB_AM_DISCARD 0x00001
00685 #define DB_AM_DUP 0x00002
00686 #define DB_AM_DUPSORT 0x00004
00687 #define DB_AM_INMEM 0x00008
00688 #define DB_AM_PGDEF 0x00010
00689 #define DB_AM_RDONLY 0x00020
00690 #define DB_AM_RECOVER 0x00040
00691 #define DB_AM_SUBDB 0x00080
00692 #define DB_AM_SWAP 0x00100
00693 #define DB_BT_RECNUM 0x00200
00694 #define DB_BT_REVSPLIT 0x00400
00695 #define DB_DBM_ERROR 0x00800
00696 #define DB_OPEN_CALLED 0x01000
00697 #define DB_RE_DELIMITER 0x02000
00698 #define DB_RE_FIXEDLEN 0x04000
00699 #define DB_RE_PAD 0x08000
00700 #define DB_RE_RENUMBER 0x10000
00701 #define DB_RE_SNAPSHOT 0x20000
00702 u_int32_t flags;
00703 };
00704
00705
00706
00707
00708
00709 struct __db_ilock {
00710 db_pgno_t pgno;
00711 u_int8_t fileid[DB_FILE_ID_LEN];
00712 #define DB_RECORD_LOCK 1
00713 #define DB_PAGE_LOCK 2
00714 u_int8_t type;
00715 };
00716
00717
00718
00719
00720
00721
00722 struct __db_lock_u {
00723 size_t off;
00724 u_int32_t ndx;
00725
00726 u_int32_t gen;
00727 };
00728
00729
00730 struct __dbc {
00731 DB *dbp;
00732 DB_TXN *txn;
00733
00734
00735
00736
00737
00738
00739
00740 struct {
00741 DBC *tqe_next;
00742 DBC **tqe_prev;
00743 } links;
00744
00745 DBC *opd;
00746
00747 DBT rkey;
00748 DBT rdata;
00749
00750 u_int32_t lid;
00751 u_int32_t locker;
00752 DBT lock_dbt;
00753 DB_LOCK_ILOCK lock;
00754 DB_LOCK mylock;
00755
00756 long cl_id;
00757
00758 DBTYPE dbtype;
00759
00760 DBC_INTERNAL *internal;
00761
00762 int (*c_close) __P((DBC *));
00763 int (*c_count) __P((DBC *, db_recno_t *, u_int32_t));
00764 int (*c_del) __P((DBC *, u_int32_t));
00765 int (*c_dup) __P((DBC *, DBC **, u_int32_t));
00766 int (*c_get) __P((DBC *, DBT *, DBT *, u_int32_t));
00767 int (*c_put) __P((DBC *, DBT *, DBT *, u_int32_t));
00768
00769
00770 int (*c_am_close) __P((DBC *, db_pgno_t, int *));
00771 int (*c_am_del) __P((DBC *));
00772 int (*c_am_destroy) __P((DBC *));
00773 int (*c_am_get) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
00774 int (*c_am_put) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
00775 int (*c_am_writelock) __P((DBC *));
00776
00777 #define DBC_ACTIVE 0x001
00778 #define DBC_OPD 0x002
00779 #define DBC_RECOVER 0x004
00780
00781
00782 #define DBC_RMW 0x008
00783 #define DBC_WRITECURSOR 0x010
00784 #define DBC_WRITEDUP 0x020
00785 #define DBC_WRITER 0x040
00786 #define DBC_TRANSIENT 0x080
00787 u_int32_t flags;
00788 };
00789
00790
00791 struct __key_range {
00792 double less;
00793 double equal;
00794 double greater;
00795 };
00796
00797
00798 struct __db_bt_stat {
00799 u_int32_t bt_magic;
00800 u_int32_t bt_version;
00801 u_int32_t bt_metaflags;
00802 u_int32_t bt_nkeys;
00803 u_int32_t bt_ndata;
00804 u_int32_t bt_pagesize;
00805 u_int32_t bt_maxkey;
00806 u_int32_t bt_minkey;
00807 u_int32_t bt_re_len;
00808 u_int32_t bt_re_pad;
00809 u_int32_t bt_levels;
00810 u_int32_t bt_int_pg;
00811 u_int32_t bt_leaf_pg;
00812 u_int32_t bt_dup_pg;
00813 u_int32_t bt_over_pg;
00814 u_int32_t bt_free;
00815 u_int32_t bt_int_pgfree;
00816 u_int32_t bt_leaf_pgfree;
00817 u_int32_t bt_dup_pgfree;
00818 u_int32_t bt_over_pgfree;
00819 };
00820
00821
00822 struct __db_qam_stat {
00823 u_int32_t qs_magic;
00824 u_int32_t qs_version;
00825 u_int32_t qs_metaflags;
00826 u_int32_t qs_nkeys;
00827 u_int32_t qs_ndata;
00828 u_int32_t qs_pagesize;
00829 u_int32_t qs_pages;
00830 u_int32_t qs_re_len;
00831 u_int32_t qs_re_pad;
00832 u_int32_t qs_pgfree;
00833 u_int32_t qs_start;
00834 u_int32_t qs_first_recno;
00835 u_int32_t qs_cur_recno;
00836 };
00837
00838
00839 struct __db_h_stat {
00840 u_int32_t hash_magic;
00841 u_int32_t hash_version;
00842 u_int32_t hash_metaflags;
00843 u_int32_t hash_nkeys;
00844 u_int32_t hash_ndata;
00845 u_int32_t hash_pagesize;
00846 u_int32_t hash_nelem;
00847 u_int32_t hash_ffactor;
00848 u_int32_t hash_buckets;
00849 u_int32_t hash_free;
00850 u_int32_t hash_bfree;
00851 u_int32_t hash_bigpages;
00852 u_int32_t hash_big_bfree;
00853 u_int32_t hash_overflows;
00854 u_int32_t hash_ovfl_free;
00855 u_int32_t hash_dup;
00856 u_int32_t hash_dup_free;
00857 };
00858
00859 int db_create __P((DB **, DB_ENV *, u_int32_t));
00860 int db_env_create __P((DB_ENV **, u_int32_t));
00861 int db_env_set_func_close __P((int (*)(int)));
00862 int db_env_set_func_dirfree __P((void (*)(char **, int)));
00863 int db_env_set_func_dirlist __P((int (*)(const char *, char ***, int *)));
00864 int db_env_set_func_exists __P((int (*)(const char *, int *)));
00865 int db_env_set_func_free __P((void (*)(void *)));
00866 int db_env_set_func_fsync __P((int (*)(int)));
00867 int db_env_set_func_ioinfo __P((int (*)(const char *,
00868 int, u_int32_t *, u_int32_t *, u_int32_t *)));
00869 int db_env_set_func_malloc __P((void *(*)(size_t)));
00870 int db_env_set_func_map __P((int (*)(char *, size_t, int, int, void **)));
00871 int db_env_set_func_open __P((int (*)(const char *, int, ...)));
00872 int db_env_set_func_read __P((ssize_t (*)(int, void *, size_t)));
00873 int db_env_set_func_realloc __P((void *(*)(void *, size_t)));
00874 int db_env_set_func_rename __P((int (*)(const char *, const char *)));
00875 int db_env_set_func_seek
00876 __P((int (*)(int, size_t, db_pgno_t, u_int32_t, int, int)));
00877 int db_env_set_func_sleep __P((int (*)(u_long, u_long)));
00878 int db_env_set_func_unlink __P((int (*)(const char *)));
00879 int db_env_set_func_unmap __P((int (*)(void *, size_t)));
00880 int db_env_set_func_write __P((ssize_t (*)(int, const void *, size_t)));
00881 int db_env_set_func_yield __P((int (*)(void)));
00882 int db_env_set_mutexlocks __P((int));
00883 int db_env_set_pageyield __P((int));
00884 int db_env_set_panicstate __P((int));
00885 int db_env_set_region_init __P((int));
00886 int db_env_set_tas_spins __P((u_int32_t));
00887 char *db_strerror __P((int));
00888 char *db_version __P((int *, int *, int *));
00889
00890
00891
00892
00893 #define DB_LOCKVERSION 1
00894
00895
00896 #define DB_LOCK_NOWAIT 0x01
00897 #define DB_LOCK_RECORD 0x02
00898 #define DB_LOCK_UPGRADE 0x04
00899
00900
00901 #define DB_LOCK_CONFLICT 0x01
00902
00903
00904
00905
00906
00907
00908
00909 typedef enum {
00910 DB_LOCK_DUMP=0,
00911 DB_LOCK_GET,
00912 DB_LOCK_INHERIT,
00913 DB_LOCK_PUT,
00914 DB_LOCK_PUT_ALL,
00915 DB_LOCK_PUT_OBJ
00916 } db_lockop_t;
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929 typedef enum {
00930 DB_LOCK_NG=0,
00931 DB_LOCK_READ,
00932 DB_LOCK_WRITE,
00933 DB_LOCK_IWRITE,
00934 DB_LOCK_IREAD,
00935 DB_LOCK_IWR
00936 } db_lockmode_t;
00937
00938
00939
00940
00941 typedef enum {
00942 DB_LSTAT_ABORTED,
00943 DB_LSTAT_ERR,
00944 DB_LSTAT_FREE,
00945 DB_LSTAT_HELD,
00946 DB_LSTAT_NOGRANT,
00947 DB_LSTAT_PENDING,
00948
00949
00950 DB_LSTAT_WAITING
00951 } db_status_t;
00952
00953
00954 struct __db_lockreq {
00955 db_lockop_t op;
00956 db_lockmode_t mode;
00957 u_int32_t locker;
00958 DBT *obj;
00959 DB_LOCK lock;
00960 };
00961
00962
00963
00964
00965
00966
00967 #define DB_LOCK_RW_N 3
00968 extern const u_int8_t db_rw_conflicts[];
00969
00970
00971 #define DB_LOCK_RIW_N 6
00972 extern const u_int8_t db_riw_conflicts[];
00973
00974 struct __db_lock_stat {
00975 u_int32_t st_lastid;
00976 u_int32_t st_maxlocks;
00977 u_int32_t st_nmodes;
00978 u_int32_t st_nlockers;
00979 u_int32_t st_maxnlockers;
00980 u_int32_t st_nconflicts;
00981 u_int32_t st_nrequests;
00982 u_int32_t st_nreleases;
00983 u_int32_t st_nnowaits;
00984
00985 u_int32_t st_ndeadlocks;
00986 u_int32_t st_region_wait;
00987 u_int32_t st_region_nowait;
00988 u_int32_t st_regsize;
00989 };
00990
00991 int lock_detect __P((DB_ENV *, u_int32_t, u_int32_t, int *));
00992 int lock_get __P((DB_ENV *,
00993 u_int32_t, u_int32_t, const DBT *, db_lockmode_t, DB_LOCK *));
00994 int lock_id __P((DB_ENV *, u_int32_t *));
00995 int lock_put __P((DB_ENV *, DB_LOCK *));
00996 int lock_stat __P((DB_ENV *, DB_LOCK_STAT **, void *(*)(size_t)));
00997 int lock_vec __P((DB_ENV *,
00998 u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **));
00999
01000
01001
01002
01003
01004 #define DB_ARCH_ABS 0x001
01005 #define DB_ARCH_DATA 0x002
01006 #define DB_ARCH_LOG 0x004
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017 struct __db_lsn {
01018 u_int32_t file;
01019 u_int32_t offset;
01020 };
01021
01022
01023 struct __db_log_stat {
01024 u_int32_t st_magic;
01025 u_int32_t st_version;
01026 int st_mode;
01027 u_int32_t st_lg_bsize;
01028 u_int32_t st_lg_max;
01029 u_int32_t st_w_bytes;
01030 u_int32_t st_w_mbytes;
01031 u_int32_t st_wc_bytes;
01032 u_int32_t st_wc_mbytes;
01033 u_int32_t st_wcount;
01034 u_int32_t st_wcount_fill;
01035 u_int32_t st_scount;
01036 u_int32_t st_region_wait;
01037 u_int32_t st_region_nowait;
01038 u_int32_t st_cur_file;
01039 u_int32_t st_cur_offset;
01040 u_int32_t st_regsize;
01041 };
01042
01043 int log_archive __P((DB_ENV *, char **[], u_int32_t, void *(*)(size_t)));
01044 int log_compare __P((const DB_LSN *, const DB_LSN *));
01045 int log_file __P((DB_ENV *, const DB_LSN *, char *, size_t));
01046 int log_flush __P((DB_ENV *, const DB_LSN *));
01047 int log_get __P((DB_ENV *, DB_LSN *, DBT *, u_int32_t));
01048 int log_put __P((DB_ENV *, DB_LSN *, const DBT *, u_int32_t));
01049 int log_register __P((DB_ENV *, DB *, const char *));
01050 int log_stat __P((DB_ENV *, DB_LOG_STAT **, void *(*)(size_t)));
01051 int log_unregister __P((DB_ENV *, DB *));
01052
01053
01054
01055
01056
01057 #define DB_MPOOL_CREATE 0x001
01058 #define DB_MPOOL_LAST 0x002
01059 #define DB_MPOOL_NEW 0x004
01060 #define DB_MPOOL_NEW_GROUP 0x008
01061
01062
01063 #define DB_MPOOL_CLEAN 0x001
01064 #define DB_MPOOL_DIRTY 0x002
01065 #define DB_MPOOL_DISCARD 0x004
01066
01067
01068 struct __db_mpool_stat {
01069 u_int32_t st_cache_hit;
01070 u_int32_t st_cache_miss;
01071 u_int32_t st_map;
01072 u_int32_t st_page_create;
01073 u_int32_t st_page_in;
01074 u_int32_t st_page_out;
01075 u_int32_t st_ro_evict;
01076 u_int32_t st_rw_evict;
01077 u_int32_t st_hash_buckets;
01078 u_int32_t st_hash_searches;
01079 u_int32_t st_hash_longest;
01080 u_int32_t st_hash_examined;
01081 u_int32_t st_page_clean;
01082 u_int32_t st_page_dirty;
01083 u_int32_t st_page_trickle;
01084 u_int32_t st_region_wait;
01085 u_int32_t st_region_nowait;
01086 u_int32_t st_gbytes;
01087 u_int32_t st_bytes;
01088 u_int32_t st_ncache;
01089 u_int32_t st_regsize;
01090 };
01091
01092
01093 struct __db_mpool_finfo {
01094 int ftype;
01095 DBT *pgcookie;
01096 u_int8_t *fileid;
01097 int32_t lsn_offset;
01098 u_int32_t clear_len;
01099 };
01100
01101
01102 struct __db_mpool_fstat {
01103 char *file_name;
01104 size_t st_pagesize;
01105 u_int32_t st_cache_hit;
01106 u_int32_t st_cache_miss;
01107 u_int32_t st_map;
01108 u_int32_t st_page_create;
01109 u_int32_t st_page_in;
01110 u_int32_t st_page_out;
01111 };
01112
01113 int memp_fclose __P((DB_MPOOLFILE *));
01114 int memp_fget __P((DB_MPOOLFILE *, db_pgno_t *, u_int32_t, void *));
01115 int memp_fopen __P((DB_ENV *, const char *,
01116 u_int32_t, int, size_t, DB_MPOOL_FINFO *, DB_MPOOLFILE **));
01117 int memp_fput __P((DB_MPOOLFILE *, void *, u_int32_t));
01118 int memp_fset __P((DB_MPOOLFILE *, void *, u_int32_t));
01119 int memp_fsync __P((DB_MPOOLFILE *));
01120 int memp_register __P((DB_ENV *, int,
01121 int (*)(DB_ENV *, db_pgno_t, void *, DBT *),
01122 int (*)(DB_ENV *, db_pgno_t, void *, DBT *)));
01123 int memp_stat __P((DB_ENV *,
01124 DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, void *(*)(size_t)));
01125 int memp_sync __P((DB_ENV *, DB_LSN *));
01126 int memp_trickle __P((DB_ENV *, int, int *));
01127
01128
01129
01130
01131 #define DB_TXNVERSION 1
01132
01133
01134 #define DB_TXN_BACKWARD_ROLL 1
01135 #define DB_TXN_FORWARD_ROLL 2
01136 #define DB_TXN_OPENFILES 3
01137 #define DB_TXN_REDO 4
01138 #define DB_TXN_UNDO 5
01139
01140
01141
01142
01143 struct __db_txn_active {
01144 u_int32_t txnid;
01145 u_int32_t parentid;
01146 DB_LSN lsn;
01147 };
01148
01149 struct __db_txn_stat {
01150 DB_LSN st_last_ckp;
01151 DB_LSN st_pending_ckp;
01152 time_t st_time_ckp;
01153 u_int32_t st_last_txnid;
01154 u_int32_t st_maxtxns;
01155 u_int32_t st_naborts;
01156 u_int32_t st_nbegins;
01157 u_int32_t st_ncommits;
01158 u_int32_t st_nactive;
01159 u_int32_t st_maxnactive;
01160 DB_TXN_ACTIVE
01161 *st_txnarray;
01162 u_int32_t st_region_wait;
01163 u_int32_t st_region_nowait;
01164 u_int32_t st_regsize;
01165 };
01166
01167 int txn_abort __P((DB_TXN *));
01168 int txn_begin __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t));
01169 int txn_checkpoint __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t));
01170 int txn_commit __P((DB_TXN *, u_int32_t));
01171 u_int32_t txn_id __P((DB_TXN *));
01172 int txn_prepare __P((DB_TXN *));
01173 int txn_stat __P((DB_ENV *, DB_TXN_STAT **, void *(*)(size_t)));
01174
01175 #ifndef DB_DBM_HSEARCH
01176 #define DB_DBM_HSEARCH 0
01177 #endif
01178 #if DB_DBM_HSEARCH != 0
01179
01180
01181
01182 #define DBM_INSERT 0
01183 #define DBM_REPLACE 1
01184
01185
01186
01187
01188
01189 #define DBM_SUFFIX ".db"
01190
01191 #if defined(_XPG4_2)
01192 typedef struct {
01193 char *dptr;
01194 size_t dsize;
01195 } datum;
01196 #else
01197 typedef struct {
01198 char *dptr;
01199 int dsize;
01200 } datum;
01201 #endif
01202
01203
01204
01205
01206
01207
01208
01209
01210 #define dbminit(a) __db_dbm_init(a)
01211 #define dbmclose __db_dbm_close
01212 #if !defined(__cplusplus)
01213 #define delete(a) __db_dbm_delete(a)
01214 #endif
01215 #define fetch(a) __db_dbm_fetch(a)
01216 #define firstkey __db_dbm_firstkey
01217 #define nextkey(a) __db_dbm_nextkey(a)
01218 #define store(a, b) __db_dbm_store(a, b)
01219
01220
01221 int __db_dbm_close __P((void));
01222 int __db_dbm_dbrdonly __P((void));
01223 int __db_dbm_delete __P((datum));
01224 int __db_dbm_dirf __P((void));
01225 datum __db_dbm_fetch __P((datum));
01226 datum __db_dbm_firstkey __P((void));
01227 int __db_dbm_init __P((char *));
01228 datum __db_dbm_nextkey __P((datum));
01229 int __db_dbm_pagf __P((void));
01230 int __db_dbm_store __P((datum, datum));
01231
01232
01233
01234
01235
01236 #define dbm_clearerr(a) __db_ndbm_clearerr(a)
01237 #define dbm_close(a) __db_ndbm_close(a)
01238 #define dbm_delete(a, b) __db_ndbm_delete(a, b)
01239 #define dbm_dirfno(a) __db_ndbm_dirfno(a)
01240 #define dbm_error(a) __db_ndbm_error(a)
01241 #define dbm_fetch(a, b) __db_ndbm_fetch(a, b)
01242 #define dbm_firstkey(a) __db_ndbm_firstkey(a)
01243 #define dbm_nextkey(a) __db_ndbm_nextkey(a)
01244 #define dbm_open(a, b, c) __db_ndbm_open(a, b, c)
01245 #define dbm_pagfno(a) __db_ndbm_pagfno(a)
01246 #define dbm_rdonly(a) __db_ndbm_rdonly(a)
01247 #define dbm_store(a, b, c, d) __db_ndbm_store(a, b, c, d)
01248
01249
01250 int __db_ndbm_clearerr __P((DBM *));
01251 void __db_ndbm_close __P((DBM *));
01252 int __db_ndbm_delete __P((DBM *, datum));
01253 int __db_ndbm_dirfno __P((DBM *));
01254 int __db_ndbm_error __P((DBM *));
01255 datum __db_ndbm_fetch __P((DBM *, datum));
01256 datum __db_ndbm_firstkey __P((DBM *));
01257 datum __db_ndbm_nextkey __P((DBM *));
01258 DBM *__db_ndbm_open __P((const char *, int, int));
01259 int __db_ndbm_pagfno __P((DBM *));
01260 int __db_ndbm_rdonly __P((DBM *));
01261 int __db_ndbm_store __P((DBM *, datum, datum, int));
01262
01263
01264
01265
01266 typedef enum {
01267 FIND, ENTER
01268 } ACTION;
01269
01270 typedef struct entry {
01271 char *key;
01272 char *data;
01273 } ENTRY;
01274
01275
01276
01277
01278
01279 #define hcreate(a) __db_hcreate(a)
01280 #define hdestroy __db_hdestroy
01281 #define hsearch(a, b) __db_hsearch(a, b)
01282
01283
01284 int __db_hcreate __P((size_t));
01285 void __db_hdestroy __P((void));
01286 ENTRY *__db_hsearch __P((ENTRY, ACTION));
01287 #endif
01288
01289
01290
01291
01292
01293 #ifdef __MWERKS__
01294 #pragma enumsalwaysint reset
01295 #endif
01296
01297 #if defined(__cplusplus)
01298 }
01299 #endif
01300
01301 #endif