diff options
author | obrien <obrien@FreeBSD.org> | 1999-11-07 04:14:55 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 1999-11-07 04:14:55 +0000 |
commit | 9c150e9d7eeabe6cf2b7ef09b05b30dc27e36190 (patch) | |
tree | f92e92029bef3e465e4ac6c5a78269b2f537aa34 /sbin | |
parent | ec94780e1f754632e93e589e97b834ada49b0a5f (diff) | |
download | FreeBSD-src-9c150e9d7eeabe6cf2b7ef09b05b30dc27e36190.zip FreeBSD-src-9c150e9d7eeabe6cf2b7ef09b05b30dc27e36190.tar.gz |
Add a new "-r" (right) option that reverses the order a filename and the
hash is printed. This aids visual diffs.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/md5/md5.1 | 8 | ||||
-rw-r--r-- | sbin/md5/md5.c | 18 |
2 files changed, 22 insertions, 4 deletions
diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1 index 7fb415f..5bf3fc6 100644 --- a/sbin/md5/md5.1 +++ b/sbin/md5/md5.1 @@ -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 diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c index bd1fd6d..4a3daac 100644 --- a/sbin/md5/md5.c +++ b/sbin/md5/md5.c @@ -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. |