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/apoint.c
11
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);
|
||||
|
||||
Reference in New Issue
Block a user