initial check-in, version 0.5.0

This commit is contained in:
Rich Felker
2011-02-12 00:22:29 -05:00
commit 0b44a0315b
1021 changed files with 45711 additions and 0 deletions
+12
View File
@@ -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);
}
+22
View File
@@ -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);
+7
View File
@@ -0,0 +1,7 @@
#include <termios.h>
#include <sys/ioctl.h>
int tcdrain(int fd)
{
return ioctl(fd, TCSBRK, 1);
}
+7
View File
@@ -0,0 +1,7 @@
#include <termios.h>
#include <sys/ioctl.h>
int tcflow(int fd, int action)
{
return ioctl(fd, TCXONC, action);
}
+7
View File
@@ -0,0 +1,7 @@
#include <termios.h>
#include <sys/ioctl.h>
int tcflush(int fd, int queue)
{
return ioctl(fd, TCFLSH, queue);
}
+10
View File
@@ -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;
}
+10
View File
@@ -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;
}
+8
View File
@@ -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);
}
+13
View File
@@ -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);
}