summaryrefslogtreecommitdiff
path: root/src/md5sum.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-07-26 04:11:21 +0000
committerJim Meyering <jim@meyering.net>1996-07-26 04:11:21 +0000
commit7ce576ff06f1ff29a490968244ee00769b11bba3 (patch)
tree8cd3574c24af0e08ae8faa6ad49ef0dac396b38a /src/md5sum.c
parent733c16465d9059d6b9e38d362af1729daeeb6e35 (diff)
downloadcoreutils-7ce576ff06f1ff29a490968244ee00769b11bba3.tar.xz
(md5_check): Remove parameter, BINARY.
Rename local TYPE_FLAG to BINARY, so md5_file uses the binary mode from the input stream rather than the one from the command line. (main): Fail with a diagnostic if --binary or --text is specified when verifying checksums. Reported by Eli Zaretskii <eliz@is.elta.co.il>.
Diffstat (limited to 'src/md5sum.c')
-rw-r--r--src/md5sum.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/md5sum.c b/src/md5sum.c
index daae484c7..cbc66a388 100644
--- a/src/md5sum.c
+++ b/src/md5sum.c
@@ -278,7 +278,7 @@ md5_file (const char *filename, int binary, unsigned char *md5_result)
}
static int
-md5_check (const char *checkfile_name, int binary)
+md5_check (const char *checkfile_name)
{
FILE *checkfile_stream;
int n_properly_formated_lines = 0;
@@ -311,7 +311,7 @@ md5_check (const char *checkfile_name, int binary)
do
{
char *filename;
- int type_flag;
+ int binary;
char *md5num;
int err;
int line_length;
@@ -330,7 +330,7 @@ md5_check (const char *checkfile_name, int binary)
if (line[line_length - 1] == '\n')
line[--line_length] = '\0';
- err = split_3 (line, line_length, &md5num, &type_flag, &filename);
+ err = split_3 (line, line_length, &md5num, &binary, &filename);
if (err || !hex_digits (md5num))
{
if (warn)
@@ -450,6 +450,7 @@ main (int argc, char **argv)
size_t n_strings = 0;
size_t i;
size_t err = 0;
+ int file_type_specified = 0;
/* Text is default of the Plumb/Lankester format. */
int binary = 0;
@@ -479,6 +480,7 @@ main (int argc, char **argv)
}
break;
case 'b':
+ file_type_specified = 1;
binary = 1;
break;
case 'c':
@@ -489,6 +491,7 @@ main (int argc, char **argv)
warn = 0;
break;
case 't':
+ file_type_specified = 1;
binary = 0;
break;
case 'w':
@@ -505,6 +508,13 @@ main (int argc, char **argv)
exit (EXIT_SUCCESS);
}
+ if (file_type_specified && do_check)
+ {
+ error (0, 0, _("the --binary and --text options are meaningless when \
+verifying checksums"));
+ usage (EXIT_FAILURE);
+ }
+
if (n_strings > 0 && do_check)
{
error (0, 0,
@@ -553,7 +563,7 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
- err = md5_check ((optind == argc) ? "-" : argv[optind], binary);
+ err = md5_check ((optind == argc) ? "-" : argv[optind]);
}
else
{