aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-util/cal-util.c
diff options
context:
space:
mode:
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.
*/