working on it

This commit is contained in:
Dawid Sobczak 2025-04-05 10:55:40 +01:00
parent 56a6e78765
commit 35a88970c2
1094 changed files with 51093 additions and 51 deletions

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);
}

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);

View file

@ -0,0 +1,7 @@
#include <termios.h>
#include <sys/ioctl.h>
int tcdrain(int fd)
{
return ioctl(fd, TCSBRK, 1);
}

View file

@ -0,0 +1,7 @@
#include <termios.h>
#include <sys/ioctl.h>
int tcflow(int fd, int action)
{
return ioctl(fd, TCXONC, action);
}

View file

@ -0,0 +1,7 @@
#include <termios.h>
#include <sys/ioctl.h>
int tcflush(int fd, int queue)
{
return ioctl(fd, TCFLSH, queue);
}

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;
}

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;
}

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);
}

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);
}