83e8cb5c6c4d2d793046812e7bad7c426750a895
[radsecproxy.git] / lib / rsp_list.h
1 /*
2  * Copyright (C) 2006-2009 Stig Venaas <venaas@uninett.no>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  */
8
9 #ifdef SYS_SOLARIS9
10 #include <sys/inttypes.h>
11 #else
12 #include <stdint.h>
13 #endif
14
15 #if defined (__cplusplus)
16 extern "C" {
17 #endif
18
19 struct list_node {
20     struct list_node *next;
21     void *data;
22 };
23
24 struct list {
25     struct list_node *first, *last;
26     uint32_t count;
27 };
28
29 /* allocates and initialises list structure; returns NULL if malloc fails */
30 struct list *list_create();
31
32 /* frees all memory associated with the list */
33 void list_destroy(struct list *list);
34
35 /* appends entry to list; returns 1 if ok, 0 if malloc fails */
36 int list_push(struct list *list, void *data);
37
38 /* removes first entry from list and returns data */
39 void *list_shift(struct list *list);
40
41 /* removes first entry with matching data pointer */
42 void list_removedata(struct list *list, void *data);
43
44 /* returns first node */
45 struct list_node *list_first(struct list *list);
46
47 /* returns the next node after the argument */
48 struct list_node *list_next(struct list_node *node);
49
50 /* returns number of nodes */
51 uint32_t list_count(struct list *list);
52
53 #if defined (__cplusplus)
54 }
55 #endif
56
57 /* Local Variables: */
58 /* c-file-style: "stroustrup" */
59 /* End: */