[GRASS-dev] [patch] Use <termios.h> in intr_char.c

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/

Ed

Thanks for your patch. Please submit it to the patches tracker.

Maciek

Maciej Sieczka wrote:

Thanks for your patch. Please submit it to the patches tracker.

This was committed to CVS shortly after the patch was posted. It
appears that I forgot to reply to this.

--
Glynn Clements <glynn@gclements.plus.com>

Glynn Clements wrote:

Maciej Sieczka wrote:

Thanks for your patch. Please submit it to the patches tracker.

This was committed to CVS shortly after the patch was posted. It
appears that I forgot to reply to this.

My email server tends to re-send a random message from time to time.
Ed's message was one such. I replied, missing how old the message was
and forgetting that the issue had been solved in patches tracker [1].

Very sorry for the fuss. My fault.

Maciek

[1]http://wald.intevation.org/tracker/?func=detail&atid=205&aid=347&group_id=21

Maciej Sieczka wrote:

My email server tends to re-send a random message from time to time.
Ed's message was one such.

I've just received it too.

<from the OP email header info>
[...]
Received: from grass.itc.it (localhost.localdomain [127.0.0.1]) by grass.itc.it (8.13.1/8.13.1) with ESMTP id l3KDiAoO027865; Fri, 20 Apr 2007 15:44:15 +0200
Received: from palm.hoeg.nl (palm.hoeg.nl [83.98.131.212]) by grass.itc.it (8.13.1/8.13.1) with ESMTP id l2QKs5W5013503 for <grass-dev@grass.itc.it>; Mon, 26 Mar 2007 22:54:05 +0200
[...]

the hold-up seems to have been in Italy.

apparently Glynn received it earlier:

CVS log for grass6/lib/gis/intr_char.c
Revision 2.2, Fri Mar 30 09:30:02 2007 UTC (3 weeks, 1 day ago)
Changes since 2.1: +9 -1 lines
Use termios if available

??
Hamish

Hamish wrote:

Maciej Sieczka wrote:
> My email server tends to re-send a random message from time to time.
> Ed's message was one such.

I've just received it too.

<from the OP email header info>
[...]
Received: from grass.itc.it (localhost.localdomain [127.0.0.1]) by grass.itc.it (8.13.1/8.13.1) with ESMTP id l3KDiAoO027865; Fri, 20 Apr 2007 15:44:15 +0200
Received: from palm.hoeg.nl (palm.hoeg.nl [83.98.131.212]) by grass.itc.it (8.13.1/8.13.1) with ESMTP id l2QKs5W5013503 for <grass-dev@grass.itc.it>; Mon, 26 Mar 2007 22:54:05 +0200
[...]

the hold-up seems to have been in Italy.

Same here:

Received: from grass.itc.it (localhost.localdomain [127.0.0.1])
  by grass.itc.it (8.13.1/8.13.1) with ESMTP id l3KDiAoO027865;
  Fri, 20 Apr 2007 15:44:15 +0200
Received: from palm.hoeg.nl (palm.hoeg.nl [83.98.131.212])
  by grass.itc.it (8.13.1/8.13.1) with ESMTP id l2QKs5W5013503
  for <grass-dev@grass.itc.it>; Mon, 26 Mar 2007 22:54:05 +0200

apparently Glynn received it earlier:

No, I received (and replied to) a similar message sent by the bug
tracker:

  http://grass.itc.it/pipermail/grass-dev/2007-March/030047.html
  http://grass.itc.it/pipermail/grass-dev/2007-March/030057.html

--
Glynn Clements <glynn@gclements.plus.com>

On Sun, Apr 22, 2007 at 12:14:01AM +1200, Hamish wrote:

Maciej Sieczka wrote:
> My email server tends to re-send a random message from time to time.
> Ed's message was one such.

I've just received it too.

<from the OP email header info>
[...]
Received: from grass.itc.it (localhost.localdomain [127.0.0.1]) by grass.itc.it (8.13.1/8.13.1) with ESMTP id l3KDiAoO027865; Fri, 20 Apr 2007 15:44:15 +0200
Received: from palm.hoeg.nl (palm.hoeg.nl [83.98.131.212]) by grass.itc.it (8.13.1/8.13.1) with ESMTP id l2QKs5W5013503 for <grass-dev@grass.itc.it>; Mon, 26 Mar 2007 22:54:05 +0200
[...]

the hold-up seems to have been in Italy.

Mea culpa (AFAIK):
This mail got trapped in Mailman since the sender wasn't subscribed
to the list. To not discard the mail, I approved it and wrote to
the person to subscribe to follow further conversation.

Usually I reject such mails. Probably I should have done so here, too.
But there us always the not so low probability that senders just
throw it away.

Well: sorry for the mess. But I don't manage to check the mailman
queues daily. I guess I will tend to always reject now.

Markus

apparently Glynn received it earlier:

CVS log for grass6/lib/gis/intr_char.c
Revision 2.2, Fri Mar 30 09:30:02 2007 UTC (3 weeks, 1 day ago)
Changes since 2.1: +9 -1 lines
Use termios if available

??
Hamish

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

--
Markus Neteler <neteler itc it> http://mpa.itc.it/markus/
FBK-irst - Centro per la Ricerca Scientifica e Tecnologica
MPBA - Predictive Models for Biol. & Environ. Data Analysis
Via Sommarive, 18 - 38050 Povo (Trento), Italy