From bbc434f9a2b83fd7459c85ab70c06542658ee4a6 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 22 Jul 2009 15:52:10 +0000 Subject: [PATCH] 2009-07-22 17:51 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * make_gnu.bat ! Added SHLVL=0 to make commands to force native shell even if sh shell is found in the PATH (f.e. when msys or cygwin is present there, for mingwarm targets, cygwin is even required.) * external/libhpdf/Makefile + Made it compile with mingwarm. * include/hbextern.ch ! Fixed typo in prev. * contrib/hbssl/pem.c + Added two new functions. Under testing. PEM_READ_BIO_RSAPRIVATEKEY() PEM_READ_BIO_RSAPUBLICKEY() --- harbour/ChangeLog | 18 ++++++++ harbour/contrib/hbssl/pem.c | 74 ++++++++++++++++++++++++++++++- harbour/external/libhpdf/Makefile | 5 +++ harbour/include/hbextern.ch | 20 ++++----- harbour/make_gnu.bat | 8 ++-- 5 files changed, 110 insertions(+), 15 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 8e43492c4e..6c5b2f428b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,24 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-07-22 17:51 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * make_gnu.bat + ! Added SHLVL=0 to make commands to force native shell + even if sh shell is found in the PATH (f.e. when msys or + cygwin is present there, for mingwarm targets, cygwin is + even required.) + + * external/libhpdf/Makefile + + Made it compile with mingwarm. + + * include/hbextern.ch + ! Fixed typo in prev. + + * contrib/hbssl/pem.c + + Added two new functions. Under testing. + PEM_READ_BIO_RSAPRIVATEKEY() + PEM_READ_BIO_RSAPUBLICKEY() + 2009-07-22 15:58 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) - contrib/hbcrypt * Deleted after move. (SVN got confused if done if previous pass) diff --git a/harbour/contrib/hbssl/pem.c b/harbour/contrib/hbssl/pem.c index 8a97c16750..5bad01ce6f 100644 --- a/harbour/contrib/hbssl/pem.c +++ b/harbour/contrib/hbssl/pem.c @@ -60,7 +60,7 @@ /* ---------------------------------------------------------------------------- */ /* Callbacks */ -int hb_ssl_pem_password_cb( char * buf, int size, int rwflag, void * userdata ) +static int hb_ssl_pem_password_cb( char * buf, int size, int rwflag, void * userdata ) { int retsize = 0; @@ -89,6 +89,78 @@ HB_FUNC( ERR_LOAD_PEM_STRINGS ) ERR_load_PEM_strings(); } +HB_FUNC( PEM_READ_BIO_RSAPRIVATEKEY ) +{ + BIO * bio; + + if( HB_ISPOINTER( 1 ) ) + bio = hb_parptr( 1 ); + else if( HB_ISCHAR( 1 ) ) + bio = BIO_new_file( hb_parc( 1 ), "r" ); + else if( HB_ISNUM( 1 ) ) + bio = BIO_new_fd( hb_parni( 1 ), BIO_NOCLOSE ); + else + bio = NULL; + + if( bio ) + { + PHB_ITEM pPassBlock = NULL; + + if( HB_ISBLOCK( 2 ) ) + { + pPassBlock = hb_itemNew( hb_param( 2, HB_IT_BLOCK ) ); + hb_retptr( PEM_read_bio_RSAPrivateKey( bio, NULL, hb_ssl_pem_password_cb, pPassBlock ) ); + } + else if( HB_ISCHAR( 2 ) ) + /* NOTE: Dropping 'const' qualifier. [vszakats] */ + hb_retptr( PEM_read_bio_RSAPrivateKey( bio, NULL, NULL, ( void * ) hb_parc( 2 ) ) ); + + if( pPassBlock ) + hb_itemRelease( pPassBlock ); + + if( ! HB_ISPOINTER( 1 ) ) + BIO_free( bio ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( PEM_READ_BIO_RSAPUBLICKEY ) +{ + BIO * bio; + + if( HB_ISPOINTER( 1 ) ) + bio = hb_parptr( 1 ); + else if( HB_ISCHAR( 1 ) ) + bio = BIO_new_file( hb_parc( 1 ), "r" ); + else if( HB_ISNUM( 1 ) ) + bio = BIO_new_fd( hb_parni( 1 ), BIO_NOCLOSE ); + else + bio = NULL; + + if( bio ) + { + PHB_ITEM pPassBlock = NULL; + + if( HB_ISBLOCK( 2 ) ) + { + pPassBlock = hb_itemNew( hb_param( 2, HB_IT_BLOCK ) ); + hb_retptr( PEM_read_bio_RSAPrivateKey( bio, NULL, hb_ssl_pem_password_cb, pPassBlock ) ); + } + else if( HB_ISCHAR( 2 ) ) + /* NOTE: Dropping 'const' qualifier. [vszakats] */ + hb_retptr( PEM_read_bio_RSAPrivateKey( bio, NULL, NULL, ( void * ) hb_parc( 2 ) ) ); + + if( pPassBlock ) + hb_itemRelease( pPassBlock ); + + if( ! HB_ISPOINTER( 1 ) ) + BIO_free( bio ); + } + else + hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + #if 0 EVP_PKEY * PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u); diff --git a/harbour/external/libhpdf/Makefile b/harbour/external/libhpdf/Makefile index bde3d03b4e..f0cbad4a16 100644 --- a/harbour/external/libhpdf/Makefile +++ b/harbour/external/libhpdf/Makefile @@ -21,6 +21,11 @@ endif ifeq ($(HB_ARCHITECTURE),wce) HB_WITH_LIBHPDF=no endif +ifeq ($(HB_COMPILER),mingwarm) +HB_WITH_LIBHPDF=yes +HB_USER_CFLAGS += -U__COREDLL__ +endif + endif ifeq ($(HB_WITH_LIBHPDF),yes) diff --git a/harbour/include/hbextern.ch b/harbour/include/hbextern.ch index 44ca664442..e710b31256 100644 --- a/harbour/include/hbextern.ch +++ b/harbour/include/hbextern.ch @@ -968,16 +968,16 @@ EXTERNAL HB_CRC32 EXTERNAL HB_CRCCT EXTERNAL HB_MD5 EXTERNAL HB_MD5FILE -EXTERNAL HB_SHA1() -EXTERNAL HB_HMAC_SHA1() -EXTERNAL HB_SHA224() -EXTERNAL HB_SHA256() -EXTERNAL HB_SHA384() -EXTERNAL HB_SHA512() -EXTERNAL HB_HMAC_SHA224() -EXTERNAL HB_HMAC_SHA256() -EXTERNAL HB_HMAC_SHA384() -EXTERNAL HB_HMAC_SHA512() +EXTERNAL HB_SHA1 +EXTERNAL HB_HMAC_SHA1 +EXTERNAL HB_SHA224 +EXTERNAL HB_SHA256 +EXTERNAL HB_SHA384 +EXTERNAL HB_SHA512 +EXTERNAL HB_HMAC_SHA224 +EXTERNAL HB_HMAC_SHA256 +EXTERNAL HB_HMAC_SHA384 +EXTERNAL HB_HMAC_SHA512 EXTERNAL HB_BASE64DECODE EXTERNAL HB_BASE64ENCODE diff --git a/harbour/make_gnu.bat b/harbour/make_gnu.bat index e2cdfa57a0..78e90b1f3d 100644 --- a/harbour/make_gnu.bat +++ b/harbour/make_gnu.bat @@ -183,7 +183,7 @@ if "%HB_COMPILER%" == "" set HB_COMPILER=djgpp set HB_CONTRIB_ADDONS= set HB_EXTERNALLIBS=no set HB_EXTERNAL_ADDONS= - %_HB_MAKE% clean install %HB_USER_MAKEFLAGS% %_HB_BUILD_LOG% + %_HB_MAKE% SHLVL=0 clean install %HB_USER_MAKEFLAGS% %_HB_BUILD_LOG% if errorlevel 1 echo Harbour GNU Make returned: %ERRORLEVEL% if errorlevel 1 goto MAKE_DONE set HB_DYNLIB=no @@ -195,14 +195,14 @@ if "%HB_COMPILER%" == "" set HB_COMPILER=djgpp set _HB_CONTRIB_ADDONS= set _HB_EXTERNALLIBS= set _HB_EXTERNAL_ADDONS= - %_HB_MAKE% clean install %HB_USER_MAKEFLAGS% %_HB_BUILD_LOG% + %_HB_MAKE% SHLVL=0 clean install %HB_USER_MAKEFLAGS% %_HB_BUILD_LOG% if errorlevel 1 echo Harbour GNU Make returned: %ERRORLEVEL% goto MAKE_DONE :DO_GCC set HB_DYNLIB=no - %_HB_MAKE% clean install %HB_USER_MAKEFLAGS% %_HB_BUILD_LOG% + %_HB_MAKE% SHLVL=0 clean install %HB_USER_MAKEFLAGS% %_HB_BUILD_LOG% if errorlevel 1 echo Harbour GNU Make returned: %ERRORLEVEL% goto MAKE_DONE @@ -217,7 +217,7 @@ if "%HB_COMPILER%" == "" set HB_COMPILER=djgpp if "%HB_COMPILER%" == "cygwin" goto SKIP_WINDLL_CYG - %_HB_MAKE% %HB_USER_MAKEFLAGS% %1 %2 %3 %4 %5 %6 %7 %8 %9 %_HB_BUILD_LOG% + %_HB_MAKE% SHLVL=0 %HB_USER_MAKEFLAGS% %1 %2 %3 %4 %5 %6 %7 %8 %9 %_HB_BUILD_LOG% if errorlevel 1 echo Harbour GNU Make returned: %ERRORLEVEL% goto MAKE_DONE