mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-15 19:09:58 +08:00
b1f07180b5
* libc/sys/linux/Makefile.am: Add support for cfspeed.c and tcsendbrk.c. * libc/sys/linux/Makefile.in: Regenerated. * libc/sys/linux/termios.c: Add tcflow(), tcflush(), tcgetpgrp(), and tcsetpgrp() functions. * libc/sys/linux/sys/termios.h: Add include of machine/termios.h to get __MAX_BAUD rate. * libc/sys/linux/machine/i386/include/termios.h: New file. * libc/include/machine/termios.h: Ditto. * libc/sys/linux/cfspeed.c: Ditto. * libc/sys/linux/tcsendbrk.c: Ditto.
72 lines
1.0 KiB
C
72 lines
1.0 KiB
C
/* libc/sys/linux/termios.c - Terminal control */
|
|
|
|
/* Written 2000 by Werner Almesberger */
|
|
|
|
|
|
#include <errno.h>
|
|
#include <sys/types.h>
|
|
#include <sys/termios.h>
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
int
|
|
tcgetattr(int fd,struct termios *termios_p)
|
|
{
|
|
return ioctl(fd,TCGETS,termios_p);
|
|
}
|
|
|
|
|
|
int
|
|
tcsetattr(int fd,int optional_actions,const struct termios *termios_p)
|
|
{
|
|
int cmd;
|
|
|
|
switch (optional_actions) {
|
|
case TCSANOW:
|
|
cmd = TCSETS;
|
|
break;
|
|
case TCSADRAIN:
|
|
cmd = TCSETSW;
|
|
break;
|
|
case TCSAFLUSH:
|
|
cmd = TCSETSF;
|
|
break;
|
|
default:
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
return ioctl(fd,cmd,termios_p);
|
|
}
|
|
|
|
|
|
pid_t
|
|
tcgetpgrp(int fd)
|
|
{
|
|
int p;
|
|
|
|
if (ioctl(fd,TIOCGPGRP,&p) < 0)
|
|
return (pid_t)-1;
|
|
return (pid_t)p;
|
|
}
|
|
|
|
|
|
int
|
|
tcsetpgrp(int fd, pid_t pid)
|
|
{
|
|
int p = (int)pid;
|
|
return ioctl(fd,TIOCSPGRP,&p);
|
|
}
|
|
|
|
int
|
|
tcflow (int fd, int action)
|
|
{
|
|
return ioctl (fd, TCXONC, action);
|
|
}
|
|
|
|
int
|
|
tcflush (int fd, int queue_selector)
|
|
{
|
|
return ioctl (fd, TCFLSH, queue_selector);
|
|
}
|
|
|