cool#6580 sw: fix infinite loop when changing document language
[LibreOffice.git] / include / vcl / checksum.hxx
blob34d8ed77ad0facd5c6759e5dd45bdbfce095e9b9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #ifndef INCLUDED_VCL_INC_CHECKSUM_HXX
22 #define INCLUDED_VCL_INC_CHECKSUM_HXX
24 #include <sal/config.h>
25 #include <sal/types.h>
26 #include <vcl/dllapi.h>
28 #define BITMAP_CHECKSUM_SIZE 8
30 typedef sal_uInt64 BitmapChecksum;
31 typedef sal_uInt8 BitmapChecksumOctetArray[BITMAP_CHECKSUM_SIZE];
33 template< sal_uInt8 N = 0 >
34 inline void BCToBCOA( BitmapChecksum n, BitmapChecksumOctetArray p )
36 p[N] = static_cast<sal_uInt8>(n >> ( 8 * N ));
37 return BCToBCOA< N + 1 >( n, p );
40 template<>
41 inline void BCToBCOA< BITMAP_CHECKSUM_SIZE >( BitmapChecksum, BitmapChecksumOctetArray )
43 return;
46 extern "C" {
48 /*========================================================================
50 * vcl_crc64 interface.
52 *======================================================================*/
53 /** Evaluate CRC64 over given data.
55 This function evaluates the CRC polynomial 0xEDB88320.
57 @param Crc [in] CRC64 over previous data or zero.
58 @param Data [in] data buffer.
59 @param DatLen [in] data buffer length.
60 @return new CRC64 value.
62 VCL_DLLPUBLIC sal_uInt64 vcl_crc64 (
63 sal_uInt64 Crc,
64 const void *Data, sal_uInt32 DatLen
65 ) SAL_THROW_EXTERN_C();
68 const sal_uInt64* vcl_get_crc64_table();
72 inline BitmapChecksum vcl_get_checksum (
73 BitmapChecksum Checksum,
74 const void *Data,
75 sal_uInt32 DatLen
78 return static_cast<BitmapChecksum>(vcl_crc64( Checksum, Data, DatLen ));
82 #endif // INCLUDED_VCL_INC_CHECKSUM_HXX
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */