aboutsummaryrefslogtreecommitdiffstats
path: root/src/passphrase.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-11-22 10:52:55 +0100
committerMattias Andrée <maandree@operamail.com>2013-11-22 10:52:55 +0100
commitc0b27bf6e2350a5eb543966a81d2930275ae8b67 (patch)
tree8c8169f7f3220173c427aabc6a69ea0de7f34428 /src/passphrase.c
parentoptionally do not hide the input (diff)
downloadlibpassphrase-c0b27bf6e2350a5eb543966a81d2930275ae8b67.tar.gz
libpassphrase-c0b27bf6e2350a5eb543966a81d2930275ae8b67.tar.bz2
libpassphrase-c0b27bf6e2350a5eb543966a81d2930275ae8b67.tar.xz
add option to print * for each char
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/passphrase.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/passphrase.c b/src/passphrase.c
index 43f1431..94922e4 100644
--- a/src/passphrase.c
+++ b/src/passphrase.c
@@ -64,6 +64,18 @@ char* passphrase_read(void)
break;
if (c != 0)
{
+#ifdef PASSPHRASE_STAR
+ if ((c == 8) || (c == 127))
+ {
+ if (len == 0)
+ continue;
+ printf("\033[D \033[D");
+ fflush(stdout);
+ *(rc + --len) = 0;
+ continue;
+ }
+ putchar('*');
+#endif
*(rc + len++) = c;
if (len == size)
if ((rc = realloc(rc, (size <<= 1L) * sizeof(char))) == NULL)
@@ -92,6 +104,9 @@ void passphrase_disable_echo(void)
tcgetattr(STDIN_FILENO, &stty);
saved_stty = stty;
stty.c_lflag &= ~ECHO;
+#ifdef PASSPHRASE_STAR
+ stty.c_lflag &= ~ICANON;
+#endif
tcsetattr(STDIN_FILENO, TCSAFLUSH, &stty);
#endif
}