aboutsummaryrefslogtreecommitdiff
path: root/sbin/md5/md5.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>1995-02-26 01:55:31 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>1995-02-26 01:55:31 +0000
commit23b406e176386f62cef07ec8c3dd5fae9b640dff (patch)
treea8d1828d78842cd2c8b968980aac3412735624f7 /sbin/md5/md5.c
parent671e2cee9740bae9ecd45ce92260b0ee8f44a8e8 (diff)
downloadsrc-23b406e176386f62cef07ec8c3dd5fae9b640dff.tar.gz
src-23b406e176386f62cef07ec8c3dd5fae9b640dff.zip
Add a '-p' option to md5. This will save some time in generation of the
ctm deltas.
Notes
Notes: svn path=/head/; revision=6725
Diffstat (limited to 'sbin/md5/md5.c')
-rw-r--r--sbin/md5/md5.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c
index afa8ef84aa48..72af3ebb9e0c 100644
--- a/sbin/md5/md5.c
+++ b/sbin/md5/md5.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: md5.c,v 1.2 1995/02/20 00:48:50 phk Exp $
*
* Derived from:
*/
@@ -36,7 +36,7 @@
static void MDString PROTO_LIST((char *));
static void MDTimeTrial PROTO_LIST((void));
static void MDTestSuite PROTO_LIST((void));
-static void MDFilter PROTO_LIST((void));
+static void MDFilter PROTO_LIST((int));
/* Main driver.
@@ -61,6 +61,8 @@ main(argc, argv)
MDString(argv[i] + 2);
else if (strcmp(argv[i], "-t") == 0)
MDTimeTrial();
+ else if (strcmp(argv[i], "-p") == 0)
+ MDFilter(1);
else if (strcmp(argv[i], "-x") == 0)
MDTestSuite();
else {
@@ -71,7 +73,7 @@ main(argc, argv)
printf("MD5 (%s) = %s\n", argv[i], p);
}
else
- MDFilter();
+ MDFilter(0);
return (0);
}
@@ -94,7 +96,7 @@ MDTimeTrial()
{
MD5_CTX context;
time_t endTime, startTime;
- unsigned char block[TEST_BLOCK_LEN], digest[16];
+ unsigned char block[TEST_BLOCK_LEN];
unsigned int i;
char *p;
@@ -151,14 +153,17 @@ MDTestSuite()
* Digests the standard input and prints the result.
*/
static void
-MDFilter()
+MDFilter(int pipe)
{
MD5_CTX context;
int len;
unsigned char buffer[BUFSIZ], digest[16];
MD5Init(&context);
- while (len = fread(buffer, 1, BUFSIZ, stdin))
+ while (len = fread(buffer, 1, BUFSIZ, stdin)) {
+ if(pipe && (len != fwrite(buffer, 1, len, stdout)))
+ perror(stdout);
MD5Update(&context, buffer, len);
+ }
printf("%s\n", MD5End(&context));
}