mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 12:26:40 +02:00
script: call function string_hash in script_repo_sha512sum_file to compute SHA512 hash
This removes dependency on libgcrypt in script plugin.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user