From 1d0c512822c83d80db5b210a9f7dcc64dea092e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Wed, 29 Jan 2025 13:50:06 +0100 Subject: [PATCH] 2025-01-29 13:50 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbssl/bio.c ! respect OPENSSL_NO_SOCK macro * contrib/hbssl/bio.c * contrib/hbssl/err.c * contrib/hbssl/evp.c * contrib/hbssl/pem.c * disabled deprecated functions which do nothinng in OpenSSL 3.0 * src/rtl/filesys.c * src/rtl/hbcom.c * src/rtl/hbproces.c * src/rtl/hbsocket.c * src/rtl/net.c * src/rtl/netusr.c * src/vm/dynlibhb.c * updated for OpenWatcom 2.0 builds --- ChangeLog.txt | 19 ++++++++++++++ contrib/hbssl/bio.c | 6 +++++ contrib/hbssl/err.c | 27 +++++++++++++++----- contrib/hbssl/evp.c | 2 ++ contrib/hbssl/pem.c | 2 ++ contrib/hbzebra/datamtrx.c | 2 ++ contrib/sddoci/core.c | 6 +++++ src/rtl/filesys.c | 13 ++++++---- src/rtl/hbcom.c | 7 +++-- src/rtl/hbproces.c | 3 +-- src/rtl/hbsocket.c | 11 ++++++-- src/rtl/net.c | 52 ++++++++++++++++---------------------- src/rtl/netusr.c | 5 ++-- src/vm/dynlibhb.c | 2 +- 14 files changed, 106 insertions(+), 51 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 05ae8ccb8a..4f4bf25fb4 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,25 @@ Entries may not always be in chronological/commit order. See license at the end of file. */ +2025-01-29 13:50 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/hbssl/bio.c + ! respect OPENSSL_NO_SOCK macro + + * contrib/hbssl/bio.c + * contrib/hbssl/err.c + * contrib/hbssl/evp.c + * contrib/hbssl/pem.c + * disabled deprecated functions which do nothinng in OpenSSL 3.0 + + * src/rtl/filesys.c + * src/rtl/hbcom.c + * src/rtl/hbproces.c + * src/rtl/hbsocket.c + * src/rtl/net.c + * src/rtl/netusr.c + * src/vm/dynlibhb.c + * updated for OpenWatcom 2.0 builds + 2025-01-28 20:27 UTC+0100 Aleksander Czajczynski (hb fki.pl) * config/global.mk ! fixed OpenWatcom target platform autodetection to conform with diff --git a/contrib/hbssl/bio.c b/contrib/hbssl/bio.c index 94c4316bf8..a13a73b07d 100644 --- a/contrib/hbssl/bio.c +++ b/contrib/hbssl/bio.c @@ -149,9 +149,11 @@ static BIO_METHOD * hb_BIO_METHOD_par( int iParam ) case HB_BIO_METHOD_S_FILE: p = BIO_s_file(); break; #endif case HB_BIO_METHOD_S_MEM: p = BIO_s_mem(); break; +#ifndef OPENSSL_NO_SOCK case HB_BIO_METHOD_S_SOCKET: p = BIO_s_socket(); break; case HB_BIO_METHOD_S_CONNECT: p = BIO_s_connect(); break; case HB_BIO_METHOD_S_ACCEPT: p = BIO_s_accept(); break; +#endif case HB_BIO_METHOD_S_FD: p = BIO_s_fd(); break; #if 0 /* BIO_s_log() isn't exported via implibs on Windows at version 0.9.8k. [vszakats] */ #ifndef OPENSSL_SYS_OS2 @@ -185,9 +187,11 @@ static int hb_BIO_METHOD_ptr_to_id( const BIO_METHOD * p ) else if( p == BIO_s_file() ) n = HB_BIO_METHOD_S_FILE; #endif else if( p == BIO_s_mem() ) n = HB_BIO_METHOD_S_MEM; +#ifndef OPENSSL_NO_SOCK else if( p == BIO_s_socket() ) n = HB_BIO_METHOD_S_SOCKET; else if( p == BIO_s_connect() ) n = HB_BIO_METHOD_S_CONNECT; else if( p == BIO_s_accept() ) n = HB_BIO_METHOD_S_ACCEPT; +#endif else if( p == BIO_s_fd() ) n = HB_BIO_METHOD_S_FD; #if 0 /* BIO_s_log() isn't exported via implibs on Windows at version 0.9.8k. [vszakats] */ #ifndef OPENSSL_SYS_OS2 @@ -848,7 +852,9 @@ HB_FUNC( BIO_DO_CONNECT ) HB_FUNC( ERR_LOAD_BIO_STRINGS ) { +#if OPENSSL_VERSION_NUMBER < 0x30000000L ERR_load_BIO_strings(); +#endif } #if 0 diff --git a/contrib/hbssl/err.c b/contrib/hbssl/err.c index 3cf5a380ce..91d3b8ba61 100644 --- a/contrib/hbssl/err.c +++ b/contrib/hbssl/err.c @@ -113,7 +113,11 @@ HB_FUNC( ERR_GET_ERROR_LINE ) const char * file = NULL; int line = 0; +#if OPENSSL_VERSION_NUMBER < 0x30000000L hb_retnint( ERR_get_error_line( &file, &line ) ); +#else + hb_retni( 0 ); +#endif hb_storc( file, 1 ); hb_storni( line, 2 ); @@ -132,20 +136,17 @@ HB_FUNC( ERR_PEEK_ERROR_LINE ) HB_FUNC( ERR_PEEK_LAST_ERROR_LINE ) { -#if OPENSSL_VERSION_NUMBER >= 0x00907000L const char * file = NULL; int line = 0; +#if OPENSSL_VERSION_NUMBER >= 0x00907000L hb_retnint( ERR_peek_last_error_line( &file, &line ) ); +#else + hb_retni( -1 ); +#endif hb_storc( file, 1 ); hb_storni( line, 2 ); -#else - hb_retnint( -1 ); - - hb_storc( NULL, 1 ); - hb_storni( 0, 2 ); -#endif } HB_FUNC( ERR_GET_ERROR_LINE_DATA ) @@ -155,7 +156,11 @@ HB_FUNC( ERR_GET_ERROR_LINE_DATA ) const char * data = NULL; int flags = 0; +#if OPENSSL_VERSION_NUMBER < 0x30000000L hb_retnint( ERR_get_error_line_data( &file, &line, &data, &flags ) ); +#else + hb_retni( 0 ); +#endif hb_storc( file, 1 ); hb_storni( line, 2 ); @@ -170,7 +175,11 @@ HB_FUNC( ERR_PEEK_ERROR_LINE_DATA ) const char * data = NULL; int flags = 0; +#if OPENSSL_VERSION_NUMBER < 0x30000000L hb_retnint( ERR_peek_error_line_data( &file, &line, &data, &flags ) ); +#else + hb_retni( 0 ); +#endif hb_storc( file, 1 ); hb_storni( line, 2 ); @@ -186,7 +195,11 @@ HB_FUNC( ERR_PEEK_LAST_ERROR_LINE_DATA ) const char * data = NULL; int flags = 0; +#if OPENSSL_VERSION_NUMBER < 0x30000000L hb_retnint( ERR_peek_last_error_line_data( &file, &line, &data, &flags ) ); +#else + hb_retni( 0 ); +#endif hb_storc( file, 1 ); hb_storni( line, 2 ); diff --git a/contrib/hbssl/evp.c b/contrib/hbssl/evp.c index 5c43b924e5..d88c71c875 100644 --- a/contrib/hbssl/evp.c +++ b/contrib/hbssl/evp.c @@ -73,7 +73,9 @@ HB_FUNC( EVP_CLEANUP ) HB_FUNC( ERR_LOAD_EVP_STRINGS ) { +#if OPENSSL_VERSION_NUMBER < 0x30000000L ERR_load_EVP_strings(); +#endif } HB_FUNC( EVP_PKEY_FREE ) diff --git a/contrib/hbssl/pem.c b/contrib/hbssl/pem.c index a4ea34300c..b0d23d8731 100644 --- a/contrib/hbssl/pem.c +++ b/contrib/hbssl/pem.c @@ -91,7 +91,9 @@ static int hb_ssl_pem_password_cb( char * buf, int size, int rwflag, void * user HB_FUNC( ERR_LOAD_PEM_STRINGS ) { +#if OPENSSL_VERSION_NUMBER < 0x30000000L ERR_load_PEM_strings(); +#endif } typedef void * PEM_READ_BIO ( BIO * bp, void ** x, pem_password_cb * cb, void * u ); diff --git a/contrib/hbzebra/datamtrx.c b/contrib/hbzebra/datamtrx.c index c06a6cafce..7af6a5417d 100644 --- a/contrib/hbzebra/datamtrx.c +++ b/contrib/hbzebra/datamtrx.c @@ -329,6 +329,8 @@ static void _datamatrix_do_placement( PHB_BITBUFFER pBits, unsigned char * pCW, /* Calculate placement size without L-patterns and clock tracks */ iPRow = pSize->iRow - 2 * ( pSize->iRow / pSize->iRegionRow ); iPCol = pSize->iCol - 2 * ( pSize->iCol / pSize->iRegionCol ); + if( iPCol < 0 ) + iPCol = 0; pArr = ( int * ) hb_xgrab( sizeof( int ) * iPCol * iPRow ); hb_xmemset( pArr, 0, sizeof( int ) * iPCol * iPRow ); diff --git a/contrib/sddoci/core.c b/contrib/sddoci/core.c index 89d1a3f29f..dd8bf63979 100644 --- a/contrib/sddoci/core.c +++ b/contrib/sddoci/core.c @@ -80,6 +80,9 @@ #define D_HB_ITEMPUTSTR( itm, str ) hb_itemPutStrU16( itm, HB_CDP_ENDIAN_NATIVE, str ) #define D_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLenU16( itm, HB_CDP_ENDIAN_NATIVE, str, len ) #define D_HB_CHAR HB_WCHAR + #ifndef ostrlen + #define ostrlen wcslen + #endif #else #define D_HB_ARRAYGETSTR( arr, n, phstr, plen ) hb_arrayGetStr( arr, n, hb_setGetOSCP(), phstr, plen ) #define D_HB_ITEMCOPYSTR( itm, str, len ) hb_itemCopyStr( itm, hb_setGetOSCP(), str, len ) @@ -87,6 +90,9 @@ #define D_HB_ITEMPUTSTR( itm, str ) hb_itemPutStr( itm, hb_setGetOSCP(), str ) #define D_HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLen( itm, hb_setGetOSCP(), str, len ) #define D_HB_CHAR char + #ifndef ostrlen + #define ostrlen strlen + #endif #endif diff --git a/src/rtl/filesys.c b/src/rtl/filesys.c index 3e282663e1..633b7ad907 100644 --- a/src/rtl/filesys.c +++ b/src/rtl/filesys.c @@ -104,10 +104,11 @@ # include #endif -#if ( defined( __DMC__ ) || defined( __BORLANDC__ ) || \ +#if ( ( defined( HB_OS_WIN ) && ! defined( HB_OS_WIN_CE ) ) || \ + defined( HB_OS_DOS ) || defined( HB_OS_OS2 ) ) && \ + ( defined( __DMC__ ) || defined( __BORLANDC__ ) || \ defined( __IBMCPP__ ) || defined( _MSC_VER ) || \ - defined( __MINGW32__ ) || defined( __WATCOMC__ ) ) && \ - ! defined( HB_OS_UNIX ) && ! defined( HB_OS_WIN_CE ) + defined( __MINGW32__ ) || defined( __WATCOMC__ ) ) #include #include #include @@ -205,7 +206,8 @@ * functions on 32-bit machines. */ #define HB_USE_LARGEFILE64 - #elif defined( HB_OS_UNIX ) && defined( O_LARGEFILE ) && ! defined( __WATCOMC__ ) + #elif defined( HB_OS_UNIX ) && defined( O_LARGEFILE ) && \ + ! ( defined( __WATCOMC__ ) && __WATCOMC__ <= 1300 ) #define HB_USE_LARGEFILE64 #endif #endif @@ -3113,7 +3115,8 @@ void hb_fsCommit( HB_FHANDLE hFileHandle ) * As workaround we are using this trick to check non zero version * number but on some systems it may disable using fdatasync() [druzus] */ -# if defined( _POSIX_SYNCHRONIZED_IO ) && _POSIX_SYNCHRONIZED_IO - 0 > 0 +# if ( defined( _POSIX_SYNCHRONIZED_IO ) && _POSIX_SYNCHRONIZED_IO - 0 > 0 ) || \ + ( defined( __WATCOMC__ ) && __WATCOMC__ >= 1300 ) /* faster - flushes data buffers only, without updating directory info */ HB_FAILURE_RETRY( iResult, fdatasync( hFileHandle ) ); diff --git a/src/rtl/hbcom.c b/src/rtl/hbcom.c index 95ddab3b01..e6d25654ef 100644 --- a/src/rtl/hbcom.c +++ b/src/rtl/hbcom.c @@ -110,7 +110,7 @@ # define INCL_DOSDEVICES # define INCL_DOSDEVIOCTL # include -#elif defined( HB_OS_LINUX ) && defined( __WATCOMC__ ) && ( __WATCOMC__ <= 1290 ) +#elif defined( HB_OS_LINUX ) && defined( __WATCOMC__ ) # include #endif @@ -1368,7 +1368,10 @@ int hb_comInit( int iPort, int iBaud, int iParity, int iSize, int iStop ) hb_comSetOsError( pCom, iResult == -1 ); if( iResult == 0 ) { -#if defined( cfmakeraw ) || defined( HB_OS_LINUX ) +#if defined( __WATCOMC__ ) && __WATCOMC__ <= 1300 + /* cfmakeraw is declared only in header files + but does not exist in CRTL in OpenWatcom 2.0 */ +#elif defined( cfmakeraw ) || defined( HB_OS_LINUX ) /* Raw input from device */ cfmakeraw( &tio ); #endif diff --git a/src/rtl/hbproces.c b/src/rtl/hbproces.c index 2100d70de1..4ae1e0c7fd 100644 --- a/src/rtl/hbproces.c +++ b/src/rtl/hbproces.c @@ -1730,8 +1730,7 @@ int hb_fsProcessRun( const char * pszFileName, } /* temporary hack for still missing sysconf() and chroot() in Watcom 1.9 */ -#if defined( HB_OS_LINUX ) && defined( __WATCOMC__ ) && \ - __WATCOMC__ <= 1290 +#if defined( HB_OS_LINUX ) && defined( __WATCOMC__ ) && __WATCOMC__ <= 1290 _WCRTLINK long sysconf( int __name ) { int iTODO; diff --git a/src/rtl/hbsocket.c b/src/rtl/hbsocket.c index f991effda2..6ec1a0e910 100644 --- a/src/rtl/hbsocket.c +++ b/src/rtl/hbsocket.c @@ -120,7 +120,12 @@ #if defined( HB_OS_UNIX ) # define HB_HAS_UNIX -# if ! defined( __WATCOMC__ ) +# if defined( __WATCOMC__ ) +# if __WATCOMC__ >= 1300 +# define HB_HAS_INET_ATON +# define HB_HAS_GETHOSTBYADDR +# endif +# else # define HB_HAS_INET_ATON # define HB_HAS_INET_PTON # define HB_HAS_INET_NTOP @@ -2463,7 +2468,9 @@ int hb_socketShutdown( HB_SOCKET sd, int iMode ) iMode = SO_SND_SHUTDOWN; else if( iMode == HB_SOCKET_SHUT_RDWR ) iMode = SO_RCV_SHUTDOWN | SO_SND_SHUTDOWN; -#elif defined( __WATCOMC__ ) +#elif defined( __WATCOMC__ ) && ( __WATCOMC__ <= 1290 ) + /* In WATCOM < 2.0 SHUT_* values are undefined but + Harbour's HB_SOCKET_SHUT_* are equal expected values */ if( iMode == HB_SOCKET_SHUT_RD || iMode == HB_SOCKET_SHUT_WR || iMode == HB_SOCKET_SHUT_RDWR ) diff --git a/src/rtl/net.c b/src/rtl/net.c index 1bc943922e..886a6525e6 100644 --- a/src/rtl/net.c +++ b/src/rtl/net.c @@ -60,6 +60,7 @@ #include "hb_io.h" #if defined( __DJGPP__ ) || defined( __RSX32__ ) || defined( __GNUC__ ) #include + #define HB_HAS_GETHOSTNAME #endif #elif defined( HB_OS_OS2 ) && defined( __GNUC__ ) @@ -73,19 +74,19 @@ #include #define gethostname __gethostname #endif + #define HB_HAS_GETHOSTNAME -#elif defined( HB_OS_UNIX ) && ! defined( __WATCOMC__ ) +#elif defined( HB_OS_UNIX ) && ! ( defined( __WATCOMC__ ) && __WATCOMC__ <= 1290 ) #if defined( HB_OS_VXWORKS ) #include #endif #include + #define HB_HAS_GETHOSTNAME #endif -#if ! defined( MAXGETHOSTNAME ) && ( defined( HB_OS_UNIX ) || \ - ( ( defined( HB_OS_OS2 ) || defined( HB_OS_DOS ) ) && \ - defined( __GNUC__ ) ) ) +#if ! defined( MAXGETHOSTNAME ) && defined( HB_HAS_GETHOSTNAME ) #define MAXGETHOSTNAME 256 /* should be enough for a host name */ #endif @@ -110,32 +111,7 @@ char * hb_netname( void ) if( lpValue[ 0 ] ) return HB_OSSTRDUP( lpValue ); -#elif defined( HB_OS_DOS ) - -# if defined( __DJGPP__ ) || defined( __RSX32__ ) || defined( __GNUC__ ) - char szValue[ MAXGETHOSTNAME + 1 ]; - szValue[ 0 ] = szValue[ MAXGETHOSTNAME ] = '\0'; - gethostname( szValue, MAXGETHOSTNAME ); - if( szValue[ 0 ] ) - return hb_osStrDecode( szValue ); -# else - union REGS regs; - struct SREGS sregs; - char szValue[ 16 ]; - szValue[ 0 ] = szValue[ 15 ] = '\0'; - - regs.HB_XREGS.ax = 0x5E00; - regs.HB_XREGS.dx = FP_OFF( szValue ); - sregs.ds = FP_SEG( szValue ); - - HB_DOS_INT86X( 0x21, ®s, ®s, &sregs ); - - if( regs.h.ch != 0 && szValue[ 0 ] ) - return hb_osStrDecode( szValue ); -# endif - -#elif ( defined( HB_OS_UNIX ) && ! defined( __WATCOMC__ ) ) || \ - ( defined( HB_OS_OS2 ) && defined( __GNUC__ ) ) +#elif defined( HB_HAS_GETHOSTNAME ) char szValue[ MAXGETHOSTNAME + 1 ]; szValue[ 0 ] = szValue[ MAXGETHOSTNAME ] = '\0'; @@ -143,6 +119,22 @@ char * hb_netname( void ) if( szValue[ 0 ] ) return hb_osStrDecode( szValue ); +#elif defined( HB_OS_DOS ) + + union REGS regs; + struct SREGS sregs; + char szValue[ 16 ]; + szValue[ 0 ] = szValue[ 15 ] = '\0'; + + regs.HB_XREGS.ax = 0x5E00; + regs.HB_XREGS.dx = FP_OFF( szValue ); + sregs.ds = FP_SEG( szValue ); + + HB_DOS_INT86X( 0x21, ®s, ®s, &sregs ); + + if( regs.h.ch != 0 && szValue[ 0 ] ) + return hb_osStrDecode( szValue ); + #endif return hb_getenv( "HOSTNAME" ); diff --git a/src/rtl/netusr.c b/src/rtl/netusr.c index c464a6604e..e21976f660 100644 --- a/src/rtl/netusr.c +++ b/src/rtl/netusr.c @@ -67,12 +67,14 @@ #if defined( __EMX__ ) && __GNUC__ * 1000 + __GNUC_MINOR__ < 3002 #include #endif + #define HB_HAS_PWD #elif defined( HB_OS_UNIX ) && ! defined( HB_OS_VXWORKS ) && ! defined( __WATCOMC__ ) #include #include #include + #define HB_HAS_PWD #endif @@ -92,8 +94,7 @@ char * hb_username( void ) if( lpValue[ 0 ] ) return HB_OSSTRDUP( lpValue ); -#elif ( defined( HB_OS_OS2 ) && defined( __GNUC__ ) ) || \ - ( defined( HB_OS_UNIX ) && ! defined( HB_OS_VXWORKS ) && ! defined( __WATCOMC__ ) ) +#elif defined( HB_HAS_PWD ) struct passwd * pwd = getpwuid( getuid() ); if( pwd && pwd->pw_name ) diff --git a/src/vm/dynlibhb.c b/src/vm/dynlibhb.c index 88ebbe52f4..55d155ef18 100644 --- a/src/vm/dynlibhb.c +++ b/src/vm/dynlibhb.c @@ -63,7 +63,7 @@ # endif #elif defined( HB_OS_OS2 ) # include -#elif defined( HB_OS_DOS ) && defined( __WATCOMC__ ) && !defined( HB_CAUSEWAY_DLL ) +#elif defined( HB_OS_DOS ) && defined( __WATCOMC__ ) && ! defined( HB_CAUSEWAY_DLL ) /* it's broken in recent OpenWatcom builds so enable it for tests only in harbour.dll [druzus] */ # if defined( HB_DYNLIB )