Annotation of 43BSDTahoe/ucb/window/main.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1983 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 the above copyright notice and this paragraph are
        !             7:  * duplicated in all such forms and that any documentation,
        !             8:  * advertising materials, and other materials related to such
        !             9:  * distribution and use acknowledge that the software was developed
        !            10:  * by the University of California, Berkeley.  The name of the
        !            11:  * University may not be used to endorse or promote products derived
        !            12:  * from this software without specific prior written permission.
        !            13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            16:  */
        !            17: 
        !            18: #ifndef lint
        !            19: static char sccsid[] = "@(#)main.c     3.33 (Berkeley) 6/29/88";
        !            20: #endif /* not lint */
        !            21: 
        !            22: #include "defs.h"
        !            23: #include <sys/signal.h>
        !            24: #include <stdio.h>
        !            25: #include "string.h"
        !            26: #include "char.h"
        !            27: #include "local.h"
        !            28: 
        !            29: #define next(a) (*++*(a) ? *(a) : (*++(a) ? *(a) : (char *)usage()))
        !            30: 
        !            31: /*ARGSUSED*/
        !            32: main(argc, argv)
        !            33: char **argv;
        !            34: {
        !            35:        register char *p;
        !            36:        char fflag = 0;
        !            37:        char dflag = 0;
        !            38:        char xflag = 0;
        !            39:        char *cmd = 0;
        !            40:        char tflag = 0;
        !            41: 
        !            42:        nbufline = NLINE;
        !            43:        escapec = ESCAPEC;      
        !            44:        if (p = rindex(*argv, '/'))
        !            45:                p++;
        !            46:        else
        !            47:                p = *argv;
        !            48:        debug = strcmp(p, "a.out") == 0;
        !            49:        while (*++argv) {
        !            50:                if (**argv == '-') {
        !            51:                        switch (*++*argv) {
        !            52:                        case 'f':
        !            53:                                fflag++;
        !            54:                                break;
        !            55:                        case 'c':
        !            56:                                if (cmd != 0) {
        !            57:                                        (void) fprintf(stderr,
        !            58:                                                "Only one -c allowed.\n");
        !            59:                                        (void) usage();
        !            60:                                }
        !            61:                                cmd = next(argv);
        !            62:                                break;
        !            63:                        case 'e':
        !            64:                                setescape(next(argv));
        !            65:                                break;
        !            66:                        case 't':
        !            67:                                tflag++;
        !            68:                                break;
        !            69:                        case 'd':
        !            70:                                dflag++;
        !            71:                                break;
        !            72:                        case 'D':
        !            73:                                debug = !debug;
        !            74:                                break;
        !            75:                        case 'x':
        !            76:                                xflag++;
        !            77:                                break;
        !            78:                        default:
        !            79:                                (void) usage();
        !            80:                        }
        !            81:                } else
        !            82:                        (void) usage();
        !            83:        }
        !            84:        if ((p = getenv("SHELL")) == 0)
        !            85:                p = SHELL;
        !            86:        if ((shellfile = str_cpy(p)) == 0)
        !            87:                nomem();
        !            88:        if (p = rindex(shellfile, '/'))
        !            89:                p++;
        !            90:        else
        !            91:                p = shellfile;
        !            92:        shell[0] = p;
        !            93:        shell[1] = 0;
        !            94:        (void) gettimeofday(&starttime, (struct timezone *)0);
        !            95:        if (wwinit() < 0) {
        !            96:                (void) fprintf(stderr, "%s.\n", wwerror());
        !            97:                exit(1);
        !            98:        }
        !            99:        if (debug)
        !           100:                wwnewtty.ww_tchars.t_quitc = wwoldtty.ww_tchars.t_quitc;
        !           101:        if (xflag) {
        !           102:                wwnewtty.ww_tchars.t_stopc = wwoldtty.ww_tchars.t_stopc;
        !           103:                wwnewtty.ww_tchars.t_startc = wwoldtty.ww_tchars.t_startc;
        !           104:        }
        !           105:        if (debug || xflag)
        !           106:                (void) wwsettty(0, &wwnewtty, &wwoldtty);
        !           107: 
        !           108:        if ((cmdwin = wwopen(wwbaud > 2400 ? WWO_REVERSE : 0, 1, wwncol,
        !           109:                             0, 0, 0)) == 0) {
        !           110:                (void) wwflush();
        !           111:                (void) fprintf(stderr, "%s.\r\n", wwerror());
        !           112:                goto bad;
        !           113:        }
        !           114:        cmdwin->ww_mapnl = 1;
        !           115:        cmdwin->ww_nointr = 1;
        !           116:        cmdwin->ww_noupdate = 1;
        !           117:        cmdwin->ww_unctrl = 1;
        !           118:        if ((framewin = wwopen(WWO_GLASS|WWO_FRAME, wwnrow, wwncol, 0, 0, 0))
        !           119:            == 0) {
        !           120:                (void) wwflush();
        !           121:                (void) fprintf(stderr, "%s.\r\n", wwerror());
        !           122:                goto bad;
        !           123:        }
        !           124:        wwadd(framewin, &wwhead);
        !           125:        if ((boxwin = wwopen(WWO_GLASS, wwnrow, wwncol, 0, 0, 0)) == 0) {
        !           126:                (void) wwflush();
        !           127:                (void) fprintf(stderr, "%s.\r\n", wwerror());
        !           128:                goto bad;
        !           129:        }
        !           130:        fgwin = framewin;
        !           131: 
        !           132:        wwupdate();
        !           133:        wwflush();
        !           134:        (void) signal(SIGCHLD, wwchild);
        !           135:        setvars();
        !           136: 
        !           137:        setterse(tflag);
        !           138:        setcmd(1);
        !           139:        if (cmd != 0)
        !           140:                (void) dolongcmd(cmd, (struct value *)0, 0);
        !           141:        if (!fflag) {
        !           142:                if (dflag || doconfig() < 0)
        !           143:                        dodefault();
        !           144:                if (selwin != 0)
        !           145:                        setcmd(0);
        !           146:        }
        !           147: 
        !           148:        mloop();
        !           149: 
        !           150: bad:
        !           151:        wwend();
        !           152:        return 0;
        !           153: }
        !           154: 
        !           155: usage()
        !           156: {
        !           157:        (void) fprintf(stderr, "Usage: window [-e escape-char] [-c command] [-t] [-f] [-d]\n");
        !           158:        exit(1);
        !           159:        return 0;                       /* for lint */
        !           160: }
        !           161: 
        !           162: nomem()
        !           163: {
        !           164:        (void) fprintf(stderr, "Out of memory.\n");
        !           165:        exit(1);
        !           166: }

unix.superglobalmegacorp.com

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