edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] [PATCH] Use termios for all Unixen.
@ 2014-02-15  0:30 Christopher Brannon
  0 siblings, 0 replies; 3+ messages in thread
From: Christopher Brannon @ 2014-02-15  0:30 UTC (permalink / raw)
  To: edbrowse-dev

termio is deprecated on Linux.
termios is specified in POSIX from 1990, so we should use it
everywhere.  We now use tcgetattr / tcsetattr instead of ioctl calls.
These should be usable on all the Unix systems we currently support.
---
 src/stringfile.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/stringfile.c b/src/stringfile.c
index cc278fd..752b9f5 100644
--- a/src/stringfile.c
+++ b/src/stringfile.c
@@ -10,17 +10,8 @@
 #include <dos.h>
 #else
 #include <dirent.h>
-#ifdef SYSBSD
 #include <termios.h>
-typedef struct termios termstruct;
-#define TTY_GET_COMMAND TIOCGETA
-#define TTY_SET_COMMAND TIOCSETA
-#else
-#include <termio.h>
-typedef struct termio termstruct;
-#define TTY_GET_COMMAND TCGETA
-#define TTY_SET_COMMAND TCSETA
-#endif
+#include <unistd.h>
 #include <sys/utsname.h>
 #endif
 #include <pcre.h>
@@ -877,12 +868,12 @@ time_t fileTimeByName(const char *name)
 
 #ifndef DOSLIKE
 
-static termstruct savettybuf;
+static struct termios savettybuf;
 void ttySaveSettings(void)
 {
 	isInteractive = isatty(0);
 	if (isInteractive) {
-		if (ioctl(0, TTY_GET_COMMAND, &savettybuf))
+		if (tcgetattr(0, &savettybuf))
 			i_printfExit(MSG_IoctlError);
 	}
 }				/* ttySaveSettings */
@@ -890,7 +881,7 @@ void ttySaveSettings(void)
 static void ttyRestoreSettings(void)
 {
 	if (isInteractive)
-		ioctl(0, TTY_SET_COMMAND, &savettybuf);
+		tcsetattr(0, TCSANOW, &savettybuf);
 }				/* ttyRestoreSettings */
 
 /* put the tty in raw mode.
@@ -902,13 +893,13 @@ static void ttyRestoreSettings(void)
  * min=0 time=0:  nonblocking, return whatever chars have been received. */
 static void ttyRaw(int charcount, int timeout, eb_bool isecho)
 {
-	termstruct buf = savettybuf;	/* structure copy */
+	struct termios buf = savettybuf;	/* structure copy */
 	buf.c_cc[VMIN] = charcount;
 	buf.c_cc[VTIME] = timeout;
 	buf.c_lflag &= ~(ICANON | ECHO);
 	if (isecho)
 		buf.c_lflag |= ECHO;
-	ioctl(0, TTY_SET_COMMAND, &buf);
+	tcsetattr(0, TCSANOW, &buf);
 }				/* ttyRaw */
 
 /* simulate MSDOS getche() system call */
-- 
1.8.3.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Edbrowse-dev] [PATCH] Use termios for all Unixen.
  2014-02-15  0:45 Karl Dahlke
@ 2014-02-15  3:46 ` Chris Brannon
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Brannon @ 2014-02-15  3:46 UTC (permalink / raw)
  To: Edbrowse-dev

> Looks good.

Thanks for looking.  This is now pushed.

-- Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Edbrowse-dev]  [PATCH] Use termios for all Unixen.
@ 2014-02-15  0:45 Karl Dahlke
  2014-02-15  3:46 ` Chris Brannon
  0 siblings, 1 reply; 3+ messages in thread
From: Karl Dahlke @ 2014-02-15  0:45 UTC (permalink / raw)
  To: Edbrowse-dev

Looks good.

Karl Dahlke

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-02-15  3:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-15  0:30 [Edbrowse-dev] [PATCH] Use termios for all Unixen Christopher Brannon
2014-02-15  0:45 Karl Dahlke
2014-02-15  3:46 ` Chris Brannon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).