#include "stdio.h"
static unsigned int table[256];
//位逆转
static unsigned int bitrev(unsigned int input, int bw)
{
int i;
unsigned int var;
var = 0;
for(i=0;i<bw;i++)
{
if(input & 0x01)
{
var |= 1<<(bw-1-i);
}
input>>=1;
}
return var;
}
//码表生成
//如:X32+X26+...X1+1,poly=(1<<26)|...|(1<<1)|(1<<0)
void crc32_init(unsigned int poly, unsigned int *table)
{
int i;
int j;
unsigned int c;
poly=bitrev(poly,32);
for(i=0; i<256; i++)
{
c = i;
for (j=0; j<8; j++)
{
if(c&1)
{