diff options
author | Hugo Hörnquist <hugo@hornquist.se> | 2019-01-19 19:06:09 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@hornquist.se> | 2019-01-19 19:06:14 +0100 |
commit | c42c2834d8c7b5d81465b9d9d127d8384151b9cb (patch) | |
tree | 53b1a8eb0368d5f91525604eea2c3173083c1955 /vcal.c | |
parent | Can now parse entire directory in one go. (diff) | |
download | calp-c42c2834d8c7b5d81465b9d9d127d8384151b9cb.tar.gz calp-c42c2834d8c7b5d81465b9d9d127d8384151b9cb.tar.xz |
[BROKEN] Work on adding hash tables.
Diffstat (limited to '')
-rw-r--r-- | vcal.c | 69 |
1 files changed, 56 insertions, 13 deletions
@@ -2,27 +2,69 @@ #include <string.h> +#define TYPE content_line +#include "hash_help.inc" +#undef TYPE + +int vevent_init(vevent* ev, int init_size) { + HASH_INIT(content_line)(&ev->clines, init_size); + return 0; +} + +content_line* get_property (vevent* ev, char* key) { + return HASH_GET(content_line)(&ev->clines, key); +} + +int add_content_line (vevent* ev, content_line* c) { + return HASH_PUT(content_line)(&ev->clines, c); +} + +int init_content_line (content_line* c, int keylen, int vallen) { + init_string(&c->key, keylen); + init_string(&c->val, vallen); + // TODO remaining fields + return 0; +} + +int content_line_copy (content_line* dest, content_line* src) { + strbuf_init_copy(&dest->key, &src->key); + strbuf_init_copy(&dest->val, &src->val); + + // TODO remaining fields + + return 0; +} + +int content_line_free (content_line* c) { + free_string(&c->key); + free_string(&c->val); + + // TODO remaining fields + + return 0; +} + int copy_vevent(vevent* dest, vevent* src) { - copy_strbuf(&dest->dtstart , &src->dtstart); - copy_strbuf(&dest->dtend , &src->dtend); - copy_strbuf(&dest->summary , &src->summary); - copy_strbuf(&dest->description , &src->description); + // copy_strbuf(&dest->dtstart , &src->dtstart); + // copy_strbuf(&dest->dtend , &src->dtend); + // copy_strbuf(&dest->summary , &src->summary); + // copy_strbuf(&dest->description , &src->description); return 0; } int vevent_init_copy(vevent* dest, vevent* src) { - strbuf_init_copy(&dest->dtstart , &src->dtstart); - strbuf_init_copy(&dest->dtend , &src->dtend); - strbuf_init_copy(&dest->summary , &src->summary); - strbuf_init_copy(&dest->description , &src->description); + // strbuf_init_copy(&dest->dtstart , &src->dtstart); + // strbuf_init_copy(&dest->dtend , &src->dtend); + // strbuf_init_copy(&dest->summary , &src->summary); + // strbuf_init_copy(&dest->description , &src->description); return 0; } int free_vevent (vevent* ev) { - free_string(&ev->dtstart); - free_string(&ev->dtend); - free_string(&ev->summary); - free_string(&ev->description); + // free_string(&ev->dtstart); + // free_string(&ev->dtend); + // free_string(&ev->summary); + // free_string(&ev->description); return 0; } @@ -34,7 +76,8 @@ int push_event(vcalendar* cal, vevent* ev) { cal->events = realloc(cal->events, sizeof(*cal->events) * cal->alloc); } - vevent_init_copy(&cal->events[cal->n_events], ev); + // vevent_init_copy(&cal->events[cal->n_events], ev); + cal->events[cal->n_events] = *ev; cal->n_events++; return 0; |