edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Christopher Brannon <chris@the-brannons.com>
To: edbrowse-dev@lists.the-brannons.com
Subject: [Edbrowse-dev] [PATCH] Use termios for all Unixen.
Date: Fri, 14 Feb 2014 16:30:49 -0800	[thread overview]
Message-ID: <1392424249-29466-1-git-send-email-chris@the-brannons.com> (raw)

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


             reply	other threads:[~2014-02-15  0:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-15  0:30 Christopher Brannon [this message]
2014-02-15  0:45 Karl Dahlke
2014-02-15  3:46 ` Chris Brannon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392424249-29466-1-git-send-email-chris@the-brannons.com \
    --to=chris@the-brannons.com \
    --cc=edbrowse-dev@lists.the-brannons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).