projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BSD 4_3 release
[unix-history]
/
usr
/
src
/
ucb
/
ftp
/
getpass.c
diff --git
a/usr/src/ucb/ftp/getpass.c
b/usr/src/ucb/ftp/getpass.c
index
05a2f59
..
2725538
100644
(file)
--- a/
usr/src/ucb/ftp/getpass.c
+++ b/
usr/src/ucb/ftp/getpass.c
@@
-1,44
+1,59
@@
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
#ifndef lint
#ifndef lint
-static char sccsid[] = "@(#)getpass.c
4.1 (Berkeley) 5/26/83
";
-#endif
+static char sccsid[] = "@(#)getpass.c
5.4 (Berkeley) 3/7/86
";
+#endif
not lint
#include <stdio.h>
#include <signal.h>
#include <sgtty.h>
#include <stdio.h>
#include <signal.h>
#include <sgtty.h>
+static struct sgttyb ttyb;
+static int flags;
+static FILE *fi;
+
+static intfix()
+{
+ ttyb.sg_flags = flags;
+ if (fi != NULL)
+ (void) stty(fileno(fi), &ttyb);
+ exit(SIGINT);
+}
+
char *
char *
-getpass(prompt)
+
my
getpass(prompt)
char *prompt;
{
char *prompt;
{
- struct sgttyb ttyb;
- int flags;
register char *p;
register c;
register char *p;
register c;
- FILE *fi;
- static char pbuf[9];
+ static char pbuf[50+1];
int (*signal())();
int (*sig)();
int (*signal())();
int (*sig)();
- if ((fi = f
dopen(open("/dev/tty", 2)
, "r")) == NULL)
+ if ((fi = f
open("/dev/tty"
, "r")) == NULL)
fi = stdin;
else
setbuf(fi, (char *)NULL);
fi = stdin;
else
setbuf(fi, (char *)NULL);
- sig = signal(SIGINT,
SIG_IGN
);
- gtty(fileno(fi), &ttyb);
+ sig = signal(SIGINT,
intfix
);
+
(void)
gtty(fileno(fi), &ttyb);
flags = ttyb.sg_flags;
ttyb.sg_flags &= ~ECHO;
flags = ttyb.sg_flags;
ttyb.sg_flags &= ~ECHO;
- stty(fileno(fi), &ttyb);
- fprintf(stderr, "%s", prompt); fflush(stderr);
+
(void)
stty(fileno(fi), &ttyb);
+ fprintf(stderr, "%s", prompt);
(void)
fflush(stderr);
for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
- if (p < &pbuf[
8
])
+ if (p < &pbuf[
sizeof(pbuf)-1
])
*p++ = c;
}
*p = '\0';
*p++ = c;
}
*p = '\0';
- fprintf(stderr, "\n"); fflush(stderr);
+ fprintf(stderr, "\n");
(void)
fflush(stderr);
ttyb.sg_flags = flags;
ttyb.sg_flags = flags;
- stty(fileno(fi), &ttyb);
- signal(SIGINT, sig);
+
(void)
stty(fileno(fi), &ttyb);
+
(void)
signal(SIGINT, sig);
if (fi != stdin)
if (fi != stdin)
- fclose(fi);
+
(void)
fclose(fi);
return(pbuf);
}
return(pbuf);
}