Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

lib/rpmdb.c File Reference

More...

#include "system.h"
#include <sys/file.h>
#include <signal.h>
#include <sys/signal.h>
#include <rpmlib.h>
#include <rpmmacro.h>
#include "rpmdb.h"
#include "fprint.h"
#include "misc.h"
#include "debug.h"

Go to the source code of this file.

Compounds

union  _dbswap
struct  _rpmdbMatchIterator

RPMDB

int rpmdbOpenAll (rpmdb rpmdb)
int rpmdbClose (rpmdb rpmdb)
int rpmdbSync (rpmdb rpmdb)
int rpmdbOpen (const char * prefix, rpmdb *dbp, int mode, int perms)
int rpmdbInit (const char * prefix, int perms)
int rpmdbCountPackages (rpmdb rpmdb, const char * name)
void rpmdbFreeIterator (rpmdbMatchIterator mi)
rpmdb rpmdbGetIteratorRpmDB (rpmdbMatchIterator mi)
unsigned int rpmdbGetIteratorOffset (rpmdbMatchIterator mi)
int rpmdbGetIteratorCount (rpmdbMatchIterator mi)
void rpmdbSetIteratorRelease (rpmdbMatchIterator mi, const char * release)
void rpmdbSetIteratorVersion (rpmdbMatchIterator mi, const char * version)
int rpmdbSetIteratorModified (rpmdbMatchIterator mi, int modified)
Header XrpmdbNextIterator (rpmdbMatchIterator mi, const char * f, unsigned l)
int rpmdbPruneIterator (rpmdbMatchIterator mi, int * hdrNums, int nHdrNums, int sorted)
int rpmdbAppendIterator (rpmdbMatchIterator mi, int * hdrNums, int nHdrNums)
rpmdbMatchIterator rpmdbInitIterator (rpmdb rpmdb, int rpmtag, const void * keyp, size_t keylen)
int rpmdbRemove (rpmdb rpmdb, int rid, unsigned int hdrNum)
int rpmdbAdd (rpmdb rpmdb, int iid, Header h)
int rpmdbRebuild (const char * rootdir)

Defines

#define INLINE
#define _DBI_FLAGS   0
#define _DBI_PERMS   0644
#define _DBI_MAJOR   -1
#define DB1vec   NULL
#define DB2vec   NULL
#define DB3vec   NULL
#define _DBSWAP(_a)
#define _DB_ROOT   "/"
#define _DB_HOME   "%{_dbpath}"
#define _DB_FLAGS   0
#define _DB_MODE   0
#define _DB_PERMS   0644
#define _DB_MAJOR   -1
#define _DB_REMOVE_ENV   0
#define _DB_FILTER_DUPS   0
#define _DB_ERRPFX   "rpmdb"
#define _RECNUM   rpmdbGetIteratorOffset(mi)

Functions

int dbiTagToDbix (int rpmtag)
 Return dbi index used for rpm tag. More...

void dbiTagsInit (void)
 Initialize database (index, tag) tuple from configuration. More...

int dbiSync (dbiIndex dbi, unsigned int flags)
int dbiByteSwapped (dbiIndex dbi)
int XdbiCopen (dbiIndex dbi, DBC ** dbcp, unsigned int flags, const char * f, unsigned int l)
int XdbiCclose (dbiIndex dbi, DBC * dbcursor, unsigned int flags, const char * f, unsigned int l)
int dbiDel (dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen, unsigned int flags)
int dbiGet (dbiIndex dbi, DBC * dbcursor, void ** keypp, size_t * keylenp, void ** datapp, size_t * datalenp, unsigned int flags)
int dbiPut (dbiIndex dbi, DBC * dbcursor, const void * keyp, size_t keylen, const void * datap, size_t datalen, unsigned int flags)
int dbiClose (dbiIndex dbi, unsigned int flags)
dbiIndex dbiOpen (rpmdb rpmdb, int rpmtag, unsigned int flags)
dbiIndexItem dbiIndexNewItem (unsigned int hdrNum, unsigned int tagNum)
 Create and initialize item for index database set. More...

int dbiSearch (dbiIndex dbi, DBC * dbcursor, const char * keyp, size_t keylen, dbiIndexSet * setp)
 Return items that match criteria. More...

int dbiUpdateIndex (dbiIndex dbi, DBC * dbcursor, const char * keyp, dbiIndexSet set)
 Change/delete items that match criteria. More...

int hdrNumCmp (const void * one, const void * two)
int dbiAppendSet (dbiIndexSet set, const void * recs, int nrecs, size_t recsize, int sortset)
 Append element(s) to set of index database items. More...

