If you allow your users to define and execute a macro or use the runtime Harbour compiler (hbcplr.lib), sometimes you may want to avoid the use of certain Harbour functions. This code allows you to protect the symbols that you don't want to be used:
Fill the array { "QOut" } to include all the symbols that you want to protect. Next version will allow to restore them when you want.
protect.prg
Fill the array { "QOut" } to include all the symbols that you want to protect. Next version will allow to restore them when you want.
protect.prg
extern Dummy
function Main()
Protect( { "QOut" } )
? Test()
return nil
function Test()
return 2 + 2
#pragma BEGINDUMP
#define _HB_API_INTERNAL_
#include <hbvmpub.h>
extern HB_EXPORT HB_SIZE hb_parinfa( int iParamNum, HB_SIZE nArrayIndex );
extern HB_EXPORT const char * hb_parvc( int iParam, ... );
extern HB_EXPORT PHB_DYNS hb_dynsymFindName( const char * szName );
extern HB_EXPORT PHB_SYMB hb_dynsymSymbol( PHB_DYNS pDynSym );
HB_FUNC( DUMMY )
{
hb_ret();
}
HB_FUNC( PROTECT )
{
int iLen = ( int ) hb_parinfa( 1, 0 );
int i;
for( i = 0; i < iLen; i++ )
{
const char * szSymbolName = hb_parvc( 1, i + 1 );
hb_dynsymSymbol( hb_dynsymFindName( szSymbolName ) )->value.pFunPtr =
hb_dynsymSymbol( hb_dynsymFindName( "DUMMY" ) )->value.pFunPtr;
}
}
#pragma ENDDUMP