- Fix indentation.

- Replace tabs by spaces.
- Replace STDCALL by WINAPI.
- Replace Alex' unreadable single-line statements by readable ones.
- No code changes.

svn path=/trunk/; revision=27514
This commit is contained in:
Eric Kohl 2007-07-08 20:09:22 +00:00
parent c57c69624e
commit add1532e20

View file

@ -49,6 +49,7 @@ CreateNamedPipeA(LPCSTR lpName,
lpSecurityAttributes);
}
/*
* @implemented
*/
@ -87,7 +88,8 @@ CreateNamedPipeW(LPCWSTR lpName,
}
/* Convert to NT syntax */
if (nMaxInstances == PIPE_UNLIMITED_INSTANCES) nMaxInstances = -1;
if (nMaxInstances == PIPE_UNLIMITED_INSTANCES)
nMaxInstances = -1;
/* Convert the name */
Result = RtlDosPathNameToNtPathName_U(lpName,
@ -98,7 +100,7 @@ CreateNamedPipeW(LPCWSTR lpName,
{
/* Conversion failed */
SetLastError(ERROR_PATH_NOT_FOUND);
return(INVALID_HANDLE_VALUE);
return INVALID_HANDLE_VALUE;
}
DPRINT("Pipe name: %wZ\n", &NamedPipeName);
@ -112,7 +114,8 @@ CreateNamedPipeW(LPCWSTR lpName,
SecurityDescriptor = lpSecurityAttributes->lpSecurityDescriptor;
/* And check if this is pipe's handle will beinheritable */
if(lpSecurityAttributes->bInheritHandle) Attributes |= OBJ_INHERIT;
if (lpSecurityAttributes->bInheritHandle)
Attributes |= OBJ_INHERIT;
}
/* Now we can initialize the object attributes */
@ -132,6 +135,7 @@ CreateNamedPipeW(LPCWSTR lpName,
{
CreateOptions |= FILE_WRITE_THROUGH;
}
if (!(dwOpenMode & FILE_FLAG_OVERLAPPED))
{
CreateOptions |= FILE_SYNCHRONOUS_IO_NONALERT;
@ -143,6 +147,7 @@ CreateNamedPipeW(LPCWSTR lpName,
ShareAccess |= FILE_SHARE_READ;
DesiredAccess |= GENERIC_WRITE;
}
if (dwOpenMode & PIPE_ACCESS_INBOUND)
{
ShareAccess |= FILE_SHARE_WRITE;
@ -232,6 +237,7 @@ CreateNamedPipeW(LPCWSTR lpName,
return PipeHandle;
}
/*
* @implemented
*/
@ -256,6 +262,7 @@ WaitNamedPipeA(LPCSTR lpNamedPipeName,
return r;
}
/*
* When NPFS will work properly, use this code instead. It is compatible with
* Microsoft's NPFS.SYS. The main difference is that:
@ -387,7 +394,7 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
SetLastErrorByStatus(Status);
RtlFreeUnicodeString(&NamedPipeName);
RtlFreeHeap(RtlGetProcessHeap(), 0, WaitPipeInfo);
return(FALSE);
return FALSE;
}
/* Check what timeout we got */
@ -454,25 +461,24 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
/*
* @implemented
*/
BOOL STDCALL
BOOL
WINAPI
WaitNamedPipeW(LPCWSTR lpNamedPipeName,
DWORD nTimeOut)
{
UNICODE_STRING NamedPipeName;
BOOL r;
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
FILE_PIPE_WAIT_FOR_BUFFER WaitPipe;
HANDLE FileHandle;
IO_STATUS_BLOCK Iosb;
r = RtlDosPathNameToNtPathName_U(lpNamedPipeName,
if (RtlDosPathNameToNtPathName_U(lpNamedPipeName,
&NamedPipeName,
NULL,
NULL);
if (!r)
NULL) == FALSE)
{
return(FALSE);
return FALSE;
}
InitializeObjectAttributes(&ObjectAttributes,
@ -489,7 +495,7 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return(FALSE);
return FALSE;
}
WaitPipe.Timeout.QuadPart = nTimeOut * -10000LL;
@ -508,17 +514,19 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return(FALSE);
return FALSE;
}
return(TRUE);
return TRUE;
}
#endif
/*
* @implemented
*/
BOOL STDCALL
BOOL
WINAPI
ConnectNamedPipe(IN HANDLE hNamedPipe,
IN LPOVERLAPPED lpOverlapped)
{
@ -586,11 +594,12 @@ ConnectNamedPipe(IN HANDLE hNamedPipe,
return TRUE;
}
/*
* @implemented
*/
BOOL
STDCALL
WINAPI
SetNamedPipeHandleState(HANDLE hNamedPipe,
LPDWORD lpMode,
LPDWORD lpMaxCollectionCount,
@ -621,7 +630,7 @@ SetNamedPipeHandleState(HANDLE hNamedPipe,
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return(FALSE);
return FALSE;
}
}
@ -638,11 +647,10 @@ SetNamedPipeHandleState(HANDLE hNamedPipe,
&RemoteSettings,
sizeof(FILE_PIPE_REMOTE_INFORMATION),
FilePipeRemoteInformation);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return(FALSE);
return FALSE;
}
}
@ -653,9 +661,8 @@ SetNamedPipeHandleState(HANDLE hNamedPipe,
if (lpCollectDataTimeout)
{
/* Convert it to Quad */
RemoteSettings.CollectDataTime.QuadPart = -(LONGLONG)
UInt32x32To64(10000,
*lpCollectDataTimeout);
RemoteSettings.CollectDataTime.QuadPart =
-(LONGLONG)UInt32x32To64(10000, *lpCollectDataTimeout);
}
/* Tell the driver to change them */
@ -664,18 +671,17 @@ SetNamedPipeHandleState(HANDLE hNamedPipe,
&RemoteSettings,
sizeof(FILE_PIPE_REMOTE_INFORMATION),
FilePipeRemoteInformation);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return(FALSE);
return FALSE;
}
}
/* All done */
return TRUE;
}
/*
* @implemented
*/
@ -706,6 +712,7 @@ CallNamedPipeA(LPCSTR lpNamedPipeName,
nTimeOut);
}
/*
* @implemented
*/
@ -736,10 +743,12 @@ CallNamedPipeW(LPCWSTR lpNamedPipeName,
NULL);
/* Success, break out */
if (hPipe != INVALID_HANDLE_VALUE) break;
if (hPipe != INVALID_HANDLE_VALUE)
break;
/* Already tried twice, give up */
if (bRetry == FALSE) return FALSE;
if (bRetry == FALSE)
return FALSE;
/* Wait on it */
WaitNamedPipeW(lpNamedPipeName, nTimeOut);
@ -767,11 +776,13 @@ CallNamedPipeW(LPCWSTR lpNamedPipeName,
lpBytesRead,
NULL);
/* Close the handle and return */
/* Close the handle */
CloseHandle(hPipe);
return bError;
}
/*
* @implemented
*/
@ -797,7 +808,8 @@ DisconnectNamedPipe(HANDLE hNamedPipe)
{
/* Wait on NPFS to finish and get updated status */
Status = NtWaitForSingleObject(hNamedPipe, FALSE, NULL);
if (NT_SUCCESS(Status)) Status = Iosb.Status;
if (NT_SUCCESS(Status))
Status = Iosb.Status;
}
/* Check for error */
@ -811,10 +823,12 @@ DisconnectNamedPipe(HANDLE hNamedPipe)
return TRUE;
}
/*
* @unimplemented
*/
BOOL STDCALL
BOOL
WINAPI
GetNamedPipeHandleStateW(HANDLE hNamedPipe,
LPDWORD lpState,
LPDWORD lpCurInstances,
@ -904,7 +918,8 @@ GetNamedPipeHandleStateW(HANDLE hNamedPipe,
/*
* @implemented
*/
BOOL STDCALL
BOOL
WINAPI
GetNamedPipeHandleStateA(HANDLE hNamedPipe,
LPDWORD lpState,
LPDWORD lpCurInstances,
@ -939,7 +954,6 @@ GetNamedPipeHandleStateA(HANDLE hNamedPipe,
lpCollectDataTimeout,
UserNameW.Buffer,
nMaxUserNameSize);
if (Ret && lpUserName != NULL)
{
NTSTATUS Status;
@ -965,7 +979,8 @@ GetNamedPipeHandleStateA(HANDLE hNamedPipe,
/*
* @implemented
*/
BOOL STDCALL
BOOL
WINAPI
GetNamedPipeInfo(HANDLE hNamedPipe,
LPDWORD lpFlags,
LPDWORD lpOutBufferSize,
@ -984,7 +999,7 @@ GetNamedPipeInfo(HANDLE hNamedPipe,
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return(FALSE);
return FALSE;
}
if (lpFlags != NULL)
@ -1007,9 +1022,10 @@ GetNamedPipeInfo(HANDLE hNamedPipe,
*lpMaxInstances = PipeLocalInformation.MaximumInstances;
}
return(TRUE);
return TRUE;
}
/*
* @implemented
*/
@ -1025,6 +1041,7 @@ PeekNamedPipe(HANDLE hNamedPipe,
PFILE_PIPE_PEEK_BUFFER Buffer;
IO_STATUS_BLOCK Iosb;
ULONG BufferSize;
ULONG BytesRead;
NTSTATUS Status;
/* Calculate the buffer space that we'll need and allocate it */
@ -1051,11 +1068,13 @@ PeekNamedPipe(HANDLE hNamedPipe,
{
/* Wait for npfs to be done, and update the status */
Status = NtWaitForSingleObject(hNamedPipe, FALSE, NULL);
if (NT_SUCCESS(Status)) Status = Iosb.Status;
if (NT_SUCCESS(Status))
Status = Iosb.Status;
}
/* Overflow is success for us */
if (Status == STATUS_BUFFER_OVERFLOW) Status = STATUS_SUCCESS;
if (Status == STATUS_BUFFER_OVERFLOW)
Status = STATUS_SUCCESS;
/* If we failed */
if (!NT_SUCCESS(Status))
@ -1067,23 +1086,25 @@ PeekNamedPipe(HANDLE hNamedPipe,
}
/* Check if caller requested bytes available */
if (lpTotalBytesAvail) *lpTotalBytesAvail = Buffer->ReadDataAvailable;
if (lpTotalBytesAvail)
*lpTotalBytesAvail = Buffer->ReadDataAvailable;
/* Calculate the bytes returned, minus our structure overhead */
BytesRead = (ULONG)(Iosb.Information -
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]))
/* Check if caller requested bytes read */
if (lpBytesRead)
{
/* Calculate the bytes returned, minus our structure overhead */
*lpBytesRead = (ULONG)(Iosb.Information -
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]));
/* Return the bytes read */
*lpBytesRead = BytesRead;
}
/* Check if caller requested bytes left */
if (lpBytesLeftThisMessage)
{
/* Calculate total minus what we returned and our structure overhead */
*lpBytesLeftThisMessage = Buffer->MessageLength -
(ULONG)(Iosb.Information -
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]));
*lpBytesLeftThisMessage = Buffer->MessageLength - BytesRead;
}
/* Check if the caller wanted to see the actual data */
@ -1092,19 +1113,21 @@ PeekNamedPipe(HANDLE hNamedPipe,
/* Give him what he wants */
RtlCopyMemory(lpBuffer,
Buffer->Data,
Iosb.Information -
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]));
BytesRead);
}
/* Free the buffer and return success */
/* Free the buffer */
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
return TRUE;
}
/*
* @implemented
*/
BOOL STDCALL
BOOL
WINAPI
TransactNamedPipe(IN HANDLE hNamedPipe,
IN LPVOID lpInBuffer,
IN DWORD nInBufferSize,
@ -1137,8 +1160,6 @@ TransactNamedPipe(IN HANDLE hNamedPipe,
nInBufferSize,
lpOutBuffer,
nOutBufferSize);
/* return FALSE in case of failure and pending operations! */
if (!NT_SUCCESS(Status) || Status == STATUS_PENDING)
{
SetLastErrorByStatus(Status);
@ -1165,18 +1186,14 @@ TransactNamedPipe(IN HANDLE hNamedPipe,
nInBufferSize,
lpOutBuffer,
nOutBufferSize);
/* wait in case operation is pending */
if (Status == STATUS_PENDING)
{
Status = NtWaitForSingleObject(hNamedPipe,
FALSE,
NULL);
if (NT_SUCCESS(Status))
{
Status = Iosb.Status;
}
}
if (NT_SUCCESS(Status))
{
@ -1200,16 +1217,19 @@ TransactNamedPipe(IN HANDLE hNamedPipe,
lpInBuffer = (LPVOID)((char *) lpInBuffer + nActualBytes);
nInBufferSize -= nActualBytes;
}
if (0 != nInBufferSize)
{
/* Must have dropped out of the while 'cause WriteFile failed */
return FALSE;
}
if (!ReadFile(hNamedPipe, lpOutBuffer, nOutBufferSize, &nActualBytes,
NULL))
{
return FALSE;
}
if (NULL != lpBytesRead)
{
*lpBytesRead = nActualBytes;