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. --- vcal.h | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'vcal.h') diff --git a/vcal.h b/vcal.h index b4b2c017..6b3667bf 100644 --- a/vcal.h +++ b/vcal.h @@ -27,6 +27,7 @@ typedef struct { INIT_F(content_line); INIT_F(content_line, int keylen, int vallen); +FREE_F(content_line); /* * Resolves a collision in some form of structure (probably a hash-map @@ -41,37 +42,33 @@ content_line* RESOLVE(content_line) #include "trie.h" #undef TYPE -typedef struct s_vevent { +typedef struct s_vcomponent vcomponent; + +#define TYPE vcomponent +#include "vector.h" +#undef TYPE + +struct s_vcomponent { char* filename; - struct s_vcalendar* calendar; + vcomponent* parent; TRIE(content_line) clines; -} vevent; + VECT(vcomponent) components; +}; -INIT_F(vevent, char* filename); +INIT_F(vcomponent); +INIT_F(vcomponent, char* filename); +FREE_F(vcomponent); -FREE_F(content_line); int content_line_copy (content_line* dest, content_line* src); -content_line* get_property (vevent* ev, char* key); - -int add_content_line (vevent* ev, content_line* c); - -FREE_F(vevent); - -typedef struct s_vcalendar { - size_t n_events; - size_t alloc; - vevent** events; -} vcalendar; +content_line* get_property (vcomponent* ev, char* key); -INIT_F(vcalendar); -int free_vcalendar (vcalendar* cal); +int add_content_line (vcomponent* ev, content_line* c); /* * Appends ev to cal. Doesn't copy ev. So make sure that it wont go * out of scope. - * TODO change this into PUSH(VCALENDAR) (vevent*) ? */ -int push_event(vcalendar* cal, vevent* ev); +int PUSH(vcomponent)(vcomponent*, vcomponent*); #endif /* VCAL_H */ -- cgit v1.2.3