diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-11 20:24:06 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-13 17:39:44 +0100 |
commit | dd85a7374675c3f91e215c2e318b2c5045a01f53 (patch) | |
tree | 9873b442c2fcf90f9c53670a5b9ee7e7aa05cf0b /src/todo.c | |
parent | ae49ef1974883dfd789f73db5dfa6d27184be444 (diff) | |
download | calcurse-dd85a7374675c3f91e215c2e318b2c5045a01f53.zip |
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 <lfleischer@calcurse.org>
Diffstat (limited to 'src/todo.c')
-rw-r--r-- | src/todo.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -39,6 +39,7 @@ #include <unistd.h> #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); |