mirror of
https://git.FreeBSD.org/src.git
synced 2025-02-04 17:15:50 +00:00
Add a new "-r" (right) option that reverses the order a filename and the
hash is printed. This aids visual diffs.
This commit is contained in:
parent
b1d9984e17
commit
9e18a3bdd2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=52949
@ -1,3 +1,4 @@
|
||||
.\" $FreeBSD$
|
||||
.Dd February 14, 1994
|
||||
.Dt MD5 1
|
||||
.Os
|
||||
@ -6,7 +7,7 @@
|
||||
.Nd calculate a message-digest fingerprint (checksum) for a file
|
||||
.Sh SYNOPSIS
|
||||
.Nm md5
|
||||
.Op Fl ptx
|
||||
.Op Fl prtx
|
||||
.Op Fl s Ar string
|
||||
.Op Ar file ...
|
||||
.Sh DESCRIPTION
|
||||
@ -37,6 +38,11 @@ Print a checksum of the given
|
||||
.Ar string .
|
||||
.It Fl p
|
||||
Echo stdin to stdout and appends the MD5 sum to stdout.
|
||||
.It Fl r
|
||||
Reverses the format of the output. This helps with visual diffs. Does nothing
|
||||
when combined with the
|
||||
.Fl stpx
|
||||
options.
|
||||
.It Fl t
|
||||
Run a built-in time trial.
|
||||
.It Fl x
|
||||
|
@ -38,6 +38,8 @@ static const char rcsid[] =
|
||||
#define TEST_BLOCK_LEN 10000
|
||||
#define TEST_BLOCK_COUNT 100000
|
||||
|
||||
int rflag;
|
||||
|
||||
static void MDString PROTO_LIST((char *));
|
||||
static void MDTimeTrial PROTO_LIST((void));
|
||||
static void MDTestSuite PROTO_LIST((void));
|
||||
@ -63,11 +65,14 @@ main(argc, argv)
|
||||
char buf[33];
|
||||
|
||||
if (argc > 1) {
|
||||
while ((ch = getopt(argc, argv, "ps:tx")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "ps:rtx")) != -1) {
|
||||
switch (ch) {
|
||||
case 'p':
|
||||
MDFilter(1);
|
||||
break;
|
||||
case 'r':
|
||||
rflag = 1;
|
||||
break;
|
||||
case 's':
|
||||
MDString(optarg);
|
||||
break;
|
||||
@ -86,7 +91,11 @@ main(argc, argv)
|
||||
if (!p)
|
||||
warn("%s", argv[optind]);
|
||||
else
|
||||
printf("MD5 (%s) = %s\n", argv[optind], p);
|
||||
if (rflag)
|
||||
printf("MD5 %s %s\n", p, argv[optind]);
|
||||
else
|
||||
printf("MD5 (%s) = %s\n", argv[optind],
|
||||
p);
|
||||
optind++;
|
||||
}
|
||||
} else
|
||||
@ -104,7 +113,10 @@ MDString(string)
|
||||
size_t len = strlen(string);
|
||||
char buf[33];
|
||||
|
||||
printf("MD5 (\"%s\") = %s\n", string, MD5Data(string, len, buf));
|
||||
if (rflag)
|
||||
printf("MD5 %s (\"%s\")\n", MD5Data(string, len, buf), string);
|
||||
else
|
||||
printf("MD5 (\"%s\") = %s\n", string, MD5Data(string, len, buf));
|
||||
}
|
||||
/*
|
||||
* Measures the time to digest TEST_BLOCK_COUNT TEST_BLOCK_LEN-byte blocks.
|
||||
|
Loading…
x
Reference in New Issue
Block a user