diff --git a/clib/sha1.h b/clib/sha1.h --- a/clib/sha1.h +++ b/clib/sha1.h @@ -13,6 +13,7 @@ extern "C" { #endif +#ifdef SHA1_USE_SHA1DC #include #include @@ -34,6 +35,24 @@ static inline int fbhg_sha1_final(unsigned char* md, fbhg_sha1_ctx_t* ctx) { return SHA1DCFinal(md, ctx); } +#else +#include + +typedef SHA_CTX fbhg_sha1_ctx_t; + +static inline int fbhg_sha1_init(fbhg_sha1_ctx_t* ctx) { + return SHA1_Init(ctx); +} + +static inline int +fbhg_sha1_update(fbhg_sha1_ctx_t* ctx, const void* data, unsigned long length) { + return SHA1_Update(ctx, data, length); +} + +static inline int fbhg_sha1_final(unsigned char* md, fbhg_sha1_ctx_t* ctx) { + return SHA1_Final(md, ctx); +} +#endif #ifdef __cplusplus } /* extern C */ diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -16,6 +16,8 @@ WEXTRA = "" if iswindows else "-Wextra" WCONVERSION = "" if iswindows else "-Wconversion" PEDANTIC = "" if iswindows else "-pedantic" +SHA1LIB_DEFINE = "/DSHA1_USE_SHA1DC" if iswindows else "-DSHA1_USE_SHA1DC" +SHA1_LIBRARY = "sha1detectcoll" NOOPTIMIZATION = "/Od" if iswindows else "-O0" OPTIMIZATION = "" if iswindows else "-O2" PRODUCEDEBUGSYMBOLS = "/DEBUG:FULL" if iswindows else "-g" @@ -52,7 +54,7 @@ sys.argv = args -cflags = [] +cflags = [SHA1LIB_DEFINE] # if this is set, compile all C extensions with -O0 -g for easy debugging. note # that this is not manifested in any way in the Makefile dependencies. @@ -160,7 +162,7 @@ 'datapack': { "sources" : ["cdatapack/cdatapack.c"], "include_dirs" : ["clib"] + include_dirs, - "libraries" : ["lz4", "sha1detectcoll"], + "libraries" : ["lz4", SHA1_LIBRARY], "extra_args" : filter(None, [STDC99, WALL, WERROR, WSTRICTPROTOTYPES] + cflags), }, @@ -259,7 +261,7 @@ 'datapack', 'lz4', 'mpatch', - 'sha1detectcoll', + SHA1_LIBRARY, ], extra_compile_args=filter(None, [STDCPP0X, WALL] + cflags), ), @@ -287,7 +289,7 @@ 'third-party', ] + include_dirs, library_dirs=library_dirs, - libraries=['sha1detectcoll'], + libraries=[SHA1_LIBRARY], extra_compile_args=filter(None, [ STDC99, WALL,