summaryrefslogtreecommitdiffstats
path: root/tasklst.h
blob: b57099bedbab3dafa2b4c175f7d67b30c40c6c8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* See LICENSE file for copyright and license details. */

#define TASK_LST_DESC_MAX_SIZE 64

enum {
	TASK_TODO,
	TASK_DONE
};

typedef struct TASK_ Task;
struct TASK_ {
	int status;
	Task *prev;
	Task *next;
	char tdesc[TASK_LST_DESC_MAX_SIZE];
};

typedef struct {
	int64_t expiry;
	Task *first;
} TaskLst;

void task_lst_init(TaskLst *list);
void task_lst_cleanup(TaskLst *list);
void task_lst_set_expiration(TaskLst *list, int64_t delta);
int task_lst_expired(TaskLst list);
int task_lst_count_todo(TaskLst list);
int task_lst_count_done(TaskLst list);
Task *task_lst_get_task(TaskLst list, int i);
int task_lst_add_task(TaskLst *list, int status, const char *str);
int task_lst_edit_task(TaskLst *list, int i, const char *newstr);
int task_lst_del_task(TaskLst *list, int i);
int task_lst_read_from_file(TaskLst *list, FILE *fp);
void task_lst_write_to_file(FILE *fp, TaskLst list);