From a2c6551ccf550b788345e5d61d3223db250c982d Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Tue, 2 Jun 1981 17:00:28 -0800 Subject: [PATCH] added echocheck mode for ftp (from decvax!shannon) SCCS-vsn: usr.bin/tip/tip.h 4.2 SCCS-vsn: usr.bin/tip/vars.c 4.2 SCCS-vsn: usr.bin/tip/cmds.c 4.3 --- usr/src/usr.bin/tip/cmds.c | 51 +++++++++++++++++++++++++++----------- usr/src/usr.bin/tip/tip.h | 4 ++- usr/src/usr.bin/tip/vars.c | 4 ++- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/usr/src/usr.bin/tip/cmds.c b/usr/src/usr.bin/tip/cmds.c index d5e007ea81..3556fe8fca 100644 --- a/usr/src/usr.bin/tip/cmds.c +++ b/usr/src/usr.bin/tip/cmds.c @@ -1,4 +1,4 @@ -/* cmds.c 4.2 81/05/31 */ +/* cmds.c 4.3 81/06/02 */ #include "tip.h" /* * tip @@ -217,6 +217,12 @@ sendfile(cc) return; } transmit(fd, value(EOFWRITE), NULL); + if (!boolean(value(ECHOCHECK))) { + struct sgttyb buf; + + ioctl(FD, TIOCGETP, &buf); /* this does a */ + ioctl(FD, TIOCSETP, &buf); /* wflushtty */ + } } /* @@ -239,7 +245,15 @@ transmit(fd, eofchars, command) if (command != NULL) { for (pc = command; *pc; pc++) send(*pc); - read(FD, (char *)&c, 1); /* trailing \n */ + if (boolean(value(ECHOCHECK))) + read(FD, (char *)&c, 1); /* trailing \n */ + else { + struct sgttyb buf; + + ioctl(FD, TIOCGETP, &buf); /* this does a */ + ioctl(FD, TIOCSETP, &buf); /* wflushtty */ + sleep(5); /* wait for remote stty to take effect */ + } } lcount = 0; lastc = '\0'; @@ -272,18 +286,20 @@ transmit(fd, eofchars, command) } while (c != '\r'); if (boolean(value(VERBOSE))) printf("\r%d", ++lcount); - alarm(10); - timedout = 0; - do { /* wait for prompt */ - read(FD, (char *)&c, 1); - if (timedout || stop) { - if (timedout) - printf("\r\ntimed out at eol\r\n"); - alarm(0); - goto out; - } - } while ((c&0177) != character(value(PROMPT))); - alarm(0); + if (boolean(value(ECHOCHECK))) { + alarm(10); + timedout = 0; + do { /* wait for prompt */ + read(FD, (char *)&c, 1); + if (timedout || stop) { + if (timedout) + printf("\r\ntimed out at eol\r\n"); + alarm(0); + goto out; + } + } while ((c&0177) != character(value(PROMPT))); + alarm(0); + } } out: if (lastc != '\n') @@ -321,7 +337,10 @@ cu_put(cc) printf("%s: cannot open\r\n", argv[0]); return; } - sprintf(line, "cat>'%s'\r", argv[1]); + if (boolean(value(ECHOCHECK))) + sprintf(line, "cat>'%s'\r", argv[1]); + else + sprintf(line, "stty -echo;cat>'%s';stty echo\r", argv[1]); transmit(fd, "\04", line); } @@ -337,6 +356,8 @@ send(c) cc = c; write(FD, (char *)&cc, 1); + if (!boolean(value(ECHOCHECK))) + return; tryagain: timedout = 0; alarm(10); diff --git a/usr/src/usr.bin/tip/tip.h b/usr/src/usr.bin/tip/tip.h index 2ae919312f..0bdcee2fa1 100644 --- a/usr/src/usr.bin/tip/tip.h +++ b/usr/src/usr.bin/tip/tip.h @@ -1,4 +1,4 @@ -/* tip.h 4.1 81/05/09 */ +/* tip.h 4.2 81/06/02 */ /* * tip - terminal interface program * @@ -163,6 +163,7 @@ extern value_t vtable[]; /* variable table */ #define VERBOSE 21 #define SHELL 22 #define HOME 23 +#define ECHOCHECK 24 #else #define PHONES 11 #define PROMPT 12 @@ -175,6 +176,7 @@ extern value_t vtable[]; /* variable table */ #define VERBOSE 19 #define SHELL 20 #define HOME 21 +#define ECHOCHECK 22 #endif #define NOVAL ((value_t *)NULL) diff --git a/usr/src/usr.bin/tip/vars.c b/usr/src/usr.bin/tip/vars.c index 16d3983175..06bad7476d 100644 --- a/usr/src/usr.bin/tip/vars.c +++ b/usr/src/usr.bin/tip/vars.c @@ -1,4 +1,4 @@ -/* vars.c 4.1 81/05/09 */ +/* vars.c 4.2 81/06/02 */ #include "tip.h" /* @@ -55,5 +55,7 @@ value_t vtable[] = { NULL, "/bin/sh" }, { "HOME", STRING|ENVIRON, (READ|WRITE)<