return i;
}
+uint16_t * rpmtdGetUint16(rpmtd td)
+{
+ uint16_t *res = NULL;
+
+ assert(td != NULL);
+
+ if (td->type == RPM_INT16_TYPE) {
+ int ix = (td->ix >= 0 ? td->ix : 0);
+ res = (uint16_t *) td->data + ix;
+ }
+ return res;
+}
+
+uint32_t * rpmtdGetUint32(rpmtd td)
+{
+ uint32_t *res = NULL;
+
+ assert(td != NULL);
+
+ if (td->type == RPM_INT32_TYPE) {
+ int ix = (td->ix >= 0 ? td->ix : 0);
+ res = (uint32_t *) td->data + ix;
+ }
+ return res;
+}
const char * rpmtdGetString(rpmtd td)
{
const char *str = NULL;
return str;
}
+char *rpmtdToString(rpmtd td)
+{
+ char *res = NULL;
+
+ switch (td->type) {
+ case RPM_STRING_TYPE:
+ case RPM_STRING_ARRAY_TYPE: {
+ const char *s = rpmtdGetString(td);
+ if (s) {
+ res = xstrdup(s);
+ }
+ break;
+ }
+ case RPM_INT16_TYPE: {
+ uint16_t *num = rpmtdGetUint16(td);
+ if (num) {
+ rasprintf(&res, "%hd", *num);
+ }
+ break;
+ }
+ case RPM_INT32_TYPE: {
+ uint32_t *num = rpmtdGetUint32(td);
+ if (num) {
+ rasprintf(&res, "%d", *num);
+ }
+ break;
+ }
+ case RPM_BIN_TYPE: {
+ /* XXX TODO: convert to hex presentation */
+ }
+ default:
+ break;
+ }
+ return res;
+}
+
int rpmtdFromArgv(rpmtd td, rpmTag tag, ARGV_t argv)
{
int count = argvCount(argv);
int rpmtdNext(rpmtd td);
/** \ingroup rpmtd
+ * Return uint16_t data from tag container.
+ * For scalar return type, just return pointer to the integer. On array
+ * types, return pointer to current iteration index. If the tag container
+ * is not for int16 type, NULL is returned.
+ * @param td Tag data container
+ * @return Pointer to uint16_t, NULL on error
+ */
+uint16_t * rpmtdGetUint16(rpmtd td);
+
+/** \ingroup rpmtd
+ * Return uint32_t data from tag container.
+ * For scalar return type, just return pointer to the integer. On array
+ * types, return pointer to current iteration index. If the tag container
+ * is not for int32 type, NULL is returned.
+ * @param td Tag data container
+ * @return Pointer to uint32_t, NULL on error
+ */
+uint32_t * rpmtdGetUint32(rpmtd td);
+
+/** \ingroup rpmtd
* Return string data from tag container.
* For string types, just return the string. On string array types,
* return the string from current iteration index. If the tag container
const char * rpmtdGetString(rpmtd td);
/** \ingroup rpmtd
+ * Return data from tag container in string presentation.
+ * Return malloced string presentation of current data in container,
+ * converting from integers etc as necessary. On array types, data from
+ * current iteration index is returned.
+ * @param td Tag data container
+ * @return String representation of current data (malloc'ed),
+ * NULL on error
+ */
+char *rpmtdToString(rpmtd td);
+
+/** \ingroup rpmtd
* Construct tag container from ARGV_t array.
* Tag type is checked to be of string array type and array is checked
* to be non-empty.