Eric Pouech : ntdll: Implemented IOCTL purge for serial objects.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Feb 6 05:10:27 CST 2006
Module: wine
Branch: refs/heads/master
Commit: b83c5ead168645fdae578bc3484d32183ef4af34
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=b83c5ead168645fdae578bc3484d32183ef4af34
Author: Eric Pouech <eric.pouech at wanadoo.fr>
Date: Mon Feb 6 11:36:19 2006 +0100
ntdll: Implemented IOCTL purge for serial objects.
---
dlls/kernel/comm.c | 34 ++++++++--------------------------
dlls/ntdll/serial.c | 20 ++++++++++++++++++++
2 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/dlls/kernel/comm.c b/dlls/kernel/comm.c
index de959de..41ae790 100644
--- a/dlls/kernel/comm.c
+++ b/dlls/kernel/comm.c
@@ -848,37 +848,19 @@ BOOL WINAPI EscapeCommFunction(
* Terminates pending operations and/or discards buffers on a
* communication resource.
*
+ * PARAMS
+ *
+ * handle [in] The communication resource to be purged
+ * flags [in] Flags for clear pending/buffer on input/output
+ *
* RETURNS
*
* True on success and false if the communications handle is bad.
*/
-BOOL WINAPI PurgeComm(
- HANDLE handle, /* [in] The communication resource to be purged. */
- DWORD flags) /* [in] Flags for clear pending/buffer on input/output. */
+BOOL WINAPI PurgeComm(HANDLE handle, DWORD flags)
{
- int fd;
-
- TRACE("handle %p, flags %lx\n", handle, flags);
-
- fd = get_comm_fd( handle, FILE_READ_DATA );
- if(fd<0) return FALSE;
-
- /*
- ** not exactly sure how these are different
- ** Perhaps if we had our own internal queues, one flushes them
- ** and the other flushes the kernel's buffers.
- */
- if(flags&PURGE_TXABORT)
- tcflush(fd,TCOFLUSH);
- if(flags&PURGE_RXABORT)
- tcflush(fd,TCIFLUSH);
- if(flags&PURGE_TXCLEAR)
- tcflush(fd,TCOFLUSH);
- if(flags&PURGE_RXCLEAR)
- tcflush(fd,TCIFLUSH);
- release_comm_fd( handle, fd );
-
- return 1;
+ return DeviceIoControl(handle, IOCTL_SERIAL_PURGE, &flags, sizeof(flags),
+ NULL, 0, NULL, NULL);
}
/*****************************************************************************
diff --git a/dlls/ntdll/serial.c b/dlls/ntdll/serial.c
index 0b15f6e..ecf025c 100644
--- a/dlls/ntdll/serial.c
+++ b/dlls/ntdll/serial.c
@@ -129,6 +129,20 @@ static const char* iocode2str(DWORD ioc)
}
}
+static NTSTATUS purge(int fd, DWORD flags)
+{
+ /*
+ ** not exactly sure how these are different
+ ** Perhaps if we had our own internal queues, one flushes them
+ ** and the other flushes the kernel's buffers.
+ */
+ if (flags & PURGE_TXABORT) tcflush(fd, TCOFLUSH);
+ if (flags & PURGE_RXABORT) tcflush(fd, TCIFLUSH);
+ if (flags & PURGE_TXCLEAR) tcflush(fd, TCOFLUSH);
+ if (flags & PURGE_RXCLEAR) tcflush(fd, TCIFLUSH);
+ return STATUS_SUCCESS;
+}
+
/******************************************************************
* COMM_DeviceIoControl
*
@@ -156,6 +170,12 @@ NTSTATUS COMM_DeviceIoControl(HANDLE hDe
switch (dwIoControlCode)
{
+ case IOCTL_SERIAL_PURGE:
+ if (lpInBuffer && nInBufferSize == sizeof(DWORD))
+ status = purge(fd, *(DWORD*)lpInBuffer);
+ else
+ status = STATUS_INVALID_PARAMETER;
+ break;
case IOCTL_SERIAL_SET_BREAK_OFF:
#if defined(TIOCSBRK) && defined(TIOCCBRK) /* check if available for compilation */
if (ioctl(fd, TIOCCBRK, 0) == -1)
More information about the wine-cvs
mailing list