1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 03:09:13 +00:00

Convert custom HeadSpin integer types to standard types from stdint.h

This commit is contained in:
2012-01-19 21:19:26 -05:00
parent a0d54e2644
commit 5027b5a4ac
1301 changed files with 14497 additions and 14532 deletions

View File

@ -54,12 +54,12 @@ public:
virtual ~plCompress() {}
// return true if successful
virtual hsBool Uncompress(UInt8* bufOut, UInt32* bufLenOut, const UInt8* bufIn, UInt32 bufLenIn) = 0;
virtual hsBool Compress(UInt8* bufOut, UInt32* bufLenOut, const UInt8* bufIn, UInt32 bufLenIn) = 0;
virtual hsBool Uncompress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn) = 0;
virtual hsBool Compress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn) = 0;
// in place versions
virtual hsBool Uncompress(UInt8** bufIn, UInt32* bufLenIn, UInt32 maxBufLenOut, int offset=0) = 0;
virtual hsBool Compress(UInt8** bufIn, UInt32* bufLenIn, int offset=0) = 0;
virtual hsBool Uncompress(uint8_t** bufIn, uint32_t* bufLenIn, uint32_t maxBufLenOut, int offset=0) = 0;
virtual hsBool Compress(uint8_t** bufIn, uint32_t* bufLenIn, int offset=0) = 0;
};

View File

