aboutsummaryrefslogtreecommitdiff
path: root/xexsplit.c
diff options
context:
space:
mode:
Diffstat (limited to 'xexsplit.c')
-rw-r--r--xexsplit.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/xexsplit.c b/xexsplit.c
index 4df51f3..c120ae6 100644
--- a/xexsplit.c
+++ b/xexsplit.c
@@ -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;