mirror of
https://github.com/sheumann/65816-crypto.git
synced 2024-11-22 07:31:58 +00:00
Display error messages where appropriate in checksum utilities.
This commit is contained in:
parent
b5b268982a
commit
0475dbf132
@ -38,12 +38,16 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
if (argc != 2)
|
if (argc != 2) {
|
||||||
|
fprintf(stderr, "Usage: %s filename\n", argv[0]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
file = fopen(argv[1], "rb");
|
file = fopen(argv[1], "rb");
|
||||||
if (file == NULL)
|
if (file == NULL) {
|
||||||
|
perror(argv[1]);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
concat(HASH_FUNCTION,_init)(&ctx);
|
concat(HASH_FUNCTION,_init)(&ctx);
|
||||||
do {
|
do {
|
||||||
@ -56,6 +60,10 @@ int main(int argc, char **argv) {
|
|||||||
concat(HASH_FUNCTION,_update)(&ctx, buf, count);
|
concat(HASH_FUNCTION,_update)(&ctx, buf, count);
|
||||||
} while (count != 0);
|
} while (count != 0);
|
||||||
|
|
||||||
|
if (ferror(file)) {
|
||||||
|
fprintf(stderr, "Error reading file\n");
|
||||||
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
concat(HASH_FUNCTION,_finalize)(&ctx);
|
concat(HASH_FUNCTION,_finalize)(&ctx);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user