-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibcrc_fast.h
132 lines (111 loc) · 3.27 KB
/
libcrc_fast.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* crc_fast library C/C++ API - Copyright 2025 Don MacAskill */
/* This header is auto-generated. Do not edit directly. */
#ifndef CRC_FAST_H
#define CRC_FAST_H
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
/**
* The supported CRC algorithms
*/
typedef enum CrcFastAlgorithm {
Crc32Aixm,
Crc32Autosar,
Crc32Base91D,
Crc32Bzip2,
Crc32CdRomEdc,
Crc32Cksum,
Crc32Iscsi,
Crc32IsoHdlc,
Crc32Jamcrc,
Crc32Mef,
Crc32Mpeg2,
Crc32Xfer,
Crc64Ecma182,
Crc64GoIso,
Crc64Ms,
Crc64Nvme,
Crc64Redis,
Crc64We,
Crc64Xz,
} CrcFastAlgorithm;
/**
* Represents a CRC Digest, which is used to compute CRC checksums.
*
* The `Digest` struct maintains the state of the CRC computation, including
* the current state, the amount of data processed, the CRC parameters, and
* the calculator function used to perform the CRC calculation.
*/
typedef struct CrcFastDigest CrcFastDigest;
/**
* A handle to the Digest object
*/
typedef struct CrcFastDigestHandle {
struct CrcFastDigest *_0;
} CrcFastDigestHandle;
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/**
* Creates a new Digest to compute CRC checksums using algorithm
*/
struct CrcFastDigestHandle *crc_fast_digest_new(enum CrcFastAlgorithm algorithm);
/**
* Updates the Digest with data
*/
void crc_fast_digest_update(struct CrcFastDigestHandle *handle, const char *data, uintptr_t len);
/**
* Calculates the CRC checksum for data that's been written to the Digest
*/
uint64_t crc_fast_digest_finalize(struct CrcFastDigestHandle *handle);
/**
* Free the Digest resources without finalizing
*/
void crc_fast_digest_free(struct CrcFastDigestHandle *handle);
/**
* Reset the Digest state
*/
void crc_fast_digest_reset(struct CrcFastDigestHandle *handle);
/**
* Finalize and reset the Digest in one operation
*/
uint64_t crc_fast_digest_finalize_reset(struct CrcFastDigestHandle *handle);
/**
* Combine two Digest checksums
*/
void crc_fast_digest_combine(struct CrcFastDigestHandle *handle1,
struct CrcFastDigestHandle *handle2);
/**
* Gets the amount of data processed by the Digest so far
*/
uint64_t crc_fast_digest_get_amount(struct CrcFastDigestHandle *handle);
/**
* Helper method to calculate a CRC checksum directly for a string using algorithm
*/
uint64_t crc_fast_checksum(enum CrcFastAlgorithm algorithm, const char *data, uintptr_t len);
/**
* Helper method to just calculate a CRC checksum directly for a file using algorithm
*/
uint64_t crc_fast_checksum_file(enum CrcFastAlgorithm algorithm,
const uint8_t *path_ptr,
uintptr_t path_len);
/**
* Combine two CRC checksums using algorithm
*/
uint64_t crc_fast_checksum_combine(enum CrcFastAlgorithm algorithm,
uint64_t checksum1,
uint64_t checksum2,
uint64_t checksum2_len);
/**
* Gets the target build properties (CPU architecture and fine-tuning parameters) for this algorithm
*/
const char *crc_fast_get_calculator_target(enum CrcFastAlgorithm algorithm);
/**
* Gets the version of this library
*/
const char *crc_fast_get_version(void);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif /* CRC_FAST_H */