rpm  4.17.0
Files | Functions
Database API.

Opening & accessing the RPM database. More...

Collaboration diagram for Database API.:

Files

file  rpmdb.h
 RPM database API.
 
file  rpmlib.h
 In Memoriam: Steve Taylor stayl.nosp@m.or@r.nosp@m.edhat.nosp@m..com was here, now he's not.
 

Functions

rpmop rpmdbOp (rpmdb db, rpmdbOpX opx)
 Retrieve operation timestamp from rpm database. More...
 
int rpmdbOpenAll (rpmdb db)
 Open all database indices. More...
 
int rpmdbCountPackages (rpmdb db, const char *name)
 Return number of instances of package in rpm database. More...
 
unsigned int rpmdbGetIteratorOffset (rpmdbMatchIterator mi)
 Return header join key for current position of rpm database iterator. More...
 
int rpmdbGetIteratorCount (rpmdbMatchIterator mi)
 Return number of elements in rpm database iterator. More...
 
unsigned int rpmdbGetIteratorFileNum (rpmdbMatchIterator mi)
 
int rpmdbAppendIterator (rpmdbMatchIterator mi, const unsigned int *hdrNums, unsigned int nHdrNums)
 Append items to set of package instances to iterate. More...
 
int rpmdbSetIteratorRE (rpmdbMatchIterator mi, rpmTagVal tag, rpmMireMode mode, const char *pattern)
 Add pattern to iterator selector. More...
 
int rpmdbSetIteratorRewrite (rpmdbMatchIterator mi, int rewrite)
 Prepare iterator for lazy writes. More...
 
int rpmdbSetIteratorModified (rpmdbMatchIterator mi, int modified)
 Modify iterator to mark header for lazy write on release. More...
 
int rpmdbSetHdrChk (rpmdbMatchIterator mi, rpmts ts, rpmRC(*hdrchk)(rpmts ts, const void *uh, size_t uc, char **msg))
 Modify iterator to verify retrieved header blobs. More...
 
rpmdbMatchIterator rpmdbInitIterator (rpmdb db, rpmDbiTagVal rpmtag, const void *keyp, size_t keylen)
 Return database iterator. More...
 
Header rpmdbNextIterator (rpmdbMatchIterator mi)
 Return next package header from iteration. More...
 
rpmdbMatchIterator rpmdbFreeIterator (rpmdbMatchIterator mi)
 Destroy rpm database iterator. More...
 
rpmdbIndexIterator rpmdbIndexKeyIteratorInit (rpmdb db, rpmDbiTag rpmtag)
 Get an iterator for index keys. More...
 
rpmdbIndexIterator rpmdbIndexIteratorInit (rpmdb db, rpmDbiTag rpmtag)
 Get an iterator for an index. More...
 
int rpmdbIndexIteratorNext (rpmdbIndexIterator ii, const void **key, size_t *keylen)
 Get the next key - Warning! Keys are not zero terminated! Binary tags may even contain zero bytes. More...
 
int rpmdbIndexIteratorNextTd (rpmdbIndexIterator ii, rpmtd keytd)
 Get the next key into a tag data container. More...
 
unsigned int rpmdbIndexIteratorNumPkgs (rpmdbIndexIterator ii)
 Get number of entries for current key. More...
 
unsigned int rpmdbIndexIteratorPkgOffset (rpmdbIndexIterator ii, unsigned int nr)
 Get package offset of entry. More...
 
unsigned int rpmdbIndexIteratorTagNum (rpmdbIndexIterator ii, unsigned int nr)
 Get tag number of entry. More...
 
rpmdbIndexIterator rpmdbIndexIteratorFree (rpmdbIndexIterator ii)
 Free index iterator. More...
 
int rpmdbCtrl (rpmdb db, rpmdbCtrlOp ctrl)
 manipulate the rpm database More...
 
char * rpmdbCookie (rpmdb db)
 Retrieve rpm database changed-cookie. More...
 