int dbiPruneSet (dbiIndexSet set, void * recs, int nrecs, size_t recsize, int sorted)
 Remove element(s) from set of index database items. More...

unsigned int dbiIndexSetCount (dbiIndexSet set)
unsigned int dbiIndexRecordOffset (dbiIndexSet set, int recno)
unsigned int dbiIndexRecordFileNumber (dbiIndexSet set, int recno)
void dbiFreeIndexSet (dbiIndexSet set)
void blockSignals (rpmdb rpmdb, sigset_t * oldMask)
 Disable all signals, returning previous signal mask. More...

void unblockSignals (rpmdb rpmdb, sigset_t * oldMask)
 Restore signal mask. More...

rpmdb newRpmdb (const char * root, const char * home, int mode, int perms, int flags)
int openDatabase (const char * prefix, const char * dbpath, int _dbapi, rpmdb *dbp, int mode, int perms, int flags)
int rpmdbFindByFile (rpmdb rpmdb, const char * filespec, dbiIndexSet * matches)
int dbiFindMatches (dbiIndex dbi, DBC * dbcursor, const char * name, const char * version, const char * release, dbiIndexSet * matches)
int dbiFindByLabel (dbiIndex dbi, DBC * dbcursor, const char * arg, dbiIndexSet * matches)
int dbiUpdateRecord (dbiIndex dbi, DBC * dbcursor, int offset, Header h)
 Rewrite a header in the database. More...

unsigned int rpmdbGetIteratorFileNum (rpmdbMatchIterator mi)
void rpmdbSortIterator (rpmdbMatchIterator mi)
int rpmdbGrowIterator (rpmdbMatchIterator mi, const void * keyp, size_t keylen, int fpNum)
int removeIndexEntry (dbiIndex dbi, DBC * dbcursor, const char * keyp, dbiIndexItem rec)
int addIndexEntry (dbiIndex dbi, DBC * dbcursor, const char *index, dbiIndexItem rec)
int rpmdbFindFpList (rpmdb rpmdb, fingerPrint * fpList, dbiIndexSet * matchList, int numItems)
char* db1basename (int rpmtag)
int rpmdbRemoveDatabase (const char * rootdir, const char * dbpath, int _dbapi)
int rpmdbMoveDatabase (const char * rootdir, const char * olddbpath, int _olddbapi, const char * newdbpath, int _newdbapi)

Variables

int _rebuildinprogress = 0
int _db_filter_dups = 0
int _filterDbDups = 0
int dbiTagsMax = 0
int* dbiTags = NULL
struct _dbiVecmydbvecs []
struct rpmdb_s dbTemplate


Detailed Description

Definition in file rpmdb.c.


Define Documentation

#define DB1vec   NULL
 

Definition at line 118 of file rpmdb.c.

#define DB2vec   NULL
 

Definition at line 125 of file rpmdb.c.

#define DB3vec   NULL
 

Definition at line 132 of file rpmdb.c.

#define INLINE
 

Definition at line 8 of file rpmdb.c.

#define _DBI_FLAGS   0
 

Definition at line 33 of file rpmdb.c.

#define _DBI_MAJOR   -1
 

Definition at line 35 of file rpmdb.c.

#define _DBI_PERMS   0644
 

Definition at line 34 of file rpmdb.c.

#define _DBSWAP( _a )
 

Initializer:

\
  { unsigned char _b, *_c = (_a).uc; \
    _b = _c[3]; _c[3] = _c[0]; _c[0] = _b; \
    _b = _c[2]; _c[2] = _c[1]; _c[1] = _b; \
  }

Definition at line 348 of file rpmdb.c.

Referenced by dbiSearch(), and dbiUpdateIndex().

#define _DB_ERRPFX   "rpmdb"
 

Definition at line 649 of file rpmdb.c.

#define _DB_FILTER_DUPS   0
 

Definition at line 648 of file rpmdb.c.

#define _DB_FLAGS   0
 

Definition at line 642 of file rpmdb.c.

#define _DB_HOME   "%{_dbpath}"
 

Definition at line 641 of file rpmdb.c.

#define _DB_MAJOR   -1
 

Definition at line 646 of file rpmdb.c.

#define _DB_MODE   0
 

Definition at line 643 of file rpmdb.c.

#define _DB_PERMS   0644
 

Definition at line 644 of file rpmdb.c.

#define _DB_REMOVE_ENV   0
 

Definition at line 647 of file rpmdb.c.

#define _DB_ROOT   "/"
 

Definition at line 640 of file rpmdb.c.

