summaryrefslogtreecommitdiff
path: root/lib/rpmtd.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-05-23 10:31:45 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-05-23 17:07:34 +0300
commit9979407567cb42df9873f83a4dca779073759296 (patch)
tree6e3ea3432340eb5035188aa5d1b8f6b09fa239a6 /lib/rpmtd.c
parent3249b289e8d9f6bcebf38e451e25b4540da3c63e (diff)
downloadlibrpm-tizen-9979407567cb42df9873f83a4dca779073759296.tar.gz
librpm-tizen-9979407567cb42df9873f83a4dca779073759296.tar.bz2
librpm-tizen-9979407567cb42df9873f83a4dca779073759296.zip
Add rpmtdSetTag() method for setting (or changing) container tag + type
- permit change on non-empty container to compatible type to allow things like headerGet(h, RPMTAG_FILENAMES, td, HEADERGET_EXT); rpmtdSetTag(td, RPMTAG_OLDFILENAMES); headerPut(h, td, HEADERPUT_DEFAULT); - empty container can be set to any valid type
Diffstat (limited to 'lib/rpmtd.c')
-rw-r--r--lib/rpmtd.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/rpmtd.c b/lib/rpmtd.c
index daac14542..911405944 100644
--- a/lib/rpmtd.c
+++ b/lib/rpmtd.c
@@ -191,6 +191,34 @@ char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg)
return str;
}
+int rpmtdSetTag(rpmtd td, rpmTag tag)
+{
+ assert(td != NULL);
+ rpmTagType newtype = rpmTagGetType(tag);
+ int rc = 0;
+
+ /*
+ * Sanity checks:
+ * - is the new tag valid at all
+ * - if changing tag of non-empty container, require matching type
+ */
+ if (newtype == RPM_NULL_TYPE)
+ goto exit;
+
+ if (td->data || td->count > 0) {
+ if (rpmTagGetType(td->tag) != rpmTagGetType(tag)) {
+ goto exit;
+ }
+ }
+
+ td->tag = tag;
+ td->type = newtype & RPM_MASK_TYPE;
+ rc = 1;
+
+exit:
+ return rc;
+}
+
int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv)
{
int count = argvCount(argv);