-#if defined(HAVE_TCSETATTR)
- static struct termios termb;
- static tcflag_t flags;
-#else
-#if defined(HAVE_TERMIO_H)
- static struct termio termb;
- static unsigned short flags;
-#else
-#if defined(HAVE_STTY)
- static struct sgttyb ttyb;
- static int flags;
-#endif
-#endif
-#endif
-
-void save_tty_state();
-void disable_tty_echo();
-void restore_tty_state();
-
-char *
-getpassword(prompt)
-char *prompt;
-{
-
-#if !(defined(HAVE_TCSETATTR) || defined(HAVE_TERMIO_H) || defined(HAVE_STTY))
-
-#if defined(HAVE_GETPASS)
- char *getpass();
- return getpass(prompt);
-#else
- fputs("ERROR: no support for getpassword() routine\n",stderr);
- exit(1);
-#endif
-
-#endif /* !(defined(HAVE_TCSETATTR) || ... */
-
- register char *p;
- register c;
- FILE *fi;
- static char pbuf[INPUT_BUF_SIZE];
- RETSIGTYPE (*sig)();
- RETSIGTYPE sigint_handler();
-
-
- /* get the file descriptor for the input device */
- if ((fi = fdopen(open("/dev/tty", 2), "r")) == NULL)
- fi = stdin;
- else
- setbuf(fi, (char *)NULL);
-
- /* store descriptor for the tty */
- ttyfd = fileno(fi);
-
- /* preserve tty state before turning off echo */
- save_tty_state();
-
- /* now that we have the current tty state, we can catch SIGINT and
- exit gracefully */
- sig = signal(SIGINT, sigint_handler);