home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CBM Funet Archive
/
cbm-funet-archive-2003.iso
/
cbm
/
crossplatform
/
converters
/
unix
/
pcrc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-21
|
863b
|
53 lines
#INCLUDE <STDIO.H>
UNSIGNED CHAR CRC[8];
MAIN(ARGC, ARGV)
INT ARGC;
CHAR *ARGV[];
{$7b}
REGISTER INT IC;
REGISTER UNSIGNED CHAR C;
REGISTER INT I;
REGISTER UNSIGNED CHAR TOP;
LONG CRCSUM;
file *F;
FOR (I=0; I<8; I++) {$7b}
CRC[I] = 0;
{$7d}
IF (ARGC != 2) {$7b}
FPRINTF(STDOUT, "USAGE: %S FILENAME\N");
EXIT( 1 );
{$7d}
PRINTF("oPENING \"%S\".\N", ARGV[1]);
F = FOPEN( ARGV[1], "R" );
IF (F == null) {$7b}
PRINTF("cANNOT OPEN!");
EXIT( 1 );
{$7d}
PRINTF("pCRC WORKING...\N");
WHILE( (IC=GETC(F)) != eof ) {$7b}
C = IC;
TOP = CRC[7];
CRC[7] = CRC[6] ^ TOP;
CRC[6] = CRC[5] ^ TOP;
CRC[5] = CRC[4];
CRC[4] = CRC[3] ^ TOP;
CRC[3] = CRC[2];
CRC[2] = CRC[1];
CRC[1] = CRC[0] ^ TOP;
CRC[0] = C ^ TOP;
{$7d}
PRINTF("CRC =");
CRCSUM = 0;
FOR (I=0; I<8; I++) {$7b}
PRINTF(" %D", CRC[I]);
CRCSUM += CRC[I];
{$7d}
PRINTF(" ; CRCSUM=%D\N", CRCSUM);
{$7d}