From eb06f0b72f2562990aaa4c1c8907d1161fc30a69 Mon Sep 17 00:00:00 2001 From: Tomas Mlcoch Date: Wed, 18 Sep 2013 15:12:18 +0200 Subject: [PATCH] repomd: Add cr_repomd_get_record function --- src/repomd.c | 14 ++++++++++++++ src/repomd.h | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/src/repomd.c b/src/repomd.c index 31bd581..9ba4742 100644 --- a/src/repomd.c +++ b/src/repomd.c @@ -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; +} diff --git a/src/repomd.h b/src/repomd.h index cd4d5ee..7d134cc 100644 --- a/src/repomd.h +++ b/src/repomd.h @@ -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 */ -- 2.7.4