diff options
Diffstat (limited to 'sal/osl/unx/socket.cxx')
-rw-r--r-- | sal/osl/unx/socket.cxx | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx index cc1798e4eb1d..535c1727cb15 100644 --- a/sal/osl/unx/socket.cxx +++ b/sal/osl/unx/socket.cxx @@ -2043,133 +2043,4 @@ oslSocketError SAL_CALL osl_getLastSocketError(oslSocket pSocket) return ERROR_FROM_NATIVE(pSocket->m_nLastError); } -struct oslSocketSetImpl -{ - int m_MaxHandle; /* for select(), the largest descriptor in the set */ - fd_set m_Set; /* the set of descriptors */ - -}; - -oslSocketSet SAL_CALL osl_createSocketSet() -{ - oslSocketSetImpl* pSet; - - pSet= static_cast<oslSocketSetImpl*>(malloc(sizeof(oslSocketSetImpl))); - - SAL_WARN_IF( !pSet, "sal.osl", "allocation error" ); - - if(pSet) - { - pSet->m_MaxHandle= 0; - FD_ZERO(&pSet->m_Set); - } - - return pSet; -} - -void SAL_CALL osl_destroySocketSet(oslSocketSet Set) -{ - if(Set) - free(Set); -} - -void SAL_CALL osl_clearSocketSet(oslSocketSet Set) -{ - SAL_WARN_IF( !Set, "sal.osl", "undefined socket set" ); - if ( Set == nullptr ) - { - return; - } - - Set->m_MaxHandle= 0; - - FD_ZERO(&Set->m_Set); -} - -void SAL_CALL osl_addToSocketSet(oslSocketSet Set, oslSocket pSocket) -{ - SAL_WARN_IF( !Set, "sal.osl", "undefined socket set" ); - SAL_WARN_IF( !pSocket, "sal.osl", "undefined socket" ); - - if ( Set == nullptr || pSocket == nullptr) - { - return; - } - - /* correct max handle */ - if(pSocket->m_Socket > Set->m_MaxHandle) - Set->m_MaxHandle= pSocket->m_Socket; - FD_SET(pSocket->m_Socket, &Set->m_Set); - -} - -void SAL_CALL osl_removeFromSocketSet(oslSocketSet Set, oslSocket pSocket) -{ - SAL_WARN_IF( !Set, "sal.osl", "undefined socket set" ); - SAL_WARN_IF( !pSocket, "sal.osl", "undefined socket" ); - - if ( Set == nullptr || pSocket == nullptr) - { - return; - } - - /* correct max handle */ - if(pSocket->m_Socket == Set->m_MaxHandle) - { - /* not optimal, since the next used descriptor might be */ - /* much smaller than m_Socket-1, but it will do */ - Set->m_MaxHandle--; - if(Set->m_MaxHandle < 0) - { - Set->m_MaxHandle= 0; /* avoid underflow */ - } - } - - FD_CLR(pSocket->m_Socket, &Set->m_Set); -} - -sal_Bool SAL_CALL osl_isInSocketSet(oslSocketSet Set, oslSocket pSocket) -{ - SAL_WARN_IF( !Set, "sal.osl", "undefined socket set" ); - SAL_WARN_IF( !pSocket, "sal.osl", "undefined socket" ); - if ( Set == nullptr || pSocket == nullptr ) - { - return false; - } - - return bool(FD_ISSET(pSocket->m_Socket, &Set->m_Set)); -} - -sal_Int32 SAL_CALL osl_demultiplexSocketEvents(oslSocketSet IncomingSet, - oslSocketSet OutgoingSet, - oslSocketSet OutOfBandSet, - const TimeValue* pTimeout) -{ - int MaxHandle= 0; - struct timeval tv; - - if (pTimeout) - { - /* non-blocking call */ - tv.tv_sec = pTimeout->Seconds; - tv.tv_usec = pTimeout->Nanosec / 1000; - } - - /* get max handle from all sets */ - if (IncomingSet) - MaxHandle= IncomingSet->m_MaxHandle; - - if (OutgoingSet && (OutgoingSet->m_MaxHandle > MaxHandle)) - MaxHandle= OutgoingSet->m_MaxHandle; - - if (OutOfBandSet && (OutOfBandSet->m_MaxHandle > MaxHandle)) - MaxHandle= OutOfBandSet->m_MaxHandle; - - return select(MaxHandle+1, - IncomingSet ? PTR_FD_SET(IncomingSet->m_Set) : nullptr, - OutgoingSet ? PTR_FD_SET(OutgoingSet->m_Set) : nullptr, - OutOfBandSet ? PTR_FD_SET(OutOfBandSet->m_Set) : nullptr, - pTimeout ? &tv : nullptr); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |