Annotation of 43BSDTahoe/usr.bin/tip/cu.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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