From 7e421e1fd5cf1c4ce33edc005fa63784d9c5a2e6 Mon Sep 17 00:00:00 2001 From: markus schnalke Date: Mon, 26 Mar 2012 22:23:33 +0200 Subject: [PATCH] Collapse termio/termios/sgtty terminal interface down to Posix termios. No longer check for termio.h or termios.h Merge from nmh. Thanks to Lyndon Nerenberg and Ken Hornstein. --- configure.ac | 2 +- sbr/discard.c | 28 +---------------------- uip/prompter.c | 68 ++++---------------------------------------------------- uip/termsbr.c | 29 +----------------------- 4 files changed, 7 insertions(+), 120 deletions(-) diff --git a/configure.ac b/configure.ac index 5b2f640..4a6b8ee 100644 --- a/configure.ac +++ b/configure.ac @@ -340,7 +340,7 @@ AC_HEADER_TIME AC_HEADER_SYS_WAIT AC_HEADER_STAT AC_HEADER_TIOCGWINSZ -AC_CHECK_HEADERS(fcntl.h crypt.h termcap.h termio.h termios.h \ +AC_CHECK_HEADERS(fcntl.h crypt.h termcap.h \ langinfo.h wchar.h wctype.h iconv.h \ sys/param.h sys/time.h sys/stream.h ) diff --git a/sbr/discard.c b/sbr/discard.c index 03eaa10..e38e5b0 100644 --- a/sbr/discard.c +++ b/sbr/discard.c @@ -8,15 +8,7 @@ #include -#ifdef HAVE_TERMIOS_H -# include -#else -# ifdef HAVE_TERMIO_H -# include -# else -# include -# endif -#endif +#include #ifdef SCO_5_STDIO # define _ptr __ptr @@ -29,28 +21,10 @@ void discard(FILE *io) { -#ifndef HAVE_TERMIOS_H -# ifdef HAVE_TERMIO_H - struct termio tio; -# else - struct sgttyb tio; -# endif -#endif - if (io == NULL) return; -#ifdef HAVE_TERMIOS_H tcflush(fileno(io), TCOFLUSH); -#else -# ifdef HAVE_TERMIO_H - if (ioctl(fileno(io), TCGETA, &tio) != -1) - ioctl(fileno(io), TCSETA, &tio); -# else - if (ioctl(fileno(io), TIOCGETP, (char *) &tio) != -1) - ioctl(fileno(io), TIOCSETP, (char *) &tio); -# endif -#endif #if defined(_FSTDIO) || defined(__DragonFly__) fpurge(io); diff --git a/uip/prompter.c b/uip/prompter.c index db61fb3..a398832 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -13,15 +13,7 @@ #include #include -#ifdef HAVE_TERMIOS_H -# include -#else -# ifdef HAVE_TERMIO_H -# include -# else -# include -# endif -#endif +#include #define QUOTE '\\' @@ -62,25 +54,10 @@ static struct swit switches[] = { }; -#ifdef HAVE_TERMIOS_H static struct termios tio; -# define ERASE tio.c_cc[VERASE] -# define KILL tio.c_cc[VKILL] -# define INTR tio.c_cc[VINTR] -#else -# ifdef HAVE_TERMIO_H -static struct termio tio; -# define ERASE tio.c_cc[VERASE] -# define KILL tio.c_cc[VKILL] -# define INTR tio.c_cc[VINTR] -# else -static struct sgttyb tio; -static struct tchars tc; -# define ERASE tio.sg_erase -# define KILL tio.sg_kill -# define INTR tc.t_intrc -# endif -#endif +#define ERASE tio.c_cc[VERASE] +#define KILL tio.c_cc[VKILL] +#define INTR tio.c_cc[VINTR] static int wtuser = 0; static int sigint = 0; @@ -195,23 +172,10 @@ main(int argc, char **argv) ** Are we changing the kill or erase character? */ if (killp || erasep) { -#ifdef HAVE_TERMIOS_H cc_t save_erase, save_kill; -#else - int save_erase, save_kill; -#endif /* get the current terminal attributes */ -#ifdef HAVE_TERMIOS_H tcgetattr(0, &tio); -#else -# ifdef HAVE_TERMIO_H - ioctl(0, TCGETA, &tio); -# else - ioctl(0, TIOCGETP, (char *) &tio); - ioctl(0, TIOCGETC, (char *) &tc); -# endif -#endif /* save original kill, erase character for later */ save_kill = KILL; @@ -222,15 +186,7 @@ main(int argc, char **argv) ERASE = erasep ? chrcnv(erasep) : save_erase; /* set the new terminal attributes */ -#ifdef HAVE_TERMIOS_H tcsetattr(0, TCSADRAIN, &tio); -#else -# ifdef HAVE_TERMIO_H - ioctl(0, TCSETAW, &tio); -# else - ioctl(0, TIOCSETN, (char *) &tio); -# endif -#endif /* print out new kill erase characters */ chrdsp("erase", ERASE); @@ -286,15 +242,7 @@ main(int argc, char **argv) if (i == -1) { abort: if (killp || erasep) { -#ifdef HAVE_TERMIOS_H tcsetattr(0, TCSADRAIN, &tio); -#else -# ifdef HAVE_TERMIO - ioctl(0, TCSETA, &tio); -# else - ioctl(0, TIOCSETN, (char *) &tio); -# endif -#endif } unlink(tmpfil); done(1); @@ -379,15 +327,7 @@ no_body: SIGNAL(SIGINT, SIG_IGN); if (killp || erasep) { -#ifdef HAVE_TERMIOS_H tcsetattr(0, TCSADRAIN, &tio); -#else -# ifdef HAVE_TERMIO_H - ioctl(0, TCSETAW, &tio); -# else - ioctl(0, TIOCSETN, (char *) &tio); -# endif -#endif } if ((fdi = open(tmpfil, O_RDONLY)) == NOTOK) diff --git a/uip/termsbr.c b/uip/termsbr.c index defc93f..b620e2c 100644 --- a/uip/termsbr.c +++ b/uip/termsbr.c @@ -8,15 +8,7 @@ #include -#ifdef HAVE_TERMIOS_H -# include -#else -# ifdef HAVE_TERMIO_H -# include -# else -# include -# endif -#endif +#include #ifdef HAVE_TERMCAP_H # include @@ -74,16 +66,7 @@ read_termcap(void) char termbuf[TXTSIZ]; #endif -#ifdef HAVE_TERMIOS_H struct termios tio; -#else -# ifdef HAVE_TERMIO_H - struct termio tio; -# else - struct sgttyb tio; -# endif -#endif - static int inited = 0; if (inited++) @@ -103,17 +86,7 @@ read_termcap(void) return; #endif -#ifdef HAVE_TERMIOS_H speedcode = cfgetospeed(&tio); -#else -# ifdef HAVE_TERMIO_H - speedcode = ioctl(fileno(stdout), TCGETA, &tio) != NOTOK ? - tio.c_cflag & CBAUD : 0; -# else - speedcode = ioctl(fileno(stdout), TIOCGETP, (char *) &tio) != NOTOK ? - tio.sg_ospeed : 0; -# endif -#endif if (!initCO && (CO = tgetnum("co")) <= 0) CO = 80; -- 1.7.10.4