aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGunter Knauf <gk@gknw.de>2007-07-06 14:58:59 +0000
committerGunter Knauf <gk@gknw.de>2007-07-06 14:58:59 +0000
commit836ffbfc222db3377b605b07b244023dc4b4aaf7 (patch)
tree5dcb5d7448452a3037a6841b26c10d4ca25a3268 /src
parent7fd4f82a45e64c8cf53a4506082ea3c0a8055354 (diff)
fixed NetWare CLIB implementation of getpass_r()
Diffstat (limited to 'src')
-rw-r--r--src/getpass.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/getpass.c b/src/getpass.c
index 244b29b9e..26d7433ea 100644
--- a/src/getpass.c
+++ b/src/getpass.c
@@ -136,18 +136,27 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen)
#include <nwconio.h>
char *getpass_r(const char *prompt, char *buffer, size_t buflen)
{
- int i = 0;
- int c;
+ size_t i = 0;
printf("%s", prompt);
do {
- c = getch();
- if (c != 13) {
- buffer[i] = c;
- i++;
- printf("%s", "*");
+ buffer[i++] = getch();
+ if (buffer[i-1] == '\b') {
+ /* remove this letter and if this is not the first key,
+ remove the previous one as well */
+ if (i > 1) {
+ printf("\b \b");
+ i = i - 2;
+ } else {
+ RingTheBell();
+ i = i - 1;
+ }
+ } else if (buffer[i-1] != 13) {
+ putchar('*');
}
- } while ((c != 13) && (i < buflen));
+ } while ((buffer[i-1] != 13) && (i < buflen));
+ buffer[i-1] = 0;
+ printf("\r\n");
return buffer;
}
#endif /* __NOVELL_LIBC__ */