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"
51 main(int argc, char **argv)
63 debug = strcmp(getprogname(), "a.out") == 0;
64 while ((ch = getopt(argc, argv, "fc:e:tdDx")) != -1) {
71 warnx("Only one -c allowed");
95 if ((kp = getenv("SHELL")) == NULL)
97 if ((default_shellfile = str_cpy(kp)) == 0)
98 errx(1, "Out of memory.");
99 if ((p = strrchr(default_shellfile, '/')))
102 p = default_shellfile;
103 default_shell[0] = p;
104 default_shell[1] = 0;
105 default_nline = NLINE;
107 (void) gettimeofday(&starttime, (struct timezone *)0);
109 errx(1, "%s", wwerror());
113 wwnewtty.ww_tchars.t_quitc = wwoldtty.ww_tchars.t_quitc;
115 wwnewtty.ww_tchars.t_stopc = wwoldtty.ww_tchars.t_stopc;
116 wwnewtty.ww_tchars.t_startc = wwoldtty.ww_tchars.t_startc;
120 wwnewtty.ww_termios.c_cc[VQUIT] =
121 wwoldtty.ww_termios.c_cc[VQUIT];
122 wwnewtty.ww_termios.c_lflag |= ISIG;
125 wwnewtty.ww_termios.c_cc[VSTOP] =
126 wwoldtty.ww_termios.c_cc[VSTOP];
127 wwnewtty.ww_termios.c_cc[VSTART] =
128 wwoldtty.ww_termios.c_cc[VSTART];
129 wwnewtty.ww_termios.c_iflag |= IXON;
133 (void) wwsettty(0, &wwnewtty);
135 if ((cmdwin = wwopen(WWT_INTERNAL, wwbaud > 2400 ? WWO_REVERSE : 0, 1,
136 wwncol, 0, 0, 0)) == 0) {
138 warnx("%s.\r", wwerror());
141 SET(cmdwin->ww_wflags,
142 WWW_MAPNL | WWW_NOINTR | WWW_NOUPDATE | WWW_UNCTRL);
143 if ((framewin = wwopen(WWT_INTERNAL, WWO_GLASS|WWO_FRAME, wwnrow,
144 wwncol, 0, 0, 0)) == 0) {
146 warnx("%s.\r", wwerror());
149 wwadd(framewin, &wwhead);
150 if ((boxwin = wwopen(WWT_INTERNAL, WWO_GLASS, wwnrow, wwncol, 0, 0, 0))
153 warnx("%s.\r", wwerror());
165 (void) dolongcmd(cmd, (struct value *)0, 0);
167 if (dflag || doconfig() < 0)
182 (void) fprintf(stderr,
183 "usage: %s [-e escape-char] [-c command] [-t] [-f] [-d]\n",