Rename COPYING -> LICENSE.
[libradsec.git] / lib / rsp_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 #if defined (__cplusplus)
11 extern "C" {
12 #endif
13
14 struct list_node {
15     struct list_node *next;
16     void *data;
17 };
18
19 struct list {
20     struct list_node *first, *last;
21     uint32_t count;
22 };
23
24 /* allocates and initialises list structure; returns NULL if malloc fails */
25 struct list *list_create();
26
27 /* frees all memory associated with the list */
28 void list_destroy(struct list *list);
29
30 /* appends entry to list; returns 1 if ok, 0 if malloc fails */
31 int list_push(struct list *list, void *data);
32
33 /* removes first entry from list and returns data */
34 void *list_shift(struct list *list);
35
36 /* removes first entry with matching data pointer */
37 void list_removedata(struct list *list, void *data);
38
39 /* returns first node */
40 struct list_node *list_first(struct list *list);
41
42 /* returns the next node after the argument */
43 struct list_node *list_next(struct list_node *node);
44
45 /* returns number of nodes */
46 uint32_t list_count(struct list *list);
47
48 #if defined (__cplusplus)
49 }
50 #endif
51
52 /* Local Variables: */
53 /* c-file-style: "stroustrup" */
54 /* End: */