* include/cygwin/version.h: Bump API minor number for below export.

* cygwin.din (pututline): New exported function.
* syscalls.cc (login): Use pututiline().
(setutent): Open utmp as read/write.
(endutent): Check if utmp file is open.
(utmpname): call endutent() to close current utmp file.
(getutid): Enable all cases, use strncmp() to compare ut_id fields.
(pututline): New.
* tty.cc (create_tty_master): Set ut_pid to current pid.
* fhandler.h (fhandler_serial::vmin_): Declare as size_t.
* fhandler_serial.cc (fhandler_serial::raw_read): Use correct type for
minchars.
(fhandler_serial::ioctl): Set errno if the ClearCommError fails.
(fhandler_serial::tcsetattr): Use correct value for vmin_.
(fhandler_serial::tcgetattr): Ditto.
* fhandler_socket.cc (fhandler_socket::recvmsg): Call if from == NULL
WSARecvFrom with fromlen = NULL.
This commit is contained in:
Christopher Faylor 2002-11-07 03:47:52 +00:00
parent eb6afbddf9
commit bffb89c23a
1 changed files with 28 additions and 41 deletions

View File

@ -18,6 +18,7 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include <sys/termios.h>
#include <ddk/ntddser.h>
/**********************************************************************/
/* fhandler_serial */
@ -43,7 +44,7 @@ fhandler_serial::raw_read (void *ptr, size_t ulen)
int tot;
DWORD n;
HANDLE w4[2];
DWORD minchars = vmin_ ?: ulen;
size_t minchars = vmin_ ?: ulen;
w4[0] = io_status.hEvent;
w4[1] = signal_arrived;
@ -56,7 +57,7 @@ fhandler_serial::raw_read (void *ptr, size_t ulen)
ResetEvent (io_status.hEvent);
}
for (n = 0, tot = 0; ulen; ulen -= n, ptr = (char *)ptr + n)
for (n = 0, tot = 0; ulen; ulen -= n, ptr = (char *) ptr + n)
{
COMSTAT st;
DWORD inq = 1;
@ -81,7 +82,7 @@ fhandler_serial::raw_read (void *ptr, size_t ulen)
inq = st.cbInQue;
else if (!overlapped_armed)
{
if ((size_t)tot >= minchars)
if ((size_t) tot >= minchars)
break;
else if (WaitCommEvent (get_handle (), &ev, &io_status))
{
@ -388,7 +389,10 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
DWORD ev;
COMSTAT st;
if (ClearCommError (get_handle (), &ev, &st))
res = -1;
{
__seterrno ();
res = -1;
}
else
switch (cmd)
{
@ -397,48 +401,35 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
break;
case TIOCMGET:
DWORD modem_lines;
if (GetCommModemStatus (get_handle (), &modem_lines) == 0)
if (!GetCommModemStatus (get_handle (), &modem_lines))
{
__seterrno ();
res = -1;
}
else
{
unsigned modem_status = 0;
ipbuffer = 0;
if (modem_lines & MS_CTS_ON)
modem_status |= TIOCM_CTS;
ipbuffer |= TIOCM_CTS;
if (modem_lines & MS_DSR_ON)
modem_status |= TIOCM_DSR;
ipbuffer |= TIOCM_DSR;
if (modem_lines & MS_RING_ON)
modem_status |= TIOCM_RI;
ipbuffer |= TIOCM_RI;
if (modem_lines & MS_RLSD_ON)
modem_status |= TIOCM_CD;
if (!wincap.supports_reading_modem_output_lines ())
modem_status |= rts | dtr;
ipbuffer |= TIOCM_CD;
DWORD cb;
DWORD mcr;
if (!DeviceIoControl (get_handle (), IOCTL_SERIAL_GET_DTRRTS,
NULL, 0, &mcr, 4, &cb, 0) || cb != 4)
ipbuffer |= rts | dtr;
else
{
DWORD cb;
DWORD mcr;
BOOL result = DeviceIoControl (get_handle (), 0x001B0078, NULL,
0, &mcr, 4, &cb, 0);
if (!result)
{
__seterrno ();
res = -1;
goto out;
}
if (cb != 4)
{
set_errno (EINVAL); /* FIXME: right errno? */
res = -1;
goto out;
}
if (mcr & 2)
modem_status |= TIOCM_RTS;
ipbuffer |= TIOCM_RTS;
if (mcr & 1)
modem_status |= TIOCM_DTR;
ipbuffer |= TIOCM_DTR;
}
ipbuffer = modem_status;
}
break;
case TIOCMSET:
@ -472,15 +463,12 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
res = -1;
}
}
else if (EscapeCommFunction (get_handle (), CLRDTR))
dtr = 0;
else
{
if (EscapeCommFunction (get_handle (), CLRDTR))
dtr = 0;
else
{
__seterrno ();
res = -1;
}
__seterrno ();
res = -1;
}
break;
case TIOCINQ:
@ -499,7 +487,6 @@ fhandler_serial::ioctl (unsigned int cmd, void *buffer)
break;
}
out:
termios_printf ("%d = ioctl (%p, %p)", res, cmd, buffer);
# undef ibuffer
# undef ipbuffer
@ -794,7 +781,7 @@ fhandler_serial::tcsetattr (int action, const struct termios *t)
if (t->c_lflag & ICANON)
{
vmin_ = MAXDWORD;
vmin_ = 0;
vtime_ = 0;
}
else
@ -999,7 +986,7 @@ fhandler_serial::tcgetattr (struct termios *t)
t->c_oflag |= ONLCR;
debug_printf ("vmin_ %d, vtime_ %d", vmin_, vtime_);
if (vmin_ == MAXDWORD)
if (vmin_ == 0)
{
t->c_lflag |= ICANON;
t->c_cc[VTIME] = t->c_cc[VMIN] = 0;