Libical API Documentation 3.0

icalbdbset.h
1/*======================================================================
2 FILE: icalbdbset.h
3
4 (C) COPYRIGHT 2001, Critical Path
5
6 This library is free software; you can redistribute it and/or modify
7 it under the terms of either:
8
9 The LGPL as published by the Free Software Foundation, version
10 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html
11
12 Or:
13
14 The Mozilla Public License Version 2.0. You may obtain a copy of
15 the License at https://www.mozilla.org/MPL/
16======================================================================*/
17
18#ifndef ICALBDBSET_H
19#define ICALBDBSET_H
20
21#include "libical_icalss_export.h"
22#include "icalset.h"
23
24#include <db.h>
25
26 typedef struct icalbdbset_impl icalbdbset;
27
28 enum icalbdbset_subdb_type
29{ ICALBDB_CALENDARS, ICALBDB_EVENTS, ICALBDB_TODOS, ICALBDB_REMINDERS };
30 typedef enum icalbdbset_subdb_type icalbdbset_subdb_type;
31
33LIBICAL_ICALSS_EXPORT int icalbdbset_init_dbenv(char *db_env_dir,
34 void (*logDbFunc) (const DB_ENV *,
35 const char *, const char *));
36
37LIBICAL_ICALSS_EXPORT icalset *icalbdbset_init(icalset *set, const char *dsn, void *options);
38
39LIBICAL_ICALSS_EXPORT int icalbdbset_cleanup(void);
40
41LIBICAL_ICALSS_EXPORT void icalbdbset_checkpoint(void);
42
43LIBICAL_ICALSS_EXPORT void icalbdbset_rmdbLog(void);
44
47LIBICAL_ICALSS_EXPORT icalset *icalbdbset_new(const char *database_filename,
48 icalbdbset_subdb_type subdb_type,
49 int dbtype, u_int32_t flag);
50
51LIBICAL_ICALSS_EXPORT DB *icalbdbset_bdb_open_secondary(DB *dbp,
52 const char *subdb,
53 const char *sindex,
54 int (*callback) (DB *db,
55 const DBT *dbt1,
56 const DBT *dbt2,
57 DBT *dbt3), int type);
58
59LIBICAL_ICALSS_EXPORT char *icalbdbset_parse_data(DBT *dbt, char *(*pfunc) (const DBT *dbt));
60
61LIBICAL_ICALSS_EXPORT void icalbdbset_free(icalset *set);
62
63/* cursor operations */
64LIBICAL_ICALSS_EXPORT int icalbdbset_acquire_cursor(DB *dbp, DB_TXN *tid, DBC ** rdbcp);
65
66LIBICAL_ICALSS_EXPORT int icalbdbset_cget(DBC *dbcp, DBT *key, DBT *data,
67 u_int32_t access_method);
68
69LIBICAL_ICALSS_EXPORT int icalbdbset_cput(DBC *dbcp, DBT *key, DBT *data,
70 u_int32_t access_method);
71
72LIBICAL_ICALSS_EXPORT int icalbdbset_get_first(DBC *dbcp, DBT *key, DBT *data);
73
74LIBICAL_ICALSS_EXPORT int icalbdbset_get_next(DBC *dbcp, DBT *key, DBT *data);
75
76LIBICAL_ICALSS_EXPORT int icalbdbset_get_last(DBC *dbcp, DBT *key, DBT *data);
77
78LIBICAL_ICALSS_EXPORT int icalbdbset_get_key(DBC *dbcp, DBT *key, DBT *data);
79
80LIBICAL_ICALSS_EXPORT int icalbdbset_delete(DB *dbp, DBT *key);
81
82LIBICAL_ICALSS_EXPORT int icalbdbset_put(DB *dbp, DBT *key, DBT *data, u_int32_t access_method);
83
84LIBICAL_ICALSS_EXPORT int icalbdbset_get(DB *dbp, DB_TXN *tid, DBT *key, DBT *data,
85 u_int32_t flags);
86
87LIBICAL_ICALSS_EXPORT const char *icalbdbset_path(icalset *set);
88
89LIBICAL_ICALSS_EXPORT const char *icalbdbset_subdb(icalset *set);
90
91/* Mark the set as changed, so it will be written to disk when it
92 is freed. Commit writes to disk immediately. */
93LIBICAL_ICALSS_EXPORT void icalbdbset_mark(icalset *set);
94
95LIBICAL_ICALSS_EXPORT icalerrorenum icalbdbset_commit(icalset *set);
96
97LIBICAL_ICALSS_EXPORT icalerrorenum icalbdbset_add_component(icalset *set, icalcomponent *child);
98
99LIBICAL_ICALSS_EXPORT icalerrorenum icalbdbset_remove_component(icalset *set,
100 icalcomponent *child);
101
102LIBICAL_ICALSS_EXPORT int icalbdbset_count_components(icalset *set, icalcomponent_kind kind);
103
104/* Restrict the component returned by icalbdbset_first, _next to those
105 that pass the gauge. _clear removes the gauge */
106LIBICAL_ICALSS_EXPORT icalerrorenum icalbdbset_select(icalset *store, icalgauge *gauge);
107
108LIBICAL_ICALSS_EXPORT void icalbdbset_clear(icalset *store);
109
110/* Gets and searches for a component by uid */
111LIBICAL_ICALSS_EXPORT icalcomponent *icalbdbset_fetch(icalset *set,
112 icalcomponent_kind kind, const char *uid);
113
114LIBICAL_ICALSS_EXPORT int icalbdbset_has_uid(icalset *set, const char *uid);
115
116LIBICAL_ICALSS_EXPORT icalcomponent *icalbdbset_fetch_match(icalset *set, icalcomponent *c);
117
118LIBICAL_ICALSS_EXPORT icalerrorenum icalbdbset_modify(icalset *set, icalcomponent *old,
119 icalcomponent *newc);
120
121/* cluster management functions */
122LIBICAL_ICALSS_EXPORT icalerrorenum icalbdbset_set_cluster(icalset *set, icalcomponent *cluster);
123
124LIBICAL_ICALSS_EXPORT icalerrorenum icalbdbset_free_cluster(icalset *set);
125
126LIBICAL_ICALSS_EXPORT icalcomponent *icalbdbset_get_cluster(icalset *set);
127
128/* Iterate through components. If a gauge has been defined, these
129 will skip over components that do not pass the gauge */
130
131LIBICAL_ICALSS_EXPORT icalcomponent *icalbdbset_get_current_component(icalset *set);
132
133LIBICAL_ICALSS_EXPORT icalcomponent *icalbdbset_get_first_component(icalset *set);
134
135LIBICAL_ICALSS_EXPORT icalcomponent *icalbdbset_get_next_component(icalset *set);
136
137/* External iterator for thread safety */
138LIBICAL_ICALSS_EXPORT icalsetiter icalbdbset_begin_component(icalset *set,
139 icalcomponent_kind kind,
140 icalgauge *gauge, const char *tzid);
141
142LIBICAL_ICALSS_EXPORT icalcomponent *icalbdbset_form_a_matched_recurrence_component(icalsetiter *
143 itr);
144
145LIBICAL_ICALSS_EXPORT icalcomponent *icalbdbsetiter_to_next(icalset *set, icalsetiter *i);
146
147LIBICAL_ICALSS_EXPORT icalcomponent *icalbdbsetiter_to_prior(icalset *set, icalsetiter *i);
148
149/* Return a reference to the internal component. You probably should
150 not be using this. */
151
152LIBICAL_ICALSS_EXPORT icalcomponent *icalbdbset_get_component(icalset *set);
153
154LIBICAL_ICALSS_EXPORT DB_ENV *icalbdbset_get_env(void);
155
156LIBICAL_ICALSS_EXPORT int icalbdbset_begin_transaction(DB_TXN *parent_id, DB_TXN ** txnid);
157
158LIBICAL_ICALSS_EXPORT int icalbdbset_commit_transaction(DB_TXN *txnid);
159
160LIBICAL_ICALSS_EXPORT DB *icalbdbset_bdb_open(const char *path,
161 const char *subdb,
162 int type, int mode, u_int32_t flag);
163
164 typedef struct icalbdbset_options
165{
166 icalbdbset_subdb_type subdb;
167 int dbtype;
168 int mode;
169 u_int32_t flag;
170 char *(*pfunc) (const DBT *dbt);
172 int (*callback) (DB *db,
174 const DBT *dbt1, const DBT *dbt2, DBT *dbt3);
175} icalbdbset_options;
176
177#endif /* !ICALBDBSET_H */
icalerrorenum
icalerrorenum
Represents the different types of errors that can be triggered in libical.
Definition: icalerror.h:76
icalset.h
icalbdbset_impl
Definition: icalbdbsetimpl.h:28
icalbdbset_options
Definition: icalbdbset.h:165
icalbdbset_options::dbtype
int dbtype
Definition: icalbdbset.h:167
icalbdbset_options::flag
u_int32_t flag
Definition: icalbdbset.h:169
icalbdbset_options::subdb
icalbdbset_subdb_type subdb
Definition: icalbdbset.h:166
icalbdbset_options::mode
int mode
Definition: icalbdbset.h:168
icalcomponent_impl
Definition: icalcomponent.c:36
icalgauge_impl
Definition: icalgaugeimpl.h:55
icalset_impl
Definition: icalset.h:61
icalsetiter
Definition: icalset.h:52