|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)main.c 3.30 8/14/85"; ! 3: #endif ! 4: ! 5: /* ! 6: * Copyright (c) 1983 Regents of the University of California, ! 7: * All rights reserved. Redistribution permitted subject to ! 8: * the terms of the Berkeley Software License Agreement. ! 9: */ ! 10: ! 11: #include "defs.h" ! 12: #include <sys/signal.h> ! 13: #include <stdio.h> ! 14: #include "string.h" ! 15: #include "char.h" ! 16: #include "local.h" ! 17: ! 18: #define next(a) (*++*(a) ? *(a) : (*++(a) ? *(a) : (char *)usage())) ! 19: ! 20: /*ARGSUSED*/ ! 21: main(argc, argv) ! 22: char **argv; ! 23: { ! 24: register char *p; ! 25: char fflag = 0; ! 26: char dflag = 0; ! 27: char xflag = 0; ! 28: char *cmd = 0; ! 29: char tflag = 0; ! 30: ! 31: nbufline = NLINE; ! 32: escapec = ESCAPEC; ! 33: if (p = rindex(*argv, '/')) ! 34: p++; ! 35: else ! 36: p = *argv; ! 37: debug = strcmp(p, "a.out") == 0; ! 38: while (*++argv) { ! 39: if (**argv == '-') { ! 40: switch (*++*argv) { ! 41: case 'f': ! 42: fflag++; ! 43: break; ! 44: case 'c': ! 45: if (cmd != 0) { ! 46: (void) fprintf(stderr, ! 47: "Only one -c allowed.\n"); ! 48: (void) usage(); ! 49: } ! 50: cmd = next(argv); ! 51: break; ! 52: case 'e': ! 53: setescape(next(argv)); ! 54: break; ! 55: case 't': ! 56: tflag++; ! 57: break; ! 58: case 'd': ! 59: dflag++; ! 60: break; ! 61: case 'D': ! 62: debug = !debug; ! 63: break; ! 64: case 'x': ! 65: xflag++; ! 66: break; ! 67: default: ! 68: (void) usage(); ! 69: } ! 70: } else ! 71: (void) usage(); ! 72: } ! 73: if ((p = getenv("SHELL")) == 0) ! 74: p = SHELL; ! 75: if ((shellfile = str_cpy(p)) == 0) ! 76: nomem(); ! 77: if (p = rindex(shellfile, '/')) ! 78: p++; ! 79: else ! 80: p = shellfile; ! 81: shell[0] = p; ! 82: shell[1] = 0; ! 83: (void) gettimeofday(&starttime, (struct timezone *)0); ! 84: if (wwinit() < 0) { ! 85: (void) fprintf(stderr, "%s.\n", wwerror()); ! 86: exit(1); ! 87: } ! 88: if (debug) ! 89: wwnewtty.ww_tchars.t_quitc = wwoldtty.ww_tchars.t_quitc; ! 90: if (xflag) { ! 91: wwnewtty.ww_tchars.t_stopc = wwoldtty.ww_tchars.t_stopc; ! 92: wwnewtty.ww_tchars.t_startc = wwoldtty.ww_tchars.t_startc; ! 93: } ! 94: if (debug || xflag) ! 95: (void) wwsettty(0, &wwnewtty, &wwoldtty); ! 96: ! 97: if ((cmdwin = wwopen(WWO_REVERSE, 1, wwncol, 0, 0, 0)) == 0) { ! 98: (void) wwflush(); ! 99: (void) fprintf(stderr, "%s.\r\n", wwerror()); ! 100: goto bad; ! 101: } ! 102: cmdwin->ww_mapnl = 1; ! 103: cmdwin->ww_nointr = 1; ! 104: cmdwin->ww_noupdate = 1; ! 105: cmdwin->ww_unctrl = 1; ! 106: if ((framewin = wwopen(WWO_GLASS|WWO_FRAME, wwnrow, wwncol, 0, 0, 0)) ! 107: == 0) { ! 108: (void) wwflush(); ! 109: (void) fprintf(stderr, "%s.\r\n", wwerror()); ! 110: goto bad; ! 111: } ! 112: wwadd(framewin, &wwhead); ! 113: if ((boxwin = wwopen(WWO_GLASS, wwnrow, wwncol, 0, 0, 0)) == 0) { ! 114: (void) wwflush(); ! 115: (void) fprintf(stderr, "%s.\r\n", wwerror()); ! 116: goto bad; ! 117: } ! 118: fgwin = framewin; ! 119: ! 120: wwupdate(); ! 121: wwflush(); ! 122: (void) signal(SIGCHLD, wwchild); ! 123: setvars(); ! 124: ! 125: setterse(tflag); ! 126: setcmd(1); ! 127: if (cmd != 0) ! 128: (void) dolongcmd(cmd, (struct value *)0, 0); ! 129: if (!fflag) { ! 130: if (dflag || doconfig() < 0) ! 131: dodefault(); ! 132: if (selwin != 0) ! 133: setcmd(0); ! 134: } ! 135: ! 136: mloop(); ! 137: ! 138: bad: ! 139: wwend(); ! 140: return 0; ! 141: } ! 142: ! 143: usage() ! 144: { ! 145: (void) fprintf(stderr, "Usage: window [-e escape-char] [-c command] [-t] [-f] [-d]\n"); ! 146: exit(1); ! 147: return 0; /* for lint */ ! 148: } ! 149: ! 150: nomem() ! 151: { ! 152: (void) fprintf(stderr, "Out of memory.\n"); ! 153: exit(1); ! 154: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.