1 /* @(#)main.c 8.2 (Berkeley) 4/2/94 */
2 /* $NetBSD: main.c,v 1.15 2009/04/14 08:50:06 lukem Exp $ */
5 * Copyright (c) 1983, 1993
6 * The Regents of the University of California. All rights reserved.
8 * This code is derived from software contributed to Berkeley by
9 * Edward Wang at The University of California, Berkeley.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 #include "window_string.h"
48 int main(int, char **);
52 main(int argc, char **argv)
64 debug = strcmp(getprogname(), "a.out") == 0;
65 while ((ch = getopt(argc, argv, "fc:e:tdDx")) != -1) {
72 warnx("Only one -c allowed");
96 if ((kp = getenv("SHELL")) == 0)
98 if ((default_shellfile = str_cpy(kp)) == 0)
99 errx(1, "Out of memory.");
100 if ((p = strrchr(default_shellfile, '/')))
103 p = default_shellfile;
104 default_shell[0] = p;
105 default_shell[1] = 0;
106 default_nline = NLINE;
108 (void) gettimeofday(&starttime, (struct timezone *)0);
110 errx(1, "%s", wwerror());
114 wwnewtty.ww_tchars.t_quitc = wwoldtty.ww_tchars.t_quitc;
116 wwnewtty.ww_tchars.t_stopc = wwoldtty.ww_tchars.t_stopc;
117 wwnewtty.ww_tchars.t_startc = wwoldtty.ww_tchars.t_startc;
121 wwnewtty.ww_termios.c_cc[VQUIT] =
122 wwoldtty.ww_termios.c_cc[VQUIT];
123 wwnewtty.ww_termios.c_lflag |= ISIG;
126 wwnewtty.ww_termios.c_cc[VSTOP] =
127 wwoldtty.ww_termios.c_cc[VSTOP];
128 wwnewtty.ww_termios.c_cc[VSTART] =
129 wwoldtty.ww_termios.c_cc[VSTART];
130 wwnewtty.ww_termios.c_iflag |= IXON;
134 (void) wwsettty(0, &wwnewtty);
136 if ((cmdwin = wwopen(WWT_INTERNAL, wwbaud > 2400 ? WWO_REVERSE : 0, 1,
137 wwncol, 0, 0, 0)) == 0) {
139 warnx("%s.\r", wwerror());
142 SET(cmdwin->ww_wflags,
143 WWW_MAPNL | WWW_NOINTR | WWW_NOUPDATE | WWW_UNCTRL);
144 if ((framewin = wwopen(WWT_INTERNAL, WWO_GLASS|WWO_FRAME, wwnrow,
145 wwncol, 0, 0, 0)) == 0) {
147 warnx("%s.\r", wwerror());
150 wwadd(framewin, &wwhead);
151 if ((boxwin = wwopen(WWT_INTERNAL, WWO_GLASS, wwnrow, wwncol, 0, 0, 0))
154 warnx("%s.\r", wwerror());
166 (void) dolongcmd(cmd, (struct value *)0, 0);
168 if (dflag || doconfig() < 0)
183 (void) fprintf(stderr,
184 "usage: %s [-e escape-char] [-c command] [-t] [-f] [-d]\n",