Annotation of 43BSDReno/usr.bin/uucp/aculib/nov.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)nov.c      4.2 (Berkeley) 2/24/88";
                      3: #endif
                      4: 
                      5: #include "../condevs.h"
                      6: 
                      7: /***
                      8:  *     novopn(telno, flds, dev) connect to novation Smart-Cat
                      9:  *     (similar to hayes smartmodem)
                     10:  *     char *flds[], *dev[];
                     11:  *
                     12:  *     return codes:
                     13:  *             >0  -  file number  -  ok
                     14:  *             CF_DIAL,CF_DEVICE  -  failed
                     15:  */
                     16: 
                     17: novopn(telno, flds, dev)
                     18: char *telno;
                     19: char *flds[];
                     20: struct Devices *dev;
                     21: {
                     22:        int     dh = -1;
                     23:        extern errno;
                     24:        char dcname[20];
                     25:        int pulse = 0;
                     26: 
                     27:        sprintf(dcname, "/dev/%s", dev->D_line);
                     28:        DEBUG(4, "dc - %s\n", dcname);
                     29:        if (strcmp(dev->D_calldev, "pulse") == 0)
                     30:                pulse = 1;
                     31:        if (setjmp(Sjbuf)) {
                     32:                DEBUG(1, "timeout novation open %s\n", dcname);
                     33:                logent("novation open", "TIMEOUT");
                     34:                if (dh >= 0)
                     35:                        close(dh);
                     36:                delock(dev->D_line);
                     37:                return CF_DIAL;
                     38:        }
                     39:        signal(SIGALRM, alarmtr);
                     40:        getnextfd();
                     41:        alarm(10);
                     42:        dh = open(dcname, 2); /* read/write */
                     43:        alarm(0);
                     44: 
                     45:        /* modem is open */
                     46:        next_fd = -1;
                     47:        if (dh >= 0) {
                     48:                fixline(dh, dev->D_speed);
                     49:                /* set guard time small so line is in transparant mode */
                     50:                slowrite(dh, "\rATS12=1\r");
                     51:                if (expect("OK", dh) != 0) {
                     52:                        logent("NOV no line", _FAILED);
                     53:                        strcpy(devSel, dev->D_line);
                     54:                        novcls(dh);
                     55:                        return CF_DIAL;
                     56:                }
                     57: 
                     58:                if (pulse)
                     59:                        slowrite(dh, "ATDP");
                     60:                else
                     61:                        slowrite(dh, "ATDT");
                     62:                slowrite(dh, telno);
                     63:                slowrite(dh, "\r");
                     64: 
                     65:                if (expect("CONNECT", dh) != 0) {
                     66:                        logent("NOV no carrier", _FAILED);
                     67:                        strcpy(devSel, dev->D_line);
                     68:                        novcls(dh);
                     69:                        return CF_DIAL;
                     70:                }
                     71: 
                     72:        }
                     73:        if (dh < 0) {
                     74:                DEBUG(4, "novation failed\n", CNULL);
                     75:                delock(dev->D_line);
                     76:        }
                     77:        DEBUG(4, "novation ok\n", CNULL);
                     78:        return dh;
                     79: }
                     80: 
                     81: novcls(fd)
                     82: int fd;
                     83: {
                     84:        char dcname[20];
                     85:        struct sgttyb hup, sav;
                     86: 
                     87:        if (fd > 0) {
                     88:                sprintf(dcname, "/dev/%s", devSel);
                     89:                DEBUG(4, "Hanging up fd = %d\n", fd);
                     90:                /*
                     91:                 * code to drop DTR -- change to 0 baud then back to default.
                     92:                 */
                     93:                gtty(fd, &hup);
                     94:                gtty(fd, &sav);
                     95:                hup.sg_ispeed = B0;
                     96:                hup.sg_ospeed = B0;
                     97:                stty(fd, &hup);
                     98:                sleep(2);
                     99:                stty(fd, &sav);
                    100:                /*
                    101:                 * now raise DTR -- close the device & open it again.
                    102:                 */
                    103:                sleep(2);
                    104:                close(fd);
                    105:                sleep(2);
                    106:                fd = open(dcname, 2);
                    107:                /*
                    108:                 * Since we have a getty sleeping on this line, when it wakes up it sends
                    109:                 * all kinds of garbage to the modem.  Unfortunatly, the modem likes to
                    110:                 * execute the previous command when it sees the garbage.  The previous
                    111:                 * command was to dial the phone, so let's make the last command reset
                    112:                 * the modem.
                    113:                 */
                    114:                sleep(2);
                    115:                slowrite(fd, "\rATZ\r");
                    116:                close(fd);
                    117:                delock(devSel);
                    118:        }
                    119: }

unix.superglobalmegacorp.com

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