Add headerGetEVR() convenience function
authorPanu Matilainen <pmatilai@redhat.com>
Wed, 9 Apr 2008 07:36:29 +0000 (10:36 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 9 Apr 2008 07:36:29 +0000 (10:36 +0300)
- return formatted evr string + optionally pointer to name

rpmdb/hdrNVR.c
rpmdb/header.h

index a7e7521..b329de1 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <rpm/rpmtypes.h>
 #include <rpm/header.h>
+#include <rpm/rpmstring.h>
 
 #include "debug.h"
 
@@ -91,6 +92,23 @@ char * headerGetNEVRA(Header h, const char ** np)
     return NVRA;
 }
 
+char * headerGetEVR(Header h, const char ** np)
+{
+    const char *n, *v, *r;
+    char *EVR;
+    int32_t *e;
+
+    (void) headerNEVRA(h, &n, &e, &v, &r, NULL);
+    if (e) {
+       rasprintf(&EVR, "%d:%s-%s", *e, v, r);
+    } else {
+       rasprintf(&EVR, "%s-%s", v, r);
+    }
+    if (np) 
+       *np = n;
+    return EVR;
+}
+
 rpm_color_t headerGetColor(Header h)
 {
     HGE_t hge = (HGE_t)headerGetEntryMinMemory;
index ab6f165..19dd0a5 100644 (file)
@@ -511,6 +511,14 @@ char * headerGetNEVR(Header h, const char ** np );
  */
 char * headerGetNEVRA(Header h, const char ** np );
 
+/* \ingroup header
+ * Return (malloc'd) header (epoch:)version-release string.
+ * @param h            header
+ * @retval np          name tag value (or NULL)
+ * @return             (epoch:)version-release string
+ */
+char * headerGetEVR(Header h, const char **np);
+
 /** \ingroup header
  * Return header color.
  * @param h            header