@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsMemory.h"
#include "hsStream.h"
hsBool plZlibCompress::Uncompress(UInt8* bufOut, UInt32* bufLenOut, const UInt8* bufIn, UInt32 bufLenIn)
hsBool plZlibCompress::Uncompress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn)
{
unsigned long buflen_out = *bufLenOut;
bool result = (uncompress(bufOut, &buflen_out, bufIn, bufLenIn) == Z_OK);
@ -52,7 +52,7 @@ hsBool plZlibCompress::Uncompress(UInt8* bufOut, UInt32* bufLenOut, const UInt8*
return result;
}
hsBool plZlibCompress::Compress(UInt8* bufOut, UInt32* bufLenOut, const UInt8* bufIn, UInt32 bufLenIn)
hsBool plZlibCompress::Compress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn)
{
// according to compress doc, the bufOut buffer should be at least .1% larger than source buffer, plus 12 bytes.
hsAssert(*bufLenOut>=(int)(bufLenIn*1.1+12), "bufOut compress buffer is not large enough");
@ -65,12 +65,12 @@ hsBool plZlibCompress::Compress(UInt8* bufOut, UInt32* bufLenOut, const UInt8* b
//
// copy bufOut to bufIn, set bufLenIn=bufLenOut
//
hsBool plZlibCompress::ICopyBuffers(UInt8** bufIn, UInt32* bufLenIn, char* bufOut, UInt32 bufLenOut, int offset, bool ok)
hsBool plZlibCompress::ICopyBuffers(uint8_t** bufIn, uint32_t* bufLenIn, char* bufOut, uint32_t bufLenOut, int offset, bool ok)
{
if (ok)
{
*bufLenIn = bufLenOut+offset;
UInt8* newBuf = TRACKED_NEW UInt8[*bufLenIn]; // alloc new buffer
uint8_t* newBuf = TRACKED_NEW uint8_t[*bufLenIn]; // alloc new buffer
HSMemory::BlockMove(*bufIn, newBuf, offset); // copy offset (uncompressed) part
delete [] *bufIn; // delete original buffer
@ -87,16 +87,16 @@ hsBool plZlibCompress::ICopyBuffers(UInt8** bufIn, UInt32* bufLenIn, char* bufOu
// In place version
// offset is how much to skip over when compressing
//
hsBool plZlibCompress::Compress(UInt8** bufIn, UInt32* bufLenIn, int offset)
hsBool plZlibCompress::Compress(uint8_t** bufIn, uint32_t* bufLenIn, int offset)
{
UInt32 adjBufLenIn = *bufLenIn - offset;
UInt8* adjBufIn = *bufIn + offset;
uint32_t adjBufLenIn = *bufLenIn - offset;
uint8_t* adjBufIn = *bufIn + offset;
// according to compress doc, the bufOut buffer should be at least .1% larger than source buffer, plus 12 bytes.
UInt32 bufLenOut = (int)(adjBufLenIn*1.1+12);
uint32_t bufLenOut = (int)(adjBufLenIn*1.1+12);
char* bufOut = TRACKED_NEW char[bufLenOut];
bool ok=(Compress((UInt8*)bufOut, &bufLenOut, (UInt8*)adjBufIn, adjBufLenIn) &&
bool ok=(Compress((uint8_t*)bufOut, &bufLenOut, (uint8_t*)adjBufIn, adjBufLenIn) &&
bufLenOut < adjBufLenIn);
return ICopyBuffers(bufIn, bufLenIn, bufOut, bufLenOut, offset, ok);
}
@ -104,14 +104,14 @@ hsBool plZlibCompress::Compress(UInt8** bufIn, UInt32* bufLenIn, int offset)
//
// In place version
//
hsBool plZlibCompress::Uncompress(UInt8** bufIn, UInt32* bufLenIn, UInt32 bufLenOut, int offset)
hsBool plZlibCompress::Uncompress(uint8_t** bufIn, uint32_t* bufLenIn, uint32_t bufLenOut, int offset)
{
UInt32 adjBufLenIn = *bufLenIn - offset;
UInt8* adjBufIn = *bufIn + offset;
uint32_t adjBufLenIn = *bufLenIn - offset;
uint8_t* adjBufIn = *bufIn + offset;
char* bufOut = TRACKED_NEW char[bufLenOut];
bool ok=Uncompress((UInt8*)bufOut, &bufLenOut, (UInt8*)adjBufIn, adjBufLenIn) ? true : false;
bool ok=Uncompress((uint8_t*)bufOut, &bufLenOut, (uint8_t*)adjBufIn, adjBufLenIn) ? true : false;
return ICopyBuffers(bufIn, bufLenIn, bufOut, bufLenOut, offset, ok);
}
@ -127,7 +127,7 @@ hsBool plZlibCompress::UncompressFile( const char *compressedPath, const char *
hsBool worked = false;
int length, err;
UInt8 buffer[ kGzBufferSize ];
uint8_t buffer[ kGzBufferSize ];
outFile = fopen( destPath, "wb" );
@ -169,7 +169,7 @@ hsBool plZlibCompress::CompressFile( const char *uncompressedPath, const char *
hsBool worked = false;
int length, err;
UInt8 buffer[ kGzBufferSize ];
uint8_t buffer[ kGzBufferSize ];
inFile = fopen( uncompressedPath, "rb" );
@ -213,7 +213,7 @@ hsBool plZlibCompress::UncompressToStream( const char * filename, hsStream * s
hsBool worked = false;
int length, err;
UInt8 buffer[ kGzBufferSize ];
uint8_t buffer[ kGzBufferSize ];
inFile = gzopen( filename, "rb" );
@ -248,7 +248,7 @@ hsBool plZlibCompress::CompressToFile( hsStream * s, const char * filename )
hsBool worked = false;
int length, err;
UInt8 buffer[ kGzBufferSize ];
uint8_t buffer[ kGzBufferSize ];
outFile = gzopen( filename, "wb" );

View File

@ -49,14 +49,14 @@ class hsStream;
class plZlibCompress : public plCompress
{
protected:
hsBool ICopyBuffers(UInt8** bufIn, UInt32* bufLenIn, char* bufOut, UInt32 bufLenOut, int offset, bool ok );
hsBool ICopyBuffers(uint8_t** bufIn, uint32_t* bufLenIn, char* bufOut, uint32_t bufLenOut, int offset, bool ok );
public:
hsBool Uncompress(UInt8* bufOut, UInt32* bufLenOut, const UInt8* bufIn, UInt32 bufLenIn);
hsBool Compress(UInt8* bufOut, UInt32* bufLenOut, const UInt8* bufIn, UInt32 bufLenIn);
hsBool Uncompress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn);
hsBool Compress(uint8_t* bufOut, uint32_t* bufLenOut, const uint8_t* bufIn, uint32_t bufLenIn);
// in place versions
hsBool Uncompress(UInt8** bufIn, UInt32* bufLenIn, UInt32 maxBufLenOut, int offset=0);
hsBool Compress(UInt8** bufIn, UInt32* bufLenIn, int offset=0);
hsBool Uncompress(uint8_t** bufIn, uint32_t* bufLenIn, uint32_t maxBufLenOut, int offset=0);
hsBool Compress(uint8_t** bufIn, uint32_t* bufLenIn, int offset=0);
// .gz versions
static hsBool UncompressFile( const char *compressedPath, const char *destPath );

View File

@ -63,15 +63,15 @@ plZlibStream::~plZlibStream()
hsBool plZlibStream::Open(const char* filename, const char* mode)
{
wchar* wFilename = hsStringToWString(filename);
wchar* wMode = hsStringToWString(mode);
wchar_t* wFilename = hsStringToWString(filename);
wchar_t* wMode = hsStringToWString(mode);
hsBool ret = Open(wFilename, wMode);
delete [] wFilename;
delete [] wMode;
return ret;
}
hsBool plZlibStream::Open(const wchar* filename, const wchar* mode)
hsBool plZlibStream::Open(const wchar_t* filename, const wchar_t* mode)
{
fFilename = filename;
fMode = mode;
@ -99,9 +99,9 @@ hsBool plZlibStream::Close()
return true;
}
UInt32 plZlibStream::Write(UInt32 byteCount, const void* buffer)
uint32_t plZlibStream::Write(uint32_t byteCount, const void* buffer)
{
UInt8* byteBuf = (UInt8*)buffer;
uint8_t* byteBuf = (uint8_t*)buffer;
// Check if we've read in the full gzip header yet
if (fHeader == kNeedMoreData)
@ -132,9 +132,9 @@ UInt32 plZlibStream::Write(UInt32 byteCount, const void* buffer)
while (zstream->avail_in != 0)
{
zstream->avail_out = sizeof(outBuf);
zstream->next_out = (UInt8*)outBuf;
zstream->next_out = (uint8_t*)outBuf;
UInt32 amtWritten = zstream->total_out;
uint32_t amtWritten = zstream->total_out;
int ret = inflate(zstream, Z_NO_FLUSH);
@ -163,7 +163,7 @@ UInt32 plZlibStream::Write(UInt32 byteCount, const void* buffer)
return byteCount;
}
int plZlibStream::IValidateGzHeader(UInt32 byteCount, const void* buffer)
int plZlibStream::IValidateGzHeader(uint32_t byteCount, const void* buffer)
{
// Ripped from gzio.cpp
#define HEAD_CRC 0x02
@ -179,13 +179,13 @@ int plZlibStream::IValidateGzHeader(UInt32 byteCount, const void* buffer)
int initCacheSize = fHeaderCache.size();
for (i = 0; i < byteCount; i++)
fHeaderCache.push_back(((UInt8*)buffer)[i]);
fHeaderCache.push_back(((uint8_t*)buffer)[i]);
hsReadOnlyStream s(fHeaderCache.size(), &fHeaderCache[0]);
// Check the gzip magic header
for (i = 0; i < 2; i++)
{
UInt8 c = s.ReadByte();
uint8_t c = s.ReadByte();
if (c != gz_magic[i])
{
CheckForEnd();
@ -211,7 +211,7 @@ int plZlibStream::IValidateGzHeader(UInt32 byteCount, const void* buffer)
if ((flags & EXTRA_FIELD) != 0)
{
// skip the extra field
UInt16 len = s.ReadLE16();
uint16_t len = s.ReadLE16();
while (len-- != 0 && s.ReadByte())
{
CheckForEnd();
@ -247,8 +247,8 @@ int plZlibStream::IValidateGzHeader(UInt32 byteCount, const void* buffer)
CheckForEnd();
UInt32 headerSize = s.GetPosition();
UInt32 clipBuffer = headerSize - initCacheSize;
uint32_t headerSize = s.GetPosition();
uint32_t clipBuffer = headerSize - initCacheSize;
// Initialize the zlib stream
z_streamp zstream = NEW(z_stream_s);
@ -257,7 +257,7 @@ int plZlibStream::IValidateGzHeader(UInt32 byteCount, const void* buffer)
zstream->zfree = ZlibFree;
zstream->opaque = nil;
zstream->avail_in = byteCount - clipBuffer;
zstream->next_in = (UInt8*)&fHeaderCache[clipBuffer];
zstream->next_in = (uint8_t*)&fHeaderCache[clipBuffer];
// Gotta use inflateInit2, because there's no header for zlib to look at.
// The -15 tells it to not try and find a header
bool initOk = (inflateInit2(zstream, -15) == Z_OK);
@ -283,13 +283,13 @@ hsBool plZlibStream::AtEnd()
return true;
}
UInt32 plZlibStream::Read(UInt32 byteCount, void* buffer)
uint32_t plZlibStream::Read(uint32_t byteCount, void* buffer)
{
hsAssert(0, "Read not supported");
return 0;
}
void plZlibStream::Skip(UInt32 deltaByteCount)
void plZlibStream::Skip(uint32_t deltaByteCount)
{
hsAssert(0, "Skip not supported");
}
@ -308,7 +308,7 @@ void plZlibStream::FastFwd()
hsAssert(0, "FastFwd not supported");
}
UInt32 plZlibStream::GetEOF()
uint32_t plZlibStream::GetEOF()
{
hsAssert(0, "GetEOF not supported");
return 0;

View File

@ -58,20 +58,20 @@ protected:
enum Validate { kNeedMoreData, kInvalidHeader, kValidHeader };
Validate fHeader;
std::vector<UInt8> fHeaderCache;
std::vector<uint8_t> fHeaderCache;
std::wstring fFilename, fMode; // needed for rewind function
int IValidateGzHeader(UInt32 byteCount, const void* buffer);
int IValidateGzHeader(uint32_t byteCount, const void* buffer);
public:
plZlibStream();
virtual ~plZlibStream();
virtual hsBool Open(const char* filename, const char* mode);
virtual hsBool Open(const wchar* filename, const wchar* mode);
virtual hsBool Open(const wchar_t* filename, const wchar_t* mode);
virtual hsBool Close();
virtual UInt32 Write(UInt32 byteCount, const void* buffer);
virtual uint32_t Write(uint32_t byteCount, const void* buffer);
// Since most functions don't check the return value from Write, you can
// call this after you've passed in all your data to determine if it
@ -80,11 +80,11 @@ public:
// You can't use these
virtual hsBool AtEnd();
virtual UInt32 Read(UInt32 byteCount, void* buffer);
virtual void Skip(UInt32 deltaByteCount);
virtual uint32_t Read(uint32_t byteCount, void* buffer);
virtual void Skip(uint32_t deltaByteCount);
virtual void Rewind();
virtual void FastFwd();
virtual UInt32 GetEOF();
virtual uint32_t GetEOF();
};
#endif // plZlibStream_h_inc