ntdll: Implemented serial IOCTL for status: GET_COMM_STATUS.

oldstable
Eric Pouech 2006-02-27 22:22:06 +01:00 committed by Alexandre Julliard
parent 8f08fe6c0d
commit a6d339c656
1 changed files with 38 additions and 0 deletions

View File

@ -168,6 +168,36 @@ static NTSTATUS get_modem_status(int fd, DWORD* lpModemStat)
return status;
}
static NTSTATUS get_status(int fd, SERIAL_STATUS* ss)
{
NTSTATUS status = STATUS_SUCCESS;
ss->Errors = 0;
ss->HoldReasons = 0;
ss->EofReceived = FALSE;
ss->WaitForImmediate = FALSE;
#ifdef TIOCOUTQ
if (ioctl(fd, TIOCOUTQ, &ss->AmountInOutQueue) == -1)
{
WARN("ioctl returned error\n");
status = FILE_GetNtStatus();
}
#else
ss->AmountInOutQueue = 0; /* FIXME: find a different way to find out */
#endif
#ifdef TIOCINQ
if (ioctl(fd, TIOCINQ, &ss->AmountInInQueue))
{
WARN("ioctl returned error\n");
status = FILE_GetNtStatus();
}
#else
ss->AmountInInQueue = 0; /* FIXME: find a different way to find out */
#endif
return status;
}
static NTSTATUS get_wait_mask(HANDLE hDevice, DWORD* mask)
{
NTSTATUS status;
@ -247,6 +277,14 @@ NTSTATUS COMM_DeviceIoControl(HANDLE hDevice,
switch (dwIoControlCode)
{
case IOCTL_SERIAL_GET_COMMSTATUS:
if (lpOutBuffer && nOutBufferSize == sizeof(SERIAL_STATUS))
{
if (!(status = get_status(fd, (SERIAL_STATUS*)lpOutBuffer)))
sz = sizeof(SERIAL_STATUS);
}
else status = STATUS_INVALID_PARAMETER;
break;
case IOCTL_SERIAL_GET_MODEMSTATUS:
if (lpOutBuffer && nOutBufferSize == sizeof(DWORD))
{