int rpmdbCountPackages(rpmdb db, const char * name)
{
- DBC * dbcursor = NULL;
+ dbiCursor dbc;
DBT key, data;
dbiIndex dbi;
rpmDbiTag dbtag = RPMDBI_NAME;
int rc;
- int xx;
if (db == NULL)
return 0;
key.data = (void *) name;
key.size = strlen(name);
- xx = dbiCopen(dbi, &dbcursor, 0);
- rc = dbiGet(dbi, dbcursor, &key, &data, DB_SET);
- xx = dbiCclose(dbi, dbcursor, 0);
- dbcursor = NULL;
+ dbc = dbiCursorInit(dbi, 0);
+ rc = dbiCursorGet(dbc, &key, &data, DB_SET);
+ dbc = dbiCursorFree(dbc);
if (rc == 0) { /* success */
dbiIndexSet matches = NULL;
union _dbswap mi_offset;
int rc = 0;
int xx;
- DBC * dbcursor = NULL;
+ dbiCursor dbc;
DBT key;
if (dbi == NULL || hdrNum == 0)
memset(&key, 0, sizeof(key));
- xx = dbiCopen(dbi, &dbcursor, DB_WRITECURSOR);
+ dbc = dbiCursorInit(dbi, DB_WRITECURSOR);
mi_offset.ui = hdrNum;
if (dbiByteSwapped(dbi) == 1)
key.size = sizeof(mi_offset.ui);
if (hdr) {
- rc = dbiPut(dbi, dbcursor, &key, hdr, DB_KEYLAST);
+ rc = dbiCursorPut(dbc, &key, hdr, DB_KEYLAST);
if (rc) {
rpmlog(RPMLOG_ERR,
_("error(%d) adding header #%d record\n"), rc, hdrNum);
DBT data;
memset(&data, 0, sizeof(data));
- rc = dbiGet(dbi, dbcursor, &key, &data, DB_SET);
+ rc = dbiCursorGet(dbc, &key, &data, DB_SET);
if (rc) {
rpmlog(RPMLOG_ERR,
_("error(%d) removing header #%d record\n"), rc, hdrNum);
} else
- rc = dbiDel(dbi, dbcursor, &key, &data, 0);
+ rc = dbiCursorDel(dbc, &key, &data, 0);
}
- xx = dbiCclose(dbi, dbcursor, DB_WRITECURSOR);
+ dbiCursorFree(dbc);
xx = dbiSync(dbi, 0);
return rc;
if (ret == 0) {
struct dbiIndexItem rec = { .hdrNum = hdrNum, .tagNum = 0 };
int rc = 0;
- DBC * dbcursor = NULL;
+ dbiCursor dbc = NULL;
DBT key, data;
memset(&key, 0, sizeof(key));
if (!headerGet(h, rpmtag, &tagdata, HEADERGET_MINMEM))
continue;
- xx = dbiCopen(dbi, &dbcursor, DB_WRITECURSOR);
+ dbc = dbiCursorInit(dbi, DB_WRITECURSOR);
logAddRemove(dbiName(dbi), 1, &tagdata);
while (rpmtdNext(&tagdata) >= 0) {
* */
set = NULL;
- rc = dbiGet(dbi, dbcursor, &key, &data, DB_SET);
+ rc = dbiCursorGet(dbc, &key, &data, DB_SET);
if (rc == 0) { /* success */
(void) dbt2set(dbi, &data, &set);
} else if (rc == DB_NOTFOUND) { /* not found */
if (set->count > 0) {
(void) set2dbt(dbi, &data, set);
- rc = dbiPut(dbi, dbcursor, &key, &data, DB_KEYLAST);
+ rc = dbiCursorPut(dbc, &key, &data, DB_KEYLAST);
if (rc) {
rpmlog(RPMLOG_ERR,
_("error(%d) storing record \"%s\" into %s\n"),
data.data = _free(data.data);
data.size = 0;
} else {
- rc = dbiDel(dbi, dbcursor, &key, &data, 0);
+ rc = dbiCursorDel(dbc, &key, &data, 0);
if (rc) {
rpmlog(RPMLOG_ERR,
_("error(%d) removing record \"%s\" from %s\n"),
}
}
- xx = dbiCclose(dbi, dbcursor, DB_WRITECURSOR);
- dbcursor = NULL;
-
+ dbc = dbiCursorFree(dbc);
xx = dbiSync(dbi, 0);
rpmtdFreeData(&tagdata);
unsigned int hdrNum = 0;
if (dbi != NULL && dbiType(dbi) == DBI_PRIMARY) {
- DBC * dbcursor = NULL;
+ dbiCursor dbc;
DBT key, data;
unsigned int firstkey = 0;
union _dbswap mi_offset;
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
- ret = dbiCopen(dbi, &dbcursor, alloc ? DB_WRITECURSOR : 0);
+ dbc = dbiCursorInit(dbi, alloc ? DB_WRITECURSOR : 0);
/* Key 0 holds the current largest instance, fetch it */
key.data = &firstkey;
key.size = sizeof(firstkey);
- ret = dbiGet(dbi, dbcursor, &key, &data, DB_SET);
+ ret = dbiCursorGet(dbc, &key, &data, DB_SET);
if (ret == 0 && data.data) {
memcpy(&mi_offset, data.data, sizeof(mi_offset.ui));
}
/* Unless we manage to insert the new instance number, we failed */
- ret = dbiPut(dbi, dbcursor, &key, &data, DB_KEYLAST);
+ ret = dbiCursorPut(dbc, &key, &data, DB_KEYLAST);
if (ret) {
hdrNum = 0;
rpmlog(RPMLOG_ERR,
ret = dbiSync(dbi, 0);
}
- ret = dbiCclose(dbi, dbcursor, 0);
+ dbiCursorFree(dbc);
}
return hdrNum;
{
int xx, i, rc = 0;
struct rpmtd_s tagdata, reqflags;
- DBC * dbcursor = NULL;
+ dbiCursor dbc = NULL;
switch (rpmtag) {
case RPMTAG_REQUIRENAME:
tagdata.count = 1;
}
- xx = dbiCopen(dbi, &dbcursor, DB_WRITECURSOR);
+ dbc = dbiCursorInit(dbi, DB_WRITECURSOR);
logAddRemove(dbiName(dbi), 0, &tagdata);
while ((i = rpmtdNext(&tagdata)) >= 0) {
set = NULL;
- rc = dbiGet(dbi, dbcursor, &key, &data, DB_SET);
+ rc = dbiCursorGet(dbc, &key, &data, DB_SET);
if (rc == 0) { /* success */
/* With duplicates, cursor is positioned, discard the record. */
if (!dbi->dbi_permit_dups)
(void) dbiAppendSet(set, &rec, 1, sizeof(rec), 0);
(void) set2dbt(dbi, &data, set);
- rc = dbiPut(dbi, dbcursor, &key, &data, DB_KEYLAST);
+ rc = dbiCursorPut(dbc, &key, &data, DB_KEYLAST);
if (rc) {
rpmlog(RPMLOG_ERR,
}
}
- xx = dbiCclose(dbi, dbcursor, DB_WRITECURSOR);
- dbcursor = NULL;
-
+ dbiCursorFree(dbc);
xx = dbiSync(dbi, 0);
exit: