• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

rpmdb/dbconfig.c

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

Generated on Mon Nov 29 2010 05:18:46 for rpm by  doxygen 1.7.2