Added handling of Backspace and Ctrl-U in the Win32 handling of get_passswd.

git-svn-id: file:///home/mbr/svn/fwknop/trunk@105 510a4753-2344-4c79-9c09-4d669213fbeb
This commit is contained in:
Damien Stuart 2009-06-14 16:38:17 +00:00
parent 33e353b2fc
commit 6e167c65df

View File

@ -81,11 +81,32 @@ getpasswd(const char *prompt)
#ifdef WIN32
_cputs(prompt);
while((c = _getch()) != '\r')
{
/* Handle a backspace without backing up too far.
*/
if(c == '\b')
{
if(ptr != pwbuf)
*ptr--;
continue;
}
/* Handle a Ctrl-U to clear the password entry and start over
* (like it works under Unix).
*/
if(c == 0x15)
{
ptr = pwbuf;
continue;
}
#else
while((c = getc(fp)) != EOF && c != '\n')
{
#endif
if(ptr < &pwbuf[MAX_PASS_LEN])
*ptr++ = c;
}
/* Null terminate the password.
*/