diff --git a/ChangeLog.txt b/ChangeLog.txt index c0e20cdc69..4e4f7e8664 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,30 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2016-02-18 17:02 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * include/fileio.ch + + added HB_VF_IONAME to hb_vcConfigure() actions + + * contrib/hbbz2io/bz2io.c + * contrib/hbcomio/comio.c + * contrib/hbgzio/gzio.c + * contrib/hbmemio/memio.c + * contrib/hbnetio/netio.h + * contrib/hbnetio/netiocli.c + * contrib/hbpipeio/pipeio.c + * contrib/hbtcpio/tcpio.c + * src/rtl/filebuf.c + + implemented HB_VF_IONAME + + * contrib/hbnetio/netiosrv.c + ! added protection against possible buffer overflow + + * src/rdd/dbfcdx/dbfcdx1.c + * src/rdd/dbfnsx/dbfnsx1.c + * src/rdd/dbfntx/dbfntx1.c + * restored CL5.[23] compatible tag selection - I had to broke + it when I was adding SIX3 compatibility functions + 2016-02-16 22:30 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * include/hbapirdd.h * src/rdd/wacore.c diff --git a/contrib/hbbz2io/bz2io.c b/contrib/hbbz2io/bz2io.c index d35a76872a..093182f7eb 100644 --- a/contrib/hbbz2io/bz2io.c +++ b/contrib/hbbz2io/bz2io.c @@ -626,6 +626,20 @@ static HB_BOOL s_fileConfigure( PHB_FILE pFile, int iIndex, PHB_ITEM pValue ) hb_itemPutNInt( pValue, _PHB_FILE->pFuncs->Handle( _PHB_FILE ) ); return HB_TRUE; + case HB_VF_IONAME: + { + const char * pszNext = NULL; + + if( _PHB_FILE->pFuncs->Configure( _PHB_FILE, iIndex, pValue ) ) + { + pszNext = hb_itemGetCPtr( pValue ); + if( *pszNext == '\0' ) + pszNext = NULL; + } + hb_itemPutCPtr( pValue, hb_xstrcpy( NULL, "BZ:", pszNext, NULL ) ); + return HB_TRUE; + } + /* TODO? GET/SET BZIP2 compression blockSize100k? */ } diff --git a/contrib/hbcomio/comio.c b/contrib/hbcomio/comio.c index b9db71bb1c..499c72cca3 100644 --- a/contrib/hbcomio/comio.c +++ b/contrib/hbcomio/comio.c @@ -405,11 +405,12 @@ static HB_BOOL s_fileConfigure( PHB_FILE pFile, int iIndex, PHB_ITEM pValue ) return HB_TRUE; } case HB_VF_RDHANDLE: + case HB_VF_WRHANDLE: hb_itemPutNInt( pValue, ( HB_NHANDLE ) hb_comGetDeviceHandle( pFile->port ) ); return HB_TRUE; - case HB_VF_WRHANDLE: - hb_itemPutNInt( pValue, ( HB_NHANDLE ) hb_comGetDeviceHandle( pFile->port ) ); + case HB_VF_IONAME: + hb_itemPutC( pValue, "COM:" ); return HB_TRUE; } diff --git a/contrib/hbgzio/gzio.c b/contrib/hbgzio/gzio.c index bbaa541a60..ed282561ab 100644 --- a/contrib/hbgzio/gzio.c +++ b/contrib/hbgzio/gzio.c @@ -614,6 +614,20 @@ static HB_BOOL s_fileConfigure( PHB_FILE pFile, int iIndex, PHB_ITEM pValue ) hb_itemPutNInt( pValue, _PHB_FILE->pFuncs->Handle( _PHB_FILE ) ); return HB_TRUE; + case HB_VF_IONAME: + { + const char * pszNext = NULL; + + if( _PHB_FILE->pFuncs->Configure( _PHB_FILE, iIndex, pValue ) ) + { + pszNext = hb_itemGetCPtr( pValue ); + if( *pszNext == '\0' ) + pszNext = NULL; + } + hb_itemPutCPtr( pValue, hb_xstrcpy( NULL, "GZ:", pszNext, NULL ) ); + return HB_TRUE; + } + /* TODO? GET/SET compression level? */ } diff --git a/contrib/hbmemio/memio.c b/contrib/hbmemio/memio.c index 8d5be64aa5..e125934a57 100644 --- a/contrib/hbmemio/memio.c +++ b/contrib/hbmemio/memio.c @@ -774,7 +774,7 @@ HB_MEMFS_EXPORT int hb_memfsLockTest( HB_FHANDLE hFile, HB_FOFFSET ulStart, HB_F * *******************************************************/ -#define FILE_PREFIX "mem:" +#define FILE_PREFIX "MEM:" #define FILE_PREFIX_LEN strlen( FILE_PREFIX ) typedef struct _HB_FILE @@ -1090,8 +1090,13 @@ static void s_fileCommit( PHB_FILE pFile ) static HB_BOOL s_fileConfigure( PHB_FILE pFile, int iIndex, PHB_ITEM pValue ) { HB_SYMBOL_UNUSED( pFile ); - HB_SYMBOL_UNUSED( iIndex ); - HB_SYMBOL_UNUSED( pValue ); + + switch( iIndex ) + { + case HB_VF_IONAME: + hb_itemPutC( pValue, FILE_PREFIX ); + return HB_TRUE; + } return HB_FALSE; } diff --git a/contrib/hbnetio/netio.h b/contrib/hbnetio/netio.h index 3fd98a52c6..5480f1e71b 100644 --- a/contrib/hbnetio/netio.h +++ b/contrib/hbnetio/netio.h @@ -54,7 +54,7 @@ #include "hbnetio.ch" /* file name prefix used by this file IO implementation */ -#define NETIO_FILE_PREFIX "net:" +#define NETIO_FILE_PREFIX "NET:" #define NETIO_FILE_PREFIX_LEN strlen( NETIO_FILE_PREFIX ) /* default server address, port and timeout */ diff --git a/contrib/hbnetio/netiocli.c b/contrib/hbnetio/netiocli.c index f2e8ddd377..a9a5644e4e 100644 --- a/contrib/hbnetio/netiocli.c +++ b/contrib/hbnetio/netiocli.c @@ -2605,6 +2605,8 @@ static HB_BOOL s_fileConfigure( PHB_FILE pFile, int iIndex, PHB_ITEM pValue ) { hb_itemMove( pValue, pResult ); hb_itemRelease( pResult ); + if( iIndex == HB_VF_IONAME ) + hb_itemPutCPtr( pValue, hb_xstrcpy( NULL, NETIO_FILE_PREFIX, hb_itemGetCPtr( pValue ), NULL ) ); } } hb_xfree( buffer ); diff --git a/contrib/hbnetio/netiosrv.c b/contrib/hbnetio/netiosrv.c index 97c3c05908..8d74022c10 100644 --- a/contrib/hbnetio/netiosrv.c +++ b/contrib/hbnetio/netiosrv.c @@ -1098,6 +1098,7 @@ HB_FUNC( NETIO_SERVER ) errCode = NETIO_ERR_WRONG_FILE_PATH; else { + nFlags &= ~ ( HB_FATTR ) ( FXO_COPYNAME ); pFile = hb_fileExtOpen( szFile, szExt, nFlags, NULL, NULL ); if( ! pFile ) errCode = s_srvFsError(); diff --git a/contrib/hbpipeio/pipeio.c b/contrib/hbpipeio/pipeio.c index d743c19523..ded383038c 100644 --- a/contrib/hbpipeio/pipeio.c +++ b/contrib/hbpipeio/pipeio.c @@ -230,6 +230,10 @@ static HB_BOOL s_fileConfigure( PHB_FILE pFile, int iIndex, PHB_ITEM pValue ) case HB_VF_WRHANDLE: hb_itemPutNInt( pValue, ( HB_NHANDLE ) pFile->hPipeWR ); return HB_TRUE; + + case HB_VF_IONAME: + hb_itemPutC( pValue, FILE_PREFIX ); + return HB_TRUE; } return HB_FALSE; diff --git a/contrib/hbtcpio/tcpio.c b/contrib/hbtcpio/tcpio.c index aa6c522f8f..ac1dd8bf34 100644 --- a/contrib/hbtcpio/tcpio.c +++ b/contrib/hbtcpio/tcpio.c @@ -55,7 +55,7 @@ #include "hbsocket.h" -#define FILE_PREFIX "tcp:" +#define FILE_PREFIX "TCP:" #define FILE_PREFIX_LEN strlen( FILE_PREFIX ) typedef struct _HB_FILE @@ -304,6 +304,10 @@ static HB_BOOL s_fileConfigure( PHB_FILE pFile, int iIndex, PHB_ITEM pValue ) case HB_VF_WRHANDLE: hb_itemPutNInt( pValue, ( HB_NHANDLE ) hb_sockexGetHandle( pFile->sock ) ); return HB_TRUE; + + case HB_VF_IONAME: + hb_itemPutC( pValue, FILE_PREFIX ); + return HB_TRUE; } return HB_FALSE; diff --git a/include/fileio.ch b/include/fileio.ch index 22d2d671cc..9b3145036e 100644 --- a/include/fileio.ch +++ b/include/fileio.ch @@ -145,5 +145,6 @@ #define HB_VF_SHUTDOWN 4 #define HB_VF_RDHANDLE 5 #define HB_VF_WRHANDLE 6 +#define HB_VF_IONAME 7 #endif /* _FILEIO_CH */ diff --git a/src/rdd/dbfcdx/dbfcdx1.c b/src/rdd/dbfcdx/dbfcdx1.c index 1431dca375..6c69483c03 100644 --- a/src/rdd/dbfcdx/dbfcdx1.c +++ b/src/rdd/dbfcdx/dbfcdx1.c @@ -5179,11 +5179,10 @@ static LPCDXTAG hb_cdxFindTag( CDXAREAP pArea, PHB_ITEM pTagItem, if( ! szTag[ 0 ] ) iFind = hb_itemGetNI( pTagItem ); - fBag = hb_itemGetCLen( pBagItem ) > 0; + fBag = szTag[ 0 ] && hb_itemGetCLen( pBagItem ) > 0; if( fBag ) { - if( szTag[ 0 ] ) - pIndex = hb_cdxFindBag( pArea, hb_itemGetCPtr( pBagItem ) ); + pIndex = hb_cdxFindBag( pArea, hb_itemGetCPtr( pBagItem ) ); } else { diff --git a/src/rdd/dbfnsx/dbfnsx1.c b/src/rdd/dbfnsx/dbfnsx1.c index 54bcd546b2..a0f9a71640 100644 --- a/src/rdd/dbfnsx/dbfnsx1.c +++ b/src/rdd/dbfnsx/dbfnsx1.c @@ -3925,13 +3925,10 @@ static LPTAGINFO hb_nsxFindTag( NSXAREAP pArea, PHB_ITEM pTagItem, ( hb_itemType( pTagItem ) & ( HB_IT_STRING | HB_IT_NUMERIC ) ) == 0 ) return pArea->lpCurTag; - fBag = hb_itemGetCLen( pBagItem ) > 0; + fBag = HB_IS_STRING( pTagItem ) && hb_itemGetCLen( pBagItem ) > 0; if( fBag ) { - if( hb_itemType( pTagItem ) & HB_IT_STRING ) - pIndex = hb_nsxFindBag( pArea, hb_itemGetCPtr( pBagItem ) ); - else - pIndex = pArea->lpIndexes; + pIndex = hb_nsxFindBag( pArea, hb_itemGetCPtr( pBagItem ) ); } else { @@ -4030,7 +4027,7 @@ static int hb_nsxFindTagNum( NSXAREAP pArea, LPTAGINFO pTag ) } /* - * find the given tag number + * count number of tags */ static int hb_nsxTagCount( NSXAREAP pArea ) { diff --git a/src/rdd/dbfntx/dbfntx1.c b/src/rdd/dbfntx/dbfntx1.c index 01d447e046..ceed81f9d5 100644 --- a/src/rdd/dbfntx/dbfntx1.c +++ b/src/rdd/dbfntx/dbfntx1.c @@ -3671,13 +3671,10 @@ static LPTAGINFO hb_ntxFindTag( NTXAREAP pArea, PHB_ITEM pTagItem, ( hb_itemType( pTagItem ) & ( HB_IT_STRING | HB_IT_NUMERIC ) ) == 0 ) return pArea->lpCurTag; - fBag = hb_itemGetCLen( pBagItem ) > 0; + fBag = HB_IS_STRING( pTagItem ) && hb_itemGetCLen( pBagItem ) > 0; if( fBag ) { - if( hb_itemType( pTagItem ) & HB_IT_STRING ) - pIndex = hb_ntxFindBag( pArea, hb_itemGetCPtr( pBagItem ) ); - else - pIndex = pArea->lpIndexes; + pIndex = hb_ntxFindBag( pArea, hb_itemGetCPtr( pBagItem ) ); } else { @@ -3775,6 +3772,23 @@ static int hb_ntxFindTagNum( NTXAREAP pArea, LPTAGINFO pTag ) return pTag->uiNumber; } +/* + * count number of tags + */ +static int hb_ntxTagCount( NTXAREAP pArea ) +{ + LPNTXINDEX pIndex = pArea->lpIndexes; + int i = 0; + + while( pIndex ) + { + i += pIndex->iTags; + pIndex = pIndex->pNext; + } + + return i; +} + /* * count number of keys in given tag */ @@ -3808,6 +3822,7 @@ static HB_ULONG hb_ntxOrdKeyCount( LPTAGINFO pTag ) pTag->keyCount = ulKeyCount; hb_ntxTagUnLockRead( pTag ); } + return ulKeyCount; } @@ -6793,18 +6808,17 @@ static HB_ERRCODE hb_ntxOrderInfo( NTXAREAP pArea, HB_USHORT uiIndex, LPDBORDERI } case DBOI_ORDERCOUNT: { - int i = 0; - HB_BOOL fBag = hb_itemGetCLen( pInfo->atomBagName ) > 0; - LPNTXINDEX pIndex = fBag ? - hb_ntxFindBag( pArea, hb_itemGetCPtr( pInfo->atomBagName ) ) : - pArea->lpIndexes; - while( pIndex ) + int i; + + if( hb_itemGetCLen( pInfo->atomBagName ) > 0 ) { - i += pIndex->iTags; - if( fBag ) - break; - pIndex = pIndex->pNext; + LPNTXINDEX pIndex = hb_ntxFindBag( pArea, + hb_itemGetCPtr( pInfo->atomBagName ) ); + i = pIndex ? pIndex->iTags : 0; } + else + i = hb_ntxTagCount( pArea ); + pInfo->itmResult = hb_itemPutNI( pInfo->itmResult, i ); return HB_SUCCESS; } diff --git a/src/rtl/filebuf.c b/src/rtl/filebuf.c index 7dcf8fc819..ccf5d0ca13 100644 --- a/src/rtl/filebuf.c +++ b/src/rtl/filebuf.c @@ -850,8 +850,13 @@ static void s_fileCommit( PHB_FILE pFile ) static HB_BOOL s_fileConfigure( PHB_FILE pFile, int iIndex, PHB_ITEM pValue ) { HB_SYMBOL_UNUSED( pFile ); - HB_SYMBOL_UNUSED( iIndex ); - HB_SYMBOL_UNUSED( pValue ); + + switch( iIndex ) + { + case HB_VF_IONAME: + hb_itemPutC( pValue, "FILE:" ); + return HB_TRUE; + } return HB_FALSE; }