From 8e2d4025fc02e07866869a33ccc686f87389cb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 8 Feb 2019 21:13:08 +0100 Subject: V{calendar,event} merged into vcomponent, making it symmetic. --- parse.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'parse.c') diff --git a/parse.c b/parse.c index ed113d47..651572bb 100644 --- a/parse.c +++ b/parse.c @@ -8,7 +8,7 @@ #include "err.h" -int parse_file(char* fname, FILE* f, vcalendar* cal) { +int parse_file(char* fname, FILE* f, vcomponent* cal) { int segments = 1; SNEW(strbuf, str, segments * SEGSIZE); @@ -24,7 +24,7 @@ int parse_file(char* fname, FILE* f, vcalendar* cal) { int line = 0; - vevent* ev = NULL; + vcomponent* ev = NULL; SNEW(content_line, cline, keylen, vallen); @@ -87,7 +87,7 @@ int parse_file(char* fname, FILE* f, vcalendar* cal) { switch (handle_kv(cal, ev, &cline, line, &ctx)) { case s_event: - RENEW(vevent, ev, fname); + RENEW(vcomponent, ev, fname); break; } strbuf_soft_reset(&str); @@ -151,10 +151,10 @@ int parse_file(char* fname, FILE* f, vcalendar* cal) { * TODO Extend this to handle properties */ int handle_kv( - vcalendar* cal, - vevent* ev, - content_line* cline, - int line, + vcomponent* cal, + vcomponent* ev, + content_line* cline, + int line, parse_ctx* ctx ) { switch (ctx->scope) { @@ -174,6 +174,11 @@ int handle_kv( break; case s_calendar: + /* + * TODO + * BEGIN's can be nested, extend this with a stack + * Apparently only VALARM can be nested. + */ if (strbuf_c(&cline->key, "BEGIN")) { if (strbuf_c(cline->vals.cur->value, "VEVENT")) { ctx->scope = s_event; @@ -205,11 +210,12 @@ int handle_kv( } if (strbuf_c(&cline->key, "END")) { if (strbuf_c(cline->vals.cur->value, "VEVENT")) { - push_event(cal, ev); + PUSH(vcomponent)(cal, ev); ctx->scope = s_calendar; return ctx->scope; } else { - ERR_F("%s, %i", "Trying to end something, expected VEVENT", line); + ERR_F("Trying to end something, expected VEVENT, Got [%s]\n%s : %i", + cline->vals.cur->value->mem, ev->filename, line); return -3; } } else { -- cgit v1.2.3