]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/external/libmar/tool/crc32.c
Fix segmentation fault in mbsdiff and fix crc by linking with libbz2.
[working/Evergreen.git] / Open-ILS / xul / staff_client / external / libmar / tool / crc32.c
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include <stdint.h>
7
8 /* This guy lives in libbz2, and is the only reason we need libbz2. */
9 extern uint32_t BZ2_crc32Table[256];
10
11 uint32_t
12 crc32(const unsigned char *buf, uint32_t len)
13 {
14   uint32_t crc = 0xffffffffL;
15
16   const unsigned char *end = buf + len;
17   for (; buf != end; ++buf)
18     crc = (crc << 8) ^ BZ2_crc32Table[(crc >> 24) ^ *buf];
19
20   crc = ~crc;
21   return crc;
22 }