aboutsummaryrefslogtreecommitdiffstats
path: root/libical/examples
diff options
context:
space:
mode:
Diffstat (limited to 'libical/examples')
-rw-r--r--libical/examples/access_components.c58
-rw-r--r--libical/examples/errors.c2
-rw-r--r--libical/examples/main.c7
-rw-r--r--libical/examples/parse_text.c3
4 files changed, 33 insertions, 37 deletions
diff --git a/libical/examples/access_components.c b/libical/examples/access_components.c
index 6b655b42f7..18fc6a6144 100644
--- a/libical/examples/access_components.c
+++ b/libical/examples/access_components.c
@@ -9,6 +9,8 @@
#include <time.h> /* for time() */
#include "icalmemory.h"
+void do_something(icalcomponent *c);
+
/* Creating iCal Components
There are two ways to create new component in libical. You can
@@ -59,14 +61,9 @@ icalcomponent* create_new_component()
icalcomponent_add_property(
calendar,
- icalproperty_new_version(strdup("2.0"))
+ icalproperty_new_version("2.0")
);
- /* Note the use of strdup() in the previous and next call. All
- properties constructors for properties with value types of
- TEXT will take control of the string you pass into them. Since
- the string '2.0' is a static string, we need to duplicate it in
- new memory before giving it to the property */
/* Here is the short version of the memory rules:
@@ -88,7 +85,7 @@ icalcomponent* create_new_component()
icalcomponent_add_property(
calendar,
- icalproperty_new_prodid(strdup("-//RDU Software//NONSGML HandCal//EN"))
+ icalproperty_new_prodid("-//RDU Software//NONSGML HandCal//EN")
);
/* Add an event */
@@ -105,11 +102,11 @@ icalcomponent* create_new_component()
icalcomponent_add_property(
event,
- icalproperty_new_uid(strdup("guid-1.host1.com"))
+ icalproperty_new_uid("guid-1.host1.com")
);
/* add a property that has parameters */
- property = icalproperty_new_organizer(strdup("mailto:mrbig@host.com"));
+ property = icalproperty_new_organizer("mailto:mrbig@host.com");
icalproperty_add_parameter(
property,
@@ -123,7 +120,7 @@ icalcomponent* create_new_component()
operation is the same as adding a property to a component */
/* add another property that has parameters */
- property = icalproperty_new_attendee(strdup("mailto:employee-A@host.com"));
+ property = icalproperty_new_attendee("mailto:employee-A@host.com");
icalproperty_add_parameter(
property,
@@ -147,17 +144,17 @@ icalcomponent* create_new_component()
icalcomponent_add_property(
event,
- icalproperty_new_description(strdup("Project XYZ Review Meeting"))
+ icalproperty_new_description("Project XYZ Review Meeting")
);
icalcomponent_add_property(
event,
- icalproperty_new_categories(strdup("MEETING"))
+ icalproperty_new_categories("MEETING")
);
icalcomponent_add_property(
event,
- icalproperty_new_class(strdup("PUBLIC"))
+ icalproperty_new_class("PUBLIC")
);
icalcomponent_add_property(
@@ -167,14 +164,14 @@ icalcomponent* create_new_component()
icalcomponent_add_property(
event,
- icalproperty_new_summary(strdup("XYZ Project Review"))
+ icalproperty_new_summary("XYZ Project Review")
);
property = icalproperty_new_dtstart(atime);
icalproperty_add_parameter(
property,
- icalparameter_new_tzid(strdup("US-Eastern"))
+ icalparameter_new_tzid("US-Eastern")
);
icalcomponent_add_property(event,property);
@@ -184,14 +181,14 @@ icalcomponent* create_new_component()
icalproperty_add_parameter(
property,
- icalparameter_new_tzid(strdup("US-Eastern"))
+ icalparameter_new_tzid("US-Eastern")
);
icalcomponent_add_property(event,property);
icalcomponent_add_property(
event,
- icalproperty_new_location(strdup("1CP Conference Room 4350"))
+ icalproperty_new_location("1CP Conference Room 4350")
);
icalcomponent_add_component(calendar,event);
@@ -224,44 +221,41 @@ icalcomponent* create_new_component_with_va_args()
calendar =
icalcomponent_vanew(
ICAL_VCALENDAR_COMPONENT,
- icalproperty_new_version(strdup("2.0")),
- icalproperty_new_prodid(strdup("-//RDU Software//NONSGML HandCal//EN")),
+ icalproperty_new_version("2.0"),
+ icalproperty_new_prodid("-//RDU Software//NONSGML HandCal//EN"),
icalcomponent_vanew(
ICAL_VEVENT_COMPONENT,
icalproperty_new_dtstamp(atime),
- icalproperty_new_uid(strdup("guid-1.host1.com")),
+ icalproperty_new_uid("guid-1.host1.com"),
icalproperty_vanew_organizer(
- strdup("mailto:mrbig@host.com"),
+ "mailto:mrbig@host.com",
icalparameter_new_role(ICAL_ROLE_CHAIR),
0
),
icalproperty_vanew_attendee(
- strdup("mailto:employee-A@host.com"),
+ "mailto:employee-A@host.com",
icalparameter_new_role(ICAL_ROLE_REQPARTICIPANT),
icalparameter_new_rsvp(1),
icalparameter_new_cutype(ICAL_CUTYPE_GROUP),
0
),
- icalproperty_new_description(strdup("Project XYZ Review Meeting")),
-
- /* Again, note the use of strdup to give libical
- ownership of a static string. */
+ icalproperty_new_description("Project XYZ Review Meeting"),
- icalproperty_new_categories(strdup("MEETING")),
- icalproperty_new_class(strdup("PUBLIC")),
+ icalproperty_new_categories("MEETING"),
+ icalproperty_new_class("PUBLIC"),
icalproperty_new_created(atime),
- icalproperty_new_summary(strdup("XYZ Project Review")),
+ icalproperty_new_summary("XYZ Project Review"),
icalproperty_vanew_dtstart(
atime,
- icalparameter_new_tzid(strdup("US-Eastern")),
+ icalparameter_new_tzid("US-Eastern"),
0
),
icalproperty_vanew_dtend(
atime,
- icalparameter_new_tzid(strdup("US-Eastern")),
+ icalparameter_new_tzid("US-Eastern"),
0
),
- icalproperty_new_location(strdup("1CP Conference Room 4350")),
+ icalproperty_new_location("1CP Conference Room 4350"),
0
),
0
diff --git a/libical/examples/errors.c b/libical/examples/errors.c
index 071a2de816..86d963bd75 100644
--- a/libical/examples/errors.c
+++ b/libical/examples/errors.c
@@ -32,7 +32,7 @@ void component_errors(icalcomponent *comp)
errors = icalcomponent_count_errors(comp);
- printf("This component has %d parsing errors\n");
+ printf("This component has %d parsing errors\n", errors);
/* Print out all of the parsing errors. This is not strictly
correct, because it does not descend into any sub-components,
diff --git a/libical/examples/main.c b/libical/examples/main.c
index 88d6621365..1be2de5c9e 100644
--- a/libical/examples/main.c
+++ b/libical/examples/main.c
@@ -1,9 +1,12 @@
/* This is just to make the code in the example directory link properly. */
+#include "ical.h"
-main()
+int main()
{
+
+ return 1;
}
-int do_something(){
+void do_something(icalcomponent* comp){
}
diff --git a/libical/examples/parse_text.c b/libical/examples/parse_text.c
index 2761e6f951..6de3e76dd5 100644
--- a/libical/examples/parse_text.c
+++ b/libical/examples/parse_text.c
@@ -25,10 +25,9 @@ char* read_stream(char *s, size_t size, void *d)
}
-int parse_text(int argc, char* argv[])
+void parse_text(int argc, char* argv[])
{
- int lineno = 0;
char* line;
FILE* stream;
icalcomponent *c;