summaryrefslogtreecommitdiff
path: root/lib/header.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-09-01 17:10:18 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-09-02 10:48:54 +0300
commite2239d295e6163d4d067bc3a9391997fa0e27367 (patch)
tree5f1abd7bcdaa98d83e98feb187501a535e631764 /lib/header.c
parent0fd95da2e7105f014475843f25f7e7270f4012d6 (diff)
downloadrpm-e2239d295e6163d4d067bc3a9391997fa0e27367.tar.gz
rpm-e2239d295e6163d4d067bc3a9391997fa0e27367.tar.bz2
rpm-e2239d295e6163d4d067bc3a9391997fa0e27367.zip
Add two new convenience functions for header string data
- headerGetString() for retrieving const strings directly from header memory - headerGetAsString() for converting any non-array tag to string
Diffstat (limited to 'lib/header.c')
-rw-r--r--lib/header.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/header.c b/lib/header.c
index f9d553df3..85cf2fd82 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -1905,3 +1905,28 @@ void headerSetInstance(Header h, unsigned int instance)
{
h->instance = instance;
}
+
+char * headerGetAsString(Header h, rpmTag tag)
+{
+ char *res = NULL;
+ struct rpmtd_s td;
+
+ if (headerGet(h, tag, &td, HEADERGET_EXT) && rpmtdCount(&td) == 1) {
+ res = rpmtdFormat(&td, RPMTD_FORMAT_STRING, NULL);
+ rpmtdFreeData(&td);
+ }
+ return res;
+}
+
+const char * headerGetString(Header h, rpmTag tag)
+{
+ const char *res = NULL;
+ struct rpmtd_s td;
+
+ if (headerGet(h, tag, &td, HEADERGET_MINMEM) && rpmtdCount(&td) == 1) {
+ res = rpmtdGetString(&td);
+ rpmtdFreeData(&td);
+ }
+ return res;
+}
+