From 2da7ac8b7bd573d5cb24e83f4f308837630e9e78 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 25 Feb 2025 07:30:05 -0500 Subject: listamsb: add -c (check only) option. --- listamsb.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'listamsb.c') diff --git a/listamsb.c b/listamsb.c index efa0621..5d9b425 100644 --- a/listamsb.c +++ b/listamsb.c @@ -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 , 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"); -- cgit v1.2.3