2 * Copyright (C) 2012 Andy Spencer <andy753421@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <libical/ical.h>
26 /* Helper functions */
27 static event_t *to_event(icalcomponent *comp)
29 event_t *event = calloc(1, sizeof(event));
34 event_t *ical_get(cal_t *cal, year_t year, month_t month, day_t day, int days)
41 void ical_printr(icalcomponent *comp, int depth)
44 icalcomponent_kind kind = icalcomponent_isa(comp);
45 printf("%*s", depth, "");
46 printf("%s", icalcomponent_kind_to_string(kind));
47 if (kind == ICAL_VEVENT_COMPONENT ||
48 kind == ICAL_VTODO_COMPONENT)
49 printf(" - %s", icalcomponent_get_summary(comp) ?: "[no summary]");
53 icalcomponent_kind find = ICAL_ANY_COMPONENT;
54 icalcomponent *child = icalcomponent_get_first_component(comp, find);
56 ical_printr(child, depth+2);
57 child = icalcomponent_get_next_component(comp, find);
63 FILE *file = fopen("data/all.ics", "r");
64 icalparser *parser = icalparser_new();
65 icalparser_set_gen_data(parser, file);
66 icalcomponent *ical = icalparser_parse(parser, (void*)fgets);
68 icalparser_free(parser);