From 81effeca0ca55d2d112d189ca218781e006a6373 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 11 Dec 2009 18:59:21 +0000 Subject: [PATCH] 2009-12-11 19:56 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/wce_smsc.c + Eliminated hb_parclen() usage. * contrib/hbwin/win_prn3.c ! Fixed typos. --- harbour/ChangeLog | 11 ++++- harbour/contrib/hbwin/wce_smsc.c | 72 +++++++++++++++++--------------- harbour/contrib/hbwin/win_prn3.c | 4 +- 3 files changed, 50 insertions(+), 37 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 7ef75ebc99..54d09e8af3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,13 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-11 19:56 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbwin/wce_smsc.c + + Eliminated hb_parclen() usage. + + * contrib/hbwin/win_prn3.c + ! Fixed typos. + 2009-12-11 19:51 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbwin/wapi_winbase.c ! fixed casting @@ -65,8 +72,8 @@ came out after cleaning header dir usage. * contrib/hbide/hbide.hbp - + Added MSVC link switched sent by Andi to make QT 4.6.0 - libs to default Harbour build. + + Added MSVC link switches sent by Andi to make QT 4.6.0 + libs work with default Harbour build. 2009-12-11 18:17 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * include/hbwinuni.h diff --git a/harbour/contrib/hbwin/wce_smsc.c b/harbour/contrib/hbwin/wce_smsc.c index f644064dbe..1a40b45425 100644 --- a/harbour/contrib/hbwin/wce_smsc.c +++ b/harbour/contrib/hbwin/wce_smsc.c @@ -64,50 +64,56 @@ HB_FUNC( WCE_SMSSENDMESSAGE ) /* cMessage, cNumber */ SMS_HANDLE smshHandle = 0; HRESULT hr = SmsOpen( SMS_MSGTYPE_TEXT, SMS_MODE_SEND, &smshHandle, NULL ); /* try to open an SMS Handle */ - if( hr == ERROR_SUCCESS && hb_parclen( 2 ) <= SMS_MAX_ADDRESS_LENGTH ) - { - SMS_ADDRESS smsaDestination; - TEXT_PROVIDER_SPECIFIC_DATA tpsd; - SMS_MESSAGE_ID smsmidMessageID = 0; + /* Set default return value */ + hb_retnl( -1 ); + if( hr == ERROR_SUCCESS ) + { void * hMessage; void * hPhoneNumber; + HB_SIZE nPhoneNumberLen; + LPCTSTR sztMessage = HB_PARSTRDEF( 1, &hMessage , NULL ); - LPCTSTR sztPhoneNumber = HB_PARSTRDEF( 2, &hPhoneNumber, NULL ); + LPCTSTR sztPhoneNumber = HB_PARSTRDEF( 2, &hPhoneNumber, &nPhoneNumberLen ); - /* Create the destination address */ - memset( &smsaDestination, 0, sizeof( smsaDestination ) ); - smsaDestination.smsatAddressType = ( *sztPhoneNumber == _T( '+' ) ) ? SMSAT_INTERNATIONAL : SMSAT_NATIONAL; - /* TOFIX: lstrcpy() unsafe and may cause buffer overrun. - Worked around using hb_parclen( 2 ) check against SMS_MAX_ADDRESS_LENGTH. - [vszakats]. */ - lstrcpy( smsaDestination.ptsAddress, sztPhoneNumber ); + if( nPhoneNumberLen <= SMS_MAX_ADDRESS_LENGTH ) + { + SMS_ADDRESS smsaDestination; + TEXT_PROVIDER_SPECIFIC_DATA tpsd; + SMS_MESSAGE_ID smsmidMessageID = 0; - /* Set up provider specific data */ - tpsd.dwMessageOptions = PS_MESSAGE_OPTION_NONE; - tpsd.psMessageClass = PS_MESSAGE_CLASS0; - tpsd.psReplaceOption = PSRO_NONE; - - /* Send the message, indicating success or failure */ - hb_retnl( SmsSendMessage( smshHandle, - NULL, - &smsaDestination, - NULL, - ( PBYTE ) sztMessage, - _tcslen( sztMessage ) * sizeof( wchar_t ), - ( PBYTE ) &tpsd, 12, - SMSDE_OPTIMAL, - SMS_OPTION_DELIVERY_NONE, - &smsmidMessageID ) ); - - SmsClose( smshHandle ); + /* Create the destination address */ + memset( &smsaDestination, 0, sizeof( smsaDestination ) ); + smsaDestination.smsatAddressType = ( *sztPhoneNumber == _T( '+' ) ) ? SMSAT_INTERNATIONAL : SMSAT_NATIONAL; + /* TOFIX: lstrcpy() unsafe and may cause buffer overrun. + Worked around using length check against SMS_MAX_ADDRESS_LENGTH. + [vszakats]. */ + lstrcpy( smsaDestination.ptsAddress, sztPhoneNumber ); + + /* Set up provider specific data */ + tpsd.dwMessageOptions = PS_MESSAGE_OPTION_NONE; + tpsd.psMessageClass = PS_MESSAGE_CLASS0; + tpsd.psReplaceOption = PSRO_NONE; + + /* Send the message, indicating success or failure */ + hb_retnl( SmsSendMessage( smshHandle, + NULL, + &smsaDestination, + NULL, + ( PBYTE ) sztMessage, + _tcslen( sztMessage ) * sizeof( wchar_t ), + ( PBYTE ) &tpsd, 12, + SMSDE_OPTIMAL, + SMS_OPTION_DELIVERY_NONE, + &smsmidMessageID ) ); + } hb_strfree( hMessage ); hb_strfree( hPhoneNumber ); + + SmsClose( smshHandle ); } - else - hb_retnl( -1 ); } #endif diff --git a/harbour/contrib/hbwin/win_prn3.c b/harbour/contrib/hbwin/win_prn3.c index d024183705..0c4a5d1347 100644 --- a/harbour/contrib/hbwin/win_prn3.c +++ b/harbour/contrib/hbwin/win_prn3.c @@ -252,9 +252,9 @@ HB_FUNC( WIN_PRINTERSETDEFAULT ) { void * hPrinterName; HB_SIZE nLen; - TCHAR pszPrinterName = HB_PARSTR( 1, &hPrinterName, &ulLen ); + LPCTSTR pszPrinterName = HB_PARSTR( 1, &hPrinterName, &nLen ); - hb_retl( ulLen > 0 ? hb_SetDefaultPrinter( pszPrinterName ) : HB_FALSE ); + hb_retl( nLen > 0 ? hb_SetDefaultPrinter( pszPrinterName ) : HB_FALSE ); hb_strfree( hPrinterName ); }