Libical API Documentation 4.0
Loading...
Searching...
No Matches
pvl.h
1/*======================================================================
2 FILE: pvl.h
3 CREATOR: eric November, 1995
4
5 SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
8
9======================================================================*/
10
11#ifndef ICAL_PVL_H
12#define ICAL_PVL_H
13
14#include "libical_ical_export.h"
15
16typedef struct pvl_list_t *pvl_list;
17typedef struct pvl_elem_t *pvl_elem;
18
24
25typedef struct pvl_elem_t {
26 int MAGIC;
27 void *d;
28 struct pvl_elem_t *next;
29 struct pvl_elem_t *prior;
31
32/* Create new lists or elements */
33LIBICAL_ICAL_EXPORT pvl_elem pvl_new_element(void *d, pvl_elem next, pvl_elem prior);
34
35LIBICAL_ICAL_EXPORT pvl_list pvl_newlist(void);
36
37LIBICAL_ICAL_EXPORT void pvl_free(pvl_list);
38
39/* Add, remove, or get the head of the list */
40LIBICAL_ICAL_EXPORT void pvl_unshift(pvl_list l, void *d);
41
42LIBICAL_ICAL_EXPORT void *pvl_shift(pvl_list l);
43
44LIBICAL_ICAL_EXPORT pvl_elem pvl_head(pvl_list);
45
46/* Add, remove or get the tail of the list */
47LIBICAL_ICAL_EXPORT void pvl_push(pvl_list l, void *d);
48
49LIBICAL_ICAL_EXPORT void *pvl_pop(pvl_list l);
50
51LIBICAL_ICAL_EXPORT pvl_elem pvl_tail(pvl_list);
52
53/* Insert elements in random places */
54typedef int (*pvl_comparef)(void *a, void *b); /* a, b are of the data type */
55
56LIBICAL_ICAL_EXPORT void pvl_insert_ordered(pvl_list l, pvl_comparef f, void *d);
57
58LIBICAL_ICAL_EXPORT void pvl_insert_after(pvl_list l, pvl_elem e, void *d);
59
60LIBICAL_ICAL_EXPORT void pvl_insert_before(pvl_list l, pvl_elem e, void *d);
61
62/* Remove an element, or clear the entire list */
63LIBICAL_ICAL_EXPORT void *pvl_remove(pvl_list, pvl_elem); /* Remove element, return data */
64
65LIBICAL_ICAL_EXPORT void pvl_clear(pvl_list); /* Remove all elements, de-allocate all data */
66
67LIBICAL_ICAL_EXPORT int pvl_count(pvl_list);
68
69/* Navigate the list */
70LIBICAL_ICAL_EXPORT pvl_elem pvl_next(pvl_elem e);
71
72LIBICAL_ICAL_EXPORT pvl_elem pvl_prior(pvl_elem e);
73
74/* get the data in the list */
75#if !defined(PVL_USE_MACROS)
76LIBICAL_ICAL_EXPORT void *pvl_data(pvl_elem);
77#else
78#define pvl_data(x) x == 0 ? 0 : ((struct pvl_elem_t *)x)->d;
79#endif
80
81/* Find an element for which a function returns true */
82typedef int (*pvl_findf)(void *a, void *b); /*a is list elem, b is other data */
83
84LIBICAL_ICAL_EXPORT pvl_elem pvl_find(pvl_list l, pvl_findf f, void *v);
85
86LIBICAL_ICAL_EXPORT pvl_elem pvl_find_next(pvl_list l, pvl_findf f, void *v);
87
92typedef void (*pvl_applyf)(void *a, void *b);
93
94LIBICAL_ICAL_EXPORT void pvl_apply(pvl_list l, pvl_applyf f, void *v);
95
96#endif /* ICAL_PVL_H */
Definition pvl.h:25
struct pvl_elem_t * prior
Definition pvl.h:29
int MAGIC
Definition pvl.h:26
struct pvl_elem_t * next
Definition pvl.h:28
void * d
Definition pvl.h:27
Definition pvl.c:58