more fixes from rick adams
authorJim Bloom <bloom@ucbvax.Berkeley.EDU>
Tue, 7 Jan 1986 07:02:30 +0000 (23:02 -0800)
committerJim Bloom <bloom@ucbvax.Berkeley.EDU>
Tue, 7 Jan 1986 07:02:30 +0000 (23:02 -0800)
SCCS-vsn: usr.bin/uucp/DOC/CHANGES 5.5
SCCS-vsn: usr.bin/uucp/uucico/cico.c 5.11
SCCS-vsn: usr.bin/uucp/uucico/condevs.c 5.13
SCCS-vsn: usr.bin/uucp/uucico/conn.c 5.9
SCCS-vsn: usr.bin/uucp/uucico/imsg.c 5.3
SCCS-vsn: usr.bin/uucp/uucico/pk.h 5.4
SCCS-vsn: usr.bin/uucp/uucico/pk0.c 5.5
SCCS-vsn: usr.bin/uucp/uucico/pk1.c 5.7
SCCS-vsn: usr.bin/uucp/includes/uucp.h 5.10

usr/src/usr.bin/uucp/DOC/CHANGES
usr/src/usr.bin/uucp/includes/uucp.h
usr/src/usr.bin/uucp/uucico/cico.c
usr/src/usr.bin/uucp/uucico/condevs.c
usr/src/usr.bin/uucp/uucico/conn.c
usr/src/usr.bin/uucp/uucico/imsg.c
usr/src/usr.bin/uucp/uucico/pk.h
usr/src/usr.bin/uucp/uucico/pk0.c
usr/src/usr.bin/uucp/uucico/pk1.c

index 9b52be7..e9a4223 100644 (file)
@@ -1,5 +1,5 @@
 List of Changes to UUCP
 List of Changes to UUCP
-CHANGES        5.4     85/10/09
+CHANGES        5.5     86/01/06
 
 Added support for Eunice.
 
 
 Added support for Eunice.
 
@@ -155,3 +155,9 @@ of getting the default MAXMSGTIME. E.g.
        system Any ACU 1200 1234567 ogin~20-\r-ogin~10-\b-ogin user password pw
 will look for ogin for 20 seconds, send CR, look for ogin for 10
 seconds, send a BREAK and look for ogin for MAXMSGTIME seconds
        system Any ACU 1200 1234567 ogin~20-\r-ogin~10-\b-ogin user password pw
 will look for ogin for 20 seconds, send CR, look for ogin for 10
 seconds, send a BREAK and look for ogin for MAXMSGTIME seconds
+
+Added code to support GTEs PC Pursuit service. It's mainly the handling of the
+dialback they use.
+
+Added time "NonPeak" for Tymnet/Telenet services that charge lower
+rates from 6pm-7am M-F and Sat & Sun.
index a95b25d..f5b2211 100644 (file)
@@ -1,4 +1,4 @@
-/*     uucp.h  5.9     85/10/24        */
+/*     uucp.h  5.10    86/01/06        */
 
 #include <stdio.h>
 
 
 #include <stdio.h>
 
 #define TCPIP
 #endif
 
 #define TCPIP
 #endif
 
-#if defined(VENTEL) || defined(NOVATION) || defined(DF112) || defined(PENRIL)
 /*
 /*
- * We need a timer to write slowly to ventels.
+ * We need a timer to write slowly to certain modems.
+ * and for generating breaks.
+ *
  * define INTERVALTIMER to use 4.[23] bsd interval timer.
  * define FASTTIMER if you have the nap() system call.
  * define FTIME if you have the ftime() system call.
  * define INTERVALTIMER to use 4.[23] bsd interval timer.
  * define FASTTIMER if you have the nap() system call.
  * define FTIME if you have the ftime() system call.
@@ -95,7 +96,6 @@
 /*#define FASTTIMER /**/
 /*#define FTIME /**/
 /*#define BUSYLOOP /**/
 /*#define FASTTIMER /**/
 /*#define FTIME /**/
 /*#define BUSYLOOP /**/
-#endif VENTEL || NOVATION || DF112 || PENRIL
 
 /*
  * If your site is using "ndir.h" to retrofit the Berkeley
 
 /*
  * If your site is using "ndir.h" to retrofit the Berkeley
index db7fb33..14e8d8b 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)cico.c     5.10 (Berkeley) %G%";
+static char sccsid[] = "@(#)cico.c     5.11 (Berkeley) %G%";
 #endif
 
 #include <signal.h>
 #endif
 
 #include <signal.h>
@@ -38,7 +38,7 @@ char *Stattext[] = {
        "WRONG TIME TO CALL",
        "SYSTEM LOCKED",
        "NO DEVICE",
        "WRONG TIME TO CALL",
        "SYSTEM LOCKED",
        "NO DEVICE",
-       "DIAL FAILED",
+       "CALL FAILED",
        "LOGIN FAILED",
        "BAD SEQUENCE"
 };
        "LOGIN FAILED",
        "BAD SEQUENCE"
 };
@@ -55,13 +55,18 @@ int Stattype[] = {
        SS_BADSEQ
 };
 
        SS_BADSEQ
 };
 
+                               /* Arguments to setdebug():                  */
+#define DBG_TEMP  0            /*   Create a temporary audit file           */
+#define DBG_PERM  1            /*   Create a permanent audit file           */
+#define DBG_CLEAN 2            /*   Cleanup, discard temp file              */
 
 int ReverseRole = 0;
 
 int ReverseRole = 0;
-int StdErrIsTty = 0;
 int Role = SLAVE;
 int onesys = 0;
 int turntime = 30 * 60;        /* 30 minutes expressed in seconds */
 int Role = SLAVE;
 int onesys = 0;
 int turntime = 30 * 60;        /* 30 minutes expressed in seconds */
+char *ttyn = NULL;
 extern int LocalOnly;
 extern int LocalOnly;
+extern int errno;
 extern char MaxGrade, DefMaxGrade;
 extern char Myfullname[];
 
 extern char MaxGrade, DefMaxGrade;
 extern char Myfullname[];
 
@@ -72,23 +77,22 @@ struct termio Savettyb;
 struct sgttyb Savettyb;
 #endif
 
 struct sgttyb Savettyb;
 #endif
 
-/*******
- *     cico - this program is used  to place a call to a
+/*
+ *     this program is used  to place a call to a
  *     remote machine, login, and copy files between the two machines.
  */
  *     remote machine, login, and copy files between the two machines.
  */
-
 main(argc, argv)
 main(argc, argv)
+int argc;
 register char *argv[];
 {
        register int ret;
        int seq;
        char wkpre[NAMESIZE], file[NAMESIZE];
 register char *argv[];
 {
        register int ret;
        int seq;
        char wkpre[NAMESIZE], file[NAMESIZE];
-       char msg[MAXFULLNAME], *q, **alias;
+       char msg[MAXFULLNAME], *q;
        register char *p;
        register char *p;
-       extern onintr(), timeout(), setdebug();
+       extern onintr(), timeout(), dbg_signal();
        extern char *pskip();
        char rflags[MAXFULLNAME];
        extern char *pskip();
        char rflags[MAXFULLNAME];
-       char *ttyn;
 #ifdef NOGETPEER
        u_long Hostnumber = 0;
 #endif NOGETPEER
 #ifdef NOGETPEER
        u_long Hostnumber = 0;
 #endif NOGETPEER
@@ -100,15 +104,15 @@ register char *argv[];
        signal(SIGQUIT, onintr);
        signal(SIGTERM, onintr);
        signal(SIGPIPE, onintr);        /* 4.1a tcp-ip stupidity */
        signal(SIGQUIT, onintr);
        signal(SIGTERM, onintr);
        signal(SIGPIPE, onintr);        /* 4.1a tcp-ip stupidity */
-       signal(SIGFPE, setdebug);
+       signal(SIGFPE, dbg_signal);
        ret = guinfo(getuid(), User, msg);
        strcpy(Loginuser, User);
        uucpname(Myname);
        ASSERT(ret == 0, "BAD UID", CNULL, ret);
 
        ret = guinfo(getuid(), User, msg);
        strcpy(Loginuser, User);
        uucpname(Myname);
        ASSERT(ret == 0, "BAD UID", CNULL, ret);
 
-#ifdef BSD4_2
-       setlinebuf(stderr);
-#endif
+       setbuf (stderr, CNULL);
+
+       rflags[0] = '\0';
        umask(WFMASK);
        strcpy(Rmtname, Myname);
        Ifn = Ofn = -1;
        umask(WFMASK);
        strcpy(Rmtname, Myname);
        Ifn = Ofn = -1;
@@ -135,11 +139,10 @@ register char *argv[];
                                onesys = 1;
                        break;
                case 'x':
                                onesys = 1;
                        break;
                case 'x':
-                       chkdebug();
                        Debug = atoi(&argv[1][2]);
                        if (Debug <= 0)
                                Debug = 1;
                        Debug = atoi(&argv[1][2]);
                        if (Debug <= 0)
                                Debug = 1;
-                       logent("ENABLED", "DEBUG");
+                       strcat(rflags, argv[1]);
                        break;
                case 't':
                        turntime = atoi(&argv[1][2])*60;/* minutes to seconds */
                        break;
                case 't':
                        turntime = atoi(&argv[1][2])*60;/* minutes to seconds */
@@ -160,7 +163,7 @@ register char *argv[];
        }
 
        while (argc > 1) {
        }
 
        while (argc > 1) {
-               printf("unknown argument %s (ignored)\n", argv[1]);
+               fprintf(stderr, "unknown argument %s (ignored)\n", argv[1]);
                --argc; argv++;
        }
 
                --argc; argv++;
        }
 
@@ -187,6 +190,17 @@ register char *argv[];
        ASSERT(ret >= 0, "CHDIR FAILED", Spool, ret);
        strcpy(Wrkdir, Spool);
 
        ASSERT(ret >= 0, "CHDIR FAILED", Spool, ret);
        strcpy(Wrkdir, Spool);
 
