Esempio n. 1
0
/* ========================================================================= */
unsigned long _crc32(
    register unsigned long crc,  /* crc shift register */
    register const char    *buf, /* pointer to bytes to pump through */
    int                    len   /* number of bytes in buf[] */

/* Run a set of bytes through the crc shift register.  If buf is a NULL
   pointer, then initialize the crc shift register contents instead.
   Return the current crc in either case. */
    ) {
    /* register ulg near *crc_table; */

    if (buf == 0) return crc /*0L*/;

    /* crc_table = get_crc_table(); */

    crc = crc ^ 0xffffffffUL;
#ifndef NO_UNROLLED_LOOPS
    while (len >= 8) {
        DO8(buf);
        len -= 8;
    }
#endif
    if (len) do {
            DO1(buf);
        } while (--len);
    return crc ^ 0xffffffffUL;   /* (instead of ~c for 64-bit machines) */
}
Esempio n. 2
0
/* ========================================================================= */
uint32_t crc32(uint32_t* ckSum, const void *buffer, size_t len)
{
  uint32_t crc;
  const uint8_t* buf = buffer;
  
  if(ckSum == NULL)
	  crc = 0;
  else
	  crc = *ckSum;
  
  if (buf == NULL) return crc;
  
  crc = crc ^ 0xffffffffL;
  while (len >= 8)
  {
    DO8(buf);
    len -= 8;
  }
  if (len)
  {
    do {
DO1(buf);
    } while (--len);
  }
  
  crc = crc ^ 0xffffffffL;
  
  if(ckSum != NULL)
	  *ckSum = crc;

  return crc;
}
Esempio n. 3
0
	static int CRC32(int crc, const unsigned char *buf, unsigned int len)
	{
		if (buf == NULL) return 0L;
		crc = crc ^ 0xffffffffL;
		while (len >= 8) {DO8(buf);len -= 8;}
		if(len) do {DO1(buf);} while (--len);
		return crc ^ 0xffffffffL;
	}
