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:
parent
33e353b2fc
commit
6e167c65df
@ -81,11 +81,32 @@ getpasswd(const char *prompt)
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
_cputs(prompt);
|
_cputs(prompt);
|
||||||
while((c = _getch()) != '\r')
|
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
|
#else
|
||||||
while((c = getc(fp)) != EOF && c != '\n')
|
while((c = getc(fp)) != EOF && c != '\n')
|
||||||
|
{
|
||||||
#endif
|
#endif
|
||||||
if(ptr < &pwbuf[MAX_PASS_LEN])
|
if(ptr < &pwbuf[MAX_PASS_LEN])
|
||||||
*ptr++ = c;
|
*ptr++ = c;
|
||||||
|
}
|
||||||
|
|
||||||
/* Null terminate the password.
|
/* Null terminate the password.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user