+       if (Debug) {
+               if (Role == MASTER)
+                       chkdebug();
+               setdebug ((Role == SLAVE) ? DBG_TEMP : DBG_PERM);
+               if (Debug > 0)
+                       logent ("Local Enabled", "DEBUG");
+       }
+
+       /*
+        * First time through: If we're the slave, do initial checking.
+        */
        if (Role == SLAVE) {
                /* check for /etc/nologin */
                if (access(NOLOGIN, 0) == 0) {
        if (Role == SLAVE) {
                /* check for /etc/nologin */
                if (access(NOLOGIN, 0) == 0) {
@@ -196,11 +210,13 @@ register char *argv[];
                        else
                                cleanup(1);
                }
                        else
                                cleanup(1);
                }
+               Ifn = 0;
+               Ofn = 1;
 #ifdef TCPIP
                /*
                 * Determine if we are on TCPIP
                 */
 #ifdef TCPIP
                /*
                 * Determine if we are on TCPIP
                 */
-               if (isatty(0) ==  0) {
+               if (isatty(Ifn) < 0) {
                        IsTcpIp = 1;
                        DEBUG(4, "TCPIP connection -- ioctl-s disabled\n", CNULL);
                } else
                        IsTcpIp = 1;
                        DEBUG(4, "TCPIP connection -- ioctl-s disabled\n", CNULL);
                } else
@@ -210,31 +226,23 @@ register char *argv[];
                onesys = 1;
                if (!IsTcpIp) {
 #ifdef USG
                onesys = 1;
                if (!IsTcpIp) {
 #ifdef USG
-                       ret = ioctl(0, TCGETA, &Savettyb);
+                       ret = ioctl(Ifn, TCGETA, &Savettyb);
                        Savettyb.c_cflag = (Savettyb.c_cflag & ~CS8) | CS7;
                        Savettyb.c_oflag |= OPOST;
                        Savettyb.c_lflag |= (ISIG|ICANON|ECHO);
 #else !USG
                        Savettyb.c_cflag = (Savettyb.c_cflag & ~CS8) | CS7;
                        Savettyb.c_oflag |= OPOST;
                        Savettyb.c_lflag |= (ISIG|ICANON|ECHO);
 #else !USG
-                       ret = ioctl(0, TIOCGETP, &Savettyb);
+                       ret = ioctl(Ifn, TIOCGETP, &Savettyb);
                        Savettyb.sg_flags |= ECHO;
                        Savettyb.sg_flags &= ~RAW;
 #endif !USG
                        Savettyb.sg_flags |= ECHO;
                        Savettyb.sg_flags &= ~RAW;
 #endif !USG
+                       ttyn = ttyname(Ifn);
                }
                }
-               Ifn = 0;
-               Ofn = 1;
                fixmode(Ifn);
                getbaud(Ifn);
                fixmode(Ifn);
                getbaud(Ifn);
-               sprintf(file,"%s/%d", RMTDEBUG, getpid());
-#ifdef VMS
-               /* hold the version number down */
-               unlink(file);
-#endif VMS
-               freopen(file, "w", stderr);
-#ifdef BSD4_2
-               setlinebuf(stderr);
-#else  !BSD4_2
-               setbuf(stderr, NULL);
-#endif !BSD4_2
+
+               /*
+                * Initial Message -- tell them we're here, and who we are.
+                */
                sprintf(msg, "here=%s", Myfullname);
                omsg('S', msg, Ofn);
                signal(SIGALRM, timeout);
                sprintf(msg, "here=%s", Myfullname);
                omsg('S', msg, Ofn);
                signal(SIGALRM, timeout);
@@ -243,22 +251,23 @@ register char *argv[];
                        /* timed out */
                        if (!IsTcpIp) {
 #ifdef USG
                        /* timed out */
                        if (!IsTcpIp) {
 #ifdef USG
-                               ret = ioctl(0, TCSETA, &Savettyb);
+                               ret = ioctl(Ifn, TCSETA, &Savettyb);
+
 #else  !USG
 #else  !USG
-                               ret = ioctl(0, TIOCSETP, &Savettyb);
+                               ret = ioctl(Ifn, TIOCSETP, &Savettyb);
 #endif !USG
                        }
                        cleanup(0);
                }
                for (;;) {
                        ret = imsg(msg, Ifn);
 #endif !USG
                        }
                        cleanup(0);
                }
                for (;;) {
                        ret = imsg(msg, Ifn);
-                       if (ret != 0) {
+                       if (ret != SUCCESS) {
                                alarm(0);
                                if (!IsTcpIp) {
 #ifdef USG
                                alarm(0);
                                if (!IsTcpIp) {
 #ifdef USG
-                                       ret = ioctl(0, TCSETA, &Savettyb);
+                                       ret = ioctl(Ifn, TCSETA, &Savettyb);
 #else  !USG
 #else  !USG
-                                       ret = ioctl(0, TIOCSETP, &Savettyb);
+                                       ret = ioctl(Ifn, TIOCSETP, &Savettyb);
 #endif !USG
                                }
                                cleanup(0);
 #endif !USG
                                }
                                cleanup(0);
@@ -271,10 +280,12 @@ register char *argv[];
                p = pskip(q);
                strncpy(Rmtname, q, MAXBASENAME);
                Rmtname[MAXBASENAME] = '\0';
                p = pskip(q);
                strncpy(Rmtname, q, MAXBASENAME);
                Rmtname[MAXBASENAME] = '\0';
-               sprintf(wkpre,"%s/%s", RMTDEBUG, Rmtname);
-               unlink(wkpre);
-               if (link(file, wkpre) == 0)
-                       unlink(file);
+
+               /*
+                * Now that we know who they are, give the audit file the right
+                * name.
+                */
+               setdebug (DBG_PERM);
                DEBUG(4, "sys-%s\n", Rmtname);
                /* The versys will also do an alias on the incoming name */
                if (versys(&Rmtname)) {
                DEBUG(4, "sys-%s\n", Rmtname);
                /* The versys will also do an alias on the incoming name */
                if (versys(&Rmtname)) {
@@ -293,7 +304,7 @@ register char *argv[];
                if (IsTcpIp) {
                        struct hostent *hp;
                        char *cpnt, *inet_ntoa();
                if (IsTcpIp) {
                        struct hostent *hp;
                        char *cpnt, *inet_ntoa();
-                       int len;
+                       int fromlen;
                        struct sockaddr_in from;
                        extern char PhoneNumber[];
 
                        struct sockaddr_in from;
                        extern char PhoneNumber[];
 
@@ -301,8 +312,8 @@ register char *argv[];
                        from.sin_addr.s_addr = Hostnumber;
                        from.sin_family = AF_INET;
 #else  !NOGETPEER
                        from.sin_addr.s_addr = Hostnumber;
                        from.sin_family = AF_INET;
 #else  !NOGETPEER
-                       len = sizeof(from);
-                       if (getpeername(0, &from, &len) < 0) {
+                       fromlen = sizeof(from);
+                       if (getpeername(Ifn, &from, &fromlen) < 0) {
                                logent(Rmtname, "NOT A TCP CONNECTION");
                                omsg('R', "NOT TCP", Ofn);
                                cleanup(0);
                                logent(Rmtname, "NOT A TCP CONNECTION");
                                omsg('R', "NOT TCP", Ofn);
                                cleanup(0);
@@ -310,7 +321,7 @@ register char *argv[];
 #endif !NOGETPEER
                        hp = gethostbyaddr(&from.sin_addr,
                                sizeof (struct in_addr), from.sin_family);
 #endif !NOGETPEER
                        hp = gethostbyaddr(&from.sin_addr,
                                sizeof (struct in_addr), from.sin_family);
-                       if (hp == 0) {
+                       if (hp == NULL) {
                                /* security break or just old host table? */
                                logent(Rmtname, "UNKNOWN IP-HOST Name =");
                                cpnt = inet_ntoa(from.sin_addr),
                                /* security break or just old host table? */
                                logent(Rmtname, "UNKNOWN IP-HOST Name =");
                                cpnt = inet_ntoa(from.sin_addr),
@@ -320,7 +331,7 @@ register char *argv[];
                                omsg('R' ,wkpre ,Ofn);
                                cleanup(0);
                        }
                                omsg('R' ,wkpre ,Ofn);
                                cleanup(0);
                        }
-                       if (Debug>99)
+                       if (Debug > 99)
                                logent(Rmtname,"Request from IP-Host name =");
                        /*
                         * The following is to determine if the name given us by
                                logent(Rmtname,"Request from IP-Host name =");
                        /*
                         * The following is to determine if the name given us by
@@ -350,7 +361,7 @@ register char *argv[];
                }
 #endif BSDTCP
 
                }
 #endif BSDTCP
 
-               if (mlock(Rmtname) == FAIL) {
+               if (mlock(Rmtname)) {
                        omsg('R', "LCK", Ofn);
                        cleanup(0);
                }
                        omsg('R', "LCK", Ofn);
                        cleanup(0);
                }
@@ -371,9 +382,17 @@ register char *argv[];
                        q = pskip(p);
                        switch(*(++p)) {
                        case 'x':
                        q = pskip(p);
                        switch(*(++p)) {
                        case 'x':
-                               Debug = atoi(++p);
-                               if (Debug <= 0)
-                                       Debug = 1;
+                               if (Debug == 0) {
+                                       Debug = atoi(++p);
+                                       if (Debug <= 0)
+                                               Debug = 1;
+                                       setdebug(DBG_PERM);
+                                       if (Debug > 0)
+                                               logent("Remote Enabled", "DEBUG");
+                               } else {
+                                       DEBUG(1, "Remote debug request ignored\n",
+                                          CNULL);
+                               }
                                break;
                        case 'Q':
                                seq = atoi(++p);
                                break;
                        case 'Q':
                                seq = atoi(++p);
@@ -417,15 +436,8 @@ register char *argv[];
                        omsg('R', "BADSEQ", Ofn);
                        cleanup(0);
                }
                        omsg('R', "BADSEQ", Ofn);
                        cleanup(0);
                }
-               ttyn = ttyname(Ifn);
                if (ttyn != NULL)
                        chmod(ttyn, 0600);
                if (ttyn != NULL)
                        chmod(ttyn, 0600);
-       } else { /* Role == MASTER */
-               struct stat stbuf;
-               if (isatty(fileno(stderr)) || (fstat(fileno(stderr),&stbuf) == 0
-                   && stbuf.st_mode&S_IFREG) )
-                       StdErrIsTty =  1;
-               setdebug(0);
        }
 
 loop:
        }
 
 loop:
@@ -438,15 +450,8 @@ loop:
                sleep(3);
        }
        if (!onesys) {
                sleep(3);
        }
        if (!onesys) {
-               struct stat sbuf;
-
-               if (!StdErrIsTty) {
-                       sprintf(file, "%s/%s", RMTDEBUG, Rmtname);
-                       if (stat(file, &sbuf) == 0 && sbuf.st_size == 0)
-                               unlink(file);
-               }
                ret = gnsys(Rmtname, Spool, CMDPRE);
                ret = gnsys(Rmtname, Spool, CMDPRE);
-               setdebug(0);
+               setdebug(DBG_PERM);
                if (ret == FAIL)
                        cleanup(100);
                if (ret == SUCCESS)
                if (ret == FAIL)
                        cleanup(100);
                if (ret == SUCCESS)
@@ -506,7 +511,7 @@ loop:
                /*
                 * Determine if we are on TCPIP
                 */
                /*
                 * Determine if we are on TCPIP
                 */
-               if (isatty(Ifn) ==  0) {
+               if (isatty(Ifn) == 0) {
                        IsTcpIp = 1;
                        DEBUG(4, "TCPIP connection -- ioctl-s disabled\n", CNULL);
                } else
                        IsTcpIp = 1;
                        DEBUG(4, "TCPIP connection -- ioctl-s disabled\n", CNULL);
                } else
@@ -533,11 +538,6 @@ loop:
 #else !GNXSEQ
                seq = 0;
 #endif !GNXSEQ
 #else !GNXSEQ
                seq = 0;
 #endif !GNXSEQ
-               if (Debug)
-                       sprintf(rflags, "-x%d", Debug);
-               else
-                       rflags[0] = '\0';
-
                if (MaxGrade != '\177') {
                        char buf[MAXFULLNAME];
                        sprintf(buf, " -p%c -vgrade=%c", MaxGrade, MaxGrade);
                if (MaxGrade != '\177') {
                        char buf[MAXFULLNAME];
                        sprintf(buf, " -p%c -vgrade=%c", MaxGrade, MaxGrade);
@@ -593,6 +593,8 @@ loop:
        DEBUG(1, "Ifn - %d, ", Ifn);
        DEBUG(1, "Loginuser - %s\n", Loginuser);
 
        DEBUG(1, "Ifn - %d, ", Ifn);
        DEBUG(1, "Loginuser - %s\n", Loginuser);
 
+       ttyn = ttyname(Ifn);
+
        alarm(MAXMSGTIME);
        if (ret=setjmp(Sjbuf))
                goto Failure;
        alarm(MAXMSGTIME);
        if (ret=setjmp(Sjbuf))
                goto Failure;
@@ -606,7 +608,14 @@ Failure:
                        "STARTUP FAILED");
                goto next;
        } else {
                        "STARTUP FAILED");
                goto next;
        } else {
-               logent("startup", "OK");
+               if (ttyn != NULL) {
+                       char startupmsg[BUFSIZ];
+                       extern int linebaudrate;
+                       sprintf(startupmsg, "startup %s %d baud", &ttyn[5], 
+                               linebaudrate);
+                       logent(startupmsg, "OK");
+               } else
+                       logent("startup", "OK");
                US_SST(us_s_gress);
                systat(Rmtname, SS_INPROGRESS, "TALKING");
                ret = cntrl(Role, wkpre);
                US_SST(us_s_gress);
                systat(Rmtname, SS_INPROGRESS, "TALKING");
                ret = cntrl(Role, wkpre);
@@ -651,21 +660,16 @@ next:
 struct sgttyb Hupvec;
 #endif
 
 struct sgttyb Hupvec;
 #endif
 
-/***
- *     cleanup(code)   cleanup and exit with "code" status
- *     int code;
+/*
+ *     cleanup and exit with "code" status
  */
  */
-
 cleanup(code)
 register int code;
 {
 cleanup(code)
 register int code;
 {
-       register char *ttyn;
-       char bfr[BUFSIZ];
-       struct stat sbuf;
-
        signal(SIGINT, SIG_IGN);
        signal(SIGHUP, SIG_IGN);
        rmlock(CNULL);
        signal(SIGINT, SIG_IGN);
        signal(SIGHUP, SIG_IGN);
        rmlock(CNULL);
+       sleep(5);                       /* Wait for any pending output    */
        clsacu();
        logcls();
        if (Role == SLAVE) {
        clsacu();
        logcls();
        if (Role == SLAVE) {
@@ -681,17 +685,16 @@ register int code;
                        (void) ioctl(0, TIOCSDTR, STBNULL);
 #else !TIOCSDTR
                        (void) ioctl(0, TIOCGETP, &Hupvec);
                        (void) ioctl(0, TIOCSDTR, STBNULL);
 #else !TIOCSDTR
                        (void) ioctl(0, TIOCGETP, &Hupvec);
-#endif !TIOCSDTR
                        Hupvec.sg_ispeed = B0;
                        Hupvec.sg_ospeed = B0;
                        (void) ioctl(0, TIOCSETP, &Hupvec);
                        Hupvec.sg_ispeed = B0;
                        Hupvec.sg_ospeed = B0;
                        (void) ioctl(0, TIOCSETP, &Hupvec);
+#endif !TIOCSDTR
                        sleep(2);
                        (void) ioctl(0, TIOCSETP, &Savettyb);
                        /* make *sure* exclusive access is off */
                        (void) ioctl(0, TIOCNXCL, STBNULL);
 #endif !USG
                }
                        sleep(2);
                        (void) ioctl(0, TIOCSETP, &Savettyb);
                        /* make *sure* exclusive access is off */
                        (void) ioctl(0, TIOCNXCL, STBNULL);
 #endif !USG
                }
-               ttyn = ttyname(Ifn);
                if (ttyn != NULL)
                        chmod(ttyn, 0600);
        }
                if (ttyn != NULL)
                        chmod(ttyn, 0600);
        }
@@ -709,16 +712,12 @@ register int code;
                xuuxqt();
        else
                DEBUG(1, "exit code %d\n", code);
                xuuxqt();
        else
                DEBUG(1, "exit code %d\n", code);
-       sprintf(bfr, "%s/%s", RMTDEBUG, Rmtname);
-       if (stat(bfr, &sbuf) == 0 && sbuf.st_size == 0)
-               unlink(bfr);
-       sprintf(bfr, "%s/%d", RMTDEBUG, getpid());
-       unlink(bfr);
+       setdebug (DBG_CLEAN);
        exit(code);
 }
 
        exit(code);
 }
 
-/***
- *     onintr(inter)   interrupt - remove locks and exit
+/*
+ *     on interrupt - remove locks and exit
  */
 
 onintr(inter)
  */
 
 onintr(inter)
@@ -741,72 +740,136 @@ register int inter;
  * (SIGFPE, ugh), and toggle debugging between 0 and 30.
  * Handy for looking in on long running uucicos.
  */
  * (SIGFPE, ugh), and toggle debugging between 0 and 30.
  * Handy for looking in on long running uucicos.
  */
-setdebug(code)
-int code;
+dbg_signal()
 {
 {
-       char buf[BUFSIZ];
-
-       if (code) {
-               if (Debug == 0)
-                       Debug = 30;
-               else
-                       Debug = 0;
-       }
-       if (Debug && !StdErrIsTty) {
-               sprintf(buf,"%s/%s", RMTDEBUG, Rmtname);
-               unlink(buf);
-               freopen(buf, "w", stderr);
-#ifdef BSD4_2
-               setlinebuf(stderr);
-#else  !BSD4_2
-               setbuf(stderr, NULL);
-#endif !BSD4_2
-       }
+       Debug = (Debug == 0) ? 30 : 0;
+       setdebug(DBG_PERM);
+       if (Debug > 0)
+               logent("Signal Enabled", "DEBUG");
 }
 
 
 }
 
 
-/***
- *     fixmode(tty)    fix kill/echo/raw on line
+/*
+ * Check debugging requests, and open RMTDEBUG audit file if necessary. If an
+ * audit file is needed, the parm argument indicates how to create the file:
+ *
+ *     DBG_TEMP  - Open a temporary file, with filename = RMTDEBUG/pid.
+ *     DBG_PERM  - Open a permanent audit file, filename = RMTDEBUG/Rmtname.
+ *                 If a temp file already exists, it is mv'ed to be permanent.
+ *     DBG_CLEAN - Cleanup; unlink temp files.
  *
  *
- *     return codes:  none
+ * Restrictions - this code can only cope with one open debug file at a time.
+ * Each call creates a new file; if an old one of the same name exists it will
+ * be overwritten.
  */
  */
-
-fixmode(tty)
-register int tty;
+setdebug(parm)
+int parm;
 {
 {
-#ifdef USG
-       struct termio ttbuf;
-#endif
-#ifndef        USG
-       struct sgttyb ttbuf;
-#endif
+       char buf[BUFSIZ];               /* Buffer for building filenames     */
+       static char *temp = NULL;       /* Ptr to temporary file name        */
+       static int auditopen = 0;       /* Set to 1 when we open a file      */
+       struct stat stbuf;              /* File status buffer                */
 
 
-       if (IsTcpIp)
+       /*
+        * If movement or cleanup of a temp file is indicated, we do it no
+        * matter what.
+        */
+       if (temp != CNULL && parm == DBG_PERM) {
+               sprintf(buf, "%s/%s", RMTDEBUG, Rmtname);
+               unlink(buf);
+               if (link(temp, buf) != 0) {
+                       Debug = 0;
+                       assert("RMTDEBUG LINK FAIL", temp, errno);
+                       cleanup(1);
+               }
+               parm = DBG_CLEAN;
+       }
+       if (parm == DBG_CLEAN) {
+               if (temp != CNULL) {
+                       unlink(temp);
+                       free(temp);
+                       temp = CNULL;
+               }
                return;
                return;
-#ifdef USG
-       ioctl(tty, TCGETA, &ttbuf);
-       ttbuf.c_iflag = ttbuf.c_oflag = ttbuf.c_lflag = (ushort)0;
-       ttbuf.c_cflag &= (CBAUD);
-       ttbuf.c_cflag |= (CS8|CREAD);
-       ttbuf.c_cc[VMIN] = 6;
-       ttbuf.c_cc[VTIME] = 1;
-       ioctl(tty, TCSETA, &ttbuf);
-#endif
-#ifndef        USG
-       ioctl(tty, TIOCGETP, &ttbuf);
-       ttbuf.sg_flags = (ANYP | RAW);
-       ioctl(tty, TIOCSETP, &ttbuf);
-#endif
-#ifndef        USG
-       ioctl(tty, TIOCEXCL, STBNULL);
-#endif
-}
+       }
 
 
+       if (Debug == 0)
+               return;         /* Gotta be in debug to come here.   */
+
+       /*
+        * If we haven't opened a file already, we can just return if it's
+        * alright to use the stderr we came in with. We can if:
+        *
+        *      Role == MASTER, and Stderr is a regular file, a TTY or a pipe.
+        *
+        * Caution: Detecting when stderr is a pipe is tricky, because the 4.2
+        * man page for fstat(2) disagrees with reality, and System V leaves it
+        * undefined, which means different implementations act differently.
+        */
+       if (!auditopen && Role == MASTER) {
+               if (isatty(fileno(stderr)))
+                       return;
+               else if (fstat(fileno(stderr), &stbuf) == 0) {
+#ifdef USG
+                       /* Is Regular File or Fifo   */
+                       if ((stbuf.st_mode & 0060000) == 0)
+                               return;
+#else !USG
+#ifdef BSD4_2
+                                       /* Is Regular File */
+                       if ((stbuf.st_mode & S_IFMT) == S_IFREG ||
+                           stbuf.st_mode == 0)         /* Is a pipe */
+                               return;
+#else !BSD4_2
+                                        /* Is Regular File or Pipe  */
+                       if ((stbuf.st_mode & S_IFMT) == S_IFREG)
+                               return;
+#endif BSD4_2
+#endif USG
+               }
+       }
+
+       /*
+        * We need RMTDEBUG directory to do auditing. If the file doesn't exist,
+        * then we forget about debugging; if it exists but has improper owner-
+        * ship or modes, we gripe about it in ERRLOG. 
+        */
+       if (stat(RMTDEBUG, &stbuf) != SUCCESS) {
+               Debug = 0;
+               return;
+       }
+       if ((geteuid() != stbuf.st_uid) ||              /* We must own it    */
+           ((stbuf.st_mode & 0170700) != 040700)) {    /* Directory, rwx    */
+               Debug = 0;
+               assert("INVALID RMTDEBUG DIRECTORY:", RMTDEBUG, stbuf.st_mode);
+               return;
+       }
+
+       if (parm == DBG_TEMP) {
+               sprintf(buf, "%s/%d", RMTDEBUG, getpid());
+               temp = malloc(strlen (buf) + 1);
+               if (temp == CNULL) {
+                       Debug = 0;
+                       assert("RMTDEBUG MALLOC ERROR:", temp, errno);
+                       cleanup(1);
+               }
+               strcpy(temp, buf);
+       } else
+               sprintf(buf, "%s/%s", RMTDEBUG, Rmtname);
+
+       unlink(buf);
+       if (freopen(buf, "w", stderr) != stderr) {
+               Debug = 0;
+               assert("FAILED RMTDEBUG FILE OPEN:", buf, errno);
+               cleanup(1);
+       }
+       setbuf(stderr, CNULL);
+       auditopen = 1;
+}
 
 /*
 
 /*
- *     timeout()       catch SIGALRM routine
+ *     catch SIGALRM routine
  */
  */
-
 timeout()
 {
        extern int HaveSentHup;
 timeout()
 {
        extern int HaveSentHup;
index 714e73c..43228ff 100644 (file)
@@ -1,7 +1,10 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)condevs.c  5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)condevs.c  5.13 (Berkeley) %G%";
 #endif
 
 #endif
 
+extern int errno;
+extern char *sys_errlist[];
+
 /*
  * Here are various dialers to establish the machine-machine connection.
  * conn.c/condevs.c was glued together by Mike Mitchell.
 /*
  * Here are various dialers to establish the machine-machine connection.
  * conn.c/condevs.c was glued together by Mike Mitchell.
@@ -179,14 +182,16 @@ register char *flds[];
 
        sprintf(dcname, "/dev/%s", dev.D_line);
        if (setjmp(Sjbuf)) {
 
        sprintf(dcname, "/dev/%s", dev.D_line);
        if (setjmp(Sjbuf)) {
+               DEBUG(4, "Open timed out\n", CNULL);
                delock(dev.D_line);
                return CF_DIAL;
        }
        signal(SIGALRM, alarmtr);
                delock(dev.D_line);
                return CF_DIAL;
        }
        signal(SIGALRM, alarmtr);
-       alarm(10);
+       /* For PC Pursuit, it could take a while to call back */
+       alarm( strcmp(flds[F_LINE], "PCP") ? 10 : MAXMSGTIME*4 );
        getnextfd();
        errno = 0;
        getnextfd();
        errno = 0;
-        DEBUG(4,"Opening %s",dcname);
+        DEBUG(4,"Opening %s\n",dcname);
        dcr = open(dcname, 2); /* read/write */
 #ifdef VMSDTR  /* Modem control on vms(works dtr) */
        fflush(stdout);
        dcr = open(dcname, 2); /* read/write */
 #ifdef VMSDTR  /* Modem control on vms(works dtr) */
        fflush(stdout);
@@ -210,16 +215,19 @@ register char *flds[];
        }
 #endif VMSDTR
        next_fd = -1;
        }
 #endif VMSDTR
        next_fd = -1;
-       if (dcr < 0 && errno == EACCES)
-               logent(dcname, "CAN'T OPEN");
        alarm(0);
        if (dcr < 0) {
        alarm(0);
        if (dcr < 0) {
+               if (errno == EACCES)
+                       logent(dev.D_line, "CANT OPEN");
+               DEBUG(4, "OPEN FAILED: errno %d\n", errno);
                delock(dev.D_line);
                return CF_DIAL;
        }
        fflush(stdout);
                delock(dev.D_line);
                return CF_DIAL;
        }
        fflush(stdout);
-       if (fixline(dcr, dev.D_speed) == FAIL)
+       if (fixline(dcr, dev.D_speed) == FAIL) {
+               DEBUG(4, "FIXLINE FAILED\n", CNULL);
                return CF_DIAL;
                return CF_DIAL;
+       }
        strcpy(devSel, dev.D_line);     /* for latter unlock */
        CU_end = dircls;
        return dcr;
        strcpy(devSel, dev.D_line);     /* for latter unlock */
        CU_end = dircls;
        return dcr;
@@ -339,7 +347,6 @@ register char *flds[];
        return retval;
 }
 
        return retval;
 }
 
-#if defined(VENTEL) || defined(NOVATION) || defined(DF112)
 /*
  * intervaldelay:  delay execution for numerator/denominator seconds.
  */
 /*
  * intervaldelay:  delay execution for numerator/denominator seconds.
  */
@@ -401,13 +408,60 @@ register char *str;
        DEBUG(6, "slowrite ", CNULL);
        while (*str) {
                DEBUG(6, "%c", *str);
        DEBUG(6, "slowrite ", CNULL);
        while (*str) {
                DEBUG(6, "%c", *str);
-               uucpdelay(1,10);        /* delay 1/10 second */
+               uucpdelay(1, 10);       /* delay 1/10 second */
                write(fd, str, 1);
                str++;
        }
        DEBUG(6, "\n", CNULL);
 }
                write(fd, str, 1);
                str++;
        }
        DEBUG(6, "\n", CNULL);
 }
