|
|
@ -48,7 +48,6 @@ f2b_addrlist_append(f2b_ipaddr_t *list, f2b_ipaddr_t *ipaddr) { |
|
|
|
|
|
|
|
|
|
|
|
f2b_ipaddr_t * |
|
|
|
f2b_ipaddr_t * |
|
|
|
f2b_addrlist_lookup(f2b_ipaddr_t *list, const char *addr) { |
|
|
|
f2b_addrlist_lookup(f2b_ipaddr_t *list, const char *addr) { |
|
|
|
|
|
|
|
|
|
|
|
assert(addr != NULL); |
|
|
|
assert(addr != NULL); |
|
|
|
|
|
|
|
|
|
|
|
if (list == NULL) |
|
|
|
if (list == NULL) |
|
|
@ -64,22 +63,36 @@ f2b_addrlist_lookup(f2b_ipaddr_t *list, const char *addr) { |
|
|
|
|
|
|
|
|
|
|
|
f2b_ipaddr_t * |
|
|
|
f2b_ipaddr_t * |
|
|
|
f2b_addrlist_remove(f2b_ipaddr_t *list, const char *addr) { |
|
|
|
f2b_addrlist_remove(f2b_ipaddr_t *list, const char *addr) { |
|
|
|
f2b_ipaddr_t *a = NULL; |
|
|
|
f2b_ipaddr_t *a = NULL, *prev = NULL; |
|
|
|
|
|
|
|
|
|
|
|
assert(addr != NULL); |
|
|
|
assert(addr != NULL); |
|
|
|
|
|
|
|
|
|
|
|
if (list == NULL) |
|
|
|
for (a = list; a != NULL; a = a->next) { |
|
|
|
return NULL; |
|
|
|
if (strncmp(a->text, addr, sizeof(a->text)) == 0) { |
|
|
|
|
|
|
|
if (prev == NULL) { |
|
|
|
|
|
|
|
/* first elem in list */ |
|
|
|
|
|
|
|
list = a->next; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
/* somewhere in list */ |
|
|
|
|
|
|
|
prev->next = a->next; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
f2b_ipaddr_destroy(a); |
|
|
|
|
|
|
|
return list; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
prev = a; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (strncmp(list->text, addr, sizeof(list->text)) == 0) { |
|
|
|
return list; |
|
|
|
a = list->next; |
|
|
|
|
|
|
|
f2b_ipaddr_destroy(list); |
|
|
|
|
|
|
|
return a; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (a = list; a->next != NULL; a = a->next) { |
|
|
|
f2b_ipaddr_t * |
|
|
|
assert(0); /* TODO */ |
|
|
|
f2b_addrlist_destroy(f2b_ipaddr_t *list) { |
|
|
|
|
|
|
|
f2b_ipaddr_t *next = NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (; list != NULL; list = next) { |
|
|
|
|
|
|
|
next = list->next; |
|
|
|
|
|
|
|
f2b_ipaddr_destroy(list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return list; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|