db_bridge/console.cpp
changeset 20 5fec678f931b
parent 19 933d86c1ff71
child 21 403742321c65
--- a/db_bridge/console.cpp
+++ b/db_bridge/console.cpp
@@ -1,5 +1,14 @@
 #include <console.h>
+#include <cstdio>
 
+#ifdef WIN32
+#include <conio.h>
+int Console::getch ()
+{
+    return::getch ();
+}
+#else
+#include <termios.h>
 int Console::getch ()
 {
     static int ch = -1, fd = 0;
@@ -14,6 +23,7 @@
     tcsetattr (fd, TCSANOW, &alt);
     return ch;
 }
+#endif
 
 void Console::getpass (std::string & password)
 {
@@ -21,9 +31,9 @@
     int c;
     char buffer[17];
 
-    while ((c = getch ()) != '\n' && i < 17) {
+    while ((c = Console::getch ()) != '\n' && i < 17) {
         buffer[i++] = c;
-        std::cout << "*";
+        std::cout << "\b*";
     }
     buffer[i] = 0;