2 GZIP file format specification version 4.3
8 Update a running crc with the bytes buf[0..len-1] and return
9 the updated crc. The crc should be initialized to zero. Pre- and
10 post-conditioning (one's complement) is performed within this
11 function so it shouldn't be done by the caller. Usage example:
13 unsigned long crc = 0L;
15 while (read_buffer(buffer, length) != EOF) {
16 crc = update_crc(crc, buffer, length);
18 if (crc != original_crc) error();
20 static uint32_t update_crc(uint32_t crc, const uint8_t *buf, int len)
22 uint32_t c = crc ^ 0xffffffffUL;
25 for (n = 0; n < len; n++) {
26 c = CRCTABLE[(c ^ buf[n]) & 0xff] ^ (c >> 8);
28 return c ^ 0xffffffffUL;
31 /* Return the CRC of the bytes buf[0..len-1]. */
32 //uint32_t crc(uint8_t *buf, int len) //ÊÑ¿ô̾¤È¤«¤Ö¤ë¤Î¤Ç¤«¤¨¤ë
33 uint32_t crc32_get(const uint8_t *buf, int len)
35 return update_crc(0UL, buf, len);