37 #ifndef HAVE_GETPASS_R
54 $DESCRIPTOR(ttdesc,
"TT");
57 sts =
sys$assign(&ttdesc, &chan,0,0);
59 sts =
sys$qiow(0, chan,
60 IO$_READPROMPT | IO$M_NOECHO,
61 &iosb, 0, 0, buffer, buflen, 0, 0,
62 prompt, strlen(prompt));
64 if((sts & 1) && (iosb.iosb$w_status&1))
65 buffer[iosb.iosb$w_bcnt] =
'\0';
67 sts =
sys$dassgn(chan);
73 # if !defined(HAVE_TCGETATTR) && !defined(HAVE_TCSETATTR)
74 # undef HAVE_TERMIOS_H
79 # define RETSIGTYPE void
98 #include "../lib/memdebug.h"
101 char *
getpass_r(
const char *prompt,
char *buffer,
size_t buflen)
104 char infp_fclose = 0;
113 #ifdef HAVE_TERMIOS_H
115 struct termios noecho;
117 # ifdef HAVE_TERMIO_H
119 struct termio noecho;
124 sigint = signal(SIGINT, SIG_IGN);
126 sigtstp = signal(SIGTSTP, SIG_IGN);
129 infp=fopen(
"/dev/tty",
"r");
141 #ifdef HAVE_TERMIOS_H
142 tcgetattr(outfd, &orig);
145 noecho.c_lflag &= ~ECHO;
146 tcsetattr(outfd, TCSANOW, &noecho);
148 # ifdef HAVE_TERMIO_H
149 ioctl(outfd, TCGETA, &orig);
151 noecho.c_lflag &= ~ECHO;
152 ioctl(outfd, TCSETA, &noecho);
157 fputs(prompt, outfp);
160 bytes_read=read(infd, buffer, buflen);
161 buffer[bytes_read > 0 ? (bytes_read -1) : 0] =
'\0';
164 #ifdef HAVE_TERMIOS_H
167 # ifdef HAVE_TERMIO_H
177 #ifdef HAVE_TERMIOS_H
178 tcsetattr(outfd, TCSAFLUSH, &orig);
180 # ifdef HAVE_TERMIO_H
181 ioctl(outfd, TCSETA, &orig);
186 signal(SIGINT, sigint);
188 signal(SIGTSTP, sigtstp);
200 char *
getpass_r(
const char *prompt,
char *buffer,
size_t buflen)
203 printf(
"%s", prompt);
205 for(i=0; i<buflen; i++) {
207 if ( buffer[i] ==
'\r' ) {
212 if ( buffer[i] ==
'\b')
229 char *getpass(
const char *prompt)
231 static char buf[256];
232 return getpass_r(prompt, buf,
sizeof(buf));
#define ioctl(a, b, c, d)
char * getpass_r(const char *prompt, char *buffer, size_t buflen)