#include <afsconfig.h>
#include <afs/param.h>
-RCSID("$Header$");
+RCSID
+ ("$Header$");
#include <mit-cpyright.h>
#include <des.h>
#endif
static int intrupt;
-#if defined(AFS_SGI_ENV) || defined (AFS_AIX_ENV) || defined(AFS_XBSD_ENV) /*|| defined (AFS_HPUX_ENV) || defined(AFS_SUN5_ENV)*/
+#if defined(AFS_SGI_ENV) || defined (AFS_AIX_ENV) || defined(AFS_XBSD_ENV) /*|| defined (AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) */
#undef BSDUNIX
#endif
int des_string_to_key(char *, des_cblock *);
/*** Routines ****************************************************** */
-int des_read_password(des_cblock *k, char *prompt, int verify)
+int
+des_read_password(des_cblock * k, char *prompt, int verify)
{
int ok;
char key_string[BUFSIZ];
des_string_to_key(key_string, k);
#ifdef BSDUNIX
-lose:
+ lose:
#endif
- memset(key_string, 0, sizeof (key_string));
+ memset(key_string, 0, sizeof(key_string));
return ok;
}
* Returns 0 on success, non-zero on failure.
*/
int
-des_read_pw_string(s,maxa,prompt,verify)
- char *s;
- int maxa;
- char *prompt;
- int verify;
+des_read_pw_string(s, maxa, prompt, verify)
+ char *s;
+ int maxa;
+ char *prompt;
+ int verify;
{
- int ok = 0, cnt1=0;
+ int ok = 0, cnt1 = 0;
char *ptr;
#if defined(AFS_HPUX_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
register int fno;
struct termio ttyb;
FILE *fi;
char savel, flags;
- void (*sig)();
+ void (*sig) ();
#endif
#endif
#ifdef AFS_NT40_ENV
if (maxa > BUFSIZ) {
return -1;
}
-
#if defined(AFS_HPUX_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
if ((fi = fopen("/dev/tty", "r")) == NULL)
- return -1;
- setbuf(fi, (char *)NULL); /* We don't want any buffering for our i/o. */
+ return -1;
+ setbuf(fi, (char *)NULL); /* We don't want any buffering for our i/o. */
/*
* Install signal handler for SIGINT so that we can restore
* the tty settings after we change them. The handler merely
newsig.sa_flags = 0;
sigaction(SIGINT, &newsig, &oldsig);
intrupt = 0;
-
+
/*
* Get the terminal characters (save for later restoration) and
* reset them so that echo is off
tcsetattr(fno, TCSAFLUSH, &ttyb);
#else
#if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
- if((fi = fopen("/dev/tty", "r")) == NULL) {
- return(-1);
- }
- else
- setbuf(fi, (char*)NULL);
+ if ((fi = fopen("/dev/tty", "r")) == NULL) {
+ return (-1);
+ } else
+ setbuf(fi, (char *)NULL);
sa.sa_handler = catch;
sa.sa_mask = 0;
sa.sa_flags = SA_INTERRUPT;
- (void) sigaction(SIGINT, &sa, &osa);
+ (void)sigaction(SIGINT, &sa, &osa);
intrupt = 0;
- (void) ioctl(fileno(fi), TCGETS, &ttyb);
+ (void)ioctl(fileno(fi), TCGETS, &ttyb);
flags = ttyb.c_lflag;
ttyb.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
- (void) ioctl(fileno(fi), TCSETSF, &ttyb);
+ (void)ioctl(fileno(fi), TCSETSF, &ttyb);
#else
#ifdef BSDUNIX
/* XXX assume jmp_buf is typedef'ed to an array */
memcpy((char *)env, (char *)old_env, sizeof(env));
if (setjmp(env))
goto lose;
- /* save terminal state*/
- if (ioctl(0,TIOCGETP,(char *)&tty_state) == -1)
+ /* save terminal state */
+ if (ioctl(0, TIOCGETP, (char *)&tty_state) == -1)
return -1;
push_signals();
/* Turn off echo */
- memcpy(&echo_off_tty_state, &tty_state, sizeof (tty_state));
+ memcpy(&echo_off_tty_state, &tty_state, sizeof(tty_state));
echo_off_tty_state.sg_flags &= ~ECHO;
- if (ioctl(0,TIOCSETP,(char *)&echo_off_tty_state) == -1)
+ if (ioctl(0, TIOCSETP, (char *)&echo_off_tty_state) == -1)
return -1;
#else
#if defined (AFS_AIX_ENV) || defined (AFS_HPUX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV)
- if((fi = fopen("/dev/tty", "r+")) == NULL)
- return(-1);
- else
- setbuf(fi, (char*)NULL);
- sig = signal(SIGINT, catch);
- intrupt = 0;
- (void) ioctl(fileno(fi), TCGETA, &ttyb);
- savel = ttyb.c_line;
- ttyb.c_line = 0;
- flags = ttyb.c_lflag;
- ttyb.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
- (void) ioctl(fileno(fi), TCSETAF, &ttyb);
+ if ((fi = fopen("/dev/tty", "r+")) == NULL)
+ return (-1);
+ else
+ setbuf(fi, (char *)NULL);
+ sig = signal(SIGINT, catch);
+ intrupt = 0;
+ (void)ioctl(fileno(fi), TCGETA, &ttyb);
+ savel = ttyb.c_line;
+ ttyb.c_line = 0;
+ flags = ttyb.c_lflag;
+ ttyb.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
+ (void)ioctl(fileno(fi), TCSETAF, &ttyb);
#else
#ifdef AFS_NT40_ENV
/* turn off console input echoing */
#endif
#endif
while (!ok) {
- (void) printf(prompt);
- (void) fflush(stdout);
+ (void)printf(prompt);
+ (void)fflush(stdout);
#ifdef CROSSMSDOS
- h19line(s,sizeof(s),0);
+ h19line(s, sizeof(s), 0);
if (!strlen(s))
continue;
#else
*ptr = '\0';
#endif
if (verify) {
- printf("\nVerifying, please re-enter %s",prompt);
- (void) fflush(stdout);
+ printf("\nVerifying, please re-enter %s", prompt);
+ (void)fflush(stdout);
#ifdef CROSSMSDOS
- h19line(key_string,sizeof(key_string),0);
+ h19line(key_string, sizeof(key_string), 0);
if (!strlen(key_string))
continue;
#else
clearerr(stdin);
continue;
}
- if ((ptr = strchr(key_string, '\n')))
- *ptr = '\0';
+ if ((ptr = strchr(key_string, '\n')))
+ *ptr = '\0';
#endif
- if (strcmp(s,key_string)) {
+ if (strcmp(s, key_string)) {
printf("\n\07\07Mismatch - try again\n");
- (void) fflush(stdout);
+ (void)fflush(stdout);
continue;
}
}
}
#ifdef BSDUNIX
-lose:
+ lose:
#endif
if (!ok)
memset(s, 0, maxa);
tcsetattr(fno, TCSANOW, &save_ttyb);
sigaction(SIGINT, &oldsig, NULL);
if (fi != stdin)
- fclose(fi);
-
+ fclose(fi);
+
/*
* If we got a SIGINT while we were doing things, send the SIGINT
* to ourselves so that the calling program receives it (since we
* were intercepting it for a period of time.)
*/
if (intrupt)
- kill(getpid(), SIGINT);
+ kill(getpid(), SIGINT);
#else
#if defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
ttyb.c_lflag = flags;
- (void) ioctl(fileno(fi), TCSETSW, &ttyb);
- (void) sigaction(SIGINT, &osa, (struct sigaction *)NULL);
- if(fi != stdin)
- (void) fclose(fi);
+ (void)ioctl(fileno(fi), TCSETSW, &ttyb);
+ (void)sigaction(SIGINT, &osa, (struct sigaction *)NULL);
+ if (fi != stdin)
+ (void)fclose(fi);
#else
#ifdef BSDUNIX
- if (ioctl(0,TIOCSETP,(char *)&tty_state))
+ if (ioctl(0, TIOCSETP, (char *)&tty_state))
ok = 0;
pop_signals();
memcpy((char *)old_env, (char *)env, sizeof(env));
#if defined (AFS_AIX_ENV) /*|| defined (AFS_HPUX_ENV)*/ || defined(AFS_SGI_ENV) || defined(AFS_LINUX20_ENV)
ttyb.c_lflag = flags;
ttyb.c_line = savel;
- (void) ioctl(fileno(fi), TCSETAW, &ttyb);
- (void) signal(SIGINT, sig);
- if(fi != stdin)
- (void) fclose(fi);
- if(intrupt)
- (void) kill(getpid(), SIGINT);
+ (void)ioctl(fileno(fi), TCSETAW, &ttyb);
+ (void)signal(SIGINT, sig);
+ if (fi != stdin)
+ (void)fclose(fi);
+ if (intrupt)
+ (void)kill(getpid(), SIGINT);
#else
#ifdef AFS_NT40_ENV
/* restore console to original mode settings */
#endif
#endif
if (verify)
- memset(key_string, 0, sizeof (key_string));
- s[maxa-1] = 0; /* force termination */
+ memset(key_string, 0, sizeof(key_string));
+ s[maxa - 1] = 0; /* force termination */
return !ok; /* return nonzero if not okay */
}
* one set saved....
*/
#ifdef mips
-void static (*old_sigfunc[NSIG])();
+void static (*old_sigfunc[NSIG]) ();
#else
-static sigtype (*old_sigfunc[NSIG])();
+static sigtype(*old_sigfunc[NSIG]) ();
#endif
-static push_signals()
+static
+push_signals()
{
register i;
for (i = 0; i < NSIG; i++)
- old_sigfunc[i] = signal(i,sig_restore);
+ old_sigfunc[i] = signal(i, sig_restore);
}
-static pop_signals()
+static
+pop_signals()
{
register i;
for (i = 0; i < NSIG; i++)
- (void) signal(i,old_sigfunc[i]);
+ (void)signal(i, old_sigfunc[i]);
}
static sigtype
sig_restore()
{
- longjmp(env,1);
+ longjmp(env, 1);
}
#endif
static void
catch(int junk)
{
- ++intrupt;
+ ++intrupt;
}
#endif