modified: src/planner.c

modified:   src/planner.h
	modified:   src/test.c
sql
simon 2024-12-11 13:59:57 +01:00
parent ba5209aa4b
commit 9cc5075531
3 changed files with 16 additions and 4 deletions

View File

@ -69,13 +69,24 @@ char *taskToStr(Task *t) {
} }
// for llist // for llist
int cmpTask(void *a, void *b) {
// compare task by name
int cmpTaskN(void *a, void *b) {
Task *aa = (Task *)a; Task *aa = (Task *)a;
Task *bb = (Task *)b; Task *bb = (Task *)b;
return strcmp(aa->name, bb->name); return strcmp(aa->name, bb->name);
} }
// compare task by priority
int cmpTaskP(void *a, void *b) {
Task *aa = (Task *)a;
Task *bb = (Task *)b;
return aa->priority - bb->priority;
}
// cmp event by task name
int cmpEvent(void *a, void *b) { int cmpEvent(void *a, void *b) {
Event *aa = (Event *)a; Event *aa = (Event *)a;
Event *bb = (Event *)b; Event *bb = (Event *)b;
return cmpTask(aa->task, bb->task); return cmpTaskN(aa->task, bb->task);
} }

View File

@ -29,7 +29,8 @@ Task *newTask(char *n, time_t c, time_t d, int p, uint64_t sp);
/* /*
* compare function for Task * compare function for Task
*/ */
int cmpTask(void *a, void *b); int cmpTaskN(void *a, void *b);
int cmpTaskP(void *a, void *b);
/* /*
* return allocated string representation of Task * return allocated string representation of Task

View File

@ -22,7 +22,7 @@ int main() {
printf("%s\n", ctime(&now)); printf("%s\n", ctime(&now));
// new llist test // new llist test
llist *list1 = llistNew(t1, cmpTask); llist *list1 = llistNew(t1, cmpTaskN);
llistAppend(list1, &t2); llistAppend(list1, &t2);
// print test tasks // print test tasks