1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

Refactor isatty() check into local_init()

In preparation for non-TTY file descriptors.
This commit is contained in:
David Leonard
2018-02-10 19:36:03 +10:00
committed by Nick Patavalis
parent ebc3566492
commit a782f86d46

19
term.c
View File

@ -89,6 +89,18 @@ static struct term_s term[MAX_TERMS];
/***************************************************************************/
static int
local_init(struct term_s *t)
{
int rval = 0;
if ( ! isatty(t->fd) ) {
term_errno = TERM_EISATTY;
rval = -1;
}
return rval;
}
static int
local_tcgetattr(struct term_s *t, struct termios *termios_out)
{
@ -144,6 +156,7 @@ local_write(struct term_s *t, const void *buf, unsigned bufsz)
}
static const struct term_ops local_term_ops = {
.init = local_init,
.tcgetattr = local_tcgetattr,
.tcsetattr = local_tcsetattr,
.modem_get = local_modem_get,
@ -591,12 +604,6 @@ term_add (int fd)
break;
}
if ( ! isatty(fd) ) {
term_errno = TERM_EISATTY;
rval = -1;
break;
}
t = term_new(fd, &local_term_ops);
if ( ! t ) {
rval = -1;