use stderr for info/error messages
This commit is contained in:
parent
4067da453e
commit
389613d56e
2 changed files with 28 additions and 26 deletions
19
exhal.c
19
exhal.c
|
@ -17,9 +17,10 @@ int main (int argc, char **argv) {
|
|||
printf("exhal - " __DATE__ " " __TIME__"\nby Devin Acker (Revenant)\n\n");
|
||||
|
||||
if (argc != 4) {
|
||||
printf("Usage:\n%s romfile offset outfile\n", argv[0]);
|
||||
printf("Example: %s kirbybowl.sfc 0x70000 test.bin\n\n", argv[0]);
|
||||
printf("offset can be in either decimal or hex.\n");
|
||||
fprintf(stderr, "Usage:\n%s romfile offset outfile\n"
|
||||
"Example: %s kirbybowl.sfc 0x70000 test.bin\n\n"
|
||||
"offset can be in either decimal or hex.\n",
|
||||
argv[0], argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -28,14 +29,14 @@ int main (int argc, char **argv) {
|
|||
// open ROM file for input
|
||||
infile = fopen(argv[1], "rb");
|
||||
if (!infile) {
|
||||
printf("Error: unable to open %s\n", argv[1]);
|
||||
fprintf(stderr, "Error: unable to open %s\n", argv[1]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// open target file for output
|
||||
outfile = fopen(argv[3], "wb");
|
||||
if (!outfile) {
|
||||
printf("Error: unable to open %s\n", argv[1]);
|
||||
fprintf(stderr, "Error: unable to open %s\n", argv[3]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -49,8 +50,8 @@ int main (int argc, char **argv) {
|
|||
if (fileoffset < ftell(infile)) {
|
||||
outputsize = unpack_from_file(infile, fileoffset, unpacked);
|
||||
} else {
|
||||
printf("Error: Unable to decompress %s because an invalid offset was specified\n"
|
||||
" (must be between zero and 0x%X).\n", argv[1], ftell(infile));
|
||||
fprintf(stderr, "Error: Unable to decompress %s because an invalid offset was specified\n"
|
||||
" (must be between zero and 0x%X).\n", argv[1], ftell(infile));
|
||||
outputsize = 0;
|
||||
}
|
||||
|
||||
|
@ -65,8 +66,8 @@ int main (int argc, char **argv) {
|
|||
|
||||
printf("Uncompressed size: %zu bytes\n", outputsize);
|
||||
} else {
|
||||
printf("Error: Unable to decompress %s because the output would have been larger than\n"
|
||||
" 64 kb. The input at 0x%X is likely not valid compressed data.\n", argv[1], fileoffset);
|
||||
fprintf(stderr, "Error: Unable to decompress %s because the output would have been larger than\n"
|
||||
" 64 kb. The input at 0x%X is likely not valid compressed data.\n", argv[1], fileoffset);
|
||||
}
|
||||
|
||||
fclose(infile);
|
||||
|
|
35
inhal.c
35
inhal.c
|
@ -19,17 +19,18 @@ int main (int argc, char **argv) {
|
|||
printf("inhal - " __DATE__ " " __TIME__"\nby Devin Acker (Revenant)\n\n");
|
||||
|
||||
if (argc < 4) {
|
||||
printf("To insert compressed data into a ROM:\n");
|
||||
printf("%s [-fast] infile romfile offset\n", argv[0]);
|
||||
fprintf(stderr, "To insert compressed data into a ROM:\n"
|
||||
"%s [-fast] infile romfile offset\n"
|
||||
|
||||
"To write compressed data to a new file:\n"
|
||||
"%s [-fast] -n infile outfile\n\n"
|
||||
|
||||
"Running with the -fast switch increases compression speed at the expense of size.\n"
|
||||
|
||||
printf("To write compressed data to a new file:\n");
|
||||
printf("%s [-fast] -n infile outfile\n\n", argv[0]);
|
||||
|
||||
printf("Running with the -fast switch increases compression speed at the expense of size.\n");
|
||||
|
||||
printf("\nExample:\n%s -fast test.chr kirbybowl.sfc 0x70000\n", argv[0]);
|
||||
printf("%s -n test.chr test-packed.bin\n\n", argv[0]);
|
||||
printf("offset can be in either decimal or hex.\n");
|
||||
"\nExample:\n%s -fast test.chr kirbybowl.sfc 0x70000\n"
|
||||
"%s -n test.chr test-packed.bin\n\n"
|
||||
"offset can be in either decimal or hex.\n",
|
||||
argv[0], argv[0], argv[0], argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -60,11 +61,11 @@ int main (int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (!infile) {
|
||||
printf("Error: unable to open input file\n");
|
||||
fprintf(stderr, "Error: unable to open input file\n");
|
||||
exit(-1);
|
||||
}
|
||||
if (!outfile) {
|
||||
printf("Error: unable to open output file\n");
|
||||
fprintf(stderr, "Error: unable to open output file\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -76,13 +77,13 @@ int main (int argc, char **argv) {
|
|||
fseek(infile, 0, SEEK_END);
|
||||
inputsize = ftell(infile);
|
||||
|
||||
printf("Uncompressed size: %zd bytes\n", inputsize);
|
||||
printf("Uncompressed size: %zd bytes\n", inputsize);
|
||||
|
||||
if (inputsize > DATA_SIZE) {
|
||||
printf("Error: File must be a maximum of 65,536 bytes!\n");
|
||||
fprintf(stderr, "Error: File must be a maximum of 65,536 bytes!\n");
|
||||
exit(-1);
|
||||
} else if (!inputsize) {
|
||||
printf("Error: Input file is empty!\n");
|
||||
fprintf(stderr, "Error: Input file is empty!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
@ -114,8 +115,8 @@ int main (int argc, char **argv) {
|
|||
|
||||
printf("Inserted at 0x%06X - 0x%06lX\n", fileoffset, ftell(outfile) - 1);
|
||||
} else {
|
||||
printf("Error: File could not be compressed because the resulting compressed data would\n"
|
||||
" have been larger than 64 kb.\n");
|
||||
fprintf(stderr, "Error: File could not be compressed because the resulting compressed data would\n"
|
||||
" have been larger than 64 kb.\n");
|
||||
}
|
||||
|
||||
fclose(infile);
|
||||
|
|
Loading…
Reference in a new issue