diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-12 19:04:35 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-12 19:04:35 +0100 |
commit | 8f7d9c78ab81448bb0eae37657a88e4b6bef0066 (patch) | |
tree | 245676da8eacc0e7d78603330373f64b2fd52e4f /calendar.c | |
parent | Add termios bindings from C. (diff) | |
download | calp-8f7d9c78ab81448bb0eae37657a88e4b6bef0066.tar.gz calp-8f7d9c78ab81448bb0eae37657a88e4b6bef0066.tar.xz |
Add name and color parsing to calendar, Add TYPE.
Diffstat (limited to 'calendar.c')
-rw-r--r-- | calendar.c | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -38,6 +38,8 @@ int read_vcalendar(vcomponent* cal, char* path) { int handle_file(vcomponent* cal, char* path) { INFO("Parsing a single file"); + vcomponent_push_val(cal, "NAME", path); + vcomponent_push_val(cal, "TYPE", "file"); char* resolved_path = realpath(path, NULL); open_ics (resolved_path, cal); free (resolved_path); @@ -58,6 +60,10 @@ int handle_dir(vcomponent* cal, char* path) { /* Slash to guarantee we have at least one */ buf[path_len - 1] = '/'; + + vcomponent_push_val(cal, "NAME", path); + vcomponent_push_val(cal, "TYPE", "vdir"); + struct dirent* d; while ((d = readdir(dir)) != NULL) { /* Check that it's a regular file */ @@ -69,7 +75,22 @@ int handle_dir(vcomponent* cal, char* path) { /* Remove file part from combined path */ buf[path_len] = '\0'; - open_ics (resolved_path, cal); + FILE* f; + char info_buf[0x100]; + if (strcmp (d->d_name, "color") == 0) { + f = fopen(resolved_path, "r"); + fgets(info_buf, 0x100, f); + fclose(f); + vcomponent_push_val(cal, "COLOR", info_buf); + } else if (strcmp (d->d_name, "displayname") == 0) { + f = fopen(resolved_path, "r"); + fgets(info_buf, 0x100, f); + fclose(f); + // TODO make sure that this replaces + vcomponent_push_val(cal, "NAME", info_buf); + } else { + open_ics (resolved_path, cal); + } free (resolved_path); } |