added echocheck mode for ftp (from decvax!shannon)
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Wed, 3 Jun 1981 01:00:28 +0000 (17:00 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Wed, 3 Jun 1981 01:00:28 +0000 (17:00 -0800)
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
usr/src/usr.bin/tip/tip.h
usr/src/usr.bin/tip/vars.c

index d5e007e..3556fe8 100644 (file)
@@ -1,4 +1,4 @@
-/*     cmds.c  4.2     81/05/31        */
+/*     cmds.c  4.3     81/06/02        */
 #include "tip.h"
 /*
  * tip
 #include "tip.h"
 /*
  * tip
@@ -217,6 +217,12 @@ sendfile(cc)
                return;
        }
        transmit(fd, value(EOFWRITE), NULL);
                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);
        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';
        }
        lcount = 0;
        lastc = '\0';
@@ -272,18 +286,20 @@ transmit(fd, eofchars, command)
                } while (c != '\r');
                if (boolean(value(VERBOSE)))
                        printf("\r%d", ++lcount);
                } 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')
        }
 out:
        if (lastc != '\n')
@@ -321,7 +337,10 @@ cu_put(cc)
                printf("%s: cannot open\r\n", argv[0]);
                return;
        }
                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);
 }
 
        transmit(fd, "\04", line);
 }
 
@@ -337,6 +356,8 @@ send(c)
 
        cc = c;
        write(FD, (char *)&cc, 1);
 
        cc = c;
        write(FD, (char *)&cc, 1);
+       if (!boolean(value(ECHOCHECK)))
+               return;
 tryagain:
        timedout = 0;
        alarm(10);
 tryagain:
        timedout = 0;
        alarm(10);
index 2ae9193..0bdcee2 100644 (file)
@@ -1,4 +1,4 @@
-/*     tip.h   4.1     81/05/09        */
+/*     tip.h   4.2     81/06/02        */
 /*
  * tip - terminal interface program
  *
 /*
  * tip - terminal interface program
  *
@@ -163,6 +163,7 @@ extern value_t      vtable[];       /* variable table */
 #define VERBOSE                21
 #define SHELL          22
 #define HOME           23
 #define VERBOSE                21
 #define SHELL          22
 #define HOME           23
+#define ECHOCHECK      24
 #else
 #define PHONES         11
 #define PROMPT         12
 #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 VERBOSE                19
 #define SHELL          20
 #define HOME           21
+#define ECHOCHECK      22
 #endif
 
 #define NOVAL  ((value_t *)NULL)
 #endif
 
 #define NOVAL  ((value_t *)NULL)
index 16d3983..06bad74 100644 (file)
@@ -1,4 +1,4 @@
-/*     vars.c  4.1     81/05/09        */
+/*     vars.c  4.2     81/06/02        */
 #include "tip.h"
 
 /*
 #include "tip.h"
 
 /*
@@ -55,5 +55,7 @@ value_t vtable[] = {
          NULL,         "/bin/sh" },
        { "HOME",       STRING|ENVIRON,         (READ|WRITE)<<PUBLIC,
          NOSTR,        NOSTR },
          NULL,         "/bin/sh" },
        { "HOME",       STRING|ENVIRON,         (READ|WRITE)<<PUBLIC,
          NOSTR,        NOSTR },
+       { "echocheck",  BOOL,                   (READ|WRITE)<<PUBLIC,
+         "ec",         (char *)FALSE },
        { NOSTR, NULL, NULL, NOSTR, NOSTR }
 };
        { NOSTR, NULL, NULL, NOSTR, NOSTR }
 };