BSD 4_3 release
[unix-history] / usr / src / usr.bin / tip / aculib / df.c
index e692b12..78e570d 100644 (file)
-/*     df.c    4.1     81/05/09        */
 /*
 /*
- * Dial the DF02-AC
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)df.c       5.1 (Berkeley) 6/6/85";
+#endif not lint
+
+/*
+ * Dial the DF02-AC or DF03-AC
  */
 
 #include "tip.h"
  */
 
 #include "tip.h"
-#if DF02
-#include <setjmp.h>
 
 
-static jmp_buf Sjbuf;
+static jmp_buf Sjbuf;
 static timeout();
 
 static timeout();
 
-df_dialer(num, acu)
-char *num, *acu;
+df02_dialer(num, acu)
+       char *num, *acu;
+{
+
+       return (df_dialer(num, acu, 0));
+}
+
+df03_dialer(num, acu)
+       char *num, *acu;
+{
+
+       return (df_dialer(num, acu, 1));
+}
+
+df_dialer(num, acu, df03)
+       char *num, *acu;
+       int df03;
 {
        register int f = FD;
 {
        register int f = FD;
-       int c;
+       struct sgttyb buf;
+       int speed = 0, rw = 2;
+       char c = '\0';
 
        ioctl(f, TIOCHPCL, 0);          /* make sure it hangs up when done */
        if (setjmp(Sjbuf)) {
                printf("connection timed out\r\n");
                df_disconnect();
 
        ioctl(f, TIOCHPCL, 0);          /* make sure it hangs up when done */
        if (setjmp(Sjbuf)) {
                printf("connection timed out\r\n");
                df_disconnect();
-               return(0);
+               return (0);
        }
        if (boolean(value(VERBOSE)))
                printf("\ndialing...");
        fflush(stdout);
        }
        if (boolean(value(VERBOSE)))
                printf("\ndialing...");
        fflush(stdout);
+#ifdef TIOCMSET
+       if (df03) {
+               int st = TIOCM_ST;      /* secondary Transmit flag */
+
+               ioctl(f, TIOCGETP, &buf);
+               if (buf.sg_ospeed != B1200) {   /* must dial at 1200 baud */
+                       speed = buf.sg_ospeed;
+                       buf.sg_ospeed = buf.sg_ispeed = B1200;
+                       ioctl(f, TIOCSETP, &buf);
+                       ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */
+               } else
+                       ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
+       }
+#endif
        signal(SIGALRM, timeout);
        alarm(5 * strlen(num) + 10);
        signal(SIGALRM, timeout);
        alarm(5 * strlen(num) + 10);
-       ioctl(f, TIOCFLUSH, 0);
+       ioctl(f, TIOCFLUSH, &rw);
        write(f, "\001", 1);
        write(f, "\001", 1);
-       sleep(0);               /* this must waste 70 ms. */
+       sleep(1);
        write(f, "\002", 1);
        write(f, num, strlen(num));
        write(f, "\002", 1);
        write(f, num, strlen(num));
-       c = 0;
-       read(f, (char *)&c, 1);
-       return(c == 'A');
+       read(f, &c, 1);
+#ifdef TIOCMSET
+       if (df03 && speed) {
+               buf.sg_ispeed = buf.sg_ospeed = speed;
+               ioctl(f, TIOCSETP, &buf);
+       }
+#endif
+       return (c == 'A');
 }
 
 }
 
-
 df_disconnect()
 {
 df_disconnect()
 {
+       int rw = 2;
+
        write(FD, "\001", 1);
        sleep(1);
        write(FD, "\001", 1);
        sleep(1);
-       ioctl(FD, TIOCFLUSH, 0);
+       ioctl(FD, TIOCFLUSH, &rw);
 }
 
 
 df_abort()
 {
 }
 
 
 df_abort()
 {
-       write(FD, "\001", 1);
-       sleep(1);
-       ioctl(FD, TIOCFLUSH, 0);
+
+       df_disconnect();
 }
 
 
 static
 timeout()
 {
 }
 
 
 static
 timeout()
 {
+
        longjmp(Sjbuf, 1);
 }
        longjmp(Sjbuf, 1);
 }
-#endif