From 05db695ee6cec89b98db87e7b00ecbffb65eb634 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 6 Jun 2008 23:47:37 +0300 Subject: [PATCH] Add access methods for 64bit integer types to rpmtd --- lib/rpmtd.c | 24 ++++++++++++++++++++++++ lib/rpmtd.h | 17 +++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/lib/rpmtd.c b/lib/rpmtd.c index e1d2408..2c377a4 100644 --- a/lib/rpmtd.c +++ b/lib/rpmtd.c @@ -123,6 +123,16 @@ uint32_t *rpmtdNextUint32(rpmtd td) return res; } +uint64_t *rpmtdNextUint64(rpmtd td) +{ + assert(td != NULL); + uint64_t *res = NULL; + if (rpmtdNext(td) >= 0) { + res = rpmtdGetUint64(td); + } + return res; +} + const char *rpmtdNextString(rpmtd td) { assert(td != NULL); @@ -170,6 +180,20 @@ uint32_t * rpmtdGetUint32(rpmtd td) } return res; } + +uint64_t * rpmtdGetUint64(rpmtd td) +{ + uint64_t *res = NULL; + + assert(td != NULL); + + if (td->type == RPM_INT64_TYPE) { + int ix = (td->ix >= 0 ? td->ix : 0); + res = (uint64_t *) td->data + ix; + } + return res; +} + const char * rpmtdGetString(rpmtd td) { const char *str = NULL; diff --git a/lib/rpmtd.h b/lib/rpmtd.h index 6da2482..ac72ddd 100644 --- a/lib/rpmtd.h +++ b/lib/rpmtd.h @@ -111,6 +111,13 @@ int rpmtdNext(rpmtd td); uint32_t *rpmtdNextUint32(rpmtd td); /** \ingroup rpmtd + * Iterate over uint64_t type tag data container. + * @param td Tag data container + * @return Pointer to next value, NULL on termination or error + */ +uint64_t *rpmtdNextUint64(rpmtd td); + +/** \ingroup rpmtd * Iterate over string / string array type tag data container. * @param td Tag data container * @return Pointer to next value, NULL on termination or error @@ -148,6 +155,16 @@ uint16_t * rpmtdGetUint16(rpmtd td); uint32_t * rpmtdGetUint32(rpmtd td); /** \ingroup rpmtd + * Return uint64_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 int64 type, NULL is returned. + * @param td Tag data container + * @return Pointer to uint64_t, NULL on error + */ +uint64_t * rpmtdGetUint64(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 -- 2.7.4