diff options
author | Simon Josefsson <simon@josefsson.org> | 2005-10-11 18:25:51 +0000 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2005-10-11 18:25:51 +0000 |
commit | 563da0755fefb7a98f8a4ee4e4de6c8c2b559905 (patch) | |
tree | ca61c66cb8318675f52a8b83e725113a26f46c02 /lib/crc.h | |
parent | 15ca72eba1ef4d940a05f6bcf92986b2cecad12e (diff) | |
download | gnulib-563da0755fefb7a98f8a4ee4e4de6c8c2b559905.tar.gz |
Add crc module.
Diffstat (limited to 'lib/crc.h')
-rw-r--r-- | lib/crc.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/crc.h b/lib/crc.h new file mode 100644 index 0000000000..ee13dafeed --- /dev/null +++ b/lib/crc.h @@ -0,0 +1,53 @@ +/* crc.h -- cyclic redundancy checks + Copyright (C) 2005 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Simon Josefsson. */ + +#ifndef CRC_H +# define CRC_H 1 + +#include <stddef.h> +#if HAVE_INTTYPES_H +# include <inttypes.h> +#endif +#if HAVE_STDINT_H +# include <stdint.h> +#endif + +/* Compute CRC-32 value of LEN bytes long BUF, and return it. */ +extern uint32_t crc32 (const char *buf, size_t len); + +/* Incrementally update CRC-32 value CRC using LEN bytes long BUF. In + the first call, use 0 as the value for CRC. Return the updated + CRC-32 value. */ +extern uint32_t crc32_update (uint32_t crc, const char *buf, size_t len); + +/* Compute modified-CRC-32 value of LEN bytes long BUF, and return it. + The "modification" is to avoid the initial and final XOR operation. + Due to historic implementation errors, this variant is sometimes + used (i.e., in RFC 3961). */ +extern uint32_t crc32_no_xor (const char *buf, size_t len); + +/* Incrementally update modified-CRC-32 value CRC using LEN bytes long + BUF. In the first call, use 0 as the value for CRC. Return the + updated modified-CRC-32 value. The "modification" is to avoid the + initial and final XOR operation. Due to historic implementation + errors, this variant is sometimes used (i.e., in RFC 3961). */ +extern uint32_t +crc32_update_no_xor (uint32_t crc, const char *buf, size_t len); + +#endif /* CRC_H */ |