2000-12-09 09:20:32 +08:00
|
|
|
/* 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>
|
|
|
|
|
|
|
|
|
2002-05-29 06:26:36 +08:00
|
|
|
int
|
|
|
|
tcgetattr(int fd,struct termios *termios_p)
|
2000-12-09 09:20:32 +08:00
|
|
|
{
|
2002-05-29 06:26:36 +08:00
|
|
|
return ioctl(fd,TCGETS,termios_p);
|
2000-12-09 09:20:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-29 06:26:36 +08:00
|
|
|
int
|
|
|
|
tcsetattr(int fd,int optional_actions,const struct termios *termios_p)
|
2000-12-09 09:20:32 +08:00
|
|
|
{
|
2002-05-29 06:26:36 +08:00
|
|
|
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;
|
2000-12-09 09:20:32 +08:00
|
|
|
}
|
2002-05-29 06:26:36 +08:00
|
|
|
return ioctl(fd,cmd,termios_p);
|
|
|
|
}
|
|
|
|
|
2002-08-27 02:56:09 +08:00
|
|
|
#if !defined(_ELIX_LEVEL) || _ELIX_LEVEL >= 4
|
2002-05-29 06:26:36 +08:00
|
|
|
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);
|
|
|
|
}
|
2002-08-27 02:56:09 +08:00
|
|
|
#endif /* !_ELIX_LEVEL || _ELIX_LEVEL >= 4 */
|
2002-05-29 06:26:36 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
tcflow (int fd, int action)
|
|
|
|
{
|
|
|
|
return ioctl (fd, TCXONC, action);
|
2000-12-09 09:20:32 +08:00
|
|
|
}
|
2002-05-29 06:26:36 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
tcflush (int fd, int queue_selector)
|
|
|
|
{
|
|
|
|
return ioctl (fd, TCFLSH, queue_selector);
|
|
|
|
}
|
|
|
|
|