aboutsummaryrefslogtreecommitdiff
path: root/unprotbas.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-05-19 14:26:16 -0400
committerB. Watson <urchlay@slackware.uk>2024-05-19 14:26:16 -0400
commita076240e441bf4b7e7f4f29cbfbb9fb2d3336c09 (patch)
treeb967a6b5118803abba9f6e5afc9a79d69ba0f147 /unprotbas.c
parentbbffe594b2f9a42bd98e4e9de6dae65a2008e54e (diff)
downloadbw-atari8-tools-a076240e441bf4b7e7f4f29cbfbb9fb2d3336c09.tar.gz
unprotbas: implement -v option, fix doc about line 32768.
Diffstat (limited to 'unprotbas.c')
-rw-r--r--unprotbas.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/unprotbas.c b/unprotbas.c
index 02263ca..0b11e0e 100644
--- a/unprotbas.c
+++ b/unprotbas.c
@@ -58,7 +58,7 @@ void die(const char *msg) {
/* read entire file into memory */
int readfile(void) {
int got = fread(data, 1, 65535, input_file);
- fprintf(stderr, "read %d bytes\n", got);
+ if(verbose) fprintf(stderr, "read %d bytes\n", got);
fclose(input_file);
return got;
}
@@ -90,7 +90,7 @@ void read_header(void) {
codestart = stmtab - STM_OFFSET - (vntp - 256);
vnstart = vntp - 256 + 14;
vvstart = vvtp - 256 + 14;
- dump_header_vars();
+ if(verbose) dump_header_vars();
}
void set_header_vars(void) {
@@ -167,7 +167,7 @@ int fixcode(void) {
offset = data[pos + 2];
/* fprintf(stderr, "pos %d, line #%d, offset %d\n", pos, lineno, offset); */
if(offset < 6) {
- fprintf(stderr, "Found invalid offset %d (<6) at line %d\n", offset, lineno);
+ if(verbose) fprintf(stderr, "Found invalid offset %d (<6) at line %d\n", offset, lineno);
offset += fixline(pos);
result++;
}
@@ -178,10 +178,10 @@ int fixcode(void) {
if(lineno == 32768) break;
}
- fprintf(stderr, "End program pos $%04x/%d\n", pos, pos);
+ if(verbose) fprintf(stderr, "End program pos $%04x/%d\n", pos, pos);
if(filelen > pos) {
- fprintf(stderr, "trailing garbage at EOF, %d bytes, %s\n",
+ if(verbose) fprintf(stderr, "trailing garbage at EOF, %d bytes, %s\n",
filelen - pos, (keepgarbage ? "keeping" : "removing"));
if(!keepgarbage) filelen = pos;
}
@@ -233,7 +233,7 @@ int vntable_ok(void) {
int vp, bad;
if(vntp == vntd) {
- fprintf(stderr, "No variables\n");
+ if(verbose) fprintf(stderr, "No variables\n");
return 1;
}
@@ -345,7 +345,7 @@ void adjust_vntable_size(int oldsize, int newsize) {
int move_by;
if(oldsize != newsize) {
move_by = newsize - oldsize;
- fprintf(stderr, "need %d bytes for vntable, have %d, moving VVTP by %d to %04x\n",
+ if(verbose) fprintf(stderr, "need %d bytes for vntable, have %d, moving VVTP by %d to %04x\n",
newsize, oldsize, move_by, vvtp + move_by);
move_code(move_by);
}
@@ -473,26 +473,28 @@ int main(int argc, char **argv) {
if(!keepvars) {
if(fixvars()) {
was_protected = 1;
- fprintf(stderr, "Variable names replaced\n");
+ if(verbose) fprintf(stderr, "Variable names replaced\n");
} else {
- fprintf(stderr, "Variable names were already OK\n");
+ if(verbose) fprintf(stderr, "Variable names were already OK\n");
}
}
if(fixcode()) {
- fprintf(stderr, "Fixed invalid offset in code\n");
+ if(verbose) fprintf(stderr, "Fixed invalid offset in code\n");
was_protected = 1;
} else {
- fprintf(stderr, "No invalid offsets\n");
+ if(verbose) fprintf(stderr, "No invalid offsets\n");
}
- if(was_protected)
- fprintf(stderr, "Program was protected.\n");
- else
- fprintf(stderr, "Program was NOT protected.\n");
+ if(verbose) {
+ if(was_protected)
+ fprintf(stderr, "Program was protected.\n");
+ else
+ fprintf(stderr, "Program was NOT protected.\n");
+ }
if(checkonly) {
- fprintf(stderr, "Check-only mode; no output written.\n");
+ if(verbose) fprintf(stderr, "Check-only mode; no output written.\n");
if(was_protected)
return 0;
else
@@ -501,7 +503,7 @@ int main(int argc, char **argv) {
int got = fwrite(data, 1, filelen, output_file);
fclose(output_file);
- fprintf(stderr, "wrote %d bytes\n", got);
+ if(verbose) fprintf(stderr, "wrote %d bytes\n", got);
return 0;
}