aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/samterm/plan9.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-03-02 23:11:58 +0000
committerrsc <devnull@localhost>2004-03-02 23:11:58 +0000
commitaf78a4cd2b73800af86db8d999d80b1ef0e9bd75 (patch)
tree9b74749fd4bcea9c56914e916a0717235a1aa62d /src/cmd/samterm/plan9.c
parentefc2b0c99e1a4f9d2be9e72785d566df903c66fb (diff)
downloadplan9port-af78a4cd2b73800af86db8d999d80b1ef0e9bd75.tar.gz
plan9port-af78a4cd2b73800af86db8d999d80b1ef0e9bd75.tar.bz2
plan9port-af78a4cd2b73800af86db8d999d80b1ef0e9bd75.zip
Little tweaks and documentation.
Diffstat (limited to 'src/cmd/samterm/plan9.c')
-rw-r--r--src/cmd/samterm/plan9.c34
1 files changed, 11 insertions, 23 deletions
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 <cursor.h>
#include <keyboard.h>
#include <frame.h>
+#include <plumb.h>
#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)