From db5ad2e09a6b38e841463dbe7eb076492b62c948 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 18 Aug 2009 15:58:17 +0200 Subject: Mad funktioniert jetzt unter Windows --- src/Client/UserCommands.cpp | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'src/Client/UserCommands.cpp') diff --git a/src/Client/UserCommands.cpp b/src/Client/UserCommands.cpp index 21259d0..166a54d 100644 --- a/src/Client/UserCommands.cpp +++ b/src/Client/UserCommands.cpp @@ -20,12 +20,12 @@ #include "UserCommands.h" #include "Application.h" #include "CommandParser.h" +#include "PasswordReader.h" #include #include #include -#include namespace Mad { @@ -511,32 +511,8 @@ void UserCommands::setPasswordCommand(CommandParser *commandParser, const std::v return; } - // TODO Extract this as a method - struct termios termold, termnew; - - if(tcgetattr(STDIN_FILENO, &termold) != 0) { - std::cerr << "Unable to set up terminal for password entry." << std::endl; - return; - } - - termnew = termold; - termnew.c_lflag &= ~ECHO; - if(tcsetattr(STDIN_FILENO, TCSAFLUSH, &termnew) != 0) { - std::cerr << "Unable to set up terminal for password entry." << std::endl; - return; - } - - std::string password, password2; - - std::cout << "Password: " << std::flush; - std::getline(std::cin, password); - std::cout << std::endl; - - std::cout << "Verify password: " << std::flush; - std::getline(std::cin, password2); - std::cout << std::endl; - - tcsetattr(STDIN_FILENO, TCSAFLUSH, &termold); + std::string password = PasswordReader::readPassword("Password: "); + std::string password2 = PasswordReader::readPassword("Verify password: "); if(password != password2) { std::cerr << "Passwords do not match." << std::endl; -- cgit v1.2.3