X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=lib%2Frbl.c;h=226e938b02f393aebf9fdda7444f0181c31fee01;hp=1a40535051a5b3704ff9fe0d5882cf3272555c00;hb=cf49b2c0647554613874cce495e4a7937a9f7863;hpb=97c54ffb35312caf38034952b9ed2733f7e374f9 diff --git a/lib/rbl.c b/lib/rbl.c index 1a405350..226e938b 100644 --- a/lib/rbl.c +++ b/lib/rbl.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: rbl.c,v 1.1.2.11 2000/11/22 19:14:08 guus Exp $ + $Id: rbl.c,v 1.1.2.12 2000/11/24 23:12:59 guus Exp $ */ #include "config.h" @@ -88,6 +88,38 @@ rbl_t *rbl_search_closest_rbl(rbltree_t *tree, void *data) return rbl; } +/* Search closest match in the tree */ +rbl_t *rbl_search_closest_greater_rbl(rbltree_t *tree, void *data) +{ + rbl_t *rbl; + + rbl = rbl_search_closest_rbl(tree, data); + + if(rbl) + { + if(tree->compare(data, rbl->data) > 0) + rbl = rbl->next; + } + + return rbl; +} + +/* Search closest match in the tree */ +rbl_t *rbl_search_closest_smaller_rbl(rbltree_t *tree, void *data) +{ + rbl_t *rbl; + + rbl = rbl_search_closest_rbl(tree, data); + + if(rbl) + { + if(tree->compare(data, rbl->data) < 0) + rbl = rbl->next; + } + + return rbl; +} + void *rbl_search_closest(rbltree_t *tree, void *data) { rbl_t *rbl; @@ -100,6 +132,30 @@ void *rbl_search_closest(rbltree_t *tree, void *data) return NULL; } +void *rbl_search_closest_greater(rbltree_t *tree, void *data) +{ + rbl_t *rbl; + + rbl = rbl_search_closest_greater_rbl(tree, data); + + if(rbl) + return rbl->data; + else + return NULL; +} + +void *rbl_search_closest_smaller(rbltree_t *tree, void *data) +{ + rbl_t *rbl; + + rbl = rbl_search_closest_smaller_rbl(tree, data); + + if(rbl) + return rbl->data; + else + return NULL; +} + /* Search exact match or return NULL pointer */ rbl_t *rbl_search_rbl(rbltree_t *tree, void *data) {