From 62f2ca6ee63c160e719249ee24ea2a7ee0bf08f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Tue, 13 Oct 2015 13:16:06 +0200 Subject: [PATCH] 2015-10-13 13:16 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbnetio/netiocli.c * strip connection parameters (server name, port, password,...) from second parameter of hb_vfRename(), hb_vfLink() and hb_vfSymLink() functions redirected to HBNETIO if it's the same as in the first parameter. Now it's possible to use above functions with path containing connection parameters in second argument. Please only remember that both parameters have to point to the same server in above functions. If not then DOS error 2 is set. In case of hb_vfCopy() the parameters can point to different servers so it's possible to copy files between different HBNETIO servers or even different Harbour File IO redirectors. --- ChangeLog.txt | 14 ++++++++ contrib/hbnetio/netiocli.c | 67 +++++++++++++++++++++++++++++--------- 2 files changed, 66 insertions(+), 15 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index e235583816..49ef4945ab 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,20 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2015-10-13 13:16 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/hbnetio/netiocli.c + * strip connection parameters (server name, port, password,...) from + second parameter of hb_vfRename(), hb_vfLink() and hb_vfSymLink() + functions redirected to HBNETIO if it's the same as in the first + parameter. + Now it's possible to use above functions with path containing connection + parameters in second argument. Please only remember that both parameters + have to point to the same server in above functions. If not then DOS + error 2 is set. + In case of hb_vfCopy() the parameters can point to different servers + so it's possible to copy files between different HBNETIO servers or + even different Harbour File IO redirectors. + 2015-10-12 17:22 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/hbsocket.c * added support for hb_socketGetIFaces() in DOS wattcp/watt-32 builds diff --git a/contrib/hbnetio/netiocli.c b/contrib/hbnetio/netiocli.c index 77d6fdc2ae..1dc7d62bd7 100644 --- a/contrib/hbnetio/netiocli.c +++ b/contrib/hbnetio/netiocli.c @@ -808,7 +808,7 @@ static const char * s_fileDecode( const char * pszFileName, return pszFileName; } -static PHB_CONCLI s_fileConnCheck( PHB_CONCLI conn, const char ** pFileName ) +static PHB_CONCLI s_fileConnCheck( PHB_CONCLI conn, const char ** pFileName, HB_BOOL fDefault ) { if( conn ) { @@ -817,7 +817,14 @@ static PHB_CONCLI s_fileConnCheck( PHB_CONCLI conn, const char ** pFileName ) char * pszIpAddres; int iPort = 0; - s_fileGetConnParam( &pszServer, &iPort, NULL, NULL, NULL ); + if( ! fDefault ) + { + pszServer = conn->server; + iPort = conn->port; + } + else + s_fileGetConnParam( &pszServer, &iPort, NULL, NULL, NULL ); + *pFileName = s_fileDecode( *pFileName, server, &pszServer, &iPort, NULL, NULL, NULL, NULL, NULL ); @@ -1721,14 +1728,24 @@ static HB_BOOL s_fileRename( PHB_FILE_FUNCS pFuncs, const char * pszFileName, co PHB_CONCLI conn; pszFileName += NETIO_FILE_PREFIX_LEN; - if( s_fileAccept( pFuncs, pszNewName ) ) - pszNewName += NETIO_FILE_PREFIX_LEN; - conn = s_fileConnect( &pszFileName, NULL, 0, 0, HB_FALSE, NULL, 0, HB_ZLIB_COMPRESSION_DISABLE, 0 ); if( conn ) { - if( s_fileConLock( conn ) ) + fResult = HB_TRUE; + + if( s_fileAccept( pFuncs, pszNewName ) ) + { + pszNewName += NETIO_FILE_PREFIX_LEN; + fResult = s_fileConnCheck( conn, &pszNewName, HB_FALSE ) != NULL; + } + + if( ! fResult ) + { + conn->errcode = 2; + hb_fsSetError( conn->errcode ); + } + else if( s_fileConLock( conn ) ) { HB_BYTE msgbuf[ NETIO_MSGLEN ]; HB_U16 len1 = ( HB_U16 ) strlen( pszFileName ); @@ -1766,7 +1783,7 @@ static HB_BOOL s_fileCopy( PHB_FILE_FUNCS pFuncs, const char * pszSrcFile, const NULL, 0, HB_ZLIB_COMPRESSION_DISABLE, 0 ); if( conn ) { - if( s_fileConnCheck( conn, &pszDestin ) == NULL ) + if( s_fileConnCheck( conn, &pszDestin, HB_TRUE ) == NULL ) fResult = hb_fsCopy( pszSrcFile, pszDstFile ); else if( s_fileConLock( conn ) ) { @@ -1930,14 +1947,24 @@ static HB_BOOL s_fileLink( PHB_FILE_FUNCS pFuncs, const char * pszExisting, cons PHB_CONCLI conn; pszExisting += NETIO_FILE_PREFIX_LEN; - if( s_fileAccept( pFuncs, pszNewName ) ) - pszNewName += NETIO_FILE_PREFIX_LEN; - conn = s_fileConnect( &pszExisting, NULL, 0, 0, HB_FALSE, NULL, 0, HB_ZLIB_COMPRESSION_DISABLE, 0 ); if( conn ) { - if( s_fileConLock( conn ) ) + fResult = HB_TRUE; + + if( s_fileAccept( pFuncs, pszNewName ) ) + { + pszNewName += NETIO_FILE_PREFIX_LEN; + fResult = s_fileConnCheck( conn, &pszNewName, HB_FALSE ) != NULL; + } + + if( ! fResult ) + { + conn->errcode = 2; + hb_fsSetError( conn->errcode ); + } + else if( s_fileConLock( conn ) ) { HB_BYTE msgbuf[ NETIO_MSGLEN ]; HB_U16 len1 = ( HB_U16 ) strlen( pszExisting ); @@ -1967,14 +1994,24 @@ static HB_BOOL s_fileLinkSym( PHB_FILE_FUNCS pFuncs, const char * pszTarget, con PHB_CONCLI conn; pszTarget += NETIO_FILE_PREFIX_LEN; - if( s_fileAccept( pFuncs, pszNewName ) ) - pszNewName += NETIO_FILE_PREFIX_LEN; - conn = s_fileConnect( &pszTarget, NULL, 0, 0, HB_FALSE, NULL, 0, HB_ZLIB_COMPRESSION_DISABLE, 0 ); if( conn ) { - if( s_fileConLock( conn ) ) + fResult = HB_TRUE; + + if( s_fileAccept( pFuncs, pszNewName ) ) + { + pszNewName += NETIO_FILE_PREFIX_LEN; + fResult = s_fileConnCheck( conn, &pszNewName, HB_FALSE ) != NULL; + } + + if( ! fResult ) + { + conn->errcode = 2; + hb_fsSetError( conn->errcode ); + } + else if( s_fileConLock( conn ) ) { HB_BYTE msgbuf[ NETIO_MSGLEN ]; HB_U16 len1 = ( HB_U16 ) strlen( pszTarget );