#define _RECNUM   rpmdbGetIteratorOffset(mi)
 


Function Documentation

int XdbiCclose ( dbiIndex dbi,
DBC * dbcursor,
unsigned int flags,
const char * f,
unsigned int l )
 

Definition at line 157 of file rpmdb.c.

int XdbiCopen ( dbiIndex dbi,
DBC ** dbcp,
unsigned int flags,
const char * f,
unsigned int l )
 

Definition at line 149 of file rpmdb.c.

Header XrpmdbNextIterator ( rpmdbMatchIterator mi,
const char * f,
unsigned l )
 

Definition at line 1310 of file rpmdb.c.

int addIndexEntry ( dbiIndex dbi,
DBC * dbcursor,
const char * index,
dbiIndexItem rec ) [static]
 

Definition at line 1738 of file rpmdb.c.

Referenced by rpmdbAdd().

void blockSignals ( rpmdb rpmdb,
sigset_t * oldMask ) [static]
 

Disable all signals, returning previous signal mask.

Definition at line 618 of file rpmdb.c.

Referenced by dbiUpdateRecord(), rpmdbAdd(), and rpmdbRemove().

int dbiAppendSet ( dbiIndexSet set,
const void * recs,
int nrecs,
size_t recsize,
int sortset ) [static]
 

Append element(s) to set of index database items.

Parameters:
set   set of index database items
recs   array of items to append to set
nrecs   number of items
recsize   size of an array item
sortset   should resulting set be sorted?
Returns:
0 success, 1 failure (bad args)

Definition at line 530 of file rpmdb.c.

Referenced by addIndexEntry(), rpmdbAppendIterator(), rpmdbFindByFile(), and rpmdbFindFpList().

int dbiDel ( dbiIndex dbi,
DBC * dbcursor,
const void * keyp,
size_t keylen,
unsigned int flags )
 

Definition at line 165 of file rpmdb.c.

int dbiFindByLabel ( dbiIndex dbi,
DBC * dbcursor,
const char * arg,
dbiIndexSet * matches ) [static]
 

Definition at line 1119 of file rpmdb.c.

Referenced by rpmdbInitIterator().

int dbiFindMatches ( dbiIndex dbi,
DBC * dbcursor,
const char * name,
const char * version,
const char * release,
dbiIndexSet * matches ) [static]
 

Definition at line 1037 of file rpmdb.c.

Referenced by dbiFindByLabel().

int dbiGet ( dbiIndex dbi,
DBC * dbcursor,
void ** keypp,
size_t * keylenp,
void ** datapp,
size_t * datalenp,
unsigned int flags )
 

Definition at line 182 of file rpmdb.c.

dbiIndexItem dbiIndexNewItem ( unsigned int hdrNum,
unsigned int tagNum ) [static]
 

Create and initialize item for index database set.

Parameters:
hdrNum   header instance in db
tagNum   tag index in header
Returns:
new item

Definition at line 336 of file rpmdb.c.

Referenced by rpmdbAdd(), rpmdbFindByFile(), and rpmdbRemove().

int dbiPruneSet ( dbiIndexSet set,
void * recs,
int nrecs,
size_t recsize,
int sorted ) [static]
 

Remove element(s) from set of index database items.

Parameters:
set   set of index database items
recs   array of items to remove from set
nrecs   number of items
recsize   size of an array item
sorted   array is already sorted?
Returns:
0 success, 1 failure (no items found)

Definition at line 567 of file rpmdb.c.

Referenced by removeIndexEntry(), and rpmdbPruneIterator().

int dbiPut ( dbiIndex dbi,
DBC * dbcursor,
const void * keyp,
size_t keylen,
const void * datap,
size_t datalen,
unsigned int flags )
 

Definition at line 211 of file rpmdb.c.

int dbiSearch ( dbiIndex dbi,
DBC * dbcursor,
const char * keyp,
size_t keylen,
dbiIndexSet * setp ) [static]
 

Return items that match criteria.

Parameters:
dbi   index database handle
keyp   search key
keylen   search key length (0 will use strlen(key))
setp   address of items retrieved from index database
Returns:
-1 error, 0 success, 1 not found

Definition at line 362 of file rpmdb.c.

Referenced by addIndexEntry(), dbiFindMatches(), removeIndexEntry(), rpmdbCountPackages(), rpmdbFindByFile(), rpmdbGrowIterator(), and rpmdbInitIterator().

int dbiTagToDbix ( int rpmtag ) [static]
 

Return dbi index used for rpm tag.

Parameters:
rpmtag   rpm header tag
Returns:
dbi index, -1 on error

