1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)v3451.c	5.1 (Berkeley) 4/30/85";
   9: #endif not lint
  10: 
  11: /*
  12:  * Routines for calling up on a Vadic 3451 Modem
  13:  */
  14: #include "tip.h"
  15: 
  16: static  jmp_buf Sjbuf;
  17: 
  18: v3451_dialer(num, acu)
  19:     register char *num;
  20:     char *acu;
  21: {
  22:     int ok, (*func)();
  23:     int slow = number(value(BAUDRATE)) < 1200, rw = 2;
  24:     char phone[50];
  25: #ifdef ACULOG
  26:     char line[80];
  27: #endif
  28: 
  29:     /*
  30: 	 * Get in synch
  31: 	 */
  32:     vawrite("I\r", 1 + slow);
  33:     vawrite("I\r", 1 + slow);
  34:     vawrite("I\r", 1 + slow);
  35:     vawrite("\005\r", 2 + slow);
  36:     if (!expect("READY")) {
  37:         printf("can't synchronize with vadic 3451\n");
  38: #ifdef ACULOG
  39:         logent(value(HOST), num, "vadic", "can't synch up");
  40: #endif
  41:         return (0);
  42:     }
  43:     ioctl(FD, TIOCHPCL, 0);
  44:     sleep(1);
  45:     vawrite("D\r", 2 + slow);
  46:     if (!expect("NUMBER?")) {
  47:         printf("Vadic will not accept dial command\n");
  48: #ifdef ACULOG
  49:         logent(value(HOST), num, "vadic", "will not accept dial");
  50: #endif
  51:         return (0);
  52:     }
  53:     strcpy(phone, num);
  54:     strcat(phone, "\r");
  55:     vawrite(phone, 1 + slow);
  56:     if (!expect(phone)) {
  57:         printf("Vadic will not accept phone number\n");
  58: #ifdef ACULOG
  59:         logent(value(HOST), num, "vadic", "will not accept number");
  60: #endif
  61:         return (0);
  62:     }
  63:     func = signal(SIGINT,SIG_IGN);
  64:     /*
  65: 	 * You cannot interrupt the Vadic when its dialing;
  66: 	 * even dropping DTR does not work (definitely a
  67: 	 * brain damaged design).
  68: 	 */
  69:     vawrite("\r", 1 + slow);
  70:     vawrite("\r", 1 + slow);
  71:     if (!expect("DIALING:")) {
  72:         printf("Vadic failed to dial\n");
  73: #ifdef ACULOG
  74:         logent(value(HOST), num, "vadic", "failed to dial");
  75: #endif
  76:         return (0);
  77:     }
  78:     if (boolean(value(VERBOSE)))
  79:         printf("\ndialing...");
  80:     ok = expect("ON LINE");
  81:     signal(SIGINT, func);
  82:     if (!ok) {
  83:         printf("call failed\n");
  84: #ifdef ACULOG
  85:         logent(value(HOST), num, "vadic", "call failed");
  86: #endif
  87:         return (0);
  88:     }
  89:     ioctl(FD, TIOCFLUSH, &rw);
  90:     return (1);
  91: }
  92: 
  93: v3451_disconnect()
  94: {
  95: 
  96:     close(FD);
  97: }
  98: 
  99: v3451_abort()
 100: {
 101: 
 102:     close(FD);
 103: }
 104: 
 105: static
 106: vawrite(cp, delay)
 107:     register char *cp;
 108:     int delay;
 109: {
 110: 
 111:     for (; *cp; sleep(delay), cp++)
 112:         write(FD, cp, 1);
 113: }
 114: 
 115: static
 116: expect(cp)
 117:     register char *cp;
 118: {
 119:     char buf[300];
 120:     register char *rp = buf;
 121:     int alarmtr(), timeout = 30, online = 0;
 122: 
 123:     if (strcmp(cp, "\"\"") == 0)
 124:         return (1);
 125:     *rp = 0;
 126:     /*
 127: 	 * If we are waiting for the Vadic to complete
 128: 	 * dialing and get a connection, allow more time
 129: 	 * Unfortunately, the Vadic times out 24 seconds after
 130: 	 * the last digit is dialed
 131: 	 */
 132:     online = strcmp(cp, "ON LINE") == 0;
 133:     if (online)
 134:         timeout = number(value(DIALTIMEOUT));
 135:     signal(SIGALRM, alarmtr);
 136:     if (setjmp(Sjbuf))
 137:         return (0);
 138:     alarm(timeout);
 139:     while (notin(cp, buf) && rp < buf + sizeof (buf) - 1) {
 140:         if (online && notin("FAILED CALL", buf) == 0)
 141:             return (0);
 142:         if (read(FD, rp, 1) < 0) {
 143:             alarm(0);
 144:             return (0);
 145:         }
 146:         if (*rp &= 0177)
 147:             rp++;
 148:         *rp = '\0';
 149:     }
 150:     alarm(0);
 151:     return (1);
 152: }
 153: 
 154: static
 155: alarmtr()
 156: {
 157: 
 158:     longjmp(Sjbuf, 1);
 159: }
 160: 
 161: static
 162: notin(sh, lg)
 163:     char *sh, *lg;
 164: {
 165: 
 166:     for (; *lg; lg++)
 167:         if (prefix(sh, lg))
 168:             return (0);
 169:     return (1);
 170: }
 171: 
 172: static
 173: prefix(s1, s2)
 174:     register char *s1, *s2;
 175: {
 176:     register char c;
 177: 
 178:     while ((c = *s1++) == *s2++)
 179:         if (c == '\0')
 180:             return (1);
 181:     return (c == '\0');
 182: }

Defined functions

alarmtr defined in line 154; used 2 times
expect defined in line 115; used 5 times
notin defined in line 161; used 2 times
prefix defined in line 172; used 1 times
v3451_abort defined in line 99; never used
v3451_dialer defined in line 18; never used
v3451_disconnect defined in line 93; never used
vawrite defined in line 105; used 8 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1985-04-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3154
Valid CSS Valid XHTML 1.0 Strict