Skip termios stuff in tests/get if building on Windows
authorDan Winship <danw@gnome.org>
Mon, 7 Sep 2009 16:46:28 +0000 (12:46 -0400)
committerDan Winship <danw@gnome.org>
Mon, 7 Sep 2009 16:46:28 +0000 (12:46 -0400)
Yeah, yeah, I should add a HAVE_TERMIOS_H test. Whatever.

http://bugzilla.gnome.org/show_bug.cgi?id=593845

tests/get.c

index 9bb00a5..a654ec4 100644 (file)
@@ -14,7 +14,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
-#include <termios.h>
 #include <unistd.h>
 
 #ifdef HAVE_GNOME
 #include <libsoup/soup.h>
 #endif
 
+#ifdef G_OS_UNIX
+#include <termios.h>
+#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;