From a0d146edd7a7de6236a0d60baafeeb59f8452aae Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 12 Jul 2005 15:23:36 +0000 Subject: return of venti --- src/cmd/venti/readlist.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 src/cmd/venti/readlist.c (limited to 'src/cmd/venti/readlist.c') diff --git a/src/cmd/venti/readlist.c b/src/cmd/venti/readlist.c new file mode 100644 index 00000000..bb1d9b6b --- /dev/null +++ b/src/cmd/venti/readlist.c @@ -0,0 +1,112 @@ +#include +#include +#include +#include +#include + +char *host; +Biobuf b; +VtConn *z; +uchar *buf; +void run(Biobuf*); +int nn; + +void +usage(void) +{ + fprint(2, "usage: readlist [-h host] list\n"); + threadexitsall("usage"); +} + +int +parsescore(uchar *score, char *buf, int n) +{ + int i, c; + + memset(score, 0, VtScoreSize); + + if(n != VtScoreSize*2){ + werrstr("score wrong length %d", n); + return -1; + } + for(i=0; i= '0' && buf[i] <= '9') + c = buf[i] - '0'; + else if(buf[i] >= 'a' && buf[i] <= 'f') + c = buf[i] - 'a' + 10; + else if(buf[i] >= 'A' && buf[i] <= 'F') + c = buf[i] - 'A' + 10; + else { + c = buf[i]; + werrstr("bad score char %d '%c'", c, c); + return -1; + } + + if((i & 1) == 0) + c <<= 4; + + score[i>>1] |= c; + } + return 0; +} + +void +threadmain(int argc, char *argv[]) +{ + int fd, i; + + ARGBEGIN{ + case 'h': + host = EARGF(usage()); + break; + default: + usage(); + break; + }ARGEND + + fmtinstall('V', vtscorefmt); + buf = vtmallocz(VtMaxLumpSize); + z = vtdial(host); + if(z == nil) + sysfatal("could not connect to server: %r"); + if(vtconnect(z) < 0) + sysfatal("vtconnect: %r"); + + if(argc == 0){ + Binit(&b, 0, OREAD); + run(&b); + }else{ + for(i=0; i