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

Generated on Sun Aug 18 14:30:39 2013 for rpm by  doxygen 1.4.4