mirror of
https://github.com/ip7z/7zip.git
synced 2025-12-06 07:12:00 +01:00
Merge ece9df515b into 5e96a82794
This commit is contained in:
commit
5263f4c160
|
|
@ -57,9 +57,18 @@ NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#ifndef UNDER_CE
|
#ifndef UNDER_CE
|
||||||
#define MY_DISABLE_ECHO
|
#define MY_DISABLE_ECHO
|
||||||
|
#define MY_DISABLE_ECHO_WIN32
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef unix
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#define MY_DISABLE_ECHO
|
||||||
|
#define MY_DISABLE_ECHO_UNIX
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool GetPassword(CStdOutStream *outStream, UString &psw)
|
static bool GetPassword(CStdOutStream *outStream, UString &psw)
|
||||||
{
|
{
|
||||||
if (outStream)
|
if (outStream)
|
||||||
|
|
@ -72,7 +81,7 @@ static bool GetPassword(CStdOutStream *outStream, UString &psw)
|
||||||
outStream->Flush();
|
outStream->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MY_DISABLE_ECHO
|
#ifdef MY_DISABLE_ECHO_WIN32
|
||||||
|
|
||||||
const HANDLE console = GetStdHandle(STD_INPUT_HANDLE);
|
const HANDLE console = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
|
||||||
|
|
@ -90,7 +99,29 @@ static bool GetPassword(CStdOutStream *outStream, UString &psw)
|
||||||
const bool res = g_StdIn.ScanUStringUntilNewLine(psw);
|
const bool res = g_StdIn.ScanUStringUntilNewLine(psw);
|
||||||
if (wasChanged)
|
if (wasChanged)
|
||||||
SetConsoleMode(console, mode);
|
SetConsoleMode(console, mode);
|
||||||
|
|
||||||
|
#elif defined(MY_DISABLE_ECHO_UNIX)
|
||||||
|
|
||||||
|
int ifd = fileno(stdin);
|
||||||
|
bool wasChanged = false;
|
||||||
|
struct termios old_mode = {};
|
||||||
|
struct termios new_mode = {};
|
||||||
|
|
||||||
|
if (tcgetattr(ifd, &old_mode) == 0) {
|
||||||
|
new_mode = old_mode;
|
||||||
|
new_mode.c_lflag &= ~ECHO;
|
||||||
|
|
||||||
|
wasChanged = true;
|
||||||
|
|
||||||
|
tcsetattr(ifd, TCSAFLUSH, &new_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool res = g_StdIn.ScanUStringUntilNewLine(psw);
|
||||||
|
|
||||||
|
if (wasChanged) {
|
||||||
|
tcsetattr(ifd, TCSAFLUSH, &old_mode);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
const bool res = g_StdIn.ScanUStringUntilNewLine(psw);
|
const bool res = g_StdIn.ScanUStringUntilNewLine(psw);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue