Changeset 4577

Show
Ignore:
Timestamp:
11/05/08 09:37:09 (2 months ago)
Author:
martin
Message:

get rid of unused iterator hook functions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/libstrongswan/utils/iterator.h

    r3589 r4577  
    2626 
    2727#include <library.h> 
    28  
    29 typedef enum hook_result_t hook_result_t; 
    30  
    31 /** 
    32  * Return value of an iterator hook. 
    33  * 
    34  * Returning HOOK_AGAIN is useful to "inject" additional elements in an 
    35  * iteration, HOOK_NEXT is the normal iterator behavior, and HOOK_SKIP may 
    36  * be used to filter elements out. 
    37  */ 
    38 enum hook_result_t { 
    39  
    40     /** 
    41      * A value was placed in out, hook is called again with the same "in" 
    42      */ 
    43     HOOK_AGAIN, 
    44      
    45     /** 
    46      * A value was placed in out, hook is called again with next "in" (if any) 
    47      */ 
    48     HOOK_NEXT, 
    49      
    50     /** 
    51      * No value in out, call again with next "in" (if any) 
    52      */ 
    53     HOOK_SKIP, 
    54 }; 
    55  
    56 /** 
    57  * Iterator hook function prototype. 
    58  * 
    59  * @param param     user supplied parameter 
    60  * @param in        the value the hook receives from the iterator 
    61  * @param out       the value supplied as a result to the iterator 
    62  * @return          a hook_result_t 
    63  */ 
    64 typedef hook_result_t (iterator_hook_t)(void *param, void *in, void **out); 
    6528 
    6629 
     
    9356     */ 
    9457    bool (*iterate) (iterator_t *this, void** value); 
    95      
    96     /** 
    97      * Hook a function into the iterator. 
    98      * 
    99      * Sometimes it is useful to hook in an iterator. The hook function is 
    100      * called before any successful return of iterate(). It takes the 
    101      * iterator value, may manipulate it (or the references object), and returns 
    102      * the value that the iterate() function returns. Depending on the hook 
    103      * return value, the hook is called again, called with next, or skipped. 
    104      * A value of NULL deactivates the iterator hook. 
    105      * If an iterator is hooked, only the iterate() method is valid, 
    106      * all other methods behave undefined. 
    107      *  
    108      * @param hook      iterator hook which manipulates the iterated value 
    109      * @param param     user supplied parameter to pass back to the hook 
    110      */ 
    111     void (*set_iterator_hook) (iterator_t *this, iterator_hook_t *hook, 
    112                                void *param); 
    11358     
    11459    /** 
  • trunk/src/libstrongswan/utils/linked_list.c

    r4576 r4577  
    120120     */ 
    121121    bool forward; 
    122      
    123     /** 
    124      * iteration hook 
    125      */ 
    126     iterator_hook_t *hook; 
    127      
    128     /** 
    129      * user parameter for iterator hook 
    130      */ 
    131     void *hook_param; 
    132122}; 
    133123 
     
    204194 
    205195/** 
    206  * default iterator hook which does nothing 
    207  */ 
    208 static hook_result_t iterator_hook(void *param, void *in, void **out) 
    209 { 
    210     *out = in; 
    211     return HOOK_NEXT; 
    212 } 
    213  
    214 /** 
    215  * Implementation of iterator_t.set_iterator_hook. 
    216  */ 
    217 static void set_iterator_hook(private_iterator_t *this, iterator_hook_t *hook, 
    218                               void* param) 
    219 { 
    220     if (hook == NULL) 
    221     { 
    222         this->hook = iterator_hook; 
    223         this->hook_param = NULL; 
    224     } 
    225     else 
    226     { 
    227         this->hook = hook; 
    228         this->hook_param = param; 
    229     } 
    230 } 
    231  
    232 /** 
    233196 * Implementation of iterator_t.iterate. 
    234197 */ 
    235198static bool iterate(private_iterator_t *this, void** value) 
    236199{ 
    237     while (TRUE) 
    238     { 
    239         if (this->forward) 
    240         { 
    241             this->current = this->current ? this->current->next : this->list->first; 
    242         } 
    243         else 
    244         { 
    245             this->current = this->current ? this->current->previous : this->list->last; 
    246         } 
    247  
    248         if (this->current == NULL) 
    249         { 
    250             return FALSE; 
    251         } 
    252      
    253         switch (this->hook(this->hook_param, this->current->value, value)) 
    254         { 
    255             case HOOK_AGAIN: 
    256                 /* rewind */ 
    257                 if (this->forward) 
    258                 { 
    259                     this->current = this->current->previous; 
    260                 } 
    261                 else 
    262                 { 
    263                     this->current = this->current->next; 
    264                 } 
    265                 break; 
    266             case HOOK_NEXT: 
    267                 /* normal iteration */ 
    268                 break; 
    269             case HOOK_SKIP: 
    270                 /* advance */ 
    271                 continue; 
    272         } 
    273         break; 
     200    if (this->forward) 
     201    { 
     202        this->current = this->current ? this->current->next : this->list->first; 
     203    } 
     204    else 
     205    { 
     206        this->current = this->current ? this->current->previous : this->list->last; 
     207    } 
     208    if (this->current == NULL) 
     209    { 
     210        return FALSE; 
    274211    } 
    275212    return TRUE; 
     
    787724    this->public.get_count = (int (*) (iterator_t*)) get_list_count; 
    788725    this->public.iterate = (bool (*) (iterator_t*, void **value)) iterate; 
    789     this->public.set_iterator_hook = (void(*)(iterator_t*, iterator_hook_t*, void*))set_iterator_hook; 
    790726    this->public.insert_before = (void (*) (iterator_t*, void *item)) insert_before; 
    791727    this->public.insert_after = (void (*) (iterator_t*, void *item)) insert_after; 
     
    798734    this->current = NULL; 
    799735    this->list = linked_list; 
    800     this->hook = iterator_hook; 
    801736     
    802737    return &this->public;