Back to index

lightning-sunbird  0.9+nobinonly
findobj.c
Go to the documentation of this file.
00001 /* -*- Mode: C -*-
00002   ======================================================================
00003   FILE: findobj.c
00004   CREATOR: eric 11 February 2000
00005   
00006   $Id: findobj.c,v 1.2 2002/06/28 10:45:12 acampi Exp $
00007   $Locker:  $
00008     
00009  (C) COPYRIGHT 2000 Eric Busboom
00010  http://www.softwarestudio.org
00011 
00012  The contents of this file are subject to the Mozilla Public License
00013  Version 1.0 (the "License"); you may not use this file except in
00014  compliance with the License. You may obtain a copy of the License at
00015  http://www.mozilla.org/MPL/
00016  
00017  Software distributed under the License is distributed on an "AS IS"
00018  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00019  the License for the specific language governing rights and
00020  limitations under the License.
00021  
00022  The Original Code is eric. The Initial Developer of the Original
00023  Code is Eric Busboom
00024 
00025 
00026  ======================================================================*/
00027 
00028 #include <stdio.h> /* for printf */
00029 #include <errno.h>
00030 #include <string.h> /* For strerror */
00031 
00032 #include "ical.h"
00033 #include "icalss.h"
00034 
00035 /* This program finds an object stored in a calendar */
00036 
00037 void usage(char* arg0) {
00038     printf("usage: %s calendar-dir uid\n",arg0);
00039 }
00040 
00041 int main(int c, char *argv[]){
00042 
00043     icalcalendar *cal;
00044     icaldirset *booked;
00045     icalcomponent *itr;
00046 
00047     if(c < 2 || c > 3){
00048        usage(argv[0]);
00049        exit(1);
00050     }
00051 
00052     cal = icalcalendar_new(argv[1]);
00053 
00054     if(cal == 0){
00055        fprintf(stderr,"%s: error in opening calendar \"%s\": %s. errno is \"%s\"\n",
00056               argv[0],argv[1],icalerror_strerror(icalerrno),
00057               strerror(errno));
00058     }
00059 
00060     booked = icalcalendar_get_booked(cal);
00061 
00062     itr = icaldirset_fetch(booked,argv[2]);
00063 
00064 
00065     if(itr != 0){
00066        printf("%s",icalcomponent_as_ical_string(itr));
00067     }
00068 
00069     return 0;
00070 }
00071