Index: wine/configure.in
===================================================================
RCS file: /home/wine/wine/configure.in,v
retrieving revision 1.152
diff -u -r1.152 configure.in
--- wine/configure.in	2000/09/06 19:46:59	1.152
+++ wine/configure.in	2000/09/08 17:00:32
@@ -956,6 +956,18 @@
     AC_DEFINE(HAVE_MSGHDR_ACCRIGHTS)
 fi
 
+
+dnl *** check for TIOCMIWAIT extensions in Linux kernel
+
+AC_CACHE_CHECK("for TIOCMIWAIT extensions in kernel", ac_cv_c_tiocmiwait_ex,
+ AC_TRY_COMPILE([#include <asm/termios.h>],[int x = TIOCMIWAIT_RX], 
+               ac_cv_c_tiocmiwait_ex="yes", ac_cv_c_tiocmiwait_ex="no"))
+if test "$ac_cv_c_tiocmiwait_ex" = "yes"
+then
+    AC_DEFINE(HAVE_TIOCMIWAIT_MODS)
+fi
+
+
 dnl *** Check for the sun_len member in struct sockaddr_un
 
 AC_CACHE_CHECK("for sun_len in struct sockaddr_un", ac_cv_c_sun_len,
Index: wine/include/config.h.in
===================================================================
RCS file: /home/wine/wine/include/config.h.in,v
retrieving revision 1.53
diff -u -r1.53 config.h.in
--- wine/include/config.h.in	2000/09/06 19:46:59	1.53
+++ wine/include/config.h.in	2000/09/08 17:00:32
@@ -56,6 +56,9 @@
 /* Define if struct msghdr contains msg_accrights */
 #undef HAVE_MSGHDR_ACCRIGHTS
 
+/* Define if you have TIOCMIWAIT extensions for serial port support */
+#undef HAVE_TIOCMIWAIT_MODS
+
 /* Define if struct sockaddr_un contains sun_len */
 #undef HAVE_SOCKADDR_SUN_LEN
 
Index: wine/misc/comm.c
===================================================================
RCS file: /home/wine/wine/misc/comm.c,v
retrieving revision 1.53
diff -u -r1.53 comm.c
--- wine/misc/comm.c	2000/09/07 18:39:51	1.53
+++ wine/misc/comm.c	2000/09/08 17:00:32
@@ -2550,13 +2550,136 @@
 }
 /***********************************************************************
  *           WaitCommEvent   (KERNEL32.719)
+ *
+ * Blocks until something interesting happens on the com port associated
+ * with hFile. Interesting things are defined by an event mask, pointed
+ * to by "eventmask". These can be combinations of:
+ *  EV_RXCHAR     a new character is received.
+ *  EV_TXEMPTY    The transmit buffer became empty.
+ *  EV_BRK        A break condition was detected on the input.
+ *  EV_CTS        The CTS line changed status.
+ *  EV_DSR        The DSR line changed status.
+ *  EV_RING       The RNG line changed status.
+ *  EV_ERR        An error was detected on the input (parity or framing)
+ *
+ * RETURNS
+ *
+ *  FALSE   If there was an error, and no waiting was done.
+ *  TRUE    When the requested condition was detected.
+ *
+ * BUGS
+ *
+ *  Doesn't handle asynchronous I/O yet. (using the overlapped structure)
+ *  Doesn't support EV_RXFLAG,  EV_RLSD and some others.
  */
-BOOL WINAPI WaitCommEvent(HANDLE hFile,LPDWORD eventmask ,LPOVERLAPPED overlapped)
-{
-	FIXME("(%d %p %p )\n",hFile, eventmask,overlapped);
-	return TRUE;
-}
 
+BOOL WINAPI WaitCommEvent(
+                HANDLE hFile,            /* file handle of the comm port */
+                LPDWORD eventmask,       /* bitmask of interesting events */
+                LPOVERLAPPED overlapped  /* asynchronous operation structure */
+) {
+#define TIOCMIWAIT_RNG   TIOCM_RNG
+#define TIOCMIWAIT_DSR   TIOCM_DSR
+#define TIOCMIWAIT_DCD   TIOCM_CD
+#define TIOCMIWAIT_CTS   TIOCM_CTS
+#define TIOCMIWAIT_RX    0x1000
+#define TIOCMIWAIT_BRK   0x2000
+#define TIOCMIWAIT_TX    0x4000
+#define TIOCMIWAIT_ERR   0x8000
+
+#define TIOCMIWAIT_RETFLAGS 0x800000/* timers in microseconds */
+
+    int fd, tiomask, r;
+    DWORD ev;
+
+    TRACE("(%d %p %p %lx )\n",hFile, eventmask,overlapped, *eventmask);
+
+    if(overlapped)
+    {
+        FIXME("can't handle the overlapped structure yet.\n");
+    }
+
+    fd=COMM_GetReadFd(hFile);
+    if(0>fd) 
+    {
+        TRACE("File descriptor was bad.\n");
+        return FALSE;
+    }
+
+    if(0==GetCommMask(hFile, &ev))
+    {
+        close(fd);
+        TRACE("GetCommMask failed\n");
+        return FALSE;
+    }
+
+#ifdef HAVE_TIOCMIWAIT_MODS
+
+    /*
+    ** A technically nice way of implementing this function:
+    ** use an ioctl to request that the kernel block until
+    ** the appropriate condition is satistfied. Only problem
+    ** is that this required a patch to the kernel source :-(
+    */
+
+    /* translate from windows to linux event mask */
+    tiomask = 0;
+    if(ev & EV_RXCHAR)
+        tiomask |= TIOCMIWAIT_RX;
+    if(ev & EV_TXEMPTY)
+        tiomask |= TIOCMIWAIT_TX;
+    if(ev & EV_BREAK)
+        tiomask |= TIOCMIWAIT_BRK;
+    if(ev & EV_CTS)
+        tiomask |= TIOCMIWAIT_CTS;
+    if(ev & EV_DSR)
+        tiomask |= TIOCMIWAIT_DSR;
+    if(ev & EV_RING)
+        tiomask |= TIOCMIWAIT_RNG;
+    if(ev & EV_ERR)
+        tiomask |= TIOCMIWAIT_ERR;
+
+    /* MJM - extended TIOCMIWAIT to handle more wait conditions */
+    TRACE("waiting tiomask %x\n",tiomask);
+    r = ioctl(fd, TIOCMIWAIT, tiomask);
+    if(r<0)
+    {
+        /* TODO: set an error code */
+        TRACE("wait failed tiomask %x\n",tiomask);
+        return FALSE;
+    }
+
+    if(eventmask)
+    {
+        /* translate from linux to windows event mask */
+        *eventmask = 0;
+        if(tiomask & TIOCMIWAIT_RX)
+            *eventmask |= EV_RXCHAR;
+        if(tiomask & TIOCMIWAIT_TX)
+            *eventmask |= EV_TXEMPTY;
+        if(tiomask & TIOCMIWAIT_BRK)
+            *eventmask |= EV_BREAK;
+        if(tiomask & TIOCMIWAIT_CTS)
+            *eventmask |= EV_CTS;
+        if(tiomask & TIOCMIWAIT_DSR)
+            *eventmask = EV_DSR;
+        if(tiomask & TIOCMIWAIT_RNG)
+            *eventmask = EV_RING;
+        if(tiomask & TIOCMIWAIT_ERR)
+            *eventmask = EV_ERR;
+    }
+    TRACE("exit eventmask %lx\n",*eventmask);
+#else /* HAVE_TIOCMIWAIT_MOD */
+
+    ERR("This can work if you upgrade your kernel's serial driver\n");
+    *eventmask = 0;
+
+#endif
+
+    close(fd);
+
+    return TRUE;
+}
 /***********************************************************************
  *           GetCommProperties   (KERNEL32.286)
  *
