From cfa824a3e6df179eaf955d161dea4847fb0453de Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 13 Nov 2012 07:33:59 +0000 Subject: [PATCH] 2012-11-13 08:33 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/contrib/hbct/disk.c * harbour/contrib/hbct/ctnet.c ! eliminated HB_TCHAR_*() macros --- harbour/ChangeLog | 5 ++ harbour/contrib/hbct/ctnet.c | 35 ++++++++----- harbour/contrib/hbct/disk.c | 96 +++++++++++++++--------------------- 3 files changed, 67 insertions(+), 69 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 34396bcdb5..1e9e0833fd 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,11 @@ The license applies to all entries newer than 2009-04-28. */ +2012-11-13 08:33 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * harbour/contrib/hbct/disk.c + * harbour/contrib/hbct/ctnet.c + ! eliminated HB_TCHAR_*() macros + 2012-11-13 05:38 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbgd/gdbar.prg * contrib/hbgd/gdbarcod.prg diff --git a/harbour/contrib/hbct/ctnet.c b/harbour/contrib/hbct/ctnet.c index d7da1bb5fc..59c0a88814 100644 --- a/harbour/contrib/hbct/ctnet.c +++ b/harbour/contrib/hbct/ctnet.c @@ -85,6 +85,7 @@ #include "hbapi.h" #include "hbapiitm.h" +#include "hbvm.h" #include "hbset.h" #include "hbapierr.h" #include "hbwinuni.h" @@ -97,15 +98,18 @@ #if defined( HB_OS_WIN ) && ! defined( HB_OS_WIN_CE ) static HB_BOOL hb_IsNetShared( const char * szLocalDevice ) { - TCHAR lpRemoteDevice[ 128 ]; - LPTSTR lpLocalDevice; + TCHAR lpRemoteDevice[ HB_PATH_MAX ]; + LPCTSTR lpLocalDevice; + LPTSTR lpFree; DWORD dwLen = HB_SIZEOFARRAY( lpRemoteDevice ); DWORD dwResult; - lpLocalDevice = HB_TCHAR_CONVTO( szLocalDevice ); - dwResult = WNetGetConnection( ( LPCTSTR ) lpLocalDevice, - ( LPTSTR ) lpRemoteDevice, &dwLen ); - HB_TCHAR_FREE( lpLocalDevice ); + lpLocalDevice = HB_FSNAMECONV( szLocalDevice, &lpFree ); + hb_vmUnlock(); + dwResult = WNetGetConnection( lpLocalDevice, lpRemoteDevice, &dwLen ); + hb_vmLock(); + if( lpFree ) + hb_xfree( lpFree ); return dwResult == NO_ERROR; } @@ -144,16 +148,21 @@ HB_FUNC( NETPRINTER ) HB_FUNC( NETDISK ) { #if defined( HB_OS_WIN ) && ! defined( HB_OS_WIN_CE ) - char cDrive[ 3 ]; + const char * pszDrive = hb_parc( 1 ); - cDrive[ 0 ] = hb_parcx( 1 )[ 0 ]; - cDrive[ 1 ] = ':'; - cDrive[ 2 ] = '\0'; + if( pszDrive ) + { + char szDrive[ 3 ]; - hb_retl( hb_IsNetShared( cDrive ) ); -#else - hb_retl( HB_FALSE ); + szDrive[ 0 ] = pszDrive[ 0 ]; + szDrive[ 1 ] = ':'; + szDrive[ 2 ] = '\0'; + + hb_retl( hb_IsNetShared( szDrive ) ); + } + else #endif + hb_retl( HB_FALSE ); } HB_FUNC( NETREDIR ) diff --git a/harbour/contrib/hbct/disk.c b/harbour/contrib/hbct/disk.c index 3ad67b765d..c212cc19f1 100644 --- a/harbour/contrib/hbct/disk.c +++ b/harbour/contrib/hbct/disk.c @@ -67,6 +67,7 @@ #include "hbapi.h" #include "hbapierr.h" #include "hbapifs.h" +#include "hbvm.h" #include "ctstrfil.h" #include "hbwinuni.h" @@ -113,8 +114,9 @@ HB_FUNC( DRIVETYPE ) #if defined( HB_OS_WIN ) && ! defined( HB_OS_WIN_CE ) HB_SIZE nSize = hb_parclen( 1 ) + 2; /* allow space for '\0' & ":\" */ char * pszDrive = ( char * ) hb_xgrab( nSize + 1 ); - LPTSTR lpDrive; - int iType; + LPCTSTR lpDrive; + LPTSTR lpFree; + UINT uiType; hb_strncpy( pszDrive, hb_parcx( 1 ), nSize ); @@ -124,31 +126,36 @@ HB_FUNC( DRIVETYPE ) if( strstr( pszDrive, "\\" ) == NULL ) hb_strncat( pszDrive, "\\", nSize ); - lpDrive = HB_TCHAR_CONVTO( pszDrive ); - switch( GetDriveType( lpDrive ) ) + lpDrive = HB_FSNAMECONV( pszDrive, &lpFree ); + hb_vmUnlock(); + uiType = GetDriveType( lpDrive ); + hb_vmLock(); + if( lpFree ) + hb_xfree( lpFree ); + hb_xfree( pszDrive ); + + switch( uiType ) { case DRIVE_RAMDISK: - iType = 0; /* RAM Drive - Clipper compatible */ + uiType = 0; /* RAM Drive - Clipper compatible */ break; case DRIVE_REMOVABLE: - iType = 2; /* Floppy Drive - Clipper compatible */ + uiType = 2; /* Floppy Drive - Clipper compatible */ break; case DRIVE_FIXED: - iType = 3; /* Hard Drive - Clipper compatible */ + uiType = 3; /* Hard Drive - Clipper compatible */ break; case DRIVE_CDROM: - iType = 4; /* CD-Rom Drive - xHarbour extension */ + uiType = 4; /* CD-Rom Drive - xHarbour extension */ break; case DRIVE_REMOTE: - iType = 5; /* Network Drive - xHarbour extension */ + uiType = 5; /* Network Drive - xHarbour extension */ break; default: - iType = 9; /* Unknown Drive - xHarbour extension */ + uiType = 9; /* Unknown Drive - xHarbour extension */ break; } - hb_retni( iType ); - hb_xfree( pszDrive ); - HB_TCHAR_FREE( lpDrive ); + hb_retni( uiType ); #else hb_retni( 9 ); #endif @@ -200,55 +207,32 @@ HB_FUNC( VOLUME ) #if defined( HB_OS_WIN ) && ! defined( HB_OS_WIN_CE ) if( ! ct_getsafety() ) { - PHB_FNAME fname; - const char * sDiskName; - char * sRoot = NULL; - char * sVolName = NULL; - char sRootBuf[ 4 ], sVolNameBuf[ 12 ]; - char * pszFree; - LPTSTR lpRoot; - LPTSTR lpVolName; + const char * pszRoot = NULL; + const char * pszVolName = NULL; + char szRootBuf[ 4 ], szVolNameBuf[ 12 ]; + LPCTSTR lpRoot, lpVolName; + LPTSTR lpRootFree = NULL, lpVolNameFree = NULL; if( hb_parclen( 1 ) > 0 ) { - sDiskName = hb_fsNameConv( hb_parc( 1 ), &pszFree ); + PHB_FNAME fname = hb_fsFNameSplit( hb_parc( 1 ) ); - if( ( fname = hb_fsFNameSplit( sDiskName ) ) != NULL ) - { - if( fname->szPath ) - { - hb_strncpy( sRootBuf, fname->szPath, sizeof( sRootBuf ) - 1 ); - sRoot = sRootBuf; - } - - if( fname->szName ) - { - hb_strncpy( sVolNameBuf, fname->szName, sizeof( sVolNameBuf ) - 1 ); - sVolName = sVolNameBuf; - } - - hb_xfree( fname ); - } - else - { - hb_strncpy( sVolNameBuf, sDiskName, sizeof( sVolNameBuf ) - 1 ); - sVolName = sVolNameBuf; - } - - if( pszFree ) - hb_xfree( pszFree ); + if( fname->szPath ) + pszRoot = hb_strncpy( szRootBuf, fname->szPath, sizeof( szRootBuf ) - 1 ); + if( fname->szName ) + pszVolName = hb_strncpy( szVolNameBuf, fname->szName, sizeof( szVolNameBuf ) - 1 ); + hb_xfree( fname ); } - lpRoot = sRoot ? HB_TCHAR_CONVTO( sRoot ) : NULL; - lpVolName = sVolName ? HB_TCHAR_CONVTO( sVolName ) : NULL; - - bReturn = SetVolumeLabel( lpRoot, lpVolName ); - - if( lpRoot ) - HB_TCHAR_FREE( lpRoot ); - - if( lpVolName ) - HB_TCHAR_FREE( lpVolName ); + lpRoot = pszRoot ? HB_FSNAMECONV( pszRoot, &lpRootFree ) : NULL; + lpVolName = pszVolName ? HB_FSNAMECONV( pszVolName, &lpVolNameFree ) : NULL; + hb_vmUnlock(); + bReturn = SetVolumeLabel( lpRoot, lpVolName ) != 0; + hb_vmLock(); + if( lpRootFree ) + hb_xfree( lpRootFree ); + if( lpVolNameFree ) + hb_xfree( lpVolNameFree ); } #endif hb_retl( bReturn );