Package: yafc
Version: 1.1.1.dfsg.1-4
Severity: important
Tags: patch

The building of Yafc for GNU/kFreeBSD fails due to missing
<termio.h> in FreeBSD and GNU/kFreeBSD. The following patch
suggests a migration away from the obsolete <termio.h> also
on GNU/Linux, and it also implements the necessary adaptions
for GNU/kFreeBSD, due to differing ioctl-calls.

Observe also that the manpage termios(3) is inaccurate
on GNU/kFreeBSD, since it mentions the invalid constants
OLCUC and IUCLC, of which the latter has to be covered
for in the present package.

I have tested the executable 'yafc' with 'kfreebsd-i386'
and 'amd64'. It works for FTP as well as for SSH. 


Best regards,

Mats Erik Andersson, fil. dr

2459 41E9 C420 3F6D F68B  2E88 F768 4541 F25B 5D41
Description: Use termios for terminal settings.
 A migration to <termios.h> will prepare adaptions
 for GNU/kFreeBSD. The old <termio.h> is obsolete.
 .
 The ioctl-calls have different names in GNU/Linux
 and GNU/kFreeBSD, so they must be redefined.
 .
 The implementation in FreeBSD and GNU/kFreeBSD lacks
 IUCLC and OLCUC, as they are not POSIX specified.
Author: Mats Erik Andersson <deb...@gisladisker.se>
Forwarded: no
Last-Update: 2010-10-29

--- yafc-1.1.1.dfsg.1/src/input.c.orig
+++ yafc-1.1.1.dfsg.1/src/input.c
@@ -76,7 +76,20 @@
 
 # include <fcntl.h> 
 # include <sys/ioctl.h> 
-# include <termio.h> 
+# include <termios.h> 
+
+# if __FreeBSD_kernel__
+#  ifndef IUCLC
+    /* Not implemented in FreeBSD 8.0!  */
+#   define IUCLC 0
+#  endif
+#  ifndef TCGETS
+#   define TCGETS TIOCGETA
+#  endif
+#  ifndef TCSETS
+#   define TCSETS TIOCGETA
+#  endif
+# endif /* __FreBSD_kernel__ */
 
 char *getpass_hook(const char *prompt)
 {
@@ -89,14 +102,14 @@
 #else
 	int c, n = 0;
 	char tmp[1024];
-	struct termio tbuf, tbufsave;
+	struct termios tbuf, tbufsave;
 	FILE *fd;
 
 	if((fd = fopen("/dev/tty", "rb")) == NULL) {
 		perror("fopen /dev/tty");
 		return NULL;
 	}
-	if (ioctl(fileno(fd), TCGETA, &tbuf) < 0) {
+	if (ioctl(fileno(fd), TCGETS, &tbuf) < 0) {
 		perror("ioctl get");
 		fclose(fd);
 		return NULL;
@@ -105,7 +118,7 @@
 	tbuf.c_iflag &= ~(IUCLC | ISTRIP | IXON | IXOFF);
 	tbuf.c_lflag &= ~(ICANON | ISIG | ECHO);
 	tbuf.c_cc[4] = 1; /* MIN */
-	if (ioctl(fileno(fd), TCSETA, &tbuf) < 0) {
+	if (ioctl(fileno(fd), TCSETS, &tbuf) < 0) {
 		perror("ioctl set");
 		fclose(fd);
 		return NULL;
@@ -132,7 +145,7 @@
 		fflush(stderr);
 	}
 	tmp[n] = '\0';
-	if (ioctl(fileno(fd), TCSETA, &tbufsave) < 0) {
+	if (ioctl(fileno(fd), TCSETS, &tbufsave) < 0) {
 		perror("ioctl restore");
 		fclose(fd);
 		return NULL;

Attachment: signature.asc
Description: Digital signature

Reply via email to