1 // L2TPNS Linked List Stuff
3 char const *cvs_id_ll
= "$Id: ll.c,v 1.5 2004-08-13 00:02:50 fred_nerk Exp $";
12 #include <arpa/inet.h>
17 linked_list
*ll_init()
19 return (linked_list
*)calloc(sizeof(linked_list
), 1);
22 void ll_done(linked_list
*l
)
36 li
*ll_push(linked_list
*l
, void *data
)
41 if (!(i
= (li
*)calloc(sizeof(li
), 1))) return NULL
;
54 void *ll_pop(linked_list
*l
)
70 void ll_iterate(linked_list
*l
, int(*func
)(void *))
73 if (!l
|| !func
) return;
75 for (i
= l
->head
; i
; i
= i
->next
)
83 void ll_reset(linked_list
*l
)
89 void *ll_next(linked_list
*l
)
95 l
->current
= l
->current
->next
;
98 return l
->current
->data
;
101 void ll_delete(linked_list
*l
, void *data
)
103 li
*i
= l
->head
, *p
= NULL
;
109 if (l
->head
== i
) l
->head
= i
->next
;
110 if (l
->end
== i
) l
->end
= i
->next
;
111 if (p
) p
->next
= i
->next
;
121 int ll_size(linked_list
*l
)
128 for (i
= l
->head
; i
; i
= i
->next
)
129 if (i
->data
) count
++;
134 int ll_contains(linked_list
*l
, void *search
)
137 for (i
= l
->head
; i
; i
= i
->next
)
138 if (i
->data
== search
)