2024-12-10 22:06:49 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "db.h"
|
|
|
|
#include "iCal.h"
|
2024-12-11 11:27:00 +01:00
|
|
|
#include "llist.h"
|
2024-12-10 22:06:49 +01:00
|
|
|
#include "planner.h" // for subject and event structs
|
|
|
|
#include "ui.h"
|
2024-12-12 16:08:19 +01:00
|
|
|
#include <assert.h>
|
2024-12-10 22:06:49 +01:00
|
|
|
#include <stdio.h>
|
2024-12-11 01:08:31 +01:00
|
|
|
#include <stdlib.h>
|
2024-12-10 22:06:49 +01:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
|
|
|
time_t now = time(NULL);
|
|
|
|
|
2024-12-11 13:03:28 +01:00
|
|
|
// create new task named LinAlg with priority 3, created now with deadline in
|
|
|
|
// 5 days sp is currently unused spare var
|
2024-12-11 01:08:31 +01:00
|
|
|
Task *t1 = newTask("LinAlg", now, now + days(5), 3, 0);
|
2024-12-12 16:08:19 +01:00
|
|
|
assert(t1 != NULL);
|
2024-12-10 22:06:49 +01:00
|
|
|
|
2024-12-11 13:03:28 +01:00
|
|
|
// Stack Allocated vars only for local use!
|
2024-12-12 16:08:19 +01:00
|
|
|
Task *t2 = newTask("Phys", now, now + days(2), 7, 0);
|
|
|
|
assert(t2 != NULL);
|
|
|
|
Task *t3 = newTask("Analysis", now, now + days(10), 5, 0);
|
|
|
|
assert(t3 != NULL);
|
|
|
|
Task *t4 = newTask("TM1", now, now + days(1), 9, 0);
|
|
|
|
assert(t4 != NULL);
|
2024-12-10 22:06:49 +01:00
|
|
|
|
|
|
|
printf("%s\n", ctime(&now));
|
|
|
|
|
2024-12-11 12:33:50 +01:00
|
|
|
// new llist test
|
2024-12-11 13:59:57 +01:00
|
|
|
llist *list1 = llistNew(t1, cmpTaskN);
|
2024-12-12 16:08:19 +01:00
|
|
|
llistAppend(list1, t2);
|
|
|
|
llistAppend(list1, t3);
|
|
|
|
llistAppend(list1, t4);
|
|
|
|
|
|
|
|
genPlan(list1);
|
2024-12-11 11:27:00 +01:00
|
|
|
|
2024-12-11 12:33:50 +01:00
|
|
|
// print test tasks
|
2024-12-11 13:03:28 +01:00
|
|
|
printTask(t1);
|
2024-12-12 16:08:19 +01:00
|
|
|
printTask(t2);
|
2024-12-11 12:33:50 +01:00
|
|
|
|
|
|
|
// find in list & modify
|
2024-12-11 13:03:28 +01:00
|
|
|
Task search = {.name = "Phys"}; // key to look for. cmpTask only compares
|
|
|
|
// names using strcmp(a.name, b.name)
|
2024-12-11 12:33:50 +01:00
|
|
|
llist *found = llistGet(list1, &search);
|
|
|
|
if (found != NULL) {
|
|
|
|
((Task *)found->data)->deadline = time(NULL) + days(10);
|
2024-12-11 13:41:31 +01:00
|
|
|
((Task *)found->data)->priority = 9;
|
2024-12-11 13:03:28 +01:00
|
|
|
printTask(found->data);
|
|
|
|
} else {
|
|
|
|
printf("%s not in List!\n", search.name);
|
2024-12-11 12:33:50 +01:00
|
|
|
}
|
2024-12-11 13:41:31 +01:00
|
|
|
|
|
|
|
char *t1Str = taskToStr(t1);
|
|
|
|
printf("%s\n", t1Str);
|
|
|
|
free(t1Str);
|
|
|
|
|
2024-12-11 01:08:31 +01:00
|
|
|
free(t1);
|
2024-12-12 16:08:19 +01:00
|
|
|
free(t2);
|
2024-12-10 22:06:49 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|