int rpmdbStat (const char *prefix, struct stat *statbuf)
 Perform stat() on rpm database. More...
 
int rpmdbFStat (rpmdb db, struct stat *statbuf)
 Perform stat() on an open rpm database. More...
 

Detailed Description

Opening & accessing the RPM database.

Function Documentation

◆ rpmdbAppendIterator()

int rpmdbAppendIterator ( rpmdbMatchIterator  mi,
const unsigned int *  hdrNums,
unsigned int  nHdrNums 
)

Append items to set of package instances to iterate.

Parameters
mirpm database iterator
hdrNumsarray of package instances
nHdrNumsnumber of elements in array
Returns
0 on success, 1 on failure (bad args)

◆ rpmdbCookie()

char* rpmdbCookie ( rpmdb  db)

Retrieve rpm database changed-cookie.

Useful for eg. determining cache validity.

Parameters
dbrpm database
Returns
cookie string (malloced), or NULL on error

◆ rpmdbCountPackages()

int rpmdbCountPackages ( rpmdb  db,
const char *  name 
)

Return number of instances of package in rpm database.

Parameters
dbrpm database
namerpm package name
Returns
number of instances

◆ rpmdbCtrl()

int rpmdbCtrl ( rpmdb  db,
rpmdbCtrlOp  ctrl 
)

manipulate the rpm database

Parameters
dbrpm database
ctrloperation
Returns
0 on success; != 0 on error

◆ rpmdbFreeIterator()

rpmdbMatchIterator rpmdbFreeIterator ( rpmdbMatchIterator  mi)

Destroy rpm database iterator.

Parameters
mirpm database iterator
Returns
NULL always

◆ rpmdbFStat()

int rpmdbFStat ( rpmdb  db,
struct stat *  statbuf 
)

Perform stat() on an open rpm database.

Parameters
dbrpm database
[out]statbufreturned data from stat()
Returns
0 on success, -1 on error

◆ rpmdbGetIteratorCount()

int rpmdbGetIteratorCount ( rpmdbMatchIterator  mi)

Return number of elements in rpm database iterator.

Parameters
mirpm database iterator
Returns
number of elements

◆ rpmdbGetIteratorFileNum()

unsigned int rpmdbGetIteratorFileNum ( rpmdbMatchIterator  mi)

◆ rpmdbGetIteratorOffset()

unsigned int rpmdbGetIteratorOffset ( rpmdbMatchIterator  mi)

Return header join key for current position of rpm database iterator.

Parameters
mirpm database iterator
Returns
current header join key

◆ rpmdbIndexIteratorFree()

rpmdbIndexIterator rpmdbIndexIteratorFree ( rpmdbIndexIterator  ii)

Free index iterator.

Parameters
iiindex iterator return NULL

◆ rpmdbIndexIteratorInit()

rpmdbIndexIterator rpmdbIndexIteratorInit ( rpmdb  db,
rpmDbiTag  rpmtag 
)

Get an iterator for an index.

Parameters
dbrpm database
rpmtagthe index to iterate over
Returns
the index iterator

◆ rpmdbIndexIteratorNext()

int rpmdbIndexIteratorNext ( rpmdbIndexIterator  ii,
const void **  key,
size_t *  keylen 
)

Get the next key - Warning! Keys are not zero terminated! Binary tags may even contain zero bytes.

Parameters
iiindex iterator
keyaddress to save the pointer to the key
keylenaddress to save the length of the key to
Returns
0 on success; != 0 on error or end of index

◆ rpmdbIndexIteratorNextTd()

int rpmdbIndexIteratorNextTd ( rpmdbIndexIterator  ii,
rpmtd  keytd 
)

Get the next key into a tag data container.

Caller is responsible for calling rpmtdFreeData() to freeing the data returned in keytd once done with it.

Parameters
iiindex iterator
keytdtag container to store the key in
Returns
0 on success; != 0 on error or end of index

