bump to 1.0.0 and clean up spec file
[platform/upstream/libical.git] / src / test / findobj.c
1 /* -*- Mode: C -*-
2   ======================================================================
3   FILE: findobj.c
4   CREATOR: eric 11 February 2000
5   
6   $Id: findobj.c,v 1.3 2008-01-02 20:07:45 dothebart Exp $
7   $Locker:  $
8     
9  (C) COPYRIGHT 2000 Eric Busboom
10  http://www.softwarestudio.org
11
12  The contents of this file are subject to the Mozilla Public License
13  Version 1.0 (the "License"); you may not use this file except in
14  compliance with the License. You may obtain a copy of the License at
15  http://www.mozilla.org/MPL/
16  
17  Software distributed under the License is distributed on an "AS IS"
18  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19  the License for the specific language governing rights and
20  limitations under the License.
21  
22  The Original Code is eric. The Initial Developer of the Original
23  Code is Eric Busboom
24
25
26  ======================================================================*/
27
28 #include <stdio.h> /* for printf */
29 #include <errno.h>
30 #include <string.h> /* For strerror */
31
32 #include <libical/ical.h>
33 #include <libicalss/icalss.h>
34
35 /* This program finds an object stored in a calendar */
36
37 void usage(char* arg0) {
38     printf("usage: %s calendar-dir uid\n",arg0);
39 }
40
41 int main(int c, char *argv[]){
42
43     icalcalendar *cal;
44     icaldirset *booked;
45     icalcomponent *itr;
46
47     if(c < 2 || c > 3){
48         usage(argv[0]);
49         exit(1);
50     }
51
52     cal = icalcalendar_new(argv[1]);
53
54     if(cal == 0){
55         fprintf(stderr,"%s: error in opening calendar \"%s\": %s. errno is \"%s\"\n",
56                 argv[0],argv[1],icalerror_strerror(icalerrno),
57                 strerror(errno));
58     }
59
60     booked = icalcalendar_get_booked(cal);
61
62     itr = icaldirset_fetch(booked,argv[2]);
63
64
65     if(itr != 0){
66         printf("%s",icalcomponent_as_ical_string(itr));
67     }
68
69     return 0;
70 }
71