MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / get_password

Function get_password

client/get_password.c:112–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110*/
111
112static 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

Callers 1

get_tty_password_extFunction · 0.85

Calls 1

my_readFunction · 0.85

Tested by

no test coverage detected