Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

rpmdb/dbconfig.c

Go to the documentation of this file.
00001 
00005 #include "system.h"
00006 
00007 #include <rpmlib.h>
00008 #include <rpmmacro.h>
00009 
00010 #define _RPMDB_INTERNAL
00011 #include "rpmdb.h"
00012 #include "debug.h"
00013 
00014 /*@access rpmdb@*/
00015 /*@access dbiIndex@*/
00016 /*@access dbiIndexSet@*/
00017 
00018 #if (DB_VERSION_MAJOR == 3) || (DB_VERSION_MAJOR == 4)
00019 #define __USE_DB3       1
00020 
00021 /*@-exportlocal -exportheadervar@*/
00022 /*@unchecked@*/
00023 struct _dbiIndex db3dbi;
00024 /*@=exportlocal =exportheadervar@*/
00025 
00026 /*@unchecked@*/
00027 static int dbi_use_cursors;
00028 
00029 /*@unchecked@*/
00030 static int dbi_tear_down;
00031 
00032 /*@-compmempass -immediatetrans -exportlocal -exportheadervar@*/
00035 /*@unchecked@*/
00036 struct poptOption rdbOptions[] = {
00037  /* XXX DB_CXX_NO_EXCEPTIONS */
00038 #if defined(DB_CLIENT)
00039  { "client",    0,POPT_BIT_SET, &db3dbi.dbi_ecflags, DB_CLIENT,
00040         NULL, NULL },
00041 #endif
00042 #if defined(DB_RPCCLIENT)
00043  { "client",    0,POPT_BIT_SET, &db3dbi.dbi_ecflags, DB_RPCCLIENT,
00044         NULL, NULL },
00045  { "rpcclient", 0,POPT_BIT_SET, &db3dbi.dbi_ecflags, DB_RPCCLIENT,
00046         NULL, NULL },
00047 #endif
00048 
00049  { "xa_create", 0,POPT_BIT_SET, &db3dbi.dbi_cflags, DB_XA_CREATE,
00050         NULL, NULL },
00051 
00052 /* DB_ENV->open and DB->open */
00053 #if defined(DB_AUTO_COMMIT)
00054  { "auto_commit", 0,POPT_BIT_SET, &db3dbi.dbi_oeflags, DB_AUTO_COMMIT,
00055         NULL, NULL },
00056 #endif
00057  { "create",    0,POPT_BIT_SET, &db3dbi.dbi_oeflags, DB_CREATE,
00058         NULL, NULL },
00059 #if defined(DB_MULTIVERSION)
00060  { "multiversion", 0,POPT_BIT_SET, &db3dbi.dbi_oeflags, DB_MULTIVERSION,
00061         NULL, NULL },
00062 #endif
00063  { "nommap",    0,POPT_BIT_SET, &db3dbi.dbi_oeflags, DB_NOMMAP,
00064         NULL, NULL },
00065  { "thread",    0,POPT_BIT_SET, &db3dbi.dbi_oeflags, DB_THREAD,
00066         NULL, NULL },
00067 
00068  { "force",     0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_FORCE,
00069         NULL, NULL },
00070 
00071 /* DB_ENV->set_flags */
00072 /* DB_ENV->get_flags */
00073  { "cdb",       0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_INIT_CDB,
00074         NULL, NULL },
00075  { "lock",      0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_INIT_LOCK,
00076         NULL, NULL },
00077  { "log",       0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_INIT_LOG,
00078         NULL, NULL },
00079  { "mpool",     0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_INIT_MPOOL,
00080         NULL, NULL },
00081 #if defined(DB_INIT_REP)
00082  { "rep", 0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_INIT_REP,
00083         NULL, NULL },
00084 #endif
00085  { "txn",       0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_INIT_TXN,
00086         NULL, NULL },
00087 
00088 #ifdef  DYING   /* XXX compatibly defined to 0 in db-4.5.20 */
00089  { "joinenv",   0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_JOINENV,
00090         NULL, NULL },
00091 #endif
00092  { "lockdown",  0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_LOCKDOWN,
00093         NULL, NULL },
00094  { "private",   0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_PRIVATE,
00095         NULL, NULL },
00096  { "recover",   0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_RECOVER,
00097         NULL, NULL },
00098  { "recover_fatal", 0,POPT_BIT_SET,     &db3dbi.dbi_eflags, DB_RECOVER_FATAL,
00099         NULL, NULL },
00100 #if defined(DB_REGISTER)
00101  { "register", 0,POPT_BIT_SET,  &db3dbi.dbi_eflags, DB_REGISTER,
00102         NULL, NULL },
00103 #endif
00104  { "shared",    0,POPT_BIT_SET, &db3dbi.dbi_eflags, DB_SYSTEM_MEM,
00105         NULL, NULL },
00106  { "txn_nosync", 0,POPT_BIT_SET,        &db3dbi.dbi_eflags, DB_TXN_NOSYNC,
00107         NULL, NULL },
00108  { "use_environ_root", 0,POPT_BIT_SET,  &db3dbi.dbi_eflags, DB_USE_ENVIRON_ROOT,
00109         NULL, NULL },
00110  { "use_environ", 0,POPT_BIT_SET,       &db3dbi.dbi_eflags, DB_USE_ENVIRON,
00111         NULL, NULL },
00112 #if defined(DB_IGNORE_LEASE)
00113  { "ignore_lease", 0,POPT_BIT_SET,     &db3dbi.dbi_eflags, DB_IGNORE_LEASE,
00114        NULL, NULL },
00115 #endif
00116 
00117  { "txn_sync",  0,POPT_BIT_SET, &db3dbi.dbi_tflags, DB_TXN_SYNC,
00118         NULL, NULL },
00119  { "txn_nowait",0,POPT_BIT_SET, &db3dbi.dbi_tflags, DB_TXN_NOWAIT,
00120         NULL, NULL },
00121 #if defined(DB_TXN_WAIT)
00122  { "txn_wait",0,POPT_BIT_SET,  &db3dbi.dbi_tflags, DB_TXN_WAIT,
00123        NULL, NULL },
00124 #endif
00125 
00126 #if defined(NOTYET)
00127 DB_AUTO_COMMIT
00128 DB_CDB_ALLDB
00129 DB_DIRECT_DB
00130 DB_DIRECT_LOG
00131 DB_DSYNC_DB
00132 DB_DSYNC_LOG
00133 DB_LOG_AUTOREMOVE
00134 DB_LOG_BUFFER_FULL      ???
00135 DB_LOG_INMEMORY
00136 DB_NOLOCKING
00137 DB_MULTIVERSION
00138 DB_NOMMAP
00139 DB_NOPANIC
00140 DB_OVERWRITE
00141 DB_PANIC_ENVIRONMENT
00142 DB_REGION_INIT
00143 DB_TIME_NOTGRANTED
00144 DB_TXN_NOSYNC
00145 DB_TXN_SNAPSHOT
00146 DB_WRITE_NOSYNC
00147 DB_YIELDCPU
00148 #endif
00149 
00150 /* DB->set_flags */
00151 /* DB->get_flags */
00152 #if defined(NOTYET)
00153 DB_CHKSUM
00154 DB_ENCRYPT
00155 DB_TXN_NOT_DURABLE
00156 
00157 DB_DUP          BTREE HASH
00158 DB_DUPSORT      BTREE HASH
00159 DB_RECNUM       BTREE
00160 DB_REVSPLITOFF  BTREE
00161 
00162 DB_INORDER      QUEUE
00163 DB_RENUMBER     RECNO
00164 DB_SNAPSHOT     RECNO
00165 #endif
00166 
00167 /* DB->open */
00168  { "excl",      0,POPT_BIT_SET, &db3dbi.dbi_oflags, DB_EXCL,
00169         NULL, NULL },
00170  { "fcntl_locking",0,POPT_BIT_SET,      &db3dbi.dbi_oflags, DB_FCNTL_LOCKING,
00171         NULL, NULL },
00172 #if defined(DB_NO_AUTO_COMMIT) && defined(NOTYET)
00173  { "noautocommit", 0,POPT_BIT_SET,      &db3dbi.dbi_oflags, DB_NO_AUTO_COMMIT,
00174         NULL, NULL },
00175 #endif
00176  { "rdonly",    0,POPT_BIT_SET, &db3dbi.dbi_oflags, DB_RDONLY,
00177         NULL, NULL },
00178 #if defined(DB_RDWRMASTER) && defined(NOTYET)
00179  { "rdwrmaster", 0,POPT_BIT_SET,        &db3dbi.dbi_oflags, DB_RDWRMASTER,
00180         NULL, NULL },
00181 #endif
00182 #if defined(NOTYET)
00183 DB_READ_UNCOMITTED
00184 #endif
00185  { "truncate",  0,POPT_BIT_SET, &db3dbi.dbi_oflags, DB_TRUNCATE,
00186         NULL, NULL },
00187 #if defined(DB_WRITEOPEN)
00188  { "writeopen", 0,POPT_BIT_SET, &db3dbi.dbi_oflags, DB_WRITEOPEN,
00189         NULL, NULL },
00190 #endif
00191 
00192  { "btree",     0,POPT_ARG_VAL,         &db3dbi.dbi_type, DB_BTREE,
00193         NULL, NULL },
00194  { "hash",      0,POPT_ARG_VAL,         &db3dbi.dbi_type, DB_HASH,
00195         NULL, NULL },
00196  { "recno",     0,POPT_ARG_VAL,         &db3dbi.dbi_type, DB_RECNO,
00197         NULL, NULL },
00198  { "queue",     0,POPT_ARG_VAL,         &db3dbi.dbi_type, DB_QUEUE,
00199         NULL, NULL },
00200  { "unknown",   0,POPT_ARG_VAL,         &db3dbi.dbi_type, DB_UNKNOWN,
00201         NULL, NULL },
00202 
00203  { "root",      0,POPT_ARG_STRING,      &db3dbi.dbi_root, 0,
00204         NULL, NULL },
00205  { "home",      0,POPT_ARG_STRING,      &db3dbi.dbi_home, 0,
00206         NULL, NULL },
00207  { "file",      0,POPT_ARG_STRING,      &db3dbi.dbi_file, 0,
00208         NULL, NULL },
00209  { "subfile",   0,POPT_ARG_STRING,      &db3dbi.dbi_subfile, 0,
00210         NULL, NULL },
00211  { "mode",      0,POPT_ARG_INT,         &db3dbi.dbi_mode, 0,
00212         NULL, NULL },
00213  { "perms",     0,POPT_ARG_INT,         &db3dbi.dbi_perms, 0,
00214         NULL, NULL },
00215  { "shmkey",    0,POPT_ARG_LONG,        &db3dbi.dbi_shmkey, 0,
00216         NULL, NULL },
00217  { "tmpdir",    0,POPT_ARG_STRING,      &db3dbi.dbi_tmpdir, 0,
00218         NULL, NULL },
00219 
00220  { "host",      0,POPT_ARG_STRING,      &db3dbi.dbi_host, 0,
00221         NULL, NULL },
00222  { "server",    0,POPT_ARG_STRING,      &db3dbi.dbi_host, 0,
00223         NULL, NULL },
00224  { "cl_timeout", 0,POPT_ARG_LONG,       &db3dbi.dbi_cl_timeout, 0,
00225         NULL, NULL },
00226  { "sv_timeout", 0,POPT_ARG_LONG,       &db3dbi.dbi_sv_timeout, 0,
00227         NULL, NULL },
00228 
00229  { "verify",    0,POPT_ARG_NONE,        &db3dbi.dbi_verify_on_close, 0,
00230         NULL, NULL },
00231  { "teardown",  0,POPT_ARG_NONE,        &dbi_tear_down, 0,
00232         NULL, NULL },
00233  { "usecursors",0,POPT_ARG_NONE,        &dbi_use_cursors, 0,
00234         NULL, NULL },
00235  { "usedbenv",  0,POPT_ARG_NONE,        &db3dbi.dbi_use_dbenv, 0,
00236         NULL, NULL },
00237  { "nofsync",   0,POPT_ARG_NONE,        &db3dbi.dbi_no_fsync, 0,
00238         NULL, NULL },
00239  { "nodbsync",  0,POPT_ARG_NONE,        &db3dbi.dbi_no_dbsync, 0,
00240         NULL, NULL },
00241  { "lockdbfd",  0,POPT_ARG_NONE,        &db3dbi.dbi_lockdbfd, 0,
00242         NULL, NULL },
00243  { "temporary", 0,POPT_ARG_NONE,        &db3dbi.dbi_temporary, 0,
00244         NULL, NULL },
00245  { "debug",     0,POPT_ARG_NONE,        &db3dbi.dbi_debug, 0,
00246         NULL, NULL },
00247 
00248 /* XXX set_alloc */
00249  { "cachesize", 0,POPT_ARG_INT,         &db3dbi.dbi_cachesize, 0,
00250         NULL, NULL },
00251 /* XXX set_dup_compare */
00252 /* XXX set_encrypt */
00253  { "errpfx",    0,POPT_ARG_STRING,      &db3dbi.dbi_errpfx, 0,
00254         NULL, NULL },
00255 /* XXX set_feedback */
00256  { "lorder",    0,POPT_ARG_INT,         &db3dbi.dbi_lorder, 0,
00257         NULL, NULL },
00258  { "pagesize",  0,POPT_ARG_INT,         &db3dbi.dbi_pagesize, 0,
00259         NULL, NULL },
00260 
00261  { "region_init", 0,POPT_ARG_VAL,       &db3dbi.dbi_region_init, 1,
00262         NULL, NULL },
00263 
00264  { "thread_count", 0,POPT_ARG_INT,      &db3dbi.dbi_thread_count, 0,
00265         NULL, NULL },
00266 
00267 #if defined(DB_VERB_CHKPOINT)
00268  { "chkpoint",  0,POPT_BIT_SET, &db3dbi.dbi_verbose, DB_VERB_CHKPOINT,
00269         NULL, NULL },
00270 #endif
00271  { "deadlock",  0,POPT_BIT_SET, &db3dbi.dbi_verbose, DB_VERB_DEADLOCK,
00272         NULL, NULL },
00273  { "recovery",  0,POPT_BIT_SET, &db3dbi.dbi_verbose, DB_VERB_RECOVERY,
00274         NULL, NULL },
00275 #if defined(DB_VERB_REGISTER)
00276  { "register",  0,POPT_BIT_SET, &db3dbi.dbi_verbose, DB_VERB_REGISTER,
00277         NULL, NULL },
00278 #endif
00279 #if defined(DB_VERB_REPLICATION)
00280  { "replication", 0,POPT_BIT_SET, &db3dbi.dbi_verbose, DB_VERB_REPLICATION,
00281         NULL, NULL },
00282 #endif
00283  { "waitsfor",  0,POPT_BIT_SET, &db3dbi.dbi_verbose, DB_VERB_WAITSFOR,
00284         NULL, NULL },
00285 #if defined(DB_VERB_FILEOPS)
00286  { "fileops",   0,POPT_BIT_SET, &db3dbi.dbi_verbose, DB_VERB_FILEOPS,
00287         NULL, NULL },
00288 #endif
00289 #if defined(DB_VERB_FILEOPS_ALL)
00290  { "fileops_all",0,POPT_BIT_SET,&db3dbi.dbi_verbose, DB_VERB_FILEOPS_ALL,
00291         NULL, NULL },
00292 #endif
00293  { "verbose",   0,POPT_ARG_VAL,         &db3dbi.dbi_verbose, -1,
00294         NULL, NULL },
00295 
00296 /* ==== Locking: */
00297 /* DB_ENV->lock_detect */
00298 /* DB_ENV->set_lk_detect */
00299 /* DB_ENV->get_lk_detect */
00300  { "lk_default",0,POPT_ARG_VAL,         &db3dbi.dbi_lk_detect, DB_LOCK_DEFAULT,
00301         NULL, NULL },
00302  { "lk_expire", 0,POPT_ARG_VAL,         &db3dbi.dbi_lk_detect, DB_LOCK_EXPIRE,
00303         NULL, NULL },
00304 #if defined(DB_LOCK_MAXLOCKS)
00305  { "lk_maxlocks", 0,POPT_ARG_VAL,       &db3dbi.dbi_lk_detect, DB_LOCK_MAXLOCKS,
00306         NULL, NULL },
00307 #endif
00308 #if defined(DB_LOCK_MAXWRITE)
00309  { "lk_maxwrite", 0,POPT_ARG_VAL,       &db3dbi.dbi_lk_detect, DB_LOCK_MAXWRITE,
00310         NULL, NULL },
00311 #endif
00312 #if defined(DB_LOCK_MINLOCKS)
00313  { "lk_minlocks", 0,POPT_ARG_VAL,       &db3dbi.dbi_lk_detect, DB_LOCK_MINLOCKS,
00314         NULL, NULL },
00315 #endif
00316 #if defined(DB_LOCK_MINWRITE)
00317  { "lk_minwrite", 0,POPT_ARG_VAL,       &db3dbi.dbi_lk_detect, DB_LOCK_MINWRITE,
00318         NULL, NULL },
00319 #endif
00320  { "lk_oldest", 0,POPT_ARG_VAL,         &db3dbi.dbi_lk_detect, DB_LOCK_OLDEST,
00321         NULL, NULL },
00322  { "lk_random", 0,POPT_ARG_VAL,         &db3dbi.dbi_lk_detect, DB_LOCK_RANDOM,
00323         NULL, NULL },
00324  { "lk_youngest",0, POPT_ARG_VAL,       &db3dbi.dbi_lk_detect, DB_LOCK_YOUNGEST,
00325         NULL, NULL },
00326 
00327 /* DB_ENV->lock_get */
00328 /* XXX DB_ENV->set_lk_conflicts */
00329 /* XXX DB_ENV->get_lk_conflicts */
00330 #if defined(NOTYET)
00331 DB_LOCK_NOWAIT  /* flags */
00332 
00333 DB_LOCK_READ    /* mode(s) */
00334 DB_LOCK_WRITE
00335 DB_LOCK_IWRITE
00336 DB_LOCK_IREAD
00337 DB_LOCK_IWR
00338 #endif
00339 
00340 /* XXX DB_ENV->set_lk_max_lockers */
00341 /* XXX DB_ENV->get_lk_max_lockers */
00342  { "lk_max_lockers", 0,POPT_ARG_INT,    &db3dbi.dbi_lk_max_lockers, 0,
00343         NULL, NULL },
00344 /* XXX DB_ENV->set_lk_max_locks */
00345 /* XXX DB_ENV->get_lk_max_locks */
00346  { "lk_max_locks", 0,POPT_ARG_INT,      &db3dbi.dbi_lk_max_locks, 0,
00347         NULL, NULL },
00348 /* XXX DB_ENV->set_lk_max_objects */
00349 /* XXX DB_ENV->get_lk_max_objects */
00350  { "lk_max_objects", 0,POPT_ARG_INT,    &db3dbi.dbi_lk_max_objects, 0,
00351         NULL, NULL },
00352 
00353 /* XXX DB_ENV->set_timeout */
00354 #if defined(NOTYET)
00355 DB_SET_LOCK_TIMEOUT
00356 DB_SET_TXN_NOW
00357 DB_SET_TXN_TIMEOUT
00358 #endif
00359 /* XXX DB_ENV->get_timeout */
00360 
00361 /* ==== Logging: */
00362 /* XXX DB_ENV->set_lg_bsize */
00363 /* XXX DB_ENV->get_lg_bsize */
00364  { "lg_bsize",  0,POPT_ARG_INT,         &db3dbi.dbi_lg_bsize, 0,
00365         NULL, NULL },
00366 /* XXX DB_ENV->set_lg_dir */
00367 /* XXX DB_ENV->get_lg_dir */
00368  { "lg_dir",    0,POPT_ARG_STRING,      &db3dbi.dbi_lg_dir, 0,
00369         NULL, NULL },
00370 /* XXX DB_ENV->set_lg_filemode */
00371 /* XXX DB_ENV->get_lg_filemode */
00372  { "lg_filemode", 0,POPT_ARG_INT,       &db3dbi.dbi_lg_filemode, 0,
00373         NULL, NULL },
00374 /* XXX DB_ENV->set_lg_max */
00375 /* XXX DB_ENV->get_lg_max */
00376  { "lg_max",    0,POPT_ARG_INT,         &db3dbi.dbi_lg_max, 0,
00377         NULL, NULL },
00378 /* XXX DB_ENV->set_lg_regionmax */
00379 /* XXX DB_ENV->get_lg_regionmax */
00380  { "lg_regionmax", 0,POPT_ARG_INT,      &db3dbi.dbi_lg_regionmax, 0,
00381         NULL, NULL },
00382 
00383 /* ==== Memory pool: */
00384  { "mp_size",   0,POPT_ARG_INT,         &db3dbi.dbi_cachesize, 0,
00385         NULL, NULL },
00386 /* XXX DB_ENV->set_mp_max_openfd */
00387 /* XXX DB_ENV->set_mp_max_write */
00388  { "mmapsize", 0,POPT_ARG_INT,          &db3dbi.dbi_mmapsize, 0,
00389         NULL, NULL },
00390  { "mp_mmapsize", 0,POPT_ARG_INT,       &db3dbi.dbi_mmapsize, 0,
00391         NULL, NULL },
00392 /* XXX DB_MPOOLFILE->set_clear_len */
00393 /* XXX DB_MPOOLFILE->set_fileid */
00394 /* XXX DB_MPOOLFILE->set_ftype */
00395 /* XXX DB_MPOOLFILE->set_lsn_offset */
00396 /* XXX DB_MPOOLFILE->set_maxsize */
00397 /* XXX DB_MPOOLFILE->set_pgcookie */
00398 /* XXX DB_MPOOLFILE->set_priority */
00399 
00400 /* ==== Mutexes: */
00401 #if defined(NOTYET)
00402 DB_MUTEX_PROCESS_ONLY   mutex_alloc
00403 DB_MUTEX_SELF_BLOCK     mutex_alloc
00404 DB_STAT_CLEAR           mutex_stat*
00405 #endif
00406 /* XXX DB_ENV->mutex_set_align */
00407 /* XXX DB_ENV->mutex_get_align */
00408  { "mutex_align", 0,POPT_ARG_INT,       &db3dbi.dbi_mutex_align, 0,
00409         NULL, NULL },
00410 /* XXX DB_ENV->mutex_set_increment */
00411 /* XXX DB_ENV->mutex_get_increment */
00412  { "mutex_increment", 0,POPT_ARG_INT,   &db3dbi.dbi_mutex_increment, 0,
00413         NULL, NULL },
00414 /* XXX DB_ENV->mutex_set_max */
00415 /* XXX DB_ENV->mutex_get_max */
00416  { "mutex_max", 0,POPT_ARG_INT,         &db3dbi.dbi_mutex_max, 0,
00417         NULL, NULL },
00418 /* XXX DB_ENV->mutex_set_tas_spins */
00419 /* XXX DB_ENV->mutex_get_tas_spins */
00420  { "mutex_tas_spins",   0,POPT_ARG_INT, &db3dbi.dbi_mutex_tas_spins, 0,
00421         NULL, NULL },
00422 
00423 /* ==== Replication: */
00424 /* XXX DB_ENV->rep_set_config */
00425 /* XXX DB_ENV->rep_set_limit */
00426 /* XXX DB_ENV->rep_set_nsites */
00427 /* XXX DB_ENV->rep_set_priority */
00428 /* XXX DB_ENV->rep_set_timeout */
00429 /* XXX DB_ENV->rep_set_transport */
00430 
00431 /* ==== Sequences: */
00432 /* XXX DB_SEQUENCE->set_cachesize */
00433 /* XXX DB_SEQUENCE->get_cachesize */
00434  { "seq_cachesize",     0,POPT_ARG_INT, &db3dbi.dbi_seq_cachesize, 0,
00435         NULL, NULL },
00436 /* XXX DB_SEQUENCE->set_flags */
00437 /* XXX DB_SEQUENCE->get_flags */
00438 #if defined(DB_SEQ_DEC)
00439  { "seq_dec",   0,POPT_BIT_SET,         &db3dbi.dbi_seq_flags, DB_SEQ_DEC,
00440         NULL, NULL },
00441 #endif
00442 #if defined(DB_SEQ_INC)
00443  { "seq_inc",   0,POPT_BIT_SET,         &db3dbi.dbi_seq_flags, DB_SEQ_INC,
00444         NULL, NULL },
00445 #endif
00446 #if defined(DB_SEQ_WRAP)
00447  { "seq_wrap",  0,POPT_BIT_SET,         &db3dbi.dbi_seq_flags, DB_SEQ_WRAP,
00448         NULL, NULL },
00449 #endif
00450 /* XXX DB_SEQUENCE->set_range */
00451 /* XXX DB_SEQUENCE->get_range */
00452 #if defined(NOTYET)             /* needs signed 64bit type */
00453  { "seq_min",   0,POPT_ARG_INT, &db3dbi.dbi_seq_min, 0,
00454         NULL, NULL },
00455  { "seq_max",   0,POPT_ARG_INT, &db3dbi.dbi_seq_max, 0,
00456         NULL, NULL },
00457 #endif
00458 
00459 /* ==== Transactions: */
00460 /* XXX DB_ENV->txn_checkpoint */
00461 /* XXX DB_ENV->txn_recover */
00462 /* XXX DB_ENV->txn_stat */
00463 /* XXX DB_ENV->set_timeout */
00464 /* XXX DB_ENV->get_timeout */
00465  { "tx_max",    0,POPT_ARG_INT,         &db3dbi.dbi_tx_max, 0,
00466         NULL, NULL },
00467 /* XXX DB_ENV->set_tx_timestamp */
00468 
00469 /* XXX set_append_recno */
00470 /* XXX set_bt_compare */
00471 /* XXX set_bt_dup_compare */
00472 /* XXX set_bt_minkey */
00473 /* XXX set_bt_prefix */
00474  { "bt_dup",    0,POPT_BIT_SET, &db3dbi.dbi_bt_flags, DB_DUP,
00475         NULL, NULL },
00476  { "bt_dupsort",0,POPT_BIT_SET, &db3dbi.dbi_bt_flags, DB_DUPSORT,
00477         NULL, NULL },
00478  { "bt_recnum", 0,POPT_BIT_SET, &db3dbi.dbi_bt_flags, DB_RECNUM,
00479         NULL, NULL },
00480  { "bt_revsplitoff", 0,POPT_BIT_SET,    &db3dbi.dbi_bt_flags, DB_REVSPLITOFF,
00481         NULL, NULL },
00482 
00483  { "h_dup",     0,POPT_BIT_SET, &db3dbi.dbi_h_flags, DB_DUP,
00484         NULL, NULL },
00485  { "h_dupsort", 0,POPT_BIT_SET, &db3dbi.dbi_h_flags, DB_DUPSORT,
00486         NULL, NULL },
00487  { "h_ffactor", 0,POPT_ARG_INT,         &db3dbi.dbi_h_ffactor, 0,
00488         NULL, NULL },
00489  { "h_nelem",   0,POPT_ARG_INT,         &db3dbi.dbi_h_nelem, 0,
00490         NULL, NULL },
00491 
00492  { "re_renumber", 0,POPT_BIT_SET,       &db3dbi.dbi_re_flags, DB_RENUMBER,
00493         NULL, NULL },
00494  { "re_snapshot",0,POPT_BIT_SET,        &db3dbi.dbi_re_flags, DB_SNAPSHOT,
00495         NULL, NULL },
00496  { "re_delim",  0,POPT_ARG_INT,         &db3dbi.dbi_re_delim, 0,
00497         NULL, NULL },
00498  { "re_len",    0,POPT_ARG_INT,         &db3dbi.dbi_re_len, 0,
00499         NULL, NULL },
00500  { "re_pad",    0,POPT_ARG_INT,         &db3dbi.dbi_re_pad, 0,
00501         NULL, NULL },
00502  { "re_source", 0,POPT_ARG_STRING,      &db3dbi.dbi_re_source, 0,
00503         NULL, NULL },
00504 
00505  { "q_extentsize", 0,POPT_ARG_INT,      &db3dbi.dbi_q_extentsize, 0,
00506         NULL, NULL },
00507 
00508     POPT_TABLEEND
00509 };
00510 /*@=compmempass =immediatetrans =exportlocal =exportheadervar@*/
00511 
00512 dbiIndex db3Free(dbiIndex dbi)
00513 {
00514     if (dbi) {
00515         dbi->dbi_root = _free(dbi->dbi_root);
00516         dbi->dbi_home = _free(dbi->dbi_home);
00517         dbi->dbi_file = _free(dbi->dbi_file);
00518         dbi->dbi_subfile = _free(dbi->dbi_subfile);
00519         dbi->dbi_tmpdir = _free(dbi->dbi_tmpdir);
00520         dbi->dbi_host = _free(dbi->dbi_host);
00521         dbi->dbi_errpfx = _free(dbi->dbi_errpfx);
00522         dbi->dbi_re_source = _free(dbi->dbi_re_source);
00523         dbi->dbi_stats = _free(dbi->dbi_stats);
00524         dbi = _free(dbi);
00525     }
00526     return dbi;
00527 }
00528 
00529 /*@observer@*/ /*@unchecked@*/
00530 static const char *db3_config_default =
00531     "hash tmpdir=/var/tmp create cdb mpool mp_mmapsize=16Mb mp_size=1Mb perms=0644";
00532 
00533 /*@-bounds@*/
00534 dbiIndex db3New(rpmdb rpmdb, rpmTag rpmtag)
00535 {
00536     dbiIndex dbi = xcalloc(1, sizeof(*dbi));
00537     char dbiTagMacro[128];
00538     char * dbOpts;
00539 
00540     sprintf(dbiTagMacro, "%%{_dbi_config_%s}", tagName(rpmtag));
00541     dbOpts = rpmExpand(dbiTagMacro, NULL);
00542     if (!(dbOpts && *dbOpts && *dbOpts != '%')) {
00543         dbOpts = _free(dbOpts);
00544         dbOpts = rpmExpand("%{_dbi_config}", NULL);
00545         if (!(dbOpts && *dbOpts && *dbOpts != '%')) {
00546             dbOpts = rpmExpand(db3_config_default, NULL);
00547         }
00548     }
00549 
00550     /* Parse the options for the database element(s). */
00551     /*@-branchstate@*/
00552     if (dbOpts && *dbOpts && *dbOpts != '%') {
00553         char *o, *oe;
00554         char *p, *pe;
00555 
00556         memset(&db3dbi, 0, sizeof(db3dbi));
00557 /*=========*/
00558         for (o = dbOpts; o && *o; o = oe) {
00559             struct poptOption *opt;
00560             const char * tok;
00561             int argInfo;
00562 
00563             /* Skip leading white space. */
00564             while (*o && xisspace(*o))
00565                 o++;
00566 
00567             /* Find and terminate next key=value pair. Save next start point. */
00568             for (oe = o; oe && *oe; oe++) {
00569                 if (xisspace(*oe))
00570                     /*@innerbreak@*/ break;
00571                 if (oe[0] == ':' && !(oe[1] == '/' && oe[2] == '/'))
00572                     /*@innerbreak@*/ break;
00573             }
00574             if (oe && *oe)
00575                 *oe++ = '\0';
00576             if (*o == '\0')
00577                 continue;
00578 
00579             /* Separate key from value, save value start (if any). */
00580             for (pe = o; pe && *pe && *pe != '='; pe++)
00581                 {};
00582             p = (pe ? *pe++ = '\0', pe : NULL);
00583 
00584             /* Skip over negation at start of token. */
00585             for (tok = o; *tok == '!'; tok++)
00586                 {};
00587 
00588             /* Find key in option table. */
00589             for (opt = rdbOptions; opt->longName != NULL; opt++) {
00590                 if (strcmp(tok, opt->longName))
00591                     /*@innercontinue@*/ continue;
00592                 /*@innerbreak@*/ break;
00593             }
00594             if (opt->longName == NULL) {
00595                 rpmError(RPMERR_DBCONFIG,
00596                         _("unrecognized db option: \"%s\" ignored.\n"), o);
00597                 continue;
00598             }
00599 
00600             /* Toggle the flags for negated tokens, if necessary. */
00601             argInfo = opt->argInfo;
00602             if (argInfo == POPT_BIT_SET && *o == '!' && ((tok - o) % 2))
00603                 argInfo = POPT_BIT_CLR;
00604 
00605             /* Save value in template as appropriate. */
00606             switch (argInfo & POPT_ARG_MASK) {
00607 
00608             case POPT_ARG_NONE:
00609                 (void) poptSaveInt((int *)opt->arg, argInfo, 1L);
00610                 /*@switchbreak@*/ break;
00611             case POPT_ARG_VAL:
00612                 (void) poptSaveInt((int *)opt->arg, argInfo, (long)opt->val);
00613                 /*@switchbreak@*/ break;
00614             case POPT_ARG_STRING:
00615             {   const char ** t = opt->arg;
00616                 /*@-mods@*/
00617                 if (t) {
00618 /*@-unqualifiedtrans@*/ /* FIX: opt->arg annotation in popt.h */
00619                     *t = _free(*t);
00620 /*@=unqualifiedtrans@*/
00621                     *t = xstrdup( (p ? p : "") );
00622                 }
00623                 /*@=mods@*/
00624             }   /*@switchbreak@*/ break;
00625 
00626             case POPT_ARG_INT:
00627             case POPT_ARG_LONG:
00628               { long aLong = strtol(p, &pe, 0);
00629                 if (pe) {
00630                     if (!xstrncasecmp(pe, "Mb", 2))
00631                         aLong *= 1024 * 1024;
00632                     else if (!xstrncasecmp(pe, "Kb", 2))
00633                         aLong *= 1024;
00634                     else if (*pe != '\0') {
00635                         rpmError(RPMERR_DBCONFIG,
00636                                 _("%s has invalid numeric value, skipped\n"),
00637                                 opt->longName);
00638                         continue;
00639                     }
00640                 }
00641 
00642                 if ((argInfo & POPT_ARG_MASK) == POPT_ARG_LONG) {
00643                     if (aLong == LONG_MIN || aLong == LONG_MAX) {
00644                         rpmError(RPMERR_DBCONFIG,
00645                                 _("%s has too large or too small long value, skipped\n"),
00646                                 opt->longName);
00647                         continue;
00648                     }
00649                     (void) poptSaveLong((long *)opt->arg, argInfo, aLong);
00650                     /*@switchbreak@*/ break;
00651                 } else {
00652                     if (aLong > INT_MAX || aLong < INT_MIN) {
00653                         rpmError(RPMERR_DBCONFIG,
00654                                 _("%s has too large or too small integer value, skipped\n"),
00655                                 opt->longName);
00656                         continue;
00657                     }
00658                     (void) poptSaveInt((int *)opt->arg, argInfo, aLong);
00659                 }
00660               } /*@switchbreak@*/ break;
00661             default:
00662                 /*@switchbreak@*/ break;
00663             }
00664         }
00665 /*=========*/
00666     }
00667     /*@=branchstate@*/
00668 
00669     dbOpts = _free(dbOpts);
00670 
00671     /*@-assignexpose@*/
00672 /*@i@*/ *dbi = db3dbi;  /* structure assignment */
00673     /*@=assignexpose@*/
00674     memset(&db3dbi, 0, sizeof(db3dbi));
00675 
00676     if (!(dbi->dbi_perms & 0600))
00677         dbi->dbi_perms = 0644;
00678     dbi->dbi_mode = rpmdb->db_mode;
00679     /*@-assignexpose -newreftrans@*/ /* FIX: figger rpmdb/dbi refcounts */
00680 /*@i@*/ dbi->dbi_rpmdb = rpmdb;
00681     /*@=assignexpose =newreftrans@*/
00682     dbi->dbi_rpmtag = rpmtag;
00683     
00684     /*
00685      * Inverted lists have join length of 2, primary data has join length of 1.
00686      */
00687     /*@-sizeoftype@*/
00688     switch (rpmtag) {
00689     case RPMDBI_PACKAGES:
00690     case RPMDBI_DEPENDS:
00691         dbi->dbi_jlen = 1 * sizeof(int_32);
00692         break;
00693     default:
00694         dbi->dbi_jlen = 2 * sizeof(int_32);
00695         break;
00696     }
00697     /*@=sizeoftype@*/
00698 
00699     dbi->dbi_byteswapped = -1;  /* -1 unknown, 0 native order, 1 alien order */
00700 
00701     if (!dbi->dbi_use_dbenv) {          /* db3 dbenv is always used now. */
00702         dbi->dbi_use_dbenv = 1;
00703         dbi->dbi_eflags |= (DB_INIT_MPOOL|DB_JOINENV);
00704         dbi->dbi_mmapsize = 16 * 1024 * 1024;
00705         dbi->dbi_cachesize = 1 * 1024 * 1024;
00706     }
00707 
00708     if ((dbi->dbi_bt_flags | dbi->dbi_h_flags) & DB_DUP)
00709         dbi->dbi_permit_dups = 1;
00710 
00711     /*@-globstate@*/ /* FIX: *(rdbOptions->arg) reachable */
00712     return dbi;
00713     /*@=globstate@*/
00714 }
00715 /*@=bounds@*/
00716 
00717 /*@-boundswrite@*/
00718 const char * prDbiOpenFlags(int dbflags, int print_dbenv_flags)
00719 {
00720     static char buf[256];
00721     struct poptOption *opt;
00722     char * oe;
00723 
00724     oe = buf;
00725     *oe = '\0';
00726     for (opt = rdbOptions; opt->longName != NULL; opt++) {
00727         if (opt->argInfo != POPT_BIT_SET)
00728             continue;
00729         if (print_dbenv_flags) {
00730             if (!(opt->arg == &db3dbi.dbi_oeflags ||
00731                   opt->arg == &db3dbi.dbi_eflags))
00732                 continue;
00733         } else {
00734             if (!(opt->arg == &db3dbi.dbi_oeflags ||
00735                   opt->arg == &db3dbi.dbi_oflags))
00736                 continue;
00737         }
00738         if ((dbflags & opt->val) != opt->val)
00739             continue;
00740         if (oe != buf)
00741             *oe++ = ':';
00742         oe = stpcpy(oe, opt->longName);
00743         dbflags &= ~opt->val;
00744     }
00745     if (dbflags) {
00746         if (oe != buf)
00747             *oe++ = ':';
00748             sprintf(oe, "0x%x", (unsigned)dbflags);
00749     }
00750     return buf;
00751 }
00752 /*@=boundswrite@*/
00753 
00754 #endif

Generated on Wed Feb 6 22:30:19 2008 for rpm by  doxygen 1.4.4