| 110 | */ |
| 111 | |
| 112 | static void get_password(char *to,uint length,int fd, my_bool echo) |
| 113 | { |
| 114 | char *pos=to,*end=to+length; |
| 115 | |
| 116 | for (;;) |
| 117 | { |
| 118 | char tmp; |
| 119 | if (my_read(fd,&tmp,1,MYF(0)) != 1) |
| 120 | break; |
| 121 | if (tmp == '\b' || (int) tmp == 127) |
| 122 | { |
| 123 | if (pos != to) |
| 124 | { |
| 125 | if (echo) |
| 126 | { |
| 127 | fputs("\b \b",stderr); |
| 128 | fflush(stderr); |
| 129 | } |
| 130 | pos--; |
| 131 | continue; |
| 132 | } |
| 133 | } |
| 134 | if (tmp == '\n' || tmp == '\r' || tmp == 3) |
| 135 | break; |
| 136 | if (iscntrl(tmp) || pos == end) |
| 137 | continue; |
| 138 | if (echo) |
| 139 | { |
| 140 | fputc('*',stderr); |
| 141 | fflush(stderr); |
| 142 | } |
| 143 | *(pos++) = tmp; |
| 144 | } |
| 145 | while (pos != to && isspace(pos[-1]) == ' ') |
| 146 | pos--; /* Allow dummy space at end */ |
| 147 | *pos=0; |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | #endif /* ! HAVE_GETPASS */ |
| 152 |
no test coverage detected