summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-03-01 09:08:48 +0100
committerSébastien Helleu <flashcode@flashtux.org>2020-03-01 09:08:48 +0100
commit3472793d24c4e4158d9d274d46eab9fff9e647ea (patch)
tree7c519412beccf0fee37115b7a9e0f8a3591b7845 /src/plugins
parentbb363ab27f8fc356cbb82947375db690030a456b (diff)
downloadweechat-3472793d24c4e4158d9d274d46eab9fff9e647ea.zip
script: call function string_hash in script_repo_sha512sum_file to compute SHA512 hash
This removes dependency on libgcrypt in script plugin.
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/script/CMakeLists.txt1
-rw-r--r--src/plugins/script/Makefile.am4
-rw-r--r--src/plugins/script/script-repo.c23
3 files changed, 5 insertions, 23 deletions
diff --git a/src/plugins/script/CMakeLists.txt b/src/plugins/script/CMakeLists.txt
index 6346a4064..9ece566bb 100644
--- a/src/plugins/script/CMakeLists.txt
+++ b/src/plugins/script/CMakeLists.txt
@@ -33,7 +33,6 @@ set_target_properties(script PROPERTIES PREFIX "")
set(LINK_LIBS)
list(APPEND LINK_LIBS ${ZLIB_LIBRARY})
-list(APPEND LINK_LIBS ${GCRYPT_LDFLAGS})
target_link_libraries(script ${LINK_LIBS} coverage_config)
diff --git a/src/plugins/script/Makefile.am b/src/plugins/script/Makefile.am
index 2be84705a..5fccb6609 100644
--- a/src/plugins/script/Makefile.am
+++ b/src/plugins/script/Makefile.am
@@ -17,7 +17,7 @@
# along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
#
-AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\" $(ZLIB_CFLAGS) $(GCRYPT_CFLAGS)
+AM_CPPFLAGS = -DLOCALEDIR=\"$(datadir)/locale\" $(ZLIB_CFLAGS)
libdir = ${weechat_libdir}/plugins
@@ -43,6 +43,6 @@ script_la_SOURCES = script.c \
script-repo.h
script_la_LDFLAGS = -module -no-undefined
-script_la_LIBADD = $(SCRIPT_LFLAGS) $(ZLIB_LFLAGS) $(GCRYPT_LFLAGS)
+script_la_LIBADD = $(SCRIPT_LFLAGS) $(ZLIB_LFLAGS)
EXTRA_DIST = CMakeLists.txt
diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c
index 2e42c2f49..26dd7db8b 100644
--- a/src/plugins/script/script-repo.c
+++ b/src/plugins/script/script-repo.c
@@ -36,7 +36,6 @@
#include <stdio.h>
#include <time.h>
#include <zlib.h>
-#include <gcrypt.h>
#include "../weechat-plugin.h"
#include "script.h"
@@ -756,13 +755,7 @@ script_repo_sha512sum_file (const char *filename)
{
struct stat st;
FILE *file;
- char sha512sum[512];
- const char *hexa = "0123456789abcdef";
- unsigned char *data, *result;
- gcry_md_hd_t hd;
- int mdlen, i;
-
- sha512sum[0] = '\0';
+ char *data, *hash;
if (stat (filename, &st) == -1)
return NULL;
@@ -780,21 +773,11 @@ script_repo_sha512sum_file (const char *filename)
}
fclose (file);
- gcry_md_open (&hd, GCRY_MD_SHA512, 0);
- mdlen = gcry_md_get_algo_dlen (GCRY_MD_SHA512);
- gcry_md_write (hd, data, st.st_size);
- result = gcry_md_read (hd, GCRY_MD_SHA512);
- for (i = 0; i < mdlen; i++)
- {
- sha512sum[i * 2] = hexa[(result[i] & 0xFF) / 16];
- sha512sum[(i * 2) + 1] = hexa[(result[i] & 0xFF) % 16];
- }
- sha512sum[((mdlen - 1) * 2) + 2] = '\0';
- gcry_md_close (hd);
+ hash = weechat_string_hash (data, st.st_size, "sha512");
free (data);
- return strdup (sha512sum);
+ return hash;
}
/*