From dd85a7374675c3f91e215c2e318b2c5045a01f53 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Mon, 11 Jan 2016 20:24:06 +0100 Subject: Add long format specifiers "raw" and "hash" Add new format specifiers to print the raw item representation or an object's hash value. Signed-off-by: Lukas Fleischer --- src/todo.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/todo.c') diff --git a/src/todo.c b/src/todo.c index 152fbaa..9869a1e 100644 --- a/src/todo.c +++ b/src/todo.c @@ -39,6 +39,7 @@ #include #include "calcurse.h" +#include "sha1.h" llist_t todolist; @@ -91,6 +92,16 @@ char *todo_tostr(struct todo *todo) return res; } +char *todo_hash(struct todo *todo) +{ + char *raw = todo_tostr(todo); + char *sha1 = mem_malloc(SHA1_DIGESTLEN * 2 + 1); + sha1_digest(raw, sha1); + mem_free(raw); + + return sha1; +} + void todo_write(struct todo *todo, FILE * f) { char *str = todo_tostr(todo); -- cgit v1.2.3-54-g00ecf