|
LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
|
CRC update routines (ARC, BinHex, CCITT, CCITT32, Kermit, ZIP). More...
#include <stddef.h>#include <stdint.h>

Go to the source code of this file.
Macros | |
| #define | JUNO_ARC_CRC_INIT (0) |
| Initial seed for CRC-16/ARC (IBM-16) computations. | |
| #define | JUNO_BINHEX_CRC_INIT (0) |
| Initial seed for BinHex 16-bit CRC computations. | |
| #define | JUNO_CCITT_CRC_INIT (-1) |
| Initial seed for CRC-16/CCITT computations (0xFFFF). | |
| #define | JUNO_CCITT32_CRC_INIT (-1) |
| Initial seed for 32-bit CCITT-style CRC computations (0xFFFFFFFF). | |
| #define | JUNO_KERMIT_CRC_INIT (0) |
| Initial seed for CRC-16/KERMIT computations. | |
| #define | JUNO_ZIP_CRC_INIT (-1) |
| Initial seed for ZIP/PKZIP CRC-32 computations (0xFFFFFFFF). | |
Internal masks (implementation detail) | |
Bit masks used by table-driven CRC update routines. | |
| #define | M1_16 0xff |
| #define | M2_16 0xff00 |
| #define | M1_32 0xffffffff |
| #define | M2_32 0xffffff00 |
Functions | |
| uint16_t | Juno_CrcArcUpdate (uint16_t iCrc, const void *pcData, size_t zDataSize) |
| Update ARC CRC with new data. | |
| uint16_t | Juno_CrcBinhexUpdate (uint16_t iCrc, const void *pcData, size_t zDataSize) |
| Update BinHex CRC with new data. | |
| uint16_t | Juno_CrcCcittUpdate (uint16_t iCrc, const void *pcData, size_t zDataSize) |
| Update CCITT CRC (16-bit) with new data. | |
| uint32_t | Juno_CrcCcitt32Update (uint32_t iCrc, const void *pcData, size_t zDataSize) |
| Update CCITT32 CRC (32-bit) with new data. | |
| uint16_t | Juno_CrcKermitUpdate (uint16_t iCrc, const void *pcData, size_t zDataSize) |
| Update Kermit CRC with new data. | |
| uint32_t | Juno_CrcZipUpdate (uint32_t iCrc, const void *pcData, size_t zDataSize) |
| Update ZIP CRC (CRC-32) with new data. | |
CRC update routines (ARC, BinHex, CCITT, CCITT32, Kermit, ZIP).
| #define JUNO_ARC_CRC_INIT (0) |
Initial seed for CRC-16/ARC (IBM-16) computations.
Expands to 0 (all zeros). Use as the first iCrc value when starting a new ARC CRC computation.
| #define JUNO_BINHEX_CRC_INIT (0) |
Initial seed for BinHex 16-bit CRC computations.
Expands to 0 (all zeros). Use as the first iCrc value for BinHex.
| #define JUNO_CCITT32_CRC_INIT (-1) |
Initial seed for 32-bit CCITT-style CRC computations (0xFFFFFFFF).
Expands to -1 (all ones) as a C integer literal; when passed to the 32-bit function parameter it yields 0xFFFFFFFF. Use as the first iCrc value when starting a new CCITT32 computation.
| #define JUNO_CCITT_CRC_INIT (-1) |
Initial seed for CRC-16/CCITT computations (0xFFFF).
Expands to -1 (all ones) as a C integer literal; when passed to the 16-bit function parameter it yields 0xFFFF. Use as the first iCrc value when starting a new CCITT CRC computation.
| #define JUNO_KERMIT_CRC_INIT (0) |
Initial seed for CRC-16/KERMIT computations.
Expands to 0 (all zeros). Use as the first iCrc value for Kermit.
| #define JUNO_ZIP_CRC_INIT (-1) |
Initial seed for ZIP/PKZIP CRC-32 computations (0xFFFFFFFF).
Expands to -1 (all ones) as a C integer literal; when passed to the 32-bit function parameter it yields 0xFFFFFFFF. Use as the first iCrc value when starting a new ZIP CRC computation.
| #define M1_16 0xff |
Low byte mask for 16-bit CRC.
| #define M1_32 0xffffffff |
Low word mask for 32-bit CRC.
| #define M2_16 0xff00 |
High byte mask for 16-bit CRC.
| #define M2_32 0xffffff00 |
High word mask for 32-bit CRC.
| uint16_t Juno_CrcArcUpdate | ( | uint16_t | iCrc, |
| const void * | pcData, | ||
| size_t | zDataSize | ||
| ) |
Update ARC CRC with new data.
| iCrc | Running CRC value (use JUNO_ARC_CRC_INIT for first chunk). |
| pcData | Pointer to data buffer (can be NULL when zDataSize is 0). |
| zDataSize | Size of data buffer in bytes. |
pcData is NULL or zDataSize is 0. | uint16_t Juno_CrcBinhexUpdate | ( | uint16_t | iCrc, |
| const void * | pcData, | ||
| size_t | zDataSize | ||
| ) |
Update BinHex CRC with new data.
| iCrc | Running CRC value (use JUNO_BINHEX_CRC_INIT initially). |
| pcData | Pointer to data buffer (can be NULL when zDataSize is 0). |
| zDataSize | Size of data buffer in bytes. |
pcData is NULL or zDataSize is 0. | uint32_t Juno_CrcCcitt32Update | ( | uint32_t | iCrc, |
| const void * | pcData, | ||
| size_t | zDataSize | ||
| ) |
Update CCITT32 CRC (32-bit) with new data.
| iCrc | Running CRC value (use JUNO_CCITT32_CRC_INIT initially). |
| pcData | Pointer to data buffer (can be NULL when zDataSize is 0). |
| zDataSize | Size of data buffer in bytes. |
pcData is NULL or zDataSize is 0. | uint16_t Juno_CrcCcittUpdate | ( | uint16_t | iCrc, |
| const void * | pcData, | ||
| size_t | zDataSize | ||
| ) |
Update CCITT CRC (16-bit) with new data.
| iCrc | Running CRC value (use JUNO_CCITT_CRC_INIT initially). |
| pcData | Pointer to data buffer (can be NULL when zDataSize is 0). |
| zDataSize | Size of data buffer in bytes. |
pcData is NULL or zDataSize is 0. | uint16_t Juno_CrcKermitUpdate | ( | uint16_t | iCrc, |
| const void * | pcData, | ||
| size_t | zDataSize | ||
| ) |
Update Kermit CRC with new data.
| iCrc | Running CRC value (use JUNO_KERMIT_CRC_INIT initially). |
| pcData | Pointer to data buffer (can be NULL when zDataSize is 0). |
| zDataSize | Size of data buffer in bytes. |
pcData is NULL or zDataSize is 0. | uint32_t Juno_CrcZipUpdate | ( | uint32_t | iCrc, |
| const void * | pcData, | ||
| size_t | zDataSize | ||
| ) |
Update ZIP CRC (CRC-32) with new data.
Applies a final XOR (0xFFFFFFFF) to the computed value before returning when data is processed. If streaming across multiple chunks, undo the XOR on the returned value before using it as the next iCrc. When pcData is NULL or zDataSize is 0, the function returns 0 (no XOR is applied in that case).
| iCrc | Running CRC value (use JUNO_ZIP_CRC_INIT initially). |
| pcData | Pointer to data buffer (can be NULL when zDataSize is 0). |
| zDataSize | Size of data buffer in bytes. |
pcData is NULL or zDataSize is 0.