Definition at line 45 of file rpmdb.c.

Referenced by dbiOpen(), and dbiTagsInit().

void dbiTagsInit ( void ) [static]
 

Initialize database (index, tag) tuple from configuration.

Definition at line 61 of file rpmdb.c.

Referenced by openDatabase().

int dbiUpdateIndex ( dbiIndex dbi,
DBC * dbcursor,
const char * keyp,
dbiIndexSet set ) [static]
 

Change/delete items that match criteria.

Parameters:
dbi   index database handle
keyp   update key
set   items to update in index database
Returns:
0 success, 1 not found

Definition at line 441 of file rpmdb.c.

Referenced by addIndexEntry(), and removeIndexEntry().

int dbiUpdateRecord ( dbiIndex dbi,
DBC * dbcursor,
int offset,
Header h ) [static]
 

Rewrite a header in the database.

Note: this is called from a markReplacedFiles iteration, and *must* preserve the "join key" (i.e. offset) for the header.

Parameters:
dbi   index database handle (always RPMDBI_PACKAGES)
offset   join key
h   rpm header
Returns:
0 on success

Definition at line 1167 of file rpmdb.c.

Referenced by XrpmdbNextIterator(), rpmdbAdd(), and rpmdbFreeIterator().

int hdrNumCmp ( const void * one,
const void * two ) [static]
 

Definition at line 516 of file rpmdb.c.

rpmdb newRpmdb ( const char * root,
const char * home,
int mode,
int perms,
int flags ) [static]
 

Definition at line 712 of file rpmdb.c.

Referenced by openDatabase().

int openDatabase ( const char * prefix,
const char * dbpath,
int _dbapi,
rpmdb * dbp,
int mode,
int perms,
int flags ) [static]
 

Definition at line 758 of file rpmdb.c.

Referenced by rpmdbInit(), rpmdbOpen(), and rpmdbRebuild().

int removeIndexEntry ( dbiIndex dbi,
DBC * dbcursor,
const char * keyp,
dbiIndexItem rec ) [static]
 

Definition at line 1582 of file rpmdb.c.

Referenced by rpmdbRemove().

int rpmdbFindByFile ( rpmdb rpmdb,
const char * filespec,
dbiIndexSet * matches ) [static]
 

Definition at line 885 of file rpmdb.c.

Referenced by rpmdbInitIterator().

int rpmdbGrowIterator ( rpmdbMatchIterator mi,
const void * keyp,
size_t keylen,
int fpNum ) [static]
 

Definition at line 1424 of file rpmdb.c.

Referenced by rpmdbFindFpList().

int rpmdbMoveDatabase ( const char * rootdir,
const char * olddbpath,
int _olddbapi,
const char * newdbpath,
int _newdbapi ) [static]
 

Definition at line 2144 of file rpmdb.c.

Referenced by rpmdbRebuild().

int rpmdbRemoveDatabase ( const char * rootdir,
const char * dbpath,
int _dbapi ) [static]
 

Definition at line 2092 of file rpmdb.c.

Referenced by rpmdbMoveDatabase(), and rpmdbRebuild().

void rpmdbSortIterator ( rpmdbMatchIterator mi ) [static]
 

Definition at line 1416 of file rpmdb.c.

Referenced by rpmdbFindFpList().

void unblockSignals ( rpmdb rpmdb,
sigset_t * oldMask ) [static]
 

Restore signal mask.

Definition at line 632 of file rpmdb.c.

Referenced by dbiUpdateRecord(), rpmdbAdd(), and rpmdbRemove().


Variable Documentation

int _db_filter_dups = 0 [static]
 

Definition at line 29 of file rpmdb.c.

int _filterDbDups = 0
 

Definition at line 31 of file rpmdb.c.

int _rebuildinprogress = 0 [static]
 

Definition at line 28 of file rpmdb.c.

struct rpmdb_s dbTemplate [static]
 

Initializer:

{
     "/" ,       "%{_dbpath}" ,  0 ,  0 ,  0644 ,
     -1 ,        0 ,  0 ,  "rpmdb" 
}

Definition at line 651 of file rpmdb.c.

int * dbiTags = NULL [static]
 

Definition at line 38 of file rpmdb.c.

int dbiTagsMax = 0 [static]
 

Definition at line 37 of file rpmdb.c.

struct _dbiVec * mydbvecs[] [static]
 

Initializer:

{
     NULL ,  NULL ,  NULL ,  NULL , NULL
}

Definition at line 135 of file rpmdb.c.


Generated at Sun Apr 8 18:43:04 2001 for rpm by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000