aboutsummaryrefslogtreecommitdiffstats
path: root/libical/doc/UsingLibical.lyx
diff options
context:
space:
mode:
Diffstat (limited to 'libical/doc/UsingLibical.lyx')
-rw-r--r--libical/doc/UsingLibical.lyx841
1 files changed, 703 insertions, 138 deletions
diff --git a/libical/doc/UsingLibical.lyx b/libical/doc/UsingLibical.lyx
index 776f0d3835..aa299de3c8 100644
--- a/libical/doc/UsingLibical.lyx
+++ b/libical/doc/UsingLibical.lyx
@@ -30,7 +30,7 @@ Using Libical
Eric Busboom (eric@softwarestudio.org)
\layout Date
-November 2000
+January 2001
\layout Standard
@@ -47,13 +47,12 @@ Introduction
Libical is an Open Source implementation of the iCalendar protocols and
protocol data units.
The iCalendar specification describes how calendar clients can communicate
- with calendar servers for users can store their calendar data and arrange
+ with calendar servers so users can store their calendar data and arrange
meetings with other users.
\layout Standard
-Libical implements RFC2445 and RFC2446.
- Eventually, it will also implement iRIP and CAP.
+Libical implements RFC2445, RFC2446 and some of RFC2447 and the CAP draft.
\layout Standard
@@ -125,19 +124,19 @@ src/test
\begin_inset Quotes erd
\end_inset
- for more annotated examples.
+ for additional annotated examples.
\layout Section
Building the Library
\layout Standard
-Libical uses autoconf to generate makefiles, although it uses none of the
- autoconf flags to influence the compilation.
+Libical uses autoconf to generate makefiles.
It should built with no adjustments on Linux, FreeBSD and Solaris under
gcc.
- Some version have been successfully been build on MacOS, Solaris and UnixWare
- without gcc, but you may run into problems with a particular later version.
+ Some version have been successfully been build on MacOS, Solaris, UnixWare,
+ And Tru64 UNIX without gcc, but you may run into problems with a particular
+ later version.
\layout Standard
@@ -194,18 +193,39 @@ ROLE
Components are groups of properties that represent the core objects of a
calendar system, such as events or timezones.
-
-\layout Standard
+ Components are delimited by
+\begin_inset Quotes eld
+\end_inset
+
+BEGIN
+\begin_inset Quotes erd
+\end_inset
+
+ and
+\begin_inset Quotes eld
+\end_inset
+
+END
+\begin_inset Quotes erd
+\end_inset
-The central goal of libical is to parse iTIP data into an internal representatio
-n of Components, Properties, Parameters an Values, and to allow the user
- to manipulate the data in various ways
+ tags.
+
\layout Standard
\added_space_bottom 0.3cm
When a component is sent across a network, if it is un-encrypted, it will
look something like:
\layout Verbatim
+BEGIN:VCALENDAR
+\layout Verbatim
+
+METHOD:REQUEST
+\layout Verbatim
+
+PRODID: -//hacksw/handcal//NONSGML v1.0//EN
+\layout Verbatim
+
BEGIN:VEVENT
\layout Verbatim
@@ -249,21 +269,84 @@ LOCATION:1CP Conference Room 4350
\layout Verbatim
END:VEVENT
+\layout Verbatim
+
+END:VCALENDAR
+\layout Standard
+
+Note that components can be nested; this example has both a VCALENDAR and
+ a VEVENT component, one nested inside the other.
+
\layout Subsection
Core iCal classes
+\layout Standard
+
+Libical is an object-based, data-oriented library.
+ Nearly all of the routines in the library are associated with an opaque
+ data types and perform some operation on that data type.
+ Although the library does not actually have classes, we will use those
+ terms since the behavior of these associations of data and routines is
+ very similar to a class.
+
\layout Subsubsection
-Components
+Properties
+\layout Standard
+
+Properties are represented with the icalproperty class and its many
+\begin_inset Quotes eld
+\end_inset
+
+derived
+\begin_inset Quotes erd
+\end_inset
+
+ classes with on
+\begin_inset Quotes eld
+\end_inset
+
+derived
+\begin_inset Quotes erd
+\end_inset
+
+ class per property type in RFC2445.
+ Again, there is no actual inheritance relations, but there are clusters
+ of routines that make this term useful.
+ A property is a container for a single value and a set of parameters.
+
\layout Subsubsection
-Properties
+Components
+\layout Standard
+
+In libical, components are represented with the icalcomponent class.
+ Icalcomponent is a container for a set of other components and properties.
\layout Subsubsection
Values
+\layout Standard
+
+Values are represented in a similar way to properties; a base class and
+ many
+\begin_inset Quotes eld
+\end_inset
+
+derived
+\begin_inset Quotes eld
+\end_inset
+
+ classes.
+ A value is essentially a abstract handle on a single fundamental type,
+ a structure or a union.
+
\layout Subsubsection
Parameters
+\layout Standard
+
+Parameters are represetned in a similar way to properties, except that they
+ contain only one value
\layout Subsection
Other elements of libical
@@ -274,32 +357,53 @@ In addition to the core iCal classes, libical has many other types, structures,
\layout Subsubsection
-Enumerations
-\layout Subsubsection
+Enumerations and types
+\layout Standard
-Types
+Libical is strongly typed, soo every component, property, parameter, and
+ value type has an enumeration, and some have an associated structure or
+ union.
+
\layout Subsubsection
The parser
-\layout Subsubsection
+\layout Standard
-Restrictions
+The libical parser offers a variety of ways to convert RFC2445 text into
+ a libical iinsteral component structure.
+ the parser can parse blocks of text as a string, or it can parse lin-by-line.
\layout Subsubsection
Error objects
+\layout Standard
+
+Libical has a substantial error reporting system for both programming errors
+ and component usage errors.
+
\layout Subsubsection
Memory Management
+\layout Standard
+
+Since many of libicals interfaces return strings, the library has its own
+ memory management system to elimiate the need to free every string returned
+ from the libraru.
+
\layout Subsubsection
Storage classes
+\layout Standard
+
+The library also offers several classes to store components to flies, memory
+ or databases.
+
\layout Section
Differences From RFCs
\layout Standard
Libical has been designed to follow the standards as closely as possible,
- so that the key objects in the standards are also keey objects in the library.
+ so that the key objects in the standards are also key objects in the library.
However, there are a few areas where the specifications are (arguably)
irregular, and following them exactly would result in an unfriendly interface.
These deviations make libical easier to use by maintaining a self-similar
@@ -350,8 +454,8 @@ X.
\layout Standard
-There are also pseudo components that are conceptually derived classess
- of VALARM.
+There are also pseudo components that are conceptually derived classes of
+ VALARM.
RFC2446 defines what properties may be included in each component, and
for VALARM, the set of properties it may have depends on the value of the
ACTION property.
@@ -405,7 +509,7 @@ Many values can take more than one type.
\layout Standard
It is natural to have interfaces that would return the value of a property,
- but it is cumbersone for a single routine to return multiple types.
+ but it is cumbersome for a single routine to return multiple types.
So, in libical, properties that can have multiple types are given a single
type that is the union of their RFC2445 types.
For instance, in libical, the value of the TRIGGER property resolves to
@@ -452,9 +556,6 @@ Oddly, RFC2445 allows some multi-valued properties ( like FREEBUSY ) to
\layout Section
-Implementation Limitations
-\layout Section
-
Using libical
\layout Subsection
@@ -470,51 +571,50 @@ There are three ways to create components in Libical: creating individual
Constructor Interfaces
\layout Standard
-Using constructor interfaces, you create each of the objects seperately
- and them assemble them in to components:
-\layout Code
+Using constructor interfaces, you create each of the objects separately
+ and then assemble them in to components:
+\layout Verbatim
icalcomponent *event;
-\layout Code
+\layout Verbatim
icalproperty *prop;
-\layout Code
+\layout Verbatim
icalparameter *param;
-\layout Code
+\layout Verbatim
struct icaltimetype atime;
-\layout Code
+\layout Verbatim
event = icalcomponent_new(ICAL_VEVENT_COMPONENT);
-\layout Code
+\layout Verbatim
prop = icalproperty_new_dtstamp(atime) ;
-\layout Code
+\layout Verbatim
icalcomponent_add_property(event, prop);
-\layout Code
+\layout Verbatim
-prop = icalproperty_new_uid("guid-1.host1.com") );
-\layout Code
+prop = icalproperty_new_uid(''guid-1.host1.com'') );
+\layout Verbatim
icalcomponent_add_property(event,prop);
-\layout Code
+\layout Verbatim
-prop=icalproperty_new_organizer("mrbig@host.com");
-\layout Code
+prop=icalproperty_new_organizer(''mrbig@host.com'');
+\layout Verbatim
param = icalparameter_new_role(ICAL_ROLE_CHAIR)
-\layout Code
+\layout Verbatim
icalproperty_add_parameter(prop, param);
-\layout Code
+\layout Verbatim
icalcomponent_add_property(event,prop);
\layout Standard
-While we are on this example, you should notice that libical uses a semi-object-
-oriented style of interface.
+Notice that libical uses a semi-object-oriented style of interface.
Most things you work with are objects, that are instantiated with a constructor
that has
\begin_inset Quotes eld
@@ -548,10 +648,11 @@ If any of the constructors fail, they will return 0.
vaargs Constructors
\layout Standard
-There is another way to create complex components, which is arguable more
+There is another way to create complex components, which is arguably more
elegant, if you are not horrified by varargs.
- The varargs constructor interface all you to create intricate components
- in a single block of text.
+ The varargs constructor interface allows you to create intricate components
+ in a single block of code.
+ Here is the previous examples in the vaargs style.
\layout Verbatim
@@ -564,13 +665,13 @@ There is another way to create complex components, which is arguable more
ICAL_VCALENDAR_COMPONENT,
\layout Verbatim
- icalproperty_new_version("2.0"),
+ icalproperty_new_version(''2.0''),
\layout Verbatim
icalproperty_new_prodid(
\layout Verbatim
- "-//RDU Software//NONSGML HandCal//EN"),
+ ''-//RDU Software//NONSGML HandCal//EN''),
\layout Verbatim
icalcomponent_vanew(
@@ -582,13 +683,13 @@ There is another way to create complex components, which is arguable more
icalproperty_new_dtstamp(atime),
\layout Verbatim
- icalproperty_new_uid("guid-1.host1.com"),
+ icalproperty_new_uid(''guid-1.host1.com''),
\layout Verbatim
icalproperty_vanew_organizer(
\layout Verbatim
- "mrbig@host.com"),
+ ''mrbig@host.com''),
\layout Verbatim
icalparameter_new_role(ICAL_ROLE_CHAIR),
@@ -603,7 +704,7 @@ There is another way to create complex components, which is arguable more
icalproperty_vanew_attendee(
\layout Verbatim
- "employee-A@host.com",
+ ''employee-A@host.com'',
\layout Verbatim
icalparameter_new_role(
@@ -642,7 +743,8 @@ There is another way to create complex components, which is arguable more
);
\layout Standard
-This form is similar to the regular constructor, except that they have
+This form is similar to the constructor form , except that the constructors
+ have
\begin_inset Quotes eld
\end_inset
@@ -659,9 +761,9 @@ new
\end_inset
in the name.
- The arguments are similar too, except that the component contstructor can
+ The arguments are similar too, except that the component constructor can
have a list of properties, and the property constructor can have a list
- or parameters.
+ of parameters.
Be sure to terminate every list with a '0', or your code will crash, if
you are lucky.
@@ -678,8 +780,16 @@ The final way to create components will probably be the most common; you
icalcomponent* icalparser_parse_string(char* str);
\layout Standard
-This may seem wasteful if you want to pull a large component off of the
- network; you may prefer to parse the component line by line.
+If the string contains only one component, the parser will return the component
+ in libical form.
+ If the string contains multiple components, the multiple components will
+ be returned as the children of an ICAL_XROOT_COMPONENT component.
+
+\layout Standard
+
+Parsing a whole string may seem wasteful if you want to pull a large component
+ off of the network or from a file; you may prefer to parse the component
+ line by line.
This is possible too by using:
\layout Verbatim
@@ -700,6 +810,8 @@ icalparser_set_gen_data(parser,stream)
These routines will construct a parser object to which you can add lines
of input and retrieve any components that the parser creates from the input.
+ These routines work by specifing an adaptor routine to get string data
+ from a source.
For an example:
\layout Verbatim
@@ -784,33 +896,34 @@ icalparser_get_line().
The parser calls read_stream() from icalparser_get_line(), but it also
needs to know what stream to use.
This is set by the call to icalparser_set_gen_data().
+ By using a different routine for read_stream or passing in different data
+ with icalparser_set_gen_data, you can connect to any data source.
\layout Standard
-Using the same mechanism, other implmentations could read from memory buffers,
+Using the same mechanism, other implementations could read from memory buffers,
sockets or other interfaces.
\layout Standard
Since the example code is a very common way to use the parser, there is
- a convienience routine;
+ a convenience routine;
\layout Verbatim
icalcomponent* icalparser_parse(icalparser *parser,
\layout Verbatim
- char* (*line_gen_func)(char *s, size_t sise, void* d))
+ char* (*line_gen_func)(char *s, size_t size, void* d))
\layout Standard
To use this routine, you still must construct the parser object and pass
in a reference to a line reading routine.
If the parser can create a single component from the input, it will return
a pointer to the newly constructed component.
- If the parser can construct multiple cmponents from the input, it will
+ If the parser can construct multiple components from the input, it will
return a reference to an XROOT component ( of type ICAL_XROOT_COMPONENT.)
This XROOT component will hold all of the components constructed from the
input as children.
- See section 6.2.2 for how to iterate through the child components.
\layout Subsection
@@ -819,7 +932,7 @@ Accessing Components
Given a reference to a component, you probably will want to access the propertie
s, parameters and values inside.
- Libical interface let you find sub-component, add and remove sub-components,
+ Libical interfaces let you find sub-component, add and remove sub-components,
and do the same three operations on properties.
\layout Subsubsection
@@ -874,7 +987,7 @@ As you might guess, if there is more than one subcomponent of the type you
\layout Subsubsection
-Interating Through Components
+Iterating Through Components
\layout Standard
Iteration requires a second routine to get the next subcomponent after the
@@ -924,7 +1037,7 @@ The iteration model in the previous section requires the component to keep
the state of the iteration.
So, you could not use this model to perform a sorting operations, since
you'd need two iterators and there is only space for one.
- If you ever call icalcomponent_get_first_component() which an iteration
+ If you ever call icalcomponent_get_first_component() when an iteration
is in progress, the pointer will be reset to the beginning.
\layout Standard
@@ -951,7 +1064,7 @@ icalcomponent* icalcompiter_deref(icalcompiter* i);
\layout Standard
The _begin_() and _end_() routines return a new iterator that points to
- the begining and ending of the list of subcomponent for the given component,
+ the beginning and ending of the list of subcomponent for the given component,
and the kind argument works like the kind argument for internal iterators.
\layout Standard
@@ -992,11 +1105,9 @@ for(
Removing Components
\layout Standard
-Libical component have internal iterators, so you can only have one iteration
- over a component at a time.
- Removing an element from a list while iterating through the list can cause
- problems, since you will probably be removing the element that the internal
- iterator points to.
+Removing an element from a list while iterating through the list with the
+ internal iterators can cause problems, since you will probably be removing
+ the element that the internal iterator points to.
The _remove() routine will keep the iterator valid by moving it to the
next component, but in a normal loop, this will result in two advances
per iteration, and you will remove only every other component.
@@ -1100,6 +1211,9 @@ void icalcomponent_remove_property(
\layout Verbatim
icalproperty* property);
+\layout Standard
+
+For parameters:
\layout Verbatim
icalparameter* icalproperty_get_first_parameter(
@@ -1136,6 +1250,10 @@ void icalproperty_remove_parameter(
\layout Verbatim
icalparameter_kind kind);
+\layout Standard
+
+Note that since there should be only one parameter of each type in a property,
+ you will rarely need to use icalparameter_get_nect_paameter.
\layout Subsubsection
Working with values
@@ -1143,10 +1261,10 @@ Working with values
Values are typically part of a property, although they can exist on their
own.
- You can maniplulate them either as part of the property or independantly.
+ You can manipulate them either as part of the property or independently.
\layout Standard
-The most common way to work with values to is to maniplate them from they
+The most common way to work with values to is to manipulate them from they
properties that contain them.
This involves fewer routine calls and intermediate variables than working
with them independently, and it is type-safe.
@@ -1155,7 +1273,7 @@ The most common way to work with values to is to maniplate them from they
For each property, there are a _get_ and a _set_ routine that access the
internal value.
- For instnace, for the UID property, the routines are:
+ For instanace, for the UID property, the routines are:
\layout Verbatim
void icalproperty_set_uid(icalproperty* prop, const char* v)
@@ -1164,7 +1282,7 @@ void icalproperty_set_uid(icalproperty* prop, const char* v)
const char* icalproperty_get_uid(icalproperty* prop)
\layout Standard
-For multivalued properties, like ATTACH, the value type is usually a struct
+For multi-valued properties, like ATTACH, the value type is usually a struct
or union that holds both possible types.
\layout Standard
@@ -1179,10 +1297,10 @@ icalvalue* icalproperty_get_value (icalproperty* prop)
void icalproperty_set_value(icalproperty* prop, icalvalue* value);
\layout Standard
-Icalproperty_get_value() will return a reference that you can manipluate
+Icalproperty_get_value() will return a reference that you can manipulate
with other icalvalue routines.
Most of the time, you will have to know what the type of the value is.
- For instance, if you know that the value is a DATETIME type, you can manipluate
+ For instance, if you know that the value is a DATETIME type, you can manipulate
it with:
\layout Verbatim
@@ -1201,23 +1319,30 @@ void icalproperty_set_x(icalproperty* prop, char* v);
\layout Verbatim
char* icalproperty_get_x(icalproperty* prop);
-\layout Subsubsection
+\layout Standard
+
+All X properties have the type of ICAL_X_PROPERTY, so you will need these
+ routines to get and set the name of the property:
+\layout Verbatim
-Working with parameters
+char* icalproperty_get_x_name(icalproperty* prop)
+\layout Verbatim
+
+void icalproperty_set_x_name(icalproperty* prop, char* name);
\layout Subsubsection
Checking Component Validity
\layout Standard
RFC 2446 defines rules for what properties must exist in a component to
- be used for transfering scheduling data.
+ be used for transferring scheduling data.
Most of these rules relate to the existence of properties relative to the
- METHOD property, which declares what operation a remote reciever should
+ METHOD property, which declares what operation a remote receiver should
use to process a component.
For instance, if the METHOD is REQUEST and the component is a VEVENT, the
- sender is probably asking the reciever to join in a meeting.
+ sender is probably asking the receiver to join in a meeting.
In this case, RFC2446 says that the component must specify a start time
- (DTSTART) and list the reciever as an attendee (ATTENDEE).
+ (DTSTART) and list the receiver as an attendee (ATTENDEE).
\layout Standard
@@ -1246,7 +1371,7 @@ When this routine runs, it will insert new properties into the component
Converting Components to Text
\layout Standard
-To create an RFC2445 compliant text representtion of an object, use one
+To create an RFC2445 compliant text representation of an object, use one
of the *_as_ical_string() routines:
\layout Verbatim
@@ -1274,20 +1399,26 @@ Icalproperty_as_ical_string() will terminate each line with the RFC2445
\backslash
-r
+
\backslash
n
\begin_inset Quotes erd
\end_inset
- However, if you compile with the symbol ICAL_UNIX_NEWLINE defined, it will
- terminate lines with
+ However, if you compile with the symbol ICAL_UNIX_NEWLINE undefined, (
+ it is defined by default) it will terminate lines with
\begin_inset Quotes eld
\end_inset
\backslash
+
+\backslash
n
+\backslash
+
+\backslash
+r
\begin_inset Quotes erd
\end_inset
@@ -1344,10 +1475,49 @@ struct icaltimetype {
*/ };
\layout Standard
-The year, month, day, hour, minute and second fields how the broken-out
+The year, month, day, hour, minute and second fields hold the broken-out
time values.
- The is_utc field distinguishes between times UTC and a local time zone.
- The is_date field indicates if the intra-day fields hold valid data.
+ The is_utc field distinguishes between times in UTC and a local time zone.
+ The is_date field indicates if the time should be interpreted only as a
+ date.
+ If it is a date, the hour, minute and second fields are assumed to be zero,
+ regardless of their actual vaules.
+
+\layout Subsubsection
+
+Creating time structures
+\layout Standard
+
+There are several ways to create a new icaltimetype structure:
+\layout Verbatim
+
+struct icaltimetype icaltime_from_string(const char* str);
+\layout Verbatim
+
+struct icaltimetype icaltime_from_timet(time_t v, int is_date);
+\layout Verbatim
+
+struct icaltimetype icaltime_from_int(int v, int is_date, int is_utc);
+\layout Standard
+
+Icaltime_from_string takes any RFC2445 compliant time string:
+\layout Verbatim
+
+struct icaltimetype tt = icaltime_from_string("19970101T103000");
+\layout Standard
+
+Icaltime_from_timet takes a timet value, representing seconds past the POSIX
+ epoch, and a flag to indicate if the time is a date.
+ Dates have an identical structure to a time, but the time portion ( hours,
+ minuts and seconds ) is always 00:00:00.
+ Dates act differently in sorting an comparision, and they have a different
+ string representation in RFC2445.
+
+\layout Standard
+
+The icaltime_from_int is like icaltime_from_timet, but with an arbitrary
+ epoch.
+ This routine was a mistake and is deprecated.
\layout Subsubsection
@@ -1376,6 +1546,30 @@ It is sensible for the broken-out time fields to contain values that are
struct icaltimetype icaltime_normalize(struct icaltimetype t);
\layout Standard
+Normalizing allows you to do arithmetic operations on time values.
+
+\layout Verbatim
+
+struct icaltimetype tt = icaltime_from_string(
+\begin_inset Quotes eld
+\end_inset
+
+19970101T103000
+\begin_inset Quotes erd
+\end_inset
+
+);
+\layout Verbatim
+
+tt.days +=3
+\layout Verbatim
+
+tt.second += 70;
+\layout Verbatim
+
+tt = icaltime_normalize(tt);
+\layout Standard
+
There are several routines to get the day of the week or month, etc, from
a time structure.
\layout Verbatim
@@ -1403,15 +1597,11 @@ short icaltime_days_in_month(short month,short year);
Two routines convert time structures to and from the number of seconds since
the POSIX epoch.
- The is_date field indicates wether or not the hour, minute and second fields
- should be used in the conversion, and is_utc indicates if the value should
- be converted to a local time or a UTC time, using the operating system
- suppled notion of the local timezone.
-
+ The is_date field indicates whether or not the hour, minute and second
+ fields should be used in the conversion.
\layout Verbatim
-struct icaltimetype icaltime_from_timet(time_t v, int is_date, int is_utc);
-
+struct icaltimetype icaltime_from_timet(time_t v, int is_date);
\layout Verbatim
time_t icaltime_as_timet(struct icaltimetype);
@@ -1442,7 +1632,7 @@ The utc_offset routine returns the offset of the named time zone from UTC,
\layout Standard
-The tt parmeter in the fonllowing routines indicates the date on which the
+The tt parameter in the following routines indicates the date on which the
conversion should be made.
The tt parameter is necessary because timezones have many different rules
for when daylight savings time is used, and these rules can change over
@@ -1453,7 +1643,10 @@ The tt parmeter in the fonllowing routines indicates the date on which the
\layout Verbatim
-int icaltime_utc_offset(struct icaltimetype tt, char* tzid)
+int icaltime_utc_offset(struct icaltimetype tt, char* tzid);
+\layout Verbatim
+
+int icaltime_local_utc_offset();
\layout Verbatim
struct icaltimetype icaltime_as_utc(struct icaltimetype tt,char* tzid);
@@ -1462,16 +1655,346 @@ struct icaltimetype icaltime_as_utc(struct icaltimetype tt,char* tzid);
struct icaltimetype icaltime_as_zone(struct icaltimetype tt,char* tzid);
\layout Verbatim
+struct icaltimetype icaltime_as_local(struct icaltimetype tt);
\layout Subsection
Storing Objects
\layout Standard
-The libical distribution inclues a seperate library, libicalss, that allows
+The libical distribution includes a separate library, libicalss, that allows
you to store iCal component data to disk in a variety of ways.
- This library is documented seperately.
- ( & currently, not at all.
- )
+ This library also includes code to implement the CSTP protocol of CAP and
+ has some routines for deciphering incomming messages.
+
+\layout Standard
+
+The file storage routines are organized in an inheritance heirarchy that
+ is rooted in icalset, with the derived class icalfileset and icaldirset.
+ Icalfileset stores components to a file, while icaldirset stores components
+ to multiple files, one per month based on DTSTAMP.
+ Other storages classess, for storage to a heap or a mysql database are
+ planned for the future.
+
+\layout Standard
+
+All of the icalset derived classes have the same interface:
+\layout Verbatim
+
+\layout Verbatim
+
+icaldirset* icaldirset_new(const char* path);
+\layout Verbatim
+
+void icaldirset_free(icaldirset* store);
+\layout Verbatim
+
+const char* icaldirset_path(icaldirset* store);
+\layout Verbatim
+
+void icaldirset_mark(icaldirset* store);
+\layout Verbatim
+
+icalerrorenum icaldirset_commit(icaldirset* store);
+\layout Verbatim
+
+icalerrorenum icaldirset_add_component(icaldirset* store, icalcomponent*
+ comp);
+\layout Verbatim
+
+icalerrorenum icaldirset_remove_component(icaldirset* store, icalcomponent*
+ comp);
+\layout Verbatim
+
+int icaldirset_count_components(icaldirset* store, icalcomponent_kind kind);
+\layout Verbatim
+
+icalerrorenum icaldirset_select(icaldirset* store, icalcomponent* gauge);
+\layout Verbatim
+
+void icaldirset_clear(icaldirset* store);
+\layout Verbatim
+
+icalcomponent* icaldirset_fetch(icaldirset* store, const char* uid);
+\layout Verbatim
+
+int icaldirset_has_uid(icaldirset* store, const char* uid);
+\layout Verbatim
+
+icalcomponent* icaldirset_fetch_match(icaldirset* set, icalcomponent *c);
+\layout Verbatim
+
+icalerrorenum icaldirset_modify(icaldirset* store, icalcomponent *oldc,
+ icalcomponent *newc);
+\layout Verbatim
+
+icalcomponent* icaldirset_get_current_component(icaldirset* store);
+\layout Verbatim
+
+icalcomponent* icaldirset_get_first_component(icaldirset* store);
+\layout Verbatim
+
+icalcomponent* icaldirset_get_next_component(icaldirset* store);
+\layout Subsubsection
+
+Creating a new set
+\layout Standard
+
+You can create a new set from either the base class or the direved class.
+ From the base class use one of:
+\layout Verbatim
+
+icalset* icalset_new_file(const char* path);
+\layout Verbatim
+
+icalset* icalset_new_dir(const char* path);
+\layout Verbatim
+
+icalset* icalset_new_heap(void);
+\layout Verbatim
+
+icalset* icalset_new_mysql(const char* path);
+\layout Standard
+
+You can also create a new set based on the derived class, For instance,
+ with icalfileset:
+\layout Verbatim
+
+icalfileset* icalfileset_new(const char* path);
+\layout Verbatim
+
+icalfileset* icalfileset_new_open(const char* path, int flags, mode_t mode);
+\layout Standard
+
+Icaset_new_file is identical to icalfileset_new.
+ BOth routines will open an existing file for readinga and writing, or create
+ a new file if it does not exist.
+ Icalfilset_new_open takes the same arguments as the open() system routine
+ and behaves in the same way.
+
+\layout Standard
+
+The icalset and icalfilset objects are somewhat interchangable -- you can
+ use an icalfileset* as an argument to any of the icalset routines.
+\layout Standard
+
+The following examples will all use icalfileset routines; using the other
+ icalset derived classess will be similar.
+
+\layout Subsubsection
+
+Adding, Finding and Removing Components
+\layout Standard
+
+To add components to a set, use:
+\layout Verbatim
+
+icalerrorenum icalfileset_add_component(icalfileset* cluster, icalcomponent*
+ child);
+\layout Standard
+
+The fileset keeps an inmemory copy of the components, and this set must
+ be written back to the file ocassionally.
+ There are two routines to manage this:
+\layout Verbatim
+
+void icalfileset_mark(icalfileset* cluster);
+\layout Verbatim
+
+icalerrorenum icalfileset_commit(icalfileset* cluster);
+\layout Standard
+
+Icalfileset_mark indicates that the in-memory components have changed.
+ Calling the _add_component routine will call _mark automatically, but you
+ may need to call it yourself if you have made a change to an existing component.
+ The _commit routine writes the data base to disk, but only if it is marked.
+ The _commit routine is called automatically when the icalfileset is freed.
+
+\layout Standard
+
+To iterate through the components in a set, use:
+\layout Verbatim
+
+icalcomponent* icalfileset_get_first_component(icalfileset* cluster);
+\layout Verbatim
+
+icalcomponent* icalfileset_get_next_component(icalfileset* cluster);
+\layout Verbatim
+
+icalcomponent* icalfileset_get_current_component (icalfileset* cluster);
+
+\layout Standard
+
+These routines work like the corresponding routines from icalcomponent,
+ except that their output is filtered through a gauge.
+ A gauge is a test for the properties within a components; only components
+ that pass the test are returned.
+ A gauge can be constructed from a MINSQL string with:
+\layout Verbatim
+
+icalgauge* icalgauge_new_from_sql(char* sql);
+\layout Standard
+
+Then, you can add the gauge to the set with :
+\layout Verbatim
+
+icalerrorenum icalfileset_select(icalfileset* store, icalgauge* gauge);
+\layout Standard
+
+Here is an example that puts all of these routines together:
+\layout Verbatim
+
+
+\latex no_latex
+void test_fileset()
+\layout Verbatim
+
+
+\latex no_latex
+{
+\layout Verbatim
+
+
+\latex no_latex
+ icalfileset *fs;
+\layout Verbatim
+
+
+\latex no_latex
+ icalcomponent *c;
+\layout Verbatim
+
+
+\latex no_latex
+ int i;
+\layout Verbatim
+
+
+\latex no_latex
+ char *path = "test_fileset.ics";
+\layout Verbatim
+
+
+\latex no_latex
+ icalgauge *g = icalgauge_new_from_sql(
+\layout Verbatim
+
+
+\latex no_latex
+ "SELECT * FROM VEVENT WHERE DTSTART > '20000103T120000Z' AND DTSTART
+ <= '20000106T120000Z'");
+\layout Verbatim
+
+
+\latex no_latex
+
+\layout Verbatim
+
+
+\latex no_latex
+fs = icalfileset_new(path);
+\layout Verbatim
+
+
+\layout Verbatim
+
+
+\latex no_latex
+for (i = 0; i!= 10; i++){
+\layout Verbatim
+
+
+\latex no_latex
+ c = make_component(i);
+\latex default
+ /* Make a new component where DTSTART has month of i */
+\layout Verbatim
+
+
+\latex no_latex
+ icalfileset_add_component(fs,c);
+\layout Verbatim
+
+
+\latex no_latex
+ }
+\layout Verbatim
+
+\layout Verbatim
+
+
+\latex no_latex
+ icalfileset_commit(fs);
+\latex default
+ /* Write to disk */
+\layout Verbatim
+
+\layout Verbatim
+
+
+\latex no_latex
+ icalfileset_select(fs,g);
+\latex default
+ /* Set the gauge to filter components */
+\layout Verbatim
+
+
+\latex no_latex
+
+\layout Verbatim
+
+
+\latex no_latex
+ for (c = icalfileset_get_first_component(fs);
+\layout Verbatim
+
+
+\latex no_latex
+ c != 0;
+\layout Verbatim
+
+
+\latex no_latex
+ c = icalfileset_get_next_component(fs)){
+\layout Verbatim
+
+
+\latex no_latex
+ struct icaltimetype t = icalcomponent_get_dtstart(c);
+\layout Verbatim
+
+
+\latex no_latex
+
+\layout Verbatim
+
+
+\latex no_latex
+ printf("%s
+\backslash
+n",icaltime_as_ctime(t));
+\layout Verbatim
+
+
+\latex no_latex
+ }
+\layout Verbatim
+
+
+\latex no_latex
+icalfileset_free(fs);
+\layout Verbatim
+
+
+\latex no_latex
+}
+\layout Subsubsection
+
+Other routines
+\layout Standard
+
+There are several other routines in the icalset interface, but they not
+ fully implemented yet.
+
\layout Subsection
@@ -1501,7 +2024,7 @@ Libical relies heavily on dynamic allocation for both the core objects and
\layout Description
-3) If the function name has "add" in it, the caller is transfering control
+3) If the function name has "add" in it, the caller is transferring control
of the memory to the routine.
( icalproperty_add_parameter() )
\layout Description
@@ -1515,6 +2038,7 @@ Libical relies heavily on dynamic allocation for both the core objects and
5) If the routine returns a string, libical owns the memory and will put
it on a ring buffer to reclaim later.
+ For example, icalcomponent_as_ical_string().
You'd better strdup() it if you want to keep it, and you don't have to
delete it.
@@ -1523,8 +2047,8 @@ Libical relies heavily on dynamic allocation for both the core objects and
Error Handling
\layout Standard
-Libical has several error handling mechanisms for the varioustypes of programmin
-g, semantic and syntactic errors you may encounter.
+Libical has several error handling mechanisms for the various types of programmi
+ng, semantic and syntactic errors you may encounter.
\layout Subsubsection
Return values
@@ -1541,11 +2065,51 @@ icalerrno
\layout Standard
Most routines will set the global error value icalerrno on errors.
- This variable is an enumeration; permissable values can be found in libical/ica
+ This variable is an enumeration; permissible values can be found in libical/ica
lerror.h.
If the routine returns an enum icalerrorenum, then the return value will
be the same as icalerrno.
- You can use icalerror_strerror() to get a string that describes the error
+ You can use icalerror_strerror() to get a string that describes the error.
+ The enumerations are:
+\layout Itemize
+
+ICAL_BADARG_ERROR -- One of the argument to a routine was bad.
+ Typically for a null pointer.
+
+\layout Itemize
+
+ICAL_NEWFAILED_ERROR -- A new() or malloc() failed
+\layout Itemize
+
+ICAL_MALFORMEDDATA_ERROR -- An input string was not in the correct format
+\layout Itemize
+
+ICAL_PARSE_ERROR -- The parser failed to parse an incomming component
+\layout Itemize
+
+ICAL_INTERNAL_ERROR -- Largely equivalent to an assert
+\layout Itemize
+
+ICAL_FILE_ERROR -- A file operation failed.
+ Check errno for more detail.
+\layout Itemize
+
+ICAL_ALLOCATION_ERROR -- ?
+\layout Itemize
+
+ICAL_USAGE_ERROR -- ?
+\layout Itemize
+
+ICAL_NO_ERROR -- No error
+\layout Itemize
+
+ICAL_MULTIPLEINCLUSION_ERROR -- ?
+\layout Itemize
+
+ICAL_TIMEDOUT_ERROR -- For CSTP and acquiring locks
+\layout Itemize
+
+ICAL_UNKNOWN_ERROR -- ?
\layout Subsubsection
X-LIC-ERROR and X-LIC-INVALID-COMPONENT
@@ -1555,14 +2119,17 @@ The library handles semantic and syntactic errors in components by inserting
errors properties into the components.
If the parser cannot parse incoming text ( a syntactic error ) or if the
icalrestriction_check() routine indicates that the component does not meet
- the requirments of RFC2446 ( a semantic error) the library will insert
+ the requirements of RFC2446 ( a semantic error) the library will insert
properties of the type X-LIC-ERROR to describe the error.
Here is an example of the error property:
\layout Verbatim
X-LIC-ERROR;X-LIC-ERRORTYPE=INVALID_ITIP :Failed iTIP restrictions for property
DTSTART.
- Expected 1 instances of the property and got 0
+
+\layout Verbatim
+
+Expected 1 instances of the property and got 0
\layout Standard
This error resulted from a call to icalrestriction_check(), which discovered
@@ -1572,6 +2139,11 @@ This error resulted from a call to icalrestriction_check(), which discovered
There are a few routines to manipulate error properties:
\layout Standard
+
+[ The following data is supposed to be in a table.
+ It looks OK in LyX, but does not format propertly in output.
+ ]
+\layout Standard
\LyXTable
multicol5
10 2 0 0 -1 -1 -1 -1
@@ -1642,7 +2214,7 @@ Convert some error properties into
\newline
\newline
-REQUESTS-STATUS to indicate the inability to
+REQUESTS-STATUS proprties to indicate the inability to
\newline
\newline
@@ -1683,12 +2255,26 @@ The libical parser will generate the error that end in PARSEERROR when it
\layout Standard
-Icalcomponent_convert_errors() converts some of the error properties ina
- component into REQUEST-STATUS properties that indicate a failure.
+Icalcomponent_convert_errors() converts some of the error properties in
+ a component into REQUEST-STATUS properties that indicate a failure.
As of libical version0.18, this routine only convert *PARSEERROR errors
and it always generates a 3.x ( failure ) code.
This makes it more of a good idea than a really useful bit of code.
+\layout Subsubsection
+
+ICAL_ERRORS_ARE_FATAL and icalerror_errors_are_fatal
+\layout Standard
+
+If the global variable icalerror_errors_are_fatal is set to 1, then any
+ error condition will cause the program to abort.
+ The abort occurs in icalerror_set_errno(), and is done with an assert(0)
+ if NDEBUG is undefined, and with icalerror_crash_here if NDEBUG is defined.
+ The default value of icalerror_errors_are_fatal is 1 when ICAL_ERRORS_ARE_FATAL
+ is defined, and 0 otherwise.
+ Since ICAL_ERRORS_ARE_FATAL is defined by default, icalerror_errors_are_fatal
+ is also defined by default.
+
\layout Subsection
Naming Standard
@@ -1811,32 +2397,11 @@ The enums for the parts of a recurarance rule and request statuses are irregular
\layout Section
-Useful Recipies
-\layout Standard
-
-Iteration
-\layout Standard
-
-Copying components.
- Remember that you must clone or remove an object before putting in on another
- list.
-
-\layout Standard
-
-Finding compliance errors
-\layout Section
-
-Performance
-\layout Standard
-
-Checking restrictions is computationally expensive.
-\layout Section
-
Hacks and Bugs
\layout Standard
There are a lot of hacks in the library -- bits of code that I am not proud
- of and should propbably be changed.
+ of and should probably be changed.
These are marked with the comment string
\begin_inset Quotes eld
\end_inset