1 // L2TPNS Linked List Stuff
2 // $Id: ll.c,v 1.3 2004-06-23 03:52:24 fred_nerk Exp $
11 #include <arpa/inet.h>
16 linked_list
*ll_init()
18 return (linked_list
*)calloc(sizeof(linked_list
), 1);
21 void ll_done(linked_list
*l
)
35 li
*ll_push(linked_list
*l
, void *data
)
40 if (!(i
= (li
*)calloc(sizeof(li
), 1))) return NULL
;
53 void *ll_pop(linked_list
*l
)
69 void ll_iterate(linked_list
*l
, int(*func
)(void *))
72 if (!l
|| !func
) return;
74 for (i
= l
->head
; i
; i
= i
->next
)
82 void ll_reset(linked_list
*l
)
88 void *ll_next(linked_list
*l
)
94 l
->current
= l
->current
->next
;
97 return l
->current
->data
;
100 void ll_delete(linked_list
*l
, void *data
)
102 li
*i
= l
->head
, *p
= NULL
;
108 if (l
->head
== i
) l
->head
= i
->next
;
109 if (l
->end
== i
) l
->end
= i
->next
;
110 if (p
) p
->next
= i
->next
;
120 int ll_size(linked_list
*l
)
127 for (i
= l
->head
; i
; i
= i
->next
)
128 if (i
->data
) count
++;
133 int ll_contains(linked_list
*l
, void *search
)
136 for (i
= l
->head
; i
; i
= i
->next
)
137 if (i
->data
== search
)