From 492302ac5d8742d99a394ee23ea290a99ad2c6c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 10 Feb 2019 00:53:10 +0100 Subject: Add param field to content_line. --- vcal.c | 23 ++++++++++++++++++----- vcal.h | 14 ++++++++++++-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/vcal.c b/vcal.c index 5937f04a..3cb46b5f 100644 --- a/vcal.c +++ b/vcal.c @@ -54,8 +54,18 @@ content_line* RESOLVE(content_line) return NULL; } + /* + * This destroys new. + */ APPEND(LLIST(strbuf)) (&dest->vals, &new->vals); + INFO_F("param length = %i", SIZE(LLIST(strbuf))(&new->params)); + FOR(LLIST(strbuf), link, &new->params) { + INFO_F("| %s", link->value->mem); + } + + APPEND(LLIST(strbuf)) (&dest->params, &new->params); + FREE(strbuf)(&new->key); free(new); @@ -70,7 +80,7 @@ INIT_F(content_line) { INIT(strbuf, &this->key); INIT( LLIST(strbuf), &this->vals ); - // TODO remaining fields + INIT( LLIST(strbuf), &this->params ); return 0; } @@ -81,7 +91,7 @@ INIT_F(content_line, int keylen, int vallen) { NEW(strbuf, s, vallen); PUSH(LLIST(strbuf))(&this->vals, s); - // TODO remaining fields + INIT( LLIST(strbuf), &this->params ); return 0; } @@ -90,16 +100,19 @@ FREE_F(content_line) { FREE(strbuf)(&this->key); FREE(LLIST(strbuf))(&this->vals); - // TODO remaining fields + FREE(LLIST(strbuf))(&this->params); return 0; } int content_line_copy (content_line* dest, content_line* src) { + if (! EMPTY(LLIST(strbuf))(&src->params)) { + INFO_F("[%s] : %s", src->key.mem, FIRST_V(&src->params)->mem); + } + DEEP_COPY(strbuf)(&dest->key, &src->key); DEEP_COPY(LLIST(strbuf))(&dest->vals, &src->vals); - - // TODO remaining fields + DEEP_COPY(LLIST(strbuf))(&dest->params, &src->params); return 0; } diff --git a/vcal.h b/vcal.h index a8245ff0..761448c9 100644 --- a/vcal.h +++ b/vcal.h @@ -7,22 +7,32 @@ #define TYPE strbuf #include "linked_list.h" +// #include "trie.h" #undef TYPE +/* typedef struct { strbuf key; strbuf value; + strbuf* vals; int val_count; } parameter; +*/ + +typedef struct { + strbuf key; + strbuf val; +} key_val; typedef struct { strbuf key; LLIST(strbuf) vals; - parameter* params; - int param_count; + /* parcams NULL by default, since most content lines doesn't have + * any properties */ + LLIST(strbuf) params; } content_line; INIT_F(content_line); -- cgit v1.2.3