summaryrefslogtreecommitdiffabout
path: root/libical/src/libical/pvl.h
Unidiff
Diffstat (limited to 'libical/src/libical/pvl.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/pvl.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/libical/src/libical/pvl.h b/libical/src/libical/pvl.h
new file mode 100644
index 0000000..14a15a1
--- a/dev/null
+++ b/libical/src/libical/pvl.h
@@ -0,0 +1,94 @@
1/*======================================================================
2 FILE: pvl.h
3 CREATOR: eric November, 1995
4
5
6 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
7======================================================================*/
8
9
10#ifndef __PVL_H__
11#define __PVL_H__
12
13typedef void* pvl_list;
14typedef void* pvl_elem;
15
16/*
17 struct pvl_elem_t
18
19 This type is private. Always use pvl_elem instead. The struct would
20 not even appear in this header except to make code in the USE_MACROS
21 blocks work
22
23 */
24typedef struct pvl_elem_t
25{
26 int MAGIC; /* Magic Identifier */
27 void *d; /* Pointer to data user is storing */
28 struct pvl_elem_t *next;/* Next element */
29 struct pvl_elem_t *prior;/* prior element */
30} pvl_elem_t;
31
32
33
34/* This global is incremented for each call to pvl_new_element(); it gives each
35 * list a unique identifer */
36
37extern int pvl_elem_count;
38extern int pvl_list_count;
39
40/* Create new lists or elements */
41pvl_elem pvl_new_element(void* d, pvl_elem next,pvl_elem prior);
42pvl_list pvl_newlist(void);
43void pvl_free(pvl_list);
44
45/* Add, remove, or get the head of the list */
46void pvl_unshift(pvl_list l,void *d);
47void* pvl_shift(pvl_list l);
48pvl_elem pvl_head(pvl_list);
49
50/* Add, remove or get the tail of the list */
51void pvl_push(pvl_list l,void *d);
52void* pvl_pop(pvl_list l);
53pvl_elem pvl_tail(pvl_list);
54
55/* Insert elements in random places */
56typedef int (*pvl_comparef)(void* a, void* b); /* a, b are of the data type*/
57void pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d);
58void pvl_insert_after(pvl_list l,pvl_elem e,void *d);
59void pvl_insert_before(pvl_list l,pvl_elem e,void *d);
60
61/* Remove an element, or clear the entire list */
62void* pvl_remove(pvl_list,pvl_elem); /* Remove element, return data */
63void pvl_clear(pvl_list); /* Remove all elements, de-allocate all data */
64
65int pvl_count(pvl_list);
66
67/* Navagate the list */
68pvl_elem pvl_next(pvl_elem e);
69pvl_elem pvl_prior(pvl_elem e);
70
71/* get the data in the list */
72#ifndef PVL_USE_MACROS
73void* pvl_data(pvl_elem);
74#else
75#define pvl_data(x) x==0 ? 0 : ((struct pvl_elem_t *)x)->d;
76#endif
77
78
79/* Find an element for which a function returns true */
80typedef int (*pvl_findf)(void* a, void* b); /*a is list elem, b is other data*/
81pvl_elem pvl_find(pvl_list l,pvl_findf f,void* v);
82pvl_elem pvl_find_next(pvl_list l,pvl_findf f,void* v);
83
84/* Pass each element in the list to a function */
85typedef void (*pvl_applyf)(void* a, void* b); /*a is list elem, b is other data*/
86void pvl_apply(pvl_list l,pvl_applyf f, void *v);
87
88
89#endif /* __PVL_H__ */
90
91
92
93
94