diff options
author | B. Watson <urchlay@slackware.uk> | 2024-04-26 04:04:37 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-04-26 04:04:37 -0400 |
commit | 1165045c943202c6bb96ff9b372e95ac1aeeaac2 (patch) | |
tree | f6415b2813e53241ca367861cd12cc5d0cec635b /xexsplit.c | |
parent | 1f392bcd89563c0582dcd2853115cf4165404d8d (diff) | |
download | bw-atari8-tools-1165045c943202c6bb96ff9b372e95ac1aeeaac2.tar.gz |
xexsplit: add -r (raw output) option.
Diffstat (limited to 'xexsplit.c')
-rw-r--r-- | xexsplit.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -11,7 +11,7 @@ #endif #define SELF "xexsplit" -#define OPTIONS "hv" +#define OPTIONS "hvr" char *usage = SELF " v" VERSION " by B. Watson (WTFPL)\n" @@ -27,12 +27,16 @@ int main(int argc, char **argv) { char outfile[4096]; unsigned char buffer[65536]; FILE *out = NULL; - int count = 1, outlen, c; + int count = 1, outlen, c, raw_output = 0; strcpy(outfile, "xexsplit"); while( (c = getopt(argc, argv, OPTIONS)) > 0) { switch(c) { + case 'r': + raw_output = 1; + break; + case 'h': printf(usage); exit(0); @@ -86,8 +90,9 @@ int main(int argc, char **argv) { seg.has_ff_header = 1; sprintf(outfile + outlen, - ".%03d.%04X.%04X", - count, seg.start_addr, seg.end_addr); + ".%03d.%04X.%04X.%s", + count, seg.start_addr, seg.end_addr, + (raw_output ? "bin" : "xex")); if( !(out = fopen(outfile, "wb")) ) { fprintf(stderr, SELF ": %s: %s\n", outfile, strerror(errno)); @@ -95,8 +100,13 @@ int main(int argc, char **argv) { exit(1); } - if(!xex_fwrite_seg(&seg, out)) - break; + if(raw_output) { + if(fwrite(seg.object, seg.len, 1, out) < 1) + break; + } else { + if(!xex_fwrite_seg(&seg, out)) + break; + } fclose(out); out = NULL; |