summaryrefslogtreecommitdiff
path: root/lib/rpmtd.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-06-18 12:36:20 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-06-18 12:36:20 +0300
commit9b162540e17fbe09f8de7d9bed09295e8c2219e6 (patch)
tree9b0bfe6aeb3cebc56c76a752a023959cd9d8aa20 /lib/rpmtd.c
parent7e8142f3cf7b3818b2d9a3a86ae0cd62eb25f772 (diff)
downloadlibrpm-tizen-9b162540e17fbe09f8de7d9bed09295e8c2219e6.tar.gz
librpm-tizen-9b162540e17fbe09f8de7d9bed09295e8c2219e6.tar.bz2
librpm-tizen-9b162540e17fbe09f8de7d9bed09295e8c2219e6.zip
Add rpmtdFromUint8()
- handles CHAR, INT8 and BIN types
Diffstat (limited to 'lib/rpmtd.c')
-rw-r--r--lib/rpmtd.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/rpmtd.c b/lib/rpmtd.c
index 761f03b26..a3fb0a09d 100644
--- a/lib/rpmtd.c
+++ b/lib/rpmtd.c
@@ -276,6 +276,33 @@ static inline int rpmtdSet(rpmtd td, rpmTag tag, rpmTagType type,
return 1;
}
+int rpmtdFromUint8(rpmtd td, rpmTag tag, uint8_t *data, rpm_count_t count)
+{
+ rpmTagType type = rpmTagGetType(tag) & RPM_MASK_TYPE;
+ rpmTagReturnType retype = rpmTagGetType(tag) & RPM_MASK_RETURN_TYPE;
+
+ if (count < 1)
+ return 0;
+
+ /*
+ * BIN type is really just an uint8_t array internally, it's just
+ * treated specially otherwise.
+ */
+ switch (type) {
+ case RPM_CHAR_TYPE:
+ case RPM_INT8_TYPE:
+ if (retype != RPM_ARRAY_RETURN_TYPE && count > 1)
+ return 0;
+ /* fallthrough */
+ case RPM_BIN_TYPE:
+ break;
+ default:
+ return 0;
+ }
+
+ return rpmtdSet(td, tag, type, data, count);
+}
+
int rpmtdFromUint16(rpmtd td, rpmTag tag, uint16_t *data, rpm_count_t count)
{
rpmTagType type = rpmTagGetType(tag) & RPM_MASK_TYPE;