WIP: Fix the Proxy-State issue.
[libradsec.git] / list.h
1 /* Copyright (c) 2007,2009, UNINETT AS */
2 /* See LICENSE for licensing information. */
3
4 #ifdef SYS_SOLARIS9
5 #include <sys/inttypes.h>
6 #else
7 #include <stdint.h>
8 #endif
9
10 struct list_node {
11     struct list_node *next;
12     void *data;
13 };
14
15 struct list {
16     struct list_node *first, *last;
17     uint32_t count;
18 };
19
20 /* allocates and initialises list structure; returns NULL if malloc fails */
21 struct list *list_create();
22
23 /* frees all memory associated with the list */
24 void list_destroy(struct list *list);
25
26 /* frees memory allocated for the list itself */
27 void list_free(struct list *list);
28
29 /* appends entry to list; returns 1 if ok, 0 if malloc fails */
30 int list_push(struct list *list, void *data);
31
32 /* removes first entry from list and returns data */
33 void *list_shift(struct list *list);
34
35 /* removes first entry with matching data pointer */
36 void list_removedata(struct list *list, void *data);
37
38 /* returns first node */
39 struct list_node *list_first(struct list *list);
40
41 /* returns the next node after the argument */
42 struct list_node *list_next(struct list_node *node);
43
44 /* returns number of nodes */
45 uint32_t list_count(struct list *list);
46
47 /* Local Variables: */
48 /* c-file-style: "stroustrup" */
49 /* End: */