new cu interface and phone numbers for tip
authorBill Shannon <shannon@ucbvax.Berkeley.EDU>
Thu, 17 Dec 1981 09:25:10 +0000 (01:25 -0800)
committerBill Shannon <shannon@ucbvax.Berkeley.EDU>
Thu, 17 Dec 1981 09:25:10 +0000 (01:25 -0800)
SCCS-vsn: usr.bin/tip/cu.c 4.3
SCCS-vsn: usr.bin/tip/tip.c 4.11
SCCS-vsn: usr.bin/tip/tip.h 4.6
SCCS-vsn: usr.bin/tip/tipout.c 4.5

usr/src/usr.bin/tip/cu.c
usr/src/usr.bin/tip/tip.c
usr/src/usr.bin/tip/tip.h
usr/src/usr.bin/tip/tipout.c

index 8cfbd22..768dc55 100644 (file)
@@ -1,4 +1,4 @@
-/*     cu.c    4.2     81/11/29        */
+/*     cu.c    4.3     81/12/16        */
 
 #include "tip.h"
 
 
 #include "tip.h"
 
@@ -12,21 +12,13 @@ cumain(argc, argv)
        char *argv[];
 {
        register int i;
        char *argv[];
 {
        register int i;
+       static char sbuf[12];
 
 
-       signal(SIGINT, cleanup);
-       signal(SIGQUIT, cleanup);
-       signal(SIGHUP, cleanup);
-       signal(SIGTERM, cleanup);
-       setbuf(stdout, NULL);
-       loginit();
-       setuid(getuid());
-       setgid(getgid());
-       vinit();
-       boolean(value(VERBOSE)) = 0;
        if (argc < 2) {
        if (argc < 2) {
-               printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line]\n");
+               printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n");
                exit(8);
        }
                exit(8);
        }
+       CU = DV = NOSTR;
        for (; argc > 1; argv++, argc--) {
                if (argv[1][0] != '-')
                        PN = argv[1];
        for (; argc > 1; argv++, argc--) {
                if (argv[1][0] != '-')
                        PN = argv[1];
@@ -43,7 +35,8 @@ cumain(argc, argv)
 
                case 's':
                        if (speed(atoi(argv[2])) == 0) {
 
                case 's':
                        if (speed(atoi(argv[2])) == 0) {
-                               printf("cu: unsupported speed %s\n", argv[2]);
+                               fprintf(stderr, "cu: unsupported speed %s\n",
+                                       argv[2]);
                                exit(3);
                        }
                        BR = atoi(argv[2]); ++argv; --argc;
                                exit(3);
                        }
                        BR = atoi(argv[2]); ++argv; --argc;
@@ -55,7 +48,10 @@ cumain(argc, argv)
 
                case '0': case '1': case '2': case '3': case '4':
                case '5': case '6': case '7': case '8': case '9':
 
                case '0': case '1': case '2': case '3': case '4':
                case '5': case '6': case '7': case '8': case '9':
-                       CU[strlen(CU)-1] = argv[1][1];
+                       if (CU)
+                               CU[strlen(CU)-1] = argv[1][1];
+                       if (DV)
+                               DV[strlen(DV)-1] = argv[1][1];
                        break;
 
                default:
                        break;
 
                default:
@@ -63,11 +59,16 @@ cumain(argc, argv)
                        break;
                }
        }
                        break;
                }
        }
+       signal(SIGINT, cleanup);
+       signal(SIGQUIT, cleanup);
+       signal(SIGHUP, cleanup);
+       signal(SIGTERM, cleanup);
+
        /*
         * The "cu" host name is used to define the
         * attributes of the generic dialer.
         */
        /*
         * The "cu" host name is used to define the
         * attributes of the generic dialer.
         */
-       if ((i = hunt("cu")) == 0) {
+       if ((i = hunt(sprintf(sbuf, "cu%d", BR))) == 0) {
                printf("all ports busy\n");
                exit(3);
        }
                printf("all ports busy\n");
                exit(3);
        }
@@ -76,6 +77,12 @@ cumain(argc, argv)
                delock(uucplock);
                exit(3);
        }
                delock(uucplock);
                exit(3);
        }
