Imported Upstream version 1.0.0
[platform/upstream/libical.git] / examples / usecases.c
1 /* -*- Mode: C -*-
2   ======================================================================
3   FILE: usecases.c
4   CREATOR: eric 03 April 1999
5   
6   DESCRIPTION:
7   
8   $Id: usecases.c,v 1.3 2008-01-02 20:07:29 dothebart Exp $
9   $Locker:  $
10
11   (C) COPYRIGHT 1999 Eric Busboom 
12   http://www.softwarestudio.org
13
14   The contents of this file are subject to the Mozilla Public License
15   Version 1.0 (the "License"); you may not use this file except in
16   compliance with the License. You may obtain a copy of the License at
17   http://www.mozilla.org/MPL/
18  
19   Software distributed under the License is distributed on an "AS IS"
20   basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
21   the License for the specific language governing rights and
22   limitations under the License.
23
24   The original author is Eric Busboom
25   The original code is usecases.c
26
27     
28   ======================================================================*/
29
30 #include <libical/ical.h>
31 #include <assert.h>
32 #include <string.h> /* for strdup */
33 #include <stdlib.h> /* for malloc */
34 #include <stdio.h> /* for printf */
35 #include <time.h> /* for time() */
36
37 char str[] = "BEGIN:VCALENDAR\
38 PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\
39 VERSION:2.0\
40 BEGIN:VEVENT\
41 DTSTAMP:19980309T231000Z\
42 UID:guid-1.host1.com\
43 ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\
44 ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com\
45 DESCRIPTION:Project XYZ Review Meeting\
46 CATEGORIES:MEETING\
47 CREATED:19980309T130000Z\
48 SUMMARY:XYZ Project Review\
49 DTSTART;TZID=US-Eastern:19980312T083000\
50 DTEND;TZID=US-Eastern:19980312T093000\
51 END:VEVENT\
52 END:VCALENDAR";
53
54
55
56
57 /* Here are some ways to work with values. */
58 void test_values()
59 {
60     icalvalue *v; 
61     icalvalue *copy; 
62     char *str;
63
64     v = icalvalue_new_caladdress("cap://value/1");
65     printf("caladdress 1: %s\n",icalvalue_get_caladdress(v));
66
67     icalvalue_set_caladdress(v,"cap://value/2");
68     printf("caladdress 2: %s\n",icalvalue_get_caladdress(v));
69     str = icalvalue_as_ical_string_r(v));
70     printf("String: %s\n", str);
71     free(str);
72     
73     copy = icalvalue_new_clone(v);
74     str = icalvalue_as_ical_string_r(v);
75     printf("Clone: %s\n", str);
76     free(str);
77     icalvalue_free(v);
78     icalvalue_free(copy);
79
80
81 }
82
83 void test_parameters()
84 {
85     icalparameter *p;
86     char *str;
87
88     p = icalparameter_new_cn("A Common Name");
89
90     printf("Common Name: %s\n",icalparameter_get_cn(p));
91
92     str = icalparameter_as_ical_string_r(p));
93     printf("As String: %s\n", str);
94     free(str);
95 }
96
97