+ if (entry != SOLVID_META && (entry < data->start || entry >= data->end))
+ continue;
+ if (!repodata_precheck_keyname(data, keyname))
+ continue;
+ chk = repodata_lookup_bin_checksum(data, entry, keyname, typep);
+ if (chk)
+ return chk;
+ if (repodata_lookup_type(data, entry, keyname))
+ return 0;
+ }
+ *typep = 0;
+ return 0;
+}
+
+const char *
+repo_lookup_checksum(Repo *repo, Id entry, Id keyname, Id *typep)
+{
+ const unsigned char *chk = repo_lookup_bin_checksum(repo, entry, keyname, typep);
+ return chk ? pool_bin2hex(repo->pool, chk, sat_chksum_len(*typep)) : 0;
+}
+
+int
+repo_lookup_void(Repo *repo, Id entry, Id keyname)
+{
+ Repodata *data;
+ int i;
+ Id type;
+
+ for (i = 0, data = repo->repodata; i < repo->nrepodata; i++, data++)
+ {
+ if (entry != SOLVID_META && (entry < data->start || entry >= data->end))
+ continue;
+ if (!repodata_precheck_keyname(data, keyname))
+ continue;
+ type = repodata_lookup_type(data, entry, keyname);
+ if (type)
+ return type == REPOKEY_TYPE_VOID;
+ }
+ return 0;
+}
+
+Id
+repo_lookup_type(Repo *repo, Id entry, Id keyname)
+{
+ Repodata *data;
+ int i;
+ Id type;
+
+ for (i = 0, data = repo->repodata; i < repo->nrepodata; i++, data++)
+ {
+ if (entry != SOLVID_META && (entry < data->start || entry >= data->end))
+ continue;
+ if (!repodata_precheck_keyname(data, keyname))
+ continue;
+ type = repodata_lookup_type(data, entry, keyname);
+ if (type)
+ return type == REPOKEY_TYPE_DELETED ? 0 : type;
+ }
+ return 0;
+}
+
+/***********************************************************************/
+
+Repodata *
+repo_add_repodata(Repo *repo, int flags)
+{
+ int i;
+ if ((flags & REPO_USE_LOADING) != 0)
+ {
+ for (i = repo->nrepodata - 1; i >= 0; i--)
+ if (repo->repodata[i].state == REPODATA_LOADING)
+ {
+ Repodata *data = repo->repodata + i;
+ /* re-init */
+ /* hack: we mis-use REPO_REUSE_REPODATA here */
+ if (!(flags & REPO_REUSE_REPODATA))
+ repodata_empty(data, (flags & REPO_LOCALPOOL) ? 1 : 0);
+ return data;
+ }
+ return 0; /* must not create a new repodata! */
+ }
+ if ((flags & REPO_REUSE_REPODATA) != 0)
+ {
+ for (i = repo->nrepodata - 1; i >= 0; i--)
+ if (repo->repodata[i].state != REPODATA_STUB)
+ return repo->repodata + i;
+ }
+ return repodata_create(repo, (flags & REPO_LOCALPOOL) ? 1 : 0);
+}
+
+Repodata *
+repo_last_repodata(Repo *repo)
+{
+ int i;
+ for (i = repo->nrepodata - 1; i >= 0; i--)
+ if (repo->repodata[i].state != REPODATA_STUB)
+ return repo->repodata + i;
+ return repo_add_repodata(repo, 0);
+}
+
+void
+repo_set_id(Repo *repo, Id p, Id keyname, Id id)
+{
+ Repodata *data = repo_last_repodata(repo);
+ if (data->localpool)
+ id = repodata_localize_id(data, id, 1);
+ repodata_set_id(data, p, keyname, id);
+}
+
+void
+repo_set_num(Repo *repo, Id p, Id keyname, unsigned int num)
+{
+ Repodata *data;
+ if (p >= 0)
+ {
+ if (keyname == RPM_RPMDBID)
+ {
+ if (!repo->rpmdbid)
+ repo->rpmdbid = repo_sidedata_create(repo, sizeof(Id));
+ repo->rpmdbid[p] = num;
+ return;