Added open-control-tty.
This commit is contained in:
parent
16a701b470
commit
b453a05b92
40
scsh/tty1.c
40
scsh/tty1.c
|
@ -11,11 +11,24 @@
|
|||
* Re-written by Olin.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* This #include is for the #ifdef'd code in open_ctty() below, and
|
||||
** is therefor ifdef'd identically.
|
||||
*/
|
||||
#if defined(TIOCSCTTY) && !defined(CIBAUD)
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include "tty1.h" /* Make sure the .h interface agrees with the code. */
|
||||
|
||||
extern int errno;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int scheme_tcgetattr(int fd, char *control_chars,
|
||||
int *iflag_hi8, int *iflag_lo24,
|
||||
int *oflag_hi8, int *oflag_lo24,
|
||||
|
@ -40,6 +53,8 @@ int scheme_tcgetattr(int fd, char *control_chars,
|
|||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int scheme_tcsetattr(int fd, int option,
|
||||
const char *control_chars,
|
||||
int iflag_hi8, int iflag_lo24,
|
||||
|
@ -75,3 +90,28 @@ int scheme_tcsetattr(int fd, int option,
|
|||
|
||||
return tcsetattr(fd, option, &t);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int open_ctty(const char *ttyname, int flags)
|
||||
{
|
||||
int fd = open(ttyname, flags);
|
||||
|
||||
/* The ifdef is tricked by HP-UX, so I'll hardwire it out for now. -Olin */
|
||||
#if 0
|
||||
#if defined(TIOCSCTTY) && !defined(CIBAUD)
|
||||
fprintf(stderr, "Doing the ioctl.\n");
|
||||
/* 4.3+BSD way to acquire control tty. !CIBAUD rules out SunOS.
|
||||
** This code stolen from Steven's *Advanced Prog. in the Unix Env.*
|
||||
*/
|
||||
if( (fd >= 0) && (ioctl(fd, TIOCSCTTY, (char *) 0) < 0) ) {
|
||||
int e = errno;
|
||||
close(fd);
|
||||
errno = e;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return fd;
|
||||
}
|
||||
|
|
|
@ -15,3 +15,5 @@ int scheme_tcsetattr(int fd, int option,
|
|||
int lflag_hi8, int lflag_lo24,
|
||||
int ispeed, int ospeed,
|
||||
int min, int time);
|
||||
|
||||
int open_ctty(const char *ttyname, int flags);
|
||||
|
|
Loading…
Reference in New Issue