* crc.h: Include stddef.h, for size_t.
[gnulib.git] / lib / crc.h
1 /* crc.h -- cyclic redundancy checks
2    Copyright (C) 2005 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2, or (at your option)
7    any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software Foundation,
16    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17
18 /* Written by Simon Josefsson.  */
19
20 #ifndef CRC_H
21 # define CRC_H 1
22
23 #include <stddef.h>
24 #include <stdint.h>
25
26 /* Compute CRC-32 value of LEN bytes long BUF, and return it. */
27 extern uint32_t crc32 (const char *buf, size_t len);
28
29 /* Incrementally update CRC-32 value CRC using LEN bytes long BUF.  In
30    the first call, use 0 as the value for CRC.  Return the updated
31    CRC-32 value.  */
32 extern uint32_t crc32_update (uint32_t crc, const char *buf, size_t len);
33
34 /* Compute modified-CRC-32 value of LEN bytes long BUF, and return it.
35    The "modification" is to avoid the initial and final XOR operation.
36    Due to historic implementation errors, this variant is sometimes
37    used (i.e., in RFC 3961). */
38 extern uint32_t crc32_no_xor (const char *buf, size_t len);
39
40 /* Incrementally update modified-CRC-32 value CRC using LEN bytes long
41    BUF.  In the first call, use 0 as the value for CRC.  Return the
42    updated modified-CRC-32 value.  The "modification" is to avoid the
43    initial and final XOR operation.  Due to historic implementation
44    errors, this variant is sometimes used (i.e., in RFC 3961).  */
45 extern uint32_t
46 crc32_update_no_xor (uint32_t crc, const char *buf, size_t len);
47
48 #endif /* CRC_H */