Consolidate changes into rpmdb.c.

CVS patchset: 3683
CVS date: 2000/04/18 18:11:43
This commit is contained in:
jbj 2000-04-18 18:11:43 +00:00
parent 24f68f3a0d
commit 588daae4b4
12 changed files with 977 additions and 439 deletions

View File

@ -8,10 +8,10 @@ EXTRA_DIST = falloc.c db0.c db1.c db2.c db3.c
pkgincdir = $(pkgincludedir)
pkginc_HEADERS = \
dbindex.h header.h misc.h rpmio.h rpmlib.h rpmmacro.h rpmurl.h stringbuf.h
header.h misc.h rpmio.h rpmlib.h rpmmacro.h rpmurl.h stringbuf.h
noinst_HEADERS = \
cpio.h depends.h falloc.h fprint.h hash.h install.h \
lookup.h md5.h oldheader.h oldrpmdb.h rpm_malloc.h \
md5.h oldheader.h oldrpmdb.h rpm_malloc.h \
rpmdb.h rpmlead.h signature.h
mylibpaths= -L$(top_builddir)/lib -L$(top_builddir)/popt
@ -19,9 +19,9 @@ mylibs= -lrpm -lpopt @INTLLIBS@ @LIBMISC@
lib_LTLIBRARIES = librpm.la
librpm_la_SOURCES = \
cpio.c $(DBLIBOBJS) dbindex.c depends.c \
cpio.c $(DBLIBOBJS) depends.c \
formats.c fprint.c fs.c hash.c header.c install.c \
lookup.c macro.c md5.c md5sum.c \
macro.c md5.c md5sum.c \
messages.c misc.c oldheader.c package.c problems.c query.c \
rebuilddb.c rpmchecksig.c rpmdb.c rpmerr.c rpminstall.c \
rpmio.c rpmlead.c rpmmalloc.c rpmrc.c signature.c stringbuf.c stubs.c \
@ -32,7 +32,7 @@ librpm_la_LIBADD = $(subst .c,.lo,$(DBLIBOBJS))
falloc.lo: falloc.c $(top_srcdir)/system.h rpmio.h falloc.h
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
db3.lo: db3.c $(top_srcdir)/system.h rpmlib.h dbindex.h
db3.lo: db3.c $(top_srcdir)/system.h rpmlib.h rpmdb.h
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
for F in $*.o $*.lo ; do \
@__LD@ -r -o $${F}.o $${F} -L/usr/lib -ldb-3.0 ; \
@ -43,7 +43,7 @@ db3.lo: db3.c $(top_srcdir)/system.h rpmlib.h dbindex.h
rm -f $${F}.o ; \
done
db2.lo: db2.c $(top_srcdir)/system.h rpmlib.h dbindex.h
db2.lo: db2.c $(top_srcdir)/system.h rpmlib.h rpmdb.h
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
for F in $*.o $*.lo ; do \
@__LD@ -r -o $${F}.o $${F} -L/usr/lib -ldb ; \
@ -54,7 +54,7 @@ db2.lo: db2.c $(top_srcdir)/system.h rpmlib.h dbindex.h
rm -f $${F}.o ; \
done
db1.lo: db1.c falloc.lo $(top_srcdir)/system.h rpmlib.h dbindex.h
db1.lo: db1.c falloc.lo $(top_srcdir)/system.h rpmlib.h rpmdb.h
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
for F in $*.o $*.lo ; do \
@__LD@ -r -o $${F}.o $${F} falloc.lo -L/usr/lib -ldb ; \
@ -65,7 +65,7 @@ db1.lo: db1.c falloc.lo $(top_srcdir)/system.h rpmlib.h dbindex.h
rm -f $${F}.o ; \
done
db0.lo: db0.c falloc.lo $(top_srcdir)/system.h rpmlib.h dbindex.h
db0.lo: db0.c falloc.lo $(top_srcdir)/system.h rpmlib.h rpmdb.h
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
for F in $*.o $*.lo ; do \
@__LD@ -r -o $${F}.o $${F} falloc.lo -L/usr/lib -ldb1 ; \

View File

