Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Wed Mar 10 14:23:43 2010 +0100

    Define USE_TERMIOS on Linux-*, kfreebsd-* and GNU/Hurd.

---
 Imakefile   |    2 +-
 mdmdetect.c |    4 ++++
 modem.c     |   14 +++++++-------
 teleinfo.c  |    4 ++--
 4 files changed, 14 insertions(+), 10 deletions(-)

--- a/Imakefile
+++ b/Imakefile
@@ -30,7 +30,7 @@ NETWORKCFLAGS = -DNO_NETWORK
 #ifdef NO_TERMIO
 TERMIOCFLAGS = -DNO_TERMIO
 #else
-#if defined(USE_TERMIOS) || defined(__FreeBSD__)
+#if defined(USE_TERMIOS) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__linux__)
 TERMIOCFLAGS = -DUSE_TERMIOS
 #endif
 #endif
--- a/mdmdetect.c
+++ b/mdmdetect.c
@@ -38,7 +38,11 @@ static char rcsid[] = "$Id: mdmdetect.c,
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#ifdef USE_TERMIOS
+#include <termios.h>
+#else
 #include <termio.h>
+#endif
 #ifdef SVR4
 #include <sys/mkdev.h>
 #endif /* SVR4 */
--- a/modem.c
+++ b/modem.c
@@ -167,7 +167,7 @@ void init_tty (int fd, int speed, int cs
 #else
 
 #ifdef USE_TERMIOS
-  ioctl (fd, TIOCGETA, &term);
+  tcgetattr (fd, &term);
   usleep(tempo);
   memcpy ((char *)&term_sauve, (char *)&term, sizeof(struct termios));
 #else
@@ -240,7 +240,7 @@ void init_tty (int fd, int speed, int cs
 
   /* Affectation des parametres */
 #ifdef USE_TERMIOS
-  ioctl (fd, TIOCSETA, &term);
+  tcsetattr (fd, TCSANOW, &term);
   usleep(tempo);
 #else
   ioctl (fd, TCSETA, &term);
@@ -268,9 +268,9 @@ void restore_tty (int fd)
 #ifdef USE_TERMIOS
   cfsetispeed (&term, B0);
   cfsetospeed (&term, B0);
-  ioctl (fd, TIOCSETAW, &term);
+  tcsetattr (fd, TCSADRAIN, &term);
   usleep(tempo);
-  ioctl (fd, TIOCSETA, &term_sauve);
+  tcsetattr (fd, TCSANOW, &term);
   usleep(tempo);
 #else
   term.c_cflag &= ~CBAUD;
@@ -321,7 +321,7 @@ int reply_size;
      *  (comme le Hayes Optima par exemple)...
      */
 #ifdef USE_TERMIOS
-    ioctl (fd, TIOCGETA, &term);
+    tcgetattr (fd, &term);
     usleep(tempo);
 #else
     ioctl (fd, TCGETA, &term);
@@ -330,7 +330,7 @@ int reply_size;
     if ((term.c_cflag | CLOCAL) == 0) {
 	term.c_cflag |= CLOCAL;
 #ifdef USE_TERMIOS
-	ioctl (fd, TIOCSETA, &term);
+	tcsetattr (fd, TCSANOW, &term);
 	usleep(tempo);
 #else
 	ioctl (fd, TCSETA, &term);
@@ -612,7 +612,7 @@ int reply_size;
     if (cmodem) {
 	term.c_cflag &= ~CLOCAL;
 #ifdef USE_TERMIOS
-	ioctl (fd, TIOCSETA, &term);
+	tcsetattr (fd, TCSANOW, &term);
 	usleep(tempo);
 #else
 	ioctl (fd, TCSETA, &term);
--- a/teleinfo.c
+++ b/teleinfo.c
@@ -171,7 +171,7 @@ char *nom;
     ioctl (fd_teleinfo, TIOCSETP, &term);
 #else
 #ifdef USE_TERMIOS
-    ioctl (fd_teleinfo, TIOCGETA, &term);
+    tcgetattr (fd_teleinfo, &term);
 #else
     ioctl (fd_teleinfo, TCGETA, &term);
 #endif /* USE_TERMIOS */
@@ -183,7 +183,7 @@ char *nom;
     term.c_cflag |= (CS7|PARENB);		/* a voir... */
 #endif
 #ifdef USE_TERMIOS
-    ioctl (fd_teleinfo, TIOCSETA, &term);
+    tcsetattr (fd_teleinfo, TCSANOW, &term);
 #else
     ioctl (fd_teleinfo, TCSETA, &term);
 #endif /* USE_TERMIOS */
