diff options
author | Jussi Pakkanen <jussi.pakkanen@canonical.com> | 2011-06-28 14:50:10 +0300 |
---|---|---|
committer | Jussi Pakkanen <jussi.pakkanen@canonical.com> | 2011-06-28 14:50:10 +0300 |
commit | 4b99c44b90aba3800246ed145270b53282a14e55 (patch) | |
tree | 91dde452f4b0b64b454af3af05481dfaece0070e | |
parent | 37990cf7bf93ea383d48e71f6c63925834418e23 (diff) |
Can set an output file on the command line.
-rw-r--r-- | tools/evemu-record.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/evemu-record.c b/tools/evemu-record.c index afdd400..1acb06f 100644 --- a/tools/evemu-record.c +++ b/tools/evemu-record.c @@ -51,8 +51,9 @@ int main(int argc, char *argv[]) { int fd; + FILE *out; if (argc < 2) { - fprintf(stderr, "Usage: %s <device>\n", argv[0]); + fprintf(stderr, "Usage: %s <device> [output file]\n", argv[0]); return -1; } fd = open(argv[1], O_RDONLY | O_NONBLOCK); @@ -60,9 +61,21 @@ int main(int argc, char *argv[]) fprintf(stderr, "error: could not open device\n"); return -1; } - if (evemu_record(stdout, fd, WAIT_MS)) { + + if (argc < 3) + out = stdout; + else { + out = fopen(argv[2], "w"); + if (!out) { + fprintf(stderr, "error: could not open output file"); + } + } + + if (evemu_record(out, fd, WAIT_MS)) { fprintf(stderr, "error: could not describe device\n"); } close(fd); + if (argc > 2) + fclose(out); return 0; } |