| 65 | the keyboard */ |
| 66 | |
| 67 | char *get_tty_password_ext(const char *opt_message, |
| 68 | strdup_handler_t strdup_function) |
| 69 | { |
| 70 | char to[80]; |
| 71 | char *pos=to,*end=to+sizeof(to)-1; |
| 72 | int i=0; |
| 73 | DBUG_ENTER("get_tty_password_ext"); |
| 74 | _cputs(opt_message ? opt_message : "Enter password: "); |
| 75 | for (;;) |
| 76 | { |
| 77 | char tmp; |
| 78 | tmp=_getch(); |
| 79 | if (tmp == '\b' || (int) tmp == 127) |
| 80 | { |
| 81 | if (pos != to) |
| 82 | { |
| 83 | _cputs("\b \b"); |
| 84 | pos--; |
| 85 | continue; |
| 86 | } |
| 87 | } |
| 88 | if (tmp == '\n' || tmp == '\r' || tmp == 3) |
| 89 | break; |
| 90 | if (iscntrl(tmp) || pos == end) |
| 91 | continue; |
| 92 | _cputs("*"); |
| 93 | *(pos++) = tmp; |
| 94 | } |
| 95 | while (pos != to && isspace(pos[-1]) == ' ') |
| 96 | pos--; /* Allow dummy space at end */ |
| 97 | *pos=0; |
| 98 | _cputs("\n"); |
| 99 | DBUG_RETURN(strdup_function(to,MYF(MY_FAE))); |
| 100 | } |
| 101 | |
| 102 | #else |
| 103 |
no test coverage detected