-#endif VENTEL || NOVATION || DF112
+
+#define BSPEED B150
+
+/*
+ *     send a break
+ */
+genbrk(fn, bnulls)
+register int fn, bnulls;
+{
+#ifdef USG
+       if (ioctl(fn, TCSBRK, STBNULL) < 0)
+               DEBUG(5, "break TCSBRK %s\n", sys_errlist[errno]);
+#else  !USG
+# ifdef        TIOCSBRK
+       if (ioctl(fn, TIOCSBRK, STBNULL) < 0)
+               DEBUG(5, "break TIOCSBRK %s\n", sys_errlist[errno]);
+# ifdef        TIOCCBRK
+       uucpdelay(bnulls, 10);
+       if (ioctl(fn, TIOCCBRK, STBNULL) < 0)
+               DEBUG(5, "break TIOCCBRK %s\n", sys_errlist[errno]);
+# endif TIOCCBRK
+       DEBUG(4, "ioctl %f second break\n", (float) bnulls/10 );
+# else !TIOCSBRK
+       struct sgttyb ttbuf;
+       register int sospeed;
+
+       if (ioctl(fn, TIOCGETP, &ttbuf) < 0)
+               DEBUG(5, "break TIOCGETP %s\n", sys_errlist[errno]);
+       sospeed = ttbuf.sg_ospeed;
+       ttbuf.sg_ospeed = BSPEED;
+       if (ioctl(fn, TIOCSETP, &ttbuf) < 0)
+               DEBUG(5, "break TIOCSETP %s\n", sys_errlist[errno]);
+       if (write(fn, "\0\0\0\0\0\0\0\0\0\0\0\0", bnulls) != bnulls) {
+badbreak:
+               logent(sys_errlist[errno], "BAD WRITE genbrk");
+               alarm(0);
+               longjmp(Sjbuf, 3);
+       }
+       ttbuf.sg_ospeed = sospeed;
+       if (ioctl(fn, TIOCSETP, &ttbuf) < 0)
+               DEBUG(5, "break ioctl %s\n", sys_errlist[errno]);
+       if (write(fn, "@", 1) != 1)
+               goto badbreak;
+       DEBUG(4, "sent BREAK nulls - %d\n", bnulls);
+#endif !TIOCSBRK
+#endif !USG
+}
+
 
 #ifdef DIALINOUT
 /* DIALIN/OUT CODE (WLS) */
 
 #ifdef DIALINOUT
 /* DIALIN/OUT CODE (WLS) */
