VirtualBox

source: vbox/trunk/include/iprt/crc.h@ 78243

Last change on this file since 78243 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1/** @file
2 * IPRT - CRCs and Checksums.
3 */
4
5/*
6 * Copyright (C) 2006-2019 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef IPRT_INCLUDED_crc_h
27#define IPRT_INCLUDED_crc_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <iprt/cdefs.h>
33#include <iprt/types.h>
34
35
36RT_C_DECLS_BEGIN
37
38/** @defgroup grp_rt_crc RTCrc - Checksums and CRCs.
39 * @ingroup grp_rt
40 * @{
41 */
42
43
44/** @defgroup grp_rt_crc32 CRC-32
45 * @{ */
46/**
47 * Calculate CRC-32 for a memory block.
48 *
49 * @returns CRC-32 for the memory block.
50 * @param pv Pointer to the memory block.
51 * @param cb Size of the memory block in bytes.
52 */
53RTDECL(uint32_t) RTCrc32(const void *pv, size_t cb);
54
55/**
56 * Start a multiblock CRC-32 calculation.
57 *
58 * @returns Start CRC-32.
59 */
60RTDECL(uint32_t) RTCrc32Start(void);
61
62/**
63 * Processes a multiblock of a CRC-32 calculation.
64 *
65 * @returns Intermediate CRC-32 value.
66 * @param uCRC32 Current CRC-32 intermediate value.
67 * @param pv The data block to process.
68 * @param cb The size of the data block in bytes.
69 */
70RTDECL(uint32_t) RTCrc32Process(uint32_t uCRC32, const void *pv, size_t cb);
71
72/**
73 * Complete a multiblock CRC-32 calculation.
74 *
75 * @returns CRC-32 value.
76 * @param uCRC32 Current CRC-32 intermediate value.
77 */
78RTDECL(uint32_t) RTCrc32Finish(uint32_t uCRC32);
79/** @} */
80
81
82/** @defgroup grp_rt_crc64 CRC-64 Calculation
83 * @{ */
84/**
85 * Calculate CRC-64 for a memory block.
86 *
87 * @returns CRC-64 for the memory block.
88 * @param pv Pointer to the memory block.
89 * @param cb Size of the memory block in bytes.
90 */
91RTDECL(uint64_t) RTCrc64(const void *pv, size_t cb);
92
93/**
94 * Start a multiblock CRC-64 calculation.
95 *
96 * @returns Start CRC-64.
97 */
98RTDECL(uint64_t) RTCrc64Start(void);
99
100/**
101 * Processes a multiblock of a CRC-64 calculation.
102 *
103 * @returns Intermediate CRC-64 value.
104 * @param uCRC64 Current CRC-64 intermediate value.
105 * @param pv The data block to process.
106 * @param cb The size of the data block in bytes.
107 */
108RTDECL(uint64_t) RTCrc64Process(uint64_t uCRC64, const void *pv, size_t cb);
109
110/**
111 * Complete a multiblock CRC-64 calculation.
112 *
113 * @returns CRC-64 value.
114 * @param uCRC64 Current CRC-64 intermediate value.
115 */
116RTDECL(uint64_t) RTCrc64Finish(uint64_t uCRC64);
117/** @} */
118
119
120/** @defgroup grp_rt_crc_adler32 Adler-32
121 * @{ */
122/**
123 * Calculate Adler-32 for a memory block.
124 *
125 * @returns Adler-32 for the memory block.
126 * @param pv Pointer to the memory block.
127 * @param cb Size of the memory block in bytes.
128 */
129RTDECL(uint32_t) RTCrcAdler32(void const *pv, size_t cb);
130
131/**
132 * Start a multiblock Adler-32 calculation.
133 *
134 * @returns Start Adler-32.
135 */
136RTDECL(uint32_t) RTCrcAdler32Start(void);
137
138/**
139 * Processes a multiblock of a Adler-32 calculation.
140 *
141 * @returns Intermediate Adler-32 value.
142 * @param uCrc Current Adler-32 intermediate value.
143 * @param pv The data block to process.
144 * @param cb The size of the data block in bytes.
145 */
146RTDECL(uint32_t) RTCrcAdler32Process(uint32_t uCrc, void const *pv, size_t cb);
147
148/**
149 * Complete a multiblock Adler-32 calculation.
150 *
151 * @returns Adler-32 value.
152 * @param uCrc Current Adler-32 intermediate value.
153 */
154RTDECL(uint32_t) RTCrcAdler32Finish(uint32_t uCrc);
155
156/** @} */
157
158
159/** @defgroup grp_rt_crc32c CRC-32C
160 * @{ */
161/**
162 * Calculate CRC-32C for a memory block.
163 *
164 * @returns CRC-32C for the memory block.
165 * @param pv Pointer to the memory block.
166 * @param cb Size of the memory block in bytes.
167 */
168RTDECL(uint32_t) RTCrc32C(const void *pv, size_t cb);
169
170/**
171 * Start a multiblock CRC-32 calculation.
172 *
173 * @returns Start CRC-32.
174 */
175RTDECL(uint32_t) RTCrc32CStart(void);
176
177/**
178 * Processes a multiblock of a CRC-32C calculation.
179 *
180 * @returns Intermediate CRC-32C value.
181 * @param uCRC32C Current CRC-32C intermediate value.
182 * @param pv The data block to process.
183 * @param cb The size of the data block in bytes.
184 */
185RTDECL(uint32_t) RTCrc32CProcess(uint32_t uCRC32C, const void *pv, size_t cb);
186
187/**
188 * Complete a multiblock CRC-32 calculation.
189 *
190 * @returns CRC-32 value.
191 * @param uCRC32 Current CRC-32 intermediate value.
192 */
193RTDECL(uint32_t) RTCrc32CFinish(uint32_t uCRC32);
194
195/** @} */
196
197
198/** @defgroup grp_rt_crc16ccitt CRC-16-CCITT
199 * @{ */
200/**
201 * Calculate CRC-16-CCITT for a memory block.
202 *
203 * @returns CRC-16-CCITT for the memory block.
204 * @param pv Pointer to the memory block.
205 * @param cb Size of the memory block in bytes.
206 */
207RTDECL(uint16_t) RTCrc16Ccitt(const void *pv, size_t cb);
208
209/**
210 * Start a multiblock CRC-16-CCITT calculation.
211 *
212 * @returns Start CRC-16-CCITT.
213 */
214RTDECL(uint16_t) RTCrc16CcittStart(void);
215
216/**
217 * Processes a multiblock of a CRC-16-CCITT calculation.
218 *
219 * @returns Intermediate CRC-16-CCITT value.
220 * @param uCrc Current CRC-16-CCITT intermediate value.
221 * @param pv The data block to process.
222 * @param cb The size of the data block in bytes.
223 */
224RTDECL(uint16_t) RTCrc16CcittProcess(uint16_t uCrc, const void *pv, size_t cb);
225
226/**
227 * Complete a multiblock CRC-16-CCITT calculation.
228 *
229 * @returns CRC-16-CCITT value.
230 * @param uCrc Current CRC-16-CCITT intermediate value.
231 */
232RTDECL(uint16_t) RTCrc16CcittFinish(uint16_t uCrc);
233/** @} */
234
235/** @} */
236
237RT_C_DECLS_END
238
239#endif /* !IPRT_INCLUDED_crc_h */
240
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette