2010-01-07 10:27 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbvmpub.h
* minor formatting
* harbour/contrib/hbnetio/netio.h
* harbour/contrib/hbnetio/netiosrv.c
+ added new PRG function:
NETIO_RPCFUNC( <pConnectionSocket> [, <sFuncSym> ] ) -> NIL
which allows to set user filter for RPC calls. <sFuncSym> is executed
on each RPC request instead of requested function and receives as
first parameter requested function symbol then function parameters.
A simple wrapper may look like:
static function rpc_filter( sFunc, ... )
? "DO", sFunc:name, "WITH", ...
return sFunc:exec( ... )
and can be activated by:
netio_rpcfunc( pConnectionSocket, @rpc_filter() )
When NETIO_RPCFUNC() is called without valid function symbol then
existing user RPC filter is cleared. Please remember that setting
user RPC filter does not automatically enable RPC support for
given connection socket. RPC support has to be enabled by NETIO_RPC()
function or by 4-th parameter of NETIO_LISTEN() socket.
This commit is contained in:
@@ -17,6 +17,29 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2010-01-07 10:27 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbvmpub.h
|
||||
* minor formatting
|
||||
|
||||
* harbour/contrib/hbnetio/netio.h
|
||||
* harbour/contrib/hbnetio/netiosrv.c
|
||||
+ added new PRG function:
|
||||
NETIO_RPCFUNC( <pConnectionSocket> [, <sFuncSym> ] ) -> NIL
|
||||
which allows to set user filter for RPC calls. <sFuncSym> is executed
|
||||
on each RPC request instead of requested function and receives as
|
||||
first parameter requested function symbol then function parameters.
|
||||
A simple wrapper may look like:
|
||||
static function rpc_filter( sFunc, ... )
|
||||
? "DO", sFunc:name, "WITH", ...
|
||||
return sFunc:exec( ... )
|
||||
and can be activated by:
|
||||
netio_rpcfunc( pConnectionSocket, @rpc_filter() )
|
||||
When NETIO_RPCFUNC() is called without valid function symbol then
|
||||
existing user RPC filter is cleared. Please remember that setting
|
||||
user RPC filter does not automatically enable RPC support for
|
||||
given connection socket. RPC support has to be enabled by NETIO_RPC()
|
||||
function or by 4-th parameter of NETIO_LISTEN() socket.
|
||||
|
||||
2010-01-06 18:57 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
|
||||
* contrib/hbide/ideactions.prg
|
||||
* contrib/hbide/ideprojmanager.prg
|
||||
|
||||
@@ -128,3 +128,4 @@
|
||||
#define NETIO_ERR_FILE_IO 0xff07
|
||||
#define NETIO_ERR_NOT_EXISTS 0xff08
|
||||
#define NETIO_ERR_UNSUPPORTED 0xff09
|
||||
#define NETIO_ERR_REFUSED 0xff10
|
||||
|
||||
@@ -84,6 +84,7 @@ typedef struct _HB_CONSRV
|
||||
int firstFree;
|
||||
BOOL stop;
|
||||
BOOL rpc;
|
||||
PHB_SYMB rpcFunc;
|
||||
int rootPathLen;
|
||||
char rootPath[ HB_PATH_MAX ];
|
||||
}
|
||||
@@ -416,6 +417,16 @@ HB_FUNC( NETIO_RPC )
|
||||
conn->rpc = hb_parl( 2 );
|
||||
}
|
||||
}
|
||||
hb_retl( fRPC );
|
||||
}
|
||||
|
||||
HB_FUNC( NETIO_RPCFUNC )
|
||||
{
|
||||
PHB_CONSRV conn = s_consrvParam( 1 );
|
||||
if( conn )
|
||||
{
|
||||
conn->rpcFunc = hb_itemGetSymbol( hb_param( 2, HB_IT_SYMBOL ) );
|
||||
}
|
||||
}
|
||||
|
||||
HB_FUNC( NETIO_SERVERSTOP )
|
||||
@@ -858,55 +869,73 @@ HB_FUNC( NETIO_SERVER )
|
||||
errCode = NETIO_ERR_NOT_EXISTS;
|
||||
else if( uiMsg != NETIO_PROCIS )
|
||||
{
|
||||
ULONG ulSize = size - size2;
|
||||
USHORT uiPCount = 0;
|
||||
|
||||
data += size2;
|
||||
|
||||
hb_vmPushDynSym( pDynSym );
|
||||
hb_vmPushNil();
|
||||
while( ulSize )
|
||||
if( hb_vmRequestReenter() )
|
||||
{
|
||||
PHB_ITEM pItem = hb_itemDeserialize( &data, &ulSize );
|
||||
if( !pItem )
|
||||
ULONG ulSize = size - size2;
|
||||
USHORT uiPCount = 0;
|
||||
|
||||
data += size2;
|
||||
|
||||
if( conn->rpcFunc )
|
||||
{
|
||||
ulSize = 1;
|
||||
break;
|
||||
hb_vmPushSymbol( conn->rpcFunc );
|
||||
hb_vmPushNil();
|
||||
hb_vmPushDynSym( pDynSym );
|
||||
++uiPCount;
|
||||
}
|
||||
++uiPCount;
|
||||
hb_vmPush( pItem );
|
||||
hb_itemRelease( pItem );
|
||||
}
|
||||
if( ulSize )
|
||||
{
|
||||
errCode = NETIO_ERR_WRONG_PARAM;
|
||||
uiPCount += 2;
|
||||
do
|
||||
hb_stackPop();
|
||||
while( --uiPCount );
|
||||
else
|
||||
{
|
||||
hb_vmPushDynSym( pDynSym );
|
||||
hb_vmPushNil();
|
||||
}
|
||||
while( ulSize )
|
||||
{
|
||||
PHB_ITEM pItem = hb_itemDeserialize( &data, &ulSize );
|
||||
if( !pItem )
|
||||
{
|
||||
ulSize = 1;
|
||||
break;
|
||||
}
|
||||
++uiPCount;
|
||||
hb_vmPush( pItem );
|
||||
hb_itemRelease( pItem );
|
||||
}
|
||||
if( ulSize )
|
||||
{
|
||||
errCode = NETIO_ERR_WRONG_PARAM;
|
||||
uiPCount += 2;
|
||||
do
|
||||
hb_stackPop();
|
||||
while( --uiPCount );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_vmProc( uiPCount );
|
||||
if( uiMsg == NETIO_FUNC )
|
||||
{
|
||||
ULONG itmSize;
|
||||
char * itmData = hb_itemSerialize( hb_stackReturnItem(), TRUE, &itmSize );
|
||||
if( itmSize <= sizeof( buffer ) - NETIO_MSGLEN )
|
||||
msg = buffer;
|
||||
else if( !ptr || itmSize > ( ULONG ) size - NETIO_MSGLEN )
|
||||
{
|
||||
if( ptr )
|
||||
hb_xfree( ptr );
|
||||
ptr = msg = ( BYTE * ) hb_xgrab( itmSize + NETIO_MSGLEN );
|
||||
}
|
||||
memcpy( msg + NETIO_MSGLEN, itmData, itmSize );
|
||||
hb_xfree( itmData );
|
||||
len = itmSize;
|
||||
}
|
||||
}
|
||||
hb_vmRequestRestore();
|
||||
}
|
||||
else
|
||||
hb_vmProc( uiPCount );
|
||||
errCode = NETIO_ERR_REFUSED;
|
||||
}
|
||||
}
|
||||
if( errCode == 0 && !fNoAnswer )
|
||||
{
|
||||
if( uiMsg == NETIO_FUNC )
|
||||
{
|
||||
ULONG itmSize;
|
||||
char * itmData = hb_itemSerialize( hb_stackReturnItem(), TRUE, &itmSize );
|
||||
if( itmSize <= sizeof( buffer ) - NETIO_MSGLEN )
|
||||
msg = buffer;
|
||||
else if( !ptr || itmSize > ( ULONG ) size - NETIO_MSGLEN )
|
||||
{
|
||||
if( ptr )
|
||||
hb_xfree( ptr );
|
||||
ptr = msg = ( BYTE * ) hb_xgrab( itmSize + NETIO_MSGLEN );
|
||||
}
|
||||
memcpy( msg + NETIO_MSGLEN, itmData, itmSize );
|
||||
hb_xfree( itmData );
|
||||
len = itmSize;
|
||||
}
|
||||
HB_PUT_LE_UINT32( &msg[ 0 ], uiMsg );
|
||||
HB_PUT_LE_UINT32( &msg[ 4 ], len );
|
||||
memset( msg + 8, '\0', NETIO_MSGLEN - 8 );
|
||||
|
||||
@@ -119,16 +119,16 @@ struct _HB_SYMB;
|
||||
( double ) (p)->item.asLong.value : \
|
||||
(p)->item.asDouble.value ) )
|
||||
|
||||
#define HB_VM_ISFUNC( pSym ) ( ( pSym )->value.pFunPtr )
|
||||
# define HB_VM_ISFUNC( pSym ) ( ( pSym )->value.pFunPtr )
|
||||
|
||||
#define HB_VM_FUNCUNREF( pSym ) \
|
||||
# define HB_VM_FUNCUNREF( pSym ) \
|
||||
do { \
|
||||
if( ( ( pSym )->scope.value & HB_FS_DEFERRED ) && \
|
||||
( pSym )->pDynSym ) \
|
||||
pSym = ( pSym )->pDynSym->pSymbol; \
|
||||
} while( 0 )
|
||||
|
||||
#define HB_VM_EXECUTE( pSym ) \
|
||||
# define HB_VM_EXECUTE( pSym ) \
|
||||
do { \
|
||||
/* Running pCode dynamic function from .hrb? */ \
|
||||
if( ( pSym )->scope.value & HB_FS_PCODEFUNC ) \
|
||||
@@ -142,16 +142,16 @@ struct _HB_SYMB;
|
||||
typedef struct _HB_DYNS
|
||||
{
|
||||
struct _HB_SYMB * pSymbol; /* pointer to its relative local symbol */
|
||||
#if !defined( HB_MT_VM )
|
||||
# if !defined( HB_MT_VM )
|
||||
void * pMemvar; /* memvar pointer ( publics & privates ) */
|
||||
USHORT uiArea; /* Workarea number */
|
||||
#endif /* !HB_MT_VM */
|
||||
# endif /* !HB_MT_VM */
|
||||
USHORT uiSymNum; /* dynamic symbol number */
|
||||
#if !defined( HB_NO_PROFILER )
|
||||
# if !defined( HB_NO_PROFILER )
|
||||
ULONG ulCalls; /* profiler support */
|
||||
ULONG ulTime; /* profiler support */
|
||||
ULONG ulRecurse; /* profiler support */
|
||||
#endif /* !HB_NO_PROFILER */
|
||||
# endif /* !HB_NO_PROFILER */
|
||||
} HB_DYNS, * PHB_DYNS, * HB_DYNS_PTR;
|
||||
|
||||
/* pCode dynamic function - HRB */
|
||||
|
||||
Reference in New Issue
Block a user