static char sccsid
[] = "@(#)wwinit.c 3.25 %G%";
* Copyright (c) 1983 Regents of the University of California,
* All rights reserved. Redistribution permitted subject to
* the terms of the Berkeley Software License Agreement.
char **env
, **termcap
= 0;
wwdtablesize
= getdtablesize();
wwhead
.ww_forw
= &wwhead
;
wwhead
.ww_back
= &wwhead
;
s
= sigblock(sigmask(SIGIO
));
if (signal(SIGIO
, wwrint
) == BADSIG
)
if (wwgettty(0, &wwoldtty
) < 0)
wwwintty
.ww_sgttyb
.sg_flags
&= ~XTABS
;
wwnewtty
.ww_sgttyb
= wwoldtty
.ww_sgttyb
;
wwnewtty
.ww_sgttyb
.sg_erase
= -1;
wwnewtty
.ww_sgttyb
.sg_kill
= -1;
wwnewtty
.ww_sgttyb
.sg_flags
|= CBREAK
;
wwnewtty
.ww_sgttyb
.sg_flags
&= ~(ECHO
|CRMOD
);
wwnewtty
.ww_tchars
.t_intrc
= -1;
wwnewtty
.ww_tchars
.t_quitc
= -1;
wwnewtty
.ww_tchars
.t_startc
= -1;
wwnewtty
.ww_tchars
.t_stopc
= -1;
wwnewtty
.ww_tchars
.t_eofc
= -1;
wwnewtty
.ww_tchars
.t_brkc
= -1;
wwnewtty
.ww_ltchars
.t_suspc
= -1;
wwnewtty
.ww_ltchars
.t_dsuspc
= -1;
wwnewtty
.ww_ltchars
.t_rprntc
= -1;
wwnewtty
.ww_ltchars
.t_flushc
= -1;
wwnewtty
.ww_ltchars
.t_werasc
= -1;
wwnewtty
.ww_ltchars
.t_lnextc
= -1;
wwnewtty
.ww_lmode
= wwoldtty
.ww_lmode
| LLITOUT
;
wwnewtty
.ww_ldisc
= wwoldtty
.ww_ldisc
;
wwnewtty
.ww_fflags
= wwoldtty
.ww_fflags
| FASYNC
;
if (wwsettty(0, &wwnewtty
, &wwoldtty
) < 0)
if ((wwterm
= getenv("TERM")) == 0) {
if (tgetent(wwtermcap
, wwterm
) != 1) {
wwbaud
= wwbaudmap
[wwoldtty
.ww_sgttyb
.sg_ospeed
];
wwavailmodes
= tt
.tt_availmodes
;
if (wwavailmodes
& WWM_REV
)
wwcursormodes
= WWM_REV
| wwavailmodes
& WWM_BLK
;
else if (wwavailmodes
& WWM_UL
)
if ((wwib
= malloc((unsigned) 512)) == 0)
if ((wwsmap
= wwalloc(0, 0, wwnrow
, wwncol
, sizeof (char))) == 0)
for (i
= 0; i
< wwnrow
; i
++)
for (j
= 0; j
< wwncol
; j
++)
wwsmap
[i
][j
] = WWX_NOBODY
;
wwos
= (union ww_char
**)
wwalloc(0, 0, wwnrow
, wwncol
, sizeof (union ww_char
));
for (i
= 0; i
< wwnrow
; i
++)
for (j
= 0; j
< wwncol
; j
++)
wwns
= (union ww_char
**)
wwalloc(0, 0, wwnrow
, wwncol
, sizeof (union ww_char
));
for (i
= 0; i
< wwnrow
; i
++)
for (j
= 0; j
< wwncol
; j
++)
wwtouched
= malloc((unsigned) wwnrow
);
for (i
= 0; i
< wwnrow
; i
++)
wwindex
[WWX_NOBODY
] = &wwnobody
;
if ((j
= tgetnum("kn")) >= 0) {
(void) sprintf(kp
, "kn#%d:", j
);
for (i
= 1; i
<= j
; i
++) {
(void) sprintf(cap
, "k%d", i
);
for (i
= 0, p
= environ
; *p
++; i
++)
if ((env
= (char **)malloc((unsigned)(i
+ 3) * sizeof (char *))) == 0)
for (p
= environ
, q
= env
; *p
; p
++, q
++) {
if (strncmp(*p
, "TERM=", 5) == 0)
else if (strncmp(*p
, "TERMCAP=", 8) == 0)
*(termcap
? termcap
: q
++) = wwwintermcap
;
(void) signal(SIGPIPE
, SIG_IGN
);
* Don't bother to free storage. We're supposed
* to exit when wwinit fails anyway.
(void) wwsettty(0, &wwoldtty
, &wwnewtty
);
(void) signal(SIGIO
, SIG_DFL
);
if ((str
= tgetstr(cap
, &tp
)) != 0) {
while (*(*kp
)++ = *cap
++)
for (p
= unctrl(*str
++); *(*kp
)++ = *p
++;)