diff options
author | rsc <devnull@localhost> | 2005-07-12 15:23:36 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-07-12 15:23:36 +0000 |
commit | a0d146edd7a7de6236a0d60baafeeb59f8452aae (patch) | |
tree | b55baa526d9f5adfc73246e6ee2fadf455e0b7a2 /src/cmd/venti/write.c | |
parent | 88bb285e3d87ec2508840af33f7e0af53ec3c13c (diff) | |
download | plan9port-a0d146edd7a7de6236a0d60baafeeb59f8452aae.tar.gz plan9port-a0d146edd7a7de6236a0d60baafeeb59f8452aae.tar.bz2 plan9port-a0d146edd7a7de6236a0d60baafeeb59f8452aae.zip |
return of venti
Diffstat (limited to 'src/cmd/venti/write.c')
-rw-r--r-- | src/cmd/venti/write.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/cmd/venti/write.c b/src/cmd/venti/write.c new file mode 100644 index 00000000..c11a5a31 --- /dev/null +++ b/src/cmd/venti/write.c @@ -0,0 +1,62 @@ +#include <u.h> +#include <libc.h> +#include <venti.h> +#include <libsec.h> +#include <thread.h> + +void +usage(void) +{ + fprint(2, "usage: write [-z] [-h host] [-t type] <datablock\n"); + threadexitsall("usage"); +} + +void +threadmain(int argc, char *argv[]) +{ + char *host; + int dotrunc, n, type; + uchar *p, score[VtScoreSize]; + VtConn *z; + + fmtinstall('F', vtfcallfmt); + fmtinstall('V', vtscorefmt); + + host = nil; + dotrunc = 0; + type = VtDataType; + ARGBEGIN{ + case 'z': + dotrunc = 1; + break; + case 'h': + host = EARGF(usage()); + break; + case 't': + type = atoi(EARGF(usage())); + break; + default: + usage(); + break; + }ARGEND + + if(argc != 0) + usage(); + + p = vtmallocz(VtMaxLumpSize+1); + n = readn(0, p, VtMaxLumpSize+1); + if(n > VtMaxLumpSize) + sysfatal("input too big: max block size is %d", VtMaxLumpSize); + z = vtdial(host); + if(z == nil) + sysfatal("could not connect to server: %r"); + if(vtconnect(z) < 0) + sysfatal("vtconnect: %r"); + if(dotrunc) + n = vtzerotruncate(type, p, n); + if(vtwrite(z, score, type, p, n) < 0) + sysfatal("vtwrite: %r"); + vthangup(z); + print("%V\n", score); + threadexitsall(0); +} |