Phone numbers in the phones file end in ',' or '\n'.
[unix-history] / usr / src / usr.bin / tip / acu.c
index a04f1ba..d9c53eb 100644 (file)
@@ -1,6 +1,14 @@
-/*     acu.c   4.6     82/02/02        */
+/*
+ * 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[] = "@(#)acu.c      5.3 (Berkeley) %G%";
+#endif not lint
+
 #include "tip.h"
 #include "tip.h"
-#include <setjmp.h>
 
 static acu_t *acu = NOACU;
 static int conflag;
 
 static acu_t *acu = NOACU;
 static int conflag;
@@ -33,7 +41,7 @@ connect()
 
        if (!DU) {              /* regular connect message */
                if (CM != NOSTR)
 
        if (!DU) {              /* regular connect message */
                if (CM != NOSTR)
-                       write(FD, cp, size(CM));
+                       pwrite(FD, CM, size(CM));
                return (NOSTR);
        }
        /*
                return (NOSTR);
        }
        /*
@@ -50,7 +58,7 @@ connect()
                if (acu != NOACU) {
                        boolean(value(VERBOSE)) = FALSE;
                        if (conflag)
                if (acu != NOACU) {
                        boolean(value(VERBOSE)) = FALSE;
                        if (conflag)
-                               disconnect();
+                               disconnect(NOSTR);
                        else
                                (*acu->acu_abort)();
                }
                        else
                                (*acu->acu_abort)();
                }
@@ -61,7 +69,7 @@ connect()
                return ("unknown ACU type");
        if (*cp != '@') {
                while (*cp) {
                return ("unknown ACU type");
        if (*cp != '@') {
                while (*cp) {
-                       for (phnum = cp; any(*cp, "0123456789-*="); cp++)
+                       for (phnum = cp; *cp && *cp != ','; cp++)
                                ;
                        if (*cp)
                                *cp++ = '\0';
                                ;
                        if (*cp)
                                *cp++ = '\0';
@@ -72,7 +80,7 @@ connect()
                                return (NOSTR);
                        } else
                                logent(value(HOST), phnum, acu->acu_name,
                                return (NOSTR);
                        } else
                                logent(value(HOST), phnum, acu->acu_name,
-                                       "no answer");
+                                       "call failed");
                        tried++;
                }
        } else {
                        tried++;
                }
        } else {
@@ -96,9 +104,10 @@ connect()
                                fclose(fd);
                                return ("missing phone number");
                        }
                                fclose(fd);
                                return ("missing phone number");
                        }
-                       for (phnum = cp; any(*cp, "0123456789-*="); cp++)
+                       for (phnum = cp; *cp && *cp != ',' && *cp != '\n'; cp++)
                                ;
                                ;
-                       *cp = '\0';
+                       if (*cp)
+                               *cp++ = '\0';
                        
                        if (conflag = (*acu->acu_dialer)(phnum, CU)) {
                                fclose(fd);
                        
                        if (conflag = (*acu->acu_dialer)(phnum, CU)) {
                                fclose(fd);
@@ -107,23 +116,29 @@ connect()
                                return (NOSTR);
                        } else
                                logent(value(HOST), phnum, acu->acu_name,
                                return (NOSTR);
                        } else
                                logent(value(HOST), phnum, acu->acu_name,
-                                       "no answer");
+                                       "call failed");
                        tried++;
                }
                fclose(fd);
        }
        if (!tried)
                logent(value(HOST), "", acu->acu_name, "missing phone number");
                        tried++;
                }
                fclose(fd);
        }
        if (!tried)
                logent(value(HOST), "", acu->acu_name, "missing phone number");
-       return (tried ? "no answer" : "missing phone number");
+       else
+               (*acu->acu_abort)();
+       return (tried ? "call failed" : "missing phone number");
 }
 
 }
 
-disconnect()
+disconnect(reason)
+       char *reason;
 {
        if (!conflag)
                return;
 {
        if (!conflag)
                return;
-       logent(value(HOST), "", acu->acu_name, "call terminated");
-       if (boolean(value(VERBOSE)))
-               printf("\r\ndisconnecting...");
+       if (reason == NOSTR) {
+               logent(value(HOST), "", acu->acu_name, "call terminated");
+               if (boolean(value(VERBOSE)))
+                       printf("\r\ndisconnecting...");
+       } else 
+               logent(value(HOST), "", acu->acu_name, reason);
        (*acu->acu_disconnect)();
 }
 
        (*acu->acu_disconnect)();
 }