+ output[fsize] = 0; // add null terminator
+
+ /* clean up */
+ fclose(file);
+
+ /* return */
+ *size = fsize;
+ return output;
+}
+
+void
+enter_todolist(State* state, char* list_name)
+{
+ TodoList* new_todolist;
+
+ new_todolist = malloc(sizeof(TodoList));
+ new_todolist->list_name = list_name;
+ new_todolist->item_list = malloc(0);
+ new_todolist->item_count = 0;
+
+ state->cur_todolist = new_todolist;
+}
+
+void
+exit_todolist(State* state)
+{
+ #define sb state->board
+
+ if (state->cur_todolist == NULL) return;
+
+ exit_todoitem(state);
+
+ sb->todolist_count += 1;
+ sb->todolist_list = realloc(sb->todolist_list, sb->todolist_count*sizeof(TodoList*));
+ sb->todolist_list[sb->todolist_count-1] = state->cur_todolist;
+ state->cur_todolist = NULL;
+
+}
+
+void
+enter_todoitem(State* state, char* item_name)
+{
+ TodoItem* new_todoitem;
+
+ new_todoitem = malloc(sizeof(TodoItem));
+ new_todoitem->item_name = item_name;
+ new_todoitem->description = NULL;
+ new_todoitem->due = NULL;
+ new_todoitem->subtask_list = malloc(0);
+ new_todoitem->subtask_count = 0;
+
+ state->cur_todoitem = new_todoitem;
+
+}
+
+void
+exit_todoitem(State* state)
+{
+ #define st state->cur_todolist
+
+ TodoList* todolist;
+ TodoItem** item_list;
+
+ if (state->cur_todoitem == NULL) return;
+
+ /* append current item to todo list */
+ todolist = state->cur_todolist;
+ item_list = todolist->item_list;
+
+ st->item_count += 1;
+ st->item_list = realloc(st->item_list, st->item_count*sizeof(TodoItem*));
+ st->item_list[st->item_count-1] = state->cur_todoitem;
+ state->cur_todoitem = NULL;
+
+}
+
+void
+set_description(State* state, char* description)
+{
+ state->cur_todoitem->description = description;
+}
+
+void
+set_due(State* state, char* due)
+{
+
+}
+
+void
+add_subtask(State* state, char* subtask_name, SubTaskState subtask_state)
+{
+ SubTask* new_subtask;
+ SubTask** subtask_list;
+
+ /* create new subtask */
+ new_subtask = malloc(sizeof(SubTask));
+ new_subtask->subtask_name = subtask_name;
+ new_subtask->done = subtask_state;
+
+ /* add it */
+ subtask_list = state->cur_todoitem->subtask_list;
+
+ state->cur_todoitem->subtask_count += 1;
+ subtask_list = realloc(subtask_list, state->cur_todoitem->subtask_count*sizeof(SubTask*));
+ subtask_list[state->cur_todoitem->subtask_count-1] = new_subtask;
+
+ state->cur_todoitem->subtask_list = subtask_list;