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