24 #ifndef HAVE_GETPASS_R 33 #elif defined(HAVE_TERMIO_H) 48 # ifdef __NOVELL_LIBC__ 74 short int iosb$w_status;
75 short int iosb$w_bcnt;
79 $DESCRIPTOR(ttdesc,
"TT");
82 sts =
sys$assign(&ttdesc, &chan, 0, 0);
84 sts =
sys$qiow(0, chan,
85 IO$_READPROMPT | IO$M_NOECHO,
86 &iosb, 0, 0, buffer, buflen, 0, 0,
87 prompt, strlen(prompt));
89 if((sts & 1) && (iosb.iosb$w_status & 1))
90 buffer[iosb.iosb$w_bcnt] =
'\0';
92 sts =
sys$dassgn(chan);
100 # define getch() getchar() 103 #if defined(WIN32) || defined(__SYMBIAN32__) 105 char *
getpass_r(
const char *prompt,
char *buffer,
size_t buflen)
108 fputs(prompt, stderr);
110 for(i = 0; i < buflen; i++) {
111 buffer[
i] = (char)getch();
112 if(buffer[i] ==
'\r' || buffer[i] ==
'\n') {
117 if(buffer[i] ==
'\b')
120 i = i - (i >= 1 ? 2 : 1);
122 #ifndef __SYMBIAN32__ 128 buffer[buflen-1] =
'\0';
137 #ifdef __NOVELL_LIBC__ 138 char *
getpass_r(
const char *prompt,
char *buffer,
size_t buflen)
140 return getpassword(prompt, buffer, buflen);
143 char *
getpass_r(
const char *prompt,
char *buffer,
size_t buflen)
149 buffer[i++] = getch();
150 if(buffer[i-1] ==
'\b') {
162 else if(buffer[i-1] != 13)
165 }
while((buffer[i-1] != 13) && (i < buflen));
176 #ifdef HAVE_TERMIOS_H 177 # define struct_term struct termios 178 #elif defined(HAVE_TERMIO_H) 179 # define struct_term struct termio 187 static struct_term withecho;
188 static struct_term noecho;
193 #ifdef HAVE_TERMIOS_H 194 tcgetattr(fd, &withecho);
196 noecho.c_lflag &= ~ECHO;
197 tcsetattr(fd, TCSANOW, &noecho);
198 #elif defined(HAVE_TERMIO_H) 199 ioctl(fd, TCGETA, &withecho);
201 noecho.c_lflag &= ~ECHO;
202 ioctl(fd, TCSETA, &noecho);
212 #ifdef HAVE_TERMIOS_H 213 tcsetattr(fd, TCSAFLUSH, &withecho);
214 #elif defined(HAVE_TERMIO_H) 215 ioctl(fd, TCSETA, &withecho);
228 int fd = open(
"/dev/tty", O_RDONLY);
234 fputs(prompt, stderr);
235 nread = read(fd, password, buflen);
237 password[--nread] =
'\0';