diff options
author | rodri <rgl@antares-labs.eu> | 2020-02-22 09:56:09 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2020-02-22 09:56:09 +0000 |
commit | a39951d8f69209cfea2b7051832b851914e662ef (patch) | |
tree | e4cd1c32e5d6f531b523f6fda558cc3a5f603547 /bgetding.c | |
download | brokentoys-a39951d8f69209cfea2b7051832b851914e662ef.tar.gz brokentoys-a39951d8f69209cfea2b7051832b851914e662ef.tar.bz2 brokentoys-a39951d8f69209cfea2b7051832b851914e662ef.zip |
now version controlled.
Diffstat (limited to 'bgetding.c')
-rw-r--r-- | bgetding.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/bgetding.c b/bgetding.c new file mode 100644 index 0000000..cc427e2 --- /dev/null +++ b/bgetding.c @@ -0,0 +1,46 @@ +#include <u.h> +#include <libc.h> +#include <bio.h> + +typedef struct +{ + double x, y, z; +} Vec; + +void +usage(void) +{ + fprint(2, "usage: %s [file]\n", argv0); + exits("usage"); +} + +void +main(int argc, char *argv[]) +{ + Biobuf *bin; + Vec v; + int fd, r; + + fd = 0; + ARGBEGIN{ + default: usage(); + }ARGEND; + if(argc > 1) + usage(); + else if(argc == 1){ + fd = open(argv[0], OREAD); + if(fd < 0) + sysfatal("open: %r"); + } + bin = Bfdopen(fd, OREAD); + if(bin == nil) + sysfatal("Bfdopen: %r"); + r = Bgetd(bin, &v.x); + print("got %g r=%d\n", v.x, r); + r = Bgetd(bin, &v.y); + print("got %g r=%d\n", v.y, r); + r = Bgetd(bin, &v.z); + print("got %g r=%d\n", v.z, r); + Bterm(bin); + exits(0); +} |