Flush out the last dregs in the terminal before quitting when
authorGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Thu, 1 Dec 1988 14:28:02 +0000 (06:28 -0800)
committerGregory Minshall <minshall@ucbvax.Berkeley.EDU>
Thu, 1 Dec 1988 14:28:02 +0000 (06:28 -0800)
the remote side quits (actually, there *may* be something left in the
network input ring, so we don't actually guarantee to get everything).

SCCS-vsn: usr.bin/telnet/tn3270.c 1.16
SCCS-vsn: usr.bin/telnet/utilities.c 1.8
SCCS-vsn: usr.bin/telnet/defines.h 1.7

usr/src/usr.bin/telnet/defines.h
usr/src/usr.bin/telnet/tn3270.c
usr/src/usr.bin/telnet/utilities.c

index 5a9a0bd..4957c73 100644 (file)
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)defines.h   1.6 (Berkeley) %G%
+ *     @(#)defines.h   1.7 (Berkeley) %G%
  */
 
 #define        settimer(x)     clocks.x = clocks.system++
 
 #if    !defined(TN3270)
 
  */
 
 #define        settimer(x)     clocks.x = clocks.system++
 
 #if    !defined(TN3270)
 
-#define        ExitString(s,r) { fprintf(stderr, s); exit(r); }
-#define        Exit(x)                 exit(x)
 #define        SetIn3270()
 
 #endif /* !defined(TN3270) */
 #define        SetIn3270()
 
 #endif /* !defined(TN3270) */
index 8e48ef8..74e855d 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)tn3270.c   1.15 (Berkeley) %G%";
+static char sccsid[] = "@(#)tn3270.c   1.16 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -210,38 +210,6 @@ register int       count;                  /* how much to send */
     }
     return(origCount);
 }
     }
     return(origCount);
 }
-
-/* EmptyTerminal - called to make sure that the terminal buffer is empty.
- *                     Note that we consider the buffer to run all the
- *                     way to the kernel (thus the select).
- */
-
-void
-EmptyTerminal()
-{
-#if    defined(unix)
-    fd_set     o;
-
-    FD_ZERO(&o);
-#endif /* defined(unix) */
-
-    if (TTYBYTES() == 0) {
-#if    defined(unix)
-       FD_SET(tout, &o);
-       (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
-                       (struct timeval *) 0);  /* wait for TTLOWAT */
-#endif /* defined(unix) */
-    } else {
-       while (TTYBYTES()) {
-           ttyflush(0);
-#if    defined(unix)
-           FD_SET(tout, &o);
-           (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
-                               (struct timeval *) 0);  /* wait for TTLOWAT */
-#endif /* defined(unix) */
-       }
-    }
-}
 \f
 
 /*
 \f
 
 /*
@@ -321,53 +289,6 @@ char c;
 }
 #endif /* ((!defined(NOT43)) || defined(PUTCHAR)) */
 
 }
 #endif /* ((!defined(NOT43)) || defined(PUTCHAR)) */
 
-void
-SetForExit()
-{
-    setconnmode();
-    if (In3270) {
-       Finish3270();
-    }
-    setcommandmode();
-    fflush(stdout);
-    fflush(stderr);
-    if (In3270) {
-       StopScreen(1);
-    }
-    setconnmode();
-    setcommandmode();
-}
-
-void
-Exit(returnCode)
-int returnCode;
-{
-    SetForExit();
-    exit(returnCode);
-}
-
-void
-ExitString(string, returnCode)
-char *string;
-int returnCode;
-{
-    SetForExit();
-    fwrite(string, 1, strlen(string), stderr);
-    exit(returnCode);
-}
-
-#if defined(MSDOS)
-void
-ExitPerror(string, returnCode)
-char *string;
-int returnCode;
-{
-    SetForExit();
-    perror(string);
-    exit(returnCode);
-}
-#endif /* defined(MSDOS) */
-
 void
 SetIn3270()
 {
 void
 SetIn3270()
 {
index e186582..2e5c5de 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)utilities.c        1.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)utilities.c        1.8 (Berkeley) %G%";
 #endif /* not lint */
 
 #define        TELOPTS
 #endif /* not lint */
 
 #define        TELOPTS
@@ -29,6 +29,8 @@ static char sccsid[] = "@(#)utilities.c       1.7 (Berkeley) %G%";
 
 #include "ring.h"
 
 
 #include "ring.h"
 
+#include "defines.h"
+
 #include "externs.h"
 
 FILE   *NetTrace = 0;          /* Not in bss, since needs to stay */
 #include "externs.h"
 
 FILE   *NetTrace = 0;          /* Not in bss, since needs to stay */
@@ -186,3 +188,87 @@ int        length;                 /* length of suboption data */
        }
     }
 }
        }
     }
 }
+
+/* EmptyTerminal - called to make sure that the terminal buffer is empty.
+ *                     Note that we consider the buffer to run all the
+ *                     way to the kernel (thus the select).
+ */
+
+void
+EmptyTerminal()
+{
+#if    defined(unix)
+    fd_set     o;
+
+    FD_ZERO(&o);
+#endif /* defined(unix) */
+
+    if (TTYBYTES() == 0) {
+#if    defined(unix)
+       FD_SET(tout, &o);
+       (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
+                       (struct timeval *) 0);  /* wait for TTLOWAT */
+#endif /* defined(unix) */
+    } else {
+       while (TTYBYTES()) {
+           ttyflush(0);
+#if    defined(unix)
+           FD_SET(tout, &o);
+           (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0,
+                               (struct timeval *) 0);  /* wait for TTLOWAT */
+#endif /* defined(unix) */
+       }
+    }
+}
+
+void
+SetForExit()
+{
+    setconnmode();
+#if    defined(TN3270)
+    if (In3270) {
+       Finish3270();
+    }
+#endif /* defined(TN3270) */
+    setcommandmode();
+    fflush(stdout);
+    fflush(stderr);
+#if    defined(TN3270)
+    if (In3270) {
+       StopScreen(1);
+    }
+#endif /* defined(TN3270) */
+    setconnmode();
+    EmptyTerminal();                   /* Flush the path to the tty */
+    setcommandmode();
+}
+
+void
+Exit(returnCode)
+int returnCode;
+{
+    SetForExit();
+    exit(returnCode);
+}
+
+void
+ExitString(string, returnCode)
+char *string;
+int returnCode;
+{
+    SetForExit();
+    fwrite(string, 1, strlen(string), stderr);
+    exit(returnCode);
+}
+
+#if defined(MSDOS)
+void
+ExitPerror(string, returnCode)
+char *string;
+int returnCode;
+{
+    SetForExit();
+    perror(string);
+    exit(returnCode);
+}
+#endif /* defined(MSDOS) */