aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-11-05 08:37:09 +0000
committerMartin Willi <martin@strongswan.org>2008-11-05 08:37:09 +0000
commit2662806b2c6c898717893d5e00958ae89f245c91 (patch)
tree4b1f209734dc06a0cedd51933da30293313259ca /src
parente13389a7f7bab5d2cd14325b7bd77ddddcd8bd91 (diff)
downloadstrongswan-2662806b2c6c898717893d5e00958ae89f245c91.tar.bz2
strongswan-2662806b2c6c898717893d5e00958ae89f245c91.tar.xz
get rid of unused iterator hook functions
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/utils/iterator.h55
-rw-r--r--src/libstrongswan/utils/linked_list.c79
2 files changed, 7 insertions, 127 deletions
diff --git a/src/libstrongswan/utils/iterator.h b/src/libstrongswan/utils/iterator.h
index 4b845d740..aefae925d 100644
--- a/src/libstrongswan/utils/iterator.h
+++ b/src/libstrongswan/utils/iterator.h
@@ -26,43 +26,6 @@
#include <library.h>
-typedef enum hook_result_t hook_result_t;
-
-/**
- * Return value of an iterator hook.
- *
- * Returning HOOK_AGAIN is useful to "inject" additional elements in an
- * iteration, HOOK_NEXT is the normal iterator behavior, and HOOK_SKIP may
- * be used to filter elements out.
- */
-enum hook_result_t {
-
- /**
- * A value was placed in out, hook is called again with the same "in"
- */
- HOOK_AGAIN,
-
- /**
- * A value was placed in out, hook is called again with next "in" (if any)
- */
- HOOK_NEXT,
-
- /**
- * No value in out, call again with next "in" (if any)
- */
- HOOK_SKIP,
-};
-
-/**
- * Iterator hook function prototype.
- *
- * @param param user supplied parameter
- * @param in the value the hook receives from the iterator
- * @param out the value supplied as a result to the iterator
- * @return a hook_result_t
- */
-typedef hook_result_t (iterator_hook_t)(void *param, void *in, void **out);
-
typedef struct iterator_t iterator_t;
@@ -94,24 +57,6 @@ struct iterator_t {
bool (*iterate) (iterator_t *this, void** value);
/**
- * Hook a function into the iterator.
- *
- * Sometimes it is useful to hook in an iterator. The hook function is
- * called before any successful return of iterate(). It takes the
- * iterator value, may manipulate it (or the references object), and returns
- * the value that the iterate() function returns. Depending on the hook
- * return value, the hook is called again, called with next, or skipped.
- * A value of NULL deactivates the iterator hook.
- * If an iterator is hooked, only the iterate() method is valid,
- * all other methods behave undefined.
- *
- * @param hook iterator hook which manipulates the iterated value
- * @param param user supplied parameter to pass back to the hook
- */
- void (*set_iterator_hook) (iterator_t *this, iterator_hook_t *hook,
- void *param);
-
- /**
* Inserts a new item before the given iterator position.
*
* The iterator position is not changed after inserting
diff --git a/src/libstrongswan/utils/linked_list.c b/src/libstrongswan/utils/linked_list.c
index 12dfa235b..585f28403 100644
--- a/src/libstrongswan/utils/linked_list.c
+++ b/src/libstrongswan/utils/linked_list.c
@@ -119,16 +119,6 @@ struct private_iterator_t {
* Direction of iterator.
*/
bool forward;
-
- /**
- * iteration hook
- */
- iterator_hook_t *hook;
-
- /**
- * user parameter for iterator hook
- */
- void *hook_param;
};
typedef struct private_enumerator_t private_enumerator_t;
@@ -203,74 +193,21 @@ static int get_list_count(private_iterator_t *this)
}
/**
- * default iterator hook which does nothing
- */
-static hook_result_t iterator_hook(void *param, void *in, void **out)
-{
- *out = in;
- return HOOK_NEXT;
-}
-
-/**
- * Implementation of iterator_t.set_iterator_hook.
+ * Implementation of iterator_t.iterate.
*/
-static void set_iterator_hook(private_iterator_t *this, iterator_hook_t *hook,
- void* param)
+static bool iterate(private_iterator_t *this, void** value)
{
- if (hook == NULL)
+ if (this->forward)
{
- this->hook = iterator_hook;
- this->hook_param = NULL;
+ this->current = this->current ? this->current->next : this->list->first;
}
else
{
- this->hook = hook;
- this->hook_param = param;
+ this->current = this->current ? this->current->previous : this->list->last;
}
-}
-
-/**
- * Implementation of iterator_t.iterate.
- */
-static bool iterate(private_iterator_t *this, void** value)
-{
- while (TRUE)
+ if (this->current == NULL)
{
- if (this->forward)
- {
- this->current = this->current ? this->current->next : this->list->first;
- }
- else
- {
- this->current = this->current ? this->current->previous : this->list->last;
- }
-
- if (this->current == NULL)
- {
- return FALSE;
- }
-
- switch (this->hook(this->hook_param, this->current->value, value))
- {
- case HOOK_AGAIN:
- /* rewind */
- if (this->forward)
- {
- this->current = this->current->previous;
- }
- else
- {
- this->current = this->current->next;
- }
- break;
- case HOOK_NEXT:
- /* normal iteration */
- break;
- case HOOK_SKIP:
- /* advance */
- continue;
- }
- break;
+ return FALSE;
}
return TRUE;
}
@@ -786,7 +723,6 @@ static iterator_t *create_iterator(private_linked_list_t *linked_list, bool forw
this->public.get_count = (int (*) (iterator_t*)) get_list_count;
this->public.iterate = (bool (*) (iterator_t*, void **value)) iterate;
- this->public.set_iterator_hook = (void(*)(iterator_t*, iterator_hook_t*, void*))set_iterator_hook;
this->public.insert_before = (void (*) (iterator_t*, void *item)) insert_before;
this->public.insert_after = (void (*) (iterator_t*, void *item)) insert_after;
this->public.replace = (status_t (*) (iterator_t*, void **, void *)) replace;
@@ -797,7 +733,6 @@ static iterator_t *create_iterator(private_linked_list_t *linked_list, bool forw
this->forward = forward;
this->current = NULL;
this->list = linked_list;
- this->hook = iterator_hook;
return &this->public;
}