mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-15 10:17:20 +00:00
Merge from Lite2 (make the command sum' an alias for
cksum -o 1', and
reject -o args other than "1" or "2").
This commit is contained in:
parent
2244ea07dc
commit
2cbd69330d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=27222
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user