# DBI.

## Files

file | rpmlib.h
file | rpmdb.c
file | rpmdb.h
| Access RPM indices using Berkeley DB interface(s).

## Data Structures

struct | dbiHStats_s
| Hash database statistics. More...
struct | dbiBStats_s
| B-tree database statistics. More...
struct | _dbiIndexItem
| A single item from an index database (i.e. More...
struct | _dbiIndexSet
| Items retrieved from the index database. More...
struct | _dbiVec
| Private methods for accessing an index database. More...
struct | _dbiIndex
| Describes an index database (implemented on Berkeley db3 functionality). More...

## Functions

dbiIndex | dbiOpen (rpmdb db, int rpmtag, unsigned int flags)
| Return handle for an index database.
int | dbiCopen (dbiIndex dbi, void **dbcp, unsigned int flags)
int | dbiCclose (dbiIndex dbi, void *dbcursor, unsigned int flags)
int | dbiDel (dbiIndex dbi, void *dbcursor, const void *keyp, size_t keylen, unsigned int flags)
| Delete (key,data) pair(s) from index database.
int | dbiGet (dbiIndex dbi, void *dbcursor, void **keypp, size_t *keylenp, void **datapp, size_t *datalenp, unsigned int flags)
| Retrieve (key,data) pair from index database.
int | dbiPut (dbiIndex dbi, void *dbcursor, const void *keyp, size_t keylen, const void *datap, size_t datalen, unsigned int flags)
| Store (key,data) pair in index database.
int | dbiCount (dbiIndex dbi, void *dbcursor, unsigned int *countp, unsigned int flags)
| Retrieve count of (possible) duplicate items.
int | dbiVerify (dbiIndex dbi, unsigned int flags)
| Verify (and close) index database.
int | dbiClose (dbiIndex dbi, unsigned int flags)
| Close index database.
int | dbiSync (dbiIndex dbi, unsigned int flags)
| Flush pending operations to disk.
int | dbiByteSwapped (dbiIndex dbi)
| Is database byte swapped?
dbiIndexSet | dbiFreeIndexSet (dbiIndexSet set)
| Destroy set of index database items.
unsigned int | dbiIndexSetCount (dbiIndexSet set)
| Count items in index database set.
unsigned int | dbiIndexRecordOffset (dbiIndexSet set, int recno)
| Return record offset of header from element in index database set.
unsigned int | dbiIndexRecordFileNumber (dbiIndexSet set, int recno)
| Return file index from element in index database set.

## Variables

int(* | _dbiVec::open )(rpmdb rpmdb, int rpmtag, dbiIndex *dbip)
| Return handle for an index database.
int(* | _dbiVec::close )(dbiIndex dbi, unsigned int flags)
| Close index database, and destroy database handle.
int(* | _dbiVec::sync )(dbiIndex dbi, unsigned int flags)
| Flush pending operations to disk.
int(* | _dbiVec::copen )(dbiIndex dbi, void **dbcp, unsigned int flags)
| Open database cursor.
int(* | _dbiVec::cclose )(dbiIndex dbi, void *dbcursor, unsigned int flags)
| Close database cursor.
int(* | _dbiVec::cdel )(dbiIndex dbi, void *dbcursor, const void *keyp, size_t keylen, unsigned int flags)
| Delete (key,data) pair(s) using db->del or dbcursor->c_del.
int(* | _dbiVec::cget )(dbiIndex dbi, void *dbcursor, void **keypp, size_t *keylenp, void **datapp, size_t *datalenp, unsigned int flags)
| Retrieve (key,data) pair using db->get or dbcursor->c_get.
int(* | _dbiVec::cput )(dbiIndex dbi, void *dbcursor, const void *keyp, size_t keylen, const void *datap, size_t datalen, unsigned int flags)
| Store (key,data) pair using db->put or dbcursor->c_put.
int(* | _dbiVec::ccount )(dbiIndex dbi, void *dbcursor, unsigned int *countp, unsigned int flags)
| Retrieve count of (possible) duplicate items using dbcursor->c_count.
int(* | _dbiVec::byteswapped )(dbiIndex dbi)
| Is database byte swapped?
int(* | _dbiVec::stat )(dbiIndex dbi, unsigned int flags)
| Save statistics in database handle.

## Function Documentation

int dbiByteSwapped | ( | dbiIndex | dbi | ) |

Is database byte swapped?

Parameters:

  | dbi | index database handle

Returns:
  0 no

Definition at line 183 of file rpmdb.c.

int dbiCclose | ( | dbiIndex | dbi,
|  | void * | dbcursor,
|  | unsigned int | flags |
| ) |  |  |

Parameters:

  | dbi | index database handle
  | flags | (unused)

Definition at line 195 of file rpmdb.c.

int dbiClose | ( | dbiIndex | dbi,
|  | unsigned int | flags |
| ) |  |  |

Close index database.

Parameters:

  | dbi | index database handle
  | flags | (unused)

Returns:
  0 on success

Definition at line 337 of file rpmdb.c.

int dbiCopen | ( | dbiIndex | dbi,
|  | void ** | dbcp,
|  | unsigned int | flags |
| ) |  |  |

Parameters:

  | dbi | index database handle
  | flags | DBI_WRITECURSOR, DBI_ITERATOR or 0

Definition at line 188 of file rpmdb.c.

int dbiCount | ( | dbiIndex | dbi,
|  | void * | dbcursor,
|  | unsigned int * | countp,
|  | unsigned int | flags |
| ) |  |  |

Retrieve count of (possible) duplicate items.

Parameters:

  | dbi | index database handle
  | dbcursor | database cursor
  | countp | address of count
  | flags | (unused)

Returns:
  0 on success

Definition at line 311 of file rpmdb.c.

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

Delete (key,data) pair(s) from index database.

Parameters:

  | dbi | index database handle
  | keyp | key data
  | keylen | key data length
  | flags | (unused)

Returns:
  0 on success

Definition at line 211 of file rpmdb.c.

dbiIndexSet dbiFreeIndexSet | ( | dbiIndexSet | set | ) |

Destroy set of index database items.

Parameters:

  | set | set of index database items

Returns:
  NULL always

Definition at line 748 of file rpmdb.c.

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

Retrieve (key,data) pair from index database.

Parameters:

  | dbi | index database handle
  | keypp | address of key data
  | keylenp | address of key data length
  | datapp | address of data pointer
  | datalenp | address of data length
  | flags | (unused)

Returns:
  0 on success

Definition at line 229 of file rpmdb.c.

unsigned int dbiIndexRecordFileNumber | ( | dbiIndexSet | set,
|  | int | recno |
| ) |  |  |

Return file index from element in index database set.

Parameters:

  | set | set of index database items
  | recno | index of item in set

Returns:
  file index

Definition at line 743 of file rpmdb.c.

unsigned int dbiIndexRecordOffset | ( | dbiIndexSet | set,
|  | int | recno |
| ) |  |  |

Return record offset of header from element in index database set.

Parameters:

  | set | set of index database items
  | recno | index of item in set

Returns:
  record offset of header

Definition at line 738 of file rpmdb.c.

unsigned int dbiIndexSetCount | ( | dbiIndexSet | set | ) |

Count items in index database set.

Parameters:

  | set | set of index database items

Returns:
  number of items

Definition at line 733 of file rpmdb.c.

dbiIndex dbiOpen | ( | rpmdb | db,
|  | int | rpmtag,
|  | unsigned int | flags |
| ) |  |  |

Return handle for an index database.

Parameters:

  | db | rpm database
  | rpmtag | rpm tag
  | flags | (unused)

Returns:
  index database handle

Definition at line 343 of file rpmdb.c.

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

Store (key,data) pair in index database.

Parameters:

  | dbi | index database handle
  | keyp | key data
  | keylen | key data length
  | datap | data pointer
  | datalen | data length
  | flags | (unused)

Returns:
  0 on success

Definition at line 271 of file rpmdb.c.

int dbiSync | ( | dbiIndex | dbi,
|  | unsigned int | flags |
| ) |  |  |

Flush pending operations to disk.

Parameters:

  | dbi | index database handle
  | flags | (unused)

Returns:
  0 on success

Definition at line 176 of file rpmdb.c.

int dbiVerify | ( | dbiIndex | dbi,
|  | unsigned int | flags |
| ) |  |  |

Verify (and close) index database.

Parameters:

  | dbi | index database handle
  | flags | (unused)

Returns:
  0 on success

Definition at line 322 of file rpmdb.c.

## Variable Documentation

int(* _dbiVec::byteswapped)(dbiIndex dbi)`[inherited]`

Is database byte swapped?

Parameters:

  | dbi | index database handle

Returns:
  0 no

int(* _dbiVec::cclose)(dbiIndex dbi,void *dbcursor, unsigned int flags)`[inherited]`

Close database cursor.

Parameters:

  | dbi | index database handle
  | dbcursor | database cursor
  | flags | (unused)

int(* _dbiVec::ccount)(dbiIndex dbi, void *dbcursor,unsigned int *countp, unsigned int flags)`[inherited]`

Retrieve count of (possible) duplicate items using dbcursor->c_count.

Parameters:

  | dbi | index database handle
  | dbcursor | database cursor
  | countp | address of count
  | flags | (unused)

Returns:
  0 on success

int(* _dbiVec::cdel)(dbiIndex dbi, void *dbcursor, const void *keyp, size_t keylen, unsigned int flags)`[inherited]`

Delete (key,data) pair(s) using db->del or dbcursor->c_del.

Parameters:

  | dbi | index database handle
  | dbcursor | database cursor
  | keyp | key data
  | keylen | key data length
  | flags | (unused)

Returns:
  0 on success

int(* _dbiVec::cget)(dbiIndex dbi, void *dbcursor,void **keypp,size_t *keylenp,void **datapp,size_t *datalenp, unsigned int flags)`[inherited]`

Retrieve (key,data) pair using db->get or dbcursor->c_get.

Parameters:

  | dbi | index database handle
  | dbcursor | database cursor
  | keypp | address of key data
  | keylenp | address of key data length
  | datapp | address of data pointer
  | datalenp | address of data length
  | flags | (unused)

Returns:
  0 on success

int(* _dbiVec::close)(dbiIndex dbi, unsigned int flags)`[inherited]`

Close index database, and destroy database handle.

Parameters:

  | dbi | index database handle
  | flags | (unused)

Returns:
  0 on success

int(* _dbiVec::copen)(dbiIndex dbi,void **dbcp, unsigned int flags)`[inherited]`

Open database cursor.

Parameters:

  | dbi | index database handle
  | dbcp | address of database cursor
  | flags | (unused)

int(* _dbiVec::cput)(dbiIndex dbi, void *dbcursor, const void *keyp, size_t keylen, const void *datap, size_t datalen, unsigned int flags)`[inherited]`

Store (key,data) pair using db->put or dbcursor->c_put.

Parameters:

  | dbi | index database handle
  | dbcursor | database cursor
  | keyp | key data
  | keylen | key data length
  | datap | data pointer
  | datalen | data length
  | flags | (unused)

Returns:
  0 on success

int(* _dbiVec::open)(rpmdb rpmdb, int rpmtag,dbiIndex *dbip)`[inherited]`

Return handle for an index database.

Parameters:

  | rpmdb | rpm database
  | rpmtag | rpm tag

Returns:
  0 on success

int(* _dbiVec::stat)(dbiIndex dbi, unsigned int flags)`[inherited]`

Save statistics in database handle.

Parameters:

  | dbi | index database handle
  | flags | retrieve statistics that don't require traversal?

Returns:
  0 on success

int(* _dbiVec::sync)(dbiIndex dbi, unsigned int flags)`[inherited]`

Flush pending operations to disk.

Parameters:

  | dbi | index database handle
  | flags | (unused)

Returns:
  0 on success