repomd: Add cr_repomd_get_record function
authorTomas Mlcoch <tmlcoch@redhat.com>
Wed, 18 Sep 2013 13:12:18 +0000 (15:12 +0200)
committerTomas Mlcoch <tmlcoch@redhat.com>
Wed, 18 Sep 2013 13:12:18 +0000 (15:12 +0200)
src/repomd.c
src/repomd.h

index 31bd581..9ba4742 100644 (file)
@@ -684,3 +684,17 @@ cr_repomd_add_content_tag(cr_Repomd *repomd, const char *tag)
                             cr_safe_string_chunk_insert(repomd->chunk, tag));
 }
 
+cr_RepomdRecord *
+cr_repomd_get_record(cr_Repomd *repomd, const char *type)
+{
+    if (!repomd || !type)
+        return NULL;
+
+    for (GSList *elem = repomd->records; elem; elem = g_slist_next(elem)) {
+        cr_RepomdRecord *rec = elem->data;
+        assert(rec);
+        if (!g_strcmp0(rec->type, type))
+            return rec;
+    }
+    return NULL;
+}
index cd4d5ee..7d134cc 100644 (file)
@@ -223,6 +223,13 @@ void cr_repomd_add_repo_tag(cr_Repomd *repomd, const char *tag);
  */
 void cr_repomd_add_content_tag(cr_Repomd *repomd, const char *tag);
 
+/** Get repomd record from the repomd object.
+ * @param repomd                cr_Repomd object
+ * @param type                  Type of the record
+ * @return                      Pointer to a record of desired type or NULL
+ */
+cr_RepomdRecord *cr_repomd_get_record(cr_Repomd *repomd, const char *type);
+
 /** Frees cr_Repomd object and all its cr_RepomdRecord objects
  * @param repomd                cr_Repomd object
  */