aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util/cal-util.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2003-03-25 21:57:25 +0800
committerDan Winship <danw@src.gnome.org>2003-03-25 21:57:25 +0800
commit5d40c589ac1f330e06d6384ebd150f24f15c04a9 (patch)
treec92a8d01fdd15526c650b1d67fa74b4c8ba6f224 /calendar/cal-util/cal-util.c
parentbe58e1949e5df9f14d07f1019a273a74aa4982f8 (diff)
downloadgsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar.gz
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar.bz2
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar.lz
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar.xz
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.tar.zst
gsoc2013-evolution-5d40c589ac1f330e06d6384ebd150f24f15c04a9.zip
Utility wrapper around icalparser.
* cal-util/cal-util.c (cal_util_parse_ics_file): Utility wrapper around icalparser. * cal-util/test-recur.c (main): Use it * pcs/cal-backend-file.c (open_cal): Likewise * gui/comp-editor-factory.c (open_client): Add the OpenClient to the hash before calling cal_client_open_calendar, since in some failure cases, that will call cal_opened_cb (which will free the oc) with a failure immediately, causing a crash if we then try to deref it. svn path=/trunk/; revision=20492
Diffstat (limited to 'calendar/cal-util/cal-util.c')
-rw-r--r--calendar/cal-util/cal-util.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/calendar/cal-util/cal-util.c b/calendar/cal-util/cal-util.c
index 040e322cce..ad495bca77 100644
--- a/calendar/cal-util/cal-util.c
+++ b/calendar/cal-util/cal-util.c
@@ -102,6 +102,33 @@ cal_util_new_top_level (void)
return icalcomp;
}
+static char *
+get_line_fn (char *buf, size_t size, void *file)
+{
+ return fgets (buf, size, file);
+}
+
+icalcomponent *
+cal_util_parse_ics_file (const char *filename)
+{
+ icalparser *parser;
+ icalcomponent *icalcomp;
+ FILE *file;
+
+ file = fopen (filename, "r");
+ if (!file)
+ return NULL;
+
+ parser = icalparser_new ();
+ icalparser_set_gen_data (parser, file);
+
+ icalcomp = icalparser_parse (parser, get_line_fn);
+ icalparser_free (parser);
+ fclose (file);
+
+ return icalcomp;
+}
+
/* Computes the range of time in which recurrences should be generated for a
* component in order to compute alarm trigger times.
*/