tAdd function to get metadata from a peer - synk - synchronize files between hosts
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 5db306110bbecf1f8b8f7067ef64f244716af280
(DIR) parent 0b4e0f2bd28198e42d8dd21df92bf3c0b37bf544
(HTM) Author: Willy <willyatmailoodotorg>
Date: Tue, 30 Aug 2016 22:31:07 +0200
Add function to get metadata from a peer
Diffstat:
M synk.c | 15 +++++++++++++++
1 file changed, 15 insertions(+), 0 deletions(-)
---
(DIR) diff --git a/synk.c b/synk.c
t@@ -255,9 +255,24 @@ getpeermeta(struct peer_t *clt, struct metadata_t local)
return close(cfd);
}
+
int
+getmetadata(struct metadata_t *meta, const char *fn)
{
+ FILE *f = NULL;
+
+ if ((f = fopen(fn, "r")) == NULL) {
+ perror(fn);
+ return -1;
+ }
+
+ sha512(f, meta->hash);
+ fclose(f);
+ snprintf(meta->path, PATH_MAX, "%s", fn);
+ meta->mtime = gettimestamp(meta->path);
+ return 0;
+}
}