#include #include #include #include #include #include "common.h" /* Pull "blkcnt" blocks from "device", starting at blk "startat" and * write it to stdout. * If "startat" is omitted, it is 0. */ int main(int argc, char **argv) { if ((argc != 4) && (argc != 3)) { fprintf(stderr, "Usage: ./blkdown device blkcnt [startat]\n"); return 1; } unsigned int blkcnt = strtol(argv[2], NULL, 10); unsigned int startat = 0; if (argc == 4) { startat = strtol(argv[3], NULL, 10); } int fd = ttyopen(argv[1]); if (fd < 0) { fprintf(stderr, "Could not open %s\n", argv[1]); return 1; } sendcmdp(fd, ": _ BLK( >A 1024 >R BEGIN AC@+ .x NEXT ;"); int returncode = 0; for (int i=startat; i 0) close(fd); return returncode; }