From 38f016f5e856cef27bc6aeba7158c36b60c1d33b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 20 Jan 2010 16:49:29 +0000 Subject: [PATCH] 2010-01-20 17:48 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/win_prn1.c * contrib/hbwin/win_prn2.c * Cleanups. --- harbour/ChangeLog | 5 +++++ harbour/contrib/hbwin/win_prn1.c | 4 ---- harbour/contrib/hbwin/win_prn2.c | 14 ++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a2e9dc3658..650c1b83ff 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,11 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-20 17:48 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbwin/win_prn1.c + * contrib/hbwin/win_prn2.c + * Cleanups. + 2010-01-20 16:57 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/wapi_wingdi.c ! Guarded for ! HB_OS_WIN_CE. diff --git a/harbour/contrib/hbwin/win_prn1.c b/harbour/contrib/hbwin/win_prn1.c index ebf8cd475c..6ff16305a8 100644 --- a/harbour/contrib/hbwin/win_prn1.c +++ b/harbour/contrib/hbwin/win_prn1.c @@ -76,10 +76,6 @@ #if ! defined( HB_OS_WIN_CE ) -#ifndef INVALID_FILE_SIZE - #define INVALID_FILE_SIZE ( DWORD ) 0xFFFFFFFF -#endif - HB_FUNC( WIN_CREATEDC ) { if( HB_ISCHAR( 1 ) ) diff --git a/harbour/contrib/hbwin/win_prn2.c b/harbour/contrib/hbwin/win_prn2.c index 5563d79d8b..c166b7a96d 100644 --- a/harbour/contrib/hbwin/win_prn2.c +++ b/harbour/contrib/hbwin/win_prn2.c @@ -62,8 +62,6 @@ #define _ENUMPRN_FLAGS_ ( PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS ) -#define MAXBUFFERSIZE 256 - static HB_BOOL hb_IsLegacyDevice( const char * pszPrinterName ) { static const char * s_pszPrnDev[] = { "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "com1", "com2", "com3", "com4", NULL }; @@ -146,7 +144,7 @@ static void hb_GetDefaultPrinter( PHB_ITEM pPrinterName ) if( fnGetDefaultPrinter ) { - TCHAR lpPrinterName[ MAXBUFFERSIZE ]; + TCHAR lpPrinterName[ 256 ]; DWORD dwSize = HB_SIZEOFARRAY( lpPrinterName ) - 1; bResult = ( *fnGetDefaultPrinter )( lpPrinterName, &dwSize ); @@ -160,7 +158,7 @@ static void hb_GetDefaultPrinter( PHB_ITEM pPrinterName ) if( ! bResult ) /* Win9x and Windows NT 4.0 or earlier & 2000+ if necessary for some reason i.e. dll could not load! */ { - TCHAR lpPrinterName[ MAXBUFFERSIZE ]; + TCHAR lpPrinterName[ 256 ]; DWORD dwSize = GetProfileString( TEXT( "windows" ), TEXT( "device" ), TEXT( "" ), lpPrinterName, ( DWORD ) HB_SIZEOFARRAY( lpPrinterName ) - 1 ); @@ -448,11 +446,9 @@ HB_FUNC( WIN_PRINTERLIST ) HB_BOOL bPrinterNamesOnly = HB_ISLOG( 1 ) ? ! hb_parl( 1 ) : HB_TRUE; HB_BOOL bLocalPrintersOnly = hb_parl( 2 ); DWORD dwNeeded = 0, dwReturned = 0, i; - PHB_ITEM pTempItem = hb_itemNew( NULL ); PHB_ITEM pPrinterArray = hb_itemArrayNew( 0 ); EnumPrinters( _ENUMPRN_FLAGS_, NULL, 5, ( LPBYTE ) NULL, 0, &dwNeeded, &dwReturned ); - if( dwNeeded ) { PRINTER_INFO_5 * pPrinterEnumBak; @@ -460,6 +456,8 @@ HB_FUNC( WIN_PRINTERLIST ) if( EnumPrinters( _ENUMPRN_FLAGS_, NULL, 5, ( LPBYTE ) pPrinterEnum, dwNeeded, &dwNeeded, &dwReturned ) ) { + PHB_ITEM pTempItem = hb_itemNew( NULL ); + for( i = 0; i < dwReturned; ++i, ++pPrinterEnum ) { if( ! bLocalPrintersOnly || pPrinterEnum->Attributes & PRINTER_ATTRIBUTE_LOCAL ) @@ -514,13 +512,13 @@ HB_FUNC( WIN_PRINTERLIST ) } } } + + hb_itemRelease( pTempItem ); } hb_xfree( pPrinterEnumBak ); } hb_itemReturnRelease( pPrinterArray ); - - hb_itemRelease( pTempItem ); } #endif