1152
|
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2 #ifndef _LIST_H
|
|
3 #define _LIST_H
|
|
4
|
|
5 #ifdef HAVE_CONFIG_H
|
|
6 #include <config.h>
|
|
7 #endif
|
|
8
|
|
9 #include <stdarg.h>
|
|
10
|
|
11 #define list_enqueue(plist, p) \
|
|
12 list_insert(plist, 0, p)
|
|
13
|
|
14 #define list_dequeue(plist) \
|
|
15 list_remove_node(plist, plist->head)
|
|
16
|
|
17 typedef struct list_node_s
|
|
18 {
|
|
19 struct list_node_s *next;
|
|
20 struct list_node_s *previous;
|
|
21 void *item;
|
|
22 } list_node;
|
|
23
|
|
24 typedef struct list_s
|
|
25 {
|
|
26 list_node *head;
|
|
27 list_node *tail;
|
|
28 int count;
|
|
29 } list;
|
|
30
|
|
31 list *list_new(void);
|
|
32 void list_delete(list *plist, void (*item_free_f)(void *));
|
|
33 void list_free(list *plist, void (*item_free_f)(void *));
|
|
34 void list_insert(list *plist, list_node *pnode, void *pitem);
|
|
35 void *list_remove(list *plist, void *pitem);
|
|
36 void *list_traverse(list *plist, int (*item_f)(void *, va_list), ...);
|
|
37 int list_dump(list *plist);
|
|
38 void *list_first(list *plist);
|
|
39 void *list_last(list *plist);
|
|
40 void *list_at(list *plist, int num);
|
|
41 list_node *list_find(list *plist, void *pitem);
|
|
42 void *list_remove_node(list *plist, list_node *p);
|
|
43
|
|
44 #endif /* _LIST_H */
|