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>
This commit is contained in:
11
src/event.c
11
src/event.c
@@ -40,6 +40,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "calcurse.h"
|
||||
#include "sha1.h"
|
||||
|
||||
llist_t eventlist;
|
||||
|
||||
@@ -123,6 +124,16 @@ char *event_tostr(struct event *o)
|
||||
return string_buf(&s);
|
||||
}
|
||||
|
||||
char *event_hash(struct event *ev)
|
||||
{
|
||||
char *raw = event_tostr(ev);
|
||||
char *sha1 = mem_malloc(SHA1_DIGESTLEN * 2 + 1);
|
||||
sha1_digest(raw, sha1);
|
||||
mem_free(raw);
|
||||
|
||||
return sha1;
|
||||
}
|
||||
|
||||
void event_write(struct event *o, FILE * f)
|
||||
{
|
||||
char *str = event_tostr(o);
|
||||
|
||||
Reference in New Issue
Block a user