2 /*======================================================================
4 CREATOR: eric 23 December 1999
7 $Id: icalfileset.h,v 1.15 2008-01-02 20:07:40 dothebart Exp $
10 (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of either:
15 The LGPL as published by the Free Software Foundation, version
16 2.1, available at: http://www.fsf.org/copyleft/lesser.html
20 The Mozilla Public License Version 1.0. You may obtain a copy of
21 the License at http://www.mozilla.org/MPL/
23 The Original Code is eric. The Initial Developer of the Original
27 ======================================================================*/
32 #include <libical/ical.h>
34 #include "icalcluster.h"
35 #include "icalgauge.h"
36 #include <sys/types.h> /* For open() flags and mode */
37 #include <sys/stat.h> /* For open() flags and mode */
38 #include <fcntl.h> /* For open() flags and mode */
44 typedef struct icalfileset_impl icalfileset;
46 icalset* icalfileset_new(const char* path);
47 icalset* icalfileset_new_reader(const char* path);
48 icalset* icalfileset_new_writer(const char* path);
50 icalset* icalfileset_init(icalset *set, const char *dsn, void* options);
52 icalfileset* icalfileset_new_from_cluster(const char* path, icalcluster *cluster);
54 icalcluster* icalfileset_produce_icalcluster(const char *path);
56 void icalfileset_free(icalset* cluster);
58 const char* icalfileset_path(icalset* cluster);
60 /* Mark the cluster as changed, so it will be written to disk when it
61 is freed. Commit writes to disk immediately. */
62 void icalfileset_mark(icalset* set);
63 icalerrorenum icalfileset_commit(icalset* set);
65 icalerrorenum icalfileset_add_component(icalset* set,
66 icalcomponent* child);
68 icalerrorenum icalfileset_remove_component(icalset* set,
69 icalcomponent* child);
71 int icalfileset_count_components(icalset* set,
72 icalcomponent_kind kind);
75 * Restrict the component returned by icalfileset_first, _next to those
76 * that pass the gauge. _clear removes the gauge
78 icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge);
80 /** clear the gauge **/
81 void icalfileset_clear(icalset* set);
83 /** Get and search for a component by uid **/
84 icalcomponent* icalfileset_fetch(icalset* set, const char* uid);
85 int icalfileset_has_uid(icalset* set, const char* uid);
86 icalcomponent* icalfileset_fetch_match(icalset* set, icalcomponent *c);
90 * Modify components according to the MODIFY method of CAP. Works on the
91 * currently selected components.
93 icalerrorenum icalfileset_modify(icalset* set,
94 icalcomponent *oldcomp,
95 icalcomponent *newcomp);
97 /* Iterate through components. If a gauge has been defined, these
98 will skip over components that do not pass the gauge */
100 icalcomponent* icalfileset_get_current_component (icalset* cluster);
101 icalcomponent* icalfileset_get_first_component(icalset* cluster);
102 icalcomponent* icalfileset_get_next_component(icalset* cluster);
104 /* External iterator for thread safety */
105 icalsetiter icalfileset_begin_component(icalset* set, icalcomponent_kind kind, icalgauge* gauge);
106 icalcomponent * icalfilesetiter_to_next(icalset* set, icalsetiter *iter);
107 icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr);
109 /** Return a reference to the internal component. You probably should
110 not be using this. */
112 icalcomponent* icalfileset_get_component(icalset* cluster);
115 * @brief options for opening an icalfileset.
117 * These options should be passed to the icalset_new() function
120 typedef struct icalfileset_options {
121 int flags; /**< flags for open() O_RDONLY, etc */
122 mode_t mode; /**< file mode */
123 int safe_saves; /**< to lock or not */
124 icalcluster *cluster; /**< use this cluster to initialize data */
125 } icalfileset_options;
127 extern icalfileset_options icalfileset_options_default;
129 #endif /* !ICALFILESET_H */