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