home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel Volume 2 #1
/
carousel.iso
/
mactosh
/
unix
/
unxbin.sha
/
crc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-04-02
|
446b
|
34 lines
/*
* compute the crc used in .hqx files
*/
#include <stdio.h>
int crc, temp;
main()
{
int c;
crc = 0;
while ( ( c = getchar() ) != EOF )
docrc( c );
docrc(0); docrc(0);
putchar( (crc>>8) & 0xff ); putchar( crc & 0xff );
}
docrc( c )
int c;
{
register int i;
temp = crc;
for ( i = 0; i < 8; i++ )
{
c <<= 1;
if ( (temp <<= 1) & 0x10000 )
temp = (temp & 0xffff) ^ 0x1021;
temp ^= (c >> 8);
c &= 0xff;
}
crc = temp;
}