index b77096d..7a2f4b5 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)conn.c     5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)conn.c     5.9 (Berkeley) %G%";
 #endif
 
 #include <signal.h>
 #endif
 
 #include <signal.h>
@@ -40,7 +40,8 @@ char  *AbortOn = NULL;
 char   par_tab[128];   /* must be power of two */
 int    linebaudrate;   /* used for the sleep test in pk1.c */
 int next_fd = -1;      /* predicted fd to close interrupted opens */
 char   par_tab[128];   /* must be power of two */
 int    linebaudrate;   /* used for the sleep test in pk1.c */
 int next_fd = -1;      /* predicted fd to close interrupted opens */
-                               /* rti!trt, courtesy unc!smb */
+
+char *PCP = "PCP";     /* PC Pursuit device type */
 /*
  *     catch alarm routine for "expect".
  */
 /*
  *     catch alarm routine for "expect".
  */
@@ -55,6 +56,37 @@ alarmtr()
        longjmp(Sjbuf, 1);
 }
 
        longjmp(Sjbuf, 1);
 }
 
+/* This template is for seismo to call ihnp4 
+ * the 3 lines marked ---> will be overwritten for the appropriate city
+ */
+#define PCP_BAUD       3
+#define PCP_PHONE      4
+#define PCP_CALLBACK   8
+#define PCP_CITY       10
+#define PCP_RPHONE     12
+#define NPCFIELDS      15
+
+static char *PCFlds[] = {
+       "PC-PURSUIT",
+       "Any",
+       "ACU",
+       "1200",
+       CNULL,  /* <--- **** Welcome to Telenet PC Pursuit ***** */
+       "ABORT",
+       "Good", /* Abort of Good bye! */
+       ")",    /* <--- Enter your 7-digit phone number (xxx-xxxx) */
+       CNULL,  /* ---> 528-1234 */
+       "call?",        /* <--- Which city do you wish to call? */
+       CNULL,  /* ---> CHICAGO */
+       ")",    /* <--- Enter the phone number you wish to call (xxx-xxxx) */
+       CNULL,  /* ---> 690-7171 */
+       "R)?",  /* <--- You are #1 in the queue. Do you want to wait, or Restart (Y/N/R)? */
+       "Y",
+       CNULL   /* <--- .....Good Bye! */
+};
+
+static char PCP_brand[20];
+
 /*
  *     place a telephone call to system and login, etc.
  *
 /*
  *     place a telephone call to system and login, etc.
  *
@@ -75,8 +107,7 @@ extern int LocalOnly;
 conn(system)
 char *system;
 {
 conn(system)
 char *system;
 {
-       int ret, nf;
-       register int fn = 0;
+       int nf;
        char info[MAXC], wkpre[NAMESIZE], file[NAMESIZE];
        register FILE *fsys;
        int fcode = 0;
        char info[MAXC], wkpre[NAMESIZE], file[NAMESIZE];
        register FILE *fsys;
        int fcode = 0;
@@ -92,18 +123,56 @@ keeplooking:
                if (LocalOnly) {
                        if (strcmp("TCP", Flds[F_LINE])
                                && strcmp("DIR", Flds[F_LINE])
                if (LocalOnly) {
                        if (strcmp("TCP", Flds[F_LINE])
                                && strcmp("DIR", Flds[F_LINE])
-                               && strcmp("LOCAL", Flds[F_LINE]) )
-                                       fn = CF_TIME;
+                               && strcmp("LOCAL", Flds[F_LINE]) ) {
+                                       fcode = CF_TIME;
+                                       continue;
+                       }
                }
                sprintf(wkpre, "%c.%.*s", CMDPRE, SYSNSIZE, Rmtname);
                if (!onesys && MaxGrade != DefMaxGrade &&
                }
                sprintf(wkpre, "%c.%.*s", CMDPRE, SYSNSIZE, Rmtname);
                if (!onesys && MaxGrade != DefMaxGrade &&
-                       !iswrk(file, "chk", Spool, wkpre)) 
-                               fn = CF_TIME;
-               if (fn != CF_TIME && (fn = getto(Flds)) > 0) {
-                       Dcf = fn;
-                       break;
+                       !iswrk(file, "chk", Spool, wkpre))  {
+                               fcode = CF_TIME;
+                               continue;
                }
                }
-               fcode = (fn == FAIL ? CF_DIAL : fn);
+               /* For GTE's PC Pursuit */
+               if (snccmp(Flds[F_LINE], PCP) == SAME) {
+                       FILE *dfp;
+                       int status;
+                       static struct Devices dev;
+                       dfp = fopen(DEVFILE, "r");
+                       ASSERT(dfp != NULL, "Can't open", DEVFILE, 0);
+                       while ((status=rddev(dfp, &dev)) != FAIL
+                               && strcmp(PCP, dev.D_type) != SAME)
+                                       ;
+                       fclose(dfp);
+                       if (status == FAIL)
+                               continue;
+                       if (mlock(PCP) == FAIL) {
+                               fcode = CF_NODEV;
+                               logent("DEVICE", "NO");
+                               continue;
+                       }
+                       PCFlds[PCP_BAUD] = dev.D_class;
+                       PCFlds[PCP_PHONE] = dev.D_calldev;
+                       PCFlds[PCP_CALLBACK] = dev.D_arg[D_CHAT];
+                       PCFlds[PCP_CITY] = Flds[F_CLASS];
+                       PCFlds[PCP_RPHONE] = Flds[F_PHONE];
+                       strncpy(PCP_brand, dev.D_brand, sizeof(PCP_brand));
+                       if ((fcode = getto(PCFlds)) < 0)
+                               continue;
+                       Dcf = fcode;
+                       fcode = login(NPCFIELDS, PCFlds, Dcf);
+                       clsacu(); /* Hang up, they'll call back */
+                       if (fcode != SUCCESS) {
+                               fcode = CF_DIAL;
+                               continue;
+                       }
+                       Flds[F_CLASS] = dev.D_class;
+                       Flds[F_PHONE] = dev.D_line;
+                       
+               } /* end PC Pursuit */
+               if ((fcode = getto(Flds)) > 0) 
+                       break;
        }
 
        if (nf <= 0) {
        }
 
        if (nf <= 0) {
@@ -111,11 +180,23 @@ keeplooking:
                return fcode ? fcode : nf;
        }
 
                return fcode ? fcode : nf;
        }
 
