FILE *tty=NULL; char *p;
if (setjmp(save)) { ok=0; goto error; }  number=5; ok=0; ps=0; is_a_tty=1; tty=NULL;
int des_read_pw(buf, buff, size, prompt, verify)char *buf;char *buff;int size;const char *prompt;int verify;	{#ifdef VMS	struct IOSB iosb;	$DESCRIPTOR(terminal,"TT");	long tty_orig[3], tty_new[3];	long status;	unsigned short channel = 0;#else#ifndef MSDOS	TTY_STRUCT tty_orig,tty_new;#endif#endif	int number=5;	int ok=0;	int ps=0;	int is_a_tty=1;	FILE *tty=NULL;	char *p;#ifndef MSDOS	if ((tty=fopen("/dev/tty","r")) == NULL)		tty=stdin;#else /* MSDOS */	if ((tty=fopen("con","r")) == NULL)		tty=stdin;#endif /* MSDOS */#if defined(TTY_get) && !defined(VMS)	if (TTY_get(fileno(tty),&tty_orig) == -1)		{#ifdef ENOTTY		if (errno == ENOTTY)			is_a_tty=0;		else#endif#ifdef EINVAL		/* Ariel Glenn ariel@columbia.edu reports that solaris		 * can return EINVAL instead.  This should be ok */		if (errno == EINVAL)			is_a_tty=0;		else#endif			return(-1);		}	memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));#endif#ifdef VMS	status = SYS$ASSIGN(&terminal,&channel,0,0);	if (status != SS$_NORMAL)		return(-1);	status=SYS$QIOW(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);	if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))		return(-1);#endif	if (setjmp(save))		{		ok=0;		goto error;		}	pushsig();	ps=1;#ifdef TTY_FLAGS	tty_new.TTY_FLAGS &= ~ECHO;#endif#if defined(TTY_set) && !defined(VMS)	if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1))		return(-1);#endif#ifdef VMS	tty_new[0] = tty_orig[0];	tty_new[1] = tty_orig[1] | TT$M_NOECHO;	tty_new[2] = tty_orig[2];	status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);	if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))		return(-1);#endif	ps=2;	while ((!ok) && (number--))		{		fputs(prompt,stderr);		fflush(stderr);		buf[0]='\0';		fgets(buf,size,tty);		if (feof(tty)) goto error;		if (ferror(tty)) goto error;		if ((p=(char *)strchr(buf,'\n')) != NULL)			*p='\0';		else	read_till_nl(tty);		if (verify)			{			fprintf(stderr,"\nVerifying password - %s",prompt);			fflush(stderr);			buff[0]='\0';			fgets(buff,size,tty);			if (feof(tty)) goto error;			if ((p=(char *)strchr(buff,'\n')) != NULL)				*p='\0';			else	read_till_nl(tty);							if (strcmp(buf,buff) != 0)				{				fprintf(stderr,"\nVerify failure");				fflush(stderr);				break;				/* continue; */				}			}		ok=1;		}error:	fprintf(stderr,"\n");#ifdef DEBUG	perror("fgets(tty)");#endif	/* What can we do if there is an error? */#if defined(TTY_set) && !defined(VMS) 	if (ps >= 2) TTY_set(fileno(tty),&tty_orig);#endif#ifdef VMS	if (ps >= 2)		status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0			,tty_orig,12,0,0,0,0);#endif		if (ps >= 1) popsig();	if (stdin != tty) fclose(tty);#ifdef VMS	status = SYS$DASSGN(channel);#endif	return(!ok);	}