initial check-in, version 0.5.0
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
speed_t cfgetospeed(const struct termios *tio)
|
||||
{
|
||||
return tio->c_cflag & CBAUD;
|
||||
}
|
||||
|
||||
speed_t cfgetispeed(const struct termios *tio)
|
||||
{
|
||||
return cfgetospeed(tio);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include "libc.h"
|
||||
|
||||
int cfsetospeed(struct termios *tio, speed_t speed)
|
||||
{
|
||||
if (speed & ~CBAUD) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
tio->c_cflag &= ~CBAUD;
|
||||
tio->c_cflag |= speed;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cfsetispeed(struct termios *tio, speed_t speed)
|
||||
{
|
||||
return speed ? cfsetospeed(tio, speed) : 0;
|
||||
}
|
||||
|
||||
weak_alias(cfsetospeed, cfsetspeed);
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int tcdrain(int fd)
|
||||
{
|
||||
return ioctl(fd, TCSBRK, 1);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int tcflow(int fd, int action)
|
||||
{
|
||||
return ioctl(fd, TCXONC, action);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int tcflush(int fd, int queue)
|
||||
{
|
||||
return ioctl(fd, TCFLSH, queue);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <string.h>
|
||||
|
||||
int tcgetattr(int fd, struct termios *tio)
|
||||
{
|
||||
if (ioctl(fd, TCGETS, tio))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
pid_t tcgetsid(int fd)
|
||||
{
|
||||
int sid;
|
||||
if (ioctl(fd, TIOCGSID, &sid) < 0)
|
||||
return -1;
|
||||
return sid;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int tcsendbreak(int fd, int dur)
|
||||
{
|
||||
/* nonzero duration is implementation-defined, so ignore it */
|
||||
return ioctl(fd, TCSBRK, 0);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
int tcsetattr(int fd, int act, const struct termios *tio)
|
||||
{
|
||||
if (act < 0 || act > 2) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
return ioctl(fd, TCSETS+act, tio);
|
||||
}
|
||||
Reference in New Issue
Block a user