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