summaryrefslogtreecommitdiffstats
path: root/usr.bin/cksum
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1997-07-06 03:03:10 +0000
committerbde <bde@FreeBSD.org>1997-07-06 03:03:10 +0000
commit1576c35fbe706826e867129cb23898825893507c (patch)
tree0c3780cb5e37fcb0188d5123c71c3c61ff55a956 /usr.bin/cksum
parent532dea9042abf44b0a21290e3e3e16fba10a32f7 (diff)
downloadFreeBSD-src-1576c35fbe706826e867129cb23898825893507c.zip
FreeBSD-src-1576c35fbe706826e867129cb23898825893507c.tar.gz
Merge from Lite2 (make the command `sum' an alias for `cksum -o 1', and
reject -o args other than "1" or "2").
Diffstat (limited to 'usr.bin/cksum')
-rw-r--r--usr.bin/cksum/cksum.120
-rw-r--r--usr.bin/cksum/cksum.c31
2 files changed, 37 insertions, 14 deletions
diff --git a/usr.bin/cksum/cksum.1 b/usr.bin/cksum/cksum.1
index a88b905..c94fceb 100644
--- a/usr.bin/cksum/cksum.1
+++ b/usr.bin/cksum/cksum.1
@@ -32,8 +32,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)cksum.1 8.2 (Berkeley) 4/28/95
-.\" $Id: cksum.1,v 1.3 1997/04/29 08:41:26 jmg Exp $
+.\" @(#)cksum.1 8.2 (Berkeley) 4/28/95
+.\" $Id: cksum.1,v 1.4 1997/06/25 07:02:00 charnier Exp $
.\"
.Dd April 28, 1995
.Dt CKSUM 1
@@ -45,6 +45,8 @@
.Nm cksum
.Op Fl o Ar \&1 No \&| Ar \&2
.Op Ar file ...
+.Nm sum
+.Op Ar file ...
.Sh DESCRIPTION
The
.Nm cksum
@@ -56,6 +58,14 @@ the total number of octets in the file and the file name.
If no file name is specified, the standard input is used and no file name
is written.
.Pp
+The
+.Nm sum
+utility is identical to the
+.Nm cksum
+utility, except that it defaults to using historic algorithm 1, as
+described below.
+It is provided for compatibility only.
+.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl o
@@ -141,8 +151,10 @@ The bit sequence is complemented and the result is the CRC.
.Ed
.Pp
The
-.Nm
-utility exits 0 on success, and >0 if an error occurs.
+.Nm cksum
+and
+.Nm sum
+utilities exit 0 on success, and >0 if an error occurs.
.Sh SEE ALSO
.Xr md5 1
.Rs
diff --git a/usr.bin/cksum/cksum.c b/usr.bin/cksum/cksum.c
index 2381f2b..32bfb9b 100644
--- a/usr.bin/cksum/cksum.c
+++ b/usr.bin/cksum/cksum.c
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: cksum.c,v 1.3 1997/06/25 07:02:03 charnier Exp $
*/
#ifndef lint
@@ -43,11 +43,12 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)cksum.c 8.1 (Berkeley) 6/6/93";
+static char sccsid[] = "@(#)cksum.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/cdefs.h>
#include <sys/types.h>
+
#include <err.h>
#include <errno.h>
#include <fcntl.h>
@@ -55,6 +56,7 @@ static char sccsid[] = "@(#)cksum.c 8.1 (Berkeley) 6/6/93";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+
#include "extern.h"
static void usage __P((void));
@@ -64,22 +66,31 @@ main(argc, argv)
int argc;
char **argv;
{
- extern int optind;
- u_long len, val;
register int ch, fd, rval;
- char *fn;
+ u_long len, val;
+ char *fn, *p;
int (*cfncn) __P((int, unsigned long *, unsigned long *));
void (*pfncn) __P((char *, unsigned long, unsigned long));
- cfncn = crc;
- pfncn = pcrc;
+ if ((p = rindex(argv[0], '/')) == NULL)
+ p = argv[0];
+ else
+ ++p;
+ if (*p == 'c') {
+ cfncn = crc;
+ pfncn = pcrc;
+ } else {
+ cfncn = csum1;
+ pfncn = psum1;
+ }
+
while ((ch = getopt(argc, argv, "o:")) != -1)
- switch(ch) {
+ switch (ch) {
case 'o':
- if (*optarg == '1') {
+ if (!strcmp(optarg, "1")) {
cfncn = csum1;
pfncn = psum1;
- } else if (*optarg == '2') {
+ } else if (!strcmp(optarg, "2")) {
cfncn = csum2;
pfncn = psum2;
} else {
OpenPOWER on IntegriCloud