From f90377d34a0a474ee6ab8d118fefbce40559b27c Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 11 Dec 2024 11:27:00 +0100 Subject: [PATCH] modified: src/planner.c modified: src/planner.h modified: src/test.c --- src/planner.c | 12 ++++++++++-- src/planner.h | 4 ++-- src/test.c | 8 ++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/planner.c b/src/planner.c index be8e953..3e80db8 100644 --- a/src/planner.c +++ b/src/planner.c @@ -36,5 +36,13 @@ Task *newTask(char *n, time_t c, time_t d, int p, uint64_t sp) { } // for llist -int cmpTask(Task *a, Task *b) { return strcmp(a->name, b->name); } -int cmpEvent(Event *a, Event *b) { return cmpTask(a->task, b->task); } +int cmpTask(void *a, void *b) { + Task *aa = (Task *)a; + Task *bb = (Task *)b; + return strcmp(aa->name, bb->name); +} +int cmpEvent(void *a, void *b) { + Event *aa = (Event *)a; + Event *bb = (Event *)b; + return cmpTask(aa->task, bb->task); +} diff --git a/src/planner.h b/src/planner.h index 75932a4..22ca46c 100644 --- a/src/planner.h +++ b/src/planner.h @@ -29,7 +29,7 @@ Task *newTask(char *n, time_t c, time_t d, int p, uint64_t sp); /* * compare function for Task */ -int cmpTask(Task *a, Task *b); +int cmpTask(void *a, void *b); /* * Event struct contains task and planned time frame @@ -53,7 +53,7 @@ Event *newEvent(Task *t, time_t s, time_t e, uint64_t sp); /* * compare function for Event */ -int cmpEvent(Event *a, Event *b); +int cmpEvent(void *a, void *b); int genPlan(Task *head); diff --git a/src/test.c b/src/test.c index 030824d..b88a40b 100644 --- a/src/test.c +++ b/src/test.c @@ -1,6 +1,7 @@ #include "config.h" #include "db.h" #include "iCal.h" +#include "llist.h" #include "planner.h" // for subject and event structs #include "ui.h" #include @@ -20,8 +21,15 @@ int main() { // printf("%s\n", ctime(&now)); + llist *list1 = llistNew(t1, cmpTask); + + llistAppend(list1, &t2); + + llist *found = llistGet(list1, &t2); + serialize(t1); serialize(&t2); + serialize(found->data); free(t1); return 0;