Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / checksum.hxx
blobbdc503a409ba394cc21203656a7f579c9cc211cc
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 <tools/solar.h>
27 #include <vcl/dllapi.h>
29 #define BITMAP_CHECKSUM_SIZE 8
31 typedef sal_uInt64 BitmapChecksum;
32 typedef sal_uInt8 BitmapChecksumOctetArray[BITMAP_CHECKSUM_SIZE];
34 template< sal_uInt8 N = 0 >
35 inline void BCToBCOA( BitmapChecksum n, BitmapChecksumOctetArray p )
37 p[N] = static_cast<sal_uInt8>(n >> ( 8 * N ));
38 return BCToBCOA< N + 1 >( n, p );
41 template<>
42 inline void BCToBCOA< BITMAP_CHECKSUM_SIZE >( BitmapChecksum, BitmapChecksumOctetArray )
44 return;
47 extern "C" {
49 /*========================================================================
51 * vcl_crc64 interface.
53 *======================================================================*/
54 /** Evaluate CRC64 over given data.
56 This function evaluates the CRC polynomial 0xEDB88320.
58 @param Crc [in] CRC64 over previous data or zero.
59 @param Data [in] data buffer.
60 @param DatLen [in] data buffer length.
61 @return new CRC64 value.
63 VCL_DLLPUBLIC sal_uInt64 SAL_CALL vcl_crc64 (
64 sal_uInt64 Crc,
65 const void *Data, sal_uInt32 DatLen
66 ) SAL_THROW_EXTERN_C();
69 VCL_DLLPUBLIC const sal_uInt64* vcl_get_crc64_table();
73 inline BitmapChecksum vcl_get_checksum (
74 BitmapChecksum Checksum,
75 const void *Data,
76 sal_uInt32 DatLen
79 return (BitmapChecksum)(vcl_crc64( Checksum, Data, DatLen ));
83 #endif // INCLUDED_VCL_INC_CHECKSUM_HXX
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */