From: Panu Matilainen Date: Tue, 20 May 2008 05:53:05 +0000 (+0300) Subject: Handle RPM_CHAR_TYPE too in stringFormat() X-Git-Tag: tznext/4.11.0.1.tizen20130304~4081 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d5381c16a794e03c0e4f202daa3c882dc1876f41;p=tools%2Flibrpm-tizen.git Handle RPM_CHAR_TYPE too in stringFormat() - used by filestates and nothing else apparently, duh.. --- diff --git a/lib/formats.c b/lib/formats.c index f841a10..0f44688 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -51,11 +51,18 @@ static char * stringFormat(rpmtd td, char *formatPrefix, size_t padding) size_t need; switch (rpmtdType(td)) { + case RPM_INT8_TYPE: + case RPM_CHAR_TYPE: + need = 10 + padding + 20; /* we can do better, just for now ... */ + val = xmalloc(need); + strcat(formatPrefix, "hhd"); + sprintf(val, formatPrefix, *rpmtdGetChar(td)); + break; case RPM_INT16_TYPE: need = 10 + padding + 20; /* we can do better, just for now ... */ val = xmalloc(need); - strcat(formatPrefix, "d"); - sprintf(val, formatPrefix, *rpmtdGetUint32(td)); + strcat(formatPrefix, "hd"); + sprintf(val, formatPrefix, *rpmtdGetUint16(td)); break; case RPM_INT32_TYPE: need = 10 + padding + 20; /* we can do better, just for now ... */ diff --git a/lib/rpmtd.c b/lib/rpmtd.c index e0a29de..ee55435 100644 --- a/lib/rpmtd.c +++ b/lib/rpmtd.c @@ -82,6 +82,18 @@ int rpmtdNext(rpmtd td) return i; } +char * rpmtdGetChar(rpmtd td) +{ + char *res = NULL; + + assert(td != NULL); + + if (td->type == RPM_CHAR_TYPE) { + int ix = (td->ix >= 0 ? td->ix : 0); + res = (char *) td->data + ix; + } + return res; +} uint16_t * rpmtdGetUint16(rpmtd td) { uint16_t *res = NULL; diff --git a/lib/rpmtd.h b/lib/rpmtd.h index b7f1a20..c058f5b 100644 --- a/lib/rpmtd.h +++ b/lib/rpmtd.h @@ -80,6 +80,16 @@ int rpmtdInit(rpmtd td); int rpmtdNext(rpmtd td); /** \ingroup rpmtd + * Return char 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 char type, NULL is returned. + * @param td Tag data container + * @return Pointer to uint16_t, NULL on error + */ +char *rpmtdGetChar(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