Enable dev build with the latest repo
[platform/framework/web/chromium-efl.git] / courgette / crc.cc
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
3 // found in the LICENSE file.
4
5 #include "courgette/crc.h"
6
7 #include <stdint.h>
8 #include <stddef.h>
9
10 #ifdef COURGETTE_USE_CRC_LIB
11 #  include "zlib.h"
12 #else
13 extern "C" {
14 #  include "third_party/lzma_sdk/7zCrc.h"
15 }
16 #endif
17
18
19 namespace courgette {
20
21 uint32_t CalculateCrc(const uint8_t* buffer, size_t size) {
22   uint32_t crc;
23
24 #ifdef COURGETTE_USE_CRC_LIB
25   // Calculate Crc by calling CRC method in zlib
26   crc = crc32(0, buffer, size);
27 #else
28   // Calculate Crc by calling CRC method in LZMA SDK
29   CrcGenerateTable();
30   crc = CrcCalc(buffer, size);
31 #endif
32
33   return ~crc;
34 }
35
36 }  // namespace