} else if (headerGet(h, RPMTAG_INSTPREFIXES, &prefixes, flags)) {
/* only return the first prefix of the array */
td->type = RPM_STRING_TYPE;
- td->data = rpmtdToString(&prefixes);
+ td->data = xstrdup(rpmtdGetString(&prefixes));
td->freeData = 1;
rpmtdFreeData(&prefixes);
return 0;
switch (rpmtdType(&td)) {
case RPM_INT32_TYPE: /* fallthrough */
case RPM_STRING_TYPE:
- body = rpmtdToString(&td);
+ body = rpmtdFormat(&td, RPMTD_FORMAT_STRING, NULL);
addMacro(NULL, tagm->macroname, NULL, body, -1);
free(body);
break;
return str;
}
-char *rpmtdToString(rpmtd td)
-{
- char *res = NULL;
-
- switch (td->type) {
- case RPM_STRING_TYPE:
- case RPM_I18NSTRING_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);
char *rpmtdFormat(rpmtd td, rpmtdFormats fmt, const char *errmsg);
/** \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.
p->release = xstrdup(release);
headerGet(h, RPMTAG_EPOCH, &td, HEADERGET_MINMEM);
- p->epoch = rpmtdToString(&td);
+ p->epoch = rpmtdFormat(&td, RPMTD_FORMAT_STRING, NULL);
p->arch = arch ? xstrdup(arch) : NULL;
p->archScore = arch ? rpmMachineScore(RPM_MACHTABLE_INSTARCH, arch) : 0;
headerGet(h, RPMTAG_OS, &td, HEADERGET_MINMEM);
- p->os = rpmtdToString(&td);
+ p->os = xstrdup(rpmtdGetString(&td));
p->osScore = p->os ? rpmMachineScore(RPM_MACHTABLE_INSTOS, p->os) : 0;
p->isSource = headerIsSource(h);