mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-05-21 12:24:29 +02:00
Allow get password to work in Windows tests
This commit is contained in:
parent
2bbddcaf98
commit
d6c1c381f2
|
|
@ -61,14 +61,19 @@ static int gets_quiet(char *s, int len)
|
||||||
|
|
||||||
memset(s, 0, len);
|
memset(s, 0, len);
|
||||||
h = GetStdHandle(STD_INPUT_HANDLE);
|
h = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
GetConsoleMode(h, &con_orig);
|
if(GetConsoleMode(h, &con_orig)){
|
||||||
con_quiet = con_orig;
|
con_quiet = con_orig;
|
||||||
con_quiet &= ~ENABLE_ECHO_INPUT;
|
con_quiet &= ~ENABLE_ECHO_INPUT;
|
||||||
con_quiet |= ENABLE_LINE_INPUT;
|
con_quiet |= ENABLE_LINE_INPUT;
|
||||||
SetConsoleMode(h, con_quiet);
|
SetConsoleMode(h, con_quiet);
|
||||||
if(!ReadConsole(h, s, len, &read_len, NULL)){
|
if(!ReadConsole(h, s, len, &read_len, NULL)){
|
||||||
|
SetConsoleMode(h, con_orig);
|
||||||
|
fprintf(stderr, "ReadConsole\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
SetConsoleMode(h, con_orig);
|
SetConsoleMode(h, con_orig);
|
||||||
return 1;
|
}else{
|
||||||
|
fgets(s, len, stdin);
|
||||||
}
|
}
|
||||||
while(s[strlen(s)-1] == 10 || s[strlen(s)-1] == 13){
|
while(s[strlen(s)-1] == 10 || s[strlen(s)-1] == 13){
|
||||||
s[strlen(s)-1] = 0;
|
s[strlen(s)-1] = 0;
|
||||||
|
|
@ -76,8 +81,6 @@ static int gets_quiet(char *s, int len)
|
||||||
if(strlen(s) == 0){
|
if(strlen(s) == 0){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
SetConsoleMode(h, con_orig);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
struct termios ts_quiet;
|
struct termios ts_quiet;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue