From 3076670a76652d538f8b3d0d925197ec2ce32dd9 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 1 Jul 2011 14:26:43 +0200 Subject: 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 --- src/todo.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/todo.c') diff --git a/src/todo.c b/src/todo.c index a6b5687..935109f 100644 --- a/src/todo.c +++ b/src/todo.c @@ -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) -- cgit v1.2.3-54-g00ecf