Fixes for Windows XP
This commit is contained in:
parent
bfac7d637f
commit
db65e4f537
@ -62,12 +62,13 @@
|
|||||||
/* were just going to fake it here and get input from the keyboard */
|
/* were just going to fake it here and get input from the keyboard */
|
||||||
void get_tty_password_buff(const char *opt_message, char *to, size_t length)
|
void get_tty_password_buff(const char *opt_message, char *to, size_t length)
|
||||||
{
|
{
|
||||||
HANDLE consoleinput;
|
HANDLE consoleinput;
|
||||||
DWORD oldstate;
|
DWORD oldstate;
|
||||||
char *pos=to,*end=to+length-1;
|
char *pos=to,*end=to+length-1;
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
consoleinput= CreateFile("CONIN$", GENERIC_WRITE | GENERIC_READ, 0 , NULL, 0, 0, NULL);
|
consoleinput= CreateFile("CONIN$", GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ ,
|
||||||
|
NULL, OPEN_EXISTING, 0, NULL);
|
||||||
if (consoleinput == NULL || consoleinput == INVALID_HANDLE_VALUE)
|
if (consoleinput == NULL || consoleinput == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
/* This is a GUI application or service without console input, bail out. */
|
/* This is a GUI application or service without console input, bail out. */
|
||||||
@ -76,11 +77,11 @@ void get_tty_password_buff(const char *opt_message, char *to, size_t length)
|
|||||||
}
|
}
|
||||||
_cputs(opt_message ? opt_message : "Enter password: ");
|
_cputs(opt_message ? opt_message : "Enter password: ");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Switch to raw mode (no line input, no echo input).
|
Switch to raw mode (no line input, no echo input).
|
||||||
Allow Ctrl-C handler with ENABLE_PROCESSED_INPUT.
|
Allow Ctrl-C handler with ENABLE_PROCESSED_INPUT.
|
||||||
*/
|
*/
|
||||||
GetConsoleMode(consoleinput, &oldstate);
|
GetConsoleMode(consoleinput, &oldstate);
|
||||||
SetConsoleMode(consoleinput, ENABLE_PROCESSED_INPUT);
|
SetConsoleMode(consoleinput, ENABLE_PROCESSED_INPUT);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user