|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)pen.c 4.3 (Berkeley) 2/24/88"; ! 3: #endif ! 4: ! 5: /* ! 6: * Speaker's quick and dirty penril hack. STA 4/1/85. ! 7: */ ! 8: #include "../condevs.h" ! 9: ! 10: penopn(telno, flds, dev) ! 11: char *flds[], *telno; ! 12: struct Devices *dev; ! 13: { ! 14: int dh; ! 15: int i, ok = -1; ! 16: char dcname[20]; ! 17: ! 18: sprintf(dcname, "/dev/%s", dev->D_line); ! 19: if (setjmp(Sjbuf)) { ! 20: DEBUG(1, "timeout penril open\n", ""); ! 21: logent("penril open", "TIMEOUT"); ! 22: if (dh >= 0) ! 23: close(dh); ! 24: delock(dev->D_line); ! 25: return CF_NODEV; ! 26: } ! 27: signal(SIGALRM, alarmtr); ! 28: getnextfd(); ! 29: alarm(10); ! 30: dh = open(dcname, 2); ! 31: alarm(0); ! 32: next_fd = -1; ! 33: if (dh < 0) { ! 34: DEBUG(4,"%s\n", errno == 4 ? "no carrier" : "can't open modem"); ! 35: delock(dev->D_line); ! 36: return errno == 4 ? CF_DIAL : CF_NODEV; ! 37: } ! 38: ! 39: /* modem is open */ ! 40: fixline(dh, dev->D_speed); ! 41: ! 42: /* translate - to P and = to W for Penril */ ! 43: DEBUG(4, "calling %s -> ", telno); ! 44: for (i = 0; i < strlen(telno); ++i) { ! 45: switch(telno[i]) { ! 46: case '-': /* delay */ ! 47: telno[i] = 'P'; ! 48: break; ! 49: case '=': /* await dial tone */ ! 50: telno[i] = 'W'; ! 51: break; ! 52: case '<': ! 53: telno[i] = 'P'; ! 54: break; ! 55: } ! 56: } ! 57: DEBUG(4, "%s\n", telno); ! 58: sleep(1); ! 59: for(i = 0; i < 5; ++i) { /* make up to 5 tries */ ! 60: slowrite(dh, "\r");/* awake, thou lowly Penril! */ ! 61: ! 62: DEBUG(4, "wanted %s ", ">"); ! 63: ok = expect(">", dh); ! 64: DEBUG(4, "got %s\n", ok ? "?" : "that"); ! 65: if (ok != 0) ! 66: continue; ! 67: slowrite(dh, "K"); /* "K" (enter number) command */ ! 68: DEBUG(4, "wanted %s ", "NO.: "); ! 69: ok = expect("NO.: ", dh); ! 70: DEBUG(4, "got %s\n", ok ? "?" : "that"); ! 71: if (ok == 0) ! 72: break; ! 73: } ! 74: ! 75: if (ok == 0) { ! 76: slowrite(dh, telno); /* send telno, send \r */ ! 77: slowrite(dh, "\r"); ! 78: DEBUG(4, "wanted %s ", "OK"); ! 79: ok = expect("OK", dh); ! 80: DEBUG(4, "got %s\n", ok ? "?" : "that"); ! 81: } ! 82: if (ok != 0) { ! 83: if (dh > 2) ! 84: close(dh); ! 85: DEBUG(4, "penDial failed\n", ""); ! 86: return CF_DIAL; ! 87: } ! 88: else ! 89: DEBUG(4, "penDial ok\n", ""); ! 90: return dh; ! 91: } ! 92: ! 93: pencls(fd) ! 94: int fd; ! 95: { ! 96: if (fd > 0) { ! 97: close(fd); ! 98: sleep(5); ! 99: delock(devSel); ! 100: } ! 101: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.