}
/**
+ * Return tag container array size.
+ * @param td tag data container
+ * @param formatPrefix sprintf format string
+ * @return formatted string
+ */
+static char * arraysizeFormat(rpmtd td, char * formatPrefix)
+{
+ char *val = NULL;
+ strcat(formatPrefix, "u");
+ rasprintf(&val, formatPrefix, rpmtdCount(td));
+ return val;
+}
+
+/**
* Retrieve mounted file system paths.
* @param h header
* @retval td tag data container
{ RPMTD_FORMAT_DATE, "date", dateFormat },
{ RPMTD_FORMAT_DAY, "day", dayFormat },
{ RPMTD_FORMAT_SHESCAPE, "shescape", shescapeFormat },
+ { RPMTD_FORMAT_ARRAYSIZE, "arraysize", arraysizeFormat },
{ -1, NULL, NULL }
};
headerTagFormatFunction fmt;
rpmTag tag;
int justOne;
- int arrayCount;
char * format;
char * type;
};
token->u.tag.format = start;
token->u.tag.justOne = 0;
- token->u.tag.arrayCount = 0;
chptr = start;
while (*chptr && *chptr != '{' && *chptr != '%') chptr++;
start++;
} else if (*start == '#') {
token->u.tag.justOne = 1;
- token->u.tag.arrayCount = 1;
+ token->u.tag.type = "arraysize";
start++;
}
return 1;
}
token->u.tag.type = chptr;
- } else {
+ }
+ /* default to string conversion if no formats found by now */
+ if (!token->u.tag.type) {
token->u.tag.type = "string";
}
size_t need = 0;
char * t, * te;
char buf[20];
- int countBuf;
struct rpmtd_s tmp;
rpmtd td;
td = &tmp;
}
- if (tag->arrayCount) {
- countBuf = td->count;
- tmp.data = &countBuf;
- tmp.count = 1;
- tmp.type = RPM_INT32_TYPE;
- element = 0;
- td = &tmp;
- }
td->ix = element; /* Ick, use iterators instead */
(void) stpcpy( stpcpy(buf, "%"), tag->format);
{
rpmtd td = NULL;
if (spft->type != PTOK_TAG ||
- spft->u.tag.arrayCount ||
spft->u.tag.justOne) continue;
if (!(td = getData(hsa, spft->u.tag.tag))) {
RPMTD_FORMAT_DATE = 11, /* date format (int32 types) */
RPMTD_FORMAT_DAY = 12, /* day format (int32 types) */
RPMTD_FORMAT_SHESCAPE = 13, /* shell escaped (any type) */
+ RPMTD_FORMAT_ARRAYSIZE = 14, /* size of contained array (any type) */
} rpmtdFormats;
/** \ingroup rpmtd