/*
* Copyright (C) 2003 Glenn L. McGrath
- * Copyright (C) 2003 Erik Andersen
- *
+ * Copyright (C) 2003-2004 Erik Andersen
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
#define FLAG_CHECK 2
#define FLAG_WARN 4
-/* This might be usefull elsewhere */
+/* This might be useful elsewhere */
static unsigned char *hash_bin_to_hex(unsigned char *hash_value,
unsigned char hash_length)
{
int src_fd;
if (strcmp(filename, "-") == 0) {
- src_fd = fileno(stdin);
+ src_fd = STDIN_FILENO;
} else {
src_fd = open(filename, O_RDONLY);
}
hash_value = hash_file(filename_ptr, hash_algo);
if (hash_value && (strcmp(hash_value, line) == 0)) {
- printf("%s: OK\n", filename_ptr);
+ if (!(flags & FLAG_SILENT))
+ printf("%s: OK\n", filename_ptr);
} else {
- printf("%s: FAILED\n", filename_ptr);
+ if (!(flags & FLAG_SILENT))
+ printf("%s: FAILED\n", filename_ptr);
count_failed++;
+ return_value = EXIT_FAILURE;
}
/* possible free(NULL) */
free(hash_value);
free(line);
}
- if (count_failed) {
+ if (count_failed && !(flags & FLAG_SILENT)) {
bb_error_msg("WARNING: %d of %d computed checksums did NOT match",
count_failed, count_total);
}
hash_value = hash_file(file_ptr, hash_algo);
if (hash_value == NULL) {
- return_value++;
+ return_value = EXIT_FAILURE;
} else {
-#ifdef CONFIG_FEATURE_MD5_SHA1_SUM_CHECK
- if (!flags & FLAG_SILENT)
-#endif
- printf("%s %s\n", hash_value, file_ptr);
+ printf("%s %s\n", hash_value, file_ptr);
free(hash_value);
}
}