static void read_icals(void)
{
for (ical_t *cal = calendars; cal; cal = cal->next) {
- if (cal->comp == NULL && cal->location) {
- wordexp_t wexp;
- wordexp(cal->location, &wexp, WRDE_NOCMD);
- icalparser *parser = icalparser_new();
- for (int i = 0; i < wexp.we_wordc; i++) {
- FILE *file = fopen(wexp.we_wordv[i], "r");
- if (!file)
- continue;
- icalparser_set_gen_data(parser, file);
- }
+ if (!cal->location)
+ debug("Missing location for ical '%s'", cal->cal.name);
+ if (cal->comp)
+ continue;
+ wordexp_t wexp;
+ wordexp(cal->location, &wexp, WRDE_NOCMD);
+ icalparser *parser = icalparser_new();
+ if (wexp.we_wordc > 1)
+ debug("Multiple calendards are not supported '%s'", cal->location);
+ FILE *file = fopen(wexp.we_wordv[0], "r");
+ if (!file) {
+ debug("Cannot open ical file '%s'", wexp.we_wordv[0]);
+ } else {
+ icalparser_set_gen_data(parser, file);
cal->comp = icalparser_parse(parser, (void*)fgets);
icalparser_free(parser);
- wordfree(&wexp);
}
+ wordfree(&wexp);
}
}
PREFIX ?= /usr
-CFLAGS ?= -g -Wall -Werror --std=c99 -DDEBUG_CALS
+CFLAGS ?= -g -Wall -Werror --std=c99 -DCAL_DEBUG
default: all run-lackey
#default: all run-test
cal_load(SEL.year, SEL.month, SEL.day, 1);
/* Debug */
-#ifdef DEBUG_CALS
+#ifdef CAL_DEBUG
for (event_t *e = EVENTS; e; e = e->next)
debug("event: %04d-%02d-%02d %02d:%02d: %s - %s",
e->start.year, e->start.month, e->start.day,
ical_todos(start, end));
/* Verify events and todos*/
-#ifdef DEBUG_CALS
+#ifdef CAL_ERROR
for (event_t *cur = EVENTS; cur; cur = cur->next) {
if (!cur->cal)
error("Missing cal in event '%s'", cur->name);
}
/* debug printout */
- printf("parse: %s.%s.%s = '%s'\n", group, name, line->key, line->value);
+ debug("parse: %s.%s.%s = '%s'", group, name, line->key, line->value);
/* save line formatting for the next write */
if (prev == NULL)
fprintf(output_fd, "%s: ", prefix);
vfprintf(output_fd, fmt, tmp);
fprintf(output_fd, "\n");
+ fflush(output_fd);
}
/* Log to debug file */
fprintf(debug_fd, "%s: ", prefix);
vfprintf(debug_fd, fmt, tmp);
fprintf(debug_fd, "\n");
+ fflush(debug_fd);
}
/* Log to status bar */