| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "courgette/crc.h" | 5 #include "courgette/crc.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 #include <stddef.h> |
| 9 |
| 7 #ifdef COURGETTE_USE_CRC_LIB | 10 #ifdef COURGETTE_USE_CRC_LIB |
| 8 # include "zlib.h" | 11 # include "zlib.h" |
| 9 #else | 12 #else |
| 10 extern "C" { | 13 extern "C" { |
| 11 # include "third_party/lzma_sdk/7zCrc.h" | 14 # include "third_party/lzma_sdk/7zCrc.h" |
| 12 } | 15 } |
| 13 #endif | 16 #endif |
| 14 | 17 |
| 15 #include "base/basictypes.h" | |
| 16 | 18 |
| 17 namespace courgette { | 19 namespace courgette { |
| 18 | 20 |
| 19 uint32 CalculateCrc(const uint8* buffer, size_t size) { | 21 uint32_t CalculateCrc(const uint8_t* buffer, size_t size) { |
| 20 uint32 crc; | 22 uint32_t crc; |
| 21 | 23 |
| 22 #ifdef COURGETTE_USE_CRC_LIB | 24 #ifdef COURGETTE_USE_CRC_LIB |
| 23 // Calculate Crc by calling CRC method in zlib | 25 // Calculate Crc by calling CRC method in zlib |
| 24 crc = crc32(0, buffer, size); | 26 crc = crc32(0, buffer, size); |
| 25 #else | 27 #else |
| 26 // Calculate Crc by calling CRC method in LZMA SDK | 28 // Calculate Crc by calling CRC method in LZMA SDK |
| 27 CrcGenerateTable(); | 29 CrcGenerateTable(); |
| 28 crc = CrcCalc(buffer, size); | 30 crc = CrcCalc(buffer, size); |
| 29 #endif | 31 #endif |
| 30 | 32 |
| 31 return ~crc; | 33 return ~crc; |
| 32 } | 34 } |
| 33 | 35 |
| 34 } // namespace | 36 } // namespace |
| OLD | NEW |