From af78a4cd2b73800af86db8d999d80b1ef0e9bd75 Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 2 Mar 2004 23:11:58 +0000 Subject: Little tweaks and documentation. --- src/cmd/samterm/mesg.c | 6 +----- src/cmd/samterm/mkfile | 2 +- src/cmd/samterm/plan9.c | 34 +++++++++++----------------------- 3 files changed, 13 insertions(+), 29 deletions(-) (limited to 'src/cmd/samterm') diff --git a/src/cmd/samterm/mesg.c b/src/cmd/samterm/mesg.c index 0bffad3d..20528431 100644 --- a/src/cmd/samterm/mesg.c +++ b/src/cmd/samterm/mesg.c @@ -25,7 +25,7 @@ long invlong(int); void hsetdot(int, long, long); void hmoveto(int, long); void hsetsnarf(int); -/* void hplumb(int); */ +void hplumb(int); void clrlock(void); int snarfswap(char*, int, char**); @@ -296,11 +296,9 @@ inmesg(Hmesg type, int count) threadexitsall(nil); break; -/* case Hplumb: hplumb(m); break; -*/ } } @@ -668,7 +666,6 @@ hsetsnarf(int nc) setcursor(mousectl, cursor); } -/* void hplumb(int nc) { @@ -687,7 +684,6 @@ hplumb(int nc) } free(s); } -*/ void hgrow(int m, long a, long new, int req) diff --git a/src/cmd/samterm/mkfile b/src/cmd/samterm/mkfile index 67997f39..facc78d2 100644 --- a/src/cmd/samterm/mkfile +++ b/src/cmd/samterm/mkfile @@ -23,6 +23,6 @@ HFILES=\ CFLAGS=$CFLAGS -I../sam LDFLAGS=$LDFLAGS -L$X11/lib -lX11 -lm -SHORTLIB=frame draw thread regexp9 bio 9 +SHORTLIB=frame draw plumb fs mux thread regexp9 bio 9 <$PLAN9/src/mkone diff --git a/src/cmd/samterm/plan9.c b/src/cmd/samterm/plan9.c index 60ef5c0e..7c4ed39b 100644 --- a/src/cmd/samterm/plan9.c +++ b/src/cmd/samterm/plan9.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "flayer.h" #include "samterm.h" @@ -170,20 +171,15 @@ extstart(void) atexit(removeextern); } -#if 0 int -plumbformat(int i) +plumbformat(Plumbmsg *m, int i) { - Plumbmsg *m; char *addr, *data, *act; int n; data = (char*)plumbbuf[i].data; - m = plumbunpack(data, plumbbuf[i].n); - if(m == nil) - return 0; n = m->ndata; - if(n == 0){ + if(n == 0 || 2+n+2 >= READBUFSIZE){ plumbfree(m); return 0; } @@ -219,8 +215,9 @@ void plumbproc(void *argv) { Channel *c; - int i, n, which, *fdp; + int i, *fdp; void **arg; + Plumbmsg *m; arg = argv; c = arg[0]; @@ -229,16 +226,14 @@ plumbproc(void *argv) i = 0; threadfdnoblock(*fdp); for(;;){ - i = 1-i; /* toggle */ - n = threadread(*fdp, plumbbuf[i].data, READBUFSIZE); - if(n <= 0){ + m = threadplumbrecv(*fdp); + if(m == nil){ fprint(2, "samterm: plumb read error: %r\n"); threadexits("plumb"); /* not a fatal error */ } - plumbbuf[i].n = n; - if(plumbformat(i)){ - which = i; - send(c, &which); + if(plumbformat(m, i)){ + send(c, &i); + i = 1-i; /* toggle */ } } } @@ -258,18 +253,11 @@ plumbstart(void) close(fd); return -1; } - arg[0] =plumbc; + arg[0] = plumbc; arg[1] = &fd; threadcreate(plumbproc, arg, STACK); return 1; } -#endif - -int -plumbstart(void) -{ - return -1; -} void hostproc(void *arg) -- cgit v1.2.3