[glib] gio/tests/gtlsconsoleinteraction: Work around missing getpass() on win32
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gio/tests/gtlsconsoleinteraction: Work around missing getpass() on win32
- Date: Sun, 28 Aug 2011 13:49:25 +0000 (UTC)
commit 41e4db80768e0155fdc5eaa71c59a7f4011e624a
Author: Kalev Lember <kalevlember gmail com>
Date: Mon Aug 15 16:09:18 2011 +0300
gio/tests/gtlsconsoleinteraction: Work around missing getpass() on win32
Loosely based on a patch by Sam Thursfield <ssssam gmail com>.
https://bugzilla.gnome.org/show_bug.cgi?id=656341
gio/tests/gtlsconsoleinteraction.c | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/gtlsconsoleinteraction.c b/gio/tests/gtlsconsoleinteraction.c
index c56ca6a..62e21c7 100644
--- a/gio/tests/gtlsconsoleinteraction.c
+++ b/gio/tests/gtlsconsoleinteraction.c
@@ -22,8 +22,14 @@
#include "config.h"
+#include <glib.h>
#include <string.h>
+#ifdef G_OS_WIN32
+#include <glib/gprintf.h>
+#include <conio.h>
+#endif
+
#include "gtlsconsoleinteraction.h"
/*
@@ -34,6 +40,31 @@
G_DEFINE_TYPE (GTlsConsoleInteraction, g_tls_console_interaction, G_TYPE_TLS_INTERACTION);
+#ifdef G_OS_WIN32
+/* win32 doesn't have getpass() */
+static gchar *
+getpass (const gchar *prompt)
+{
+ static gchar buf[BUFSIZ];
+ gint i;
+
+ g_printf ("%s", prompt);
+ fflush (stdout);
+
+ for (i = 0; i < BUFSIZ - 1; ++i)
+ {
+ buf[i] = _getch ();
+ if (buf[i] == '\r')
+ break;
+ }
+ buf[i] = '\0';
+
+ g_printf ("\n");
+
+ return &buf[0];
+}
+#endif
+
static GTlsInteractionResult
g_tls_console_interaction_ask_password (GTlsInteraction *interaction,
GTlsPassword *password,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]