maint: update copyright
[gnulib.git] / lib / crc.h
1 /* crc.h -- cyclic redundancy checks
2    Copyright (C) 2005, 2009-2014 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 3 of the License, or
7    (at your option) 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, see <http://www.gnu.org/licenses/>.  */
16
17 /* Written by Simon Josefsson.  */
18
19 #ifndef CRC_H
20 # define CRC_H 1
21
22 #include <stddef.h>
23 #include <stdint.h>
24
25 /* Compute CRC-32 value of LEN bytes long BUF, and return it. */
26 extern uint32_t crc32 (const char *buf, size_t len);
27
28 /* Incrementally update CRC-32 value CRC using LEN bytes long BUF.  In
29    the first call, use 0 as the value for CRC.  Return the updated
30    CRC-32 value.  */
31 extern uint32_t crc32_update (uint32_t crc, const char *buf, size_t len);
32
33 /* Compute modified-CRC-32 value of LEN bytes long BUF, and return it.
34    The "modification" is to avoid the initial and final XOR operation.
35    Due to historic implementation errors, this variant is sometimes
36    used (i.e., in RFC 3961). */
37 extern uint32_t crc32_no_xor (const char *buf, size_t len);
38
39 /* Incrementally update modified-CRC-32 value CRC using LEN bytes long
40    BUF.  In the first call, use 0 as the value for CRC.  Return the
41    updated modified-CRC-32 value.  The "modification" is to avoid the
42    initial and final XOR operation.  Due to historic implementation
43    errors, this variant is sometimes used (i.e., in RFC 3961).  */
44 extern uint32_t
45 crc32_update_no_xor (uint32_t crc, const char *buf, size_t len);
46
47 #endif /* CRC_H */