Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

crc32.c File Reference

#include "crc32.h"

Go to the source code of this file.

Defines

#define STEPCRC(crc, byte)   crc = crc_table[((int)crc ^ (byte)) & 0xff] ^ (crc >> 8)

Functions

uint32 CRC32_Start (void)
uint32 CRC32_Finish (uint32 crc)
uint32 CRC32_AddByte (uint32 crc, uint8 b)
uint32 CRC32_AddWord (uint32 crc, uint16 w)
uint32 CRC32_AddLong (uint32 crc, uint32 l)
uint32 CRC32_Array (const uint8 *buf, uint32 buflen)

Variables

uint32 crc_table [256]


Define Documentation

#define STEPCRC crc,
byte   )     crc = crc_table[((int)crc ^ (byte)) & 0xff] ^ (crc >> 8)
 

Definition at line 80 of file crc32.c.

Referenced by CRC32_AddByte(), CRC32_AddLong(), CRC32_AddWord(), and CRC32_Array().


Function Documentation

uint32 CRC32_AddByte uint32  crc,
uint8  b
 

Definition at line 92 of file crc32.c.

References STEPCRC, and uint32.

00093 {
00094         STEPCRC(crc,b);
00095 return(crc); 
00096 }

uint32 CRC32_AddLong uint32  crc,
uint32  l
 

Definition at line 107 of file crc32.c.

References STEPCRC, uint32, and uint8.

00108 {
00109 uint8 *ptr;
00110         ptr = (uint8 *)&l;
00111         STEPCRC(crc,ptr[0]);
00112         STEPCRC(crc,ptr[1]);
00113         STEPCRC(crc,ptr[2]);
00114         STEPCRC(crc,ptr[3]);
00115 return(crc); 
00116 }

uint32 CRC32_AddWord uint32  crc,
uint16  w
 

Definition at line 98 of file crc32.c.

References STEPCRC, uint32, and uint8.

00099 { 
00100 uint8 *ptr;
00101         ptr = (uint8 *)&w;
00102         STEPCRC(crc,ptr[0]);
00103         STEPCRC(crc,ptr[1]);
00104 return(crc); 
00105 }

uint32 CRC32_Array const uint8 buf,
uint32  buflen
 

Definition at line 118 of file crc32.c.

References STEPCRC, and uint32.

Referenced by Hash_StringToKey().

00119 {
00120 uint32 crc = (~((uint32)0));
00121 
00122         if (!buf ) return 0;
00123 
00124         while( (buflen&0xF) != 0 )
00125         {
00126                 STEPCRC(crc,*buf); buf++;
00127                 buflen--;
00128         }
00129 
00130         buflen>>=4; /* 16 at a time */
00131 
00132         while(buflen--)
00133         {
00134                 STEPCRC(crc,*buf); buf++;
00135                 STEPCRC(crc,*buf); buf++;
00136                 STEPCRC(crc,*buf); buf++;
00137                 STEPCRC(crc,*buf); buf++;
00138 
00139                 STEPCRC(crc,*buf); buf++;
00140                 STEPCRC(crc,*buf); buf++;
00141                 STEPCRC(crc,*buf); buf++;
00142                 STEPCRC(crc,*buf); buf++;
00143 
00144                 STEPCRC(crc,*buf); buf++;
00145                 STEPCRC(crc,*buf); buf++;
00146                 STEPCRC(crc,*buf); buf++;
00147                 STEPCRC(crc,*buf); buf++;
00148 
00149                 STEPCRC(crc,*buf); buf++;
00150                 STEPCRC(crc,*buf); buf++;
00151                 STEPCRC(crc,*buf); buf++;
00152                 STEPCRC(crc,*buf); buf++;
00153         }
00154 
00155         crc ^= 0xFFFFFFFF;
00156 
00157 return crc;
00158 }

uint32 CRC32_Finish uint32  crc  ) 
 

Definition at line 87 of file crc32.c.

References uint32.

00088 {
00089 return (~crc);
00090 }

uint32 CRC32_Start void   ) 
 

Definition at line 82 of file crc32.c.

References uint32.

00083 {
00084 return (~((uint32)0));
00085 }


Variable Documentation

uint32 crc_table[256] [static]
 

Definition at line 24 of file crc32.c.


Generated on Tue Sep 30 12:37:13 2003 for GTestAndEngine by doxygen 1.3.2