Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/cksum Some changes to cksum:



details:   https://anonhg.NetBSD.org/src/rev/4dc5ea53a067
branches:  trunk
changeset: 583756:4dc5ea53a067
user:      elad <elad%NetBSD.org@localhost>
date:      Sun Aug 21 18:51:44 2005 +0000

description:
Some changes to cksum:

1. Deprecate the -1, -2, -4, -5, -6, and -m flags. For now, simply remove
   them from the documentation.

2. Add and document ``-a algorithm''.

diffstat:

 usr.bin/cksum/cksum.1 |  33 +++++++++++++++------------------
 usr.bin/cksum/cksum.c |  37 +++++++++++++++++++++++++++++++++----
 2 files changed, 48 insertions(+), 22 deletions(-)

diffs (127 lines):

diff -r ef7c97f8ca76 -r 4dc5ea53a067 usr.bin/cksum/cksum.1
--- a/usr.bin/cksum/cksum.1     Sun Aug 21 18:35:26 2005 +0000
+++ b/usr.bin/cksum/cksum.1     Sun Aug 21 18:51:44 2005 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: cksum.1,v 1.25 2004/07/09 11:47:59 wiz Exp $
+.\"    $NetBSD: cksum.1,v 1.26 2005/08/21 18:51:44 elad Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"    @(#)cksum.1     8.2 (Berkeley) 4/28/95
 .\"
-.Dd July 9, 2004
+.Dd August 21, 2005
 .Dt CKSUM 1
 .Os
 .Sh NAME
@@ -48,12 +48,7 @@
 .Nm
 .Op Fl n
 .Oo
-.Fl m |
-.Fl 1 |
-.Fl 2 |
-.Fl 4 |
-.Fl 5 |
-.Fl 6 |
+.Fl a Ar algorithm |
 .Op Fl o Ar 1 | Ar 2
 .Oc
 .Op Ar
@@ -159,16 +154,18 @@
 .Pp
 The options are as follows:
 .Bl -tag -width indent
-.It Fl 1
-Use the SHA1 algorithm rather than the default one.
-.It Fl 2
-Use the MD2 algorithm rather than the default one.
-.It Fl 4
-Use the MD4 algorithm rather than the default one.
-.It Fl m | 5
-Use the MD5 algorithm rather than the default one.
-.It Fl 6
-Use the RMD160 algorithm rather than the default one.
+.It Fl a Ar algorithm
+When invoked as
+.Nm cksum ,
+use the specified
+.Pa algorithm .
+Valid algorithms are MD2, MD4, MD5, SHA1, RMD160, CRC, old1, and old2.
+Old1 and old2 are equal to
+.Fl o Ar 1
+and
+.Fl o Ar 2 ,
+respectively.
+The default is CRC.
 .It Fl o
 Use historic algorithms instead of the (superior) default one.
 .Pp
diff -r ef7c97f8ca76 -r 4dc5ea53a067 usr.bin/cksum/cksum.c
--- a/usr.bin/cksum/cksum.c     Sun Aug 21 18:35:26 2005 +0000
+++ b/usr.bin/cksum/cksum.c     Sun Aug 21 18:51:44 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cksum.c,v 1.24 2005/02/05 00:13:34 simonb Exp $        */
+/*     $NetBSD: cksum.c,v 1.25 2005/08/21 18:51:44 elad Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)cksum.c    8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: cksum.c,v 1.24 2005/02/05 00:13:34 simonb Exp $");
+__RCSID("$NetBSD: cksum.c,v 1.25 2005/08/21 18:51:44 elad Exp $");
 #endif /* not lint */
 
 #include <sys/cdefs.h>
@@ -153,7 +153,7 @@
        int (*cfncn) (int, u_int32_t *, off_t *);
        void (*pfncn) (char *, u_int32_t, off_t);
        struct hash *hash;
-       int normal;
+       int normal, i;
 
        cfncn = NULL;
        pfncn = NULL;
@@ -181,8 +181,37 @@
                }
        }
 
-       while ((ch = getopt(argc, argv, "mno:ps:tx12456")) != -1)
+       while ((ch = getopt(argc, argv, "a:mno:ps:tx12456")) != -1)
                switch(ch) {
+               case 'a':
+                       if (hash != NULL || dosum) {
+                               warnx("illegal use of -a option\n");
+                               usage();
+                       }
+                       i = 0;
+                       while (hashes[i].hashname != NULL) {
+                               if (!strcasecmp(hashes[i].hashname, optarg)) {
+                                       hash = &hashes[i];
+                                       break;
+                               }
+                               i++;
+                       }
+                       if (hash == NULL) {
+                               if (!strcasecmp(optarg, "old1")) {
+                                       cfncn = csum1;
+                                       pfncn = psum1;
+                               } else if (!strcasecmp(optarg, "old2")) {
+                                       cfncn = csum2;
+                                       pfncn = psum2;
+                               } else if (!strcasecmp(optarg, "crc")) {
+                                       cfncn = crc;
+                                       pfncn = pcrc;
+                               } else {
+                                       warnx("illegal argument to -a option");
+                                       usage();
+                               }
+                       }
+                       break;
                case '2':
                        if (dosum) {
                                warnx("sum mutually exclusive with md2");



Home | Main Index | Thread Index | Old Index