From cb899dc01de595859d46f3de6026859f627d2758 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 7 Sep 2009 12:46:28 -0400 Subject: [PATCH] Skip termios stuff in tests/get if building on Windows Yeah, yeah, I should add a HAVE_TERMIOS_H test. Whatever. http://bugzilla.gnome.org/show_bug.cgi?id=593845 --- tests/get.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/get.c b/tests/get.c index 9bb00a5..a654ec4 100644 --- a/tests/get.c +++ b/tests/get.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #ifdef HAVE_GNOME @@ -23,6 +22,10 @@ #include #endif +#ifdef G_OS_UNIX +#include +#endif + static SoupSession *session; static GMainLoop *loop; static gboolean debug = FALSE; @@ -80,13 +83,17 @@ authenticate (SoupSession *session, SoupMessage *msg, { char *uri; GSList *saved_users; +#ifdef G_OS_UNIX struct termios t; int old_lflag; +#endif char user[80], pwbuf[80]; const char *password; +#ifdef G_OS_UNIX if (tcgetattr (STDIN_FILENO, &t) != 0) return; +#endif uri = soup_uri_to_string (soup_message_get_uri (msg), FALSE); fprintf (stderr, "Authentication required for %s:\n", uri); @@ -120,9 +127,11 @@ authenticate (SoupSession *session, SoupMessage *msg, fprintf (stderr, " password: "); fflush (stderr); +#ifdef G_OS_UNIX old_lflag = t.c_lflag; t.c_lflag = (t.c_lflag | ICANON | ECHONL) & ~ECHO; tcsetattr (STDIN_FILENO, TCSANOW, &t); +#endif /* For some reason, fgets can return EINTR on * Linux if ECHO is false... @@ -131,8 +140,10 @@ authenticate (SoupSession *session, SoupMessage *msg, password = fgets (pwbuf, sizeof (pwbuf), stdin); while (password == NULL && errno == EINTR); +#ifdef G_OS_UNIX t.c_lflag = old_lflag; tcsetattr (STDIN_FILENO, TCSANOW, &t); +#endif if (!password || pwbuf[0] == '\n') return; -- 2.7.4