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
This commit is contained in:
Przemysław Czerpak
2016-02-18 17:02:48 +01:00
parent 24633c2478
commit 078899e74c
15 changed files with 118 additions and 33 deletions

View File

@@ -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

View File

@@ -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? */
}

View File

@@ -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;
}

View File

@@ -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? */
}

View File

@@ -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;
}

View File

@@ -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 */

View File

@@ -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 );

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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
{

View File

@@ -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 )
{

View File

@@ -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;
}

View File

@@ -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;
}