From: fredrik Date: Wed, 19 Oct 2005 01:14:16 +0000 (+0000) Subject: Add hashcmp. X-Git-Tag: 0.1~192 X-Git-Url: http://dolda2000.com/gitweb/?a=commitdiff_plain;h=4f8fc795dd4bae877bfef8ac1e8df062c023fca2;p=doldaconnect.git Add hashcmp. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@383 959494ce-11ee-0310-bf91-de5d638817bd --- diff --git a/daemon/client.c b/daemon/client.c index bf7a3af..6f39327 100644 --- a/daemon/client.c +++ b/daemon/client.c @@ -201,6 +201,17 @@ wchar_t *unparsehash(struct hash *hash) return(buf); } +int hashcmp(struct hash *h1, struct hash *h2) +{ + if(wcscmp(h1->algo, h2->algo)) + return(0); + if(h1->len != h2->len) + return(0); + if(memcmp(h1->buf, h2->buf, h1->len)) + return(0); + return(1); +} + static struct hashcache *newhashcache(void) { struct hashcache *new; diff --git a/daemon/client.h b/daemon/client.h index a36c87b..669b2ea 100644 --- a/daemon/client.h +++ b/daemon/client.h @@ -89,6 +89,7 @@ void freehash(struct hash *hash); struct hash *duphash(struct hash *hash); struct hash *parsehash(wchar_t *text); wchar_t *unparsehash(struct hash *hash); +int hashcmp(struct hash *h1, struct hash *h2); extern struct sharecache *shareroot; extern unsigned long long sharesize;