Annotation of 43BSD/usr.bin/uucp/aculib/vad.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)vad.c      4.2 (Berkeley) 10/10/85";
                      3: #endif
                      4: 
                      5: #include "../condevs.h"
                      6: #ifdef VADIC
                      7: 
                      8: /*
                      9:  *     vadopn: establish dial-out connection through a Racal-Vadic 3450.
                     10:  *     Returns descriptor open to tty for reading and writing.
                     11:  *     Negative values (-1...-7) denote errors in connmsg.
                     12:  *     Be sure to disconnect tty when done, via HUPCL or stty 0.
                     13:  */
                     14: 
                     15: vadopn(telno, flds, dev)
                     16: char *telno;
                     17: char *flds[];
                     18: struct Devices *dev;
                     19: {
                     20:        int     dh = -1;
                     21:        int     i, ok, er = 0, delay;
                     22:        extern errno;
                     23:        char dcname[20];
                     24: 
                     25:        sprintf(dcname, "/dev/%s", dev->D_line);
                     26:        if (setjmp(Sjbuf)) {
                     27:                DEBUG(1, "timeout vadic open\n", "");
                     28:                logent("vadic open", "TIMEOUT");
                     29:                if (dh >= 0)
                     30:                        close(dh);
                     31:                delock(dev->D_line);
                     32:                return CF_NODEV;
                     33:        }
                     34:        signal(SIGALRM, alarmtr);
                     35:        getnextfd();
                     36:        alarm(10);
                     37:        dh = open(dcname, 2);
                     38:        alarm(0);
                     39: 
                     40:        /* modem is open */
                     41:        next_fd = -1;
                     42:        if (dh < 0) {
                     43:                delock(dev->D_line);
                     44:                return CF_NODEV;
                     45:        }
                     46:        fixline(dh, dev->D_speed);
                     47: 
                     48:        DEBUG(4, "calling %s -> ", telno);
                     49:        if (dochat(dev, flds, dh)) {
                     50:                logent(dcname, "CHAT FAILED");
                     51:                close(dh);
                     52:                return CF_DIAL;
                     53:        }
                     54:        delay = 0;
                     55:        for (i = 0; i < strlen(telno); ++i) {
                     56:                switch(telno[i]) {
                     57:                case '=':       /* await dial tone */
                     58:                case '-':
                     59:                case ',':
                     60:                case '<':
                     61:                case 'K':
                     62:                        telno[i] = 'K';
                     63:                        delay += 5;
                     64:                        break;
                     65:                }
                     66:        }
                     67:        DEBUG(4, "%s\n", telno);
                     68:        for(i = 0; i < 5; ++i) {        /* make 5 tries */
                     69:                /* wake up Vadic */
                     70:                write(dh, "\005", 1);
                     71:                sleep(1);
                     72:                write(dh, "\r", 1);
                     73:                DEBUG(4, "wanted * ", CNULL);
                     74:                ok = expect("*~5", dh);
                     75:                DEBUG(4, "got %s\n", ok ? "?" : "that");
                     76:                if (ok != 0)
                     77:                        continue;
                     78: 
                     79:                write(dh, "D\r", 2); /* "D" (enter number) command */
                     80:                DEBUG(4, "wanted NUMBER?\\r\\n ", CNULL);
                     81:                ok = expect("NUMBER?\r\n~5", dh);
                     82:                DEBUG(4, "got %s\n", ok ? "?" : "that");
                     83:                if (ok != 0)
                     84:                        continue;
                     85: 
                     86:                /* send telno, send \r */
                     87:                write(dh, telno, strlen(telno));
                     88:                sleep(1);
                     89:                write(dh, "\r", 1);
                     90:                DEBUG(4, "wanted %s ", telno);
                     91:                ok = expect(telno, dh);
                     92:                if (ok == 0)
                     93:                        ok = expect("\r\n", dh);
                     94:                DEBUG(4, "got %s\n", ok ? "?" : "that");
                     95:                if (ok != 0)
                     96:                        continue;
                     97: 
                     98:                write(dh, "\r", 1); /* confirm number */
                     99:                DEBUG(4, "wanted DIALING: ", CNULL);
                    100:                ok = expect("DIALING: ", dh);
                    101:                DEBUG(4, "got %s\n", ok ? "?" : "that");
                    102:                if (ok == 0)
                    103:                        break;
                    104:        }
                    105: 
                    106:        if (ok == 0) {
                    107:                sleep(10 + delay);      /* give vadic some time */
                    108:                DEBUG(4, "wanted ON LINE\\r\\n ", CNULL);
                    109:                ok = expect("ON LINE\r\n", dh);
                    110:                DEBUG(4, "got %s\n", ok ? "?" : "that");
                    111:        }
                    112: 
                    113:        if (ok != 0) {
                    114:                if (dh > 2)
                    115:                        close(dh);
                    116:                DEBUG(4, "vadDial failed\n", CNULL);
                    117:                delock(dev->D_line);
                    118:                return CF_DIAL;
                    119:        }
                    120:        DEBUG(4, "vadic ok\n", CNULL);
                    121:        return dh;
                    122: }
                    123: 
                    124: vadcls(fd)
                    125: {
                    126:        if (fd > 0) {
                    127:                close(fd);
                    128:                sleep(5);
                    129:                delock(devSel);
                    130:        }
                    131: }
                    132: #endif VADIC

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.