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/recur.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/recur.c')
-rw-r--r-- | src/recur.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/recur.c b/src/recur.c index 5946217..ddfddb4 100644 --- a/src/recur.c +++ b/src/recur.c @@ -41,6 +41,7 @@ #include <time.h> #include "calcurse.h" +#include "sha1.h" llist_ts_t recur_alist_p; llist_t recur_elist; @@ -498,6 +499,16 @@ char *recur_apoint_tostr(struct recur_apoint *o) return string_buf(&s); } +char *recur_apoint_hash(struct recur_apoint *rapt) +{ + char *raw = recur_apoint_tostr(rapt); + char *sha1 = mem_malloc(SHA1_DIGESTLEN * 2 + 1); + sha1_digest(raw, sha1); + mem_free(raw); + + return sha1; +} + void recur_apoint_write(struct recur_apoint *o, FILE * f) { char *str = recur_apoint_tostr(o); @@ -545,6 +556,16 @@ char *recur_event_tostr(struct recur_event *o) return string_buf(&s); } +char *recur_event_hash(struct recur_event *rev) +{ + char *raw = recur_event_tostr(rev); + char *sha1 = mem_malloc(SHA1_DIGESTLEN * 2 + 1); + sha1_digest(raw, sha1); + mem_free(raw); + + return sha1; +} + void recur_event_write(struct recur_event *o, FILE * f) { char *str = recur_event_tostr(o); |