diff options
author | Tobias Brunner <tobias@strongswan.org> | 2011-06-09 09:53:12 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2011-07-06 09:43:46 +0200 |
commit | 1142726ba0b6ac0b952d245fb91c9a9162dff595 (patch) | |
tree | cf9401893503da0d23ed05e31aa727ae6626bf22 /src | |
parent | 2bf9d39da64382e143b7201ec12888e42279da93 (diff) | |
download | strongswan-1142726ba0b6ac0b952d245fb91c9a9162dff595.tar.bz2 strongswan-1142726ba0b6ac0b952d245fb91c9a9162dff595.tar.xz |
Added linked_list_t.has_more which checks if any elements follow an enumerator's current position.
Diffstat (limited to 'src')
-rw-r--r-- | src/libstrongswan/utils/linked_list.c | 11 | ||||
-rw-r--r-- | src/libstrongswan/utils/linked_list.h | 8 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/libstrongswan/utils/linked_list.c b/src/libstrongswan/utils/linked_list.c index e4c1a3308..59d416f2f 100644 --- a/src/libstrongswan/utils/linked_list.c +++ b/src/libstrongswan/utils/linked_list.c @@ -164,6 +164,16 @@ METHOD(linked_list_t, reset_enumerator, void, enumerator->finished = FALSE; } +METHOD(linked_list_t, has_more, bool, + private_linked_list_t *this, private_enumerator_t *enumerator) +{ + if (enumerator->current) + { + return enumerator->current->next != NULL; + } + return !enumerator->finished && this->first != NULL; +} + METHOD(linked_list_t, get_count, int, private_linked_list_t *this) { @@ -537,6 +547,7 @@ linked_list_t *linked_list_create() .get_count = _get_count, .create_enumerator = _create_enumerator, .reset_enumerator = (void*)_reset_enumerator, + .has_more = (void*)_has_more, .get_first = _get_first, .get_last = _get_last, .find_first = (void*)_find_first, diff --git a/src/libstrongswan/utils/linked_list.h b/src/libstrongswan/utils/linked_list.h index cb3d53e58..293ca8661 100644 --- a/src/libstrongswan/utils/linked_list.h +++ b/src/libstrongswan/utils/linked_list.h @@ -78,6 +78,14 @@ struct linked_list_t { void (*reset_enumerator)(linked_list_t *this, enumerator_t *enumerator); /** + * Checks if there are more elements following after the enumerator's + * current position. + * + * @param enumerator enumerator to check + */ + bool (*has_more)(linked_list_t *this, enumerator_t *enumerator); + + /** * Inserts a new item at the beginning of the list. * * @param item item value to insert in list |