Remove obsolete sum
This commit is contained in:
parent
d9f4f71916
commit
c248e23d93
6 changed files with 3 additions and 197 deletions
|
@ -24,7 +24,7 @@ SUBDIR= add_route arp ash at backup banner basename btrace cal \
|
||||||
reboot remsync rev rget rlogin \
|
reboot remsync rev rget rlogin \
|
||||||
rotate rsh rshd service setup shar acksize \
|
rotate rsh rshd service setup shar acksize \
|
||||||
sleep slip sort spell split sprofalyze sprofdiff srccrc \
|
sleep slip sort spell split sprofalyze sprofdiff srccrc \
|
||||||
stty sum svclog svrctl swifi sync synctree sysenv \
|
stty svclog svrctl swifi sync synctree sysenv \
|
||||||
syslogd tail tcpd tcpdp tcpstat tee telnet \
|
syslogd tail tcpd tcpdp tcpstat tee telnet \
|
||||||
telnetd term termcap tget time touch tr \
|
telnetd term termcap tget time touch tr \
|
||||||
truncate tsort tty udpstat umount uname unexpand \
|
truncate tsort tty udpstat umount uname unexpand \
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
PROG= sum
|
|
||||||
MAN=
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
|
@ -1,121 +0,0 @@
|
||||||
/* sum - checksum a file Author: Martin C. Atkins */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This program was written by:
|
|
||||||
* Martin C. Atkins,
|
|
||||||
* University of York,
|
|
||||||
* Heslington,
|
|
||||||
* York. Y01 5DD
|
|
||||||
* England
|
|
||||||
* and is released into the public domain, on the condition
|
|
||||||
* that this comment is always included without alteration.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <minix/minlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define BUFFER_SIZE (512)
|
|
||||||
|
|
||||||
int rc = 0;
|
|
||||||
|
|
||||||
char *defargv[] = {"-", 0};
|
|
||||||
|
|
||||||
int main(int argc, char **argv);
|
|
||||||
void error(char *s, char *f);
|
|
||||||
void sum(int fd, char *fname);
|
|
||||||
void putd(int number, int fw, int zeros);
|
|
||||||
|
|
||||||
int main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
|
||||||
register int fd;
|
|
||||||
|
|
||||||
if (*++argv == 0) argv = defargv;
|
|
||||||
for (; *argv; argv++) {
|
|
||||||
if (argv[0][0] == '-' && argv[0][1] == '\0')
|
|
||||||
fd = 0;
|
|
||||||
else
|
|
||||||
fd = open(*argv, O_RDONLY);
|
|
||||||
|
|
||||||
if (fd == -1) {
|
|
||||||
error("can't open ", *argv);
|
|
||||||
rc = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
sum(fd, (argc > 2) ? *argv : (char *) 0);
|
|
||||||
if (fd != 0) close(fd);
|
|
||||||
}
|
|
||||||
return(rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void error(s, f)
|
|
||||||
char *s, *f;
|
|
||||||
{
|
|
||||||
|
|
||||||
std_err("sum: ");
|
|
||||||
std_err(s);
|
|
||||||
|
|
||||||
if (f) std_err(f);
|
|
||||||
std_err("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void sum(fd, fname)
|
|
||||||
int fd;
|
|
||||||
char *fname;
|
|
||||||
{
|
|
||||||
char buf[BUFFER_SIZE];
|
|
||||||
register int i, n;
|
|
||||||
long size = 0;
|
|
||||||
unsigned crc = 0;
|
|
||||||
unsigned tmp, blks;
|
|
||||||
|
|
||||||
while ((n = read(fd, buf, BUFFER_SIZE)) > 0) {
|
|
||||||
for (i = 0; i < n; i++) {
|
|
||||||
crc = (crc >> 1) + ((crc & 1) ? 0x8000 : 0);
|
|
||||||
tmp = buf[i] & 0377;
|
|
||||||
crc += tmp;
|
|
||||||
crc &= 0xffff;
|
|
||||||
size++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (n < 0) {
|
|
||||||
if (fname)
|
|
||||||
error("read error on ", fname);
|
|
||||||
else
|
|
||||||
error("read error", (char *) 0);
|
|
||||||
rc = 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
putd(crc, 5, 1);
|
|
||||||
blks = (size + (long) BUFFER_SIZE - 1L) / (long) BUFFER_SIZE;
|
|
||||||
putd(blks, 6, 0);
|
|
||||||
if (fname) printf(" %s", fname);
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void putd(number, fw, zeros)
|
|
||||||
int number, fw, zeros;
|
|
||||||
{
|
|
||||||
/* Put a decimal number, in a field width, to stdout. */
|
|
||||||
|
|
||||||
char buf[10];
|
|
||||||
int n;
|
|
||||||
unsigned num;
|
|
||||||
|
|
||||||
num = (unsigned) number;
|
|
||||||
for (n = 0; n < fw; n++) {
|
|
||||||
if (num || n == 0) {
|
|
||||||
buf[fw - n - 1] = '0' + num % 10;
|
|
||||||
num /= 10;
|
|
||||||
} else
|
|
||||||
buf[fw - n - 1] = zeros ? '0' : ' ';
|
|
||||||
}
|
|
||||||
buf[fw] = 0;
|
|
||||||
printf("%s", buf);
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
MAN= ash.1 at.1 banner.1 basename.1 \
|
MAN= ash.1 at.1 banner.1 basename.1 \
|
||||||
bsfilt.1 cal.1 cawf.1 chgrp.1 \
|
bsfilt.1 cal.1 cawf.1 chgrp.1 \
|
||||||
chmod.1 cksum.1 clear.1 cmp.1 comm.1 compress.1 \
|
chmod.1 clear.1 cmp.1 comm.1 compress.1 \
|
||||||
cp.1 crc.1 crontab.1 ctags.1 dd.1 \
|
cp.1 crc.1 crontab.1 ctags.1 dd.1 \
|
||||||
df.1 dhrystone.1 dosdir.1 dosread.1 doswrite.1 \
|
df.1 dhrystone.1 dosdir.1 dosread.1 doswrite.1 \
|
||||||
dumpcore.1 echo.1 eject.1 elvis.1 elvrec.1 \
|
dumpcore.1 echo.1 eject.1 elvis.1 elvrec.1 \
|
||||||
|
@ -16,7 +16,7 @@ MAN= ash.1 at.1 banner.1 basename.1 \
|
||||||
profile.1 ps.1 pwd.1 rcp.1 recwave.1 \
|
profile.1 ps.1 pwd.1 rcp.1 recwave.1 \
|
||||||
ref.1 remsync.1 rget.1 rlogin.1 rsh.1 rz.1 \
|
ref.1 remsync.1 rget.1 rlogin.1 rsh.1 rz.1 \
|
||||||
shar.1 acksize.1 sleep.1 sort.1 spell.1 \
|
shar.1 acksize.1 sleep.1 sort.1 spell.1 \
|
||||||
split.1 stty.1 sum.1 svc.1 svrctl.1 \
|
split.1 stty.1 svc.1 svrctl.1 \
|
||||||
synctree.1 sysenv.1 sz.1 tail.1 tee.1 telnet.1 template.1 \
|
synctree.1 sysenv.1 sz.1 tail.1 tee.1 telnet.1 template.1 \
|
||||||
term.1 termcap.1 tget.1 time.1 tr.1 true.1 \
|
term.1 termcap.1 tget.1 time.1 tr.1 true.1 \
|
||||||
truncate.1 tsort.1 tty.1 umount.1 uname.1 unexpand.1 \
|
truncate.1 tsort.1 tty.1 umount.1 uname.1 unexpand.1 \
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
.TH CKSUM 1
|
|
||||||
.SH NAME
|
|
||||||
cksum \- display file checksum and size
|
|
||||||
.SH SYNOPSIS
|
|
||||||
\fBcksum \fR[\fIfile\fR ...]\fR
|
|
||||||
.br
|
|
||||||
.de FL
|
|
||||||
.TP
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
\\$2
|
|
||||||
..
|
|
||||||
.de EX
|
|
||||||
.TP 20
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
# \\$2
|
|
||||||
..
|
|
||||||
.SH EXAMPLES
|
|
||||||
.TP 20
|
|
||||||
.B cksum
|
|
||||||
# Display CRC and size of \fIstdin\fR
|
|
||||||
.TP 20
|
|
||||||
.B cksum *.c
|
|
||||||
# Display CRC and size of \fI.c\fP files
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.PP
|
|
||||||
.I Cksum
|
|
||||||
calculates and writes to standard output the 32-bits CRC of the input
|
|
||||||
.I files ,
|
|
||||||
or of stdin if no
|
|
||||||
.I files
|
|
||||||
were specified. The size in bytes of each
|
|
||||||
.I file
|
|
||||||
will be displayed after a space. The name of each
|
|
||||||
.I file
|
|
||||||
will be displayed after another space.
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR crc (1),
|
|
||||||
.BR sum (1).
|
|
|
@ -1,31 +0,0 @@
|
||||||
.TH SUM 1
|
|
||||||
.SH NAME
|
|
||||||
sum \- compute the checksum and block count of a file
|
|
||||||
.SH SYNOPSIS
|
|
||||||
\fBsum \fIfile\fR
|
|
||||||
.br
|
|
||||||
.de FL
|
|
||||||
.TP
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
\\$2
|
|
||||||
..
|
|
||||||
.de EX
|
|
||||||
.TP 20
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
# \\$2
|
|
||||||
..
|
|
||||||
.SH EXAMPLES
|
|
||||||
.TP 20
|
|
||||||
.B sum /user/ast/xyz
|
|
||||||
# Checksum \fI/user/ast/xyz
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.PP
|
|
||||||
.I Sum
|
|
||||||
computes the checksum of one or more files.
|
|
||||||
It is most often used to see if a file copied from another machine has
|
|
||||||
been correctly received.
|
|
||||||
This program works best when both machines use the same checksum algorithm.
|
|
||||||
See also \fIcrc\fR.
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR cksum (1),
|
|
||||||
.BR crc (1).
|
|
Loading…
Reference in a new issue