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

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)va820.c    4.3 (Berkeley) 10/10/85";
                      3: #endif
                      4: 
                      5: #include "../condevs.h"
                      6: #ifdef VA820
                      7: 
                      8: /*
                      9:  * Racal-Vadic 'RV820' with 831 adaptor.
                     10:  * BUGS:
                     11:  * dialer baud rate is hardcoded
                     12:  */
                     13: #define        MAXDIG 30       /* set by switches inside adapter */
                     14: char   c_abort = '\001';
                     15: char   c_start = '\002';
                     16: char   c_empty = '\017';
                     17: char   c_end   = '\003';
                     18: 
                     19: va820opn(ph, flds, dev)
                     20: char *ph, *flds[];
                     21: struct Devices *dev;
                     22: {
                     23:        register int va, i, child;
                     24:        char c, acu[20], com[20];
                     25:        char vadbuf[MAXDIG+2];
                     26:        int nw, lt;
                     27:        unsigned timelim;
                     28:        struct sgttyb sg;
                     29: 
                     30:        child = -1;
                     31:        if (strlen(ph) > MAXDIG) {
                     32:                DEBUG(4, "BAD PHONE NUMBER %s\n", ph);
                     33:                logent("rvadopn", "BAD PHONE NUMBER");
                     34:                i = CF_DIAL;
                     35:                goto ret;
                     36:        }
                     37: 
                     38:        if (setjmp(Sjbuf)) {
                     39:                logent("rvadopn", "TIMEOUT");
                     40:                i = CF_DIAL;
                     41:                goto ret;
                     42:        }
                     43:        DEBUG(4, "ACU %s\n", dev->D_calldev);
                     44:        DEBUG(4, "LINE %s\n", dev->D_line);
                     45:        sprintf(acu, "/dev/%s", dev->D_calldev);
                     46:        getnextfd();
                     47:        signal(SIGALRM, alarmtr);
                     48:        alarm(10);
                     49:        va = open(acu, 2);
                     50:        alarm(0);
                     51:        next_fd = -1;
                     52:        if (va < 0) {
                     53:                DEBUG(4, "ACU OPEN FAIL %d\n", errno);
                     54:                logent(acu, "CAN'T OPEN");
                     55:                i = CF_NODEV;
                     56:                goto ret;
                     57:        }
                     58:        /*
                     59:         * Set speed and modes on dialer and clear any
                     60:         * previous requests
                     61:         */
                     62:        DEBUG(4, "SETTING UP VA831 (%d)\n", va);
                     63:        ioctl(va, TIOCGETP, &sg);
                     64:        sg.sg_ispeed = sg.sg_ospeed = B1200;
                     65:        sg.sg_flags |= RAW;
                     66:        sg.sg_flags &= ~ECHO;
                     67:        ioctl(va, TIOCSETP, &sg);
                     68:        DEBUG(4, "CLEARING VA831\n", 0);
                     69:        if ( write(va, &c_abort, 1) != 1) {
                     70:                DEBUG(4,"BAD VA831 WRITE %d\n", errno);
                     71:                logent(acu, "CAN'T CLEAR");
                     72:                i = CF_DIAL;
                     73:                goto ret;
                     74:        }
                     75:        sleep(1);                       /* XXX */
                     76:        read(va, &c, 1);
                     77:        if (c != 'B') {
                     78:                DEBUG(4,"BAD VA831 RESPONSE %c\n", c);
                     79:                logent(acu, "CAN'T CLEAR");
                     80:                i = CF_DIAL;
                     81:                goto ret;
                     82:        }
                     83:        /*
                     84:         * Build the dialing sequence for the adapter
                     85:         */
                     86:        DEBUG(4, "DIALING %s\n", ph);
                     87:        sprintf(vadbuf, "%c%s<%c%c", c_start, ph, c_empty, c_end);
                     88:        timelim = 5 * strlen(ph);
                     89:        alarm(timelim < 30 ? 30 : timelim);
                     90:        nw = write(va, vadbuf, strlen(vadbuf)); /* Send Phone Number */
                     91:        if (nw != strlen(vadbuf)) {
                     92:                DEBUG(4,"BAD VA831 WRITE %d\n", nw);
                     93:                logent(acu, "BAD WRITE");
                     94:                goto failret;
                     95:        }
                     96: 
                     97:        sprintf(com, "/dev/%s", dev->D_line);
                     98: 
                     99:        /* create child to open comm line */
                    100:        if ((child = fork()) == 0) {
                    101:                signal(SIGINT, SIG_DFL);
                    102:                open(com, 0);
                    103:                sleep(5);
                    104:                _exit(1);
                    105:        }
                    106: 
                    107:        DEBUG(4, "WAITING FOR ANSWER\n", 0);
                    108:        if (read(va, &c, 1) != 1) {
                    109:                logent("ACU READ", _FAILED);
                    110:                goto failret;
                    111:        }
                    112:        switch(c) {
                    113:        case 'A':
                    114:                /* Fine! */
                    115:                break;
                    116:        case 'B':
                    117:                DEBUG(2, "Line Busy / No Answer\n", 0);
                    118:                goto failret;
                    119:        case 'D':
                    120:                DEBUG(2, "Dialer format error\n", 0);
                    121:                goto failret;
                    122:        case 'E':
                    123:                DEBUG(2, "Dialer parity error\n", 0);
                    124:                goto failret;
                    125:        case 'F':
                    126:                DEBUG(2, "Phone number too long\n", 0);
                    127:                goto failret;
                    128:        case 'G':
                    129:                DEBUG(2, "Modem Busy\n", 0);
                    130:                goto failret;
                    131:        default:
                    132:                DEBUG(2, "Unknown MACS return code '%c'\n", c&0177);
                    133:                goto failret;
                    134:        }
                    135:        /*
                    136:         * open line - will return on carrier
                    137:         */
                    138:        if ((i = open(com, 2)) < 0) {
                    139:                if (errno == EIO)
                    140:                        logent("carrier", "LOST");
                    141:                else
                    142:                        logent("dialup open", _FAILED);
                    143:                goto failret;
                    144:        }
                    145:        DEBUG(2, "RVADIC opened %d\n", i);
                    146:        fixline(i, dev->D_speed);
                    147:        goto ret;
                    148: failret:
                    149:        i = CF_DIAL;
                    150: ret:
                    151:        alarm(0);
                    152:        if (child != -1)
                    153:                kill(child, SIGKILL);
                    154:        close(va);
                    155:        while ((nw = wait(&lt)) != child && nw != -1)
                    156:                ;
                    157:        return i;
                    158: }
                    159: 
                    160: va820cls(fd)
                    161: register int fd;
                    162: {
                    163: 
                    164:        DEBUG(2, "RVADIC close %d\n", fd);
                    165:        close(fd);
                    166: }
                    167: #endif VA820

unix.superglobalmegacorp.com

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