aboutsummaryrefslogtreecommitdiff
path: root/blob2xex.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-04-24 15:18:53 -0400
committerB. Watson <urchlay@slackware.uk>2024-04-24 15:18:53 -0400
commit3286d83fb8ddbcbbcde3adca2b41dbb3339daa02 (patch)
tree5013babab1682800127fa029a3222097beae2d21 /blob2xex.c
parent8ca7c68e9e3baa4c0d17ffeaaee84ff351c104eb (diff)
downloadbw-atari8-tools-3286d83fb8ddbcbbcde3adca2b41dbb3339daa02.tar.gz
blob2xex: add -v -h/--help -V/--version options.
Diffstat (limited to 'blob2xex.c')
-rw-r--r--blob2xex.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/blob2xex.c b/blob2xex.c
index fb339e7..9740e45 100644
--- a/blob2xex.c
+++ b/blob2xex.c
@@ -121,7 +121,21 @@ int main(int argc, char **argv) {
char *outfile = 0, *infile = 0;
int i, loadaddr = -1, runaddr = -1, initaddr = -1, offset = 0, size = DEFAULT_SIZE, *param = 0;
- xex_verbose = 1;
+ outfile = argv[1];
+ if(!outfile || strcmp(outfile, "--help") == 0 || strcmp(outfile, "-h") == 0) {
+ usage();
+ exit(0);
+ }
+
+ if(strcmp(outfile, "--version") == 0 || strcmp(outfile, "-V") == 0) {
+ printf(SELF " " VERSION "\n");
+ exit(0);
+ }
+
+ if(outfile[0] == '-' && outfile[1] != '\0') {
+ fprintf(stderr, SELF ": output file must come before any options.\n");
+ exit(1);
+ }
if(argc < 5) {
fprintf(stderr, SELF ": not enough arguments.\n");
@@ -129,8 +143,6 @@ int main(int argc, char **argv) {
exit(1);
}
- outfile = argv[1];
-
for(i = 2; i < argc; i++) {
char *arg = argv[i];
@@ -153,6 +165,7 @@ int main(int argc, char **argv) {
case 'i': param = &initaddr; break;
case 'o': param = &offset; break;
case 's': param = &size; break;
+ case 'v': xex_verbose = 1; break;
default:
fprintf(stderr, SELF ": unknown option '-%c'\n", arg[1]);
usage();