Back to index

lightning-sunbird  0.9+nobinonly
icaltestparser.c
Go to the documentation of this file.
00001 /* -*- Mode: C -*-
00002   ======================================================================
00003   FILE: icaltestparser.c
00004   CREATOR: eric 20 June 1999
00005   
00006   $Id: icaltestparser.c,v 1.2 2001/01/16 06:55:09 ebusboom Exp $
00007   $Locker:  $
00008     
00009  The contents of this file are subject to the Mozilla Public License
00010  Version 1.0 (the "License"); you may not use this file except in
00011  compliance with the License. You may obtain a copy of the License at
00012  http://www.mozilla.org/MPL/
00013  
00014  Software distributed under the License is distributed on an "AS IS"
00015  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00016  the License for the specific language governing rights and
00017  limitations under the License.
00018 
00019   The original author is Eric Busboom
00020   The original code is icaltestparser.c
00021 
00022  
00023  (C) COPYRIGHT 1999 The Software Studio. 
00024  http://www.softwarestudio.org
00025 
00026  ======================================================================*/
00027 
00028 #include <stdio.h>
00029 #include <errno.h>
00030 #include <stdio.h>
00031 #include <string.h>
00032 #include "ical.h"
00033 
00034 #include <stdlib.h>
00035 
00036 char str[] = "BEGIN:VCALENDAR\
00037 PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\
00038 VERSION:2.0\
00039 BEGIN:VTIMEZONE\
00040 TZID:US-Eastern\
00041 BEGIN:STANDARD\
00042 DTSTART:19990404T020000\
00043 RDATE:19990u404xT020000\
00044 TZOFFSETFROM:-0500\
00045 TZOFFSETTO:-0400\
00046 END:STANDARD\
00047 BEGIN:DAYLIGHT\
00048 DTSTART:19990404T020000\
00049 RDATE:19990404T020000\
00050 TZOFFSETFROM:-0500\
00051 TZOFFSETTO:-0400\
00052 TZNAME:EDT\
00053 Dkjhgri:derhvnv;\
00054 BEGIN:dfkjh\
00055 END:dfdfkjh\
00056 END:DAYLIGHT\
00057 END:VTIMEZONE\
00058 BEGIN:VEVENT\
00059 GEO:Bongo\
00060 DTSTAMP:19980309T231000Z\
00061 UID:guid-1.host1.com\
00062 ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\
00063 ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP\
00064  :MAILTO:employee-A@host.com\
00065 DESCRIPTION:Project XYZ Review Meeting\
00066 CATEGORIES:MEETING\
00067 CLASS:PUBLIC\
00068 CREATED:19980309T130000Z\
00069 SUMMARY:XYZ Project Review\
00070 DTSTART;TZID=US-Eastern:19980312T083000\
00071 DTEND;TZID=US-Eastern:19980312T093000\
00072 LOCATION:1CP Conference Room 4350\
00073 END:VEVENT\
00074 END:VCALENDAR\
00075 ";
00076 
00077 extern int yydebug;
00078 
00079 /* Have the parser fetch data from stdin */
00080 
00081 char* read_stream(char *s, size_t size, void *d)
00082 {
00083   char *c = fgets(s,size, (FILE*)d);
00084 
00085   return c;
00086 
00087 }
00088 
00089 
00090 
00091 int main(int argc, char* argv[])
00092 {
00093 
00094     char* line; 
00095     FILE* stream;
00096     icalcomponent *c; 
00097     icalparser *parser = icalparser_new();
00098 
00099     stream = fopen(argv[1],"r");
00100 
00101     assert(stream != 0);
00102 
00103     icalparser_set_gen_data(parser,stream);
00104 
00105     do{
00106     
00107        line = icalparser_get_line(parser,read_stream);
00108 
00109        c = icalparser_add_line(parser,line);
00110 
00111 
00112        if (c != 0){
00113            /*icalcomponent_convert_errors(c);*/
00114            printf("%s",icalcomponent_as_ical_string(c));
00115            printf("\n---------------\n");
00116            icalcomponent_free(c);
00117        }
00118 
00119     } while ( line != 0);
00120 
00121     return 0;
00122  }