SCCS-vsn: usr.bin/window/wwiomux.c 3.2
SCCS-vsn: usr.bin/window/wwspawn.c 3.3
SCCS-vsn: usr.bin/window/wwinit.c 3.9
SCCS-vsn: usr.bin/window/wwopen.c 3.8
SCCS-vsn: usr.bin/window/ww.h 3.11
SCCS-vsn: usr.bin/window/cmd.c 3.8
SCCS-vsn: usr.bin/window/cmd1.c 3.9
SCCS-vsn: usr.bin/window/wwtty.c 3.4
SCCS-vsn: usr.bin/window/wwwrite.c 3.9
SCCS-vsn: usr.bin/window/cmd2.c 3.10
SCCS-vsn: usr.bin/window/wwlabel.c 3.6
SCCS-vsn: usr.bin/window/startup.c 3.5
SCCS-vsn: usr.bin/window/ttinit.c 3.6
SCCS-vsn: usr.bin/window/lcmd1.c 3.6
SCCS-vsn: usr.bin/window/wwalloc.c 3.4
SCCS-vsn: usr.bin/window/wwpty.c 3.3
16 files changed:
-static char *sccsid = "@(#)cmd.c 3.7 83/08/26";
+static char *sccsid = "@(#)cmd.c 3.8 83/08/26";
buf[0] = w->ww_id + '1';
buf[1] = 0;
buf[0] = w->ww_id + '1';
buf[1] = 0;
- (void) wwlabel(w, framewin, 1, buf, mode);
+ wwlabel(w, framewin, 1, buf, mode);
}
if (w->ww_label) {
int col;
}
if (w->ww_label) {
int col;
col = MAX(3, col);
} else
col = 3;
col = MAX(3, col);
} else
col = 3;
- (void) wwlabel(w, framewin, col, w->ww_label, mode);
+ wwlabel(w, framewin, col, w->ww_label, mode);
-static char *sccsid = "@(#)cmd1.c 3.8 83/08/26";
+static char *sccsid = "@(#)cmd1.c 3.9 83/08/26";
int col, row, xcol, xrow;
int id;
int col, row, xcol, xrow;
int id;
- if ((id = findid()) < 0) {
- error("Too many windows.");
+ if ((id = findid()) < 0)
if (!terse)
(void) wwputs("Upper left corner: ", cmdwin);
col = 0;
if (!terse)
(void) wwputs("Upper left corner: ", cmdwin);
col = 0;
if (!terse)
(void) wwputs("\r\n", cmdwin);
wwcurtowin(cmdwin);
if (!terse)
(void) wwputs("\r\n", cmdwin);
wwcurtowin(cmdwin);
- if (openwin(id, row, col, xrow-row+1, xcol-col+1, nbufline) == 0)
- error("Can't open window.");
+ (void) openwin(id, row, col, xrow-row+1, xcol-col+1, nbufline);
for (i = 0; i < NWINDOW && window[i] != 0; i++)
;
for (i = 0; i < NWINDOW && window[i] != 0; i++)
;
- return i < NWINDOW ? i : -1;
+ if (i >= NWINDOW) {
+ error("Too many windows.");
+ return -1;
+ }
+ return i;
}
getpos(row, col, minrow, mincol)
}
getpos(row, col, minrow, mincol)
- if (row <= 0)
- return 0;
if (id < 0 && (id = findid()) < 0)
return 0;
if (id < 0 && (id = findid()) < 0)
return 0;
- if ((w = wwopen(WWO_PTY, nrow, ncol, row, col, nline)) == 0)
+ if (row <= 0) {
+ error("Bad row number.");
+ return 0;
+ }
+ if ((w = wwopen(WWO_PTY, nrow, ncol, row, col, nline)) == 0) {
+ error("%s.", wwerror());
w->ww_id = id;
window[id] = w;
w->ww_hasframe = 1;
w->ww_id = id;
window[id] = w;
w->ww_hasframe = 1;
switch (wwfork(w)) {
case -1:
c_close(w);
switch (wwfork(w)) {
case -1:
c_close(w);
+ error("%s.", wwerror());
return 0;
case 0:
execl(shell, shellname, 0);
return 0;
case 0:
execl(shell, shellname, 0);
-static char *sccsid = "@(#)cmd2.c 3.9 83/08/26";
+static char *sccsid = "@(#)cmd2.c 3.10 83/08/26";
-struct ww *openiwin();
-
c_help()
{
register struct ww *w;
if ((w = openiwin(wwnrow - 3, "Help")) == 0) {
c_help()
{
register struct ww *w;
if ((w = openiwin(wwnrow - 3, "Help")) == 0) {
- error("Can't open help window.");
+ error("Can't open help window: %s.", wwerror());
return;
}
(void) wwprintf(w, "The escape character is %s, which gets you into command mode.\n\n",
return;
}
(void) wwprintf(w, "The escape character is %s, which gets you into command mode.\n\n",
struct timezone timezone;
if ((w = openiwin(6, "Timing and Resource Usage")) == 0) {
struct timezone timezone;
if ((w = openiwin(6, "Timing and Resource Usage")) == 0) {
- error("Can't open time window.");
+ error("Can't open time window: %s.", wwerror());
register struct ww *w;
if ((w = openiwin(4, "IO Statics")) == 0) {
register struct ww *w;
if ((w = openiwin(4, "IO Statics")) == 0) {
- error("Can't open statistics window.");
+ error("Can't open statistics window: %s.", wwerror());
return;
}
(void) wwprintf(w, "nread\tnreadz\tnreade\tnreadc\tnwrite\tnwritec\tnupdate\tntouchd\tnmiss\n");
return;
}
(void) wwprintf(w, "nread\tnreadz\tnreade\tnreadc\tnwrite\tnwritec\tnupdate\tntouchd\tnmiss\n");
if (window[i] != 0)
n++;
if ((w = openiwin(MAX(n, 1) + 2, "Active Windows")) == 0) {
if (window[i] != 0)
n++;
if ((w = openiwin(MAX(n, 1) + 2, "Active Windows")) == 0) {
- error("Can't open listing window.");
+ error("Can't open listing window: %s.", wwerror());
-static char *sccsid = "@(#)lcmd1.c 3.5 83/08/25";
+static char *sccsid = "@(#)lcmd1.c 3.6 83/08/26";
l_window()
{
register char **pp = argv;
l_window()
{
register char **pp = argv;
int col, row, ncol, nrow, id, nline;
int col, row, ncol, nrow, id, nline;
- if ((id = findid()) < 0) {
- error("Too many windows.");
+ if ((id = findid()) < 0)
row = **++pp == '*' ? 1 : atoi(*pp);
col = **++pp == '*' ? 0 : atoi(*pp);
nrow = **++pp == '*' ? wwnrow - row : atoi(*pp);
ncol = **++pp == '*' ? wwncol - col : atoi(*pp);
nline = *++pp == 0 ? nbufline : atoi(*pp);
row = **++pp == '*' ? 1 : atoi(*pp);
col = **++pp == '*' ? 0 : atoi(*pp);
nrow = **++pp == '*' ? wwnrow - row : atoi(*pp);
ncol = **++pp == '*' ? wwncol - col : atoi(*pp);
nline = *++pp == 0 ? nbufline : atoi(*pp);
- w = openwin(id, row, col, nrow, ncol, nline);
- if (w == 0)
- error("Can't open window: row %d col %d, %d rows %d cols %d lines.",
- row, col, nrow, ncol, nline);
+ (void) openwin(id, row, col, nrow, ncol, nline);
-static char *sccsid = "@(#)startup.c 3.4 83/08/25";
+static char *sccsid = "@(#)startup.c 3.5 83/08/26";
setselwin(w);
return;
bad:
setselwin(w);
return;
bad:
- (void) wwputs("Can't open default windows. ", cmdwin);
+ (void) wwputs("\nCan't open default windows. ", cmdwin);
-static char *sccsid = "@(#)ttinit.c 3.5 83/08/15";
+static char *sccsid = "@(#)ttinit.c 3.6 83/08/26";
for (tp = tt_tab; tp->tt_name != 0; tp++)
if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0)
break;
for (tp = tt_tab; tp->tt_name != 0; tp++)
if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0)
break;
+ if (tp->tt_name == 0) {
+ wwerrno = WWE_BADTERM;
- return (*tp->tt_func)();
+ }
+ if ((*tp->tt_func)() < 0) {
+ wwerrno = WWE_CANTDO;
+ return -1;
+ }
+ return 0;
- * @(#)ww.h 3.10 83/08/19
+ * @(#)ww.h 3.11 83/08/26
/* special ww_index value */
#define WWX_NOBODY NWW
/* special ww_index value */
#define WWX_NOBODY NWW
+#define WWE_NOERR 0
+#define WWE_SYS 1 /* system error */
+#define WWE_NOMEM 2 /* out of memory */
+#define WWE_TOOMANY 3 /* too many windows */
+#define WWE_NOPTY 4 /* no more ptys */
+#define WWE_SIZE 5 /* bad window size */
+#define WWE_BADTERM 6 /* bad terminal type */
+#define WWE_CANTDO 7 /* dumb terminal */
+
struct ww wwhead;
struct ww *wwindex[NWW + 1]; /* last location is for wwnobody */
struct ww wwnobody;
struct ww wwhead;
struct ww *wwindex[NWW + 1]; /* last location is for wwnobody */
struct ww wwnobody;
int wwbaudmap[]; /* maps stty() baud rate code into number */
int wwbaud; /* wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed] */
int wwcursorrow, wwcursorcol; /* where we want the cursor to be */
int wwbaudmap[]; /* maps stty() baud rate code into number */
int wwbaud; /* wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed] */
int wwcursorrow, wwcursorcol; /* where we want the cursor to be */
+int wwerrno; /* error number */
/* statistics */
int wwnwrite, wwnwritec;
/* statistics */
int wwnwrite, wwnwritec;
int wwsuspend();
char *unctrl();
char **wwalloc();
int wwsuspend();
char *unctrl();
char **wwalloc();
/* c library functions */
char *malloc();
/* c library functions */
char *malloc();
-static char *sccsid = "@(#)wwalloc.c 3.3 83/08/19";
+static char *sccsid = "@(#)wwalloc.c 3.4 83/08/26";
/* fast, call malloc only once */
pp = (char **)
malloc((unsigned) sizeof (char **) * nrow + size * nrow * ncol);
/* fast, call malloc only once */
pp = (char **)
malloc((unsigned) sizeof (char **) * nrow + size * nrow * ncol);
+ if (pp == 0) {
+ wwerrno = WWE_NOMEM;
p = (char *)&pp[nrow];
size /= sizeof (char); /* paranoid */
size *= ncol;
p = (char *)&pp[nrow];
size /= sizeof (char); /* paranoid */
size *= ncol;
-static char *sccsid = "@(#)wwinit.c 3.8 83/08/19";
+static char *sccsid = "@(#)wwinit.c 3.9 83/08/26";
if (wwsettty(0, &wwnewtty) < 0)
goto bad;
if (wwsettty(0, &wwnewtty) < 0)
goto bad;
- if ((wwterm = getenv("TERM")) == 0)
+ if ((wwterm = getenv("TERM")) == 0) {
+ wwerrno = WWE_BADTERM;
- if (tgetent(wwtermcap, wwterm) != 1)
+ }
+ if (tgetent(wwtermcap, wwterm) != 1) {
+ wwerrno = WWE_BADTERM;
wwbaud = wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed];
if (ttinit() < 0)
wwbaud = wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed];
if (ttinit() < 0)
wwns[i][j].c_w = ' ';
wwtouched = malloc((unsigned) wwnrow);
wwns[i][j].c_w = ' ';
wwtouched = malloc((unsigned) wwnrow);
+ if (wwtouched == 0) {
+ wwerrno = WWE_NOMEM;
for (i = 0; i < wwnrow; i++)
wwtouched[i] = 0;
for (i = 0; i < wwnrow; i++)
wwtouched[i] = 0;
-static char *sccsid = "@(#)wwiomux.c 3.1 83/08/11";
+static char *sccsid = "@(#)wwiomux.c 3.2 83/08/26";
*imask |= 1 << (*w)->ww_pty;
n = select(wwdtablesize, imask, (int *)0, (int *)0,
(struct timeval *)0);
*imask |= 1 << (*w)->ww_pty;
n = select(wwdtablesize, imask, (int *)0, (int *)0,
(struct timeval *)0);
+ if (n <= 0) {
+ wwerrno = WWE_SYS;
for (w = wwindex; w < &wwindex[NWW]; w++)
if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0
&& *imask & 1 << (*w)->ww_pty) {
for (w = wwindex; w < &wwindex[NWW]; w++)
if (*w && (*w)->ww_haspty && (*w)->ww_pty >= 0
&& *imask & 1 << (*w)->ww_pty) {
-static char *sccsid = "@(#)wwlabel.c 3.5 83/08/19";
+static char *sccsid = "@(#)wwlabel.c 3.6 83/08/26";
char *touched;
if (f->ww_fmap == 0)
char *touched;
if (f->ww_fmap == 0)
i = w->ww_w.t - 1 - f->ww_w.t;
if (i < 0)
i = w->ww_w.t - 1 - f->ww_w.t;
if (i < 0)
j = w->ww_w.l + where - f->ww_w.l;
if (j < 0)
j = 0;
j = w->ww_w.l + where - f->ww_w.l;
if (j < 0)
j = 0;
*fmap++ |= WWF_LABEL;
}
}
*fmap++ |= WWF_LABEL;
}
}
-static char *sccsid = "@(#)wwopen.c 3.7 83/08/23";
+static char *sccsid = "@(#)wwopen.c 3.8 83/08/26";
short nvis;
w = (struct ww *)calloc(sizeof (struct ww), 1);
short nvis;
w = (struct ww *)calloc(sizeof (struct ww), 1);
+ if (w == 0) {
+ wwerrno = WWE_NOMEM;
for (i = 0; i < NWW && wwindex[i] != 0; i++)
;
for (i = 0; i < NWW && wwindex[i] != 0; i++)
;
+ if (i >= NWW) {
+ wwerrno = WWE_TOOMANY;
- if (nrow <= 0 || ncol <= 0)
- goto bad;
- if ((w->ww_w.l = col) < 0)
- goto bad;
- if ((w->ww_w.r = col + ncol) > wwncol)
- goto bad;
- if ((w->ww_w.t = row) < 0)
+ if ((w->ww_w.nr = nrow) <= 0
+ || (w->ww_w.nc = ncol) <= 0
+ || (w->ww_w.l = col) < 0
+ || (w->ww_w.r = col + ncol) > wwncol
+ || (w->ww_w.t = row) < 0
+ || (w->ww_w.b = row + nrow) > wwnrow) {
+ wwerrno = WWE_SIZE;
- if ((w->ww_w.b = row + nrow) > wwnrow)
- goto bad;
- w->ww_w.nc = ncol;
- w->ww_w.nr = nrow;
w->ww_nline = MAX(nline, w->ww_w.nr);
w->ww_pty = w->ww_tty = -1; /* closing by mistake is still safe */
w->ww_nline = MAX(nline, w->ww_w.nr);
w->ww_pty = w->ww_tty = -1; /* closing by mistake is still safe */
if (flags & WWO_FRAME) {
w->ww_fmap = wwalloc(w->ww_w.nr, w->ww_w.nc, sizeof (char));
if (w->ww_fmap == 0)
if (flags & WWO_FRAME) {
w->ww_fmap = wwalloc(w->ww_w.nr, w->ww_w.nc, sizeof (char));
if (w->ww_fmap == 0)
for (i = 0; i < wwnrow; i++)
for (j = 0; j < wwncol; j++)
w->ww_fmap[i][j] = 0;
for (i = 0; i < wwnrow; i++)
for (j = 0; j < wwncol; j++)
w->ww_fmap[i][j] = 0;
w->ww_buf[i][j].c_w = ' ';
w->ww_nvis = (short *)malloc((unsigned) w->ww_w.nr * sizeof (short));
w->ww_buf[i][j].c_w = ' ';
w->ww_nvis = (short *)malloc((unsigned) w->ww_w.nr * sizeof (short));
+ if (w->ww_nvis == 0) {
+ wwerrno = WWE_NOMEM;
nvis = m ? 0 : w->ww_w.nc;
for (i = 0; i < w->ww_w.nr; i++)
w->ww_nvis[i] = nvis;
nvis = m ? 0 : w->ww_w.nc;
for (i = 0; i < w->ww_w.nr; i++)
w->ww_nvis[i] = nvis;
-static char *sccsid = "@(#)wwpty.c 3.2 83/08/11";
+static char *sccsid = "@(#)wwpty.c 3.3 83/08/26";
return -1;
good:
(void) strcpy(w->ww_ttyname, line);
return -1;
good:
(void) strcpy(w->ww_ttyname, line);
-static char *sccsid = "@(#)wwspawn.c 3.2 83/08/17";
+static char *sccsid = "@(#)wwspawn.c 3.3 83/08/26";
{
switch (wp->ww_pid = fork()) {
case -1:
{
switch (wp->ww_pid = fork()) {
case -1:
return -1;
case 0:
moncontrol(0);
return -1;
case 0:
moncontrol(0);
-static char *sccsid = "@(#)wwtty.c 3.3 83/08/23";
+static char *sccsid = "@(#)wwtty.c 3.4 83/08/26";
register struct ww_tty *t;
{
if (ioctl(d, (int)TIOCGETP, (char *)&t->ww_sgttyb) < 0)
register struct ww_tty *t;
{
if (ioctl(d, (int)TIOCGETP, (char *)&t->ww_sgttyb) < 0)
if (ioctl(d, (int)TIOCGETC, (char *)&t->ww_tchars) < 0)
if (ioctl(d, (int)TIOCGETC, (char *)&t->ww_tchars) < 0)
if (ioctl(d, (int)TIOCGLTC, (char *)&t->ww_ltchars) < 0)
if (ioctl(d, (int)TIOCGLTC, (char *)&t->ww_ltchars) < 0)
if (ioctl(d, (int)TIOCLGET, (char *)&t->ww_lmode) < 0)
if (ioctl(d, (int)TIOCLGET, (char *)&t->ww_lmode) < 0)
if (ioctl(d, (int)TIOCGETD, (char *)&t->ww_ldisc) < 0)
if (ioctl(d, (int)TIOCGETD, (char *)&t->ww_ldisc) < 0)
if (ioctl(d, (int)TIOCGPGRP, (char *)&t->ww_pgrp) < 0)
if (ioctl(d, (int)TIOCGPGRP, (char *)&t->ww_pgrp) < 0)
+bad:
+ wwerrno = WWE_SYS;
+ return -1;
}
wwsettty(d, t)
register struct ww_tty *t;
{
if (ioctl(d, (int)TIOCSETN, (char *)&t->ww_sgttyb) < 0)
}
wwsettty(d, t)
register struct ww_tty *t;
{
if (ioctl(d, (int)TIOCSETN, (char *)&t->ww_sgttyb) < 0)
if (ioctl(d, (int)TIOCSETC, (char *)&t->ww_tchars) < 0)
if (ioctl(d, (int)TIOCSETC, (char *)&t->ww_tchars) < 0)
if (ioctl(d, (int)TIOCSLTC, (char *)&t->ww_ltchars) < 0)
if (ioctl(d, (int)TIOCSLTC, (char *)&t->ww_ltchars) < 0)
if (ioctl(d, (int)TIOCLSET, (char *)&t->ww_lmode) < 0)
if (ioctl(d, (int)TIOCLSET, (char *)&t->ww_lmode) < 0)
if (ioctl(d, (int)TIOCSETD, (char *)&t->ww_ldisc) < 0)
if (ioctl(d, (int)TIOCSETD, (char *)&t->ww_ldisc) < 0)
if (ioctl(d, (int)TIOCSPGRP, (char *)&t->ww_pgrp) < 0)
if (ioctl(d, (int)TIOCSPGRP, (char *)&t->ww_pgrp) < 0)
+bad:
+ wwerrno = WWE_SYS;
+ return -1;
-static char *sccsid = "@(#)wwwrite.c 3.8 83/08/23";
+static char *sccsid = "@(#)wwwrite.c 3.9 83/08/26";
- if (w == 0)
- return -1;
wwnwrite++;
wwnwritec += n;
if (hascursor = w->ww_hascursor)
wwnwrite++;
wwnwritec += n;
if (hascursor = w->ww_hascursor)
}
if (hascursor)
wwcursor(w, 1);
}
if (hascursor)
wwcursor(w, 1);