Annotation of 42BSD/usr.bin/tip/cu.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char sccsid[] = "@(#)cu.c       4.6 (Berkeley) 6/28/83";
        !             3: #endif
        !             4: 
        !             5: #include "tip.h"
        !             6: 
        !             7: int    cleanup();
        !             8: int    timeout();
        !             9: 
        !            10: /*
        !            11:  * Botch the interface to look like cu's
        !            12:  */
        !            13: cumain(argc, argv)
        !            14:        char *argv[];
        !            15: {
        !            16:        register int i;
        !            17:        static char sbuf[12];
        !            18: 
        !            19:        if (argc < 2) {
        !            20:                printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n");
        !            21:                exit(8);
        !            22:        }
        !            23:        CU = DV = NOSTR;
        !            24:        for (; argc > 1; argv++, argc--) {
        !            25:                if (argv[1][0] != '-')
        !            26:                        PN = argv[1];
        !            27:                else switch (argv[1][1]) {
        !            28: 
        !            29:                case 't':
        !            30:                        HW = 1, DU = -1;
        !            31:                        --argc;
        !            32:                        continue;
        !            33: 
        !            34:                case 'a':
        !            35:                        CU = argv[2]; ++argv; --argc;
        !            36:                        break;
        !            37: 
        !            38:                case 's':
        !            39:                        if (speed(atoi(argv[2])) == 0) {
        !            40:                                fprintf(stderr, "cu: unsupported speed %s\n",
        !            41:                                        argv[2]);
        !            42:                                exit(3);
        !            43:                        }
        !            44:                        BR = atoi(argv[2]); ++argv; --argc;
        !            45:                        break;
        !            46: 
        !            47:                case 'l':
        !            48:                        DV = argv[2]; ++argv; --argc;
        !            49:                        break;
        !            50: 
        !            51:                case '0': case '1': case '2': case '3': case '4':
        !            52:                case '5': case '6': case '7': case '8': case '9':
        !            53:                        if (CU)
        !            54:                                CU[strlen(CU)-1] = argv[1][1];
        !            55:                        if (DV)
        !            56:                                DV[strlen(DV)-1] = argv[1][1];
        !            57:                        break;
        !            58: 
        !            59:                default:
        !            60:                        printf("Bad flag %s", argv[1]);
        !            61:                        break;
        !            62:                }
        !            63:        }
        !            64:        signal(SIGINT, cleanup);
        !            65:        signal(SIGQUIT, cleanup);
        !            66:        signal(SIGHUP, cleanup);
        !            67:        signal(SIGTERM, cleanup);
        !            68: 
        !            69:        /*
        !            70:         * The "cu" host name is used to define the
        !            71:         * attributes of the generic dialer.
        !            72:         */
        !            73:        if ((i = hunt(sprintf(sbuf, "cu%d", BR))) == 0) {
        !            74:                printf("all ports busy\n");
        !            75:                exit(3);
        !            76:        }
        !            77:        if (i == -1) {
        !            78:                printf("link down\n");
        !            79:                delock(uucplock);
        !            80:                exit(3);
        !            81:        }
        !            82:        setbuf(stdout, NULL);
        !            83:        loginit();
        !            84:        setuid(getuid());
        !            85:        setgid(getgid());
        !            86:        vinit();
        !            87:        setparity("none");
        !            88:        boolean(value(VERBOSE)) = 0;
        !            89:        if (HW)
        !            90:                ttysetup(speed(BR));
        !            91:        if (connect()) {
        !            92:                printf("Connect failed\n");
        !            93:                delock(uucplock);
        !            94:                exit(1);
        !            95:        }
        !            96:        if (!HW)
        !            97:                ttysetup(speed(BR));
        !            98: }

unix.superglobalmegacorp.com

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