From: Panu Matilainen Date: Fri, 23 May 2008 08:49:56 +0000 (+0300) Subject: Add rpmtdGetIndex() + rpmtdSetIndex() methods X-Git-Tag: rpm-4.6.0-rc1~496 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9c209c8a2de5adb741f90c37a59c99d3578f4bdf;p=platform%2Fupstream%2Frpm.git Add rpmtdGetIndex() + rpmtdSetIndex() methods --- diff --git a/lib/rpmtd.c b/lib/rpmtd.c index 9114059..e1d2408 100644 --- a/lib/rpmtd.c +++ b/lib/rpmtd.c @@ -71,6 +71,23 @@ rpmTagType rpmtdType(rpmtd td) return td->type; } +int rpmtdGetIndex(rpmtd td) +{ + assert(td != NULL); + return td->ix; +} + +int rpmtdSetIndex(rpmtd td, int index) +{ + assert(td != NULL); + + if (index < 0 || index >= rpmtdCount(td)) { + return -1; + } + td->ix = index; + return td->ix; +} + int rpmtdInit(rpmtd td) { assert(td != NULL); diff --git a/lib/rpmtd.h b/lib/rpmtd.h index bc368fa..6da2482 100644 --- a/lib/rpmtd.h +++ b/lib/rpmtd.h @@ -73,6 +73,23 @@ rpmTag rpmtdTag(rpmtd td); rpmTagType rpmtdType(rpmtd td); /** \ingroup rpmtd + * Retrieve current iteration index of the container. + * @param td Tag data container + * @return Iteration index (or -1 if not iterating) + */ +int rpmtdGetIndex(rpmtd td); + +/** \ingroup rpmtd + * Set iteration index of the container. + * If new index is out of bounds for the container, -1 is returned and + * iteration index is left untouched. + * @param td Tag data container + * @param index New index + * @return New index, or -1 if index out of bounds + */ +int rpmtdSetIndex(rpmtd td, int index); + +/** \ingroup rpmtd * Initialize tag container for iteration * @param td Tag data container * @return 0 on success