资源简介
libical 包含iCalendar协议和数据格式的一个实现。在编译bluez时可能需要这个软件包。
编译方法,请参考:http://www.linuxfromscratch.org/blfs/view/cvs/general/libical.html
代码片段和文件信息
/* Access_component.c */
#include
#include
#include /* for strdup */
#include /* for malloc */
#include /* for printf */
#include /* for time() */
void do_something(icalcomponent *c);
/* Creating iCal Components
There are two ways to create new component in libical. You can
build the component from primitive parts or you can create it
from a string.
There are two variations of the API for building the component from
primitive parts. In the first variation you add each parameter and
value to a property and then add each property to a
component. This results in a long series of function calls. This
style is show in create_new_component()
The second variation uses vargs lists to nest many primitive part
constructors resulting in a compact neatly formated way to create
components. This style is shown in create_new_component_with_va_args()
*/
icalcomponent* create_new_component()
{
/* variable definitions */
icalcomponent* calendar;
icalcomponent* event;
struct icaltimetype atime = icaltime_from_timet( time(0)0);
struct icalperiodtype rtime;
icalproperty* property;
/* Define a time type that will use as data later. */
rtime.start = icaltime_from_timet( time(0)0);
rtime.end = icaltime_from_timet( time(0)0);
rtime.end.hour++;
/* Create calendar and add properties */
calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT);
/* Nearly every libical function call has the same general
form. The first part of the name defines the ‘class‘ for the
function and the first argument will be a pointer to a struct
of that class. So icalcomponent_ functions will all take
icalcomponent* as their first argument. */
/* The next call creates a new proeprty and immediately adds it to the
‘calendar‘ component. */
icalcomponent_add_property(
calendar
icalproperty_new_version(“2.0“)
);
/* Here is the short version of the memory rules:
If the routine name has “new“ in it:
Caller owns the returned memory.
If you pass in a string the routine takes the memory.
If the routine name has “add“ in it:
The routine takes control of the component property
parameter or value memory.
If the routine returns a string ( “get“ and “as_ical_string“ )
The library owns the returned memory.
There are more rules so refer to the documentation for more
details.
*/
icalcomponent_add_property(
calendar
icalproperty_new_prodid(“-//RDU Software//NONSGML HandCal//EN“)
);
/* Add an event */
event = icalcomponent_new(ICAL_VEVENT_COMPONENT);
icalcomponent_add_property(
event
icalproperty_new_dtstamp(atime)
);
/* In the previous call atime is a struct and it is passed in by value.
This is how all compound types of values ar
评论
共有 条评论