[gtk-vnc] Make use of termios.h conditional, to fix win32 builds



commit ab2d034a86f34716e3c08929439fae1b3f190257
Author: Daniel P. Berrange <dan berrange com>
Date:   Sun Jul 11 18:27:34 2010 +0100

    Make use of termios.h conditional, to fix win32 builds
    
    Win32 does not have termios support to disable terminal echo.
    Disable that code until a better solution can be found.

 configure.ac        |    2 +-
 tools/gvnccapture.c |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 02ebf49..5d055d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -98,7 +98,7 @@ AC_SUBST([GTK_REQUIRED])
 AM_CONDITIONAL([HAVE_GTK_2],[test "$with_gtk" = "2.0"])
 AM_CONDITIONAL([HAVE_GTK_3],[test "$with_gtk" = "3.0"])
 
-AC_CHECK_HEADERS([pwd.h winsock2.h])
+AC_CHECK_HEADERS([pwd.h winsock2.h termios.h])
 
 AC_ARG_WITH(python,
 [  --with-python           build python bindings],
diff --git a/tools/gvnccapture.c b/tools/gvnccapture.c
index 67c274a..5617b6b 100644
--- a/tools/gvnccapture.c
+++ b/tools/gvnccapture.c
@@ -88,7 +88,9 @@ vinagre(1)
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#ifdef HAVE_TERMIOS_H
 #include <termios.h>
+#endif
 #include <unistd.h>
 #include <glib/gi18n.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
@@ -136,7 +138,9 @@ static const guint preferable_auths[] = {
 static gchar *
 do_vnc_get_credential(const gchar *prompt, gboolean doecho)
 {
+#ifdef HAVE_TERMIOS_H
 	struct termios old, new;
+#endif
 	gchar *res = NULL;
 	size_t n;
 	ssize_t len;
@@ -144,6 +148,7 @@ do_vnc_get_credential(const gchar *prompt, gboolean doecho)
 	printf("%s", prompt);
 	fflush(stdout);
 
+#ifdef HAVE_TERMIOS_H
 	/* Turn echoing off and fail if we can't. */
 	if (!doecho && tcgetattr (fileno (stdin), &old) != 0)
 		return NULL;
@@ -151,6 +156,9 @@ do_vnc_get_credential(const gchar *prompt, gboolean doecho)
 	new.c_lflag &= ~ECHO;
 	if (!doecho && tcsetattr(fileno(stdin), TCSAFLUSH, &new) != 0)
 		return NULL;
+#else
+	doecho = TRUE; /* Avoid unused parameter compile warning */
+#endif
 
 	/* Read the password. */
 	if ((len = getline(&res, &n, stdin)) < 0)
@@ -159,11 +167,13 @@ do_vnc_get_credential(const gchar *prompt, gboolean doecho)
 	if (res && res[len-1] == '\n')
 		res[len-1] = '\0';
 
+#ifdef HAVE_TERMIOS_H
 	/* Restore terminal. */
 	if (!doecho) {
 		printf("\n");
 		(void) tcsetattr(fileno (stdin), TCSAFLUSH, &old);
 	}
+#endif
 
 	return res;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]