Refactor out todo item serialization

Add a todo_write() function that allows one to serialize todo items and
write serialized data to an output stream in a fashion similar to
apoint_write() and event_write().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer
2011-07-01 14:26:43 +02:00
parent 29d71935af
commit 3076670a76
3 changed files with 11 additions and 4 deletions

View File

@@ -183,6 +183,15 @@ todo_add (char *mesg, int id, char *note)
return todo;
}
void
todo_write (struct todo *todo, FILE *f)
{
if (todo->note)
(void)fprintf (f, "[%d]>%s %s\n", todo->id, todo->note, todo->mesg);
else
(void)fprintf (f, "[%d] %s\n", todo->id, todo->mesg);
}
/* Delete a note previously attached to a todo item. */
static void
todo_delete_note_bynum (unsigned num)