From 77c25969a97cc3fc31e7c8bdbc27a99481ae828a Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 26 May 2008 12:40:43 +0300 Subject: [PATCH] Convert triggertypeTag() to new headerGet() --- lib/tagexts.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/tagexts.c b/lib/tagexts.c index 1e17408..7575ce4 100644 --- a/lib/tagexts.c +++ b/lib/tagexts.c @@ -247,47 +247,47 @@ static int triggercondsTag(Header h, rpmtd td) */ static int triggertypeTag(Header h, rpmtd td) { - HGE_t hge = (HGE_t)headerGetEntryMinMemory; - HFD_t hfd = headerFreeData; - rpmTagType tst; - int32_t * indices; - const char ** conds; - const char ** s; - int xx; - rpm_count_t numScripts, numNames; - rpm_count_t i, j; - rpm_flag_t * flags; - - if (!hge(h, RPMTAG_TRIGGERINDEX, NULL, (rpm_data_t *) &indices, &numNames)) { + int i; + char ** conds; + struct rpmtd_s indices, flags, scripts; + + if (!headerGet(h, RPMTAG_TRIGGERINDEX, &indices, HEADERGET_MINMEM)) { return 1; } - xx = hge(h, RPMTAG_TRIGGERFLAGS, NULL, (rpm_data_t *) &flags, NULL); - xx = hge(h, RPMTAG_TRIGGERSCRIPTS, &tst, (rpm_data_t *) &s, &numScripts); - s = hfd(s, tst); + headerGet(h, RPMTAG_TRIGGERFLAGS, &flags, HEADERGET_MINMEM); + headerGet(h, RPMTAG_TRIGGERSCRIPTS, &scripts, HEADERGET_MINMEM); td->flags = RPMTD_ALLOCED | RPMTD_PTR_ALLOCED; - td->data = conds = xmalloc(sizeof(*conds) * numScripts); - td->count = numScripts; + td->count = rpmtdCount(&scripts); + td->data = conds = xmalloc(sizeof(*conds) * td->count); td->type = RPM_STRING_ARRAY_TYPE; - for (i = 0; i < numScripts; i++) { - for (j = 0; j < numNames; j++) { - if (indices[j] != i) + + while ((i = rpmtdNext(&scripts)) >= 0) { + rpm_flag_t *flag; + rpmtdInit(&indices); rpmtdInit(&flags); + + while (rpmtdNext(&indices) >= 0 && rpmtdNext(&flags) >= 0) { + if (*rpmtdGetUint32(&indices) != i) continue; - if (flags[j] & RPMSENSE_TRIGGERPREIN) + flag = rpmtdGetUint32(&flags); + if (*flag & RPMSENSE_TRIGGERPREIN) conds[i] = xstrdup("prein"); - else if (flags[j] & RPMSENSE_TRIGGERIN) + else if (*flag & RPMSENSE_TRIGGERIN) conds[i] = xstrdup("in"); - else if (flags[j] & RPMSENSE_TRIGGERUN) + else if (*flag & RPMSENSE_TRIGGERUN) conds[i] = xstrdup("un"); - else if (flags[j] & RPMSENSE_TRIGGERPOSTUN) + else if (*flag & RPMSENSE_TRIGGERPOSTUN) conds[i] = xstrdup("postun"); else conds[i] = xstrdup(""); break; } } + rpmtdFreeData(&indices); + rpmtdFreeData(&flags); + rpmtdFreeData(&scripts); return 0; } -- 2.7.4