1: #if defined(DOSCCS) && !defined(lint)
2: static char sccsid[] = "@(#)main.c 3.31 1/1/94";
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: #ifdef pdp11
18: #include "tt.h"
19: #endif
20:
21: #define next(a) (*++*(a) ? *(a) : (*++(a) ? *(a) : (char *)usage()))
22:
23: /*ARGSUSED*/
24: main(argc, argv)
25: char **argv;
26: {
27: register char *p;
28: char fflag = 0;
29: char dflag = 0;
30: char xflag = 0;
31: char *cmd = 0;
32: char tflag = 0;
33: #ifdef pdp11
34: /* Move some buffers onto the stack to get at the memory */
35: /* The program really doesn't fit, but we make a valiant effort */
36: char inbuf[BUFSIZ];
37: char ww_tbuf[1024], ww_kbuf[256], ww_ibuf[512];
38: char tt_sbuf[512], tt_obuf[TTOBSIZ];
39:
40: setbuf(stdin, inbuf);
41: setbuf(stdout, NULL);
42: wwtermcap = ww_tbuf;
43: wwkeys = ww_kbuf;
44: wwwintermcap = ww_ibuf;
45: tt_strings = tt_sbuf;
46: tt_ob = tt_obuf;
47: #endif
48:
49: nbufline = NLINE;
50: escapec = ESCAPEC;
51: if (p = rindex(*argv, '/'))
52: p++;
53: else
54: p = *argv;
55: debug = strcmp(p, "a.out") == 0;
56: while (*++argv) {
57: if (**argv == '-') {
58: switch (*++*argv) {
59: case 'f':
60: fflag++;
61: break;
62: case 'c':
63: if (cmd != 0) {
64: (void) fprintf(stderr,
65: "Only one -c allowed.\n");
66: (void) usage();
67: }
68: cmd = next(argv);
69: break;
70: case 'e':
71: setescape(next(argv));
72: break;
73: case 't':
74: tflag++;
75: break;
76: case 'd':
77: dflag++;
78: break;
79: case 'D':
80: debug = !debug;
81: break;
82: case 'x':
83: xflag++;
84: break;
85: default:
86: (void) usage();
87: }
88: } else
89: (void) usage();
90: }
91: if ((p = getenv("SHELL")) == 0)
92: p = SHELL;
93: if ((shellfile = str_cpy(p)) == 0)
94: nomem();
95: if (p = rindex(shellfile, '/'))
96: p++;
97: else
98: p = shellfile;
99: shell[0] = p;
100: shell[1] = 0;
101: (void) gettimeofday(&starttime, (struct timezone *)0);
102: if (wwinit() < 0) {
103: (void) fprintf(stderr, "%s.\n", wwerror());
104: exit(1);
105: }
106: if (debug)
107: wwnewtty.ww_tchars.t_quitc = wwoldtty.ww_tchars.t_quitc;
108: if (xflag) {
109: wwnewtty.ww_tchars.t_stopc = wwoldtty.ww_tchars.t_stopc;
110: wwnewtty.ww_tchars.t_startc = wwoldtty.ww_tchars.t_startc;
111: }
112: if (debug || xflag)
113: (void) wwsettty(0, &wwnewtty, &wwoldtty);
114:
115: if ((cmdwin = wwopen(WWO_REVERSE, 1, wwncol, 0, 0, 0)) == 0) {
116: (void) wwflush();
117: (void) fprintf(stderr, "%s.\r\n", wwerror());
118: goto bad;
119: }
120: cmdwin->ww_mapnl = 1;
121: cmdwin->ww_nointr = 1;
122: cmdwin->ww_noupdate = 1;
123: cmdwin->ww_unctrl = 1;
124: if ((framewin = wwopen(WWO_GLASS|WWO_FRAME, wwnrow, wwncol, 0, 0, 0))
125: == 0) {
126: (void) wwflush();
127: (void) fprintf(stderr, "%s.\r\n", wwerror());
128: goto bad;
129: }
130: wwadd(framewin, &wwhead);
131: if ((boxwin = wwopen(WWO_GLASS, wwnrow, wwncol, 0, 0, 0)) == 0) {
132: (void) wwflush();
133: (void) fprintf(stderr, "%s.\r\n", wwerror());
134: goto bad;
135: }
136: fgwin = framewin;
137:
138: wwupdate();
139: wwflush();
140: (void) signal(SIGCHLD, wwchild);
141: setvars();
142:
143: setterse(tflag);
144: setcmd(1);
145: if (cmd != 0)
146: (void) dolongcmd(cmd, (struct value *)0, 0);
147: if (!fflag) {
148: if (dflag || doconfig() < 0)
149: dodefault();
150: if (selwin != 0)
151: setcmd(0);
152: }
153:
154: mloop();
155:
156: bad:
157: wwend();
158: return 0;
159: }
160:
161: usage()
162: {
163: (void) fprintf(stderr, "Usage: window [-e escape-char] [-c command] [-t] [-f] [-d]\n");
164: exit(1);
165: return 0; /* for lint */
166: }
167:
168: nomem()
169: {
170: (void) fprintf(stderr, "Out of memory.\n");
171: exit(1);
172: }
Defined functions
main
defined in line
24;
never used
Defined variables
sccsid
defined in line
2;
never used
Defined macros
next
defined in line
21; used 2 times