Back to index

tetex-bin  3.0
Defines | Functions
crc32.c File Reference
#include "zutil.h"
#include "crc32.h"

Go to the source code of this file.

Defines

#define local   static
#define TBLS   1
#define DO1   crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8   DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1

Functions

const unsigned long FAR *ZEXPORT get_crc_table ()
unsigned long ZEXPORT crc32 (unsigned long crc, const unsigned char FAR *buf, unsigned len)

Define Documentation

#define DO1   crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)

Definition at line 189 of file crc32.c.

#define DO8   DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1

Definition at line 190 of file crc32.c.

#define local   static

Definition at line 23 of file crc32.c.

#define TBLS   1

Definition at line 56 of file crc32.c.


Function Documentation

unsigned long ZEXPORT crc32 ( unsigned long  crc,
const unsigned char FAR buf,
unsigned  len 
)

Definition at line 193 of file crc32.c.

{
    if (buf == Z_NULL) return 0UL;

#ifdef DYNAMIC_CRC_TABLE
    if (crc_table_empty)
        make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */

#ifdef BYFOUR
    if (sizeof(void *) == sizeof(ptrdiff_t)) {
        u4 endian;

        endian = 1;
        if (*((unsigned char *)(&endian)))
            return crc32_little(crc, buf, len);
        else
            return crc32_big(crc, buf, len);
    }
#endif /* BYFOUR */
    crc = crc ^ 0xffffffffUL;
    while (len >= 8) {
        DO8;
        len -= 8;
    }
    if (len) do {
        DO1;
    } while (--len);
    return crc ^ 0xffffffffUL;
}

Here is the caller graph for this function:

const unsigned long FAR* ZEXPORT get_crc_table ( )

Definition at line 180 of file crc32.c.

{
#ifdef DYNAMIC_CRC_TABLE
  if (crc_table_empty) make_crc_table();
#endif /* DYNAMIC_CRC_TABLE */
  return (const unsigned long FAR *)crc_table;
}