summaryrefslogtreecommitdiff
path: root/lib/rpmtd.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-05-13 16:11:28 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-05-13 16:11:28 +0300
commit11980a42f28feddf33c0b2c74b6424b217404263 (patch)
tree8a4da9dabea0bff4993f98937da46cb3a95e8c9d /lib/rpmtd.c
parentae218d25aee90d967b3b928b332cb759f27cc22e (diff)
downloadlibrpm-tizen-11980a42f28feddf33c0b2c74b6424b217404263.tar.gz
librpm-tizen-11980a42f28feddf33c0b2c74b6424b217404263.tar.bz2
librpm-tizen-11980a42f28feddf33c0b2c74b6424b217404263.zip
Add methods to construct tag containers from argv and argi arrays
- basic type checking done based on tag (return) type
Diffstat (limited to 'lib/rpmtd.c')
-rw-r--r--lib/rpmtd.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/rpmtd.c b/lib/rpmtd.c
index 5d46bf916..dfb86285a 100644
--- a/lib/rpmtd.c
+++ b/lib/rpmtd.c
@@ -52,6 +52,12 @@ rpmTag rpmtdTag(rpmtd td)
return td->tag;
}
+rpmTagType rpmtdType(rpmtd td)
+{
+ assert(td != NULL);
+ return td->type;
+}
+
int rpmtdInit(rpmtd td)
{
assert(td != NULL);
@@ -91,3 +97,38 @@ const char * rpmtdGetString(rpmtd td)
}
return str;
}
+
+int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv)
+{
+ int count = argvCount(argv);
+ rpmTagType type = rpmTagGetType(tag) & RPM_MASK_TYPE;
+
+ if (type != RPM_STRING_ARRAY_TYPE || count < 1)
+ return 0;
+
+ assert(td != NULL);
+ rpmtdReset(td);
+ td->type = type;
+ td->tag = tag;
+ td->count = count;
+ td->data = argv;
+ return 1;
+}
+
+int rpmtdFromArgi(rpmtd td, rpmTag tag, ARGI_t argi)
+{
+ int count = argiCount(argi);
+ rpmTagType type = rpmTagGetType(tag) & RPM_MASK_TYPE;
+ rpmTagReturnType retype = rpmTagGetType(tag) & RPM_MASK_RETURN_TYPE;
+
+ if (type != RPM_INT32_TYPE || retype != RPM_ARRAY_RETURN_TYPE || count < 1)
+ return 0;
+
+ assert(td != NULL);
+ rpmtdReset(td);
+ td->type = type;
+ td->tag = tag;
+ td->count = count;
+ td->data = argiData(argi);
+ return 1;
+}