Libical API Documentation  3.0
pvl.h
1 /*======================================================================
2  FILE: pvl.h
3  CREATOR: eric November, 1995
4 
5  (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
6  http://www.softwarestudio.org
7 
8  This library is free software; you can redistribute it and/or modify
9  it under the terms of either:
10 
11  The LGPL as published by the Free Software Foundation, version
12  2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.html
13 
14  Or:
15 
16  The Mozilla Public License Version 2.0. You may obtain a copy of
17  the License at http://www.mozilla.org/MPL/
18 ======================================================================*/
19 
20 #ifndef ICAL_PVL_H
21 #define ICAL_PVL_H
22 
23 #include "libical_ical_export.h"
24 
25 typedef struct pvl_list_t *pvl_list;
26 typedef struct pvl_elem_t *pvl_elem;
27 
34 typedef struct pvl_elem_t
35 {
36  int MAGIC;
37  void *d;
38  struct pvl_elem_t *next;
39  struct pvl_elem_t *prior;
40 } pvl_elem_t;
41 
42 /* Create new lists or elements */
43 LIBICAL_ICAL_EXPORT pvl_elem pvl_new_element(void *d, pvl_elem next, pvl_elem prior);
44 
45 LIBICAL_ICAL_EXPORT pvl_list pvl_newlist(void);
46 
47 LIBICAL_ICAL_EXPORT void pvl_free(pvl_list);
48 
49 /* Add, remove, or get the head of the list */
50 LIBICAL_ICAL_EXPORT void pvl_unshift(pvl_list l, void *d);
51 
52 LIBICAL_ICAL_EXPORT void *pvl_shift(pvl_list l);
53 
54 LIBICAL_ICAL_EXPORT pvl_elem pvl_head(pvl_list);
55 
56 /* Add, remove or get the tail of the list */
57 LIBICAL_ICAL_EXPORT void pvl_push(pvl_list l, void *d);
58 
59 LIBICAL_ICAL_EXPORT void *pvl_pop(pvl_list l);
60 
61 LIBICAL_ICAL_EXPORT pvl_elem pvl_tail(pvl_list);
62 
63 /* Insert elements in random places */
64 typedef int (*pvl_comparef) (void *a, void *b); /* a, b are of the data type */
65 
66 LIBICAL_ICAL_EXPORT void pvl_insert_ordered(pvl_list l, pvl_comparef f, void *d);
67 
68 LIBICAL_ICAL_EXPORT void pvl_insert_after(pvl_list l, pvl_elem e, void *d);
69 
70 LIBICAL_ICAL_EXPORT void pvl_insert_before(pvl_list l, pvl_elem e, void *d);
71 
72 /* Remove an element, or clear the entire list */
73 LIBICAL_ICAL_EXPORT void *pvl_remove(pvl_list, pvl_elem); /* Remove element, return data */
74 
75 LIBICAL_ICAL_EXPORT void pvl_clear(pvl_list); /* Remove all elements, de-allocate all data */
76 
77 LIBICAL_ICAL_EXPORT int pvl_count(pvl_list);
78 
79 /* Navagate the list */
80 LIBICAL_ICAL_EXPORT pvl_elem pvl_next(pvl_elem e);
81 
82 LIBICAL_ICAL_EXPORT pvl_elem pvl_prior(pvl_elem e);
83 
84 /* get the data in the list */
85 #if !defined(PVL_USE_MACROS)
86 LIBICAL_ICAL_EXPORT void *pvl_data(pvl_elem);
87 #else
88 #define pvl_data(x) x==0 ? 0 : ((struct pvl_elem_t *)x)->d;
89 #endif
90 
91 /* Find an element for which a function returns true */
92 typedef int (*pvl_findf) (void *a, void *b); /*a is list elem, b is other data */
93 
94 LIBICAL_ICAL_EXPORT pvl_elem pvl_find(pvl_list l, pvl_findf f, void *v);
95 
96 LIBICAL_ICAL_EXPORT pvl_elem pvl_find_next(pvl_list l, pvl_findf f, void *v);
97 
102 typedef void (*pvl_applyf) (void *a, void *b);
103 
104 LIBICAL_ICAL_EXPORT void pvl_apply(pvl_list l, pvl_applyf f, void *v);
105 
106 #endif /* ICAL_PVL_H */
struct pvl_elem_t * next
Definition: pvl.h:38
struct pvl_elem_t * prior
Definition: pvl.h:39
void * d
Definition: pvl.h:37
int MAGIC
Definition: pvl.h:36
Definition: pvl.h:34
Definition: pvl.c:46