static PHB_FILE s_fileOpen( PHB_FILE_FUNCS pFuncs, const char * pszName, const char * pszDefExt, HB_USHORT uiExFlags, const char * pPaths, PHB_ITEM pError ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; PHB_FILE pFile = NULL; PHB_ITEM pFileItm; s_pushMethod( pIO, IOUSR_OPEN ); hb_vmPushString( pszName, strlen( pszName ) ); if( pszDefExt ) hb_vmPushString( pszDefExt, strlen( pszDefExt ) ); else hb_vmPushNil(); hb_vmPushInteger( uiExFlags ); if( pPaths ) hb_vmPushString( pPaths, strlen( pPaths ) ); else hb_vmPushNil(); if( pError ) hb_vmPush( pError ); else hb_vmPushNil(); hb_vmDo( 5 ); pFileItm = hb_stackReturnItem(); if( ! HB_IS_NIL( pFileItm ) ) pFile = s_fileNew( pIO, hb_itemNew( pFileItm ) ); return pFile; }
static HB_BOOL s_fileCopy( PHB_FILE_FUNCS pFuncs, const char * pSrcFile, const char * pszDstFile ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; s_pushMethod( pIO, IOUSR_COPY ); hb_vmPushString( pSrcFile, strlen( pSrcFile ) ); hb_vmPushString( pszDstFile, strlen( pszDstFile ) ); hb_vmDo( 2 ); return hb_parl( -1 ); }
static HB_BOOL s_fileLinkSym( PHB_FILE_FUNCS pFuncs, const char * pszTarget, const char * pszNewName ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; s_pushMethod( pIO, IOUSR_LINKSYM ); hb_vmPushString( pszTarget, strlen( pszTarget ) ); hb_vmPushString( pszNewName, strlen( pszNewName ) ); hb_vmDo( 2 ); return hb_parl( -1 ); }
static HB_BOOL s_fileRename( PHB_FILE_FUNCS pFuncs, const char * pszName, const char * pszNewName ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; s_pushMethod( pIO, IOUSR_RENAME ); hb_vmPushString( pszName, strlen( pszName ) ); hb_vmPushString( pszNewName, strlen( pszNewName ) ); hb_vmDo( 2 ); return hb_parl( -1 ); }
static PHB_ITEM s_fileDirectory( PHB_FILE_FUNCS pFuncs, const char * pszDirSpec, const char * pszAttr ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; s_pushMethod( pIO, IOUSR_DIRECTORY ); hb_vmPushString( pszDirSpec, strlen( pszDirSpec ) ); hb_vmPushString( pszAttr, strlen( pszAttr ) ); hb_vmDo( 2 ); return hb_itemNew( hb_stackReturnItem() ); }
HB_BOOL hbamf_is_cls_externalizable( HB_USHORT uiClass ) { PHB_DYNS pSymbol = hb_dynsymGet( "__CLSMSGTYPE" ); HB_BOOL result = HB_FALSE; /* as far as i know, there is no exported Harbour C level api for this */ if( uiClass && pSymbol ) { PHB_ITEM pRetCopy = hb_itemNew( NULL ); hb_itemMove( pRetCopy, hb_stackReturnItem() ); hb_vmPushDynSym( pSymbol ); hb_vmPushNil(); hb_vmPushInteger( uiClass ); hb_vmPushString( "EXTERNALIZABLE", 14 ); hb_vmDo( 2 ); if( hb_itemGetNI( hb_stackReturnItem() ) == HB_OO_MSG_CLASSDATA ) result = HB_TRUE; hb_itemMove( hb_stackReturnItem(), pRetCopy ); hb_itemRelease( pRetCopy ); } return result; }
static HB_BOOL s_fileTimeGet( PHB_FILE_FUNCS pFuncs, const char * pszFileName, long * plJulian, long * plMillisec ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; HB_BOOL fResult; int iOffset; iOffset = ( int ) ( hb_stackTopOffset() - hb_stackBaseOffset() ); hb_vmPushNil(); hb_vmPushNil(); s_pushMethod( pIO, IOUSR_TIMEGET ); hb_vmPushString( pszFileName, strlen( pszFileName ) ); hb_xvmPushLocalByRef( ( HB_SHORT ) iOffset ); hb_xvmPushLocalByRef( ( HB_SHORT ) ( iOffset + 1 ) ); hb_vmDo( 3 ); fResult = hb_parl( -1 ); if( fResult ) { *plJulian = hb_itemGetNL( hb_stackItemFromBase( iOffset ) ); *plMillisec = hb_itemGetNL( hb_stackItemFromBase( iOffset + 1 ) ); } hb_stackPop(); hb_stackPop(); return fResult; }
static HB_SIZE s_fileReadAt( PHB_FILE pFile, void * buffer, HB_SIZE nSize, HB_FOFFSET nOffset ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; HB_SIZE nResult; int iOffset; iOffset = ( int ) ( hb_stackTopOffset() - hb_stackBaseOffset() ); memset( buffer, 0, nSize ); hb_vmPushString( ( const char * ) buffer, nSize ); s_pushMethod( pIO, IOUSR_READAT ); hb_vmPush( pFile->pFileItm ); hb_xvmPushLocalByRef( ( HB_SHORT ) iOffset ); hb_vmPushSize( nSize ); hb_vmPushNumInt( ( HB_MAXINT ) nOffset ); hb_vmDo( 4 ); nResult = hb_parns( -1 ); if( nResult > 0 ) { nSize = hb_itemGetCLen( hb_stackItemFromBase( iOffset ) ); if( nResult > nSize ) nResult = nSize; memcpy( buffer, hb_itemGetCPtr( hb_stackItemFromBase( iOffset ) ), nSize ); } hb_stackPop(); return nResult; }
static HB_BOOL s_fileDelete( PHB_FILE_FUNCS pFuncs, const char * pszFileName ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; s_pushMethod( pIO, IOUSR_DELETE ); hb_vmPushString( pszFileName, strlen( pszFileName ) ); hb_vmDo( 1 ); return hb_parl( -1 ); }
static HB_BOOL s_fileDirRemove( PHB_FILE_FUNCS pFuncs, const char * pszDirName ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; s_pushMethod( pIO, IOUSR_DIRREMOVE ); hb_vmPushString( pszDirName, strlen( pszDirName ) ); hb_vmDo( 1 ); return hb_parl( -1 ); }
static HB_BOOL s_fileAttrSet( PHB_FILE_FUNCS pFuncs, const char * pszFileName, HB_FATTR nAttr ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; s_pushMethod( pIO, IOUSR_ATTRSET ); hb_vmPushString( pszFileName, strlen( pszFileName ) ); hb_vmPushLong( nAttr ); hb_vmDo( 2 ); return hb_parl( -1 ); }
static double s_fileDirSpace( PHB_FILE_FUNCS pFuncs, const char * pszDirName, HB_USHORT uiType ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; s_pushMethod( pIO, IOUSR_DIRSPACE ); hb_vmPushString( pszDirName, strlen( pszDirName ) ); hb_vmPushInteger( uiType ); hb_vmDo( 2 ); return hb_parnd( -1 ); }
static HB_BOOL s_fileTimeSet( PHB_FILE_FUNCS pFuncs, const char * pszFileName, long lJulian, long lMillisec ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; s_pushMethod( pIO, IOUSR_TIMESET ); hb_vmPushString( pszFileName, strlen( pszFileName ) ); hb_vmPushLong( lJulian ); hb_vmPushLong( lMillisec ); hb_vmDo( 3 ); return hb_parl( -1 ); }
static char * s_fileLinkRead( PHB_FILE_FUNCS pFuncs, const char * pszFileName ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; const char * pszLink; s_pushMethod( pIO, IOUSR_LINKREAD ); hb_vmPushString( pszFileName, strlen( pszFileName ) ); hb_vmDo( 1 ); pszLink = hb_parc( -1 ); return pszLink != NULL ? hb_strdup( pszLink ) : NULL; }
static HB_BOOL s_fileExists( PHB_FILE_FUNCS pFuncs, const char * pszFileName, char * pRetPath ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; HB_SYMBOL_UNUSED( pRetPath ); s_pushMethod( pIO, IOUSR_EXISTS ); hb_vmPushString( pszFileName, strlen( pszFileName ) ); hb_vmDo( 1 ); return hb_parl( -1 ); }
static HB_SIZE s_fileWrite( PHB_FILE pFile, const void * data, HB_SIZE nSize, HB_MAXINT timeout ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_WRITE ); hb_vmPush( pFile->pFileItm ); hb_vmPushString( ( const char * ) data, nSize ); hb_vmPushSize( nSize ); hb_vmPushNumInt( timeout ); hb_vmDo( 4 ); return hb_parns( -1 ); }
static HB_SIZE s_fileWriteAt( PHB_FILE pFile, const void * buffer, HB_SIZE nSize, HB_FOFFSET nOffset ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_WRITEAT ); hb_vmPush( pFile->pFileItm ); hb_vmPushString( ( const char * ) buffer, nSize ); hb_vmPushSize( nSize ); hb_vmPushNumInt( ( HB_MAXINT ) nOffset ); hb_vmDo( 4 ); return hb_parns( -1 ); }
static char * sz_callhrb_sz( char * szName, char * szParam1 ) { PHB_DYNS pSym_onEvent = hb_dynsymFindName( szName ); if( pSym_onEvent ) { hb_vmPushSymbol( hb_dynsymSymbol( pSym_onEvent ) ); hb_vmPushNil(); hb_vmPushString( szParam1, strlen( szParam1 ) ); hb_vmDo( 1 ); return (char *) hb_parc(-1); } else return ""; }
static void hb_ssl_msg_callback( int write_p, int version, int content_type, const void * buf, size_t len, SSL * ssl, void * userdata ) { HB_SYMBOL_UNUSED( ssl ); if( userdata && hb_vmRequestReenter() ) { hb_vmPushEvalSym(); hb_vmPush( ( PHB_ITEM ) userdata ); hb_vmPushLogical( write_p ); hb_vmPushInteger( version ); hb_vmPushInteger( content_type ); hb_vmPushString( ( const char * ) buf, ( HB_SIZE ) len ); hb_vmSend( 4 ); hb_vmRequestRestore(); } }
static HB_BOOL s_fileAccept( PHB_FILE_FUNCS pFuncs, const char * pszFileName ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; HB_BOOL fResult = HB_FALSE; if( hb_strnicmp( pszFileName, pIO->prefix, pIO->prefix_len ) == 0 ) { if( s_hasMethod( pIO, IOUSR_ACCEPT ) ) { s_pushMethod( pIO, IOUSR_ACCEPT ); hb_vmPushString( pszFileName, strlen( pszFileName ) ); hb_vmDo( 1 ); fResult = hb_parl( -1 ); } else if( pIO->prefix_len > 0 ) fResult = HB_TRUE; } return fResult; }
static HB_BOOL s_fileAttrGet( PHB_FILE_FUNCS pFuncs, const char * pszFileName, HB_FATTR * pnAttr ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFuncs; HB_BOOL fResult; int iOffset; iOffset = ( int ) ( hb_stackTopOffset() - hb_stackBaseOffset() ); hb_vmPushNil(); s_pushMethod( pIO, IOUSR_ATTRGET ); hb_vmPushString( pszFileName, strlen( pszFileName ) ); hb_xvmPushLocalByRef( ( HB_SHORT ) iOffset ); hb_vmDo( 2 ); fResult = hb_parl( -1 ); if( fResult ) *pnAttr = ( HB_FATTR ) hb_itemGetNL( hb_stackItemFromBase( iOffset ) ); hb_stackPop(); return fResult; }
int hb_cmdargPushArgs( void ) { int iArgCount = 0, i; for( i = 1; i < s_argc; i++ ) { /* Filter out any parameters beginning with //, like //INFO */ if( ! hb_cmdargIsInternal( s_argv[ i ], NULL ) ) { #if defined( HB_OS_WIN ) if( s_lpArgV ) HB_ITEMPUTSTR( hb_stackAllocItem(), s_lpArgV[ i ] ); else #endif hb_vmPushString( s_argv[ i ], strlen( s_argv[ i ] ) ); iArgCount++; } } return iArgCount; }
HB_USHORT hbgi_hb_clsNew(const char *szClassName, int nDatas, PHB_ITEM pSuperArray) { if (!s_pDyns__CLSNEW) { hbgihb_init(NULL); } hb_vmPushDynSym(s_pDyns__CLSNEW); hb_vmPushNil(); hb_vmPushString(szClassName, strlen(szClassName)); hb_vmPushNumInt(nDatas); if (!pSuperArray) { hb_vmPushNil(); } else { hb_vmPush(pSuperArray); } hb_vmProc(3); return hb_itemGetNI(hb_stackReturnItem()); }
static void hbgi_hb_clsAddMsgNative(HB_USHORT uiClass, const char *szMessage, HB_USHORT uiType, HB_USHORT uiScope, PHB_ITEM pFuncOrOffset, PHB_ITEM pInit) { PHB_ITEM pInitCopy; HB_BOOL allocated = !pInit; pInitCopy = allocated ? hb_itemNew(NULL) : pInit; if (!s_pDyns__CLSADDMSG) { hbgihb_init(NULL); } hb_vmPushDynSym(s_pDyns__CLSADDMSG); hb_vmPushNil(); hb_vmPushNumInt(uiClass); hb_vmPushString(szMessage, strlen(szMessage)); hb_vmPush(pFuncOrOffset); hb_vmPushNumInt(uiType); hb_vmPush(pInitCopy); hb_vmPushNumInt(uiScope); hb_vmProc(6); if (allocated) { hb_itemRelease(pInitCopy); } }