diff -r ff854d3df20c -r 272173064319 libidav/utils.c --- a/libidav/utils.c Thu Oct 08 12:58:49 2015 +0200 +++ b/libidav/utils.c Thu Oct 08 14:25:53 2015 +0200 @@ -37,8 +37,12 @@ #include #include -#ifndef _WIN32 +#ifdef _WIN32 +#include +#define getpasswordchar() getch() +#else #include +#define getpasswordchar() getchar() #endif #include @@ -447,10 +451,8 @@ fprintf(stderr, "%s", prompt); fflush(stderr); +#ifndef _WIN32 // hide terminal input -#ifdef _WIN32 - // TODO -#else struct termios oflags, nflags; tcgetattr(fileno(stdin), &oflags); nflags = oflags; @@ -464,18 +466,17 @@ // read password input UcxBuffer *buf = ucx_buffer_new(NULL, 128, UCX_BUFFER_AUTOEXTEND); int c = 0; - while((c = getchar()) != EOF) { - if(c == '\n') { + while((c = getpasswordchar()) != EOF) { + if(c == '\n' || c == '\r') { break; } ucx_buffer_putc(buf, c); } ucx_buffer_putc(buf, 0); + fflush(stdin); +#ifndef _WIN32 // restore terminal settings -#ifdef _WIN32 - // TODO -#else if (tcsetattr(fileno(stdin), TCSANOW, &oflags) != 0) { perror("tcsetattr"); }