+       setbuf(stdout, NULL);
+       loginit();
+       setuid(getuid());
+       setgid(getgid());
+       vinit();
+       boolean(value(VERBOSE)) = 0;
        if (HW)
                ttysetup(speed(BR));
        if (connect()) {
        if (HW)
                ttysetup(speed(BR));
        if (connect()) {
index e177b53..ece27c6 100644 (file)
@@ -1,4 +1,4 @@
-/*     tip.c   4.10    81/11/29        */
+/*     tip.c   4.11    81/12/16        */
 
 /*
  * tip - UNIX link to other systems
 
 /*
  * tip - UNIX link to other systems
@@ -23,15 +23,18 @@ int disc = OTTYDISC;                /* tip normally runs this way */
 int    intprompt();
 int    timeout();
 int    cleanup();
 int    intprompt();
 int    timeout();
 int    cleanup();
+char   *sname();
+extern char *sprintf();
 
 main(argc, argv)
        char *argv[];
 {
        char *system = NOSTR;
        register int i;
 
 main(argc, argv)
        char *argv[];
 {
        char *system = NOSTR;
        register int i;
-       char *p;
+       register char *p;
+       char sbuf[12];
 
 
-       if (strcmp(argv[0], "tip")) {
+       if (equal(sname(argv[0]), "cu")) {
                cumain(argc, argv);
                cumode = 1;
                goto cucommon;
                cumain(argc, argv);
                cumode = 1;
                goto cucommon;
@@ -45,8 +48,34 @@ main(argc, argv)
                fprintf(stderr, "tip: must be interactive\n");
                exit(1);
        }
                fprintf(stderr, "tip: must be interactive\n");
                exit(1);
        }
-       if (argc > 1 && argv[argc-1][0] != '-')
-               system = argv[argc-1];          /* always last item */
+
+       for (; argc > 1; argv++, argc--) {
+               if (argv[1][0] != '-')
+                       system = argv[1];
+               else switch (argv[1][1]) {
+
+               case 'v':
+                       vflag++;
+                       break;
+
+               case '0': case '1': case '2': case '3': case '4':
+               case '5': case '6': case '7': case '8': case '9':
+                       BR = atoi(&argv[1][1]);
+                       break;
+
+               default:
+                       fprintf(stderr, "tip: %s, unknown option\n", argv[1]);
+                       break;
+               }
+       }
+
+       for (p = system; *p; p++)
+               if (isalpha(*p))
+                       goto notnumber;
+       PN = system;            /* system name is really a phone number */
+       system = sprintf(sbuf, "tip%d", BR);
+
+notnumber:
        signal(SIGINT, cleanup);
        signal(SIGQUIT, cleanup);
        signal(SIGHUP, cleanup);
        signal(SIGINT, cleanup);
        signal(SIGQUIT, cleanup);
        signal(SIGHUP, cleanup);
@@ -72,9 +101,7 @@ main(argc, argv)
         */
        setuid(getuid());
        setgid(getgid());
         */
        setuid(getuid());
        setgid(getgid());
-       for (i = 1; i < argc-1; i++)
-               if (equal(argv[i], "-v"))
-                       vflag++;
+
        /*
         * Kludge, their's no easy way to get the initialization
         *   in the right order, so force it here
        /*
         * Kludge, their's no easy way to get the initialization
         *   in the right order, so force it here
@@ -82,13 +109,6 @@ main(argc, argv)
        if ((PH = getenv("PHONES")) == NOSTR)
                PH = "/etc/phones";
        vinit();                                /* init variables */
        if ((PH = getenv("PHONES")) == NOSTR)
                PH = "/etc/phones";
        vinit();                                /* init variables */
-       for (i = 1; i < argc-1; i++)
-               if (argv[i][0] == '-' && argv[i][1] != 'v') {
-                       if (isnum(argv[i][1]))
-                               number(value(BAUDRATE)) = atoi(&argv[i][1]);
-                       else
-                               printf("%s: unknown option\n", argv[i]);
-               }
        if ((i = speed(number(value(BAUDRATE)))) == NULL) {
                printf("tip: bad baud rate %d\n", number(value(BAUDRATE)));
                delock(uucplock);
        if ((i = speed(number(value(BAUDRATE)))) == NULL) {
                printf("tip: bad baud rate %d\n", number(value(BAUDRATE)));
                delock(uucplock);
@@ -389,3 +409,19 @@ ttysetup(speed)
        ioctl(FD, TIOCLBIS, (char *)&bits);
 #endif
 }
        ioctl(FD, TIOCLBIS, (char *)&bits);
 #endif
 }
+
+/*
+ * Return "simple" name from a file name,
+ * strip leading directories.
+ */
+char *
+sname(s)
+       register char *s;
+{
+       register char *p = s;
+
+       while (*s)
+               if (*s++ == '/')
+                       p = s;
+       return (p);
+}
index bc26f22..cfbf675 100644 (file)
@@ -1,4 +1,4 @@
-/*     tip.h   4.5     81/11/20        */
+/*     tip.h   4.6     81/12/16        */
 /*
  * tip - terminal interface program
  *
 /*
  * tip - terminal interface program
  *
@@ -10,6 +10,7 @@
 #include <stdio.h>
 #include <pwd.h>
 #include <sys/types.h>
 #include <stdio.h>
 #include <pwd.h>
 #include <sys/types.h>
+#include <ctype.h>
 
 /*
  * Remote host attributes
 
 /*
  * Remote host attributes
@@ -80,9 +81,6 @@ typedef
        acu_t;
 
 #define        equal(a, b)     (strcmp(a,b)==0)/* A nice function to string compare */
        acu_t;
 
 #define        equal(a, b)     (strcmp(a,b)==0)/* A nice function to string compare */
-#define islower(c)     ((c)>='a'&&(c)<='z')
-#define toupper(c)     (c)-=('a'-'A')
-#define isnum(c)       ((c)>='0'&&(c)<= '9')
 #define CTRL(c)                ('c'&037)
 
 /*
 #define CTRL(c)                ('c'&037)
 
 /*
index a522c18..5b8e98e 100644 (file)
@@ -1,4 +1,4 @@
-/*     tipout.c        4.4     81/11/29        */
+/*     tipout.c        4.5     81/12/16        */
 #include "tip.h"
 /*
  * tip
 #include "tip.h"
 /*
  * tip
@@ -67,6 +67,7 @@ intSYS()
 {
        signal(SIGSYS, intSYS);
        boolean(value(BEAUTIFY)) = !boolean(value(BEAUTIFY));
 {
        signal(SIGSYS, intSYS);
        boolean(value(BEAUTIFY)) = !boolean(value(BEAUTIFY));
+       intflag = 1;
 }
 
 /*
 }
 
 /*
@@ -74,6 +75,10 @@ intSYS()
  */
 tipout()
 {
  */
 tipout()
 {
+       char buf[BUFSIZ];
+       register char *cp;
+       register int cnt;
+
        signal(SIGINT, SIG_IGN);
        signal(SIGQUIT, SIG_IGN);
        signal(SIGEMT, intEMT);         /* attention from TIPIN */
        signal(SIGINT, SIG_IGN);
        signal(SIGQUIT, SIG_IGN);
        signal(SIGEMT, intEMT);         /* attention from TIPIN */
@@ -82,18 +87,26 @@ tipout()
        signal(SIGHUP, intTERM);        /* for dial-ups */
        signal(SIGSYS, intSYS);         /* beautify toggle */
 
        signal(SIGHUP, intTERM);        /* for dial-ups */
        signal(SIGSYS, intSYS);         /* beautify toggle */
 
-       while (1) {
+       for (;;) {
                do {
                        intflag = 0;
                do {
                        intflag = 0;
-                       read(FD,&ch,1);
-                       ch &= 0177;
+                       cnt = read(FD, buf, BUFSIZ);
                } while (intflag);
                } while (intflag);
-               write(1, &ch, 1);
+               if (cnt <= 0)
+                       continue;
+               for (cp = buf; cp < buf + cnt; cp++)
+                       *cp &= 0177;
+               write(1, buf, cnt);
                if (boolean(value(SCRIPT)) && fscript != NULL) {
                if (boolean(value(SCRIPT)) && fscript != NULL) {
-                       if (boolean(value(BEAUTIFY)) && ch < 040 &&
-                           !any(ch, value(EXCEPTIONS)))
+                       if (!boolean(value(BEAUTIFY))) {
+                               fputs(buf, fscript);
+                               continue;
+                       }
+                       for (cp = buf; cp < buf + cnt; cp++) {
+                               if (*cp < ' ' && !any(*cp, value(EXCEPTIONS)))
                                        continue;
                                        continue;
-                       putc(ch, fscript);
+                               putc(*cp, fscript);
+                       }
                }
        }
 }
                }
        }
 }