BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / tip / tip.c
index 0e80b5a..7bc02d6 100644 (file)
@@ -3,16 +3,18 @@
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement:  ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may be used to endorse or promote products derived
  * from this software without specific prior written permission.
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * from this software without specific prior written permission.
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -22,7 +24,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)tip.c      5.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)tip.c      5.13 (Berkeley) 6/1/90";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -118,10 +120,10 @@ main(argc, argv)
        system = sbuf;
 
 notnumber:
        system = sbuf;
 
 notnumber:
-       signal(SIGINT, cleanup);
-       signal(SIGQUIT, cleanup);
-       signal(SIGHUP, cleanup);
-       signal(SIGTERM, cleanup);
+       (void)signal(SIGINT, cleanup);
+       (void)signal(SIGQUIT, cleanup);
+       (void)signal(SIGHUP, cleanup);
+       (void)signal(SIGTERM, cleanup);
 
        if ((i = hunt(system)) == 0) {
                printf("all ports busy\n");
 
        if ((i = hunt(system)) == 0) {
                printf("all ports busy\n");
@@ -193,7 +195,7 @@ cucommon:
        raw();
 
        pipe(fildes); pipe(repdes);
        raw();
 
        pipe(fildes); pipe(repdes);
-       signal(SIGALRM, timeout);
+       (void)signal(SIGALRM, timeout);
 
        /*
         * Everything's set up now:
 
        /*
         * Everything's set up now:
@@ -298,7 +300,7 @@ prompt(s, p)
 
        stoprompt = 0;
        oint = signal(SIGINT, intprompt);
 
        stoprompt = 0;
        oint = signal(SIGINT, intprompt);
-       oint = signal(SIGQUIT, SIG_IGN);
+       oquit = signal(SIGQUIT, SIG_IGN);
        unraw();
        printf("%s", s);
        if (setjmp(promptbuf) == 0)
        unraw();
        printf("%s", s);
        if (setjmp(promptbuf) == 0)
@@ -307,8 +309,8 @@ prompt(s, p)
        *p = '\0';
 
        raw();
        *p = '\0';
 
        raw();
-       signal(SIGINT, oint);
-       signal(SIGQUIT, oint);
+       (void)signal(SIGINT, oint);
+       (void)signal(SIGQUIT, oquit);
        return (stoprompt || p == b);
 }
 
        return (stoprompt || p == b);
 }
 
@@ -319,7 +321,7 @@ void
 intprompt()
 {
 
 intprompt()
 {
 
-       signal(SIGINT, SIG_IGN);
+       (void)signal(SIGINT, SIG_IGN);
        stoprompt = 1;
        printf("\r\n");
        longjmp(promptbuf, 1);
        stoprompt = 1;
        printf("\r\n");
        longjmp(promptbuf, 1);
@@ -520,6 +522,7 @@ sname(s)
 }
 
 static char partab[0200];
 }
 
 static char partab[0200];
+static int bits8;
 
 /*
  * Do a write to the remote machine with the correct parity.
 
 /*
  * Do a write to the remote machine with the correct parity.
@@ -536,10 +539,11 @@ pwrite(fd, buf, n)
        extern int errno;
 
        bp = buf;
        extern int errno;
 
        bp = buf;
-       for (i = 0; i < n; i++) {
-               *bp = partab[(*bp) & 0177];
-               bp++;
-       }
+       if (bits8 == 0)
+               for (i = 0; i < n; i++) {
+                       *bp = partab[(*bp) & 0177];
+                       bp++;
+               }
        if (write(fd, buf, n) < 0) {
                if (errno == EIO)
                        abort("Lost carrier.");
        if (write(fd, buf, n) < 0) {
                if (errno == EIO)
                        abort("Lost carrier.");
@@ -561,6 +565,11 @@ setparity(defparity)
        if (value(PARITY) == NOSTR)
                value(PARITY) = defparity;
        parity = value(PARITY);
        if (value(PARITY) == NOSTR)
                value(PARITY) = defparity;
        parity = value(PARITY);
+       if (equal(parity, "none")) {
+               bits8 = 1;
+               return;
+       } else
+               bits8 = 0;
        for (i = 0; i < 0200; i++)
                partab[i] = evenpartab[i];
        if (equal(parity, "even"))
        for (i = 0; i < 0200; i++)
                partab[i] = evenpartab[i];
        if (equal(parity, "even"))
@@ -570,7 +579,7 @@ setparity(defparity)
                        partab[i] ^= 0200;      /* reverse bit 7 */
                return;
        }
                        partab[i] ^= 0200;      /* reverse bit 7 */
                return;
        }
-       if (equal(parity, "none") || equal(parity, "zero")) {
+       if (equal(parity, "zero")) {
                for (i = 0; i < 0200; i++)
                        partab[i] &= ~0200;     /* turn off bit 7 */
                return;
                for (i = 0; i < 0200; i++)
                        partab[i] &= ~0200;     /* turn off bit 7 */
                return;