#include <stdio.h>
#include <signal.h>
#include <fcntl.h>
+#include <stdlib.h>
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#endif
#endif
-void static save_tty_state(void);
-void static disable_tty_echo(void);
-void static restore_tty_state(void);
+static void save_tty_state(void);
+static void disable_tty_echo(void);
+static void restore_tty_state(void);
static RETSIGTYPE sigint_handler(int);
-char *getpassword(prompt)
-char *prompt;
+char *fm_getpassword(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);
+ fputs(GT_("ERROR: no support for getpassword() routine\n"),stderr);
exit(1);
#endif
#else
register int c;
FILE *fi;
static char pbuf[INPUT_BUF_SIZE];
- RETSIGTYPE (*sig)(int) = 0; /* initialization pacifies -Wall */
- RETSIGTYPE sigint_handler(int);
+ SIGHANDLERTYPE sig = 0; /* initialization pacifies -Wall */
int istty = isatty(0);
/* now that we have the current tty state, we can catch SIGINT and
exit gracefully */
- sig = signal(SIGINT, sigint_handler);
+ sig = set_signal_handler(SIGINT, sigint_handler);
/* turn off echo on the tty */
disable_tty_echo();
restore_tty_state();
/* restore previous state of SIGINT */
- signal(SIGINT, sig);
+ set_signal_handler(SIGINT, sig);
}
if (fi != stdin)
- fclose(fi);
+ fclose(fi); /* not checking should be safe, file mode was "r" */
return(pbuf);
#endif /* !(defined(HAVE_TCSETATTR) || ... */
static RETSIGTYPE sigint_handler(int signum)
{
+ (void)signum;
restore_tty_state();
- report(stderr, _("\nCaught SIGINT... bailing out.\n"));
+ report(stderr, GT_("\nCaught SIGINT... bailing out.\n"));
exit(1);
}