@ -16,7 +16,7 @@ static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
#include "falloc.h"
#include "misc.h"
#include "dbindex.h"
#include "rpmdb.h"
/*@access dbiIndex@*/
/*@access dbiIndexSet@*/
@ -157,7 +157,7 @@ static int db0SearchIndex(dbiIndex dbi, const void * str, size_t len,
const char * sdbir = data.data;
int i;
*set = dbiCreateIndexSet();
*set = xmalloc(sizeof(**set));
(*set)->count = data.size / sizeof(struct _dbiIR);
(*set)->recs = xmalloc((*set)->count * sizeof(*((*set)->recs)));
@ -532,7 +532,7 @@ static int db0put(dbiIndex dbi, void * keyp, size_t keylen,
static int db0close(dbiIndex dbi, unsigned int flags) {
DB * db = GetDB(dbi);
int rc;
int rc = 0;
if (dbi->dbi_rpmtag == 0) {
FD_t pkgs;
@ -552,8 +552,10 @@ static int db0close(dbiIndex dbi, unsigned int flags) {
dbi->dbi_cursor = NULL;
}
rc = db->close(db, 0);
dbi->dbi_db = NULL;
if (db) {
rc = db->close(db, 0);
dbi->dbi_db = NULL;
}
if (dbinfo) {
free(dbinfo);
@ -565,7 +567,10 @@ static int db0close(dbiIndex dbi, unsigned int flags) {
dbi->dbi_dbenv = NULL;
}
#else
rc = db->close(db);
if (db) {
rc = db->close(db);
dbi->dbi_db = NULL;
}
#endif
switch (rc) {

View File

@ -14,7 +14,7 @@ static int _debug = 1;
#include <rpmlib.h>
#include "dbindex.h"
#include "rpmdb.h"
/*@access dbiIndex@*/
/*@access dbiIndexSet@*/
@ -153,7 +153,7 @@ static int db1SearchIndex(dbiIndex dbi, const void * str, size_t len,
DBIR_t dbir = data.data;
int i;
*set = dbiCreateIndexSet();
*set = xmalloc(sizeof(**set));
(*set)->count = data.size / sizeof(*dbir);
(*set)->recs = xmalloc((*set)->count * sizeof(*((*set)->recs)));

View File

@ -6,7 +6,7 @@ static int _debug = 1;
#include <rpmlib.h>
#include "dbindex.h"
#include "rpmdb.h"
/*@access dbiIndex@*/
/*@access dbiIndexSet@*/
@ -277,7 +277,7 @@ static int db2SearchIndex(dbiIndex dbi, const void * str, size_t len,
DBIR_t dbir = data.data;
int i;
*set = dbiCreateIndexSet();
*set = xmalloc(sizeof(**set));
(*set)->count = data.size / sizeof(*dbir);
(*set)->recs = xmalloc((*set)->count * sizeof(*((*set)->recs)));

219
lib/db3.c
View File

@ -1,13 +1,15 @@
#include "system.h"
static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
static int _use_cursors = 0;
static int __do_dbcursor_rmw = 0;
#include <db3/db.h>
#include <rpmlib.h>
#include <rpmmacro.h>
#include "dbindex.h"
#include "rpmdb.h"
/*@access dbiIndex@*/
/*@access dbiIndexSet@*/
@ -184,12 +186,12 @@ static /*@observer@*/ const char * db_strerror(int error)
return ("DB_OLDVERSION: Database requires a version upgrade");
case DB_RUNRECOVERY:
return ("DB_RUNRECOVERY: Fatal error, run database recovery");
#else
#else /* __USE_DB3 */
case DB_LOCK_NOTHELD:
return ("DB_LOCK_NOTHELD:");
case DB_REGISTERED:
return ("DB_REGISTERED:");
#endif
#endif /* __USE_DB3 */
default:
{
/*
@ -273,11 +275,11 @@ static int db_fini(dbiIndex dbi)
xx = cvtdberr(dbi, "dbenv->remove", rc, _debug);
}
#else
#else /* __USE_DB3 */
rc = db_appexit(dbenv);
rc = cvtdberr(dbi, "db_appexit", rc, _debug);
free(dbenv);
#endif
#endif /* __USE_DB3 */
dbi->dbi_dbenv = NULL;
return rc;
}
@ -320,14 +322,14 @@ static int db_init(dbiIndex dbi, const char *dbhome, int dbflags,
/* dbenv->set_tx_max(???) */
/* dbenv->set_tx_recover(???) */
}
#else
#else /* __USE_DB3 */
dbenv->db_errcall = db_errcall;
dbenv->db_errfile = db_errfile;
dbenv->db_errpfx = db_errpfx;
dbenv->db_verbose = db_verbose;
dbenv->mp_mmapsize = dbmp_mmapsize; /* XXX default is 10 Mb */
dbenv->mp_size = dbmp_size; /* XXX default is 128 Kb */
#endif
#endif /* __USE_DB3 */
#define _DBFMASK (DB_CREATE)
mydbopenflags = (dbflags & _DBFMASK) | dbiOpenFlags();
@ -337,12 +339,12 @@ static int db_init(dbiIndex dbi, const char *dbhome, int dbflags,
rc = cvtdberr(dbi, "dbenv->open", rc, _debug);
if (rc)
goto errxit;
#else
#else /* __USE_DB3 */
rc = db_appinit(dbhome, NULL, dbenv, mydbopenflags);
rc = cvtdberr(dbi, "db_appinit", rc, _debug);
if (rc)
goto errxit;
#endif
#endif /* __USE_DB3 */
*dbenvp = dbenv;
if (_debug < 0)
@ -358,9 +360,9 @@ errxit:
xx = dbenv->close(dbenv, 0);
xx = cvtdberr(dbi, "dbenv->close", xx, _debug);
}
#else
#else /* __USE_DB3 */
if (dbenv) free(dbenv);
#endif
#endif /* __USE_DB3 */
return rc;
}
@ -374,13 +376,76 @@ static int db3sync(dbiIndex dbi, unsigned int flags)
#if defined(__USE_DB2) || defined(__USE_DB3)
rc = db->sync(db, flags);
rc = cvtdberr(dbi, "db->sync", rc, _debug);
#else
#else /* __USE_DB2 || __USE_DB3 */
rc = db->sync(db, flags);
#endif
#endif /* __USE_DB2 || __USE_DB3 */
return rc;
}
static int db3c_del(dbiIndex dbi, DBC * dbcursor, u_int32_t flags)
{
int rc;
rc = dbcursor->c_del(dbcursor, flags);
rc = cvtdberr(dbi, "dbcursor->c_del", rc, _debug);
return rc;
}
static int db3c_dup(dbiIndex dbi, DBC * dbcursor, DBC ** dbcp, u_int32_t flags)
{
int rc;
rc = dbcursor->c_dup(dbcursor, dbcp, flags);
rc = cvtdberr(dbi, "dbcursor->c_dup", rc, _debug);
return rc;
}
static int db3c_get(dbiIndex dbi, DBC * dbcursor,
DBT * key, DBT * data, u_int32_t flags)
{
int rc;
int _printit;
rc = dbcursor->c_get(dbcursor, key, data, flags);
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
rc = cvtdberr(dbi, "dbcursor->c_get", rc, _printit);
return rc;
}
static int db3c_put(dbiIndex dbi, DBC * dbcursor,
DBT * key, DBT * data, u_int32_t flags)
{
int rc;
rc = dbcursor->c_put(dbcursor, key, data, flags);
rc = cvtdberr(dbi, "dbcursor->c_put", rc, _debug);
return rc;
}
static int db3c_close(dbiIndex dbi, DBC * dbcursor)
{
int rc;
rc = dbcursor->c_close(dbcursor);
rc = cvtdberr(dbi, "dbcursor->c_close", rc, _debug);
return rc;
}
static int db3c_open(dbiIndex dbi, DB_TXN * txnid, DBC ** dbcp, u_int32_t flags)
{
DB * db = GetDB(dbi);
int rc;
#if defined(__USE_DB3)
rc = db->cursor(db, txnid, dbcp, flags);
#else /* __USE_DB3 */
rc = db->cursor(db, txnid, dbcp);
#endif /* __USE_DB3 */
rc = cvtdberr(dbi, "db->cursor", rc, _debug);
return rc;
}
union _dbswap {
unsigned int ui;
unsigned char uc[4];
@ -397,7 +462,6 @@ static int db3SearchIndex(dbiIndex dbi, const void * str, size_t len,
{
DBT key, data;
DB * db = GetDB(dbi);
int _printit;
int rc;
if (set) *set = NULL;
@ -411,19 +475,36 @@ static int db3SearchIndex(dbiIndex dbi, const void * str, size_t len,
data.size = 0;
#if defined(__USE_DB2) || defined(__USE_DB3)
rc = db->get(db, NULL, &key, &data, 0);
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
rc = cvtdberr(dbi, "db->get", rc, _printit);
#else
{ DB_TXN * txnid = NULL;
if (!_use_cursors) {
int _printit;
rc = db->get(db, txnid, &key, &data, 0);
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
rc = cvtdberr(dbi, "db->get", rc, _printit);
} else {
DBC * dbcursor;
int xx;
rc = db3c_open(dbi, txnid, &dbcursor, 0);
if (rc)
return rc;
/* XXX TODO: loop over duplicates */
rc = db3c_get(dbi, dbcursor, &key, &data, DB_SET);
xx = db3c_close(dbi, dbcursor);
}
}
#else /* __USE_DB2 || __USE_DB3 */
rc = db->get(db, &key, &data, 0);
#endif
#endif /* __USE_DB2 || __USE_DB3 */
if (rc == 0 && set) {
int _dbbyteswapped = db->get_byteswapped(db);
const char * sdbir = data.data;
int i;
*set = dbiCreateIndexSet();
*set = xmalloc(sizeof(**set));
(*set)->count = data.size / sizeof(struct _dbiIR);
(*set)->recs = xmalloc((*set)->count * sizeof(*((*set)->recs)));
@ -451,23 +532,25 @@ static int db3SearchIndex(dbiIndex dbi, const void * str, size_t len,
/*@-compmempass@*/
static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set)
{
DB * db = GetDB(dbi);
DBT key;
DBT data;
DB * db = GetDB(dbi);
DB_TXN * txnid = NULL;
int rc;
_mymemset(&key, 0, sizeof(key));
_mymemset(&data, 0, sizeof(data));
key.data = (void *)str;
key.size = strlen(str);
_mymemset(&data, 0, sizeof(data));
if (set->count) {
#if defined(__USE_DB2) || defined(__USE_DB3)
int _dbbyteswapped = db->get_byteswapped(db);
DBIR_t dbir = alloca(set->count * sizeof(*dbir));
int i;
int _dbbyteswapped = 0;
#if defined(__USE_DB3)
_dbbyteswapped = db->get_byteswapped(db);
#endif /* __USE_DB3 */
/* Convert to database internal format */
for (i = 0; i < set->count; i++) {
@ -483,26 +566,52 @@ static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set)
dbir[i].fileNumber = fileNumber.ui;
}
{
data.data = dbir;
data.size = set->count * sizeof(*dbir);
rc = db->put(db, NULL, &key, &data, 0);
data.data = dbir;
data.size = set->count * sizeof(*dbir);
#if defined(__USE_DB2) || defined(__USE_DB3)
if (!_use_cursors) {
rc = db->put(db, txnid, &key, &data, 0);
rc = cvtdberr(dbi, "db->put", rc, _debug);
} else {
DBC * dbcursor;
rc = db3c_open(dbi, txnid, &dbcursor, DB_WRITECURSOR);
if (rc)
return rc;
/* XXX TODO: loop over duplicates */
rc = db3c_put(dbi, dbcursor, &key, &data, DB_KEYLAST);
(void) db3c_close(dbi, dbcursor);
}
#else
#else /* __USE_DB2 || __USE_DB3 */
rc = db->put(db, &key, &data, 0);
#endif
#endif /* __USE_DB2 || __USE_DB3 */
} else {
#if defined(__USE_DB2) || defined(__USE_DB3)
{
rc = db->del(db, NULL, &key, 0);
if (!_use_cursors) {
rc = db->del(db, txnid, &key, 0);
rc = cvtdberr(dbi, "db->del", rc, _debug);
} else {
DBC * dbcursor;
rc = db3c_open(dbi, txnid, &dbcursor, DB_WRITECURSOR);
if (rc)
return rc;
rc = db3c_get(dbi, dbcursor, &key, &data, DB_RMW | DB_SET);
/* XXX TODO: loop over duplicates */
rc = db3c_del(dbi, dbcursor, 0);
(void) db3c_close(dbi, dbcursor);
}
#else
#else /* __USE_DB2 || __USE_DB3 */
rc = db->del(db, &key, 0);
#endif
#endif /* __USE_DB2 || __USE_DB3 */
}
@ -516,15 +625,8 @@ static int db3copen(dbiIndex dbi)
int rc = 0;
if ((dbcursor = dbi->dbi_dbcursor) == NULL) {
DB * db = GetDB(dbi);
DB_TXN * txnid = NULL;
#if defined(__USE_DB3)
rc = db->cursor(db, txnid, &dbcursor, 0);
#else
rc = db->cursor(db, txnid, &dbcursor);
#endif
rc = cvtdberr(dbi, "db->cursor", rc, _debug);
rc = db3c_open(dbi, txnid, &dbcursor, 0);
if (rc == 0)
dbi->dbi_dbcursor = dbcursor;
}
@ -538,13 +640,11 @@ static int db3cclose(dbiIndex dbi)
int rc = 0;
if ((dbcursor = dbi->dbi_dbcursor) != NULL) {
rc = dbcursor->c_close(dbcursor);
rc = cvtdberr(dbi, "dbcursor->c_close", rc, _debug);
rc = db3c_close(dbi, dbcursor);
dbi->dbi_dbcursor = NULL;
}
if ((dbcursor = dbi->dbi_dbjoin) != NULL) {
rc = dbcursor->c_close(dbcursor);
rc = cvtdberr(dbi, "dbcursor->c_close", rc, _debug);
rc = db3c_close(dbi, dbcursor);
dbi->dbi_dbjoin = NULL;
}
dbi->dbi_lastoffset = 0;
@ -583,8 +683,6 @@ static int db3cget(dbiIndex dbi, void ** keyp, size_t * keylen,
_mymemset(&data, 0, sizeof(data));
{ DBC * dbcursor;
int _printit;
int xx;
if ((dbcursor = dbi->dbi_dbcursor) == NULL) {
rc = db3copen(dbi);
@ -594,14 +692,7 @@ static int db3cget(dbiIndex dbi, void ** keyp, size_t * keylen,
}
/* XXX db3 does DB_FIRST on uninitialized cursor */
rc = dbcursor->c_get(dbcursor, &key, &data, DB_NEXT);
_printit = _debug;
if (rc == DB_NOTFOUND) {
xx = db3cclose(dbi);
_printit = 0;
}
rc = cvtdberr(dbi, "dbcursor->c_get", rc, _printit);
rc = db3c_get(dbi, dbcursor, &key, &data, DB_NEXT);
if (rc == 0) {
if (keyp)
*keyp = key.data;
@ -611,6 +702,8 @@ static int db3cget(dbiIndex dbi, void ** keyp, size_t * keylen,
*datap = data.data;
if (datalen)
*datalen = data.size;
} else if (rc > 0) { /* DB_NOTFOUND */
(void) db3cclose(dbi);
}
}
@ -711,11 +804,11 @@ static int db3close(dbiIndex dbi, unsigned int flags)
xx = db_fini(dbi);
#else
#else /* __USE_DB2 || __USE_DB3 */
rc = db->close(db);
#endif
#endif /* __USE_DB2 || __USE_DB3 */
dbi->dbi_db = NULL;
return rc;
@ -731,7 +824,7 @@ static int db3open(dbiIndex dbi)
char * dbfile;
u_int32_t dbflags;
DB_ENV * dbenv = NULL;
int __do_dbcursor_rmw = 0;
DB_TXN * txnid = NULL;
dbhome = alloca(strlen(dbi->dbi_file) + 1);
strcpy(dbhome, dbi->dbi_file);
@ -787,7 +880,7 @@ static int db3open(dbiIndex dbi)
if (__do_dbcursor_rmw) {
DBC * dbcursor = NULL;
int xx;
xx = db->cursor(db, NULL, &dbcursor,
xx = db->cursor(db, txnid, &dbcursor,
((dbflags & DB_RDONLY) ? 0 : DB_WRITECURSOR));
xx = cvtdberr(dbi, "db->cursor", xx, _debug);
dbi->dbi_dbcursor = dbcursor;
@ -817,7 +910,7 @@ static int db3open(dbiIndex dbi)
dbi->dbi_db = db;
dbi->dbi_dbenv = dbenv;
#else
#else /* __USE_DB2 || __USE_DB3 */
void * dbopeninfo = NULL;
dbi->dbi_db = dbopen(dbfile, dbi->dbi_flags, dbi->dbi_perms,
dbi_to_dbtype(dbi->dbi_type), dbopeninfo);

View File

@ -4,6 +4,7 @@
#include <rpmmacro.h> /* XXX for rpmGetPath */
#include "rpmdb.h"
#include "misc.h"
extern int _useDbiMajor; /* XXX shared with dbindex.c */
extern int __do_dbenv_remove; /* XXX in dbindex.c, shared with rebuilddb.c */

File diff suppressed because it is too large Load Diff

View File

@ -2,12 +2,175 @@
#define H_RPMDB
/** \file lib/rpmdb.h
* Access RPM indices using Berkeley db[123] interface.
*/
#include <rpmlib.h>
#include "fprint.h"
typedef void DBI_t;
typedef enum { DBI_BTREE, DBI_HASH, DBI_RECNO, DBI_QUEUE, DBI_UNKNOWN } DBI_TYPE;
typedef /*@abstract@*/ struct _dbiIndexRecord * dbiIndexRecord;
typedef /*@abstract@*/ struct _dbiIndex * dbiIndex;
/* this will break if sizeof(int) != 4 */
/**
* A single item from an index database (i.e. the "data returned").
* Note: In rpm-3.0.4 and earlier, this structure was passed by value,
* and was identical to the "data saved" structure below.
*/
struct _dbiIndexRecord {
unsigned int recOffset; /*!< byte offset of header in db */
unsigned int fileNumber; /*!< file array index */
int fpNum; /*!< finger print index */
int dbNum; /*!< database index */
};
/**
* A single item in an index database (i.e. the "data saved").
*/
struct _dbiIR {
unsigned int recOffset; /*!< byte offset of header in db */
unsigned int fileNumber; /*!< file array index */
};
typedef struct _dbiIR * DBIR_t;
/**
* Items retrieved from the index database.
*/
struct _dbiIndexSet {
/*@owned@*/ struct _dbiIndexRecord * recs; /*!< array of records */
int count; /*!< number of records */
};
/**
* Private methods for accessing an index database.
*/
struct _dbiVec {
int dbv_major; /*<! Berkeley db version major */
int dbv_minor; /*<! Berkeley db version minor */
int dbv_patch; /*<! Berkeley db version patch */
/**
* Return handle for an index database.
* @param dbi index database handle
* @return 0 success 1 fail
*/
int (*open) (dbiIndex dbi);
/**
* Close index database.
* @param dbi index database handle
* @param flags
*/
int (*close) (dbiIndex dbi, unsigned int flags);
/**
* Flush pending operations to disk.
* @param dbi index database handle
* @param flags
*/
int (*sync) (dbiIndex dbi, unsigned int flags);
/**
* Return items that match criteria.
* @param dbi index database handle
* @param str search key
* @param set items retrieved from index database
* @return -1 error, 0 success, 1 not found
*/
int (*SearchIndex) (dbiIndex dbi, const void * str, size_t len, dbiIndexSet * set);
/**
* Change/delete items that match criteria.
* @param dbi index database handle
* @param str update key
* @param set items to update in index database
* @return 0 success, 1 not found
*/
int (*UpdateIndex) (dbiIndex dbi, const char * str, dbiIndexSet set);
/**
* Delete item using db->del.
* @param dbi index database handle
* @param keyp key data
* @param keylen key data length
*/
int (*del) (dbiIndex dbi, void * keyp, size_t keylen);
/**
* Retrieve item using db->get.
* @param dbi index database handle
* @param keyp key data
* @param keylen key data length
* @param datap address of data pointer
* @param datalen address of data length
*/
int (*get) (dbiIndex dbi, void * keyp, size_t keylen,
void ** datap, size_t * datalen);
/**
* Save item using db->put.
* @param dbi index database handle
* @param keyp key data
* @param keylen key data length
* @param datap data pointer
* @param datalen data length
*/
int (*put) (dbiIndex dbi, void * keyp, size_t keylen,
void * datap, size_t datalen);
/**
*/
int (*copen) (dbiIndex dbi);
/**
*/
int (*cclose) (dbiIndex dbi);
/**
*/
int (*join) (dbiIndex dbi);
/**
* Retrieve item using dbcursor->c_get.
* @param dbi index database handle
* @param keyp address of key data
* @param keylen address of key data length
* @param datap address of data pointer
* @param datalen address of data length
*/
int (*cget) (dbiIndex dbi, void ** keyp, size_t * keylen,
void ** datap, size_t * datalen);
};
/**
* Describes an index database (implemented on Berkeley db[123] API).
*/
struct _dbiIndex {
const char *dbi_basename; /*<! last component of name */
int dbi_rpmtag; /*<! rpm tag used for index */
DBI_TYPE dbi_type; /*<! type of access */
int dbi_flags; /*<! flags to use on open */
int dbi_perms; /*<! file permission to use on open */
int dbi_major; /*<! Berkeley db version major */
unsigned int dbi_lastoffset; /*<! db0 with falloc.c needs this */
rpmdb dbi_rpmdb;
const char *dbi_file; /*<! name of index database */
void * dbi_db; /*<! Berkeley db[123] handle */
void * dbi_dbenv;
void * dbi_dbinfo;
void * dbi_dbjoin;
void * dbi_dbcursor;
void * dbi_pkgs;
/*@observer@*/ const struct _dbiVec * dbi_vec; /*<! private methods */
};
/* for RPM's internal use only */
#define RPMDB_FLAG_JUSTCHECK (1 << 0)
@ -52,6 +215,10 @@ int rpmdbMoveDatabase(const char * rootdir, const char * olddbpath, const char *
int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, /*@out@*/dbiIndexSet * matchList,
int numItems);
/* XXX only for the benefit of runTransactions() */
int findMatches(rpmdb db, const char * name, const char * version,
const char * release, /*@out@*/ dbiIndexSet * matches);
#ifdef __cplusplus
}
#endif

View File

@ -48,21 +48,22 @@ unsigned int dbiIndexRecordOffset(dbiIndexSet set, int recno);
unsigned int dbiIndexRecordFileNumber(dbiIndexSet set, int recno);
/**
* Change record offset of header within element in index database set.
* @param set set of index database items
* @param recno index of item in set
* @param recoff new record offset
*/
void dbiIndexRecordOffsetSave(dbiIndexSet set, int recno, unsigned int recoff);
int rpmReadPackageInfo(FD_t fd, /*@out@*/ Header * signatures,
/*@out@*/ Header * hdr);
/**
*/
int rpmReadPackageHeader(FD_t fd, /*@out@*/ Header * hdr,
/*@out@*/ int * isSource, /*@out@*/ int * major, /*@out@*/ int * minor);
/**
*/
int headerNVR(Header h, /*@out@*/ const char **np, /*@out@*/ const char **vp,
/*@out@*/ const char **rp);
/**
*/
void rpmBuildFileList(Header h, /*@out@*/ const char *** fileListPtr,
/*@out@*/ int * fileCountPtr);

View File

@ -7,7 +7,6 @@
#include "fprint.h"
#include "hash.h"
#include "install.h"
#include "lookup.h"
#include "md5.h"
#include "misc.h"
#include "rpmdb.h"

View File

@ -26,7 +26,6 @@ build/parseSpec.c
build/reqprov.c
build/spec.c
lib/cpio.c
lib/dbindex.c
lib/depends.c
lib/falloc.c
lib/formats.c
@ -35,7 +34,6 @@ lib/fs.c
lib/hash.c
lib/header.c
lib/install.c
lib/lookup.c
lib/macro.c
lib/md5.c
lib/md5sum.c

View File

@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2000-04-17 08:56-0400\n"
"POT-Creation-Date: 2000-04-18 14:17-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1986,39 +1986,6 @@ msgstr ""
msgid " failed - "
msgstr ""
#: lib/dbindex.c:105
#, c-format
msgid "bad db file %s"
msgstr ""
#: lib/dbindex.c:145
msgid ""
"\n"
"--> Please run \"rpm --rebuilddb\" as root to convert your database from\n"
" db1 to db2 on-disk format.\n"
"\n"
msgstr ""
#: lib/dbindex.c:158
#, c-format
msgid "cannot open file %s: %s"
msgstr ""
#: lib/dbindex.c:212 lib/rpmdb.c:139
#, c-format
msgid "error getting record %s from %s"
msgstr ""
#: lib/dbindex.c:226 lib/rpmdb.c:160
#, c-format
msgid "error storing record %s into %s"
msgstr ""
#: lib/dbindex.c:231 lib/rpmdb.c:165
#, c-format
msgid "error removing record %s into %s"
msgstr ""
#. XXX legacy epoch-less requires/conflicts compatibility
#: lib/depends.c:434
#, c-format
@ -2323,11 +2290,6 @@ msgstr ""
msgid "running postinstall scripts (if any)\n"
msgstr ""
#: lib/lookup.c:44
#, c-format
msgid "cannot read header at %d for lookup"
msgstr ""
#: lib/macro.c:161
#, c-format
msgid "======================== active %d empty %d\n"
@ -2714,64 +2676,64 @@ msgstr ""
msgid "display a verbose file listing"
msgstr ""
#: lib/rebuilddb.c:33 lib/rpmdb.c:337 lib/rpmdb.c:431
#: lib/rebuilddb.c:34 lib/rpmdb.c:458
msgid "no dbpath has been set"
msgstr ""
#: lib/rebuilddb.c:58
#: lib/rebuilddb.c:59
#, c-format
msgid "rebuilding database %s into %s\n"
msgstr ""
#: lib/rebuilddb.c:62
#: lib/rebuilddb.c:63
#, c-format
msgid "temporary database %s already exists"
msgstr ""
#: lib/rebuilddb.c:68
#: lib/rebuilddb.c:69
#, c-format
msgid "creating directory: %s\n"
msgstr ""
#: lib/rebuilddb.c:70
#: lib/rebuilddb.c:71
#, c-format
msgid "error creating directory %s: %s"
msgstr ""
#: lib/rebuilddb.c:81
#: lib/rebuilddb.c:82
#, c-format
msgid "opening old database with dbi_major %d\n"
msgstr ""
#: lib/rebuilddb.c:90
#: lib/rebuilddb.c:91
#, c-format
msgid "opening new database with dbi_major %d\n"
msgstr ""
#: lib/rebuilddb.c:111
#: lib/rebuilddb.c:112
#, c-format
msgid "record number %d in database is bad -- skipping."
msgstr ""
#: lib/rebuilddb.c:143
#: lib/rebuilddb.c:144
#, c-format
msgid "cannot add record originally at %d"
msgstr ""
#: lib/rebuilddb.c:159
#: lib/rebuilddb.c:160
msgid "failed to rebuild database; original database remains in place\n"
msgstr ""
#: lib/rebuilddb.c:167
#: lib/rebuilddb.c:168
msgid "failed to replace old database with new database!\n"
msgstr ""
#: lib/rebuilddb.c:169
#: lib/rebuilddb.c:170
#, c-format
msgid "replace files in %s with files from %s to recover"
msgstr ""
#: lib/rebuilddb.c:175
#: lib/rebuilddb.c:176
#, c-format
msgid "failed to remove directory %s: %s\n"
msgstr ""
@ -2859,72 +2821,115 @@ msgstr ""
msgid "OK"
msgstr ""
#: lib/rpmdb.c:401
#: lib/rpmdb.c:89
#, c-format
msgid "error getting record %s from %s"
msgstr ""
#: lib/rpmdb.c:110
#, c-format
msgid "error storing record %s into %s"
msgstr ""
#: lib/rpmdb.c:115
#, c-format
msgid "error removing record %s into %s"
msgstr ""
#: lib/rpmdb.c:267
#, c-format
msgid "bad db file %s"
msgstr ""
#: lib/rpmdb.c:307
msgid ""
"\n"
"--> Please run \"rpm --rebuilddb\" as root to convert your database from\n"
" db1 to db2 on-disk format.\n"
"\n"
msgstr ""
#: lib/rpmdb.c:320
#, c-format
msgid "cannot open file %s: %s"
msgstr ""
#: lib/rpmdb.c:528
msgid ""
"old format database is present; use --rebuilddb to generate a new format "
"database"
msgstr ""
#. error
#: lib/rpmdb.c:607
#: lib/rpmdb.c:709
#, c-format
msgid "cannot retrieve package \"%s\" from db"
msgstr ""
#: lib/rpmdb.c:830
#, c-format
msgid "package not found with key \"%s\" in %s"
msgstr ""
#: lib/rpmdb.c:839
#: lib/rpmdb.c:1031
#, c-format
msgid "key \"%s\" not found in %s"
msgstr ""
#: lib/rpmdb.c:857
#: lib/rpmdb.c:1039
#, c-format
msgid "key \"%s\" not removed from %s"
msgstr ""
#: lib/rpmdb.c:1065
#, c-format
msgid "rpmdbRemove: cannot read header at 0x%x"
msgstr ""
#: lib/rpmdb.c:882
#: lib/rpmdb.c:1096
#, c-format
msgid "removing 0 %s entries.\n"
msgstr ""
#: lib/rpmdb.c:888
#: lib/rpmdb.c:1103
#, c-format
msgid "removing \"%s\" from %s index.\n"
msgstr ""
#: lib/rpmdb.c:896
#: lib/rpmdb.c:1111
#, c-format
msgid "removing %d entries in %s index:\n"
msgstr ""
#: lib/rpmdb.c:900 lib/rpmdb.c:1097
#: lib/rpmdb.c:1115
#, c-format
msgid "\t%6d %s\n"
msgstr ""
#: lib/rpmdb.c:1035
#: lib/rpmdb.c:1255
msgid "cannot allocate new instance in database"
msgstr ""
#: lib/rpmdb.c:1074
#: lib/rpmdb.c:1301
#, c-format
msgid "adding 0 %s entries.\n"
msgstr ""
#: lib/rpmdb.c:1086
#: lib/rpmdb.c:1314
#, c-format
msgid "adding \"%s\" to %s index.\n"
msgstr ""
#: lib/rpmdb.c:1093
#: lib/rpmdb.c:1321
#, c-format
msgid "adding %d entries to %s index:\n"
msgstr ""
#: lib/rpmdb.c:1325
#, c-format
msgid "%6d %s\n"
msgstr ""
#: lib/rpmdb.c:1637
#, c-format
msgid "cannot read header at %d for lookup"
msgstr ""
#: lib/rpminstall.c:126
msgid "counting packages to install\n"
msgstr ""
@ -3316,27 +3321,27 @@ msgstr ""
msgid "You must set \"%%_pgp_name\" in your macro file"
msgstr ""
#: lib/transaction.c:400
#: lib/transaction.c:399
#, c-format
msgid "excluding file %s%s\n"
msgstr ""
#: lib/transaction.c:426 lib/transaction.c:509
#: lib/transaction.c:425 lib/transaction.c:508
#, c-format
msgid "excluding directory %s\n"
msgstr ""
#: lib/transaction.c:431
#: lib/transaction.c:430
#, c-format
msgid "relocating %s to %s\n"
msgstr ""
#: lib/transaction.c:502
#: lib/transaction.c:501
#, c-format
msgid "relocating directory %s to %s\n"
msgstr ""
#: lib/transaction.c:654
#: lib/transaction.c:653
#, c-format
msgid "%s skipped due to missingok flag\n"
msgstr ""