-       DEBUG(4, "login %s\n", "called");
-       ret = login(nf, Flds, fn);
-       if (ret != SUCCESS) {
+       Dcf = fcode;
+
+       if (fcode >= 0 && snccmp(Flds[F_LINE], PCP) == SAME) {
+               AbortOn = "Good";       /* .... Good Bye */
+               fcode = expect("****~300", Dcf);
+               if (fcode != SUCCESS) {
+                       DEBUG(4, "\nexpect timed out\n", CNULL);
+                       fcode = CF_DIAL;
+               }
+       }
+       if (fcode >= 0) {
+               DEBUG(4, "login %s\n", "called");
+               fcode = login(nf, Flds, Dcf);
+       }
+       if (fcode < 0) {
                clsacu();
                clsacu();
-               if (ret == ABORT) {
+               if (fcode == ABORT) {
                        fcode = CF_DIAL;
                        goto  keeplooking;
                } else {
                        fcode = CF_DIAL;
                        goto  keeplooking;
                } else {
@@ -124,8 +205,8 @@ keeplooking:
                }
        }
        fclose(fsys);
                }
        }
        fclose(fsys);
-       fioclex(fn);
-       return fn;
+       fioclex(Dcf);
+       return Dcf;
 }
 
 /*
 }
 
 /*
@@ -155,13 +236,23 @@ register char *flds[];
                reenable();
 #endif DIALINOUT
        CU_end = nulldev;
                reenable();
 #endif DIALINOUT
        CU_end = nulldev;
-       for (cd = condevs; cd->CU_meth != NULL; cd++) {
-               if (snccmp(cd->CU_meth, line) == SAME) {
-                       DEBUG(4, "Using %s to call\n", cd->CU_meth);
-                       return (*(cd->CU_gen))(flds);
+       if (snccmp(line, PCP) == SAME) {
+               for(cd = condevs; cd->CU_meth != NULL; cd++) {
+                       if (snccmp(PCP_brand, cd->CU_brand) == SAME) {
+                               CU_end = cd->CU_clos;
+                               return diropn(flds);
+                       }
                }
                }
+               logent(PCP_brand, "UNSUPPORTED ACU TYPE");
+       } else {
+               for (cd = condevs; cd->CU_meth != NULL; cd++) {
+                       if (snccmp(cd->CU_meth, line) == SAME) {
+                               DEBUG(4, "Using %s to call\n", cd->CU_meth);
+                               return (*(cd->CU_gen))(flds);
+                       }
+               }
+               DEBUG(1, "Can't find %s, assuming DIR\n", flds[F_LINE]);
        }
        }
-       DEBUG(1, "Can't find %s, assuming DIR\n", flds[F_LINE]);
        return diropn(flds);    /* search failed, so use direct */
 }
 
        return diropn(flds);    /* search failed, so use direct */
 }
 
@@ -180,7 +271,7 @@ clsacu()
         * easiest place to put the call.
         * Hopefully everyone honors the LCK protocol, of course
         */
         * easiest place to put the call.
         * Hopefully everyone honors the LCK protocol, of course
         */
-#ifndef        USG
+#ifdef TIOCNXCL
        if (!IsTcpIp && Dcf >= 0 && ioctl(Dcf, TIOCNXCL, STBNULL) < 0)
                DEBUG(5, "clsacu ioctl %s\n", sys_errlist[errno]);
 #endif
        if (!IsTcpIp && Dcf >= 0 && ioctl(Dcf, TIOCNXCL, STBNULL) < 0)
                DEBUG(5, "clsacu ioctl %s\n", sys_errlist[errno]);
 #endif
@@ -336,7 +427,7 @@ int nf, fn;
                                DEBUG(4, "ABORT ON: %s\n", AbortOn);
                                goto nextfield;
                        }
                                DEBUG(4, "ABORT ON: %s\n", AbortOn);
                                goto nextfield;
                        }
-                       DEBUG(4, "wanted: %s\n", want);
+                       DEBUG(4, "wanted \"%s\"\n", want);
                        ok = expect(want, fn);
                        DEBUG(4, "got: %s\n", ok ? "?" : "that");
                        if (ok == FAIL) {
                        ok = expect(want, fn);
                        DEBUG(4, "got: %s\n", ok ? "?" : "that");
                        if (ok == FAIL) {
@@ -471,7 +562,7 @@ int tty, spwant;
        return SUCCESS;
 }
 
        return SUCCESS;
 }
 
