diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-04-01 11:13:37 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-04-01 11:13:37 +0300 |
commit | f30e6d409a19a943224d6697a06dd1996bc61d72 (patch) | |
tree | 26c897dacbe5d04c0f01fe5348b877e99507f69e /lib/backend | |
parent | 12236b58b62c0c21048aff843624d7623d43fda7 (diff) | |
download | librpm-tizen-f30e6d409a19a943224d6697a06dd1996bc61d72.tar.gz librpm-tizen-f30e6d409a19a943224d6697a06dd1996bc61d72.tar.bz2 librpm-tizen-f30e6d409a19a943224d6697a06dd1996bc61d72.zip |
Split dbiIndex out of rpmdb_internal.h into header of its own
- the dbi presents an internal api of its own, and deserves a separate
header (baby steps to making dbiIndex opaque outside the backend)
- move dbiVerify() to the backend where it belongs
- mark all the dbiFoo() functions as internal
Diffstat (limited to 'lib/backend')
-rw-r--r-- | lib/backend/db3.c | 6 | ||||
-rw-r--r-- | lib/backend/dbi.h | 202 |
2 files changed, 208 insertions, 0 deletions
diff --git a/lib/backend/db3.c b/lib/backend/db3.c index 6f8f67458..b886868a7 100644 --- a/lib/backend/db3.c +++ b/lib/backend/db3.c @@ -374,6 +374,12 @@ int dbiStat(dbiIndex dbi, unsigned int flags) return rc; } +int dbiVerify(dbiIndex dbi, unsigned int flags) +{ + dbi->dbi_verify_on_close = 1; + return dbiClose(dbi, flags); +} + int dbiClose(dbiIndex dbi, unsigned int flags) { rpmdb rpmdb = dbi->dbi_rpmdb; diff --git a/lib/backend/dbi.h b/lib/backend/dbi.h new file mode 100644 index 000000000..d1dcb9ea0 --- /dev/null +++ b/lib/backend/dbi.h @@ -0,0 +1,202 @@ +#ifndef _DBI_H +#define _DBI_H + +typedef struct _dbiIndex * dbiIndex; + +/** \ingroup dbi + * Describes an index database (implemented on Berkeley db functionality). + */ +struct _dbiIndex { + const char * dbi_file; /*!< file component of path */ + + int dbi_ecflags; /*!< db_env_create flags */ + int dbi_cflags; /*!< db_create flags */ + int dbi_oeflags; /*!< common (db,dbenv}->open flags */ + int dbi_eflags; /*!< dbenv->open flags */ + int dbi_oflags; /*!< db->open flags */ + int dbi_tflags; /*!< dbenv->txn_begin flags */ + + int dbi_type; /*!< db index type */ + unsigned dbi_mode; /*!< mode to use on open */ + int dbi_perms; /*!< file permission to use on open */ + + int dbi_verify_on_close; + int dbi_use_dbenv; /*!< use db environment? */ + int dbi_permit_dups; /*!< permit duplicate entries? */ + int dbi_no_fsync; /*!< no-op fsync for db */ + int dbi_no_dbsync; /*!< don't call dbiSync */ + int dbi_lockdbfd; /*!< do fcntl lock on db fd */ + int dbi_byteswapped; + + /* dbenv parameters */ + /* XXX db-4.3.14 adds dbenv as 1st arg. */ + int dbi_verbose; + /* mpool sub-system parameters */ + int dbi_mmapsize; /*!< (10Mb) */ + int dbi_cachesize; /*!< (128Kb) */ + /* dbinfo parameters */ + int dbi_pagesize; /*!< (fs blksize) */ + + rpmdb dbi_rpmdb; /*!< the parent rpm database */ + rpmTag dbi_rpmtag; /*!< rpm tag used for index */ + int dbi_jlen; /*!< size of join key */ + + DB * dbi_db; /*!< Berkeley DB * handle */ + DB_TXN * dbi_txnid; /*!< Bekerley DB_TXN * transaction id */ + void * dbi_stats; /*!< Berkeley db statistics */ +}; + +/** \ingroup dbi + * Return new configured index database handle instance. + * @param rpmdb rpm database + * @param rpmtag rpm tag + * @return index database handle + */ +RPM_GNUC_INTERNAL +dbiIndex dbiNew(rpmdb rpmdb, rpmTag rpmtag); + +/** \ingroup dbi + * Destroy index database handle instance. + * @param dbi index database handle + * @return NULL always + */ +RPM_GNUC_INTERNAL +dbiIndex dbiFree( dbiIndex dbi); + +/** \ingroup dbi + * Format dbi open flags for debugging print. + * @param dbflags db open flags + * @param print_dbenv_flags format db env flags instead? + * @return formatted flags (malloced) + */ +RPM_GNUC_INTERNAL +char * prDbiOpenFlags(int dbflags, int print_dbenv_flags); + +/** \ingroup dbi + * Actually open the database of the index. + * @param db rpm database + * @param rpmtag rpm tag + * @param dbiIndex address of index database handle + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiOpenDB(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip); + + +/* FIX: vector annotations */ +/** \ingroup dbi + * Open a database cursor. + * @param dbi index database handle + * @retval dbcp returned database cursor + * @param flags DB_WRITECURSOR if writing, or 0 + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiCopen(dbiIndex dbi, DBC ** dbcp, unsigned int flags); + +/** \ingroup dbi + * Close a database cursor. + * @param dbi index database handle + * @param dbcursor database cursor + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiCclose(dbiIndex dbi, DBC * dbcursor, unsigned int flags); + +/** \ingroup dbi + * Delete (key,data) pair(s) from index database. + * @param dbi index database handle + * @param dbcursor database cursor (NULL will use db->del) + * @param key delete key value/length/flags + * @param data delete data value/length/flags + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiDel(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, + unsigned int flags); + +/** \ingroup dbi + * Retrieve (key,data) pair from index database. + * @param dbi index database handle + * @param dbcursor database cursor (NULL will use db->get) + * @param key retrieve key value/length/flags + * @param data retrieve data value/length/flags + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiGet(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, + unsigned int flags); + +/** \ingroup dbi + * Store (key,data) pair in index database. + * @param dbi index database handle + * @param dbcursor database cursor (NULL will use db->put) + * @param key store key value/length/flags + * @param data store data value/length/flags + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiPut(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, + unsigned int flags); + +/** \ingroup dbi + * Retrieve count of (possible) duplicate items. + * @param dbi index database handle + * @param dbcursor database cursor + * @param countp address of count + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiCount(dbiIndex dbi, DBC * dbcursor, unsigned int * countp, + unsigned int flags); + +/** \ingroup dbi + * Close index database. + * @param dbi index database handle + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiClose(dbiIndex dbi, unsigned int flags); + +/** \ingroup dbi + * Flush pending operations to disk. + * @param dbi index database handle + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiSync (dbiIndex dbi, unsigned int flags); + +/** \ingroup dbi + * Verify (and close) index database. + * @param dbi index database handle + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiVerify(dbiIndex dbi, unsigned int flags); + +/** \ingroup dbi + * Is database byte swapped? + * @param dbi index database handle + * @return 0 same order, 1 swapped order + */ +RPM_GNUC_INTERNAL +int dbiByteSwapped(dbiIndex dbi); + +/** \ingroup dbi + * Is database byte swapped? + * @param dbi index database handle + * @param flags DB_FAST_STAT or 0 + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiStat(dbiIndex dbi, unsigned int flags); + +#endif /* _DBI_H */ |