X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Tools%2FNetTest%2Fvfs_shim.c;h=d2d1d5fe5c45bb3cf3d0ff71816062edb25c1280;hb=3d67e21210fbcad7cdcbfa9c348019a191ce1798;hp=bc0c67c346d783a9d8e48362bfdbf0d145205ce7;hpb=c29ddaf5a4acb51469c9a4ff10bd0dde88872c46;p=tpg%2Facess2.git diff --git a/Tools/NetTest/vfs_shim.c b/Tools/NetTest/vfs_shim.c index bc0c67c3..d2d1d5fe 100644 --- a/Tools/NetTest/vfs_shim.c +++ b/Tools/NetTest/vfs_shim.c @@ -10,39 +10,52 @@ #include // === CODE === -int VFS_SelectNode(tVFS_Node *Node, int Type, tTime *Timeout, const char *Name) +int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode) { - - return 0; -} + const int maxfd = *Threads_GetMaxFD(NULL); + tVFS_Handle *handles = *Threads_GetHandlesPtr(); + if( !handles ) { + handles = calloc( maxfd, sizeof(tVFS_Handle) ); + *Threads_GetHandlesPtr() = handles; + } -int VFS_MarkAvaliable(tVFS_Node *Node, BOOL bAvail) -{ - Node->DataAvaliable = bAvail; - if( Node->DataAvaliable && Node->ReadThreads ) - Threads_PostEvent( (void*)Node->ReadThreads, THREAD_EVENT_VFS ); - return 0; -} + // TODO: Global handles -int VFS_MarkError(tVFS_Node *Node, BOOL bError) -{ - Node->ErrorOccurred = bError; - if( Node->ErrorOccurred && Node->ErrorThreads ) - Threads_PostEvent( (void*)Node->ErrorThreads, THREAD_EVENT_VFS ); - return 0; -} - -int VFS_Open(const char *Path, Uint Flags) -{ + for( int i = 0; i < maxfd; i ++ ) + { + if( handles[i].Node == NULL ) { + handles[i].Node = Node; + handles[i].Mode = Mode; + return i; + } + } return -1; } -void VFS_Close(int FD) +tVFS_Handle *VFS_GetHandle(int FD) { + const int maxfd = *Threads_GetMaxFD(NULL); + tVFS_Handle *handles = *Threads_GetHandlesPtr(); + if( !handles ) + return NULL; + + if( FD < 0 || FD >= maxfd ) + return NULL; + + return &handles[FD]; } -tVFS_Handle *VFS_GetHandle(int FD) +int VFS_SetHandle(int FD, tVFS_Node *Node, int Mode) { - return NULL; -} + const int maxfd = *Threads_GetMaxFD(NULL); + tVFS_Handle *handles = *Threads_GetHandlesPtr(); + if( !handles ) + return -1; + + if( FD < 0 || FD >= maxfd ) + return -1; + handles[FD].Node = Node; + handles[FD].Mode = Mode; + return FD; +}