1 // L2TPNS Linked List Stuff
10 #include <arpa/inet.h>
15 linked_list
*ll_init()
17 return (linked_list
*)calloc(sizeof(linked_list
), 1);
20 void ll_done(linked_list
*l
)
34 li
*ll_push(linked_list
*l
, void *data
)
39 if (!(i
= (li
*)calloc(sizeof(li
), 1))) return NULL
;
52 void *ll_pop(linked_list
*l
)
68 void ll_iterate(linked_list
*l
, int(*func
)(void *))
71 if (!l
|| !func
) return;
73 for (i
= l
->head
; i
; i
= i
->next
)
75 if (i
->data
&& !func(i
->data
))
80 void ll_reset(linked_list
*l
)
86 void *ll_next(linked_list
*l
)
92 l
->current
= l
->current
->next
;
95 return l
->current
->data
;
98 void ll_delete(linked_list
*l
, void *data
)
100 li
*i
= l
->head
, *p
= NULL
;
106 if (l
->head
== i
) l
->head
= i
->next
;
107 if (l
->end
== i
) l
->end
= p
;
108 if (p
) p
->next
= i
->next
;
118 int ll_size(linked_list
*l
)
125 for (i
= l
->head
; i
; i
= i
->next
)
126 if (i
->data
) count
++;
131 int ll_contains(linked_list
*l
, void *search
)
134 for (i
= l
->head
; i
; i
= i
->next
)
135 if (i
->data
== search
)