aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--macro.h1
-rw-r--r--main.c37
-rw-r--r--vcal.h1
3 files changed, 22 insertions, 17 deletions
diff --git a/macro.h b/macro.h
index b3831086..bf0c1864 100644
--- a/macro.h
+++ b/macro.h
@@ -77,6 +77,7 @@
/* Declare destructor */
#define FREE_F(T) int FREE(T) (T* this)
+
/*
* General functions that different container types may implement.
* Actuall implementation and type signature is mostly left to
diff --git a/main.c b/main.c
index 6b52d96e..47d69e4d 100644
--- a/main.c
+++ b/main.c
@@ -35,40 +35,43 @@ int main (int argc, char* argv[argc]) {
arg_shift(&args);
- vcomponent* cal = FCHILD(&root);
-
- assert(strcmp(root.type, "ROOT") == 0);
- assert(strcmp(cal->type, "VCALENDAR") == 0);
-
if (args.argc == 0 || strcmp(args.argv[0], "-p") == 0) {
printf("\nParsed calendar file containing [%u] events\n",
root.components.length
);
- for (size_t i = 0; i < cal->components.length; i++) {
- char* filename = cal->components.items[i]->filename;
- vcomponent* ev = GET(VECT(vcomponent))(&cal->components, i);
+ for (size_t i = 0; i < root.components.length; i++) {
+ vcomponent* cal = GET(VECT(vcomponent))(&root.components, i);
+ assert(strcmp(cal->type, "VCALENDAR") == 0);
+
+ char* filename = cal->filename;
+ for (size_t j = 0; j < cal->components.length; j++) {
+ vcomponent* ev = GET(VECT(vcomponent))(&cal->components, j);
- printf("TYPE = %s\n", ev->type);
- if (strcmp(ev->type, "VEVENT") != 0) continue;
+ if (strcmp(ev->type, "VEVENT") != 0) continue;
- printf("%3lu | %s | %s\n",
- i + 1,
- filename,
- get_property(ev, "SUMMARY")->vals.cur->value->mem);
+ printf("%3lu | %s | %s\n",
+ i + 1,
+ filename,
+ get_property(ev, "SUMMARY")->vals.cur->value->mem);
+ }
}
} else if (strcmp(args.argv[0], "-g") == 0) {
if (arg_shift(&args) == 0) {
- for (size_t i = 0; i < cal->components.length; i++) {
+ for (size_t i = 0; i < root.components.length; i++) {
+ vcomponent* cal = GET(VECT(vcomponent))(&root.components, i);
+ assert(strcmp(cal->type, "VCALENDAR") == 0);
+
+ vcomponent* ev = FCHILD(cal);
+
char target[0xFF];
target[0] = '\0';
strcat(target, "/tmp/dot/");
- vcomponent* ev = GET(VECT(vcomponent))(&cal->components, i);
strcat(target, ev->filename);
strcat(target, ".dot");
create_graph(ev, target);
}
} else {
- create_graph(GET(VECT(vcomponent))(&cal->components, 0), args.argv[0]);
+ create_graph(FCHILD(FCHILD(&root)), args.argv[0]);
}
}
diff --git a/vcal.h b/vcal.h
index 08d706a6..a8245ff0 100644
--- a/vcal.h
+++ b/vcal.h
@@ -77,4 +77,5 @@ int PUSH(vcomponent)(vcomponent*, vcomponent*);
int DEEP_COPY(vcomponent)(vcomponent*, vcomponent*);
+
#endif /* VCAL_H */