diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/extract.c | 15 | ||||
| -rw-r--r-- | src/unalf.1 | 14 | ||||
| -rw-r--r-- | src/unalf.c | 2 | ||||
| -rw-r--r-- | src/unalf.h | 1 | ||||
| -rw-r--r-- | src/unalf.rst | 10 |
5 files changed, 37 insertions, 5 deletions
diff --git a/src/extract.c b/src/extract.c index 31559cf..9c45941 100644 --- a/src/extract.c +++ b/src/extract.c @@ -7,6 +7,7 @@ #include "unalf.h" #include "addrs.h" +int bad_checksum, bad_checksum_count = 0; char *out_filename; void dpoke(int addr, u16 value) { @@ -87,15 +88,27 @@ void extract_alf(void) { out_filename = realname; } + bad_checksum = 0; uncrunch_file(); + if(bad_checksum) bad_checksum_count++; if(!opts.extract_to_stdout) fclose(out_file); out_filename = 0; } + + if(opts.testonly && !opts.quiet) { + if(bad_checksum_count) + printf("%d file%s with bad checksum!\n", + bad_checksum_count, + bad_checksum_count == 1 ? "" : "s"); + else + printf("All files OK.\n"); + } } static void chksum_err(void) { - fprintf(stderr, "%s: checksum error on file %s\n", self, out_filename); + bad_checksum = 1; + fprintf(stderr, "%s: checksum error on %s\n", self, out_filename); } void uncrunch_file(void) { diff --git a/src/unalf.1 b/src/unalf.1 index bf9c141..d3ca220 100644 --- a/src/unalf.1 +++ b/src/unalf.1 @@ -205,8 +205,18 @@ unalf filename.alf \(aq*.txt\(aq .UNINDENT .UNINDENT .SH EXIT STATUS -.sp -\fB0\fP for success, \fB1\fP for failure. +.INDENT 0.0 +.TP +.B 0 +Success. +.TP +.B 1 +Fatal error (I/O or bad command\-line arguments). +.TP +.B 2 +Processing completed OK, but at least one file in the archive +has a bad checksum. +.UNINDENT .SH DIAGNOSTICS .sp Besides the standard error messages such as "no such file or directory": diff --git a/src/unalf.c b/src/unalf.c index d4b5aa0..af21aa9 100644 --- a/src/unalf.c +++ b/src/unalf.c @@ -82,5 +82,5 @@ int main(int argc, char **argv) { else extract_alf(); - exit(0); + exit(bad_checksum_count ? 2 : 0); } diff --git a/src/unalf.h b/src/unalf.h index 030f6f2..40a23d1 100644 --- a/src/unalf.h +++ b/src/unalf.h @@ -39,6 +39,7 @@ void list_alf(void); unsigned int getquad(int offs); /* extract.c */ +extern int bad_checksum_count; void extract_alf(void); void dpoke(int addr, u16 value); u16 dpeek(int addr); diff --git a/src/unalf.rst b/src/unalf.rst index bcb1c8a..e5d8dc7 100644 --- a/src/unalf.rst +++ b/src/unalf.rst @@ -165,7 +165,15 @@ Example:: EXIT STATUS =========== -**0** for success, **1** for failure. +0 + Success. + +1 + Fatal error (I/O or bad command-line arguments). + +2 + Processing completed OK, but at least one file in the archive + has a bad checksum. DIAGNOSTICS =========== |
