Unsigned char appengcrc32 (unsigned char * filename)
{
Unsigned long CRC = 0 xffffffff;
Unsigned int I;
Unsigned char res = 0;
Unsigned char buff [513];
Unsigned int realread;
File * FP;
Unsigned short filesize;
Fp = fopen (const char *) filename, "R + ");
Fread (& filesize, 1, 2, FP );
Filesize + = 4;
Fseek (FP, 0, seek_set );
Fwrite (& filesize, 2, 1, FP );
fseek (FP, 0, seek_set);
If (FP! = NULL)
{<
for (;)
{< br>
realread = fread (buff, 1,512, FP );
If (realread! = 0)
{< br> for (I = 0; I CRC = CRC32 [(CRC & 0xff) ^ buff [I])] ^ (CRC> 8);
}< br> else
break;
}< BR >}< br> CRC = ~ CRC;
fseek (FP, 0, seek_end);
fwrite (& CRC, 4,1, FP);
fclose (FP );
return 1;
}
Unsigned char wincheckcrc32 (unsigned char * filename)
{
Typedef struct
{
Signed int filesize;
Signed int accfp;
Unsigned long crcread;
} Tcrc32file;
Unsigned long CRC = 0 xffffffff;
Signed int I;
Unsigned char res = 0;
Unsigned char buff [513];
Signed int realread;
Tcrc32file crc32file;
File * FP;
Crc32file. accfp = 0;
Fp = fopen (filename, "rb ");
Fseek (FP, 0, seek_end );
Crc32file. filesize = ftell (FP );
Fseek (FP, seek_set, 0 );
If (FP! = NULL)
{< br> for (;)
{< br> realread = fread (buff, 1,512, FP );
If (realread> 0)
{< br> for (I = 0; I {< br> crc32file. accfp ++;
If (crc32file. accfp> crc32file. fileSize-4) break;
CRC = CRC32 [(CRC & 0xff) ^ buff [I])] ^ (CRC> 8 );
}< BR >}< br> else
break;
}< BR >}< br> CRC = ~ CRC;
fclose (FP);
Fp = fopen (filename, "rb ");
Fseek (FP,-4, seek_end );
Fread (& crc32file. crcread, 4,1, FP );
Fclose (FP );
Return (crc32file. crcread = CRC );
}