Authors: David Hammerton <david@transgaming.com>, Mike McCormack <mike@codeweavers.com>

Completed PeekNamedPipe implementation.
This commit is contained in:
Alexandre Julliard 2004-02-12 20:03:53 +00:00
parent e8fedffa31
commit 850ee4ba4e
1 changed files with 22 additions and 6 deletions

View File

@ -32,6 +32,9 @@
#ifdef HAVE_SYS_POLL_H
#include <sys/poll.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#include <stdarg.h>
#include <stdio.h>
@ -1117,13 +1120,26 @@ BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
return FALSE;
}
}
wine_server_release_fd( hPipe, fd );
TRACE(" 0x%08x bytes available\n", avail );
if (!lpvBuffer && lpcbAvail)
{
*lpcbAvail= avail;
return TRUE;
}
ret = TRUE;
if (lpcbAvail)
*lpcbAvail = avail;
if (lpcbRead)
*lpcbRead = 0;
if (avail && lpvBuffer)
{
int readbytes = (avail < cbBuffer) ? avail : cbBuffer;
readbytes = recv(fd, lpvBuffer, readbytes, MSG_PEEK);
if (readbytes < 0)
{
WARN("failed to peek socket (%d)\n", errno);
ret = FALSE;
}
else if (lpcbRead)
*lpcbRead = readbytes;
}
wine_server_release_fd( hPipe, fd );
return ret;
#endif /* defined(FIONREAD) */
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);