summaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
authorAmadeusz Sławiński <amade@asmblr.net>2013-03-15 18:36:57 +0100
committerAmadeusz Sławiński <amade@asmblr.net>2015-06-25 17:05:31 +0200
commit272b68b2ecf935c15cac5e05062e47114e4cedd4 (patch)
treeab185a67a5b9cd378d50939632b060dff2b2802a /src/window.c
parentc389013e89e7b04ce43872f2e72d43f77461a3c0 (diff)
downloadscreen-272b68b2ecf935c15cac5e05062e47114e4cedd4.tar.gz
bye bye DEBUG
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c88
1 files changed, 0 insertions, 88 deletions
diff --git a/src/window.c b/src/window.c
index 772a9a5..d6b3a9d 100644
--- a/src/window.c
+++ b/src/window.c
@@ -200,7 +200,6 @@ static void WinProcess(char **bufpp, int *lenp)
int l2 = 0, f, *ilen, l = *lenp, trunc;
char *ibuf;
- debug("WinProcess: %d bytes\n", *lenp);
fore = (struct win *)flayer->l_data;
if (fore->w_type == W_TYPE_GROUP) {
@@ -218,14 +217,10 @@ static void WinProcess(char **bufpp, int *lenp)
*/
if (display && fore->w_wlock == WLOCK_AUTO && !fore->w_wlockuser && !AclCheckPermWin(D_user, ACL_WRITE, fore)) {
fore->w_wlockuser = D_user;
- debug("window %d: pending writelock grabbed by user %s\n", fore->w_number, fore->w_wlockuser->u_name);
}
/* if w_wlock is set, only one user may write, else we check acls */
if (display && ((fore->w_wlock == WLOCK_OFF) ?
AclCheckPermWin(D_user, ACL_WRITE, fore) : (D_user != fore->w_wlockuser))) {
- debug("window %d, user %s: ", fore->w_number, D_user->u_name);
- debug("writelock %d (wlockuser %s)\n", fore->w_wlock,
- fore->w_wlockuser ? fore->w_wlockuser->u_name : "NULL");
Msg(0, "write: permission denied (user %s)", D_user->u_name);
*bufpp += *lenp;
*lenp = 0;
@@ -281,20 +276,16 @@ static void ZombieProcess(char **bufpp, int *lenp)
int l = *lenp;
char *buf = *bufpp, b1[10], b2[10];
- debug("ZombieProcess: %d bytes\n", *lenp);
fore = (struct win *)flayer->l_data;
- ASSERT(fore->w_ptyfd < 0);
*bufpp += *lenp;
*lenp = 0;
for (; l-- > 0; buf++) {
if (*(unsigned char *)buf == ZombieKey_destroy) {
- debug("Turning undead: %d\n", fore->w_number);
KillWindow(fore);
return;
}
if (*(unsigned char *)buf == ZombieKey_resurrect) {
- debug("Resurrecting Zombie: %d\n", fore->w_number);
WriteString(fore, "\r\n", 2);
RemakeWindow(fore);
return;
@@ -307,7 +298,6 @@ static void ZombieProcess(char **bufpp, int *lenp)
static void WinRedisplayLine(int y, int from, int to, int isblank)
{
- debug("WinRedisplayLine %d %d %d\n", y, from, to);
if (y < 0)
return;
fore = (struct win *)flayer->l_data;
@@ -326,7 +316,6 @@ static int WinRewrite(int y, int x1, int x2, struct mchar *rend, int doit)
register uint32_t *colorbg;
register uint32_t *colorfg;
- debug("WinRewrite %d, %d-%d\n", y, x1, x2);
fore = (struct win *)flayer->l_data;
dx = x2 - x1 + 1;
if (doit) {
@@ -365,7 +354,6 @@ static int WinRewrite(int y, int x1, int x2, struct mchar *rend, int doit)
static void WinClearLine(int y, int xs, int xe, int bce)
{
fore = (struct win *)flayer->l_data;
- debug("WinClearLine %d %d-%d\n", y, xs, xe);
LClearLine(flayer, y, xs, xe, bce, &fore->w_mlines[y]);
}
@@ -380,7 +368,6 @@ static void WinRestore()
{
struct canvas *cv;
fore = (struct win *)flayer->l_data;
- debug("WinRestore: win %p\n", fore);
for (cv = flayer->l_cvlist; cv; cv = cv->c_next) {
display = cv->c_display;
if (cv != D_forecv)
@@ -415,8 +402,6 @@ int DoStartLog(struct win *w, char *buf, int bufsize)
strncpy(buf, MakeWinMsg(screenlogfile, w, '%'), bufsize - 1);
buf[bufsize - 1] = 0;
- debug("DoStartLog: win %d, file %s\n", w->w_number, buf);
-
if (w->w_log != NULL)
logfclose(w->w_log);
@@ -451,15 +436,7 @@ int MakeWindow(struct NewWindow *newwin)
wtab = calloc(maxwin, sizeof(struct win *));
}
- debug("NewWindow: StartAt %d\n", newwin->StartAt);
- debug("NewWindow: aka %s\n", newwin->aka ? newwin->aka : "NULL");
- debug("NewWindow: dir %s\n", newwin->dir ? newwin->dir : "NULL");
- debug("NewWindow: term %s\n", newwin->term ? newwin->term : "NULL");
-
nwin_compose(&nwin_default, newwin, &nwin);
- debug("NWin: aka %s\n", nwin.aka ? nwin.aka : "NULL");
- debug("NWin: wlock %d\n", nwin.wlock);
- debug("NWin: Lflag %d\n", nwin.Lflag);
startat = nwin.StartAt < maxwin ? nwin.StartAt : 0;
pp = wtab + startat;
@@ -485,7 +462,6 @@ int MakeWindow(struct NewWindow *newwin)
}
#endif
n = pp - wtab;
- debug("Makewin creating %d\n", n);
#ifdef BUILTIN_TELNET
if (!strcmp(nwin.args[0], "//telnet")) {
@@ -651,10 +627,7 @@ int MakeWindow(struct NewWindow *newwin)
#ifdef UTMPOK
p->w_slot = (slot_t) - 1;
#ifdef LOGOUTOK
- debug("MakeWindow will %slog in.\n", nwin.lflag ? "" : "not ");
if (nwin.lflag & 1)
-#else /* LOGOUTOK */
- debug("MakeWindow will log in, LOGOUTOK undefined in config.h%s.\n", nwin.lflag ? "" : " (although lflag=0)");
#endif /* LOGOUTOK */
{
p->w_slot = (slot_t) 0;
@@ -695,7 +668,6 @@ int MakeWindow(struct NewWindow *newwin)
p->w_silenceev.data = (char *)p;
p->w_silenceev.handler = win_silenceev_fn;
if (p->w_silence > 0) {
- debug("New window has silence enabled.\n");
SetTimeout(&p->w_silenceev, p->w_silencewait * 1000);
evenq(&p->w_silenceev);
}
@@ -806,7 +778,6 @@ void FreeWindow(struct win *wp)
struct canvas *cv, *ncv;
struct layer *l;
- debug("FreeWindow %d\n", wp ? wp->w_number : -1);
if (wp->w_pwin)
FreePseudowin(wp);
#ifdef UTMPOK
@@ -902,7 +873,6 @@ static int OpenDevice(char **args, int lflag, int *typep, char **namep)
Msg(errno, "Cannot access line '%s' for R/W", arg);
return -1;
}
- debug("OpenDevice: OpenTTY\n");
if ((f = OpenTTY(arg, args[1])) < 0)
return -1;
lflag = 0;
@@ -926,7 +896,6 @@ static int OpenDevice(char **args, int lflag, int *typep, char **namep)
}
#endif /* TIOCPKT */
}
- debug("fcntl(%d, F_SETFL, FNBLOCK)\n", f);
(void)fcntl(f, F_SETFL, FNBLOCK);
/*
* Tenebreux (zeus@ns.acadiacom.net) has Linux 1.3.70 where select
@@ -1001,14 +970,12 @@ static int ForkWindow(struct win *win, char **args, char *ttyn)
#ifdef O_NOCTTY
if (pty_preopen) {
- debug("pre-opening slave...\n");
if ((slave = open(ttyn, O_RDWR | O_NOCTTY)) == -1) {
Msg(errno, "ttyn");
return -1;
}
}
#endif
- debug("forking...\n");
proc = *args;
if (proc == 0) {
args = ShellArgs;
@@ -1050,10 +1017,6 @@ static int ForkWindow(struct win *win, char **args, char *ttyn)
freetty();
} else
brktty(-1);
-#ifdef DEBUG
- if (dfp && dfp != stderr)
- fclose(dfp);
-#endif
if (slave != -1) {
close(0);
dup(slave);
@@ -1062,18 +1025,6 @@ static int ForkWindow(struct win *win, char **args, char *ttyn)
slave = dup(0);
} else
closeallfiles(win->w_ptyfd);
-#ifdef DEBUG
- if (dfp) { /* do not produce child debug, when debug is "off" */
- char buf[256];
-
- sprintf(buf, "%s/screen.child", DEBUGDIR);
- if ((dfp = fopen(buf, "a")) == 0)
- dfp = stderr;
- else
- (void)chmod(buf, 0666);
- }
- debug("=== ForkWindow: pid %d\n", (int)getpid());
-#endif
/* Close the three /dev/null descriptors */
close(0);
close(1);
@@ -1083,7 +1034,6 @@ static int ForkWindow(struct win *win, char **args, char *ttyn)
* distribute filedescriptors between the ttys
*/
pat = pwin ? pwin->p_fdpat : ((F_PFRONT << (F_PSHIFT * 2)) | (F_PFRONT << F_PSHIFT) | F_PFRONT);
- debug("Using window pattern 0x%x\n", pat);
wfdused = 0;
for (i = 0; i < 3; i++) {
if (pat & F_PFRONT << F_PSHIFT * i) {
@@ -1110,7 +1060,6 @@ static int ForkWindow(struct win *win, char **args, char *ttyn)
* the pseudo window process should not be surprised with a
* nonblocking filedescriptor. Poor Backend!
*/
- debug("Clearing NBLOCK on window-fd(%d)\n", win->w_ptyfd);
if (fcntl(win->w_ptyfd, F_SETFL, 0))
Msg(errno, "Warning: clear NBLOCK fcntl failed");
}
@@ -1122,21 +1071,15 @@ static int ForkWindow(struct win *win, char **args, char *ttyn)
if (fgtty(newfd))
Msg(errno, "fgtty");
if (display) {
- debug("ForkWindow: using display tty mode for new child.\n");
modep = &D_OldMode;
} else {
- debug("No display - creating tty setting\n");
modep = &fakemode;
InitTTY(modep, 0);
-#ifdef DEBUG
- DebugTTY(modep);
-#endif
}
/* We only want echo if the users input goes to the pseudo
* and the pseudo's stdout is not send to the window.
*/
if (pwin && (!(pat & F_UWP) || (pat & F_PBACK << F_PSHIFT))) {
- debug("clearing echo on pseudywin fd (pat %x)\n", pat);
#if defined(POSIX) || defined(TERMIO)
modep->tio.c_lflag &= ~ECHO;
modep->tio.c_iflag &= ~ICRNL;
@@ -1164,12 +1107,10 @@ static int ForkWindow(struct win *win, char **args, char *ttyn)
strncpy(shellbuf + 6, ShellProg + (*ShellProg == '-'), sizeof(shellbuf) - 7);
shellbuf[sizeof(shellbuf) - 1] = 0;
NewEnv[4] = shellbuf;
- debug("ForkWindow: NewEnv[4] = '%s'\n", shellbuf);
if (win->w_term && *win->w_term && strcmp(screenterm, win->w_term) && (strlen(win->w_term) < 20)) {
char *s1, *s2, tl;
sprintf(tebuf, "TERM=%s", win->w_term);
- debug("Makewindow %d with %s\n", win->w_number, tebuf);
tl = strlen(win->w_term);
NewEnv[1] = tebuf;
if ((s1 = strchr(NewEnv[2], '|'))) {
@@ -1188,9 +1129,7 @@ static int ForkWindow(struct win *win, char **args, char *ttyn)
proc++;
if (!*proc)
proc = DefaultShell;
- debug("calling execvpe %s\n", proc);
execvpe(proc, args, NewEnv);
- debug("exec error: %d\n", errno);
Panic(errno, "Cannot exec '%s'", proc);
default:
break;
@@ -1310,7 +1249,6 @@ int winexec(char **av)
l |= F_UWP;
*t++ = ' ';
pwin->p_fdpat = l;
- debug("winexec: '%#x'\n", pwin->p_fdpat);
l = MAXSTR - 4;
for (pp = av; *pp; pp++) {
@@ -1322,7 +1260,6 @@ int winexec(char **av)
*t++ = ' ';
}
*--t = '\0';
- debug("%s\n", pwin->p_cmd);
if ((pwin->p_ptyfd = OpenDevice(av, 0, &type, &t)) < 0) {
free((char *)pwin);
@@ -1376,7 +1313,6 @@ void FreePseudowin(struct win *w)
{
struct pseudowin *pwin = w->w_pwin;
- ASSERT(pwin);
if (fcntl(w->w_ptyfd, F_SETFL, FNBLOCK))
Msg(errno, "Warning: FreePseudowin: NBLOCK fcntl failed");
#ifdef TIOCPKT
@@ -1405,7 +1341,6 @@ void FreePseudowin(struct win *w)
*/
int ReleaseAutoWritelock(struct display *dis, struct win *w)
{
- debug("ReleaseAutoWritelock: user %s, window %d\n", dis->d_user->u_name, w->w_number);
/* release auto writelock when user has no other display here */
if (w->w_wlock == WLOCK_AUTO && w->w_wlockuser == dis->d_user) {
@@ -1414,7 +1349,6 @@ int ReleaseAutoWritelock(struct display *dis, struct win *w)
for (d = displays; d; d = d->d_next)
if ((d != dis) && (d->d_fore == w) && (d->d_user == dis->d_user))
break;
- debug("%s %s autolock on win %d\n", dis->d_user->u_name, d ? "keeps" : "releases", w->w_number);
if (!d) {
w->w_wlockuser = NULL;
return 0;
@@ -1429,7 +1363,6 @@ int ReleaseAutoWritelock(struct display *dis, struct win *w)
int ObtainAutoWritelock(struct display *d, struct win *w)
{
if ((w->w_wlock == WLOCK_AUTO) && !AclCheckPermWin(d->d_user, ACL_WRITE, w) && !w->w_wlockuser) {
- debug("%s obtained auto writelock for exported window %d\n", d->d_user->u_name, w->w_number);
w->w_wlockuser = d->d_user;
return 0;
}
@@ -1465,26 +1398,20 @@ static int muchpending(struct win *p, struct event *ev)
display = cv->c_display;
if (D_status == STATUS_ON_WIN && !D_status_bell) {
/* wait 'til status is gone */
- debug("BLOCKING because of status\n");
ev->condpos = &const_one;
ev->condneg = &D_status;
return 1;
}
- debug("muchpending %s %d: ", D_usertty, D_blocked);
- debug("%d %d %d\n", D_obufp - D_obuf, D_obufmax, D_blocked_fuzz);
if (D_blocked)
continue;
if (D_obufp - D_obuf > D_obufmax + D_blocked_fuzz) {
if (D_nonblock == 0) {
- debug("obuf is full, stopping output to display %s\n", D_usertty);
D_blocked = 1;
continue;
}
- debug("BLOCKING because of full obuf\n");
ev->condpos = &D_obuffree;
ev->condneg = &D_obuflenmax;
if (D_nonblock > 0 && !D_blockedev.queued) {
- debug("created timeout of %g secs\n", D_nonblock / 1000.);
SetTimeout(&D_blockedev, D_nonblock);
evenq(&D_blockedev);
}
@@ -1506,7 +1433,6 @@ static void win_readev_fn(struct event *ev, char *data)
wtop = p->w_pwin && W_WTOP(p);
if (wtop) {
- ASSERT(sizeof(p->w_pwin->p_inbuf) == IOSIZE);
size = IOSIZE - p->w_pwin->p_inlen;
if (size <= 0) {
ev->condpos = &const_IOSIZE;
@@ -1531,7 +1457,6 @@ static void win_readev_fn(struct event *ev, char *data)
return;
}
- debug("going to read from window fd %d\n", ev->fd);
if ((len = read(ev->fd, buf, size)) < 0) {
if (errno == EINTR || errno == EAGAIN)
return;
@@ -1539,20 +1464,16 @@ static void win_readev_fn(struct event *ev, char *data)
if (errno == EWOULDBLOCK)
return;
#endif
- debug("Window %d: read error (errno %d) - killing window\n", p->w_number, errno);
WindowDied(p, 0, 0);
return;
}
if (len == 0) {
- debug("Window %d: EOF - killing window\n", p->w_number);
WindowDied(p, 0, 0);
return;
}
- debug(" -> %d bytes\n", len);
#ifdef TIOCPKT
if (p->w_type == W_TYPE_PTY) {
if (buf[0]) {
- debug("PAKET %x\n", buf[0]);
if (buf[0] & TIOCPKT_NOSTOP)
WNewAutoFlow(p, 0);
if (buf[0] & TIOCPKT_DOSTOP)
@@ -1571,7 +1492,6 @@ static void win_readev_fn(struct event *ev, char *data)
if (zmodem_mode && zmodem_parse(p, bp, len))
return;
if (wtop) {
- debug("sending input to pwin\n");
memmove(p->w_pwin->p_inbuf + p->w_pwin->p_inlen, bp, len);
p->w_pwin->p_inlen += len;
}
@@ -1588,11 +1508,9 @@ struct event *ev;
char *data;
{
struct win *p = (struct win *)data;
- debug("Try to resurrecting Zombie event: %d [%s]\n", p->w_number, p->w_title);
/* Already reconnected? */
if (p->w_deadpid != p->w_pid)
return;
- debug("Resurrecting Zombie: %d\n", p->w_number);
WriteString(p, "\r\n", 2);
RemakeWindow(p);
}
@@ -1603,7 +1521,6 @@ static void win_writeev_fn(struct event *ev, char *data)
struct win *win;
int len;
if (p->w_inlen) {
- debug("writing %d bytes to win %d\n", p->w_inlen, p->w_number);
if ((len = write(ev->fd, p->w_inbuf, p->w_inlen)) <= 0)
len = p->w_inlen; /* dead window */
@@ -1636,7 +1553,6 @@ static void pseu_readev_fn(struct event *ev, char *data)
ptow = W_PTOW(p);
if (ptow) {
- ASSERT(sizeof(p->w_inbuf) == IOSIZE);
size = IOSIZE - p->w_inlen;
if (size <= 0) {
ev->condpos = &const_IOSIZE;
@@ -1667,8 +1583,6 @@ static void pseu_readev_fn(struct event *ev, char *data)
if (errno == EWOULDBLOCK)
return;
#endif
- debug("Window %d: pseudowin read error (errno %d) -- removing pseudowin\n", p->w_number,
- len ? errno : 0);
FreePseudowin(p);
return;
}
@@ -1687,7 +1601,6 @@ static void pseu_writeev_fn(struct event *ev, char *data)
struct pseudowin *pw = p->w_pwin;
int len;
- ASSERT(pw);
if (pw->p_inlen == 0)
return;
if ((len = write(ev->fd, pw->p_inbuf, pw->p_inlen)) <= 0)
@@ -1700,7 +1613,6 @@ static void win_silenceev_fn(struct event *ev, char *data)
{
struct win *p = (struct win *)data;
struct canvas *cv;
- debug("FOUND silence win %d\n", p->w_number);
for (display = displays; display; display = display->d_next) {
for (cv = D_cvlist; cv; cv = cv->c_next)
if (cv->c_layer->l_bottom == &p->w_layer)