summaryrefslogtreecommitdiff
path: root/src/apoint.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-11 20:24:06 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-13 17:39:44 +0100
commitdd85a7374675c3f91e215c2e318b2c5045a01f53 (patch)
tree9873b442c2fcf90f9c53670a5b9ee7e7aa05cf0b /src/apoint.c
parentae49ef1974883dfd789f73db5dfa6d27184be444 (diff)
downloadcalcurse-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/apoint.c')
-rw-r--r--src/apoint.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/apoint.c b/src/apoint.c
index 263db9d..23c3163 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -40,6 +40,7 @@
#include <time.h>
#include "calcurse.h"
+#include "sha1.h"
llist_ts_t alist_p;
@@ -167,6 +168,16 @@ char *apoint_tostr(struct apoint *o)
return string_buf(&s);
}
+char *apoint_hash(struct apoint *apt)
+{
+ char *raw = apoint_tostr(apt);
+ char *sha1 = mem_malloc(SHA1_DIGESTLEN * 2 + 1);
+ sha1_digest(raw, sha1);
+ mem_free(raw);
+
+ return sha1;
+}
+
void apoint_write(struct apoint *o, FILE * f)
{
char *str = apoint_tostr(o);