Handle RPM_CHAR_TYPE too in stringFormat()

- used by filestates and nothing else apparently, duh..
This commit is contained in:
Panu Matilainen 2008-05-20 08:53:05 +03:00
parent 2bfc0fad38
commit d5381c16a7
3 changed files with 31 additions and 2 deletions

View File

@ -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 ... */

View File

@ -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;

View File

@ -79,6 +79,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