[PATCH] Add a simple getpass() for MinGW

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

 



This should be replaced with a graphical getpass() at some stage.

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---

	I saw it coming that I had to do this.

 compat/mingw.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/compat/mingw.c b/compat/mingw.c
index d50186e..2ab5bbe 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1157,3 +1157,18 @@ int link(const char *oldpath, const char *newpath)
 	}
 	return 0;
 }
+
+char *getpass(const char *prompt)
+{
+	struct strbuf buf = STRBUF_INIT;
+
+	fputs(prompt, stderr);
+	for (;;) {
+		char c = _getch();
+		if (c == '\r' || c == '\n')
+			break;
+		strbuf_addch(&buf, c);
+	}
+	fputs("\n", stderr);
+	return strbuf_detach(&buf, NULL);
+}
-- 
1.6.2.1.613.g25746
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]