10 fprint(2, "usage: read [-h host] score [type]\n");
11 threadexitsall("usage");
15 parsescore(uchar *score, char *buf, int n)
19 memset(score, 0, VtScoreSize);
21 if(n != VtScoreSize*2){
22 werrstr("score wrong length %d", n);
25 for(i=0; i<VtScoreSize*2; i++) {
26 if(buf[i] >= '0' && buf[i] <= '9')
28 else if(buf[i] >= 'a' && buf[i] <= 'f')
29 c = buf[i] - 'a' + 10;
30 else if(buf[i] >= 'A' && buf[i] <= 'F')
31 c = buf[i] - 'A' + 10;
34 werrstr("bad score char %d '%c'", c, c);
47 threadmain(int argc, char *argv[])
50 uchar score[VtScoreSize];
56 host = EARGF(usage());
63 if(argc != 1 && argc != 2)
67 fmtinstall('V', vtscorefmt);
69 if(parsescore(score, argv[0], strlen(argv[0])) < 0)
70 sysfatal("could not parse score '%s': %r", argv[0]);
72 buf = vtmallocz(VtMaxLumpSize);
76 sysfatal("could not connect to server: %r");
79 sysfatal("vtconnect: %r");
83 for(type=0; type<VtMaxType; type++){
84 n = vtread(z, score, type, buf, VtMaxLumpSize);
86 fprint(2, "venti/read%s%s %V %d\n", host ? " -h" : "", host ? host : "",
93 n = vtread(z, score, type, buf, VtMaxLumpSize);
97 sysfatal("could not read block: %r");
98 if(write(1, buf, n) != n)
99 sysfatal("write: %r");