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

1.1       root        1: /*
                      2:  * Copyright (c) 1983 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted
                      6:  * provided that: (1) source distributions retain this entire copyright
                      7:  * notice and comment, and (2) distributions including binaries display
                      8:  * the following acknowledgement:  ``This product includes software
                      9:  * developed by the University of California, Berkeley and its contributors''
                     10:  * in the documentation or other materials provided with the distribution
                     11:  * and in all advertising materials mentioning features or use of this
                     12:  * software. Neither the name of the University nor the names of its
                     13:  * contributors may be used to endorse or promote products derived
                     14:  * from this software without specific prior written permission.
                     15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     18:  */
                     19: 
                     20: #ifndef lint
                     21: static char sccsid[] = "@(#)cu.c       5.9 (Berkeley) 6/1/90";
                     22: #endif /* not lint */
                     23: 
                     24: #include "tip.h"
                     25: 
                     26: void   cleanup();
                     27: 
                     28: /*
                     29:  * Botch the interface to look like cu's
                     30:  */
                     31: cumain(argc, argv)
                     32:        char *argv[];
                     33: {
                     34:        register int i;
                     35:        static char sbuf[12];
                     36: 
                     37:        if (argc < 2) {
                     38:                printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n");
                     39:                exit(8);
                     40:        }
                     41:        CU = DV = NOSTR;
                     42:        BR = DEFBR;
                     43:        for (; argc > 1; argv++, argc--) {
                     44:                if (argv[1][0] != '-')
                     45:                        PN = argv[1];
                     46:                else switch (argv[1][1]) {
                     47: 
                     48:                case 't':
                     49:                        HW = 1, DU = -1;
                     50:                        --argc;
                     51:                        continue;
                     52: 
                     53:                case 'a':
                     54:                        CU = argv[2]; ++argv; --argc;
                     55:                        break;
                     56: 
                     57:                case 's':
                     58:                        if (argc < 3 || speed(atoi(argv[2])) == 0) {
                     59:                                fprintf(stderr, "cu: unsupported speed %s\n",
                     60:                                        argv[2]);
                     61:                                exit(3);
                     62:                        }
                     63:                        BR = atoi(argv[2]); ++argv; --argc;
                     64:                        break;
                     65: 
                     66:                case 'l':
                     67:                        DV = argv[2]; ++argv; --argc;
                     68:                        break;
                     69: 
                     70:                case '0': case '1': case '2': case '3': case '4':
                     71:                case '5': case '6': case '7': case '8': case '9':
                     72:                        if (CU)
                     73:                                CU[strlen(CU)-1] = argv[1][1];
                     74:                        if (DV)
                     75:                                DV[strlen(DV)-1] = argv[1][1];
                     76:                        break;
                     77: 
                     78:                default:
                     79:                        printf("Bad flag %s", argv[1]);
                     80:                        break;
                     81:                }
                     82:        }
                     83:        signal(SIGINT, cleanup);
                     84:        signal(SIGQUIT, cleanup);
                     85:        signal(SIGHUP, cleanup);
                     86:        signal(SIGTERM, cleanup);
                     87: 
                     88:        /*
                     89:         * The "cu" host name is used to define the
                     90:         * attributes of the generic dialer.
                     91:         */
                     92:        (void)sprintf(sbuf, "cu%d", BR);
                     93:        if ((i = hunt(sbuf)) == 0) {
                     94:                printf("all ports busy\n");
                     95:                exit(3);
                     96:        }
                     97:        if (i == -1) {
                     98:                printf("link down\n");
                     99:                (void)uu_unlock(uucplock);
                    100:                exit(3);
                    101:        }
                    102:        setbuf(stdout, NULL);
                    103:        loginit();
                    104:        user_uid();
                    105:        vinit();
                    106:        setparity("none");
                    107:        boolean(value(VERBOSE)) = 0;
                    108:        if (HW)
                    109:                ttysetup(speed(BR));
                    110:        if (connect()) {
                    111:                printf("Connect failed\n");
                    112:                daemon_uid();
                    113:                (void)uu_unlock(uucplock);
                    114:                exit(1);
                    115:        }
                    116:        if (!HW)
                    117:                ttysetup(speed(BR));
                    118: }

unix.superglobalmegacorp.com

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