From 066d7497f830d33c22039a7b42ffacf1f6c46037 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 26 Jun 2009 14:35:29 +0000 Subject: [PATCH] 2009-06-25 16:34 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * source/rtl/hbmd5.c + HB_MD5(), HB_MD5FILE(): New logical parameter added, which controls whether to return binary data or hexadecimal string. The default is .T. which will return hexa string, to stay compatible. Later we should switch the default to .F.. * mpkg_gnu.bat * Updated requirement section. --- harbour/ChangeLog | 10 ++++++++++ harbour/mpkg_gnu.bat | 3 +-- harbour/source/rtl/hbmd5.c | 28 ++++++++++++++++++++-------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b4f396593f..9b121eadf6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,16 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-25 16:34 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * source/rtl/hbmd5.c + + HB_MD5(), HB_MD5FILE(): New logical parameter added, which + controls whether to return binary data or hexadecimal string. + The default is .T. which will return hexa string, to stay + compatible. Later we should switch the default to .F.. + + * mpkg_gnu.bat + * Updated requirement section. + 2009-06-26 15:52 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rdd/hsx/hsx.c * removed ( BYTE * ) casting diff --git a/harbour/mpkg_gnu.bat b/harbour/mpkg_gnu.bat index 4316981251..b8725839b7 100644 --- a/harbour/mpkg_gnu.bat +++ b/harbour/mpkg_gnu.bat @@ -20,8 +20,7 @@ rem or HB_DIR_NSIS envvar set to its dir with an ending backslash. rem (only for Windows builds) rem - Info-ZIP zip.exe in PATH rem https://sourceforge.net/project/showfiles.php?group_id=118012 -rem - HB_COMPILER envvar configured (see INSTALL doc) -rem - C compiler and GNU Make configured (see INSTALL doc) +rem - C compiler configured (see INSTALL doc) rem --------------------------------------------------------------- if not "%OS%" == "Windows_NT" echo This Harbour build script requires Windows NT or upper. diff --git a/harbour/source/rtl/hbmd5.c b/harbour/source/rtl/hbmd5.c index 95c513e2c2..c0dc140de0 100644 --- a/harbour/source/rtl/hbmd5.c +++ b/harbour/source/rtl/hbmd5.c @@ -378,14 +378,20 @@ HB_FUNC( HB_MD5 ) { ULONG ulLen = hb_parclen( 1 ); char dststr[ 16 ]; - char digest[ 33 ]; hb_md5( pszStr, ulLen, dststr ); - hb_md5digest( dststr, digest ); - hb_retclen( digest, 32 ); + + if( ! ISLOG( 2 ) || hb_parl( 2 ) ) + { + char digest[ 32 + 1 ]; + hb_md5digest( dststr, digest ); + hb_retclen( digest, HB_SIZEOFARRAY( digest ) - 1 ); + } + else + hb_retclen( dststr, HB_SIZEOFARRAY( dststr ) ); } else - hb_retc( NULL ); /* return empty string on wrong call */ + hb_retc_null(); /* return empty string on wrong call */ } HB_FUNC( HB_MD5FILE ) @@ -399,13 +405,19 @@ HB_FUNC( HB_MD5FILE ) if( hFile != FS_ERROR ) { char dststr[ 16 ]; - char digest[ 33 ]; hb_md5file( hFile, dststr ); - hb_md5digest( dststr, digest ); - hb_retclen( digest, 32 ); + + if( ! ISLOG( 2 ) || hb_parl( 2 ) ) + { + char digest[ 32 + 1 ]; + hb_md5digest( dststr, digest ); + hb_retclen( digest, HB_SIZEOFARRAY( digest ) - 1 ); + } + else + hb_retclen( dststr, HB_SIZEOFARRAY( dststr ) ); return; } } - hb_retc( NULL ); /* return empty string on wrong call */ + hb_retc_null(); /* return empty string on wrong call */ }