Make use of termios on OpenBSD

This commit is contained in:
Brad Smith 2022-09-02 23:52:34 -04:00
parent 4afc476d92
commit 662a041dba
3 changed files with 33 additions and 2 deletions

View File

@ -41,7 +41,7 @@ typedef struct {
#define TX_CMD_PROMPT ":"
/* all of the state associated with a tty terminal */
#if !defined(SYSV) && !defined(CYGWIN)
#if !defined(SYSV) && !defined(CYGWIN) && !defined(__OpenBSD__)
typedef struct {
struct sgttyb tx_i_sgtty;
struct tchars tx_i_tchars;

View File

@ -1215,6 +1215,15 @@ txGetTermState(buf)
ioctl( fileno( stdin ), TCGETA, buf);
}
#elif defined (__OpenBSD__)
void
txGetTermState(buf)
struct termios *buf;
{
(void) tcgetattr(fileno(stdin), buf);
}
#else
void
@ -1247,12 +1256,16 @@ void
txSetTermState(buf)
#if defined(SYSV) || defined(CYGWIN)
struct termio *buf;
#elif defined(__OpenBSD__)
struct termios *buf;
#else
txTermState *buf;
#endif /* SYSV */
{
#if defined(SYSV) || defined(CYGWIN)
ioctl( fileno(stdin), TCSETAF, buf );
#elif defined (__OpenBSD__)
(void) tcsetattr( fileno(stdin), TCSANOW, buf );
#else
/* set the current terminal characteristics */
(void) ioctl(fileno(stdin), TIOCSETN, (char *) &(buf->tx_i_sgtty) );
@ -1282,11 +1295,13 @@ void
txInitTermRec(buf)
#if defined(SYSV) || defined(CYGWIN)
struct termio *buf;
#elif defined(__OpenBSD__)
struct termios *buf;
#else
txTermState *buf;
#endif /* SYSV */
{
#if defined(SYSV) || defined(CYGWIN)
#if defined(SYSV) || defined(CYGWIN) || defined(__OpenBSD__)
buf->c_lflag = ISIG; /* raw: no echo and no processing, allow signals */
buf->c_cc[ VMIN ] = 1;
buf->c_cc[ VTIME ] = 0;
@ -1303,6 +1318,8 @@ txInitTermRec(buf)
#if defined(SYSV) || defined(CYGWIN)
struct termio closeTermState;
#elif defined(__OpenBSD__)
struct termios closeTermState;
#else
static txTermState closeTermState;
#endif /* SYSV */
@ -1335,6 +1352,13 @@ txSaveTerm()
TxEOFChar = closeTermState.c_cc[VEOF];
TxInterruptChar = closeTermState.c_cc[VINTR];
haveCloseState = TRUE;
#elif defined(__OpenBSD__)
(void) tcgetattr( fileno( stdin ), &closeTermState);
txEraseChar = closeTermState.c_cc[VERASE];
txKillChar = closeTermState.c_cc[VKILL];
TxEOFChar = closeTermState.c_cc[VEOF];
TxInterruptChar = closeTermState.c_cc[VINTR];
haveCloseState = TRUE;
#else
struct ltchars lt;
txGetTermState(&closeTermState);
@ -1371,6 +1395,8 @@ TxSetTerminal()
{
#if defined(SYSV) || defined(CYGWIN)
struct termio buf;
#elif defined(__OpenBSD__)
struct termios buf;
#else
txTermState buf;
#endif /* SYSV */

View File

@ -33,7 +33,12 @@
# endif
#include <sys/ioctl.h>
#if defined(__OpenBSD__)
#include <termios.h>
#else
#include <sys/ioctl_compat.h>
#endif
#else
#include <termio.h>