diff options
author | B. Watson <urchlay@slackware.uk> | 2025-02-25 07:30:05 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2025-02-25 07:30:05 -0500 |
commit | 2da7ac8b7bd573d5cb24e83f4f308837630e9e78 (patch) | |
tree | 67b03121dbadb7b406f3774799a2786d74084230 /listamsb.c | |
parent | 1c075d559e69958af1964ad389393f496571d322 (diff) | |
download | bw-atari8-tools-2da7ac8b7bd573d5cb24e83f4f308837630e9e78.tar.gz |
listamsb: add -c (check only) option.
Diffstat (limited to 'listamsb.c')
-rw-r--r-- | listamsb.c | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -34,8 +34,9 @@ const char *self; char pipe_command[BUFSIZ + 1] = { "a8cat" }; -int verbose = 0; -int raw_output = 0; +int verbose = 0; /* -v */ +int raw_output = 0; /* -a */ +int check_only = 0; /* -c */ int need_pclose = 0; int bytes_read = 0; @@ -208,6 +209,7 @@ void print_help(void) { puts("By B. Watson <urchlay@slackware.uk>, released under the WTFPL"); printf("Usage: %s [-a] [-v] [-h] [-i] [-u] [-t] [-m] [-s] [file]\n", self); puts(" -a: raw ATASCII output"); + puts(" -c: check only (no listing)"); puts(" -v: verbose"); puts(" -h: show this help"); puts(" -i -u -t -m -s: passed to a8cat (try 'a8cat -h')"); @@ -218,8 +220,9 @@ void parse_args(int argc, char **argv) { char tmp[10]; int opt; - while( (opt = getopt(argc, argv, "vaiutmsh")) != -1) { + while( (opt = getopt(argc, argv, "cvaiutmsh")) != -1) { switch(opt) { + case 'c': check_only = 1; break; case 'a': raw_output = 1; break; case 'h': print_help(); exit(0); case 'v': verbose = 1; break; @@ -257,6 +260,14 @@ void parse_args(int argc, char **argv) { } void open_output() { + if(check_only) { + outfile = freopen("/dev/null", "wb", stdout); + if(!outfile) { + fprintf(stderr, "%s: ", self); + perror("/dev/null"); + exit(1); + } + } if(raw_output) { if(isatty(fileno(stdout))) die("refusing to write raw ATASCII to a terminal"); |