Annotation of 43BSD/usr.bin/uucp/aculib/pen.c, revision 1.1

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

unix.superglobalmegacorp.com

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