From e13f6bb201dff690208b9cc951b5c098b0d63356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 3 Oct 2019 00:46:01 +0200 Subject: Slowly going through and fixing everything. --- src/calendar.c | 9 ++++++++- src/parse.c | 15 +++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 2cd25f13..a90dfe44 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -10,6 +10,8 @@ #include #include +#include "struct.h" + #include "parse.h" #include "err.h" @@ -45,6 +47,9 @@ int handle_file(SCM cal, char* path) { /* NAME is the `fancy' name of the calendar. */ // vcomponent_push_val(cal, "NAME", basename(path)); // vcomponent_push_val(cal, "X-HNH-SOURCETYPE", "file"); + SCM line = scm_make_vline(); + scm_struct_set_x(line, vline_value, scm_from_utf8_string("file")); + scm_add_line_x(cal, scm_from_utf8_string("X-HNH-SOURCETYPE"), line); char* resolved_path = realpath(path, NULL); open_ics (resolved_path, cal); free (resolved_path); @@ -68,7 +73,9 @@ int handle_dir(SCM cal, char* path) { /* NAME is the `fancy' name of the calendar. */ // vcomponent_push_val(cal, "NAME", basename(path)); - // vcomponent_push_val(cal, "X-HNH-SOURCETYPE", "vdir"); + SCM line = scm_make_vline(); + scm_struct_set_x(line, vline_value, scm_from_utf8_string("vdir")); + scm_add_line_x(cal, scm_from_utf8_string("X-HNH-SOURCETYPE"), line); struct dirent* d; while ((d = readdir(dir)) != NULL) { diff --git a/src/parse.c b/src/parse.c index dd8066ed..06d8707c 100644 --- a/src/parse.c +++ b/src/parse.c @@ -91,14 +91,14 @@ int parse_file(char* filename, FILE* f, SCM root) { */ if (string_eq(line_key, scm_from_utf8_string("BEGIN"))) { /* key \in { VCALENDAR, VEVENT, VALARM, VTODO, VTIMEZONE, ... } */ - // INFO("Creating child"); + INFO("Creating child"); SCM child = scm_make_vcomponent(scm_string_to_symbol(scm_from_strbuf(&str))); scm_add_child_x (component, child); component = child; } else if (string_eq(line_key, scm_from_utf8_string("END"))) { // TODO make current component be parent of current component? - // INFO("back to parent"); + INFO("back to parent"); component = scm_component_parent(component); /* @@ -106,7 +106,8 @@ int parse_file(char* filename, FILE* f, SCM root) { * component. */ } else { - // INFO("Adding attribute"); + strbuf_cap(&str); // TODO remove + INFO_F("Adding attribute [%s]", str.mem); scm_struct_set_x(line, vline_value, scm_from_strbuf(&str)); scm_add_line_x(component, line_key, line); line = scm_make_vline(); @@ -127,7 +128,7 @@ int parse_file(char* filename, FILE* f, SCM root) { /* Save the current parameter key */ // TODO // TRANSFER (¶m_key, &ctx.str); - // INFO("Param key"); + INFO_F("Param key [%s]", str.mem); attr_key = scm_from_strbuf(&str); p_ctx = p_param_value; strbuf_soft_reset (&str); @@ -144,7 +145,7 @@ int parse_file(char* filename, FILE* f, SCM root) { /* We got a parameter value, push the current string to * the current parameter set. */ if (p_ctx == p_param_value) { - // INFO("param value"); + INFO_F("param value [%s]", str.mem); /* save current parameter value. */ scm_add_attribute_x(line, attr_key, scm_from_strbuf(&str)); strbuf_soft_reset (&str); @@ -158,7 +159,8 @@ int parse_file(char* filename, FILE* f, SCM root) { */ if (p_ctx == p_key) { - // INFO("key"); + strbuf_cap(&str); // TODO remove + INFO_F("key [%s]", str.mem); // TRANSFER(&cline_key, &ctx.str); // NEW(content_set, p); @@ -193,6 +195,7 @@ int parse_file(char* filename, FILE* f, SCM root) { * end with CRLF. My files however does not, so we also parse * the end here. */ + ERR("Not implemented"); // TRANSFER(CLINE_CUR_VAL(&cline), &ctx.str); // TODO -- cgit v1.2.3