return 0;
}
+rpmdbMatchIterator rpmdbNewIterator(rpmdb db, rpmDbiTagVal dbitag)
+{
+ rpmdbMatchIterator mi = NULL;
+
+ if (rpmdbOpenIndex(db, dbitag, 0) == NULL)
+ return NULL;
+
+ mi = xcalloc(1, sizeof(*mi));
+ mi->mi_keyp = NULL;
+ mi->mi_keylen = 0;
+ mi->mi_set = NULL;
+ mi->mi_db = rpmdbLink(db);
+ mi->mi_rpmtag = dbitag;
+
+ mi->mi_dbc = NULL;
+ mi->mi_setx = 0;
+ mi->mi_h = NULL;
+ mi->mi_sorted = 0;
+ mi->mi_cflags = 0;
+ mi->mi_modified = 0;
+ mi->mi_prevoffset = 0;
+ mi->mi_offset = 0;
+ mi->mi_filenum = 0;
+ mi->mi_nre = 0;
+ mi->mi_re = NULL;
+
+ mi->mi_ts = NULL;
+ mi->mi_hdrchk = NULL;
+
+ /* Chain cursors for teardown on abnormal exit. */
+ mi->mi_next = rpmmiRock;
+ rpmmiRock = mi;
+
+ return mi;
+};
+
rpmdbMatchIterator rpmdbInitIterator(rpmdb db, rpmDbiTagVal rpmtag,
const void * keyp, size_t keylen)
{
}
}
- mi = xcalloc(1, sizeof(*mi));
+ mi = rpmdbNewIterator(db, rpmtag);
mi->mi_keyp = mi_keyp;
mi->mi_keylen = keylen;
mi->mi_set = set;
- mi->mi_db = rpmdbLink(db);
- mi->mi_rpmtag = rpmtag;
-
- /* Chain cursors for teardown on abnormal exit. */
- mi->mi_next = rpmmiRock;
- rpmmiRock = mi;
-
- mi->mi_dbc = NULL;
- mi->mi_setx = 0;
- mi->mi_h = NULL;
- mi->mi_sorted = 0;
- mi->mi_cflags = 0;
- mi->mi_modified = 0;
- mi->mi_prevoffset = 0;
- mi->mi_offset = 0;
- mi->mi_filenum = 0;
- mi->mi_nre = 0;
- mi->mi_re = NULL;
-
- mi->mi_ts = NULL;
- mi->mi_hdrchk = NULL;
if (rpmtag != RPMDBI_PACKAGES && keyp == NULL) {
rpmdbSortIterator(mi);
*/
int rpmdbPruneIterator(rpmdbMatchIterator mi, intHash hdrNums);
+/** \ingroup rpmdb
+ * Create a new, empty match iterator (for purposes of extending it
+ * through other means)
+ * @param db rpm database
+ * @param dbitag database index tag
+ * @return empty match iterator
+ */
+RPM_GNUC_INTERNAL
+rpmdbMatchIterator rpmdbNewIterator(rpmdb db, rpmDbiTagVal dbitag);
+
#ifndef __APPLE__
/**
* * Mergesort, same arguments as qsort(2).
rpmStringSet baseNames = rpmStringSetCreate(fileCount,
hashFunctionString, strcmp, NULL);
- mi = rpmdbInitIterator(rpmtsGetRdb(ts), RPMDBI_BASENAMES, NULL, 0);
+ mi = rpmdbNewIterator(rpmtsGetRdb(ts), RPMDBI_BASENAMES);
pi = rpmtsiInit(ts);
while ((p = rpmtsiNext(pi, 0)) != NULL) {