aboutsummaryrefslogtreecommitdiff
path: root/vcal.c
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-03-08 10:05:35 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-03-08 10:05:35 +0100
commit0dff6c5d179aeb9e1ba3fc5f4dd679987e342036 (patch)
treec43ef6a0ef0fe6f684928a226a0f439975b20e01 /vcal.c
parentWork on recuring event stream. (diff)
downloadcalp-0dff6c5d179aeb9e1ba3fc5f4dd679987e342036.tar.gz
calp-0dff6c5d179aeb9e1ba3fc5f4dd679987e342036.tar.xz
Remove C vector library.
Diffstat (limited to 'vcal.c')
-rw-r--r--vcal.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/vcal.c b/vcal.c
index 2c3ef7e1..305275e7 100644
--- a/vcal.c
+++ b/vcal.c
@@ -26,7 +26,8 @@
#undef TYPE
#define TYPE vcomponent
-#include "vector.inc.h"
+// #include "vector.inc.h"
+#include "linked_list.inc.h"
#undef TYPE
INIT_F(vcomponent) {
@@ -42,7 +43,7 @@ INIT_F(vcomponent, const char* type) {
INIT_F(vcomponent, const char* type, const char* filename) {
INIT(TRIE(content_line), &self->clines);
- INIT(VECT(vcomponent), &self->components);
+ INIT(LLIST(vcomponent), &self->components);
if (filename != NULL) {
vcomponent_push_val (self, "X-HNH-FILENAME", filename);
@@ -75,14 +76,14 @@ FREE_F(vcomponent) {
ERR("Error freeing vcomponent");
}
- FREE(VECT(vcomponent))(&self->components);
+ FREE(LLIST(vcomponent))(&self->components);
return 0;
}
int PUSH(vcomponent)(vcomponent* parent, vcomponent* child) {
child->parent = parent;
- return PUSH(VECT(vcomponent))(&parent->components, child);
+ return PUSH(LLIST(vcomponent))(&parent->components, child);
}
int DEEP_COPY(vcomponent)(vcomponent* a, vcomponent* b) {
@@ -92,17 +93,31 @@ int DEEP_COPY(vcomponent)(vcomponent* a, vcomponent* b) {
return -1;
}
+int vcomponent_copy(vcomponent* dest, vcomponent* src) {
+
+ DEEP_COPY(TRIE(content_line))(&dest->clines, &src->clines);
+
+ /* Children are the same objects */
+ FOR(LLIST, vcomponent, c, &src->components) {
+ PUSH(LLIST(vcomponent))(&dest->components, c);
+ }
+
+ PUSH(vcomponent)(src->parent, dest);
+
+ return 0;
+}
+
FMT_F(vcomponent) {
int seek = 0;
for (int i = 0; i < 40; i++) fmtf("_");
seek += sprintf(buf + seek, _YELLOW);
- seek += sprintf(buf + seek, "\nVComponet (Type := %s)\n", self->type);
+ seek += sprintf(buf + seek, "\nVComponet (Type := %s)\n", self->type);
seek += sprintf(buf + seek, _RESET);
seek += FMT(TRIE(content_line))(&self->clines, buf + seek);
seek += sprintf(buf + seek, "\nComponents:\n");
- FOR(VECT, vcomponent, comp, &self->components) {
+ FOR(LLIST, vcomponent, comp, &self->components) {
seek += FMT(vcomponent)(comp, buf + seek);
}