Lines 1-99
Link Here
|
1 |
/************************************************************************* |
|
|
2 |
* |
3 |
* OpenOffice.org - a multi-platform office productivity suite |
4 |
* |
5 |
* $RCSfile$ |
6 |
* |
7 |
* $Revision$ |
8 |
* |
9 |
* last change: $Author$ $Date$ |
10 |
* |
11 |
* The Contents of this file are made available subject to |
12 |
* the terms of GNU Lesser General Public License Version 2.1. |
13 |
* |
14 |
* |
15 |
* GNU Lesser General Public License Version 2.1 |
16 |
* ============================================= |
17 |
* Copyright 2005 by Sun Microsystems, Inc. |
18 |
* 901 San Antonio Road, Palo Alto, CA 94303, USA |
19 |
* |
20 |
* This library is free software; you can redistribute it and/or |
21 |
* modify it under the terms of the GNU Lesser General Public |
22 |
* License version 2.1, as published by the Free Software Foundation. |
23 |
* |
24 |
* This library is distributed in the hope that it will be useful, |
25 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
26 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
27 |
* Lesser General Public License for more details. |
28 |
* |
29 |
* You should have received a copy of the GNU Lesser General Public |
30 |
* License along with this library; if not, write to the Free Software |
31 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
32 |
* MA 02111-1307 USA |
33 |
* |
34 |
************************************************************************/ |
35 |
|
1 |
|
36 |
// MARKER(update_precomp.py): autogen include statement, do not remove |
|
|
37 |
#include "precompiled_package.hxx" |
38 |
#ifndef _ADLER32_HXX |
39 |
#include <Adler32.hxx> |
40 |
#endif |
41 |
#ifndef _ZLIB_H |
42 |
#ifdef SYSTEM_ZLIB |
43 |
#include <zlib.h> |
44 |
#else |
45 |
#include <external/zlib/zlib.h> |
46 |
#endif |
47 |
#endif |
48 |
|
49 |
/** |
50 |
* A class that can be used to compute the Adler-32 checksum of a data |
51 |
* stream. An Adler-32 checksum is almost as reliable as a CRC-32 but |
52 |
* can be computed much faster. |
53 |
* |
54 |
*/ |
55 |
|
56 |
using namespace rtl; |
57 |
using namespace com::sun::star; |
58 |
|
59 |
Adler32::Adler32() : nAdler(1) |
60 |
{ |
61 |
} |
62 |
|
63 |
Adler32::~Adler32() |
64 |
{ |
65 |
} |
66 |
/** Updates checksum with specified byte |
67 |
*/ |
68 |
void SAL_CALL Adler32::updateByte (sal_Int8 nByte) |
69 |
{ |
70 |
sal_uInt8 pBuf[1]; |
71 |
pBuf[0] = (sal_uInt8)nByte; |
72 |
nAdler = adler32(nAdler, pBuf, 1); |
73 |
} |
74 |
/** Updates checksum with specified sequence of bytes |
75 |
*/ |
76 |
void SAL_CALL Adler32::updateSegment(const uno::Sequence< sal_Int8 > &b, |
77 |
sal_Int32 off, |
78 |
sal_Int32 len) |
79 |
{ |
80 |
nAdler = adler32(nAdler, (const unsigned char*)b.getConstArray()+off, len ); |
81 |
} |
82 |
/** Updates checksum with specified sequence of bytes |
83 |
*/ |
84 |
void SAL_CALL Adler32::update(const uno::Sequence< sal_Int8 > &b) |
85 |
{ |
86 |
nAdler = adler32(nAdler, (const unsigned char*)b.getConstArray(),b.getLength()); |
87 |
} |
88 |
/** Returns checksum value. |
89 |
*/ |
90 |
sal_Int32 SAL_CALL Adler32::getValue() |
91 |
{ |
92 |
return (sal_Int32) nAdler & 0xFFFFFFFFL; |
93 |
} |
94 |
/** Resets checksum to initial value. |
95 |
*/ |
96 |
void SAL_CALL Adler32::reset() |
97 |
{ |
98 |
nAdler = 1; |
99 |
} |