1 /* $NetBSD: main.c,v 1.14 2008/07/21 14:19:28 lukem Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Edward Wang at The University of California, Berkeley.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/cdefs.h>
37 __COPYRIGHT("@(#) Copyright (c) 1983, 1993\
38 The Regents of the University of California. All rights reserved.");
43 static char sccsid
[] = "@(#)main.c 8.2 (Berkeley) 4/2/94";
45 __RCSID("$NetBSD: main.c,v 1.14 2008/07/21 14:19:28 lukem Exp $");
57 #include "window_string.h"
61 int main(int, char **);
65 main(int argc
, char **argv
)
77 debug
= strcmp(getprogname(), "a.out") == 0;
78 while ((ch
= getopt(argc
, argv
, "fc:e:tdDx")) != -1) {
85 warnx("Only one -c allowed");
109 if ((kp
= getenv("SHELL")) == 0)
111 if ((default_shellfile
= str_cpy(kp
)) == 0)
112 errx(1, "Out of memory.");
113 if ((p
= strrchr(default_shellfile
, '/')))
116 p
= default_shellfile
;
117 default_shell
[0] = p
;
118 default_shell
[1] = 0;
119 default_nline
= NLINE
;
121 (void) gettimeofday(&starttime
, (struct timezone
*)0);
123 errx(1, "%s", wwerror());
127 wwnewtty
.ww_tchars
.t_quitc
= wwoldtty
.ww_tchars
.t_quitc
;
129 wwnewtty
.ww_tchars
.t_stopc
= wwoldtty
.ww_tchars
.t_stopc
;
130 wwnewtty
.ww_tchars
.t_startc
= wwoldtty
.ww_tchars
.t_startc
;
134 wwnewtty
.ww_termios
.c_cc
[VQUIT
] =
135 wwoldtty
.ww_termios
.c_cc
[VQUIT
];
136 wwnewtty
.ww_termios
.c_lflag
|= ISIG
;
139 wwnewtty
.ww_termios
.c_cc
[VSTOP
] =
140 wwoldtty
.ww_termios
.c_cc
[VSTOP
];
141 wwnewtty
.ww_termios
.c_cc
[VSTART
] =
142 wwoldtty
.ww_termios
.c_cc
[VSTART
];
143 wwnewtty
.ww_termios
.c_iflag
|= IXON
;
147 (void) wwsettty(0, &wwnewtty
);
149 if ((cmdwin
= wwopen(WWT_INTERNAL
, wwbaud
> 2400 ? WWO_REVERSE
: 0, 1,
150 wwncol
, 0, 0, 0)) == 0) {
152 warnx("%s.\r", wwerror());
155 SET(cmdwin
->ww_wflags
,
156 WWW_MAPNL
| WWW_NOINTR
| WWW_NOUPDATE
| WWW_UNCTRL
);
157 if ((framewin
= wwopen(WWT_INTERNAL
, WWO_GLASS
|WWO_FRAME
, wwnrow
,
158 wwncol
, 0, 0, 0)) == 0) {
160 warnx("%s.\r", wwerror());
163 wwadd(framewin
, &wwhead
);
164 if ((boxwin
= wwopen(WWT_INTERNAL
, WWO_GLASS
, wwnrow
, wwncol
, 0, 0, 0))
167 warnx("%s.\r", wwerror());
179 (void) dolongcmd(cmd
, (struct value
*)0, 0);
181 if (dflag
|| doconfig() < 0)
196 (void) fprintf(stderr
,
197 "usage: %s [-e escape-char] [-c command] [-t] [-f] [-d]\n",