Blob Blame History Raw
--- ./lib/rpmdb.c.orig	2020-11-27 13:09:17.968992873 +0000
+++ ./lib/rpmdb.c	2020-11-27 13:14:21.524165780 +0000
@@ -2679,6 +2679,48 @@ int rpmdbCtrl(rpmdb db, rpmdbCtrlOp ctrl
     return dbctrl ? dbCtrl(db, dbctrl) : 1;
 }
 
+const unsigned char *rpmdbNextIteratorHeaderBlob(rpmdbMatchIterator mi, unsigned int *size)
+{
+    dbiIndex dbi = NULL;
+    unsigned char * uh;
+    unsigned int uhlen;
+    int rc;
+    if (mi == NULL || mi->mi_re != NULL)
+	return NULL;
+    if (pkgdbOpen(mi->mi_db, 0, &dbi))
+	return NULL;
+    if (mi->mi_dbc == NULL)
+	mi->mi_dbc = dbiCursorInit(dbi, mi->mi_cflags);
+    miFreeHeader(mi, dbi);
+    uh = NULL;
+    uhlen = 0;
+    do {
+	if (mi->mi_set) {
+	    if (!(mi->mi_setx < mi->mi_set->count))
+		return NULL;
+	    mi->mi_offset = dbiIndexRecordOffset(mi->mi_set, mi->mi_setx);
+	    mi->mi_filenum = dbiIndexRecordFileNumber(mi->mi_set, mi->mi_setx);
+	} else {
+	    rc = pkgdbGet(dbi, mi->mi_dbc, 0, &uh, &uhlen);
+	    if (rc == 0)
+		mi->mi_offset = pkgdbKey(dbi, mi->mi_dbc);
+
+	    /* Terminate on error or end of keys */
+	    if (rc || (mi->mi_setx && mi->mi_offset == 0))
+		return NULL;
+	}
+	mi->mi_setx++;
+    } while (mi->mi_offset == 0);
+    if (uh == NULL) {
+	rc = pkgdbGet(dbi, mi->mi_dbc, mi->mi_offset, &uh, &uhlen);
+	if (rc || uh == NULL)
+	    return NULL;
+    }
+    if (size)
+	*size = uhlen;
+    return uh;
+}
+
 char *rpmdbCookie(rpmdb db)
 {
     void *cookie = NULL;
--- ./lib/rpmdb.h.orig	2020-11-27 13:09:17.968992873 +0000
+++ ./lib/rpmdb.h	2020-11-27 13:09:36.352942782 +0000
@@ -253,6 +253,14 @@ int rpmdbStat(const char *prefix, struct
  */
 int rpmdbFStat(rpmdb db, struct stat *statbuf);
 
+/** \ingroup rpmdb
+ * Return next unverified package header blob from iteration.
+ * @param mi           rpm database iterator
+ * @retval size         header blob size in bytes
+ * @return             NULL on end of iteration.
+ */
+const unsigned char *rpmdbNextIteratorHeaderBlob(rpmdbMatchIterator mi, unsigned int *size);
+
 #ifdef __cplusplus
 }
 #endif