# HG changeset patch # User Mike Becker # Date 1444307153 -7200 # Node ID 2721730643196067341c0d400c0dffdc38505b76 # Parent ff854d3df20cc6286d38464a8ba2b620735bb3b4 implemented hidden password input for windows by using conio 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"); } diff -r ff854d3df20c -r 272173064319 mingw.mk --- a/mingw.mk Thu Oct 08 12:58:49 2015 +0200 +++ b/mingw.mk Thu Oct 08 14:25:53 2015 +0200 @@ -31,7 +31,7 @@ AR = ar RM = rm -CFLAGS = -std=gnu99 -c -O2 -m64 +CFLAGS = -std=gnu99 -c -O2 COFLAGS = -o LDFLAGS = LOFLAGS = -o @@ -43,5 +43,5 @@ APP_EXT = .exe DAV_CFLAGS = -I /mingw/include/libxml2 -DAV_LDFLAGS = -m64 -lcurl -lxml2 -lssl -lcrypto -lws2_32 -lgdi32 -lregex +DAV_LDFLAGS = -lcurl -lxml2 -lssl -lcrypto -lws2_32 -lgdi32 -lregex