Esempio n. 4
0
void crc32(const void * key, int len, uint32_t seed, void * out) {
  uint8_t* buf = (uint8_t*)key;
  uint32_t crc = seed ^ 0xffffffffL;
  while (len >= 8) {
    DO8(buf);
    len -= 8;
  }
  while(len--)
    DO1(buf);
  crc ^= 0xffffffffL;
  *(uint32_t*)out = crc;
}
Esempio n. 5
0
unsigned long crc32_no_comp(unsigned long crc, const unsigned char *buf, int len) {
	while (len >= 8) {
		DO8(buf);
		len -= 8;
	}
	if (len)
		do {
			DO1(buf);
		} while (--len);

	return crc;
}
static uint32_t ubcrc32(uint32_t crc, const char *buf, uint32_t len)
{
    crc = crc ^ 0xffffffffL;

    while (len >= 8) {
        DO8(buf);
        len -= 8;
    }

    if (len)
        do { DO1(buf); } while (--len);
    return crc ^ 0xffffffffL;
}
Esempio n. 7
0
/* ========================================================================= */
unsigned long crc32(unsigned char* buf, unsigned len)
{
    unsigned long crc = 0xffffffffL;
    while (len >= 8)
    {
      DO8(buf);
      len -= 8;
    }
    if (len) do {
      DO1(buf);
    } while (--len);
    return crc ^ 0xffffffffL;
}
Esempio n. 8
0
/* ========================================================================= */
static unsigned long crc32 (unsigned long crc, const unsigned char *buf,  unsigned int len)
{
    crc = crc ^ 0xffffffffL;
    while (len >= 8)
    {
      DO8(buf);
      len -= 8;
    }
    if (len) do {
      DO1(buf);
    } while (--len);
    return crc ^ 0xffffffffL;
}
Esempio n. 9
0
/* ========================================================================= */
uLong crc32(uLong crc, const Byte *buf, uInt len)
{
    if (buf == Z_NULL) return 0L;
    crc = crc ^ 0xffffffffL;
    while (len >= 8)
    {
      DO8(buf);
      len -= 8;
    }
    if (len) do {
      DO1(buf);
    } while (--len);
    return crc ^ 0xffffffffL;
}
Esempio n. 10
0
//	uLong crc = crc32(0L, NULL, 0);
//
//	while (read_buffer(buffer, length) != EOF) 
//  {
//		crc = crc32(crc, buffer, length);
//  }
//  if (crc != original_crc) error();
//
/////////////////////////////////////////////////////////////////////////////////////
ULONG CCRC32::crc32(ULONG crc, const BYTE *buf, UINT len)
{
    if (buf == NULL) return 0L;
    crc = crc ^ 0xffffffffL;
    while (len >= 8)
    {
      DO8(buf);
      len -= 8;
    }
    if (len) do {
      DO1(buf);
    } while (--len);
    return crc ^ 0xffffffffL;
}
Esempio n. 11
0
static unsigned int crc32(const unsigned char *buffer, unsigned int len)
{
	unsigned int crc;
	crc = 0;
	crc = crc ^ 0xffffffffL;
	while(len >= 8) {
		DO8(buffer);
		len -= 8;
	}
	if(len) do {
		DO1(buffer);
	} while(--len);
	return crc ^ 0xffffffffL;
}
Esempio n. 12
0
/* ========================================================================= */
uint32_t nv_crc32(uint32_t crc, const char *buf, uint32_t len)
{
    if (buf == 0) return 0L;
    crc = crc ^ 0xffffffffL;
    while (len >= 8)
    {
      DO8(buf);
      len -= 8;
    }
    if (len) do {
      DO1(buf);
    } while (--len);
    return crc ^ 0xffffffffL;
}
Esempio n. 13
0
unsigned long crc32(unsigned long crc, const uint8_t *buf, unsigned int len) {
	if (!buf)
		return 0L;
	crc = crc ^ 0xffffffffL;
	while (len >= 8) {
		DO8(buf);
		len -= 8;
	}
	if (len) {
		do {
			DO1(buf);
		} while (--len);
	}
	return crc ^ 0xffffffffL;
}
Esempio n. 14
0
void crc32_add ( unsigned long& crc, const void * key, int len )
{
	uint8_t * buf = (uint8_t*)key;

	while (len >= 8)
	{
		DO8(buf);
		len -= 8;
	}

	while(len--)
	{
		DO1(buf);
	} 

}
Esempio n. 15
0
DWORD CHList::Crc32(DWORD crc, LPVOID vbuf, DWORD size)
{
	LPBYTE buf = (LPBYTE)vbuf;

	crc = crc ^ 0xffffffffL; 
	while ( size >= 8 ) 
	{
		DO8 ( buf ); 
		size -= 8; 		
	} 
	if ( size ) do 
	{
		DO1 ( buf ); 		
	} while ( --size ); 

	return ( crc ^ 0xffffffffL ); 
}
Esempio n. 16
0
unsigned long
fz_crc32(unsigned long crc, unsigned char *buf, int len)
{
    if (buf == nil)
        return 0L;
    crc = crc ^ 0xffffffffL;
    while (len >= 8)
    {
        DO8(buf);
        len -= 8;
    }
    if (len)
    {
        do { DO1(buf); } while (--len);
    }
    return crc ^ 0xffffffffL;
}
Esempio n. 17
0
static void cyPartialCRC32( cyUint32* crc, const cyByte* buf, cyUint32 len )
{

    while (len >= 8) 
    {
        DO8(buf);
        len -= 8;
    }

    if (len) 
    {
        do 
        {
            DO1(buf);
        } while (--len);
    }
}
Esempio n. 18
0
/* ========================================================================= */
uint crc32(uint crc, const char *buf, uint len)
{
    crc = crc ^ 0xffffffffL;
    while (len >= 8)
    {
      DO8(buf);
      len -= 8;
    }

    if (len)
    {
    	do {
    		DO1(buf);
    	} while (--len);
    }

    return crc ^ 0xffffffffL;
}
Esempio n. 19
0
void crc32 ( const void * key, int len, unsigned long seed, unsigned long * out )
{
  uint8_t * buf = (uint8_t*)key;
  unsigned long crc = seed ^ 0xffffffffL;

  while (len >= 8)
  {
    DO8(buf);
    len -= 8;
  }

  while(len--)
  {
    DO1(buf);
  } 

  crc ^= 0xffffffffL;

  *(unsigned long*)out = crc;
}
Esempio n. 20
0
File: crc.c Progetto: OPSF/uClinux
unsigned int aal5_calc_crc(unsigned char *mem, int len, unsigned int initial)
{

	register unsigned int crc;

	crc = initial;

	while( len >= 8) {
		DO8(mem, crc);
		len -= 8;
	}

	while( len ) {
		DO1(mem, crc);
		len--;
	}

	return(crc);

}
Esempio n. 21
0
UInt32 MoreCRC32 (UInt32 crc, void *buf, UInt32 len)
{
	if (buf == NULL) {
		assert(false);
		return 0;
	}

	crc = crc ^ 0xffffffffL;

	while (len >= 8)
	{
		DO8(buf);
		len -= 8;
	}

	if (len) do
	{
		DO1(buf);
	}
	while (--len);

	return crc ^ 0xffffffffL;
}