rpm 4.15.1

Files | Functions
Database API.
I/O

Opening & accessing the RPM indices using Berkeley DB (the so called rpmdb) More...

Collaboration diagram for Database API.:

## Files
file | rpmdb.h
file | rpmlib.h

## Functions
rpmop | rpmdbOp (rpmdb db, rpmdbOpX opx)
int | rpmdbOpenAll (rpmdb db)
int | rpmdbCountPackages (rpmdb db, const char *name)
unsigned int | rpmdbGetIteratorOffset (rpmdbMatchIterator mi)
int | rpmdbGetIteratorCount (rpmdbMatchIterator mi)
unsigned int | rpmdbGetIteratorFileNum (rpmdbMatchIterator mi)
int | rpmdbAppendIterator (rpmdbMatchIterator mi, const unsigned int *hdrNums, unsigned int nHdrNums)
int | rpmdbSetIteratorRE (rpmdbMatchIterator mi, rpmTagVal tag, rpmMireMode mode, const char *pattern)
int | rpmdbSetIteratorRewrite (rpmdbMatchIterator mi, int rewrite)
int | rpmdbSetIteratorModified (rpmdbMatchIterator mi, int modified)
int | rpmdbSetHdrChk (rpmdbMatchIterator mi, rpmts ts, rpmRC(*hdrchk)(rpmts ts, const void *uh, size_t uc, char **msg))
rpmdbMatchIterator | rpmdbInitIterator (rpmdb db, rpmDbiTagVal rpmtag, const void *keyp, size_t keylen)
Header | rpmdbNextIterator (rpmdbMatchIterator mi)
rpmdbMatchIterator | rpmdbFreeIterator (rpmdbMatchIterator mi)
rpmdbIndexIterator | rpmdbIndexIteratorInit (rpmdb db, rpmDbiTag rpmtag)
int | rpmdbIndexIteratorNext (rpmdbIndexIterator ii, const void **key, size_t *keylen)
int | rpmdbIndexIteratorNextTd (rpmdbIndexIterator ii, rpmtd keytd)
unsigned int | rpmdbIndexIteratorNumPkgs (rpmdbIndexIterator ii)
unsigned int | rpmdbIndexIteratorPkgOffset (rpmdbIndexIterator ii, unsigned int nr)
unsigned int | rpmdbIndexIteratorTagNum (rpmdbIndexIterator ii, unsigned int nr)
rpmdbIndexIterator | rpmdbIndexIteratorFree (rpmdbIndexIterator ii)
int | rpmdbCtrl (rpmdb db, rpmdbCtrlOp ctrl)
char * | rpmdbCookie (rpmdb db)

## Detailed Description

Opening & accessing the RPM indices using Berkeley DB (the so called rpmdb)

## Function Documentation

## ◆ rpmdbAppendIterator()

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

Append items to set of package instances to iterate.

Parameters

  mi | rpm database iterator
  hdrNums | array of package instances
  nHdrNums | number 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

  db | rpm 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

  db | rpm database
  name | rpm package name

Returns
  number of instances

## ◆ rpmdbCtrl()

int rpmdbCtrl | ( | rpmdb | db,
|  | rpmdbCtrlOp | ctrl
| ) |  |

manipulate the rpm database

Parameters

  db | rpm database
  ctrl | operation

Returns
  0 on success; != 0 on error

## ◆ rpmdbFreeIterator()

rpmdbMatchIterator rpmdbFreeIterator | ( | rpmdbMatchIterator | mi | ) |

Destroy rpm database iterator.

Parameters

  mi | rpm database iterator

Returns
  NULL always

## ◆ rpmdbGetIteratorCount()

int rpmdbGetIteratorCount | ( | rpmdbMatchIterator | mi | ) |

Return number of elements in rpm database iterator.

Parameters

  mi | rpm 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

  mi | rpm database iterator

Returns
  current header join key

## ◆ rpmdbIndexIteratorFree()

rpmdbIndexIterator rpmdbIndexIteratorFree | ( | rpmdbIndexIterator | ii | ) |

Free index iterator

Parameters

  ii | index iterator return NULL

## ◆ rpmdbIndexIteratorInit()

rpmdbIndexIterator rpmdbIndexIteratorInit | ( | rpmdb | db,
|  | rpmDbiTag | rpmtag
| ) |  |

Get an iterator for an index

Parameters

  db | rpm database
  rpmtag | the 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

  ii | index iterator
  key | address to save the pointer to the key
  keylen | address 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

  ii | index iterator
  keytd | tag 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

  ii | index iterator

Returns
  number of entries. 0 on error.

## ◆ rpmdbIndexIteratorPkgOffset()

unsigned int rpmdbIndexIteratorPkgOffset | ( | rpmdbIndexIterator | ii,
|  | unsigned int | nr
| ) |  |

Get package offset of entry

Parameters

  ii | index iterator
  nr | number of the entry

Returns
  db offset of pkg

## ◆ rpmdbIndexIteratorTagNum()

unsigned int rpmdbIndexIteratorTagNum | ( | rpmdbIndexIterator | ii,
|  | unsigned int | nr
| ) |  |

Get tag number of entry

Parameters

  ii | index iterator
  nr | number of the entry

Returns
  number of tag within the package

## ◆ rpmdbInitIterator()

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

Return database iterator.

Parameters

  db | rpm database
  rpmtag | database index tag
  keyp | key data (NULL for sequential access)
  keylen | key data length (0 will use strlen(keyp))

Returns
  NULL on failure

## ◆ rpmdbNextIterator()

Header rpmdbNextIterator | ( | rpmdbMatchIterator | mi | ) |

Return next package header from iteration.

Parameters

  mi | rpm database iterator

Returns
  NULL on end of iteration.

## ◆ rpmdbOp()

rpmop rpmdbOp | ( | rpmdb | db,
|  | rpmdbOpX | opx
| ) |  |

Retrieve operation timestamp from rpm database.

Parameters

  db | rpm database
  opx | operation timestamp index

Returns
  pointer to operation timestamp.

## ◆ rpmdbOpenAll()

int rpmdbOpenAll | ( | rpmdb | db | ) |

Open all database indices.

Parameters

  db | rpm 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

  mi | rpm database iterator
  ts | transaction 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

  mi | rpm database iterator
  modified | new value of modified

Returns
  previous value

## ◆ rpmdbSetIteratorRE()

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

Add pattern to iterator selector.

Parameters

  mi | rpm database iterator
  tag | rpm tag
  mode | type of pattern match
  pattern | pattern 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

  mi | rpm database iterator
  rewrite | new value of rewrite

Returns
  previous value