Kaydet (Commit) 2c2e80da authored tarafından Caolán McNamara's avatar Caolán McNamara

callcatcher: remove newly unused code

and rework reads to just return the read value

Change-Id: I5d2f01064465c65859ec4ba031ec9dfa16403487
üst c928840e
......@@ -88,24 +88,6 @@ LwpSvStream& LwpSvStream::ReadUInt32( sal_uInt32& rUInt32 )
return *this;
}
LwpSvStream& LwpSvStream::ReadInt8( sal_Int8& rInt8 )
{
m_pStream->ReadSChar( rInt8 );
return *this;
}
LwpSvStream& LwpSvStream::ReadInt16( sal_Int16& rInt16 )
{
m_pStream->ReadInt16( rInt16 );
return *this;
}
LwpSvStream& LwpSvStream::ReadInt32( sal_Int32& rInt32 )
{
m_pStream->ReadInt32( rInt32 );
return *this;
}
/**
* @descr SeekRel in stream
*/
......
......@@ -76,10 +76,6 @@ public:
LwpSvStream& ReadUInt16( sal_uInt16& rUInt16 );
LwpSvStream& ReadUInt32( sal_uInt32& rUInt32 );
LwpSvStream& ReadInt8( sal_Int8& rInt8 );
LwpSvStream& ReadInt16( sal_Int16& rInt16 );
LwpSvStream& ReadInt32( sal_Int32& rInt32 );
static const sal_uInt32 LWP_STREAM_BASE;
LwpSvStream * GetCompressedStream()
......
......@@ -48,12 +48,37 @@ public:
sal_Int64 GetPosition()
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
ByteChucker& WriteInt8(sal_Int8 nInt8);
ByteChucker& WriteInt16(sal_Int16 nInt16);
ByteChucker& WriteInt32(sal_Int32 nInt32);
ByteChucker& WriteUInt8(sal_uInt8 nuInt8);
ByteChucker& WriteUInt16(sal_uInt16 nuInt16);
ByteChucker& WriteUInt32(sal_uInt32 nuInt32);
void WriteInt16(sal_Int16 nInt16)
{
p2Sequence[0] = static_cast< sal_Int8 >((nInt16 >> 0 ) & 0xFF);
p2Sequence[1] = static_cast< sal_Int8 >((nInt16 >> 8 ) & 0xFF);
WriteBytes( a2Sequence );
}
void WriteInt32(sal_Int32 nInt32)
{
p4Sequence[0] = static_cast< sal_Int8 >((nInt32 >> 0 ) & 0xFF);
p4Sequence[1] = static_cast< sal_Int8 >((nInt32 >> 8 ) & 0xFF);
p4Sequence[2] = static_cast< sal_Int8 >((nInt32 >> 16 ) & 0xFF);
p4Sequence[3] = static_cast< sal_Int8 >((nInt32 >> 24 ) & 0xFF);
WriteBytes( a4Sequence );
}
void WriteUInt16(sal_uInt16 nuInt16)
{
p2Sequence[0] = static_cast< sal_Int8 >((nuInt16 >> 0 ) & 0xFF);
p2Sequence[1] = static_cast< sal_Int8 >((nuInt16 >> 8 ) & 0xFF);
WriteBytes( a2Sequence );
}
void WriteUInt32(sal_uInt32 nuInt32)
{
p4Sequence[0] = static_cast < sal_Int8 > ((nuInt32 >> 0 ) & 0xFF);
p4Sequence[1] = static_cast < sal_Int8 > ((nuInt32 >> 8 ) & 0xFF);
p4Sequence[2] = static_cast < sal_Int8 > ((nuInt32 >> 16 ) & 0xFF);
p4Sequence[3] = static_cast < sal_Int8 > ((nuInt32 >> 24 ) & 0xFF);
WriteBytes( a4Sequence );
}
};
#endif
......
......@@ -58,12 +58,16 @@ public:
sal_Int64 SAL_CALL getLength( )
throw(::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
ByteGrabber& ReadInt8(sal_Int8& rInt8);
ByteGrabber& ReadInt16(sal_Int16& rInt16);
ByteGrabber& ReadInt32(sal_Int32& rInt32);
ByteGrabber& ReadUInt8(sal_uInt8& ruInt8);
ByteGrabber& ReadUInt16(sal_uInt16& ruInt16);
ByteGrabber& ReadUInt32(sal_uInt32& ruInt32);
sal_uInt16 ReadUInt16();
sal_uInt32 ReadUInt32();
sal_Int16 ReadInt16()
{
return static_cast<sal_Int16>(ReadUInt16());
}
sal_Int32 ReadInt32()
{
return static_cast<sal_Int32>(ReadUInt32());
}
};
#endif
......
......@@ -54,51 +54,4 @@ sal_Int64 ByteChucker::GetPosition( )
return xSeek->getPosition();
}
ByteChucker& ByteChucker::WriteInt8(sal_Int8 nInt8)
{
p1Sequence[0] = nInt8 & 0xFF;
WriteBytes( a1Sequence );
return *this;
}
ByteChucker& ByteChucker::WriteInt16(sal_Int16 nInt16)
{
p2Sequence[0] = static_cast< sal_Int8 >((nInt16 >> 0 ) & 0xFF);
p2Sequence[1] = static_cast< sal_Int8 >((nInt16 >> 8 ) & 0xFF);
WriteBytes( a2Sequence );
return *this;
}
ByteChucker& ByteChucker::WriteInt32(sal_Int32 nInt32)
{
p4Sequence[0] = static_cast< sal_Int8 >((nInt32 >> 0 ) & 0xFF);
p4Sequence[1] = static_cast< sal_Int8 >((nInt32 >> 8 ) & 0xFF);
p4Sequence[2] = static_cast< sal_Int8 >((nInt32 >> 16 ) & 0xFF);
p4Sequence[3] = static_cast< sal_Int8 >((nInt32 >> 24 ) & 0xFF);
WriteBytes( a4Sequence );
return *this;
}
ByteChucker& ByteChucker::WriteUInt8(sal_uInt8 nuInt8)
{
p1Sequence[0] = nuInt8 & 0xFF;
WriteBytes( a1Sequence );
return *this;
}
ByteChucker& ByteChucker::WriteUInt16(sal_uInt16 nuInt16)
{
p2Sequence[0] = static_cast< sal_Int8 >((nuInt16 >> 0 ) & 0xFF);
p2Sequence[1] = static_cast< sal_Int8 >((nuInt16 >> 8 ) & 0xFF);
WriteBytes( a2Sequence );
return *this;
}
ByteChucker& ByteChucker::WriteUInt32(sal_uInt32 nuInt32)
{
p4Sequence[0] = static_cast < sal_Int8 > ((nuInt32 >> 0 ) & 0xFF);
p4Sequence[1] = static_cast < sal_Int8 > ((nuInt32 >> 8 ) & 0xFF);
p4Sequence[2] = static_cast < sal_Int8 > ((nuInt32 >> 16 ) & 0xFF);
p4Sequence[3] = static_cast < sal_Int8 > ((nuInt32 >> 24 ) & 0xFF);
WriteBytes( a4Sequence );
return *this;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -100,90 +100,32 @@ sal_Int64 SAL_CALL ByteGrabber::getLength( )
throw io::IOException(THROW_WHERE );
}
ByteGrabber& ByteGrabber::ReadInt8(sal_Int8& rInt8)
sal_uInt16 ByteGrabber::ReadUInt16()
{
::osl::MutexGuard aGuard( m_aMutex );
if (xStream->readBytes(aSequence,1) != 1)
rInt8 = 0;
else
rInt8 = aSequence[0] & 0xFF;
return *this;
}
ByteGrabber& ByteGrabber::ReadInt16(sal_Int16& rInt16)
{
::osl::MutexGuard aGuard( m_aMutex );
if (xStream->readBytes ( aSequence, 2) != 2)
rInt16 = 0;
else
{
pSequence = aSequence.getConstArray();
rInt16 = static_cast <sal_Int16>
( (pSequence[0] & 0xFF)
| (pSequence[1] & 0xFF) << 8);
}
return *this;
}
ByteGrabber& ByteGrabber::ReadInt32(sal_Int32& rInt32)
{
::osl::MutexGuard aGuard( m_aMutex );
if (xStream->readBytes(aSequence, 4) != 4)
rInt32 = 0;
else
{
pSequence = aSequence.getConstArray();
rInt32 = static_cast < sal_Int32 >
( (pSequence[0] & 0xFF)
| ( pSequence[1] & 0xFF ) << 8
| ( pSequence[2] & 0xFF ) << 16
| ( pSequence[3] & 0xFF ) << 24 );
}
return *this;
}
ByteGrabber& ByteGrabber::ReadUInt8(sal_uInt8& rInt8)
{
::osl::MutexGuard aGuard( m_aMutex );
if (xStream->readBytes(aSequence, 2) != 2)
return 0;
if (xStream->readBytes(aSequence,1) != 1)
rInt8 = 0;
else
rInt8 = static_cast < sal_uInt8 > (aSequence[0] & 0xFF );
return *this;
pSequence = aSequence.getConstArray();
return static_cast <sal_uInt16>
( (pSequence[0] & 0xFF)
| (pSequence[1] & 0xFF) << 8);
}
ByteGrabber& ByteGrabber::ReadUInt16(sal_uInt16& rInt16)
{
::osl::MutexGuard aGuard( m_aMutex );
if (xStream->readBytes(aSequence, 2) != 2)
rInt16 = 0;
else
{
pSequence = aSequence.getConstArray();
rInt16 = static_cast <sal_uInt16>
( (pSequence[0] & 0xFF)
| (pSequence[1] & 0xFF) << 8);
}
return *this;
}
ByteGrabber& ByteGrabber::ReadUInt32(sal_uInt32& ruInt32)
sal_uInt32 ByteGrabber::ReadUInt32()
{
::osl::MutexGuard aGuard( m_aMutex );
if (xStream->readBytes(aSequence, 4) != 4)
ruInt32 = 0;
else
{
pSequence = aSequence.getConstArray();
ruInt32 = static_cast < sal_uInt32 >
( (pSequence[0] & 0xFF)
| ( pSequence[1] & 0xFF ) << 8
| ( pSequence[2] & 0xFF ) << 16
| ( pSequence[3] & 0xFF ) << 24 );
}
return *this;
return 0;
pSequence = aSequence.getConstArray();
return static_cast < sal_uInt32 >
( (pSequence[0] & 0xFF)
| ( pSequence[1] & 0xFF ) << 8
| ( pSequence[2] & 0xFF ) << 16
| ( pSequence[3] & 0xFF ) << 24 );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -99,70 +99,57 @@ public:
{
return mnEnd;
}
MemoryByteGrabber& ReadInt8(sal_Int8& rInt8)
sal_Int8 ReadInt8()
{
if (mnCurrent + 1 > mnEnd )
rInt8 = 0;
else
rInt8 = mpBuffer [mnCurrent++] & 0xFF;
return *this;
return 0;
return mpBuffer [mnCurrent++] & 0xFF;
}
MemoryByteGrabber& ReadInt16(sal_Int16& rInt16)
sal_Int16 ReadInt16()
{
if (mnCurrent + 2 > mnEnd )
rInt16 = 0;
else
{
rInt16 = mpBuffer[mnCurrent++] & 0xFF;
rInt16 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 8;
}
return *this;
return 0;
sal_Int16 nInt16 = mpBuffer[mnCurrent++] & 0xFF;
nInt16 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 8;
return nInt16;
}
MemoryByteGrabber& ReadInt32(sal_Int32& rInt32)
sal_Int32 ReadInt32()
{
if (mnCurrent + 4 > mnEnd )
rInt32 = 0;
else
{
rInt32 = mpBuffer[mnCurrent++] & 0xFF;
rInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 8;
rInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 16;
rInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 24;
}
return *this;
return 0;
sal_Int32 nInt32 = mpBuffer[mnCurrent++] & 0xFF;
nInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 8;
nInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 16;
nInt32 |= ( mpBuffer[mnCurrent++] & 0xFF ) << 24;
return nInt32;
}
MemoryByteGrabber& ReadUInt8(sal_uInt8& rInt8)
sal_uInt8 ReadUInt8()
{
if (mnCurrent + 1 > mnEnd )
rInt8 = 0;
else
rInt8 = mpBuffer [mnCurrent++] & 0xFF;
return *this;
return 0;
return mpBuffer [mnCurrent++] & 0xFF;
}
MemoryByteGrabber& ReadUInt16(sal_uInt16& rInt16)
sal_uInt16 ReadUInt16()
{
if (mnCurrent + 2 > mnEnd )
rInt16 = 0;
else
{
rInt16 = mpBuffer [mnCurrent++] & 0xFF;
rInt16 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 8;
}
return *this;
return 0;
sal_uInt16 nInt16 = mpBuffer [mnCurrent++] & 0xFF;
nInt16 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 8;
return nInt16;
}
MemoryByteGrabber& ReadUInt32(sal_uInt32& rInt32)
sal_uInt32 ReadUInt32()
{
if (mnCurrent + 4 > mnEnd )
rInt32 = 0;
else
{
rInt32 = mpBuffer [mnCurrent++] & 0xFF;
rInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 8;
rInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 16;
rInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 24;
}
return *this;
return 0;
sal_uInt32 nInt32 = mpBuffer [mnCurrent++] & 0xFF;
nInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 8;
nInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 16;
nInt32 |= ( mpBuffer [mnCurrent++] & 0xFF ) << 24;
return nInt32;
}
};
......
......@@ -634,24 +634,22 @@ bool ZipFile::readLOC( ZipEntry &rEntry )
{
::osl::MutexGuard aGuard( m_aMutex );
sal_Int32 nTestSig, nTime, nCRC, nSize, nCompressedSize;
sal_Int16 nVersion, nFlag, nHow, nPathLen, nExtraLen;
sal_Int64 nPos = -rEntry.nOffset;
aGrabber.seek(nPos);
aGrabber.ReadInt32( nTestSig );
sal_Int32 nTestSig = aGrabber.ReadInt32();
if (nTestSig != LOCSIG)
throw ZipIOException("Invalid LOC header (bad signature)" );
aGrabber.ReadInt16( nVersion );
aGrabber.ReadInt16( nFlag );
aGrabber.ReadInt16( nHow );
aGrabber.ReadInt32( nTime );
aGrabber.ReadInt32( nCRC );
aGrabber.ReadInt32( nCompressedSize );
aGrabber.ReadInt32( nSize );
aGrabber.ReadInt16( nPathLen );
aGrabber.ReadInt16( nExtraLen );
sal_Int16 nVersion = aGrabber.ReadInt16();
aGrabber.ReadInt16(); //flag
aGrabber.ReadInt16(); //how
aGrabber.ReadInt32(); //time
aGrabber.ReadInt32(); //crc
aGrabber.ReadInt32(); //compressed size
aGrabber.ReadInt32(); //size
sal_Int16 nPathLen = aGrabber.ReadInt16();
sal_Int16 nExtraLen = aGrabber.ReadInt16();
rEntry.nOffset = aGrabber.getPosition() + nPathLen + nExtraLen;
// FIXME64: need to read 64bit LOC
......@@ -754,8 +752,8 @@ sal_Int32 ZipFile::readCEN()
throw(IOException, ZipException, RuntimeException)
{
// this method is called in constructor only, no need for mutex
sal_Int32 nCenLen, nCenPos = -1, nCenOff, nEndPos, nLocPos;
sal_uInt16 nCount, nTotal;
sal_Int32 nCenPos = -1, nEndPos, nLocPos;
sal_uInt16 nCount;
try
{
......@@ -763,9 +761,9 @@ sal_Int32 ZipFile::readCEN()
if (nEndPos == -1)
return -1;
aGrabber.seek(nEndPos + ENDTOT);
aGrabber.ReadUInt16( nTotal );
aGrabber.ReadInt32( nCenLen );
aGrabber.ReadInt32( nCenOff );
sal_uInt16 nTotal = aGrabber.ReadUInt16();
sal_Int32 nCenLen = aGrabber.ReadInt32();
sal_Int32 nCenOff = aGrabber.ReadInt32();
if ( nTotal * CENHDR > nCenLen )
throw ZipException("invalid END header (bad entry count)" );
......@@ -791,39 +789,36 @@ sal_Int32 ZipFile::readCEN()
MemoryByteGrabber aMemGrabber ( aCENBuffer );
ZipEntry aEntry;
sal_Int32 nTestSig;
sal_Int16 nCommentLen;
for (nCount = 0 ; nCount < nTotal; nCount++)
{
aMemGrabber.ReadInt32( nTestSig );
sal_Int32 nTestSig = aMemGrabber.ReadInt32();
if ( nTestSig != CENSIG )
throw ZipException("Invalid CEN header (bad signature)" );
aMemGrabber.skipBytes ( 2 );
aMemGrabber.ReadInt16( aEntry.nVersion );
aEntry.nVersion = aMemGrabber.ReadInt16();
if ( ( aEntry.nVersion & 1 ) == 1 )
throw ZipException("Invalid CEN header (encrypted entry)" );
aMemGrabber.ReadInt16( aEntry.nFlag );
aMemGrabber.ReadInt16( aEntry.nMethod );
aEntry.nFlag = aMemGrabber.ReadInt16();
aEntry.nMethod = aMemGrabber.ReadInt16();
if ( aEntry.nMethod != STORED && aEntry.nMethod != DEFLATED)
throw ZipException("Invalid CEN header (bad compression method)" );
aMemGrabber.ReadInt32( aEntry.nTime );
aMemGrabber.ReadInt32( aEntry.nCrc );
aEntry.nTime = aMemGrabber.ReadInt32();
aEntry.nCrc = aMemGrabber.ReadInt32();
sal_uInt32 nCompressedSize, nSize, nOffset;
aMemGrabber.ReadUInt32( nCompressedSize );
aMemGrabber.ReadUInt32( nSize );
aMemGrabber.ReadInt16( aEntry.nPathLen );
aMemGrabber.ReadInt16( aEntry.nExtraLen );
aMemGrabber.ReadInt16( nCommentLen );
sal_uInt32 nCompressedSize = aMemGrabber.ReadUInt32();
sal_uInt32 nSize = aMemGrabber.ReadUInt32();
aEntry.nPathLen = aMemGrabber.ReadInt16();
aEntry.nExtraLen = aMemGrabber.ReadInt16();
nCommentLen = aMemGrabber.ReadInt16();
aMemGrabber.skipBytes ( 8 );
aMemGrabber.ReadUInt32( nOffset );
sal_uInt32 nOffset = aMemGrabber.ReadUInt32();
// FIXME64: need to read the 64bit header instead
if ( nSize == 0xffffffff ||
......@@ -905,22 +900,20 @@ sal_Int32 ZipFile::recover()
ZipEntry aEntry;
MemoryByteGrabber aMemGrabber ( Sequence< sal_Int8 >( ((sal_Int8*)(&(pBuffer[nPos+4]))), 26 ) );
aMemGrabber.ReadInt16( aEntry.nVersion );
aEntry.nVersion = aMemGrabber.ReadInt16();
if ( ( aEntry.nVersion & 1 ) != 1 )
{
aMemGrabber.ReadInt16( aEntry.nFlag );
aMemGrabber.ReadInt16( aEntry.nMethod );
aEntry.nFlag = aMemGrabber.ReadInt16();
aEntry.nMethod = aMemGrabber.ReadInt16();
if ( aEntry.nMethod == STORED || aEntry.nMethod == DEFLATED )
{
sal_uInt32 nCompressedSize, nSize;
aMemGrabber.ReadInt32( aEntry.nTime );
aMemGrabber.ReadInt32( aEntry.nCrc );
aMemGrabber.ReadUInt32( nCompressedSize );
aMemGrabber.ReadUInt32( nSize );
aMemGrabber.ReadInt16( aEntry.nPathLen );
aMemGrabber.ReadInt16( aEntry.nExtraLen );
aEntry.nTime = aMemGrabber.ReadInt32();
aEntry.nCrc = aMemGrabber.ReadInt32();
sal_uInt32 nCompressedSize = aMemGrabber.ReadUInt32();
sal_uInt32 nSize = aMemGrabber.ReadUInt32();
aEntry.nPathLen = aMemGrabber.ReadInt16();
aEntry.nExtraLen = aMemGrabber.ReadInt16();
// FIXME64: need to read the 64bit header instead
if ( nSize == 0xffffffff ||
......@@ -974,13 +967,11 @@ sal_Int32 ZipFile::recover()
}
else if (pBuffer[nPos] == 'P' && pBuffer[nPos+1] == 'K' && pBuffer[nPos+2] == 7 && pBuffer[nPos+3] == 8 )
{
sal_Int32 nCRC32;
sal_uInt32 nCompressedSize32, nSize32;
sal_Int64 nCompressedSize, nSize;
MemoryByteGrabber aMemGrabber ( Sequence< sal_Int8 >( ((sal_Int8*)(&(pBuffer[nPos+4]))), 12 ) );
aMemGrabber.ReadInt32( nCRC32 );
aMemGrabber.ReadUInt32( nCompressedSize32 );
aMemGrabber.ReadUInt32( nSize32 );
sal_Int32 nCRC32 = aMemGrabber.ReadInt32();
sal_uInt32 nCompressedSize32 = aMemGrabber.ReadUInt32();
sal_uInt32 nSize32 = aMemGrabber.ReadUInt32();
// FIXME64: work to be done here ...
nCompressedSize = nCompressedSize32;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment