Loading src/getpass.c +17 −8 Original line number Original line Diff line number Diff line Loading @@ -136,18 +136,27 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen) #include <nwconio.h> #include <nwconio.h> char *getpass_r(const char *prompt, char *buffer, size_t buflen) char *getpass_r(const char *prompt, char *buffer, size_t buflen) { { int i = 0; size_t i = 0; int c; printf("%s", prompt); printf("%s", prompt); do { do { c = getch(); buffer[i++] = getch(); if (c != 13) { if (buffer[i-1] == '\b') { buffer[i] = c; /* remove this letter and if this is not the first key, i++; remove the previous one as well */ printf("%s", "*"); if (i > 1) { printf("\b \b"); i = i - 2; } else { RingTheBell(); i = i - 1; } } } while ((c != 13) && (i < buflen)); } else if (buffer[i-1] != 13) { putchar('*'); } } while ((buffer[i-1] != 13) && (i < buflen)); buffer[i-1] = 0; printf("\r\n"); return buffer; return buffer; } } #endif /* __NOVELL_LIBC__ */ #endif /* __NOVELL_LIBC__ */ Loading Loading
src/getpass.c +17 −8 Original line number Original line Diff line number Diff line Loading @@ -136,18 +136,27 @@ char *getpass_r(const char *prompt, char *buffer, size_t buflen) #include <nwconio.h> #include <nwconio.h> char *getpass_r(const char *prompt, char *buffer, size_t buflen) char *getpass_r(const char *prompt, char *buffer, size_t buflen) { { int i = 0; size_t i = 0; int c; printf("%s", prompt); printf("%s", prompt); do { do { c = getch(); buffer[i++] = getch(); if (c != 13) { if (buffer[i-1] == '\b') { buffer[i] = c; /* remove this letter and if this is not the first key, i++; remove the previous one as well */ printf("%s", "*"); if (i > 1) { printf("\b \b"); i = i - 2; } else { RingTheBell(); i = i - 1; } } } while ((c != 13) && (i < buflen)); } else if (buffer[i-1] != 13) { putchar('*'); } } while ((buffer[i-1] != 13) && (i < buflen)); buffer[i-1] = 0; printf("\r\n"); return buffer; return buffer; } } #endif /* __NOVELL_LIBC__ */ #endif /* __NOVELL_LIBC__ */ Loading