home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
OS2OMMM.SRC
/
CRC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-02-13
|
755b
|
41 lines
#include <stdio.h>
#include <stdlib.h>
#include <crc.h>
/*
this program and source code are completely public-domain. crc
routines are from the rzsz source code by Chuck Forsberg
updcrc macro derived from article Copyright (C) 1986 Stephen Satchell.
*/
void main(int argc, char *argv[])
{
FILE *fp;
unsigned int crc = 0;
unsigned int ch = 0;
if (argc < 2) {
fputs("crc by jim nutt\nneed a filename\n.",stderr);
exit(1);
}
if ((fp = fopen(argv[1],"rb")) == NULL) {
fputs("crc by jim nutt\nfile does not exist\n.",stderr);
exit(1);
}
while (!feof(fp)) {
fread(&ch,1,1,fp);
crc = updcrc(ch,crc);
}
fclose(fp);
printf("the 16 bit CRC of %s is %x\n",argv[1],crc);
exit(0);
}