aboutsummaryrefslogtreecommitdiff
path: root/blob2xex.c
diff options
context:
space:
mode:
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();