Move hGet*() funcs from rpmts, rename to headerGet*()
authorPanu Matilainen <pmatilai@redhat.com>
Sat, 1 Dec 2007 08:29:44 +0000 (10:29 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Sat, 1 Dec 2007 08:29:44 +0000 (10:29 +0200)
lib/depends.c
lib/package.c
lib/rpmte.c
lib/rpmts.c
lib/rpmts.h
lib/transaction.c
lib/verify.c
rpmdb/hdrNVR.c
rpmdb/header.h

index 2e2067f..bb063f1 100644 (file)
@@ -133,7 +133,7 @@ int rpmtsAddInstallElement(rpmts ts, Header h,
     xx = hge(h, RPMTAG_ARCH, NULL, (void **)&arch, NULL);
     os = NULL;
     xx = hge(h, RPMTAG_OS, NULL, (void **)&os, NULL);
-    hcolor = hGetColor(h);
+    hcolor = headerGetColor(h);
     pkgKey = RPMAL_NOMATCH;
 
     /* Check for supported payload format if it's a package */
@@ -278,7 +278,7 @@ addheader:
     while((oh = rpmdbNextIterator(mi)) != NULL) {
 
        /* Ignore colored packages not in our rainbow. */
-       ohcolor = hGetColor(oh);
+       ohcolor = headerGetColor(oh);
        if (tscolor && hcolor && ohcolor && !(hcolor & ohcolor))
            continue;
 
@@ -323,7 +323,7 @@ addheader:
 
        while((oh = rpmdbNextIterator(mi)) != NULL) {
            /* Ignore colored packages not in our rainbow. */
-           ohcolor = hGetColor(oh);
+           ohcolor = headerGetColor(oh);
            /* XXX provides *are* colored, effectively limiting Obsoletes:
                to matching only colored Provides: based on pkg coloring. */
            if (tscolor && hcolor && ohcolor && !(hcolor & ohcolor))
@@ -335,7 +335,7 @@ addheader:
             */
            if (rpmdsEVR(obsoletes) == NULL
             || rpmdsAnyMatchesDep(oh, obsoletes, _rpmds_nopromote)) {
-               const char * ohNEVRA = hGetNEVRA(oh, NULL);
+               const char * ohNEVRA = headerGetNEVRA(oh, NULL);
 #ifdef DYING   /* XXX see http://bugzilla.redhat.com #134497 */
                if (rpmVersionCompare(h, oh))
 #endif
@@ -660,7 +660,7 @@ static int checkPackageSet(rpmts ts, const char * dep,
        rpmds requires, conflicts;
        int rc;
 
-       pkgNEVRA = hGetNEVRA(h, NULL);
+       pkgNEVRA = headerGetNEVRA(h, NULL);
        requires = rpmdsNew(h, RPMTAG_REQUIRENAME, scareMem);
        (void) rpmdsSetNoPromote(requires, _rpmds_nopromote);
        conflicts = rpmdsNew(h, RPMTAG_CONFLICTNAME, scareMem);
index 7741490..1539dac 100644 (file)
@@ -977,7 +977,7 @@ rpmRC headerCheckPayloadFormat(Header h) {
     if (payloadfmt && strncmp(payloadfmt, "cpio", strlen("cpio")) == 0) {
        rc = RPMRC_OK;
     } else {
-        const char *nevra = hGetNEVRA(h, NULL);
+        const char *nevra = headerGetNEVRA(h, NULL);
         if (payloadfmt && strncmp(payloadfmt, "drpm", strlen("drpm")) == 0) {
             rpmlog(RPMLOG_ERR,
                      _("%s is a Delta RPM and cannot be directly installed\n"),
index 44c852f..4244538 100644 (file)
@@ -84,7 +84,7 @@ static void addTE(rpmts ts, rpmte p, Header h,
     size_t nb;
     int xx;
 
-    p->NEVR = hGetNEVR(h, NULL);
+    p->NEVR = headerGetNEVR(h, NULL);
     p->name = xstrdup(p->NEVR);
     if ((p->release = strrchr(p->name, '-')) != NULL)
        *p->release++ = '\0';
index ae70f7f..19e4df9 100644 (file)
@@ -48,65 +48,6 @@ int _rpmts_debug = 0;
 
 int _rpmts_stats = 0;
 
-char * hGetNEVR(Header h, const char ** np)
-{
-    const char * n, * v, * r;
-    char * NVR, * t;
-
-    (void) headerNVR(h, &n, &v, &r);
-    NVR = t = xcalloc(1, strlen(n) + strlen(v) + strlen(r) + sizeof("--"));
-    t = stpcpy(t, n);
-    t = stpcpy(t, "-");
-    t = stpcpy(t, v);
-    t = stpcpy(t, "-");
-    t = stpcpy(t, r);
-    if (np)
-       *np = n;
-    return NVR;
-}
-
-char * hGetNEVRA(Header h, const char ** np)
-{
-    const char * n, * v, * r, * a;
-    char * NVRA, * t;
-    int xx;
-
-    (void) headerNVR(h, &n, &v, &r);
-    xx = headerGetEntry(h, RPMTAG_ARCH, NULL, (void **) &a, NULL);
-    NVRA = t = xcalloc(1, strlen(n) + strlen(v) + strlen(r) + strlen(a) + sizeof("--."));
-    t = stpcpy(t, n);
-    t = stpcpy(t, "-");
-    t = stpcpy(t, v);
-    t = stpcpy(t, "-");
-    t = stpcpy(t, r);
-    t = stpcpy(t, ".");
-    t = stpcpy(t, a);
-    if (np)
-       *np = n;
-    return NVRA;
-}
-
-uint32_t hGetColor(Header h)
-{
-    HGE_t hge = (HGE_t)headerGetEntryMinMemory;
-    uint32_t hcolor = 0;
-    uint32_t * fcolors;
-    int32_t ncolors;
-    int i;
-
-    fcolors = NULL;
-    ncolors = 0;
-    if (hge(h, RPMTAG_FILECOLORS, NULL, (void **)&fcolors, &ncolors)
-     && fcolors != NULL && ncolors > 0)
-    {
-       for (i = 0; i < ncolors; i++)
-           hcolor |= fcolors[i];
-    }
-    hcolor &= 0x0f;
-
-    return hcolor;
-}
-
 rpmts XrpmtsUnlink(rpmts ts, const char * msg, const char * fn, unsigned ln)
 {
 if (_rpmts_debug)
index 49bd289..1121d44 100644 (file)
@@ -733,29 +733,6 @@ int rpmtsGetKeys(rpmts ts,
                fnpyKey ** ep,
                int * nep);
 
-/**
- * Return (malloc'd) header name-version-release string.
- * @param h            header
- * @retval np          name tag value
- * @return             name-version-release string
- */
-char * hGetNEVR(Header h, const char ** np );
-
-/**
- * Return (malloc'd) header name-version-release.arch string.
- * @param h            header
- * @retval np          name tag value
- * @return             name-version-release string
- */
-char * hGetNEVRA(Header h, const char ** np );
-
-/**
- * Return header color.
- * @param h            header
- * @return             header color
- */
-uint32_t hGetColor(Header h);
-
 #ifdef __cplusplus
 }
 #endif
index 65d5327..d06fbf5 100644 (file)
@@ -99,7 +99,7 @@ static int handleInstInstalledFiles(const rpmts ts,
        mi = rpmtsInitIterator(ts, RPMDBI_PACKAGES,
                        &shared->otherPkg, sizeof(shared->otherPkg));
        while ((h = rpmdbNextIterator(mi)) != NULL) {
-           altNEVR = hGetNEVRA(h, NULL);
+           altNEVR = headerGetNEVRA(h, NULL);
            otherFi = rpmfiNew(ts, h, RPMTAG_BASENAMES, scareMem);
            break;
        }
@@ -628,7 +628,7 @@ static int ensureOlder(rpmts ts,
 
     if (rc == 0) {
        rpmps ps = rpmtsProblems(ts);
-       const char * altNEVR = hGetNEVRA(h, NULL);
+       const char * altNEVR = headerGetNEVRA(h, NULL);
        rpmpsAppend(ps, RPMPROB_OLDPACKAGE,
                rpmteNEVRA(p), rpmteKey(p),
                NULL, NULL,
index 4047463..60af24a 100644 (file)
@@ -366,7 +366,7 @@ static int verifyDependencies(QVA_t qva, rpmts ts,
 
     psi = rpmpsInitIterator(ps);
     if (rpmpsNumProblems(ps) > 0) {
-       char *nevra = hGetNEVRA(h, NULL);
+       char *nevra = headerGetNEVRA(h, NULL);
        rpmlog(RPMLOG_NOTICE, "Unsatisfied dependencies for %s:\n", nevra);
        free(nevra);
        while (rpmpsNextIterator(psi) >= 0) {
index 752cd6e..2e93625 100644 (file)
@@ -44,3 +44,63 @@ int headerNEVRA(Header h, const char **np,
     }
     return 0;
 }
+
+char * headerGetNEVR(Header h, const char ** np)
+{
+    const char * n, * v, * r;
+    char * NVR, * t;
+
+    (void) headerNVR(h, &n, &v, &r);
+    NVR = t = xcalloc(1, strlen(n) + strlen(v) + strlen(r) + sizeof("--"));
+    t = stpcpy(t, n);
+    t = stpcpy(t, "-");
+    t = stpcpy(t, v);
+    t = stpcpy(t, "-");
+    t = stpcpy(t, r);
+    if (np)
+       *np = n;
+    return NVR;
+}
+
+char * headerGetNEVRA(Header h, const char ** np)
+{
+    const char * n, * v, * r, * a;
+    char * NVRA, * t;
+    int xx;
+
+    (void) headerNVR(h, &n, &v, &r);
+    xx = headerGetEntry(h, RPMTAG_ARCH, NULL, (void **) &a, NULL);
+    NVRA = t = xcalloc(1, strlen(n) + strlen(v) + strlen(r) + strlen(a) + sizeof("--."));
+    t = stpcpy(t, n);
+    t = stpcpy(t, "-");
+    t = stpcpy(t, v);
+    t = stpcpy(t, "-");
+    t = stpcpy(t, r);
+    t = stpcpy(t, ".");
+    t = stpcpy(t, a);
+    if (np)
+       *np = n;
+    return NVRA;
+}
+
+uint32_t headerGetColor(Header h)
+{
+    HGE_t hge = (HGE_t)headerGetEntryMinMemory;
+    uint32_t hcolor = 0;
+    uint32_t * fcolors;
+    int32_t ncolors;
+    int i;
+
+    fcolors = NULL;
+    ncolors = 0;
+    if (hge(h, RPMTAG_FILECOLORS, NULL, (void **)&fcolors, &ncolors)
+     && fcolors != NULL && ncolors > 0)
+    {
+       for (i = 0; i < ncolors; i++)
+           hcolor |= fcolors[i];
+    }
+    hcolor &= 0x0f;
+
+    return hcolor;
+}
+
index 1da80e0..f57c48d 100644 (file)
@@ -600,6 +600,29 @@ void * headerFreeData( const void * data, rpmTagType type)
     return NULL;
 }
 
+/** \ingroup header
+ * Return (malloc'd) header name-version-release string.
+ * @param h            header
+ * @retval np          name tag value
+ * @return             name-version-release string
+ */
+char * headerGetNEVR(Header h, const char ** np );
+
+/** \ingroup header
+ * Return (malloc'd) header name-version-release.arch string.
+ * @param h            header
+ * @retval np          name tag value
+ * @return             name-version-release string
+ */
+char * headerGetNEVRA(Header h, const char ** np );
+
+/** \ingroup header
+ * Return header color.
+ * @param h            header
+ * @return             header color
+ */
+uint32_t headerGetColor(Header h);
+
 #ifdef __cplusplus
 }
 #endif