Hello,
Some of you may know that the GRASS application is also available from
FreeBSD Ports (the framework that allows people to compile, install and
package third party applications).
The last few weeks I've been patching various applications to avoid
inclusion of the <sgtty.h> header file. The idea behind this is that
FreeBSD currently supports two terminal line discipline interfaces,
namely the old sgtty interface and the standard POSIX termios interface.
On Linux, this is even worse, because it also supports the SystemV
termio interface.
The GRASS application currently checks for termios.h, termio.h and
sgtty.h, but only uses termio.h and sgtty.h in the intr_char.c file.
The following patch adds some bits to use termios as well:
%%%
--- lib/gis/intr_char.c Thu Feb 9 04:08:56 2006
+++ lib/gis/intr_char.c Mon Mar 26 19:27:22 2007
@@ -2,7 +2,11 @@
#include <grass/config.h>
#ifndef __MINGW32__
-#ifdef HAVE_TERMIO_H
+#if defined(HAVE_TERMIOS_H)
+# include <termios.h>
+# define TYPE termios
+# define C c_cc[VINTR]
+#elif defined(HAVE_TERMIO_H)
# include <termio.h>
# define TYPE termio
# define C c_cc[VINTR]
@@ -32,7 +36,11 @@
#ifndef __MINGW32__
struct TYPE buf;
+#ifdef HAVE_TERMIOS_H
+ tcgetattr (2, &buf);
+#else
ioctl (2, GET, &buf);
+#endif
c = buf.C;
#endif
return c;
%%%
The POSIX documentation mentions a function, tcgetattr(), which is a
portable routine to acquire the current terminal line discipline
configuration. We're better off using this routine instead of some
ioctl(), because isn't the same on all operating systems per se.
This patch will probably enable usage of termios on operating systems,
such as Linux and Solaris as well.
Yours,
--
Ed Schouten <ed@fxq.nl>
WWW: http://g-rave.nl/