shithub: rewise

ref: ce1852b585349f8244fb132b199004f22d2a99fb
dir: /src/crc32.h/

View raw version
/* This file is part of REWise.
 *
 * REWise is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * REWise is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef H_REWISE_CRC32
#define H_REWISE_CRC32

#include <stdint.h>

// https://wiki.osdev.org/CRC32

#define CRC32_SEED 0xedb88320
#define CRC32_NEW  0xffffffff


uint32_t crc32Finalize(uint32_t value);
uint32_t crc32UpdateByte(uint32_t value, unsigned char byte);
uint32_t crc32Update(uint32_t value, unsigned char * buff, uint32_t size);

#ifdef REWISE_DEV_DEBUG
// Don't use these, they where used to generate the lookup table.
// Preserve to give insight on how the 'CRC32_LOOKUP' array is build.
void crc32BuildTable(void);
void crc32PrintTable(void);
#endif

#endif