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