summaryrefslogtreecommitdiffstats
path: root/src/todo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/todo.c')
-rw-r--r--src/todo.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/todo.c b/src/todo.c
index 95e591a..152fbaa 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -79,13 +79,23 @@ struct todo *todo_add(char *mesg, int id, char *note)
return todo;
}
-void todo_write(struct todo *todo, FILE * f)
+char *todo_tostr(struct todo *todo)
{
+ char *res;
+
if (todo->note)
- fprintf(f, "[%d]>%s %s\n", todo->id, todo->note,
- todo->mesg);
+ asprintf(&res, "[%d]>%s %s", todo->id, todo->note, todo->mesg);
else
- fprintf(f, "[%d] %s\n", todo->id, todo->mesg);
+ asprintf(&res, "[%d] %s", todo->id, todo->mesg);
+
+ return res;
+}
+
+void todo_write(struct todo *todo, FILE * f)
+{
+ char *str = todo_tostr(todo);
+ fprintf(f, "%s\n", str);
+ mem_free(str);
}
/* Delete a note previously attached to a todo item. */