1*89dcb3daSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*89dcb3daSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*89dcb3daSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*89dcb3daSAndrew Rist  * distributed with this work for additional information
6*89dcb3daSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*89dcb3daSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*89dcb3daSAndrew Rist  * "License"); you may not use this file except in compliance
9*89dcb3daSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*89dcb3daSAndrew Rist  *
11*89dcb3daSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*89dcb3daSAndrew Rist  *
13*89dcb3daSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*89dcb3daSAndrew Rist  * software distributed under the License is distributed on an
15*89dcb3daSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*89dcb3daSAndrew Rist  * KIND, either express or implied.  See the License for the
17*89dcb3daSAndrew Rist  * specific language governing permissions and limitations
18*89dcb3daSAndrew Rist  * under the License.
19*89dcb3daSAndrew Rist  *
20*89dcb3daSAndrew Rist  *************************************************************/
21*89dcb3daSAndrew Rist 
22*89dcb3daSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmlhelp.hxx"
26cdf0e10cSrcweir #include <util/Decompressor.hxx>
27cdf0e10cSrcweir #include <util/CompressorIterator.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir using namespace xmlsearch;
30cdf0e10cSrcweir using namespace xmlsearch::util;
31cdf0e10cSrcweir 
32cdf0e10cSrcweir const sal_Int32 Decompressor::BitsInByte = 8;
33cdf0e10cSrcweir const sal_Int32 Decompressor::NBits = 32;
34cdf0e10cSrcweir 
getInteger_(const sal_Int8 * v)35cdf0e10cSrcweir inline sal_Int32 getInteger_( const sal_Int8* v )
36cdf0e10cSrcweir {
37cdf0e10cSrcweir     return (((((( (v[0]&0xFF) ) << 8 )
38cdf0e10cSrcweir                 | (v[1]&0xFF) ) << 8 )
39cdf0e10cSrcweir                 | (v[2]&0xFF) ) << 8 )
40cdf0e10cSrcweir                 | (v[3]&0xFF);
41cdf0e10cSrcweir }
42cdf0e10cSrcweir 
getNextByte()43cdf0e10cSrcweir sal_Int32 StreamDecompressor::getNextByte()
44cdf0e10cSrcweir {
45cdf0e10cSrcweir   sal_Int8 a[4];
46cdf0e10cSrcweir   a[0] = a[1] = a[2] = 0;
47cdf0e10cSrcweir   if( in_->readBytes( &a[3],1 ) != -1 )
48cdf0e10cSrcweir     return getInteger_( a );
49cdf0e10cSrcweir   else
50cdf0e10cSrcweir     return -1;
51cdf0e10cSrcweir }
52