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 PHB_ITEM hbamf_cls_externalizable_instance( PHB_ITEM pClassFuncStr ) { PHB_DYNS pSymbol = hb_dynsymGet( hb_itemGetCPtr( pClassFuncStr ) ); if( pSymbol ) { PHB_ITEM pRetCopy = hb_itemNew( NULL ); PHB_ITEM pNewItem = hb_itemNew( NULL ); hb_itemMove( pRetCopy, hb_stackReturnItem() ); hb_vmPushDynSym( pSymbol ); hb_vmPushNil(); hb_vmDo( 0 ); hb_objSendMsg( hb_stackReturnItem(), "NEW", 0 ); hb_itemMove( pNewItem, hb_stackReturnItem() ); hb_itemMove( hb_stackReturnItem(), pRetCopy ); hb_itemRelease( pRetCopy ); if( pNewItem ) { if( ! HB_IS_OBJECT( pNewItem ) ) { hb_itemRelease( pNewItem ); pNewItem = NULL; } } return pNewItem; } return NULL; }
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; }
LRESULT CALLBACK ControlWindowProcedure( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { PHB_ITEM pBlock = ( PHB_ITEM ) GetProp( hwnd, TEXT( "BLOCKCALLBACK" ) ); long lRet; if( pBlock ) { if( hb_itemType( pBlock ) == HB_IT_POINTER ) { hb_vmPushSymbol( hb_dynsymSymbol( ( ( PHB_SYMB ) pBlock )->pDynSym ) ); hb_vmPushNil(); } else { hb_vmPushEvalSym(); hb_vmPush( pBlock ); } hb_vmPushNumInt( ( HB_PTRUINT ) hwnd ); hb_vmPushInteger( msg ); hb_vmPushNumInt( ( HB_PTRUINT ) wParam ); hb_vmPushNumInt( ( HB_PTRUINT ) lParam ); hb_vmDo( 4 ); lRet = ( long ) hb_parnint( -1 ); return lRet; } return DefWindowProc( hwnd, msg, wParam, lParam ); }
static void s_fileClose( PHB_FILE pFile ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_CLOSE ); hb_vmPush( pFile->pFileItm ); hb_vmDo( 1 ); }
static void s_fileCommit( PHB_FILE pFile ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_COMMIT ); hb_vmPush( pFile->pFileItm ); hb_vmDo( 1 ); }
static void s_fileFlush( PHB_FILE pFile, HB_BOOL fDirty ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_FLUSH ); hb_vmPush( pFile->pFileItm ); hb_vmPushLogical( fDirty ); hb_vmDo( 2 ); }
static HB_BOOL s_fileEof( PHB_FILE pFile ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_EOF ); hb_vmPush( pFile->pFileItm ); 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_FHANDLE s_fileHandle( PHB_FILE pFile ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_HANDLE ); hb_vmPush( pFile->pFileItm ); hb_vmDo( 1 ); return ( HB_FHANDLE ) hb_parns( -1 ); }
static HB_FOFFSET s_fileSize( PHB_FILE pFile ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_SIZE ); hb_vmPush( pFile->pFileItm ); hb_vmDo( 1 ); return ( HB_FOFFSET ) hb_parnint( -1 ); }
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_fileTruncAt( PHB_FILE pFile, HB_FOFFSET nOffset ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_TRUNCAT ); hb_vmPush( pFile->pFileItm ); hb_vmPushNumInt( ( HB_MAXINT ) nOffset ); 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() ); }
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_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_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 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_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 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 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_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 HB_FOFFSET s_fileSeek( PHB_FILE pFile, HB_FOFFSET nOffset, HB_USHORT uiFlags ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_SEEK ); hb_vmPush( pFile->pFileItm ); hb_vmPushNumInt( ( HB_MAXINT ) nOffset ); hb_vmPushInteger( uiFlags ); hb_vmDo( 3 ); return ( HB_FOFFSET ) hb_parnint( -1 ); }
static HB_BOOL s_fileConfigure( PHB_FILE pFile, int iIndex, PHB_ITEM pValue ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_CONFIGURE ); hb_vmPush( pFile->pFileItm ); hb_vmPushInteger( iIndex ); if( pValue != NULL ) hb_vmPush( pValue ); hb_vmDo( pValue != NULL ? 3 : 2 ); return hb_parl( -1 ); }
static int s_fileLockTest( PHB_FILE pFile, HB_FOFFSET nStart, HB_FOFFSET nLen, int iType ) { PHB_IOUSR pIO = ( PHB_IOUSR ) pFile->pFuncs; s_pushMethod( pIO, IOUSR_LOCKTEST ); hb_vmPush( pFile->pFileItm ); hb_vmPushNumInt( ( HB_MAXINT ) nStart ); hb_vmPushNumInt( ( HB_MAXINT ) nLen ); hb_vmPushInteger( iType ); hb_vmDo( 4 ); return hb_parni( -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 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 char * sz_callhrb_i( char * szName, int iParam1 ) { PHB_DYNS pSym_onEvent = hb_dynsymFindName( szName ); if( pSym_onEvent ) { hb_vmPushSymbol( hb_dynsymSymbol( pSym_onEvent ) ); hb_vmPushNil(); hb_vmPushInteger( iParam1 ); hb_vmDo( 1 ); return (char *) hb_parc(-1); } else return ""; }