StudyPlanner/src/planner.h

89 lines
1.8 KiB
C

#ifndef PLANNER
#define PLANNER
#include "llist.h"
#include <stdint.h>
#include <time.h>
/*
* task subject struct used to track different tasks
d* create new task with taskNew(name, time_t created, time_t deadline, int
* priority, uint64_t spare)
*
* should be freed by user
*
* used to interface with human and store data
*/
typedef struct Task {
char *name;
time_t created;
time_t deadline;
int priority;
uint64_t spare;
} Task;
/*
* allocates and returns Task (free after use)
* returns NULL on failure
*/
Task *newTask(char *n, time_t c, time_t d, int p, uint64_t sp);
/*
* compare function for Task
*/
int cmpTaskN(const void *a, const void *b);
int cmpTaskP(const void *a, const void *b);
/*
* return allocated string representation of Task
*/
char *taskToStr(Task *t);
/*
* prints human readable str of Task to stdout
*/
void printTask(Task *s);
void llistFreeT(llist *head);
/*
* create deepCopy of task
* !! r->name is malloced
*/
Task *copyTask(Task *t);
/*
* Event struct contains task and planned time frame
*
* used to create timetable
*
* eventNew(task, start, end, spare)
* task: pointer to task (Alloced with newTask)
* plannedStartTime: time_t
* plannedEndTime: time_t
* uint64_t spare var
*
*/
typedef struct Event {
Task *task;
time_t plannedStartTime;
time_t plannedEndTime;
uint64_t spare; // spare var
} Event;
/*
* allocates and returns Event (free after use)
* returns NULL on failure
*/
Event *newEvent(Task *t, time_t s, time_t e, uint64_t sp);
/*
* compare function for Event
*/
void freeEvent(Event *e);
void llistFreeE(llist *head);
int cmpEvent(const void *a, const void *b);
/*
* takes llist of tasks and returns llist of events
*/
llist *genPlan(llist *head, time_t timeAvail);
int exportiCal(llist *head);
#endif // !PLANNER