summaryrefslogtreecommitdiff
path: root/bmtoa.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-05 18:38:18 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-02-05 18:49:14 -0800
commita53f6c680d78e41e17e1b6af05d588f5d0083f2d (patch)
tree82f14fcc77d92757c41ebc2ac2fbd81fef1599b2 /bmtoa.c
parentda8af2618143577c36ba7fe7656bb6e296616438 (diff)
atobm, bmtoa, bitmap: Add -help and -version options
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'bmtoa.c')
-rw-r--r--bmtoa.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/bmtoa.c b/bmtoa.c
index a9de614..da5d0d2 100644
--- a/bmtoa.c
+++ b/bmtoa.c
@@ -54,13 +54,16 @@ static void print_scanline (unsigned int width, unsigned int height,
unsigned const char *data, const char *chars);
static void _X_NORETURN
-usage (void)
+usage (int exitval)
{
fprintf (stderr, "usage: %s [-options ...] [filename]\n\n%s\n",
ProgramName,
"where options include:\n"
- " -chars cc chars to use for 0 and 1 bits, respectively\n");
- exit (1);
+ " -chars cc chars to use for 0 and 1 bits, respectively\n"
+ " -help print this usage message\n"
+ " -version print version information\n"
+ );
+ exit (exitval);
}
static char *
@@ -133,14 +136,26 @@ main (int argc, char *argv[])
if (++i >= argc) {
fprintf(stderr, "%s: -chars requires an argument\n",
ProgramName);
- usage ();
+ usage(1);
}
chars = argv[i];
continue;
+ case 'h':
+ if (strcmp(arg, "-help") == 0) {
+ usage(0);
+ }
+ goto unknown;
+ case 'v':
+ if (strcmp(arg, "-version") == 0) {
+ puts(PACKAGE_STRING);
+ exit(0);
+ }
+ goto unknown;
default:
+ unknown:
fprintf(stderr, "%s: unrecognized option '%s'\n",
ProgramName, argv[i]);
- usage ();
+ usage(1);
}
} else {
filename = arg;