aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--blob2xex.117
-rw-r--r--blob2xex.c19
-rw-r--r--blob2xex.rst15
3 files changed, 44 insertions, 7 deletions
diff --git a/blob2xex.1 b/blob2xex.1
index 831519f..cf118b1 100644
--- a/blob2xex.1
+++ b/blob2xex.1
@@ -36,7 +36,7 @@ blob2xex \- Create Atari 8-bit executables from arbitrary data
.
.SH SYNOPSIS
.sp
-blob2xex \fIoutfile\fP [\fB\-r\fP \fIrunaddr\fP] [\fB\-l\fP \fIloadaddr\fP [\fB\-i\fP \fIinitaddr\fP] [\fB\-o\fP \fIoffset\fP] [\fB\-s\fP \fIsize\fP] \fIinfile\fP] ...
+blob2xex \fIoutfile\fP [\fB\-v\fP] [\fB\-r\fP \fIrunaddr\fP] [\fB\-l\fP \fIloadaddr\fP [\fB\-i\fP \fIinitaddr\fP] [\fB\-o\fP \fIoffset\fP] [\fB\-s\fP \fIsize\fP] \fIinfile\fP] ...
.SH DESCRIPTION
.sp
\fBblob2xex\fP creates an Atari 8\-bit binary load (xex) file from one or
@@ -50,7 +50,9 @@ input file. To read from standard input, use \fB\-\fP for the \fIinfile\fP\&.
\fIoutfile\fP must be given as the first argument. When multiple
input files are used, the resulting .xex file will have multiple
segments. If \fIoutfile\fP already exists, it will be overwritten. Use
-\fB\-\fP to write to standard output.
+\fB\-\fP to write to standard output. If \fIoutfile\fP is a filename that
+begins with a \fB\-\fP, prefix it with "./", otherwise it\(aqll be taken as
+an option.
.sp
Addresses, offsets, and sizes may be given in decimal or hex. Hex
addresses must be prefixed with either \fB$\fP or \fB0x\fP\&.
@@ -78,6 +80,17 @@ Optional; skip this many bytes of the next input file. Default is \fB0\fP\&.
Optional; read this many bytes of the next input file. Default is the entire file,
or \fB0xffff\fP (\fB65535\fP) if the file is longer than 64KB.
.UNINDENT
+.INDENT 0.0
+.TP
+.B \-v
+Verbose output.
+.TP
+.B \-h\fP,\fB \-\-help
+Print usage message and exit.
+.TP
+.B \-V\fP,\fB \-\-version
+Print version number and exit.
+.UNINDENT
.SH EXAMPLES
.sp
TODO: come up with a few examples.
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();
diff --git a/blob2xex.rst b/blob2xex.rst
index cf5bf10..18ebd6e 100644
--- a/blob2xex.rst
+++ b/blob2xex.rst
@@ -14,7 +14,7 @@ Create Atari 8-bit executables from arbitrary data
SYNOPSIS
========
-blob2xex *outfile* [**-r** *runaddr*] [**-l** *loadaddr* [**-i** *initaddr*] [**-o** *offset*] [**-s** *size*] *infile*] ...
+blob2xex *outfile* [**-v**] [**-r** *runaddr*] [**-l** *loadaddr* [**-i** *initaddr*] [**-o** *offset*] [**-s** *size*] *infile*] ...
DESCRIPTION
===========
@@ -30,7 +30,9 @@ input file. To read from standard input, use **-** for the *infile*.
*outfile* must be given as the first argument. When multiple
input files are used, the resulting .xex file will have multiple
segments. If *outfile* already exists, it will be overwritten. Use
-**-** to write to standard output.
+**-** to write to standard output. If *outfile* is a filename that
+begins with a **-**, prefix it with "./", otherwise it'll be taken as
+an option.
Addresses, offsets, and sizes may be given in decimal or hex. Hex
addresses must be prefixed with either **$** or **0x**.
@@ -59,6 +61,15 @@ not **-l0x2000**.
Optional; read this many bytes of the next input file. Default is the entire file,
or **0xffff** (**65535**) if the file is longer than 64KB.
+-v
+ Verbose output.
+
+-h, --help
+ Print usage message and exit.
+
+-V, --version
+ Print version number and exit.
+
EXAMPLES
========