From 01bf8f930309ffa5990f35eb354fe30dd948bfc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Wed, 16 Oct 2019 15:07:31 -0400 Subject: [PATCH] c wrapper: add dht_infohash_get --- c/opendht.cpp | 5 +++++ c/opendht_c.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/c/opendht.cpp b/c/opendht.cpp index fb28b721..99759eda 100644 --- a/c/opendht.cpp +++ b/c/opendht.cpp @@ -22,6 +22,11 @@ void dht_infohash_random(dht_infohash* h) *reinterpret_cast<dht::InfoHash*>(h) = dht::InfoHash::getRandom(); } +void dht_infohash_get(dht_infohash* h, const uint8_t* dat, size_t dat_size) +{ + *reinterpret_cast<dht::InfoHash*>(h) = dht::InfoHash::get(dat, dat_size); +} + bool dht_infohash_is_zero(const dht_infohash* h) { return static_cast<bool>(*reinterpret_cast<const dht::InfoHash*>(h)); } diff --git a/c/opendht_c.h b/c/opendht_c.h index de69a013..e4b0180c 100644 --- a/c/opendht_c.h +++ b/c/opendht_c.h @@ -37,6 +37,7 @@ struct OPENDHT_C_PUBLIC dht_infohash { uint8_t d[HASH_LEN]; }; typedef struct dht_infohash dht_infohash; OPENDHT_C_PUBLIC void dht_infohash_zero(dht_infohash* h); OPENDHT_C_PUBLIC void dht_infohash_random(dht_infohash* h); +OPENDHT_C_PUBLIC void dht_infohash_get(dht_infohash* h, const uint8_t* dat, size_t dat_size); OPENDHT_C_PUBLIC const char* dht_infohash_print(const dht_infohash* h); OPENDHT_C_PUBLIC bool dht_infohash_is_zero(const dht_infohash* h); @@ -63,7 +64,7 @@ typedef struct dht_privatekey dht_privatekey; OPENDHT_C_PUBLIC dht_privatekey* dht_privatekey_generate(unsigned key_length_bits); OPENDHT_C_PUBLIC dht_privatekey* dht_privatekey_import(const uint8_t* dat, size_t dat_size, const char* password); OPENDHT_C_PUBLIC dht_publickey* dht_privatekey_get_publickey(const dht_privatekey*); -OPENDHT_C_PUBLIC void dht_privatekey_delete(dht_privatekey* pk); +OPENDHT_C_PUBLIC void dht_privatekey_delete(dht_privatekey*); // dht::crypto::Certificate struct OPENDHT_C_PUBLIC dht_certificate; -- GitLab