-/***
+/*
  *     getbaud(tty)    set linebaudrate variable
  *
  *     return codes:  none
  *     getbaud(tty)    set linebaudrate variable
  *
  *     return codes:  none
@@ -558,6 +649,7 @@ int fn;
        alarm(timo);
        *rp = 0;
        while (notin(str, rdvec)) {
        alarm(timo);
        *rp = 0;
        while (notin(str, rdvec)) {
+               int c;
                if(AbortOn != NULL && !notin(AbortOn, rdvec)) {
                        DEBUG(1, "Call aborted on '%s'\n", AbortOn);
                        alarm(0);
                if(AbortOn != NULL && !notin(AbortOn, rdvec)) {
                        DEBUG(1, "Call aborted on '%s'\n", AbortOn);
                        alarm(0);
@@ -570,15 +662,11 @@ int fn;
                        logent("LOGIN", "LOST LINE");
                        return FAIL;
                }
                        logent("LOGIN", "LOST LINE");
                        return FAIL;
                }
-               {
-               int c;
                c = nextch & 0177;
                c = nextch & 0177;
-               DEBUG(4, c >= 040 ? "%c" : "\\%03o", c);
-               if (c == '\n')
-                       DEBUG(4,"\n", CNULL);
-               }
-               if ((*rp = nextch & 0177) != '\0')
-                       rp++;
+               if (c == '\0')
+                       continue;
+               DEBUG(4, (isprint(c) || isspace(c)) ? "%c" : "\\%03o", c);
+               *rp++ = c;
                if (rp >= rdvec + MR) {
                        register char *p;
                        for (p = rdvec+MR/2; p < rp; p++)
                if (rp >= rdvec + MR) {
                        register char *p;
                        for (p = rdvec+MR/2; p < rp; p++)
@@ -617,7 +705,7 @@ int fn;
        register char c;
        static int p_init = 0;
 
        register char c;
        static int p_init = 0;
 
-       DEBUG(5, "send %s\n", str);
+       DEBUG(5, "send \"%s\"\n", str);
 
        if (!p_init) {
                p_init++;
 
        if (!p_init) {
                p_init++;
@@ -648,12 +736,16 @@ int fn;
        }
 
        /* Send a '\n' */
        }
 
        /* Send a '\n' */
-       if (strcmp(str, "LF") == SAME)
-               str = "\\n\\c";
+       if (strcmp(str, "LF") == SAME) {
+               p_chwrite(fn, '\n');
+               return;
+       }
 
        /* Send a '\r' */
 
        /* Send a '\r' */
-       if (strcmp(str, "CR") == SAME)
-               str = "\\r\\c";
+       if (strcmp(str, "CR") == SAME) {
+               p_chwrite(fn, '\r');
+               return;
+       }
 
        /* Set parity as needed */
        if (strcmp(str, "P_ZERO") == SAME) {
 
        /* Set parity as needed */
        if (strcmp(str, "P_ZERO") == SAME) {
@@ -679,20 +771,29 @@ int fn;
                return;
        }
 
                return;
        }
 
-       for (strptr = str; c = *strptr++;) {
+       strptr = str;
+       while ((c = *strptr++) != '\0') {
                if (c == '\\') {
                        switch(*strptr++) {
                if (c == '\\') {
                        switch(*strptr++) {
+                       case '\0':
+                               DEBUG(5, "TRAILING BACKSLASH IGNORED\n", CNULL);
+                               --strptr;
+                               continue;
                        case 's':
                                DEBUG(5, "BLANK\n", CNULL);
                        case 's':
                                DEBUG(5, "BLANK\n", CNULL);
-                               p_chwrite(fn, ' ');
+                               c = ' ';
                                break;
                        case 'd':
                                DEBUG(5, "DELAY\n", CNULL);
                                sleep(1);
                                continue;
                                break;
                        case 'd':
                                DEBUG(5, "DELAY\n", CNULL);
                                sleep(1);
                                continue;
+                       case 'n':
+                               DEBUG(5, "NEW LINE\n", CNULL);
+                               c = '\n';
+                               break;
                        case 'r':
                                DEBUG(5, "RETURN\n", CNULL);
                        case 'r':
                                DEBUG(5, "RETURN\n", CNULL);
-                               p_chwrite(fn, '\r');
+                               c = '\r';
                                break;
                        case 'b':
                                if (isdigit(*strptr)) {
                                break;
                        case 'b':
                                if (isdigit(*strptr)) {
@@ -710,24 +811,24 @@ int fn;
                                if (*strptr == '\0') {
                                        DEBUG(5, "NO CR\n", CNULL);
                                        cr = 0;
                                if (*strptr == '\0') {
                                        DEBUG(5, "NO CR\n", CNULL);
                                        cr = 0;
-                                       continue;
-                               }
-                               DEBUG(5, "NO CR - MIDDLE IGNORED\n", CNULL);
+                               } else
+                                       DEBUG(5, "NO CR - IGNORED NOT EOL\n", CNULL);
                                continue;
                                continue;
+#define isoctal(x)     ((x >= '0') && (x <= '7'))
                        default:
                        default:
-                               if (isdigit(*strptr)) {
+                               if (isoctal(strptr[-1])) {
                                        i = 0;
                                        n = 0;
                                        i = 0;
                                        n = 0;
-                                       while (isdigit(*strptr) && ++n <= 3)
-                                               i = i*8 + (*strptr++ - '0');
+                                       --strptr;
+                                       while (isoctal(*strptr) && ++n <= 3)
+                                               i = i * 8 + (*strptr++ - '0');
+                                       DEBUG(5, "\\%o\n", i);
                                        p_chwrite(fn, (char)i);
                                        continue;
                                }
                                        p_chwrite(fn, (char)i);
                                        continue;
                                }
-                               DEBUG(5, "BACKSLASH\n", CNULL);
-                               --strptr;
                        }
                        }
-               } else
-                       p_chwrite(fn, c);
+               }
+               p_chwrite(fn, c);
        }
 
        if (cr)
        }
 
        if (cr)
@@ -766,53 +867,6 @@ int type;
        }
 }
 
        }
 }
 
-#define BSPEED B150
-
-/*
- *     send a break
- */
-genbrk(fn, bnulls)
-register int fn, bnulls;
-{
-#ifdef USG
-       if (ioctl(fn, TCSBRK, STBNULL) < 0)
-               DEBUG(5, "break ioctl %s\n", sys_errlist[errno]);
-#else  !USG
-       struct sgttyb ttbuf;
-       register int sospeed;
-# ifdef        TIOCSBRK
-       if (ioctl(fn, TIOCSBRK, STBNULL) < 0)
-               DEBUG(5, "break ioctl %s\n", sys_errlist[errno]);
-# ifdef        TIOCCBRK
-       sleep(1);
-       if (ioctl(fn, TIOCCBRK, STBNULL) < 0)
-               DEBUG(5, "break ioctl %s\n", sys_errlist[errno]);
-# endif TIOCCBRK
-       DEBUG(4, "ioctl %d second break\n", bnulls );
-# else !TIOCSBRK
-
-       if (ioctl(fn, TIOCGETP, &ttbuf) < 0)
-               DEBUG(5, "break ioctl %s\n", sys_errlist[errno]);
-       sospeed = ttbuf.sg_ospeed;
-       ttbuf.sg_ospeed = BSPEED;
-       if (ioctl(fn, TIOCSETP, &ttbuf) < 0)
-               DEBUG(5, "break ioctl %s\n", sys_errlist[errno]);
-       if (write(fn, "\0\0\0\0\0\0\0\0\0\0\0\0", bnulls) != bnulls) {
-badbreak:
-               logent(sys_errlist[errno], "BAD WRITE genbrk");
-               alarm(0);
-               longjmp(Sjbuf, 3);
-       }
-       ttbuf.sg_ospeed = sospeed;
-       if (ioctl(fn, TIOCSETP, &ttbuf) < 0)
-               DEBUG(5, "break ioctl %s\n", sys_errlist[errno]);
-       if (write(fn, "@", 1) != 1)
-               goto badbreak;
-       DEBUG(4, "sent BREAK nulls - %d\n", bnulls);
-#endif !TIOCSBRK
-#endif !USG
-}
-
 /*
  *     check for occurrence of substring "sh"
  *
 /*
  *     check for occurrence of substring "sh"
  *
@@ -838,7 +892,7 @@ register char *sh, *lg;
 ifdate(p)
 register char *p;
 {
 ifdate(p)
 register char *p;
 {
-       register char *np, c;
+       register char *np;
        register int ret, g;
        int rtime, i;
 
        register int ret, g;
        int rtime, i;
 
@@ -931,6 +985,12 @@ char *string;
                                || (tp->tm_wday == 0 && tp->tm_hour < 17))
                                        dayok = 1;
                }
                                || (tp->tm_wday == 0 && tp->tm_hour < 17))
                                        dayok = 1;
                }
+               if (prefix("NonPeak", s)) { /* For Tymnet and PC Pursuit */
+                       /* Sat or Sun */
+                       if (tp->tm_wday == 6 || tp->tm_wday == 0
+                               || tp->tm_hour >= 18 || tp->tm_hour < 7)
+                                       dayok = 1;
+               }
                s++;
        }
 
                s++;
        }
 
@@ -1078,3 +1138,47 @@ int fd;
                sleep(2);
        return(i);
 }
                sleep(2);
        return(i);
 }
