|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1983 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution and use in source and binary forms are permitted ! 6: * provided that: (1) source distributions retain this entire copyright ! 7: * notice and comment, and (2) distributions including binaries display ! 8: * the following acknowledgement: ``This product includes software ! 9: * developed by the University of California, Berkeley and its contributors'' ! 10: * in the documentation or other materials provided with the distribution ! 11: * and in all advertising materials mentioning features or use of this ! 12: * software. Neither the name of the University nor the names of its ! 13: * contributors may be used to endorse or promote products derived ! 14: * from this software without specific prior written permission. ! 15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 16: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 17: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 18: */ ! 19: ! 20: #ifndef lint ! 21: static char sccsid[] = "@(#)v3451.c 5.4 (Berkeley) 6/1/90"; ! 22: #endif /* not lint */ ! 23: ! 24: /* ! 25: * Routines for calling up on a Vadic 3451 Modem ! 26: */ ! 27: #include "tip.h" ! 28: ! 29: static jmp_buf Sjbuf; ! 30: ! 31: v3451_dialer(num, acu) ! 32: register char *num; ! 33: char *acu; ! 34: { ! 35: sig_t func; ! 36: int ok; ! 37: int slow = number(value(BAUDRATE)) < 1200, rw = 2; ! 38: char phone[50]; ! 39: #ifdef ACULOG ! 40: char line[80]; ! 41: #endif ! 42: ! 43: /* ! 44: * Get in synch ! 45: */ ! 46: vawrite("I\r", 1 + slow); ! 47: vawrite("I\r", 1 + slow); ! 48: vawrite("I\r", 1 + slow); ! 49: vawrite("\005\r", 2 + slow); ! 50: if (!expect("READY")) { ! 51: printf("can't synchronize with vadic 3451\n"); ! 52: #ifdef ACULOG ! 53: logent(value(HOST), num, "vadic", "can't synch up"); ! 54: #endif ! 55: return (0); ! 56: } ! 57: ioctl(FD, TIOCHPCL, 0); ! 58: sleep(1); ! 59: vawrite("D\r", 2 + slow); ! 60: if (!expect("NUMBER?")) { ! 61: printf("Vadic will not accept dial command\n"); ! 62: #ifdef ACULOG ! 63: logent(value(HOST), num, "vadic", "will not accept dial"); ! 64: #endif ! 65: return (0); ! 66: } ! 67: strcpy(phone, num); ! 68: strcat(phone, "\r"); ! 69: vawrite(phone, 1 + slow); ! 70: if (!expect(phone)) { ! 71: printf("Vadic will not accept phone number\n"); ! 72: #ifdef ACULOG ! 73: logent(value(HOST), num, "vadic", "will not accept number"); ! 74: #endif ! 75: return (0); ! 76: } ! 77: func = signal(SIGINT,SIG_IGN); ! 78: /* ! 79: * You cannot interrupt the Vadic when its dialing; ! 80: * even dropping DTR does not work (definitely a ! 81: * brain damaged design). ! 82: */ ! 83: vawrite("\r", 1 + slow); ! 84: vawrite("\r", 1 + slow); ! 85: if (!expect("DIALING:")) { ! 86: printf("Vadic failed to dial\n"); ! 87: #ifdef ACULOG ! 88: logent(value(HOST), num, "vadic", "failed to dial"); ! 89: #endif ! 90: return (0); ! 91: } ! 92: if (boolean(value(VERBOSE))) ! 93: printf("\ndialing..."); ! 94: ok = expect("ON LINE"); ! 95: signal(SIGINT, func); ! 96: if (!ok) { ! 97: printf("call failed\n"); ! 98: #ifdef ACULOG ! 99: logent(value(HOST), num, "vadic", "call failed"); ! 100: #endif ! 101: return (0); ! 102: } ! 103: ioctl(FD, TIOCFLUSH, &rw); ! 104: return (1); ! 105: } ! 106: ! 107: v3451_disconnect() ! 108: { ! 109: ! 110: close(FD); ! 111: } ! 112: ! 113: v3451_abort() ! 114: { ! 115: ! 116: close(FD); ! 117: } ! 118: ! 119: static ! 120: vawrite(cp, delay) ! 121: register char *cp; ! 122: int delay; ! 123: { ! 124: ! 125: for (; *cp; sleep(delay), cp++) ! 126: write(FD, cp, 1); ! 127: } ! 128: ! 129: static ! 130: expect(cp) ! 131: register char *cp; ! 132: { ! 133: char buf[300]; ! 134: register char *rp = buf; ! 135: int alarmtr(), timeout = 30, online = 0; ! 136: ! 137: if (strcmp(cp, "\"\"") == 0) ! 138: return (1); ! 139: *rp = 0; ! 140: /* ! 141: * If we are waiting for the Vadic to complete ! 142: * dialing and get a connection, allow more time ! 143: * Unfortunately, the Vadic times out 24 seconds after ! 144: * the last digit is dialed ! 145: */ ! 146: online = strcmp(cp, "ON LINE") == 0; ! 147: if (online) ! 148: timeout = number(value(DIALTIMEOUT)); ! 149: signal(SIGALRM, alarmtr); ! 150: if (setjmp(Sjbuf)) ! 151: return (0); ! 152: alarm(timeout); ! 153: while (notin(cp, buf) && rp < buf + sizeof (buf) - 1) { ! 154: if (online && notin("FAILED CALL", buf) == 0) ! 155: return (0); ! 156: if (read(FD, rp, 1) < 0) { ! 157: alarm(0); ! 158: return (0); ! 159: } ! 160: if (*rp &= 0177) ! 161: rp++; ! 162: *rp = '\0'; ! 163: } ! 164: alarm(0); ! 165: return (1); ! 166: } ! 167: ! 168: static ! 169: alarmtr() ! 170: { ! 171: ! 172: longjmp(Sjbuf, 1); ! 173: } ! 174: ! 175: static ! 176: notin(sh, lg) ! 177: char *sh, *lg; ! 178: { ! 179: ! 180: for (; *lg; lg++) ! 181: if (prefix(sh, lg)) ! 182: return (0); ! 183: return (1); ! 184: } ! 185: ! 186: static ! 187: prefix(s1, s2) ! 188: register char *s1, *s2; ! 189: { ! 190: register char c; ! 191: ! 192: while ((c = *s1++) == *s2++) ! 193: if (c == '\0') ! 194: return (1); ! 195: return (c == '\0'); ! 196: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.