static char *sccsid
= "@(#)wwinit.c 3.14 84/01/16";
static char *kp
= wwkeys
;
wwdtablesize
= getdtablesize();
if (wwgettty(0, &wwoldtty
) < 0)
wwwintty
.ww_sgttyb
.sg_flags
&= ~XTABS
;
wwnewtty
.ww_sgttyb
.sg_flags
= wwoldtty
.ww_sgttyb
.sg_flags
;
wwnewtty
.ww_sgttyb
.sg_ispeed
= wwoldtty
.ww_sgttyb
.sg_ispeed
;
wwnewtty
.ww_sgttyb
.sg_ospeed
= wwoldtty
.ww_sgttyb
.sg_ospeed
;
wwnewtty
.ww_lmode
= wwoldtty
.ww_lmode
;
wwnewtty
.ww_ldisc
= wwoldtty
.ww_ldisc
;
wwnewtty
.ww_sgttyb
.sg_flags
|= CBREAK
;
wwnewtty
.ww_sgttyb
.sg_flags
&= ~(ECHO
|CRMOD
);
wwnewtty
.ww_lmode
|= LLITOUT
;
if (wwsettty(0, &wwnewtty
) < 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 ((kn
= tgetnum("kn")) >= 0) {
(void) sprintf(kp
, "kn#%d:", kn
);
for (i
= 1; i
<= kn
; i
++) {
(void) sprintf(cap
, "k%d", i
);
* Don't bother to free storage. We're supposed
* to exit when wwinit fails anyway.
(void) wwsettty(0, &wwoldtty
);
if ((str
= tgetstr(cap
, &tp
)) != 0) {
for (p
= unctrl(*str
++); *kp
++ = *p
++;)