+
+/*
+ *     fix kill/echo/raw on line
+ *
+ *     return codes:  none
+ */
+fixmode(tty)
+register int tty;
+{
+#ifdef USG
+       struct termio ttbuf;
+#else  !USG
+       struct sgttyb ttbuf;
+#endif !USG
+       register struct sg_spds *ps;
+       int speed;
+
+       if (IsTcpIp)
+               return;
+#ifdef USG
+       ioctl(tty, TCGETA, &ttbuf);
+       ttbuf.c_iflag = ttbuf.c_oflag = ttbuf.c_lflag = (ushort)0;
+       speed = ttbuf.c_cflag &= (CBAUD);
+       ttbuf.c_cflag |= (CS8|CREAD);
+       ttbuf.c_cc[VMIN] = 6;
+       ttbuf.c_cc[VTIME] = 1;
+       ioctl(tty, TCSETA, &ttbuf);
+#else  !USG
+       ioctl(tty, TIOCGETP, &ttbuf);
+       ttbuf.sg_flags = (ANYP | RAW);
+       ioctl(tty, TIOCSETP, &ttbuf);
+       speed = ttbuf.sg_ispeed;
+       ioctl(tty, TIOCEXCL, STBNULL);
+#endif !USG
+
+       for (ps = spds; ps->sp_val; ps++)
+               if (ps->sp_name == speed) {
+                       linebaudrate = ps->sp_val;
+                       DEBUG(9,"Incoming baudrate is %d\n", linebaudrate);
+                       return;
+               }
+       ASSERT(linebaudrate >= 0, "BAD SPEED", CNULL, speed);
+}
+
index 71ca3e9..d9ea0ea 100644 (file)
@@ -1,8 +1,9 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)imsg.c     5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)imsg.c     5.3 (Berkeley) %G%";
 #endif
 
 #include "uucp.h"
 #endif
 
 #include "uucp.h"
+#include <ctype.h>
 
 char Msync[2] = "\020";
 
 
 char Msync[2] = "\020";
 
@@ -22,53 +23,49 @@ char Mend = '\0';
  *     used before a protocol is agreed upon.
  *
  *     return codes:
  *     used before a protocol is agreed upon.
  *
  *     return codes:
- *             EOF - no more messages
- *             0 - message returned
+ *             FAIL - no more messages
+ *             SUCCESS - message returned
  */
 
  */
 
-imsg(msg, fn)
-register char *msg;
+imsg(amsg, fn)
+char *amsg;
 register int fn;
 {
 register int fn;
 {
-       register int ret;
-       char *amsg;
+       register char *msg = amsg;
+       int foundsync = FAIL;
+       char c;
 
 
-       DEBUG(5, "imsg %s<", "sync");
-       while ((ret = read(fn, msg, 1)) == 1) {
-               *msg &= 0177;
-               DEBUG(5, (*msg>037 && *msg<0177) ? "%c" : "\\%03o", *msg & 0377);
-               if (*msg == Msync[0])
-                       break;
-               fflush(stderr);
-       }
-       DEBUG(5, ">got %s\n", ret == 1 ? "it" : "EOF");
-       if (ret < 1)
-               return EOF;
-       amsg = msg;
-resync:
-       DEBUG(5, "imsg %s<", "input");
-       while (read(fn, msg, 1) == 1) {
-               *msg &= 0177;
-               DEBUG(5, (*msg>037 && *msg<0177) ? "%c" : "\\%03o", *msg & 0377);
-               if (*msg == Msync[0]) {
-                       DEBUG(5, "%s\n", ">found sync");
+       DEBUG(5, "imsg looking for SYNC<", CNULL);
+       for (;;) {
+               if (read(fn, &c, 1) != 1)
+                       return FAIL;
+               c &= 0177;
+               if (c == '\n' || c == '\r')
+                       DEBUG(5, "%c", c);
+               else 
+                       DEBUG(5, (isprint(c) || isspace(c)) ? "%c" : "\\%o",
+                               c & 0377);
+               if (c == Msync[0]) {
+                       DEBUG(5, ">\nimsg input<", CNULL);
                        msg = amsg;
                        msg = amsg;
-                       goto resync;
-               }
-               if (*msg == '\n' || *msg == '\0') {
+                       foundsync = SUCCESS;
+                       continue;
+               } else if (foundsync != SUCCESS)
+                               continue;
+               if (c == '\n' || c == '\0') {
                        if (!seenend) {
                        if (!seenend) {
-                               Mend = *msg;
+                               Mend = c;
                                seenend++;
                                seenend++;
-                               DEBUG(6,"\nUsing \\%o as End of message char\n", Mend);
+                               DEBUG(9, "\nUsing \\%o as End of message char\n", Mend);
                        }
                        break;
                }
                        }
                        break;
                }
-               msg++;
+               *msg++ = c;
                fflush(stderr);
        }
        *msg = '\0';
                fflush(stderr);
        }
        *msg = '\0';
-       DEBUG(5, ">got %d\n", strlen(amsg));
-       return 0;
+       DEBUG(5, ">got %d characters\n", strlen(amsg));
+       return foundsync;
 }
 
 
 }
 
 
index 99b7275..61594ae 100644 (file)
@@ -1,4 +1,4 @@
-/*     pk.h    5.3     85/04/10        */
+/*     pk.h    5.4     86/01/06        */
 
 struct header {
        char    sync;
 
 struct header {
        char    sync;
@@ -8,9 +8,11 @@ struct header {
        char    ccntl;
 };
 
        char    ccntl;
 };
 
-#define        HDRSIZ  6
-#define        PACKSIZE        64
-#define WINDOWS        3
+#define        HDRSIZ          6       /* Packet header size */
+#define        PACKSIZE        64      /* Standard packet size */
+#define WINDOWS                3
+
+#define TAILSIZE       2       /* Number of trailing nulls after packet    */
 
 struct pack {
        short   p_state;        /* line state */
 
 struct pack {
        short   p_state;        /* line state */
@@ -50,7 +52,6 @@ struct pack {
 #define        CHECK   0125252
 #define        SYN     020
 #define        MOD8    7
 #define        CHECK   0125252
 #define        SYN     020
 #define        MOD8    7
-#define        PKASSERT(e, s1, s2, i1) if (!(e)) {assert(s1, s2, i1);pkfail();} else
 #define        ISCNTL(a)       ((a & 0300)==0)
 /* MIN may have been defined in <sys/param.h> */
 #undef MIN
 #define        ISCNTL(a)       ((a & 0300)==0)
 /* MIN may have been defined in <sys/param.h> */
 #undef MIN
@@ -58,8 +59,6 @@ struct pack {
 
 extern char    next[8];
 extern char    mask[8];
 
 extern char    next[8];
 extern char    mask[8];
-extern int     npbits;
-extern int     pkactive;
 
 /*
  * driver state
 
 /*
  * driver state
@@ -105,16 +104,14 @@ extern int        pkactive;
 #define        INITB   6
 #define        INITA   7
 
 #define        INITB   6
 #define        INITA   7
 
-#define        M_RJ    4
+#define        M_CLOSE 002
+#define        M_RJ    004
 #define        M_SRJ   010
 #define        M_RR    020
 #define        M_INITC 040
 #define        M_SRJ   010
 #define        M_RR    020
 #define        M_INITC 040
-#define        M_CLOSE 2
 #define        M_INITA 0200
 #define        M_INITB 0100
 
 #define        M_INITA 0200
 #define        M_INITB 0100
 
-#define        PKOPRI  31
-#define        PKIPRI  30
 #define        NPLINES 20
 
 /*
 #define        NPLINES 20
 
 /*
@@ -128,5 +125,4 @@ struct      piocb {
        char    window;
 };
 
        char    window;
 };
 
-extern int pkdebug;
 extern int pksizes[];
 extern int pksizes[];
index 8d0789d..44ffbe9 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)pk0.c      5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)pk0.c      5.5 (Berkeley) %G%";
 #endif
 
 #include "uucp.h"
 #endif
 
 #include "uucp.h"
@@ -13,7 +13,9 @@ char next[8] = { 1, 2, 3, 4, 5, 6, 7, 0};     /* packet sequence numbers */
 char mask[8] = { 1, 2, 4, 010, 020, 040, 0100, 0200 };
 
 struct pack *pklines[NPLINES];
 char mask[8] = { 1, 2, 4, 010, 020, 040, 0100, 0200 };
 
 struct pack *pklines[NPLINES];
-int    pkactive;
+
+#define PKTIME 4
+extern int pktimeout, Ntimeout;
 
 /*
  * receive control messages
 
 /*
  * receive control messages
@@ -220,6 +222,8 @@ int icount;
 
        xfr = 0;
        count = 0;
 
        xfr = 0;
        count = 0;
+       pktimeout = PKTIME;
+       Ntimeout = 0;
        while (pkaccept(pk) == 0)
                ;
 
        while (pkaccept(pk) == 0)
                ;
 
@@ -283,6 +287,8 @@ int icount;
                return -1;
        }
 
                return -1;
        }
 
+       pktimeout = PKTIME;
+       Ntimeout = 0;
        count = icount;
        do {
                while (pk->p_xcount>=pk->p_swindow)  {
        count = icount;
        do {
                while (pk->p_xcount>=pk->p_swindow)  {
index 8811e35..93e57fa 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)pk1.c      5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)pk1.c      5.7 (Berkeley) %G%";
 #endif
 
 #include <signal.h>
 #endif
 
 #include <signal.h>
@@ -18,9 +18,9 @@ int iomask[2];
 #endif VMS
 
 #define PKMAXSTMSG 40
 #endif VMS
 
 #define PKMAXSTMSG 40
-#define        PKTIME  25
+#define        MAXPKTIME 32    /* was 16 */
 #define CONNODATA 10
 #define CONNODATA 10
-#define NTIMEOUT 10
+#define MAXTIMEOUT 32
 
 extern int errno;
 extern int Retries;
 
 extern int errno;
 extern int Retries;
@@ -30,6 +30,7 @@ extern        char *malloc();
 
 int Connodata = 0;
 int Ntimeout = 0;
 
 int Connodata = 0;
 int Ntimeout = 0;
+int pktimeout = 4;
 /*
  * packet driver support routines
  *
 /*
  * packet driver support routines
  *
@@ -49,8 +50,6 @@ int ifn, ofn;
        register char **bp;
        register int i;
 
        register char **bp;
        register int i;
 
-       if (++pkactive >= NPLINES)
-               return NULL;
        if ((pk = (struct pack *) malloc(sizeof (struct pack))) == NULL)
                return NULL;
        bzero((caddr_t) pk, sizeof (struct pack));
        if ((pk = (struct pack *) malloc(sizeof (struct pack))) == NULL)
                return NULL;
        bzero((caddr_t) pk, sizeof (struct pack));
@@ -65,8 +64,10 @@ int ifn, ofn;
                *bp = (char *) pk->p_ipool;
                pk->p_ipool = bp;
        }
                *bp = (char *) pk->p_ipool;
                pk->p_ipool = bp;
        }
-       if (i == 0)
+       if (i == 0) {
+               DEBUG(1, "pkopen: can't malloc i = 0\n", CNULL);
                return NULL;
                return NULL;
+       }
        pk->p_rwindow = i;
 
        /* start synchronization */
        pk->p_rwindow = i;
 
        /* start synchronization */
@@ -77,8 +78,10 @@ int ifn, ofn;
                        break;
                }
        }
                        break;
                }
        }
-       if (i >= NPLINES)
+       if (i >= NPLINES) {
+               DEBUG(1,"pkopen: i>=NPLINES\n", CNULL);
                return NULL;
                return NULL;
+       }
        pkoutput(pk);
 
        for (i = 0; i < PKMAXSTMSG; i++) {
        pkoutput(pk);
 
        for (i = 0; i < PKMAXSTMSG; i++) {
@@ -86,8 +89,10 @@ int ifn, ofn;
                if ((pk->p_state & LIVE) != 0)
                        break;
        }
                if ((pk->p_state & LIVE) != 0)
                        break;
        }
-       if (i >= PKMAXSTMSG)
+       if (i >= PKMAXSTMSG) {
+               DEBUG(1, "pkopen: i>= PKMAXSTMSG\n", CNULL);
                return NULL;
                return NULL;
+       }
 
        pkreset(pk);
        return pk;
 
        pkreset(pk);
        return pk;
@@ -113,25 +118,23 @@ int pksizes[] = {
        1, 32, 64, 128, 256, 512, 1024, 2048, 4096, 1
 };
 
        1, 32, 64, 128, 256, 512, 1024, 2048, 4096, 1
 };
 
