X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=getpass.c;h=3c19ba7c832fb9f3825c3b98c6d29e7cd5024351;hb=91b6ab63f35f8f11544b401fced7859d963ad06c;hp=4d0a75f74b080da6cb9e0d76992db5669d715b2b;hpb=836bbce0c428581f40d13d8c3d27d1c7adc31ccb;p=~andy%2Ffetchmail diff --git a/getpass.c b/getpass.c index 4d0a75f7..3c19ba7c 100644 --- a/getpass.c +++ b/getpass.c @@ -9,7 +9,7 @@ description: getpass() replacement which allows for long passwords. This version hacked by Wilfred Teiken, allowing the password to be piped to fetchmail. - + ***********************************************************************/ #include "config.h" @@ -17,10 +17,12 @@ #include #include #include +#include #if defined(HAVE_UNISTD_H) #include #endif #include "fetchmail.h" +#include "i18n.h" #define INPUT_BUF_SIZE PASSWORDLEN @@ -54,20 +56,19 @@ static int ttyfd; #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 @@ -75,8 +76,7 @@ char *prompt; 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); @@ -101,7 +101,7 @@ char *prompt; /* 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(); @@ -127,10 +127,10 @@ char *prompt; 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) || ... */ @@ -188,8 +188,10 @@ static void restore_tty_state(void) static RETSIGTYPE sigint_handler(int signum) { + (void)signum; restore_tty_state(); - error(1, 0, "\nCaught signal... bailing out."); + report(stderr, GT_("\nCaught SIGINT... bailing out.\n")); + exit(1); } /* getpass.c ends here */