Fix compilation on Android with the bionic C library
[platform/upstream/glib.git] / gio / tests / gtlsconsoleinteraction.c
index 717a83c..81e9119 100644 (file)
 
 G_DEFINE_TYPE (GTlsConsoleInteraction, g_tls_console_interaction, G_TYPE_TLS_INTERACTION);
 
-#ifdef G_OS_WIN32
+#if defined(G_OS_WIN32) || defined(__BIONIC__)
 /* win32 doesn't have getpass() */
+#include <stdio.h>
+#ifndef BUFSIZ
+#define BUFSIZ 8192
+#endif
 static gchar *
 getpass (const gchar *prompt)
 {
@@ -53,7 +57,11 @@ getpass (const gchar *prompt)
 
   for (i = 0; i < BUFSIZ - 1; ++i)
     {
+#ifdef __BIONIC__
+      buf[i] = getc (stdin);
+#else
       buf[i] = _getch ();
+#endif
       if (buf[i] == '\r')
         break;
     }