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