◆ rpmdbIndexIteratorNumPkgs()

unsigned int rpmdbIndexIteratorNumPkgs ( rpmdbIndexIterator  ii)

Get number of entries for current key.

Parameters
iiindex iterator
Returns
number of entries. 0 on error.

◆ rpmdbIndexIteratorPkgOffset()

unsigned int rpmdbIndexIteratorPkgOffset ( rpmdbIndexIterator  ii,
unsigned int  nr 
)

Get package offset of entry.

Parameters
iiindex iterator
nrnumber of the entry
Returns
db offset of pkg

◆ rpmdbIndexIteratorTagNum()

unsigned int rpmdbIndexIteratorTagNum ( rpmdbIndexIterator  ii,
unsigned int  nr 
)

Get tag number of entry.

Parameters
iiindex iterator
nrnumber of the entry
Returns
number of tag within the package

◆ rpmdbIndexKeyIteratorInit()

rpmdbIndexIterator rpmdbIndexKeyIteratorInit ( rpmdb  db,
rpmDbiTag  rpmtag 
)

Get an iterator for index keys.

Parameters
dbrpm database
rpmtagthe index to iterate over
Returns
the index iterator

◆ rpmdbInitIterator()

rpmdbMatchIterator rpmdbInitIterator ( rpmdb  db,
rpmDbiTagVal  rpmtag,
const void *  keyp,
size_t  keylen 
)

Return database iterator.

Parameters
dbrpm database
rpmtagdatabase index tag
keypkey data (NULL for sequential access)
keylenkey data length (0 will use strlen(keyp))
Returns
NULL on failure

◆ rpmdbNextIterator()

Header rpmdbNextIterator ( rpmdbMatchIterator  mi)

Return next package header from iteration.

Parameters
mirpm database iterator
Returns
NULL on end of iteration.

◆ rpmdbOp()

rpmop rpmdbOp ( rpmdb  db,
rpmdbOpX  opx 
)

Retrieve operation timestamp from rpm database.

Parameters
dbrpm database
opxoperation timestamp index
Returns
pointer to operation timestamp.

◆ rpmdbOpenAll()

int rpmdbOpenAll ( rpmdb  db)

Open all database indices.

Parameters
dbrpm database
Returns
0 on success

◆ rpmdbSetHdrChk()

int rpmdbSetHdrChk ( rpmdbMatchIterator  mi,
rpmts  ts,
rpmRC(*)(rpmts ts, const void *uh, size_t uc, char **msg)  hdrchk 
)

Modify iterator to verify retrieved header blobs.

Parameters
mirpm database iterator
tstransaction set
(*hdrchk)headerCheck() vector
Returns
0 always

◆ rpmdbSetIteratorModified()

int rpmdbSetIteratorModified ( rpmdbMatchIterator  mi,
int  modified 
)

Modify iterator to mark header for lazy write on release.

Parameters
mirpm database iterator
modifiednew value of modified
Returns
previous value

◆ rpmdbSetIteratorRE()

int rpmdbSetIteratorRE ( rpmdbMatchIterator  mi,
rpmTagVal  tag,
rpmMireMode  mode,
const char *  pattern 
)

Add pattern to iterator selector.

Parameters
mirpm database iterator
tagrpm tag
modetype of pattern match
patternpattern to match
Returns
0 on success

◆ rpmdbSetIteratorRewrite()

int rpmdbSetIteratorRewrite ( rpmdbMatchIterator  mi,
int  rewrite 
)

Prepare iterator for lazy writes.

Note
Must be called before rpmdbNextIterator() with CDB model database.
Parameters
mirpm database iterator
rewritenew value of rewrite
Returns
previous value

◆ rpmdbStat()

int rpmdbStat ( const char *  prefix,
struct stat *  statbuf 
)

Perform stat() on rpm database.

Parameters
prefixprefix or NULL for /
[out]statbufreturned data from stat()
Returns
0 on success, -1 on error