-#define GETRIES 5
+#define GETRIES 10
 /*
  * Pseudo-dma byte collection.
  */
 
 /*
  * Pseudo-dma byte collection.
  */
 
-pkgetpack(ipk)
-struct pack *ipk;
+pkgetpack(pk)
+register struct pack *pk;
 {
        int k, tries, noise;
        register char *p;
 {
        int k, tries, noise;
        register char *p;
-       register struct pack *pk;
        register struct header *h;
        unsigned short sum;
        int ifn;
        char **bp;
        char hdchk;
 
        register struct header *h;
        unsigned short sum;
        int ifn;
        char **bp;
        char hdchk;
 
-       pk = ipk;
-       if ((pk->p_state & DOWN) || Connodata > CONNODATA || Ntimeout > NTIMEOUT)
+       if ((pk->p_state & DOWN) || Connodata > CONNODATA || Ntimeout > MAXTIMEOUT)
                pkfail();
        ifn = pk->p_ifn;
 
                pkfail();
        ifn = pk->p_ifn;
 
@@ -142,10 +145,11 @@ struct pack *ipk;
                        if (*p++ == SYN) {
                                if (pkcget(ifn, p, HDRSIZ-1) == SUCCESS)
                                        break;
                        if (*p++ == SYN) {
                                if (pkcget(ifn, p, HDRSIZ-1) == SUCCESS)
                                        break;
-                       } else
-                               if (noise++ < (3*pk->p_rsize))
+                       } else {
+                               if (noise++ < 10 || noise < (3*pk->p_rsize))
                                        continue;
                                        continue;
-                       DEBUG(4, "Noisy line - set up RXMIT", "");
+                       }
+                       DEBUG(4, "Noisy line - set up RXMIT\n", CNULL);
                        noise = 0;
                }
                /* set up retransmit or REJ */
                        noise = 0;
                }
                /* set up retransmit or REJ */
@@ -157,12 +161,6 @@ struct pack *ipk;
                if ((pk->p_state & LIVE) == LIVE)
                        pk->p_state |= RXMIT;
                pkoutput(pk);
                if ((pk->p_state & LIVE) == LIVE)
                        pk->p_state |= RXMIT;
                pkoutput(pk);
-
-               if (*p != SYN)
-                       continue;
-               p++;
-               if (pkcget(ifn, p, HDRSIZ - 1) == SUCCESS)
-                       break;
        }
        if (tries >= GETRIES) {
                DEBUG(4, "tries = %d\n", tries);
        }
        if (tries >= GETRIES) {
                DEBUG(4, "tries = %d\n", tries);
@@ -170,7 +168,7 @@ struct pack *ipk;
        }
 
        Connodata++;
        }
 
        Connodata++;
-       h = (struct header * ) &pk->p_ihbuf;
+       h = (struct header *) &pk->p_ihbuf;
        p = (caddr_t) h;
        hdchk = p[1] ^ p[2] ^ p[3] ^ p[4];
        p += 2;
        p = (caddr_t) h;
        hdchk = p[1] ^ p[2] ^ p[3] ^ p[4];
        p += 2;
@@ -199,19 +197,18 @@ struct pack *ipk;
        if (k && pksizes[k] == pk->p_rsize) {
                pk->p_rpr = h->cntl & MOD8;
                pksack(pk);
        if (k && pksizes[k] == pk->p_rsize) {
                pk->p_rpr = h->cntl & MOD8;
                pksack(pk);
-               Connodata = 0;
                bp = pk->p_ipool;
                if (bp == NULL) {
                        DEBUG(7, "bp NULL %s\n", "");
                        return;
                }
                pk->p_ipool = (char **) *bp;
                bp = pk->p_ipool;
                if (bp == NULL) {
                        DEBUG(7, "bp NULL %s\n", "");
                        return;
                }
                pk->p_ipool = (char **) *bp;
-       } else {
+               Connodata = 0;
+       } else
                return;
                return;
-       }
+
        if (pkcget(pk->p_ifn, (char *) bp, pk->p_rsize) == SUCCESS)
                pkdata(h->cntl, h->sum, pk, (char **) bp);
        if (pkcget(pk->p_ifn, (char *) bp, pk->p_rsize) == SUCCESS)
                pkdata(h->cntl, h->sum, pk, (char **) bp);
-       Ntimeout = 0;
 }
 
 pkdata(c, sum, pk, bp)
 }
 
 pkdata(c, sum, pk, bp)
@@ -247,8 +244,6 @@ slot:
        pk->p_ib[x] = (char *)bp;
 }
 
        pk->p_ib[x] = (char *)bp;
 }
 
-
-
 /*
  * setup input transfers
  */
 /*
  * setup input transfers
  */
@@ -274,8 +269,7 @@ register x;
        if (x < 0) {
                *p++ = hdchk = 9;
                checkword = cntl;
        if (x < 0) {
                *p++ = hdchk = 9;
                checkword = cntl;
-       }
-       else {
+       } else {
                *p++ = hdchk = pk->p_lpsize;
                checkword = pk->p_osum[x] ^ (unsigned)(cntl & 0377);
        }
                *p++ = hdchk = pk->p_lpsize;
                checkword = pk->p_osum[x] ^ (unsigned)(cntl & 0377);
        }
@@ -296,15 +290,19 @@ register x;
                        logent("PKXSTART write failed", sys_errlist[errno]);
                        longjmp(Sjbuf, 4);
                }
                        logent("PKXSTART write failed", sys_errlist[errno]);
                        longjmp(Sjbuf, 4);
                }
-       }
-       else {
-               char buf[PKMAXBUF + HDRSIZ], *b;
+       } else {
+               char buf[PKMAXBUF + HDRSIZ + TAILSIZE], *b;
                int i;
                for (i = 0, b = buf; i < HDRSIZ; i++)
                        *b++ = *p++;
                for (i = 0, p = pk->p_ob[x]; i < pk->p_xsize; i++)
                        *b++ = *p++;
                int i;
                for (i = 0, b = buf; i < HDRSIZ; i++)
                        *b++ = *p++;
                for (i = 0, p = pk->p_ob[x]; i < pk->p_xsize; i++)
                        *b++ = *p++;
-               if (write(pk->p_ofn, buf, pk->p_xsize + HDRSIZ) != (HDRSIZ + pk->p_xsize)) {
+#if TAILSIZE != 0
+               for (i = 0; i < TAILSIZE; i++)
+                       *b++ = '\0';
+#endif TAILSIZE
+               if (write(pk->p_ofn, buf, pk->p_xsize + HDRSIZ + TAILSIZE)
+                   != (HDRSIZ + TAILSIZE + pk->p_xsize)) {
                        alarm(0);
                        logent("PKXSTART write failed", sys_errlist[errno]);
                        longjmp(Sjbuf, 5);
                        alarm(0);
                        logent("PKXSTART write failed", sys_errlist[errno]);
                        longjmp(Sjbuf, 5);
@@ -335,11 +333,8 @@ int count, flag;
 }
 
 
 }
 
 
-/***
- *     pkcget(fn, b, n)        get n characters from input
- *     char *b;                - buffer for characters
- *     int fn;                 - file descriptor
- *     int n;                  - requested number of characters
+/*
+ *     get n characters from input
  *
  *     return codes:
  *             n - number of characters returned
  *
  *     return codes:
  *             n - number of characters returned
@@ -354,8 +349,8 @@ cgalarm()
 
 pkcget(fn, b, n)
 int fn;
 
 pkcget(fn, b, n)
 int fn;
-register int n;
 register char *b;
 register char *b;
+register int n;
 {
        register int ret;
        extern int linebaudrate;
 {
        register int ret;
        extern int linebaudrate;
@@ -371,12 +366,15 @@ register char *b;
 
        if (setjmp(Getjbuf)) {
                Ntimeout++;
 
        if (setjmp(Getjbuf)) {
                Ntimeout++;
+               pktimeout += 2;
+               if (pktimeout > MAXPKTIME)
+                       pktimeout = MAXPKTIME;
                DEBUG(4, "pkcget: alarm %d\n", Ntimeout);
                return FAIL;
        }
        signal(SIGALRM, cgalarm);
 
                DEBUG(4, "pkcget: alarm %d\n", Ntimeout);
                return FAIL;
        }
        signal(SIGALRM, cgalarm);
 
-       alarm(PKTIME);
+       alarm(pktimeout);
        while (n > 0) {
 #ifdef BSD4_2
                if (linebaudrate > 0) {
        while (n > 0) {
 #ifdef BSD4_2
                if (linebaudrate > 0) {